Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/WiFiConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#ifdef BOARD_HAS_WIFI /* Only compile if the board has WiFi */
#include "WiFiConnectionHandler.h"
#include "connectionHandlerUtils/wifiSupport.h"

/******************************************************************************
CONSTANTS
Expand Down Expand Up @@ -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."));
Expand Down
31 changes: 31 additions & 0 deletions src/connectionHandlerUtils/wifiSupport.h
Original file line number Diff line number Diff line change
@@ -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 <opta_info.h>
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<OptaBoardInfo*>(boardInfo());
return info->_board_functionalities.wifi == 1;
#elif defined(BOARD_HAS_WIFI)
return true;
#else
return false;
#endif
}
Loading