43 #include "contiki-conf.h"
46 #ifdef JSONTREE_CONF_MAX_DEPTH
47 #define JSONTREE_MAX_DEPTH JSONTREE_CONF_MAX_DEPTH
49 #define JSONTREE_MAX_DEPTH 10
52 #ifdef JSONTREE_CONF_PRETTY
53 #define JSONTREE_PRETTY JSONTREE_CONF_PRETTY
55 #define JSONTREE_PRETTY 0
58 struct jsontree_context {
59 struct jsontree_value *values[JSONTREE_MAX_DEPTH];
60 uint16_t index[JSONTREE_MAX_DEPTH];
67 struct jsontree_value {
72 struct jsontree_string {
77 struct jsontree_uint {
88 struct jsonparse_state;
89 struct jsontree_callback {
91 int (*
output)(
struct jsontree_context *js_ctx);
92 int (* set)(
struct jsontree_context *js_ctx,
struct jsonparse_state *parser);
95 struct jsontree_pair {
97 struct jsontree_value *value;
100 struct jsontree_object {
103 struct jsontree_pair *pairs;
106 struct jsontree_array {
109 struct jsontree_value **values;
112 struct jsontree_ptr {
117 #define JSONTREE_STRING(text) {JSON_TYPE_STRING, (text)}
118 #define JSONTREE_PAIR(name, value) {(name), (struct jsontree_value *)(value)}
119 #define JSONTREE_CALLBACK(output, set) {JSON_TYPE_CALLBACK, (output), (set)}
121 #define JSONTREE_OBJECT(name, ...) \
122 static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__}; \
123 static struct jsontree_object name = { \
125 sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair), \
126 jsontree_pair_##name }
128 #define JSONTREE_OBJECT_EXT(name, ...) \
129 static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__}; \
130 struct jsontree_object name = { \
132 sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair), \
133 jsontree_pair_##name }
135 #define JSONTREE_ARRAY(name, count) \
136 static struct jsontree_value *jsontree_value##name[count]; \
137 static struct jsontree_array name = { \
140 jsontree_value##name }
142 void jsontree_setup(
struct jsontree_context *js_ctx,
143 struct jsontree_value *root,
int (* putchar)(
int));
144 void jsontree_reset(
struct jsontree_context *js_ctx);
146 const char *jsontree_path_name(
const struct jsontree_context *js_ctx,
149 void jsontree_write_uint(
const struct jsontree_context *js_ctx,
151 void jsontree_write_int(
const struct jsontree_context *js_ctx,
int value);
152 void jsontree_write_atom(
const struct jsontree_context *js_ctx,
154 void jsontree_write_string(
const struct jsontree_context *js_ctx,
156 int jsontree_print_next(
struct jsontree_context *js_ctx);
157 struct jsontree_value *jsontree_find_next(
struct jsontree_context *js_ctx,
static volatile clock_time_t count
These routines define the AVR-specific calls declared in /core/sys/clock.h CLOCK_SECOND is the number...
A few JSON defines used for parsing and generating JSON.
static uint8_t output(const uip_lladdr_t *localdest)
Take an IP packet and format it to be sent on an 802.15.4 network using 6lowpan.