cbor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Silke Hofstra
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
25 #ifndef SENML_CBOR_H
26 #define SENML_CBOR_H
27 
28 #include <stddef.h>
29 #include <stdbool.h>
30 #include <stdint.h>
31 
32 #include "senml.h"
33 #include "nanocbor/nanocbor.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
44 typedef enum {
45  SENML_LABEL_BASE_VERSION = -1,
46  SENML_LABEL_BASE_NAME = -2,
47  SENML_LABEL_BASE_TIME = -3,
48  SENML_LABEL_BASE_UNIT = -4,
49  SENML_LABEL_BASE_VALUE = -5,
50  SENML_LABEL_BASE_SUM = -6,
51  SENML_LABEL_NAME = 0,
52  SENML_LABEL_UNIT = 1,
53  SENML_LABEL_VALUE = 2,
54  SENML_LABEL_STRING_VALUE = 3,
55  SENML_LABEL_BOOLEAN_VALUE = 4,
56  SENML_LABEL_SUM = 5,
57  SENML_LABEL_TIME = 6,
58  SENML_LABEL_UPDATE_TIME = 7,
59  SENML_LABEL_DATA_VALUE = 8,
61 
62 #if IS_ACTIVE(CONFIG_SENML_ATTR_SUM) || defined(DOXYGEN)
73 int senml_encode_sum_cbor(nanocbor_encoder_t *enc, const senml_attr_t *attr);
74 #endif
75 
84 int senml_encode_bool_cbor(nanocbor_encoder_t *enc, const senml_bool_value_t *val);
85 
94 int senml_encode_value_cbor(nanocbor_encoder_t *enc, const senml_value_t *val);
95 
104 int senml_encode_string_cbor(nanocbor_encoder_t *enc, const senml_string_value_t *val);
105 
114 int senml_encode_data_cbor(nanocbor_encoder_t *enc, const senml_data_value_t *val);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* SENML_CBOR_H */
int senml_encode_string_cbor(nanocbor_encoder_t *enc, const senml_string_value_t *val)
Encode senml_string_value_t as CBOR.
int senml_encode_sum_cbor(nanocbor_encoder_t *enc, const senml_attr_t *attr)
Encode senml_attr_t containing sum as CBOR.
int senml_encode_value_cbor(nanocbor_encoder_t *enc, const senml_value_t *val)
Encode senml_value_t as CBOR.
int senml_encode_bool_cbor(nanocbor_encoder_t *enc, const senml_bool_value_t *val)
Encode senml_bool_value_t as CBOR.
int senml_encode_data_cbor(nanocbor_encoder_t *enc, const senml_data_value_t *val)
Encode senml_data_value_t as CBOR.
senml_cbor_label_t
SenML CBOR labels.
Definition: cbor.h:44
Basic SenML types.
SenML common record attributes.
Definition: senml.h:239
SenML boolean value.
Definition: senml.h:281
SenML data value.
Definition: senml.h:289
SenML string value.
Definition: senml.h:272
SenML string value.
Definition: senml.h:264