Golioth Firmware SDK
golioth_client.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Golioth, Inc.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #pragma once
7 
8 #include <stdbool.h>
9 #include <stdint.h>
10 #include <stdlib.h> // size_t
11 #include "golioth_status.h"
12 #include "golioth_sys.h"
13 
28 
30 typedef void* golioth_client_t;
31 
33 typedef enum {
39 
41 typedef struct {
50  uint8_t status_class;
52  uint8_t status_code;
54 
56 typedef enum {
62 
67 typedef struct {
69  const char* psk_id;
70  size_t psk_id_len;
71 
73  const char* psk;
74  size_t psk_len;
76 
81 typedef struct {
82  // PEM Common CA cert
83  const uint8_t* ca_cert;
84  size_t ca_cert_len;
85 
87  const uint8_t* public_cert;
89 
91  const uint8_t* private_key;
94 
96 typedef struct {
98  union {
101  };
103 
105 typedef struct {
108 
115  golioth_client_t client,
117  void* arg);
118 
131 typedef void (*golioth_get_cb_fn)(
132  golioth_client_t client,
133  const golioth_response_t* response,
134  const char* path,
135  const uint8_t* payload,
136  size_t payload_size,
137  void* arg);
138 typedef void (*golioth_get_block_cb_fn)(
139  golioth_client_t client,
140  const golioth_response_t* response,
141  const char* path,
142  const uint8_t* payload,
143  size_t payload_size,
144  bool is_last,
145  void* arg);
146 
158 typedef void (*golioth_set_cb_fn)(
159  golioth_client_t client,
160  const golioth_response_t* response,
161  const char* path,
162  void* arg);
163 
177 
187 
198 
214 
221 
229 
240 
247  golioth_client_t client,
249  void* arg);
250 
259 
267 
275 
282 
golioth_status_t
void * golioth_sys_thread_t
Definition: golioth_sys.h:57
void(* golioth_get_cb_fn)(golioth_client_t client, const golioth_response_t *response, const char *path, const uint8_t *payload, size_t payload_size, void *arg)
golioth_client_t golioth_client_create(const golioth_client_config_t *config)
golioth_status_t golioth_client_stop(golioth_client_t client)
bool golioth_client_is_connected(golioth_client_t client)
void(* golioth_client_event_cb_fn)(golioth_client_t client, golioth_client_event_t event, void *arg)
void golioth_client_destroy(golioth_client_t client)
golioth_status_t golioth_client_start(golioth_client_t client)
bool golioth_client_has_allocation_leaks(void)
bool golioth_client_is_running(golioth_client_t client)
bool golioth_client_wait_for_connect(golioth_client_t client, int timeout_ms)
void(* golioth_get_block_cb_fn)(golioth_client_t client, const golioth_response_t *response, const char *path, const uint8_t *payload, size_t payload_size, bool is_last, void *arg)
golioth_sys_thread_t golioth_client_get_thread(golioth_client_t client)
void * golioth_client_t
Opaque handle to the Golioth client.
golioth_tls_auth_type_t
TLS authentication type.
void golioth_client_register_event_callback(golioth_client_t client, golioth_client_event_cb_fn callback, void *arg)
golioth_client_event_t
Golioth client events.
uint32_t golioth_client_num_items_in_request_queue(golioth_client_t client)
void golioth_client_set_packet_loss_percent(uint8_t percent)
void(* golioth_set_cb_fn)(golioth_client_t client, const golioth_response_t *response, const char *path, void *arg)
@ GOLIOTH_TLS_AUTH_TYPE_PKI
Authenticate with PKI certificates (CA cert, public client cert, private client key)
@ GOLIOTH_TLS_AUTH_TYPE_PSK
Authenticate with pre-shared key (psk-id and psk)
@ GOLIOTH_CLIENT_EVENT_CONNECTED
Client was previously not connected, and is now connected.
@ GOLIOTH_CLIENT_EVENT_DISCONNECTED
Client was previously connected, and is now disconnected.
Golioth client configuration, passed into golioth_client_create.
golioth_tls_credentials_t credentials
const uint8_t * public_cert
PEM Public client cert.
const uint8_t * private_key
PEM Private client key.
const char * psk_id
PSK Identifier (e.g. "[email protected]")
const char * psk
Pre-shared key, secret password.
Response status and CoAP class/code.
uint8_t status_code
the 03 in 4.03
golioth_status_t status
uint8_t status_class
the 2 in 2.XX
TLS Authentication Credentials.
golioth_pki_credentials_t pki
golioth_tls_auth_type_t auth_type
golioth_psk_credentials_t psk