void tg_print_system_ready_message(void) { cmd_add_token("fv"); cmd_add_token("fb"); cmd_add_string("msg", "SYSTEM READY"); cmd_print_list(TG_OK, TEXT_MULTILINE_FORMATTED); }
void tg_print_initializing_message(void) { cmd_add_token("fv"); cmd_add_token("fb"); cmd_add_string("msg", INIT_CONFIGURATION_MESSAGE); // see settings.h & sub-headers cmd_print_list(TG_INITIALIZING, TEXT_MULTILINE_FORMATTED); }
void tg_print_loading_configs_message(void) { cmd_add_token("fv"); cmd_add_token("fb"); cmd_add_string("msg", "Loading configs from EEPROM"); cmd_print_list(TG_INITIALIZING, TEXT_MULTILINE_FORMATTED); }
void tg_print_message(char *msg) { cmd_add_string("msg", msg); cmd_print_list(TG_OK, TEXT_INLINE_VALUES); }
void _test_serialize() { cmdObj_t *cmd = cmd_array; // printf("\n\nJSON serialization tests\n"); // null list _reset_array(); js_serialize_json(cmd_array, tg.out_buf, sizeof(tg.out_buf)); _printit(); // parent with a null child cmd = _reset_array(); cmd = _add_parent(cmd, "r"); js_serialize_json(cmd_array, tg.out_buf, sizeof(tg.out_buf)); _printit(); // single string element (message) cmd = _reset_array(); cmd = _add_string(cmd, "msg", "test message"); js_serialize_json(cmd_array, tg.out_buf, sizeof(tg.out_buf)); _printit(); // string element and an integer element cmd = _reset_array(); cmd = _add_string(cmd, "msg", "test message"); cmd = _add_integer(cmd, "answer", 42); js_serialize_json(cmd_array, tg.out_buf, sizeof(tg.out_buf)); _printit(); // parent with a string and an integer element cmd = _reset_array(); cmd = _add_parent(cmd, "r"); cmd = _add_string(cmd, "msg", "test message"); cmd = _add_integer(cmd, "answer", 42); js_serialize_json(cmd_array, tg.out_buf, sizeof(tg.out_buf)); _printit(); // parent with a null child followed by a final level 0 element (footer) cmd = _reset_array(); cmd = _add_parent(cmd, "r"); cmd = _add_empty(cmd); cmd = _add_string(cmd, "f", "[1,0,12,1234]"); // fake out a footer cmd->pv->depth = 0; js_serialize_json(cmd_array, tg.out_buf, sizeof(tg.out_buf)); _printit(); // parent with a single element child followed by empties folowed by a final level 0 element cmd = _reset_array(); cmd = _add_parent(cmd, "r"); cmd = _add_integer(cmd, "answer", 42); cmd = _add_empty(cmd); cmd = _add_empty(cmd); cmd = _add_string(cmd, "f", "[1,0,12,1234]"); // fake out a footer cmd->pv->depth = 0; js_serialize_json(cmd_array, tg.out_buf, sizeof(tg.out_buf)); _printit(); // response object parent with no children w/footer cmd_reset_list(); // works with the header/body/footer list _add_array(cmd, "1,0,12,1234"); // fake out a footer js_serialize_json(cmd_header, tg.out_buf, sizeof(tg.out_buf)); _printit(); // response parent with one element w/footer cmd_reset_list(); // works with the header/body/footer list cmd_add_string("msg", "test message"); _add_array(cmd, "1,0,12,1234"); // fake out a footer js_serialize_json(cmd_header, tg.out_buf, sizeof(tg.out_buf)); _printit(); }