@@ -73,6 +73,8 @@ void ArduinoCloudClass::mqttClientBegin(Client& net)
73
73
// MQTT topics definition
74
74
_stdoutTopic = " /a/d/" + _id + " /s/o" ;
75
75
_stdinTopic = " /a/d/" + _id + " /s/i" ;
76
+ _dataTopicIn = " /a/d/" + _id + " /e/i" ;
77
+ _dataTopicOut = " /a/d/" + _id + " /e/o" ;
76
78
77
79
// use onMessage as callback for received mqtt messages
78
80
_mqttClient.onMessageAdvanced (ArduinoCloudClass::onMessage);
@@ -90,7 +92,7 @@ int ArduinoCloudClass::connect()
90
92
return 0 ;
91
93
}
92
94
_mqttClient.subscribe (_stdinTopic);
93
- _mqttClient.subscribe (_dataTopic );
95
+ _mqttClient.subscribe (_dataTopicIn );
94
96
95
97
return 1 ;
96
98
}
@@ -142,7 +144,8 @@ void ArduinoCloudClass::poll(int reconnectionMaxRetries, int reconnectionTimeout
142
144
143
145
// MTTQClient connected!, poll() used to retrieve data from MQTT broker
144
146
_mqttClient.loop ();
145
- uint8_t data[1024 ];
147
+
148
+ uint8_t data[MQTT_BUFFER_SIZE];
146
149
int length = Thing.poll (data, sizeof (data));
147
150
if (length > 0 ) {
148
151
writeProperties (data, length);
@@ -168,7 +171,7 @@ int ArduinoCloudClass::connected()
168
171
169
172
int ArduinoCloudClass::writeProperties (const byte data[], int length)
170
173
{
171
- return _mqttClient.publish (_dataTopic .c_str (), (const char *)data, length);
174
+ return _mqttClient.publish (_dataTopicOut .c_str (), (const char *)data, length);
172
175
}
173
176
174
177
int ArduinoCloudClass::writeStdout (const byte data[], int length)
@@ -186,7 +189,7 @@ void ArduinoCloudClass::handleMessage(char topic[], char bytes[], int length)
186
189
if (_stdinTopic == topic) {
187
190
CloudSerial.appendStdin ((uint8_t *)bytes, length);
188
191
}
189
- if (_dataTopic == topic) {
192
+ if (_dataTopicIn == topic) {
190
193
Thing.decode ((uint8_t *)bytes, length);
191
194
}
192
195
}
0 commit comments