Skip to content

Commit ce27e66

Browse files
dimonomidcesantabot
authored andcommitted
Slightly improve docs for mgos_mqtt.h
PUBLISHED_FROM=db8546313bca38b85d3d8e31b1b58788881405b7
1 parent a66eef8 commit ce27e66

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

include/mgos_mqtt.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
extern "C" {
2424
#endif /* __cplusplus */
2525

26-
/* Initialises global MQTT connection */
27-
bool mgos_mqtt_init(void);
28-
2926
/*
3027
* Subscribe to a specific topic.
3128
* 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,
3936
void mgos_mqtt_add_global_handler(mg_event_handler_t handler, void *ud);
4037

4138
/*
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.
4441
*/
4542
typedef void (*mgos_mqtt_connect_fn_t)(struct mg_connection *c,
4643
const char *client_id,
4744
struct mg_send_mqtt_handshake_opts *opts,
4845
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+
*/
4951
void mgos_mqtt_set_connect_fn(mgos_mqtt_connect_fn_t cb, void *fn_arg);
5052

5153
/*
@@ -71,6 +73,9 @@ bool mgos_mqtt_global_connect(void);
7173
bool mgos_mqtt_pub(const char *topic, const void *message, size_t len, int qos,
7274
bool retain);
7375

76+
/*
77+
* Callback signature for `mgos_mqtt_sub()` below.
78+
*/
7479
typedef void (*sub_handler_t)(struct mg_connection *nc, const char *topic,
7580
int topic_len, const char *msg, int msg_len,
7681
void *ud);
@@ -79,8 +84,15 @@ typedef void (*sub_handler_t)(struct mg_connection *nc, const char *topic,
7984
*/
8085
void mgos_mqtt_sub(const char *topic, sub_handler_t, void *ud);
8186

87+
/*
88+
* Returns number of pending bytes to send.
89+
*/
8290
size_t mgos_mqtt_num_unsent_bytes(void);
8391

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+
*/
8496
uint16_t mgos_mqtt_get_packet_id(void);
8597

8698
/*

0 commit comments

Comments
 (0)