Skip to content

Commit ccab1b6

Browse files
committed
remove serviceId
1 parent 4c13ccf commit ccab1b6

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

src/ConfiguratorAgents/AgentsManager.cpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ AgentsManagerClass &AgentsManagerClass::getInstance() {
2828
return instance;
2929
};
3030

31-
bool AgentsManagerClass::begin(uint8_t id) {
32-
_servicesList.push_back(id);
31+
bool AgentsManagerClass::begin() {
3332
_instances++;
3433

3534
if (_state != AgentsManagerStates::END) {
@@ -82,14 +81,7 @@ bool AgentsManagerClass::isBLEAgentEnabled() {
8281
return _bleAgentEnabled;
8382
}
8483

85-
bool AgentsManagerClass::end(uint8_t id) {
86-
std::list<uint8_t>::iterator it = std::find(_servicesList.begin(), _servicesList.end(), id);
87-
if (it != _servicesList.end()) {
88-
_servicesList.erase(it);
89-
} else {
90-
return false;
91-
}
92-
84+
bool AgentsManagerClass::end() {
9385
_instances--;
9486
if (_instances == 0) {
9587
std::for_each(_agentsList.begin(), _agentsList.end(), [](ConfiguratorAgent *agent) {

src/ConfiguratorAgents/AgentsManager.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ enum class RequestType: int { NONE = -1,
3333
class AgentsManagerClass {
3434
public:
3535
static AgentsManagerClass &getInstance();
36-
bool begin(uint8_t id);
37-
bool end(uint8_t id);
36+
bool begin();
37+
bool end();
3838
void disconnect();
3939
AgentsManagerStates poll();
4040
void enableBLEAgent(bool enable);
@@ -54,7 +54,6 @@ class AgentsManagerClass {
5454
AgentsManagerClass();
5555
AgentsManagerStates _state;
5656
std::list<ConfiguratorAgent *> _agentsList;
57-
std::list<uint8_t> _servicesList;
5857
ConfiguratorRequestHandler _reqHandlers[6];
5958
ReturnTimestamp _returnTimestampCb;
6059
ReturnNetworkSettings _returnNetworkSettingsCb;

src/NetworkConfigurator.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#endif
1919
#include "NetworkConfigurator.h"
2020

21-
#define SERVICE_ID_FOR_AGENTMANAGER 0xB0
22-
2321
#define NC_CONNECTION_RETRY_TIMER_ms 120000
2422
#define NC_CONNECTION_TIMEOUT_ms 15000
2523
#define NC_UPDATE_NETWORK_OPTIONS_TIMER_ms 120000
@@ -73,7 +71,7 @@ bool NetworkConfiguratorClass::begin() {
7371

7472
_agentsManager->addRequestHandler(RequestType::GET_WIFI_FW_VERSION, getWiFiFWVersionHandler);
7573

76-
if (!_agentsManager->begin(SERVICE_ID_FOR_AGENTMANAGER)) { //TODO check if this is needed if the counter is enough
74+
if (!_agentsManager->begin()) {
7775
DEBUG_ERROR("NetworkConfiguratorClass::%s Failed to initialize the AgentsManagerClass", __FUNCTION__);
7876
}
7977

@@ -155,12 +153,16 @@ bool NetworkConfiguratorClass::resetStoredConfiguration() {
155153
}
156154

157155
bool NetworkConfiguratorClass::end() {
156+
if (_state == NetworkConfiguratorStates::END) {
157+
return true;
158+
}
159+
158160
_agentsManager->removeReturnNetworkSettingsCallback();
159161
_agentsManager->removeRequestHandler(RequestType::SCAN);
160162
_agentsManager->removeRequestHandler(RequestType::CONNECT);
161163
_agentsManager->removeRequestHandler(RequestType::GET_WIFI_FW_VERSION);
162164
_state = NetworkConfiguratorStates::END;
163-
return _agentsManager->end(SERVICE_ID_FOR_AGENTMANAGER);
165+
return _agentsManager->end();
164166
}
165167

166168
bool NetworkConfiguratorClass::scanNetworkOptions() {

0 commit comments

Comments
 (0)