A demand-based slot assignment algorithm for energy-aware reliable data transmission in wireless sensor networks