File tree 3 files changed +10
-17
lines changed
3 files changed +10
-17
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,7 @@ AgentsManagerClass &AgentsManagerClass::getInstance() {
28
28
return instance;
29
29
};
30
30
31
- bool AgentsManagerClass::begin (uint8_t id) {
32
- _servicesList.push_back (id);
31
+ bool AgentsManagerClass::begin () {
33
32
_instances++;
34
33
35
34
if (_state != AgentsManagerStates::END) {
@@ -82,14 +81,7 @@ bool AgentsManagerClass::isBLEAgentEnabled() {
82
81
return _bleAgentEnabled;
83
82
}
84
83
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 () {
93
85
_instances--;
94
86
if (_instances == 0 ) {
95
87
std::for_each (_agentsList.begin (), _agentsList.end (), [](ConfiguratorAgent *agent) {
Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ enum class RequestType: int { NONE = -1,
33
33
class AgentsManagerClass {
34
34
public:
35
35
static AgentsManagerClass &getInstance ();
36
- bool begin (uint8_t id );
37
- bool end (uint8_t id );
36
+ bool begin ();
37
+ bool end ();
38
38
void disconnect ();
39
39
AgentsManagerStates poll ();
40
40
void enableBLEAgent (bool enable);
@@ -54,7 +54,6 @@ class AgentsManagerClass {
54
54
AgentsManagerClass ();
55
55
AgentsManagerStates _state;
56
56
std::list<ConfiguratorAgent *> _agentsList;
57
- std::list<uint8_t > _servicesList;
58
57
ConfiguratorRequestHandler _reqHandlers[6 ];
59
58
ReturnTimestamp _returnTimestampCb;
60
59
ReturnNetworkSettings _returnNetworkSettingsCb;
Original file line number Diff line number Diff line change 18
18
#endif
19
19
#include " NetworkConfigurator.h"
20
20
21
- #define SERVICE_ID_FOR_AGENTMANAGER 0xB0
22
-
23
21
#define NC_CONNECTION_RETRY_TIMER_ms 120000
24
22
#define NC_CONNECTION_TIMEOUT_ms 15000
25
23
#define NC_UPDATE_NETWORK_OPTIONS_TIMER_ms 120000
@@ -73,7 +71,7 @@ bool NetworkConfiguratorClass::begin() {
73
71
74
72
_agentsManager->addRequestHandler (RequestType::GET_WIFI_FW_VERSION, getWiFiFWVersionHandler);
75
73
76
- if (!_agentsManager->begin (SERVICE_ID_FOR_AGENTMANAGER )) { // TODO check if this is needed if the counter is enough
74
+ if (!_agentsManager->begin ()) {
77
75
DEBUG_ERROR (" NetworkConfiguratorClass::%s Failed to initialize the AgentsManagerClass" , __FUNCTION__);
78
76
}
79
77
@@ -155,12 +153,16 @@ bool NetworkConfiguratorClass::resetStoredConfiguration() {
155
153
}
156
154
157
155
bool NetworkConfiguratorClass::end () {
156
+ if (_state == NetworkConfiguratorStates::END) {
157
+ return true ;
158
+ }
159
+
158
160
_agentsManager->removeReturnNetworkSettingsCallback ();
159
161
_agentsManager->removeRequestHandler (RequestType::SCAN);
160
162
_agentsManager->removeRequestHandler (RequestType::CONNECT);
161
163
_agentsManager->removeRequestHandler (RequestType::GET_WIFI_FW_VERSION);
162
164
_state = NetworkConfiguratorStates::END;
163
- return _agentsManager->end (SERVICE_ID_FOR_AGENTMANAGER );
165
+ return _agentsManager->end ();
164
166
}
165
167
166
168
bool NetworkConfiguratorClass::scanNetworkOptions () {
You can’t perform that action at this time.
0 commit comments