diff --git a/src/WiFiConnectionHandler.cpp b/src/WiFiConnectionHandler.cpp index a736f29..699a895 100644 --- a/src/WiFiConnectionHandler.cpp +++ b/src/WiFiConnectionHandler.cpp @@ -16,6 +16,7 @@ #ifdef BOARD_HAS_WIFI /* Only compile if the board has WiFi */ #include "WiFiConnectionHandler.h" +#include "connectionHandlerUtils/wifiSupport.h" /****************************************************************************** CONSTANTS @@ -90,7 +91,7 @@ NetworkConnectionState WiFiConnectionHandler::update_handleInit() #endif #if !defined(ARDUINO_ARCH_ESP8266) && !defined(ARDUINO_ARCH_ESP32) - if (WiFi.status() == NETWORK_HARDWARE_ERROR) + if (!isWifiModulePresent() || WiFi.status() == NETWORK_HARDWARE_ERROR) { #if !defined(__AVR__) DEBUG_ERROR(F("WiFi Hardware failure.\nMake sure you are using a WiFi enabled board/shield.")); diff --git a/src/connectionHandlerUtils/wifiSupport.h b/src/connectionHandlerUtils/wifiSupport.h new file mode 100644 index 0000000..f29e9cd --- /dev/null +++ b/src/connectionHandlerUtils/wifiSupport.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) Arduino SA + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "ConnectionHandlerDefinitions.h" + +#if defined(ARDUINO_OPTA) && !defined(ARDUINO_ARCH_ZEPHYR) +#include +extern uint8_t* boardInfo(); +#endif + +/* Depending on the board there may be hardware differences that cannot be established at compile + * time, for instance opta have factory variants without wifi module present. + * in order to check for this, we need to check variant configuration at runtime + */ +inline bool isWifiModulePresent() { +#if defined(ARDUINO_OPTA) && !defined(ARDUINO_ARCH_ZEPHYR) + OptaBoardInfo* info = reinterpret_cast(boardInfo()); + return info->_board_functionalities.wifi == 1; +#elif defined(BOARD_HAS_WIFI) + return true; +#else + return false; +#endif +}