Skip to content

Commit e77616c

Browse files
fixup! ArduinoIoTCloudTCP: switch to messages
1 parent f00cfc9 commit e77616c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/ArduinoIoTCloudTCP.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
188188

189189
_deviceTopicOut = getTopic_deviceout();
190190
_deviceTopicIn = getTopic_devicein();
191+
_messageTopicIn = getTopic_messagein();
192+
_messageTopicOut = getTopic_messageout();
191193

192194
_thing.begin();
193195
_device.begin();
@@ -317,7 +319,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
317319
{
318320
if (_mqttClient.connect(_brokerAddress.c_str(), _brokerPort))
319321
{
320-
_mqttClient.subscribe(getTopic_messagein());
322+
_mqttClient.subscribe(_messageTopicIn);
321323
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s connected to %s:%d", __FUNCTION__, _brokerAddress.c_str(), _brokerPort);
322324
/* Reconfigure timers for next state */
323325
_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)
465467
}
466468

467469
/* Topic for device commands */
468-
if (getTopic_messagein() == topic) {
470+
if (_messageTopicIn == topic) {
469471
CommandDown command;
470472
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s [%d] received %d bytes", __FUNCTION__, millis(), length);
471473
CBORMessageDecoder decoder;
@@ -516,7 +518,7 @@ void ArduinoIoTCloudTCP::sendMessage(Message * msg)
516518

517519
if (encoder.encode(msg, data, bytes_encoded) == Encoder::Status::Complete &&
518520
bytes_encoded > 0) {
519-
write(getTopic_messageout(), data, bytes_encoded);
521+
write(_messageTopicOut, data, bytes_encoded);
520522
} else {
521523
DEBUG_ERROR("error encoding %d", msg->id);
522524
}

0 commit comments

Comments
 (0)