Skip to content

Commit 895498c

Browse files
committed
Apparently the GSM modem is unhappy if there are filesystem ops originating from the OTA code part during establishment of connections, pulling OTA code at the very front up update solves this problem
1 parent 5f00432 commit 895498c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/ArduinoIoTCloudTCP.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
166166

167167
void ArduinoIoTCloudTCP::update()
168168
{
169+
#if OTA_ENABLED
170+
/* If a _ota_logic object has been instantiated then we are spinning its
171+
* 'update' method here in order to process incoming data and generally
172+
* to transition to the OTA logic update states.
173+
*/
174+
OTAError const err = _ota_logic.update();
175+
_ota_error = static_cast<int>(err);
176+
#endif /* OTA_ENABLED */
177+
169178
/* Run through the state machine. */
170179
State next_state = _state;
171180
switch (_state)
@@ -180,17 +189,9 @@ void ArduinoIoTCloudTCP::update()
180189
_state = next_state;
181190

182191
/* Check for new data from the MQTT client. */
183-
if (_mqttClient.connected())
184-
_mqttClient.poll();
185-
186-
#if OTA_ENABLED
187-
/* If a _ota_logic object has been instantiated then we are spinning its
188-
* 'update' method here in order to process incoming data and generally
189-
* to transition to the OTA logic update states.
190-
*/
191-
OTAError const err = _ota_logic.update();
192-
_ota_error = static_cast<int>(err);
193-
#endif /* OTA_ENABLED */
192+
if ((_state == State::SubscribeMqttTopics) || (_state == State::RequestLastValues) || (_state == State::Connected))
193+
if (_mqttClient.connected())
194+
_mqttClient.poll();
194195
}
195196

196197
int ArduinoIoTCloudTCP::connected()

0 commit comments

Comments
 (0)