7 #ifndef GOLIOTH_INCLUDE_NET_GOLIOTH_H_
8 #define GOLIOTH_INCLUDE_NET_GOLIOTH_H_
12 #include <net/tls_credentials.h>
21 #define GOLIOTH_COAP_MAX_NON_PAYLOAD_LEN 128
23 #define GOLIOTH_MAX_IDENTITY_LEN 32
24 #define GOLIOTH_EMPTY_PACKET_LEN (16 + GOLIOTH_MAX_IDENTITY_LEN)
26 #define GOLIOTH_LIGHTDB_PATH(x) ".d/" x
27 #define GOLIOTH_LIGHTDB_STREAM_PATH(x) ".s/" x
61 struct coap_option
rx_options[CONFIG_GOLIOTH_COAP_MAX_OPTIONS];
68 struct coap_packet *rx);
80 size_t offset,
size_t len,
102 size_t offset,
size_t len,
127 k_mutex_lock(&client->
lock, K_FOREVER);
132 k_mutex_unlock(&client->
lock);
185 uint8_t *identity,
size_t identity_len);
203 sec_tag_t *sec_tag_list,
204 size_t sec_tag_count);
218 struct coap_packet *packet);
235 struct coap_packet *packet,
236 uint8_t *data, uint16_t data_len);
277 enum coap_content_format format,
278 struct coap_reply *reply, coap_reply_t reply_cb);
295 enum coap_content_format format,
296 uint8_t *data, uint16_t data_len);
327 enum coap_content_format format,
328 struct coap_reply *reply, coap_reply_t reply_cb);
346 const char *path,
struct coap_reply *reply,
int golioth_observe_blockwise(struct golioth_client *client, struct golioth_blockwise_observe_ctx *ctx, const char *path, struct coap_reply *reply, golioth_blockwise_observe_received_t received_cb)
Observe resource with blockwise updates.
int golioth_lightdb_set(struct golioth_client *client, const uint8_t *path, enum coap_content_format format, uint8_t *data, uint16_t data_len)
Set value to Golioth's Light DB.
void golioth_blockwise_download_init(struct golioth_client *client, struct golioth_blockwise_download_ctx *ctx)
Initialize blockwise download.
int golioth_ping(struct golioth_client *client)
Send PING message to Golioth.
int golioth_set_proto_coap_udp(struct golioth_client *client, uint8_t *identity, size_t identity_len)
Set UDP as transport protocol.
int golioth_process_rx(struct golioth_client *client)
Process incoming data from Golioth.
int golioth_send_coap(struct golioth_client *client, struct coap_packet *packet)
Send CoAP packet to Golioth.
int golioth_disconnect(struct golioth_client *client)
Disconnect from Golioth.
int(* golioth_blockwise_download_received_t)(struct golioth_blockwise_download_ctx *ctx, const uint8_t *data, size_t offset, size_t len, bool last)
Type of the callback being called when a single block of data is received as part of CoAP response.
Definition: golioth.h:100
int golioth_lightdb_observe(struct golioth_client *client, const uint8_t *path, enum coap_content_format format, struct coap_reply *reply, coap_reply_t reply_cb)
Observe value in Golioth's Light DB.
int golioth_lightdb_delete(struct golioth_client *client, const uint8_t *path)
Delete value in Golioth's Light DB.
int golioth_send_hello(struct golioth_client *client)
Send Hello message to Golioth.
int golioth_send_coap_payload(struct golioth_client *client, struct coap_packet *packet, uint8_t *data, uint16_t data_len)
Send CoAP packet with separate payload to Golioth.
int golioth_lightdb_get(struct golioth_client *client, const uint8_t *path, enum coap_content_format format, struct coap_reply *reply, coap_reply_t reply_cb)
Get value from Golioth's Light DB.
int(* golioth_blockwise_observe_received_t)(struct golioth_blockwise_observe_ctx *ctx, const uint8_t *data, size_t offset, size_t len, bool last)
Type of the callback being called when a single block of data is received as part of CoAP observe not...
Definition: golioth.h:78
int golioth_connect(struct golioth_client *client, const char *host, uint16_t port)
Connect to Golioth.
void golioth_init(struct golioth_client *client)
Initialize golioth client instance.
int golioth_set_proto_coap_dtls(struct golioth_client *client, sec_tag_t *sec_tag_list, size_t sec_tag_count)
Set DTLS as transport protocol.
Represents blockwise download transfer from Golioth.
Definition: golioth.h:108
struct coap_block_context block_ctx
Definition: golioth.h:109
golioth_blockwise_download_received_t received_cb
Definition: golioth.h:113
uint8_t token[COAP_TOKEN_MAX_LEN]
Definition: golioth.h:112
struct coap_reply * reply
Definition: golioth.h:111
struct golioth_client * client
Definition: golioth.h:110
Represents a Golioth blockwise observe context.
Definition: golioth.h:86
golioth_blockwise_observe_received_t received_cb
Definition: golioth.h:90
const char * path
Definition: golioth.h:89
struct coap_block_context block_ctx
Definition: golioth.h:87
struct golioth_client * client
Definition: golioth.h:88
Represents a Golioth client instance.
Definition: golioth.h:48
struct k_mutex lock
Definition: golioth.h:63
uint8_t * rx_buffer
Definition: golioth.h:56
size_t rx_received
Definition: golioth.h:58
int sock
Definition: golioth.h:64
struct golioth_unsecure unsecure
Definition: golioth.h:52
struct coap_packet rx_packet
Definition: golioth.h:60
void(* on_connect)(struct golioth_client *client)
Definition: golioth.h:66
struct coap_option rx_options[CONFIG_GOLIOTH_COAP_MAX_OPTIONS]
Definition: golioth.h:61
void(* on_message)(struct golioth_client *client, struct coap_packet *rx)
Definition: golioth.h:67
int proto
Definition: golioth.h:49
size_t rx_buffer_len
Definition: golioth.h:57
struct golioth_tls tls
Definition: golioth.h:53
(D)TLS credentials of Golioth client.
Definition: golioth.h:40
size_t sec_tag_count
Definition: golioth.h:42
sec_tag_t * sec_tag_list
Definition: golioth.h:41
UDP (unsecure) credentials (identity only) of Golioth client.
Definition: golioth.h:32
const uint8_t * identity
Definition: golioth.h:33
size_t identity_len
Definition: golioth.h:34