Skip to content

Commit 1c2f0fb

Browse files
committed
add Config.h
1 parent 3a944c5 commit 1c2f0fb

File tree

13 files changed

+275
-86
lines changed

13 files changed

+275
-86
lines changed

src/ANetworkConfigurator_Config.h

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
Copyright (c) 2024 Arduino SA
3+
4+
This Source Code Form is subject to the terms of the Mozilla Public
5+
License, v. 2.0. If a copy of the MPL was not distributed with this
6+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+
*/
8+
#pragma once
9+
10+
#define NETWORK_CONFIGURATOR_COMPATIBLE 0
11+
#define ZERO_TOUCH_ENABLED 0
12+
13+
#if defined(ARDUINO_SAMD_MKRWIFI1010)
14+
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
15+
#define PIN_RECONFIGURE 7
16+
#define LED_RECONFIGURE LED_BUILTIN
17+
#define BOARD_HAS_RGB
18+
#define GREEN_LED 25
19+
#define BLUE_LED 27
20+
#define RED_LED 26
21+
#define BOARD_USE_NINA
22+
#define LED_ON HIGH
23+
#define LED_OFF LOW
24+
#endif
25+
26+
#if defined(ARDUINO_SAMD_NANO_33_IOT)
27+
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
28+
#define PIN_RECONFIGURE 2
29+
#define LED_RECONFIGURE LED_BUILTIN
30+
#define GREEN_LED LED_BUILTIN
31+
#define LED_ON HIGH
32+
#define LED_OFF LOW
33+
#endif
34+
35+
#if defined(ARDUINO_NANO_RP2040_CONNECT)
36+
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
37+
#define PIN_RECONFIGURE 2
38+
#define LED_RECONFIGURE LED_BUILTIN
39+
#define BOARD_HAS_RGB
40+
#define GREEN_LED 25
41+
#define BLUE_LED 26
42+
#define RED_LED 27
43+
#define BOARD_USE_NINA
44+
#define LED_ON LOW
45+
#define LED_OFF HIGH
46+
#endif
47+
48+
#if defined(ARDUINO_UNOR4_WIFI)
49+
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
50+
#define PIN_RECONFIGURE 2
51+
#define LED_RECONFIGURE LED_BUILTIN
52+
#define GREEN_LED LED_BUILTIN
53+
#define LED_ON HIGH
54+
#define LED_OFF LOW
55+
#define BOARD_HAS_LED_MATRIX
56+
#endif
57+
58+
#if defined(ARDUINO_PORTENTA_H7_M7)
59+
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
60+
#define ZERO_TOUCH_ENABLED 1
61+
#define PIN_RECONFIGURE 2 //TODO update doc and test
62+
#define LED_RECONFIGURE LED_BUILTIN
63+
#define BOARD_HAS_RGB
64+
#define GREEN_LED LEDG
65+
#define BLUE_LED LEDB
66+
#define RED_LED LEDR
67+
#define LED_ON LOW
68+
#define LED_OFF HIGH
69+
#endif
70+
71+
#if defined(ARDUINO_OPTA)
72+
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
73+
#define ZERO_TOUCH_ENABLED 1
74+
#define PIN_RECONFIGURE BTN_USER
75+
#define LED_RECONFIGURE LED_USER
76+
#define BOARD_HAS_RGB
77+
#define GREEN_LED LED_BUILTIN
78+
#define BLUE_LED LED_USER
79+
#define RED_LED LEDR
80+
#define LED_ON HIGH
81+
#define LED_OFF LOW
82+
#endif
83+
84+
85+
#if defined(ARDUINO_GIGA)
86+
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
87+
#define PIN_RECONFIGURE 2
88+
#define LED_RECONFIGURE LED_BUILTIN
89+
#define BOARD_HAS_RGB
90+
#define GREEN_LED LEDG
91+
#define BLUE_LED LEDB
92+
#define RED_LED LEDR
93+
#define LED_ON LOW
94+
#define LED_OFF HIGH
95+
#endif
96+
97+
#if defined(ARDUINO_NICLA_VISION)
98+
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
99+
#define PIN_RECONFIGURE 2
100+
#define LED_RECONFIGURE LED_BUILTIN
101+
#define BOARD_HAS_RGB
102+
#define GREEN_LED LEDG
103+
#define BLUE_LED LEDB
104+
#define RED_LED LEDR
105+
#define LED_ON LOW
106+
#define LED_OFF HIGH
107+
#endif
108+
109+
#if defined(ARDUINO_PORTENTA_C33)
110+
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
111+
#define ZERO_TOUCH_ENABLED 1
112+
#define PIN_RECONFIGURE 2
113+
#define LED_RECONFIGURE LED_BUILTIN
114+
#define BOARD_HAS_RGB
115+
#define GREEN_LED LEDG
116+
#define BLUE_LED LEDB
117+
#define RED_LED LEDR
118+
#define LED_ON LOW
119+
#define LED_OFF HIGH
120+
#endif
121+
122+
#ifndef RESET_HOLD_TIME
123+
#define RESET_HOLD_TIME 3000000
124+
#endif
125+
126+
#ifndef BCP_DEBUG_PACKET
127+
#define BCP_DEBUG_PACKET 0
128+
#endif

