Skip to content

Commit

Permalink
Text mode: allow disabling text mode to reduce code size
Browse files Browse the repository at this point in the history
  • Loading branch information
garethpotter authored and martinjaeger committed Apr 26, 2024
1 parent 9af2b08 commit d2a610d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Kconfig.thingset
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ config THINGSET

if THINGSET

config THINGSET_TEXT_MODE
bool "Enable text mode (JSON)"
default y
help
Whether to enable text mode (JSON). It may be desirable to disable this
to reduce code size in certain circumstances.

Please note that text mode may also be required for the ThingSet shell
in some applications, so one should be careful when disabling it.

config THINGSET_IMMUTABLE_OBJECTS
bool "Make data objects immutable and store them in ROM"
default n
Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ zephyr_library_named("thingset")
target_sources(thingset PRIVATE thingset.c)
target_sources(thingset PRIVATE thingset_bin.c)
target_sources(thingset PRIVATE thingset_common.c)
target_sources(thingset PRIVATE thingset_txt.c)
if(DEFINED CONFIG_THINGSET_TEXT_MODE)
target_sources(thingset PRIVATE thingset_txt.c)
endif()
4 changes: 3 additions & 1 deletion src/thingset.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int thingset_process_message(struct thingset_context *ts, const uint8_t *msg, si
ts->rsp_size = rsp_size;
ts->rsp_pos = 0;

if (ts->msg[0] >= 0x20) {
if (IS_ENABLED(CONFIG_THINGSET_TEXT_MODE) && ts->msg[0] >= 0x20) {
ret = thingset_txt_process(ts);
}
else {
Expand Down Expand Up @@ -447,9 +447,11 @@ int thingset_report_path(struct thingset_context *ts, char *buf, size_t buf_size
}

switch (format) {
#ifdef CONFIG_THINGSET_TEXT_MODE
case THINGSET_TXT_NAMES_VALUES:
thingset_txt_setup(ts);
break;
#endif
case THINGSET_BIN_IDS_VALUES:
ts->endpoint.use_ids = true;
thingset_bin_setup(ts, 1);
Expand Down

0 comments on commit d2a610d

Please sign in to comment.