Skip to content

Handle opta lite #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
4 changes: 0 additions & 4 deletions examples/utility/DeleteConfiguration/DeleteConfiguration.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@
#include <GenericConnectionHandler.h>
#include <Arduino_KVStore.h>
#include <Arduino_NetworkConfigurator.h>
#include <configuratorAgents/agents/BLEAgent.h>
#include <configuratorAgents/agents/SerialAgent.h>

KVStore kvstore;
BLEAgentClass BLEAgent;
SerialAgentClass SerialAgent;
GenericConnectionHandler conMan;
NetworkConfiguratorClass NetworkConfigurator(conMan);

Expand Down
1 change: 1 addition & 0 deletions src/ANetworkConfigurator_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#if defined(ARDUINO_OPTA)
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
#define ZERO_TOUCH_ENABLED 1
#define OPTA_WIFI_PID 0x0264
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use _BOARD_PRODUCTID from the core if possible

#define PIN_RECONFIGURE BTN_USER
#define LED_RECONFIGURE LED_USER
#define BOARD_HAS_RGB
Expand Down
28 changes: 28 additions & 0 deletions src/Arduino_NetworkConfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,17 @@ bool NetworkConfiguratorClass::begin() {
memset(&_networkSetting, 0x00, sizeof(models::NetworkSetting));
_ledFeedback->begin();
#ifdef BOARD_HAS_WIFI
#ifdef ARDUINO_OPTA
if(_getPid_() == OPTA_WIFI_PID) {
#endif
String fv = WiFi.firmwareVersion();
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
DEBUG_ERROR(F("The current WiFi firmware version is not the latest and it may cause compatibility issues. Please upgrade the WiFi firmware"));
}

#ifdef ARDUINO_OPTA
}
#endif
_agentsManager->addRequestHandler(RequestType::SCAN, scanReqHandler);

_agentsManager->addRequestHandler(RequestType::GET_WIFI_FW_VERSION, getWiFiFWVersionHandler);
Expand Down Expand Up @@ -294,6 +301,13 @@ bool NetworkConfiguratorClass::insertWiFiAP(WiFiOption &wifiOptObj, char *ssid,

bool NetworkConfiguratorClass::scanWiFiNetworks(WiFiOption &wifiOptObj) {
wifiOptObj.numDiscoveredWiFiNetworks = 0;

#if defined(ARDUINO_OPTA)
if(_getPid_() != OPTA_WIFI_PID) {
return true; // Skip scanning if it's not the Opta with WiFi
}
#endif

#if defined(ARDUINO_UNOR4_WIFI)
WiFi.end();
#endif
Expand Down Expand Up @@ -349,6 +363,14 @@ bool NetworkConfiguratorClass::handleConnectRequest() {
return false;
}

#ifdef ARDUINO_OPTA
if(_networkSetting.type == NetworkAdapter::WIFI && _getPid_() != OPTA_WIFI_PID) {
DEBUG_WARNING("NetworkConfiguratorClass::%s WiFi configuration is not supported on this board", __FUNCTION__);
sendStatus(StatusMessage::INVALID_PARAMS);
return false;
}
#endif

if (_kvstore != nullptr) {
if (!_kvstore->begin()) {
DEBUG_ERROR("NetworkConfiguratorClass::%s error initializing kvstore", __FUNCTION__);
Expand Down Expand Up @@ -469,7 +491,13 @@ String NetworkConfiguratorClass::decodeConnectionErrorMessage(NetworkConnectionS
void NetworkConfiguratorClass::handleGetWiFiFWVersion() {
String fwVersion = "";
#ifdef BOARD_HAS_WIFI
#ifdef ARDUINO_OPTA
if(_getPid_() == OPTA_WIFI_PID) {
#endif
fwVersion = WiFi.firmwareVersion();
#ifdef ARDUINO_OPTA
}
#endif
#endif
ProvisioningOutputMessage fwVersionMsg = { MessageOutputType::WIFI_FW_VERSION };
fwVersionMsg.m.wifiFwVersion = fwVersion.c_str();
Expand Down
6 changes: 6 additions & 0 deletions src/configuratorAgents/AgentsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
******************************************************************************/

bool AgentsManagerClass::addAgent(ConfiguratorAgent &agent) {
#ifdef ARDUINO_OPTA
if(agent.getAgentType() == ConfiguratorAgent::AgentTypes::BLE && _getPid_() != OPTA_WIFI_PID) {
return false;
}
#endif
_agentsList.push_back(&agent);
return true;
}

AgentsManagerClass &AgentsManagerClass::getInstance() {
Expand Down
Loading