Energy efficient and latency aware adaptive compression in wireless sensor networks