A rule based programming model for wireless sensor networks