Enhancing the Quality of Service and Energy Efficiency of WiFi-based IoT Networks