Golioth Firmware SDK
Loading...
Searching...
No Matches
gateway.h File Reference
#include <golioth/golioth_status.h>
#include <golioth/client.h>
#include <stdlib.h>

Go to the source code of this file.

Typedefs

typedef enum golioth_status(* gateway_downlink_block_cb) (const uint8_t *data, size_t len, bool is_last, void *arg)
 
typedef void(* gateway_downlink_end_cb) (enum golioth_status status, const struct golioth_coap_rsp_code *coap_rsp_code, void *arg)
 

Functions

struct gateway_uplink * golioth_gateway_uplink_start (struct golioth_client *client, gateway_downlink_block_cb dnlk_block_cb, gateway_downlink_end_cb dnlk_end_cb, void *downlink_arg)
 
enum golioth_status golioth_gateway_uplink_block (struct gateway_uplink *uplink, uint32_t block_idx, const uint8_t *buf, size_t buf_len, bool is_last, golioth_set_block_cb_fn set_cb, void *callback_arg)
 
void golioth_gateway_uplink_finish (struct gateway_uplink *uplink)
 
enum golioth_status golioth_gateway_server_cert_get (struct golioth_client *client, void *buf, size_t *len)
 
enum golioth_status golioth_gateway_device_cert_set (struct golioth_client *client, const void *buf, size_t len, int32_t timeout_s)
 

Typedef Documentation

◆ gateway_downlink_block_cb

typedef enum golioth_status(* gateway_downlink_block_cb) (const uint8_t *data, size_t len, bool is_last, void *arg)

Definition at line 1 of file gateway.h.

◆ gateway_downlink_end_cb

typedef void(* gateway_downlink_end_cb) (enum golioth_status status, const struct golioth_coap_rsp_code *coap_rsp_code, void *arg)

Definition at line 25 of file gateway.h.

Function Documentation

◆ golioth_gateway_device_cert_set()

enum golioth_status golioth_gateway_device_cert_set ( struct golioth_client * client,
const void * buf,
size_t len,
int32_t timeout_s )

Set device certificate.

Parameters
clientThe client handle from golioth_client_create
bufPointer to buffer where certificate is stored
lenCertificate length
timeout_sTimeout in seconds for API call

◆ golioth_gateway_server_cert_get()

enum golioth_status golioth_gateway_server_cert_get ( struct golioth_client * client,
void * buf,
size_t * len )

Get server certificate.

Parameters
clientThe client handle from golioth_client_create
bufPointer to buffer where certificate will be written
lenPointer to length. On input it is buffer length. On output it is certificate length.

◆ golioth_gateway_uplink_block()

enum golioth_status golioth_gateway_uplink_block ( struct gateway_uplink * uplink,
uint32_t block_idx,
const uint8_t * buf,
size_t buf_len,
bool is_last,
golioth_set_block_cb_fn set_cb,
void * callback_arg )

Send a single uplink block

Call this function for each block. For each call you must increment the block_idx, On the final block, set is_last to true. Block size is determined by the value of CONFIG_GOLIOTH_BLOCKWISE_DOWNLOAD_MAX_BLOCK_SIZE.

An optional callback and callback argument may be supplied. The callback will be called after the block is uploaded to provide access to status and CoAP response codes.

Parameters
uplinkThe context used for all blocks in an uplink / downlink operation, returned from golioth_gateway_uplink_start
block_idxThe index of the block being sent
bufThe buffer where the data for this block is located
buf_lenThe actual length of data (in bytes) for this block. This should be equal to CONFIG_GOLIOTH_BLOCKWISE_DOWNLOAD_MAX_BLOCK_SIZE for all blocks except for the final block, which may be shorter
is_lastSet this to true if this is the last block in the upload
set_cbA callback that will be called after each block is sent (can be NULL)
callback_argAn optional user provided argument that will be passed to set_cb (can be NULL)

◆ golioth_gateway_uplink_finish()

void golioth_gateway_uplink_finish ( struct gateway_uplink * uplink)

Finish a gateway uplink.

Parameters
uplinkThe uplink context to finish, returned from golioth_gateway_uplink_start

◆ golioth_gateway_uplink_start()

struct gateway_uplink * golioth_gateway_uplink_start ( struct golioth_client * client,
gateway_downlink_block_cb dnlk_block_cb,
gateway_downlink_end_cb dnlk_end_cb,
void * downlink_arg )

Start a gateway uplink. The pointer returned from this function can be used with golioth_gateway_uplink_block and golioth_gateway_uplink_finish

Parameters
clientThe client handle from golioth_client_create
dnlk_block_cbA callback that will be called after each block in downlink is received
dnlk_end_cbA callback that will be called after downlink completes
downlink_argAn optional user provided argument that will be passed to callbacks (can be NULL)