Skip to content

Commit 2531c39

Browse files
committed
Fix a connection stopping condition.
1 parent 0f5983b commit 2531c39

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: src/MqttClient.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ int MqttClient::endMessage()
205205
{
206206
if (!_txStreamPayload) {
207207
if (!publishHeader(_txPayloadBufferIndex) ||
208-
(clientWrite(_txPayloadBuffer, _txPayloadBufferIndex) != _txPayloadBufferIndex)) {
208+
(clientWrite(_txPayloadBuffer, _txPayloadBufferIndex) < _txPayloadBufferIndex)) {
209209
stop();
210210

211211
return 0;
@@ -439,17 +439,17 @@ void MqttClient::poll()
439439
if ((b & 0x80) == 0) { // length done
440440
bool malformedResponse = false;
441441

442-
if (_rxType == MQTT_CONNACK ||
442+
if (_rxType == MQTT_CONNACK ||
443443
_rxType == MQTT_PUBACK ||
444-
_rxType == MQTT_PUBREC ||
444+
_rxType == MQTT_PUBREC ||
445445
_rxType == MQTT_PUBCOMP ||
446446
_rxType == MQTT_UNSUBACK) {
447447
malformedResponse = (_rxFlags != 0x00 || _rxLength != 2);
448448
} else if (_rxType == MQTT_PUBLISH) {
449449
malformedResponse = ((_rxFlags & 0x06) == 0x06);
450450
} else if (_rxType == MQTT_PUBREL) {
451451
malformedResponse = (_rxFlags != 0x02 || _rxLength != 2);
452-
} else if (_rxType == MQTT_SUBACK) {
452+
} else if (_rxType == MQTT_SUBACK) {
453453
malformedResponse = (_rxFlags != 0x00 || _rxLength != 3);
454454
} else if (_rxType == MQTT_PINGRESP) {
455455
malformedResponse = (_rxFlags != 0x00 || _rxLength != 0);
@@ -522,7 +522,7 @@ void MqttClient::poll()
522522
if (_rxMessageIndex == 2) {
523523
_rxMessageTopicLength = (_rxMessageBuffer[0] << 8) | _rxMessageBuffer[1];
524524
_rxLength -= 2;
525-
525+
526526
_rxMessageTopic = "";
527527
_rxMessageTopic.reserve(_rxMessageTopicLength);
528528

@@ -705,7 +705,7 @@ int MqttClient::read(uint8_t *buf, size_t size)
705705

706706
if (b == -1) {
707707
break;
708-
}
708+
}
709709

710710
result++;
711711
*buf++ = b;

0 commit comments

Comments
 (0)