| Begin |
| Switch the working mode of sensor do |
| Case sleeping mode |
| If timer is up then |
| Change to monitoring mode; |
| Else If get activation message then |
| Change to monitoring mode; |
| Else wait; |
| Case monitoring mode |
| Detecting target; |
| If target detected then |
| Broadcast “wake” message to one hop neighbour; |
| Change to target mode; |
| Else |
| Change to sleeping mode until receive “sleep” message; |
| Case target mode |
| If the closest node then |
| Broadcast “wake” message to one hop neighbour; |
| Tracking target; |
| Else |
| Tracking target; |
| If target disappear then |
| Broadcast “sleep” message to one hop neighbour; |
| Change sleeping mode; |
| End |