A device node, comprising: - a processor running an operating system and an application layer; and - memory in communication with the processor, the processor configured to: - receive, by an application layer manager that tracks an index of current functions running in the device node, an independent software agent from a server computing system in a first tier of a plurality of tiers of a sensor network, with the independent software agent being a dynamically loaded root function that includes at least one rule, wherein the root function is run by the operating system of the device node according to a function priority; - transfer function control to the received at least one rule by either changing the index value corresponding to a function currently running in the device node to an index value of the received rule or asking the application layer manager to change the index value and to verify that a transition to the received at least one rule is an allowed transition; and - execute the at least one rule included in the independent software agent by the operating system of the device node according to the transfer of function control for the device node. - a processor running an operating system and an application layer; and - memory in communication with the processor, the processor configured to: - receive, by an application layer manager that tracks an index of current functions running in the device node, an independent software agent from a server computing system in a first tier of a plurality of tiers of a sensor network, with the independent software agent being a dynamically loaded root function that includes at least one rule, wherein the root function is run by the operating system of the device node according to a function priority; - transfer function control to the received at least one rule by either changing the index value corresponding to a function currently running in the device node to an index value of the received rule or asking the application layer manager to change the index value and to verify that a transition to the received at least one rule is an allowed transition; and - execute the at least one rule included in the independent software agent by the operating system of the device node according to the transfer of function control for the device node. - receive, by an application layer manager that tracks an index of current functions running in the device node, an independent software agent from a server computing system in a first tier of a plurality of tiers of a sensor network, with the independent software agent being a dynamically loaded root function that includes at least one rule, wherein the root function is run by the operating system of the device node according to a function priority; - transfer function control to the received at least one rule by either changing the index value corresponding to a function currently running in the device node to an index value of the received rule or asking the application layer manager to change the index value and to verify that a transition to the received at least one rule is an allowed transition; and - execute the at least one rule included in the independent software agent by the operating system of the device node according to the transfer of function control for the device node. <EOS>