Refactored WiFi protocol handling.