Thor: Energy Programmable WiFi Networks