Add Adafruit_MQTT_Subscribe::datalen
This stores the number of valid bytes in lastread. Having access to this information allows transmitting binary data as well, containing embedded nul bytes.
This commit is contained in:
parent
22c3533745
commit
22b77ecb68
@ -234,6 +234,7 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::readSubscription(int16_t timeout) {
|
|||||||
}
|
}
|
||||||
// extract out just the data, into the subscription object itself
|
// extract out just the data, into the subscription object itself
|
||||||
memcpy(subscriptions[i]->lastread, buffer+4+topiclen, datalen);
|
memcpy(subscriptions[i]->lastread, buffer+4+topiclen, datalen);
|
||||||
|
subscriptions[i]->datalen = datalen;
|
||||||
DEBUG_PRINT(F("Data len: ")); DEBUG_PRINTLN(datalen);
|
DEBUG_PRINT(F("Data len: ")); DEBUG_PRINTLN(datalen);
|
||||||
DEBUG_PRINT(F("Data: ")); DEBUG_PRINTLN((char *)subscriptions[i]->lastread);
|
DEBUG_PRINT(F("Data: ")); DEBUG_PRINTLN((char *)subscriptions[i]->lastread);
|
||||||
|
|
||||||
|
@ -203,6 +203,9 @@ class Adafruit_MQTT_Subscribe {
|
|||||||
uint8_t qos;
|
uint8_t qos;
|
||||||
|
|
||||||
uint8_t lastread[SUBSCRIPTIONDATALEN];
|
uint8_t lastread[SUBSCRIPTIONDATALEN];
|
||||||
|
// Number valid bytes in lastread. Limited to SUBSCRIPTIONDATALEN-1 to
|
||||||
|
// ensure nul terminating lastread.
|
||||||
|
uint8_t datalen;
|
||||||
private:
|
private:
|
||||||
Adafruit_MQTT *mqtt;
|
Adafruit_MQTT *mqtt;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user