src/ConfiguratorAgents/AgentsManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
License, v. 2.0. If a copy of the MPL was not distributed with this
66
file, You can obtain one at http://mozilla.org/MPL/2.0/.
77
*/
8+
#include "ANetworkConfigurator_Config.h"
9+
#if NETWORK_CONFIGURATOR_COMPATIBLE
810

911
#include <Arduino_DebugUtils.h>
1012
#include <algorithm>
@@ -408,3 +410,5 @@ void AgentsManagerClass::startBLEAgent() {
408410
}
409411
});
410412
}
413+
414+
#endif // NETWORK_CONFIGURATOR_COMPATIBLE

src/ConfiguratorAgents/NetworkOptionsDefinitions.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
#define MAX_WIFI_NETWORKS 20
1212

1313
enum class NetworkOptionsClass { NONE,
14-
WIFI,
15-
LAN };
14+
WIFI };
1615

1716
typedef struct {
1817
char *SSID;

src/ConfiguratorAgents/agents/BLE/BLEAgent.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "Utility/LEDFeedback/LEDFeedback.h"
2121
#include "ConfiguratorAgents/agents/BoardConfigurationProtocol/cbor/CBORInstances.h"
2222

23-
#define DEBUG_PACKET
2423
#define BASE_LOCAL_NAME "Arduino"
2524
#define ARDUINO_COMPANY_ID 0x09A3
2625

src/ConfiguratorAgents/agents/BoardConfigurationProtocol/BoardConfigurationProtocol.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
License, v. 2.0. If a copy of the MPL was not distributed with this
66
file, You can obtain one at http://mozilla.org/MPL/2.0/.
77
*/
8+
#include "ANetworkConfigurator_Config.h"
9+
#if NETWORK_CONFIGURATOR_COMPATIBLE
10+
811
#include "BoardConfigurationProtocol.h"
912
#include "Arduino_DebugUtils.h"
1013
#include "CBORAdapter.h"
1114
#include "cbor/CBOR.h"
1215

13-
#ifndef BCP_DEBUG_PACKET
14-
#define BCP_DEBUG_PACKET 0
15-
#endif
16-
1716
#define PACKET_VALIDITY_MS 30000
1817

1918
/******************************************************************************
@@ -370,3 +369,5 @@ void BoardConfigurationProtocol::printPacket(const char *label, const uint8_t *d
370369
}
371370
Debug.newlineOn();
372371
}
372+
373+
#endif // NETWORK_CONFIGURATOR_COMPATIBLE

src/ConfiguratorAgents/agents/BoardConfigurationProtocol/CBORAdapter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
License, v. 2.0. If a copy of the MPL was not distributed with this
66
file, You can obtain one at http://mozilla.org/MPL/2.0/.
77
*/
8+
#include "ANetworkConfigurator_Config.h"
9+
#if NETWORK_CONFIGURATOR_COMPATIBLE
810

911
#include "CBORAdapter.h"
1012
#include "cbor/MessageEncoder.h"
@@ -147,3 +149,5 @@ bool CBORAdapter::adaptWiFiOptions(const WiFiOption *wifiOptions, uint8_t *data,
147149

148150
return status == MessageEncoder::Status::Complete ? true : false;
149151
}
152+
153+
#endif // NETWORK_CONFIGURATOR_COMPATIBLE

src/ConfiguratorAgents/agents/BoardConfigurationProtocol/PacketManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
License, v. 2.0. If a copy of the MPL was not distributed with this
66
file, You can obtain one at http://mozilla.org/MPL/2.0/.
77
*/
8+
#include "ANetworkConfigurator_Config.h"
9+
#if NETWORK_CONFIGURATOR_COMPATIBLE
810

911
#include <Arduino_DebugUtils.h>
1012
#include "PacketManager.h"
@@ -199,3 +201,5 @@ namespace PacketManager {
199201
return ReceivingState::WAITING_END;
200202
}
201203
}
204+
205+
#endif // NETWORK_CONFIGURATOR_COMPATIBLE

