Skip to content

Commit bbbc8fe

Browse files
Merge pull request #1110 from andreagilardoni/opta-rs485-wificheck
Opta rs485 wifi module check
2 parents f4e9813 + 9298439 commit bbbc8fe

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

libraries/WiFi/src/WiFi.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#include "WiFi.h"
22

3+
#if defined(ARDUINO_OPTA)
4+
#include <opta_info.h>
5+
extern uint8_t* boardInfo();
6+
#endif
7+
38
#define SSID_MAX_LENGTH 32
49
#define SSID_MAX_COUNT 64
510

@@ -46,8 +51,26 @@ bool arduino::WiFiClass::isVisible(const char* ssid) {
4651
return false;
4752
}
4853

54+
arduino::WiFiClass::WiFiClass(WiFiInterface* _if)
55+
: wifi_if(_if) {
56+
#if defined(ARDUINO_OPTA)
57+
/* opta have factory variants without wifi module present. in order to check for this, we need to
58+
* check variant configuration at runtime
59+
*/
60+
61+
OptaBoardInfo* info = reinterpret_cast<OptaBoardInfo*>(boardInfo());
62+
if (info->_board_functionalities.wifi != 1) {
63+
_currentNetworkStatus = WL_NO_MODULE;
64+
wifi_if = nullptr;
65+
}
66+
#endif
67+
}
68+
4969
int arduino::WiFiClass::begin(const char* ssid, const char* passphrase, wl_enc_type security) {
50-
if (wifi_if == nullptr) {
70+
if (wifi_if == nullptr || _currentNetworkStatus == WL_NO_MODULE) {
71+
#if defined(ARDUINO_OPTA)
72+
Serial.println("This Arduino Opta device doesn't support wifi connectivity");
73+
#endif
5174
return 0;
5275
}
5376

@@ -380,6 +403,10 @@ wiced_result_t whd_firmware_check_hook(const char* mounted_name, int mount_err)
380403

381404
#include "whd_version.h"
382405
const char* arduino::WiFiClass::firmwareVersion() {
406+
if(_currentNetworkStatus == WL_NO_MODULE) {
407+
return "";
408+
}
409+
383410
if (!firmware_available) {
384411
/* Try to mount WiFi firmware filesystem */
385412
wiced_filesystem_init();

libraries/WiFi/src/WiFi.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ class WiFiClass : public MbedSocketClass {
5151
static int16_t _state[MAX_SOCK_NUM];
5252
static uint16_t _server_port[MAX_SOCK_NUM];
5353

54-
WiFiClass(WiFiInterface* _if)
55-
: wifi_if(_if){};
54+
WiFiClass(WiFiInterface* _if);
5655

5756
/*
5857
* Get firmware version
5958
*/
60-
static const char* firmwareVersion();
59+
const char* firmwareVersion();
6160

6261
/* Start Wifi connection for OPEN networks
6362
*

0 commit comments

Comments
 (0)