A Calculus for Programming Wireless Sensor Networks