Managed to get our first MQTT connection started!
The code is now pretty messy, as I've just been hacking it together so far. It's basically hardcoded, so the next steps will be to parameterise everything. I also need to rethink the data structures, and function names/structures. I need to make this feel more like an API to be called by a user. This will naturally help organize the functions.
This commit is contained in:
parent
ff0c7fac97
commit
65d0810b5e
2 changed files with 119 additions and 14 deletions
16
mqtt.h
16
mqtt.h
|
@ -23,10 +23,16 @@ typedef enum mqtt_message_enum
|
|||
} mqtt_message_type;
|
||||
|
||||
typedef struct {
|
||||
uint8_t *message;
|
||||
uint16_t length;
|
||||
mqtt_message_type type;
|
||||
} mqtt_message_t;
|
||||
uint8_t *fixedHeader;
|
||||
uint32_t fixedHeader_len;
|
||||
uint8_t *varHeader;
|
||||
uint32_t varHeader_len;
|
||||
uint8_t *payload;
|
||||
uint32_t payload_len;
|
||||
uint32_t length;
|
||||
mqtt_message_type msgType;
|
||||
} mqtt_packet_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t ip[4];
|
||||
|
@ -47,5 +53,5 @@ LOCAL void ICACHE_FLASH_ATTR reconnected_callback(void *arg, sint8 err);
|
|||
LOCAL void ICACHE_FLASH_ATTR connected_callback(void *arg);
|
||||
LOCAL void ICACHE_FLASH_ATTR data_recv_callback(void *arg, char *pdata, unsigned short len);
|
||||
LOCAL void ICACHE_FLASH_ATTR data_sent_callback(void *arg);
|
||||
LOCAL uint8_t ICACHE_FLASH_ATTR mqtt_send(mqtt_session_t *session, mqtt_message_t *message);
|
||||
LOCAL uint8_t ICACHE_FLASH_ATTR mqtt_send(mqtt_session_t *session, uint8_t *data, uint32_t len, mqtt_message_type msgType);
|
||||
LOCAL uint8_t ICACHE_FLASH_ATTR mqtt_connect(mqtt_session_t *session);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue