Protocol Stack and System Software Optimization for Energy Efficient Wireless Embedded Systems