23
23
extern "C" {
24
24
#endif /* __cplusplus */
25
25
26
- /* Initialises global MQTT connection */
27
- bool mgos_mqtt_init (void );
28
-
29
26
/*
30
27
* Subscribe to a specific topic.
31
28
* This handler will receive SUBACK - when first subscribed to the topic,
@@ -39,13 +36,18 @@ void mgos_mqtt_global_subscribe(const struct mg_str topic,
39
36
void mgos_mqtt_add_global_handler (mg_event_handler_t handler , void * ud );
40
37
41
38
/*
42
- * Set connect callback. It is invoked when CONNECT message is about to
43
- * be sent. The callback is responsible to call `mg_send_mqtt_handshake_opt()`
39
+ * Callback signature for `mgos_mqtt_set_connect_fn()`, see its docs for
40
+ * details.
44
41
*/
45
42
typedef void (* mgos_mqtt_connect_fn_t )(struct mg_connection * c ,
46
43
const char * client_id ,
47
44
struct mg_send_mqtt_handshake_opts * opts ,
48
45
void * fn_arg );
46
+
47
+ /*
48
+ * Set connect callback. It is invoked when CONNECT message is about to
49
+ * be sent. The callback is responsible to call `mg_send_mqtt_handshake_opt()`
50
+ */
49
51
void mgos_mqtt_set_connect_fn (mgos_mqtt_connect_fn_t cb , void * fn_arg );
50
52
51
53
/*
@@ -71,6 +73,9 @@ bool mgos_mqtt_global_connect(void);
71
73
bool mgos_mqtt_pub (const char * topic , const void * message , size_t len , int qos ,
72
74
bool retain );
73
75
76
+ /*
77
+ * Callback signature for `mgos_mqtt_sub()` below.
78
+ */
74
79
typedef void (* sub_handler_t )(struct mg_connection * nc , const char * topic ,
75
80
int topic_len , const char * msg , int msg_len ,
76
81
void * ud );
@@ -79,8 +84,15 @@ typedef void (*sub_handler_t)(struct mg_connection *nc, const char *topic,
79
84
*/
80
85
void mgos_mqtt_sub (const char * topic , sub_handler_t , void * ud );
81
86
87
+ /*
88
+ * Returns number of pending bytes to send.
89
+ */
82
90
size_t mgos_mqtt_num_unsent_bytes (void );
83
91
92
+ /*
93
+ * Returns next packet id; the returned value is incremented every time the
94
+ * function is called, and it's never 0 (so after 0xffff it'll be 1)
95
+ */
84
96
uint16_t mgos_mqtt_get_packet_id (void );
85
97
86
98
/*
0 commit comments