-
Notifications
You must be signed in to change notification settings - Fork 30
/
esp_lwmqtt.h
65 lines (52 loc) · 1.66 KB
/
esp_lwmqtt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef ESP_LWMQTT_H
#define ESP_LWMQTT_H
#include <lwmqtt.h>
/**
* The lwmqtt timer object for the esp platform.
*/
typedef struct {
uint32_t deadline;
} esp_lwmqtt_timer_t;
/**
* The lwmqtt timer set callback for the esp platform.
*/
void esp_lwmqtt_timer_set(void *ref, uint32_t timeout);
/**
* The lwmqtt timer get callback for the esp platform.
*/
int32_t esp_lwmqtt_timer_get(void *ref);
/**
* The lwmqtt network object for the esp platform.
*/
typedef struct {
int socket;
} esp_lwmqtt_network_t;
/**
* Initiate a connection to the specified remote hose.
*/
lwmqtt_err_t esp_lwmqtt_network_connect(esp_lwmqtt_network_t *n, char *host, char *port);
/**
* Wait until the socket is connected or a timeout has been reached.
*/
lwmqtt_err_t esp_lwmqtt_network_wait(esp_lwmqtt_network_t *n, bool *connected, uint32_t timeout);
/**
* Terminate the connection.
*/
void esp_lwmqtt_network_disconnect(esp_lwmqtt_network_t *n);
/**
* Will set available to the available amount of data in the underlying network buffer.
*/
lwmqtt_err_t esp_lwmqtt_network_peek(esp_lwmqtt_network_t *n, size_t *available);
/**
* Will wait for a socket until data is available or the timeout has been reached.
*/
lwmqtt_err_t esp_lwmqtt_network_select(esp_lwmqtt_network_t *n, bool *available, uint32_t timeout);
/**
* The lwmqtt network read callback for the esp platform.
*/
lwmqtt_err_t esp_lwmqtt_network_read(void *ref, uint8_t *buf, size_t len, size_t *received, uint32_t timeout);
/**
* The lwmqtt network write callback for the esp platform.
*/
lwmqtt_err_t esp_lwmqtt_network_write(void *ref, uint8_t *buf, size_t len, size_t *sent, uint32_t timeout);
#endif // ESP_LWMQTT_H