Golioth Zephyr SDK
Golioth Networking

Modules

 Golioth LightDB
 
 Golioth LightDB Stream
 
 Golioth Remote Procedure Call
 
 Golioth Settings
 
 Golioth System Client
 

Data Structures

struct  golioth_tls
 (D)TLS credentials of Golioth client. More...
 
struct  golioth_client
 Represents a Golioth client instance. More...
 

Macros

#define GOLIOTH_COAP_MAX_NON_PAYLOAD_LEN   128
 
#define GOLIOTH_MAX_IDENTITY_LEN   32
 
#define GOLIOTH_EMPTY_PACKET_LEN   (16 + GOLIOTH_MAX_IDENTITY_LEN)
 

Enumerations

enum  golioth_content_format { GOLIOTH_CONTENT_FORMAT_APP_OCTET_STREAM = COAP_CONTENT_FORMAT_APP_OCTET_STREAM , GOLIOTH_CONTENT_FORMAT_APP_JSON = COAP_CONTENT_FORMAT_APP_JSON , GOLIOTH_CONTENT_FORMAT_APP_CBOR = COAP_CONTENT_FORMAT_APP_CBOR }
 Set of Content-Format option values for Golioth APIs. More...
 

Functions

static void golioth_lock (struct golioth_client *client)
 
static void golioth_unlock (struct golioth_client *client)
 
void golioth_init (struct golioth_client *client)
 Initialize golioth client instance. More...
 
bool golioth_is_connected (struct golioth_client *client)
 Check if client is connected to Golioth. More...
 
int golioth_connect (struct golioth_client *client, const char *host, uint16_t port)
 Connect to Golioth. More...
 
int golioth_disconnect (struct golioth_client *client)
 Disconnect from Golioth. More...
 
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. More...
 
int golioth_send_coap (struct golioth_client *client, struct coap_packet *packet)
 Send CoAP packet to Golioth. More...
 
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. More...
 
int golioth_ping (struct golioth_client *client)
 Send PING message to Golioth. More...
 
int golioth_send_hello (struct golioth_client *client)
 Send Hello message to Golioth. More...
 
int golioth_process_rx (struct golioth_client *client)
 Process incoming data from Golioth. More...
 
void golioth_poll_prepare (struct golioth_client *client, int64_t now, int *fd, int64_t *timeout)
 Prepare for poll() system call on transport socket. More...
 

Detailed Description

Functions for communicating with the Golioth servers

Macro Definition Documentation

◆ GOLIOTH_COAP_MAX_NON_PAYLOAD_LEN

#define GOLIOTH_COAP_MAX_NON_PAYLOAD_LEN   128

Definition at line 25 of file net/golioth.h.

◆ GOLIOTH_EMPTY_PACKET_LEN

#define GOLIOTH_EMPTY_PACKET_LEN   (16 + GOLIOTH_MAX_IDENTITY_LEN)

Definition at line 28 of file net/golioth.h.

◆ GOLIOTH_MAX_IDENTITY_LEN

#define GOLIOTH_MAX_IDENTITY_LEN   32

Definition at line 27 of file net/golioth.h.

Enumeration Type Documentation

◆ golioth_content_format

Set of Content-Format option values for Golioth APIs.

Enumerator
GOLIOTH_CONTENT_FORMAT_APP_OCTET_STREAM 
GOLIOTH_CONTENT_FORMAT_APP_JSON 
GOLIOTH_CONTENT_FORMAT_APP_CBOR 

Definition at line 33 of file net/golioth.h.

Function Documentation

◆ golioth_connect()

int golioth_connect ( struct golioth_client client,
const char *  host,
uint16_t  port 
)

Connect to Golioth.

Attempt to connect to Golioth.

Parameters
clientClient instance
hostServer hostname or IP address
portServer port number
Return values
0On success
<0On failure

◆ golioth_disconnect()

int golioth_disconnect ( struct golioth_client client)

Disconnect from Golioth.

Attempt to disconnect from Golioth.

Parameters
clientClient instance
Return values
0On success
<0On failure

◆ golioth_init()

void golioth_init ( struct golioth_client client)

Initialize golioth client instance.

Initializes internal data of client instance. Must be called before using any other APIs on client instance.

Parameters
clientClient instance

◆ golioth_is_connected()

bool golioth_is_connected ( struct golioth_client client)

Check if client is connected to Golioth.

Check if client instance is connected to Golioth.

Parameters
clientClient instance.
Return values
trueWhen client is connected to Golioth.
falseWhen client is not connected to Golioth.

◆ golioth_lock()

static void golioth_lock ( struct golioth_client client)
inlinestatic

Definition at line 79 of file net/golioth.h.

◆ golioth_ping()

int golioth_ping ( struct golioth_client client)

Send PING message to Golioth.

Parameters
clientClient instance
Return values
0On success
<0On failure

◆ golioth_poll_prepare()

void golioth_poll_prepare ( struct golioth_client client,
int64_t  now,
int *  fd,
int64_t *  timeout 
)

Prepare for poll() system call on transport socket.

Parameters
[in]clientClient instance
[in]nowTimestamp in msec for current event loop (e.g. output of k_uptime_get())
[out]fdFile descriptor of transport socket (optional, can be NULL)
[out]timeoutTimeout till the next action needs to be taken, such as resending a packet (optional, can be NULL)

◆ golioth_process_rx()

int golioth_process_rx ( struct golioth_client client)

Process incoming data from Golioth.

Process incoming data on network socket. It does not block when there is no more data, so it is best to use it with zsock_poll.

Parameters
clientClient instance
Return values
0On success
<0On failure

◆ golioth_send_coap()

int golioth_send_coap ( struct golioth_client client,
struct coap_packet *  packet 
)

Send CoAP packet to Golioth.

This is low-level API for sending arbitrary CoAP packet to Golioth.

Parameters
clientClient instance
packetCoAP packet
Return values
0On success
<0On failure

◆ golioth_send_coap_payload()

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.

Similar to golioth_send_coap, but appends payload (internally) before sending.

Parameters
clientClient instance
packetCoAP packet (without payload)
dataPayload data
data_lenPayload length
Return values
0On success
<0On failure

◆ golioth_send_hello()

int golioth_send_hello ( struct golioth_client client)

Send Hello message to Golioth.

Sends Hello message to Golioth, which is mostly useful verifying Golioth connection.

Parameters
clientClient instance
Return values
0On success
<0On failure

◆ golioth_set_proto_coap_dtls()

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.

Set DTLS as transport protocol for CoAP packets to Golioth and assignes credentials to be used.

Parameters
clientClient instance
sec_tag_listSecure tag array (see sec_tag_t and TLS_SEC_TAG_LIST)
sec_tag_countSecure tag count (see sec_tag_t and TLS_SEC_TAG_LIST)
Return values
0On success
<0On failure

◆ golioth_unlock()

static void golioth_unlock ( struct golioth_client client)
inlinestatic

Definition at line 84 of file net/golioth.h.