aboutsummaryrefslogtreecommitdiff
path: root/lib/mqtt.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mqtt.h')
-rw-r--r--lib/mqtt.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/mqtt.h b/lib/mqtt.h
index b5e447be5..155fbd60a 100644
--- a/lib/mqtt.h
+++ b/lib/mqtt.h
@@ -26,13 +26,22 @@
extern const struct Curl_handler Curl_handler_mqtt;
#endif
+enum mqttstate {
+ MQTT_FIRST, /* 0 */
+ MQTT_REMAINING_LENGTH, /* 1 */
+ MQTT_CONNACK, /* 2 */
+ MQTT_SUBACK, /* 3 */
+ MQTT_SUBACK_COMING, /* 4 - the SUBACK remainder */
+ MQTT_PUBWAIT, /* 5 - wait for publish */
+ MQTT_PUB_REMAIN, /* 6 - wait for the remainder of the publish */
+
+ MQTT_NOSTATE = 99 /* never an actual state */
+};
+
struct mqtt_conn {
- enum {
- MQTT_CONNACK,
- MQTT_SUBACK,
- MQTT_SUBWAIT, /* wait for subscribe response */
- MQTT_SUB_REMAIN /* wait for the remainder of the subscribe response */
- } state;
+ enum mqttstate state;
+ enum mqttstate nextstate; /* switch to this after remaining length is
+ done */
unsigned int packetid;
};
@@ -41,9 +50,10 @@ struct MQTT {
char *sendleftovers;
size_t nsend; /* size of sendleftovers */
- /* when receving a PUBLISH */
+ /* when receving */
size_t npacket; /* byte counter */
unsigned char firstbyte;
+ size_t remaining_length;
};
#endif /* HEADER_CURL_MQTT_H */