Middleware design for sensor networks