|
1 | 1 | #include "WiFi.h" |
2 | 2 |
|
| 3 | +#if defined(ARDUINO_OPTA) |
| 4 | +#include <opta_info.h> |
| 5 | +extern uint8_t* boardInfo(); |
| 6 | +#endif |
| 7 | + |
3 | 8 | #define SSID_MAX_LENGTH 32 |
4 | 9 | #define SSID_MAX_COUNT 64 |
5 | 10 |
|
@@ -46,8 +51,26 @@ bool arduino::WiFiClass::isVisible(const char* ssid) { |
46 | 51 | return false; |
47 | 52 | } |
48 | 53 |
|
| 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 | + |
49 | 69 | 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 |
51 | 74 | return 0; |
52 | 75 | } |
53 | 76 |
|
@@ -380,6 +403,10 @@ wiced_result_t whd_firmware_check_hook(const char* mounted_name, int mount_err) |
380 | 403 |
|
381 | 404 | #include "whd_version.h" |
382 | 405 | const char* arduino::WiFiClass::firmwareVersion() { |
| 406 | + if(_currentNetworkStatus == WL_NO_MODULE) { |
| 407 | + return ""; |
| 408 | + } |
| 409 | + |
383 | 410 | if (!firmware_available) { |
384 | 411 | /* Try to mount WiFi firmware filesystem */ |
385 | 412 | wiced_filesystem_init(); |
|
0 commit comments