@@ -188,6 +188,8 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
188
188
189
189
_deviceTopicOut = getTopic_deviceout ();
190
190
_deviceTopicIn = getTopic_devicein ();
191
+ _messageTopicIn = getTopic_messagein ();
192
+ _messageTopicOut = getTopic_messageout ();
191
193
192
194
_thing.begin ();
193
195
_device.begin ();
@@ -317,7 +319,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
317
319
{
318
320
if (_mqttClient.connect (_brokerAddress.c_str (), _brokerPort))
319
321
{
320
- _mqttClient.subscribe (getTopic_messagein () );
322
+ _mqttClient.subscribe (_messageTopicIn );
321
323
DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s connected to %s:%d" , __FUNCTION__, _brokerAddress.c_str (), _brokerPort);
322
324
/* Reconfigure timers for next state */
323
325
_connection_attempt.begin (AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms, AIOT_CONFIG_MAX_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms);
@@ -465,7 +467,7 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
465
467
}
466
468
467
469
/* Topic for device commands */
468
- if (getTopic_messagein () == topic) {
470
+ if (_messageTopicIn == topic) {
469
471
CommandDown command;
470
472
DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s [%d] received %d bytes" , __FUNCTION__, millis (), length);
471
473
CBORMessageDecoder decoder;
@@ -516,7 +518,7 @@ void ArduinoIoTCloudTCP::sendMessage(Message * msg)
516
518
517
519
if (encoder.encode (msg, data, bytes_encoded) == Encoder::Status::Complete &&
518
520
bytes_encoded > 0 ) {
519
- write (getTopic_messageout () , data, bytes_encoded);
521
+ write (_messageTopicOut , data, bytes_encoded);
520
522
} else {
521
523
DEBUG_ERROR (" error encoding %d" , msg->id );
522
524
}
0 commit comments