Programming Wireless Sensor Networks: Fundamental Concepts and State of the Art