Golioth Firmware SDK
golioth_lightdb.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 "golioth_status.h"
9 #include "golioth_client.h"
10 
18 
25 int32_t golioth_payload_as_int(const uint8_t* payload, size_t payload_size);
26 
33 float golioth_payload_as_float(const uint8_t* payload, size_t payload_size);
34 
42 bool golioth_payload_as_bool(const uint8_t* payload, size_t payload_size);
43 
53 bool golioth_payload_is_null(const uint8_t* payload, size_t payload_size);
54 
55 // TODO - block transfers for large post/get
56 
57 //-------------------------------------------------------------------------------
58 // LightDB State
59 //-------------------------------------------------------------------------------
60 
81  golioth_client_t client,
82  const char* path,
83  int32_t value,
84  golioth_set_cb_fn callback,
85  void* callback_arg);
86 
107  golioth_client_t client,
108  const char* path,
109  int32_t value,
110  int32_t timeout_s);
111 
116  golioth_client_t client,
117  const char* path,
118  bool value,
119  golioth_set_cb_fn callback,
120  void* callback_arg);
121 
126  golioth_client_t client,
127  const char* path,
128  bool value,
129  int32_t timeout_s);
130 
135  golioth_client_t client,
136  const char* path,
137  float value,
138  golioth_set_cb_fn callback,
139  void* callback_arg);
140 
142  golioth_client_t client,
143  const char* path,
144  float value,
145  int32_t timeout_s);
146 
151  golioth_client_t client,
152  const char* path,
153  const char* str,
154  size_t str_len,
155  golioth_set_cb_fn callback,
156  void* callback_arg);
157 
159  golioth_client_t client,
160  const char* path,
161  const char* str,
162  size_t str_len,
163  int32_t timeout_s);
164 
182  golioth_client_t client,
183  const char* path,
184  const char* json_str,
185  size_t json_str_len,
186  golioth_set_cb_fn callback,
187  void* callback_arg);
188 
199  golioth_client_t client,
200  const char* path,
201  const char* json_str,
202  size_t json_str_len,
203  int32_t timeout_s);
204 
221  golioth_client_t client,
222  const char* path,
223  golioth_get_cb_fn callback,
224  void* callback_arg);
225 
245  golioth_client_t client,
246  const char* path,
247  int32_t* value,
248  int32_t timeout_s);
249 
252  golioth_client_t client,
253  const char* path,
254  bool* value,
255  int32_t timeout_s);
256 
259  golioth_client_t client,
260  const char* path,
261  float* value,
262  int32_t timeout_s);
263 
266  golioth_client_t client,
267  const char* path,
268  char* strbuf,
269  size_t strbuf_size,
270  int32_t timeout_s);
271 
274  golioth_client_t client,
275  const char* path,
276  char* strbuf,
277  size_t strbuf_size,
278  int32_t timeout_s);
279 
299  golioth_client_t client,
300  const char* path,
301  golioth_set_cb_fn callback,
302  void* callback_arg);
303 
322  golioth_client_t client,
323  const char* path,
324  int32_t timeout_s);
325 
351  golioth_client_t client,
352  const char* path,
353  golioth_get_cb_fn callback,
354  void* callback_arg);
355 
356 //-------------------------------------------------------------------------------
357 // LightDB Stream
358 //-------------------------------------------------------------------------------
359 
362  golioth_client_t client,
363  const char* path,
364  int32_t value,
365  golioth_set_cb_fn callback,
366  void* callback_arg);
367 
370  golioth_client_t client,
371  const char* path,
372  int32_t value,
373  int32_t timeout_s);
374 
377  golioth_client_t client,
378  const char* path,
379  bool value,
380  golioth_set_cb_fn callback,
381  void* callback_arg);
382 
385  golioth_client_t client,
386  const char* path,
387  bool value,
388  int32_t timeout_s);
389 
392  golioth_client_t client,
393  const char* path,
394  float value,
395  golioth_set_cb_fn callback,
396  void* callback_arg);
397 
400  golioth_client_t client,
401  const char* path,
402  float value,
403  int32_t timeout_s);
404 
407  golioth_client_t client,
408  const char* path,
409  const char* str,
410  size_t str_len,
411  golioth_set_cb_fn callback,
412  void* callback_arg);
413 
416  golioth_client_t client,
417  const char* path,
418  const char* str,
419  size_t str_len,
420  int32_t timeout_s);
421 
424  golioth_client_t client,
425  const char* path,
426  const char* json_str,
427  size_t json_str_len,
428  golioth_set_cb_fn callback,
429  void* callback_arg);
430 
433  golioth_client_t client,
434  const char* path,
435  const char* json_str,
436  size_t json_str_len,
437  int32_t timeout_s);
438 
441  golioth_client_t client,
442  const char* path,
443  const uint8_t* cbor_data,
444  size_t cbor_data_len,
445  golioth_set_cb_fn callback,
446  void* callback_arg);
447 
450  golioth_client_t client,
451  const char* path,
452  const uint8_t* cbor_data,
453  size_t cbor_data_len,
454  int32_t timeout_s);
455 
golioth_status_t
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)
void * golioth_client_t
Opaque handle to the Golioth client.
void(* golioth_set_cb_fn)(golioth_client_t client, const golioth_response_t *response, const char *path, void *arg)
golioth_status_t golioth_lightdb_set_bool_sync(golioth_client_t client, const char *path, bool value, int32_t timeout_s)
golioth_status_t golioth_lightdb_stream_set_string_async(golioth_client_t client, const char *path, const char *str, size_t str_len, golioth_set_cb_fn callback, void *callback_arg)
Similar to golioth_lightdb_set_string_async, but for LightDB stream.
golioth_status_t golioth_lightdb_get_json_sync(golioth_client_t client, const char *path, char *strbuf, size_t strbuf_size, int32_t timeout_s)
Similar to golioth_lightdb_get_int_sync, but for string-encoded JSON objects.
golioth_status_t golioth_lightdb_set_string_async(golioth_client_t client, const char *path, const char *str, size_t str_len, golioth_set_cb_fn callback, void *callback_arg)
bool golioth_payload_is_null(const uint8_t *payload, size_t payload_size)
golioth_status_t golioth_lightdb_delete_async(golioth_client_t client, const char *path, golioth_set_cb_fn callback, void *callback_arg)
golioth_status_t golioth_lightdb_set_string_sync(golioth_client_t client, const char *path, const char *str, size_t str_len, int32_t timeout_s)
golioth_status_t golioth_lightdb_set_json_async(golioth_client_t client, const char *path, const char *json_str, size_t json_str_len, golioth_set_cb_fn callback, void *callback_arg)
golioth_status_t golioth_lightdb_get_float_sync(golioth_client_t client, const char *path, float *value, int32_t timeout_s)
Similar to golioth_lightdb_get_int_sync, but for type float.
golioth_status_t golioth_lightdb_delete_sync(golioth_client_t client, const char *path, int32_t timeout_s)
golioth_status_t golioth_lightdb_observe_async(golioth_client_t client, const char *path, golioth_get_cb_fn callback, void *callback_arg)
golioth_status_t golioth_lightdb_set_bool_async(golioth_client_t client, const char *path, bool value, golioth_set_cb_fn callback, void *callback_arg)
int32_t golioth_payload_as_int(const uint8_t *payload, size_t payload_size)
golioth_status_t golioth_lightdb_stream_set_float_async(golioth_client_t client, const char *path, float value, golioth_set_cb_fn callback, void *callback_arg)
Similar to golioth_lightdb_set_float_async, but for LightDB stream.
float golioth_payload_as_float(const uint8_t *payload, size_t payload_size)
golioth_status_t golioth_lightdb_stream_set_int_sync(golioth_client_t client, const char *path, int32_t value, int32_t timeout_s)
Similar to golioth_lightdb_set_int_sync, but for LightDB stream.
golioth_status_t golioth_lightdb_stream_set_bool_async(golioth_client_t client, const char *path, bool value, golioth_set_cb_fn callback, void *callback_arg)
Similar to golioth_lightdb_set_bool_async, but for LightDB stream.
golioth_status_t golioth_lightdb_set_int_async(golioth_client_t client, const char *path, int32_t value, golioth_set_cb_fn callback, void *callback_arg)
golioth_status_t golioth_lightdb_get_bool_sync(golioth_client_t client, const char *path, bool *value, int32_t timeout_s)
Similar to golioth_lightdb_get_int_sync, but for type bool.
golioth_status_t golioth_lightdb_stream_set_float_sync(golioth_client_t client, const char *path, float value, int32_t timeout_s)
Similar to golioth_lightdb_set_float_sync, but for LightDB stream.
golioth_status_t golioth_lightdb_stream_set_json_sync(golioth_client_t client, const char *path, const char *json_str, size_t json_str_len, int32_t timeout_s)
Similar to golioth_lightdb_set_json_sync, but for LightDB stream.
golioth_status_t golioth_lightdb_set_int_sync(golioth_client_t client, const char *path, int32_t value, int32_t timeout_s)
golioth_status_t golioth_lightdb_stream_set_json_async(golioth_client_t client, const char *path, const char *json_str, size_t json_str_len, golioth_set_cb_fn callback, void *callback_arg)
Similar to golioth_lightdb_set_json_async, but for LightDB stream.
golioth_status_t golioth_lightdb_set_float_async(golioth_client_t client, const char *path, float value, golioth_set_cb_fn callback, void *callback_arg)
golioth_status_t golioth_lightdb_stream_set_string_sync(golioth_client_t client, const char *path, const char *str, size_t str_len, int32_t timeout_s)
Similar to golioth_lightdb_set_string_sync, but for LightDB stream.
golioth_status_t golioth_lightdb_stream_set_cbor_sync(golioth_client_t client, const char *path, const uint8_t *cbor_data, size_t cbor_data_len, int32_t timeout_s)
Similar to golioth_lightdb_stream_set_json_sync, but for CBOR.
golioth_status_t golioth_lightdb_stream_set_int_async(golioth_client_t client, const char *path, int32_t value, golioth_set_cb_fn callback, void *callback_arg)
Similar to golioth_lightdb_set_int_async, but for LightDB stream.
golioth_status_t golioth_lightdb_set_float_sync(golioth_client_t client, const char *path, float value, int32_t timeout_s)
golioth_status_t golioth_lightdb_set_json_sync(golioth_client_t client, const char *path, const char *json_str, size_t json_str_len, int32_t timeout_s)
golioth_status_t golioth_lightdb_get_string_sync(golioth_client_t client, const char *path, char *strbuf, size_t strbuf_size, int32_t timeout_s)
Similar to golioth_lightdb_get_int_sync, but for type string.
golioth_status_t golioth_lightdb_stream_set_cbor_async(golioth_client_t client, const char *path, const uint8_t *cbor_data, size_t cbor_data_len, golioth_set_cb_fn callback, void *callback_arg)
Similar to golioth_lightdb_stream_set_json_async, but for CBOR.
golioth_status_t golioth_lightdb_get_async(golioth_client_t client, const char *path, golioth_get_cb_fn callback, void *callback_arg)
bool golioth_payload_as_bool(const uint8_t *payload, size_t payload_size)
golioth_status_t golioth_lightdb_get_int_sync(golioth_client_t client, const char *path, int32_t *value, int32_t timeout_s)
golioth_status_t golioth_lightdb_stream_set_bool_sync(golioth_client_t client, const char *path, bool value, int32_t timeout_s)
Similar to golioth_lightdb_set_bool_sync, but for LightDB stream.