src/ConfiguratorAgents/agents/BoardConfigurationProtocol/cbor/Decoder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
License, v. 2.0. If a copy of the MPL was not distributed with this
66
file, You can obtain one at http://mozilla.org/MPL/2.0/.
77
*/
8+
#include "ANetworkConfigurator_Config.h"
9+
#if NETWORK_CONFIGURATOR_COMPATIBLE
810

911
#include "Decoder.h"
1012
#include <settings/settings_default.h>
@@ -403,3 +405,5 @@ MessageDecoder::Status GSMConfigProvisioningMessageDecoder::decode(CborValue* it
403405
return extractCellularFields(iter, &provisioningNetworkConfig->networkSetting.gsm);
404406
}
405407
#endif
408+
409+
#endif // NETWORK_CONFIGURATOR_COMPATIBLE

src/ConfiguratorAgents/agents/BoardConfigurationProtocol/cbor/Encoder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
License, v. 2.0. If a copy of the MPL was not distributed with this
66
file, You can obtain one at http://mozilla.org/MPL/2.0/.
77
*/
8+
#include "ANetworkConfigurator_Config.h"
9+
#if NETWORK_CONFIGURATOR_COMPATIBLE
810

911
#include "Encoder.h"
1012

@@ -132,3 +134,5 @@ MessageEncoder::Status WiFiFWVersionProvisioningMessageEncoder::encode(CborEncod
132134

133135
return MessageEncoder::Status::Complete;
134136
}
137+
138+
#endif // NETWORK_CONFIGURATOR_COMPATIBLE

src/NetworkConfigurator.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
License, v. 2.0. If a copy of the MPL was not distributed with this
66
file, You can obtain one at http://mozilla.org/MPL/2.0/.
77
*/
8+
#include "ANetworkConfigurator_Config.h"
9+
#if NETWORK_CONFIGURATOR_COMPATIBLE
810

911
#include <Arduino_DebugUtils.h>
1012
#include "ConnectionHandlerDefinitions.h"
@@ -66,15 +68,15 @@ bool NetworkConfiguratorClass::begin() {
6668

6769
_agentsManager->addRequestHandler(RequestType::GET_WIFI_FW_VERSION, getWiFiFWVersionHandler);
6870

69-
if (!_agentsManager->begin(SERVICE_ID_FOR_AGENTMANAGER)) {
71+
if (!_agentsManager->begin(SERVICE_ID_FOR_AGENTMANAGER)) { //TODO check if this is needed if the counter is enough
7072
DEBUG_ERROR("NetworkConfiguratorClass::%s Failed to initialize the AgentsManagerClass", __FUNCTION__);
7173
}
7274

7375
_connectionTimeout.begin(NC_CONNECTION_TIMEOUT_ms);
7476
_connectionRetryTimer.begin(NC_CONNECTION_RETRY_TIMER_ms);
7577
_resetInput->begin();
7678

77-
#ifdef BOARD_HAS_ETHERNET
79+
#ifdef BOARD_HAS_ETHERNET //TODO Generalize
7880
_networkSetting.type = NetworkAdapter::ETHERNET;
7981
_networkSetting.eth.timeout = 250;
8082
_networkSetting.eth.response_timeout = 500;
@@ -90,7 +92,7 @@ bool NetworkConfiguratorClass::begin() {
9092

9193
NetworkConfiguratorStates NetworkConfiguratorClass::poll() {
9294
NetworkConfiguratorStates nextState = _state;
93-
LEDFeedbackClass::getInstance().poll();
95+
LEDFeedbackClass::getInstance().poll();//TODO rename in update
9496

9597
switch (_state) {
9698
#ifdef BOARD_HAS_ETHERNET
@@ -590,7 +592,7 @@ void NetworkConfiguratorClass::printNetworkSettings() {
590592
#if defined(BOARD_HAS_WIFI)
591593
case NetworkAdapter::WIFI:
592594
DEBUG_INFO("WIFI");
593-
DEBUG_INFO("SSID: %s PSW: %s", _networkSetting.wifi.ssid, _networkSetting.wifi.pwd);
595+
DEBUG_INFO("SSID: %s PSW: %s", _networkSetting.wifi.ssid, _networkSetting.wifi.pwd);//TODO remove psw
594596
break;
595597
#endif
596598

@@ -663,3 +665,4 @@ void NetworkConfiguratorClass::printNetworkSettings() {
663665
break;
664666
}
665667
}
668+
#endif // NETWORK_CONFIGURATOR_COMPATIBLE

0 commit comments

Comments
 (0)