-
Notifications
You must be signed in to change notification settings - Fork 6
Add support for publishing individual records #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nvelozsavino
wants to merge
7
commits into
ThingSet:main
Choose a base branch
from
nvelozsavino:statement-simple-value
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
01932af
Add support for publishing individual records
nvelozsavino 113ec92
Adding support for bool and some tests
nvelozsavino 7d874ee
Adding test for txt_statement
nvelozsavino 93f062a
Fixing duplicated TS_T_BOOL case on thingset_txt.c
nvelozsavino a0a5f78
Fixing get path for nested objects
nvelozsavino 0e93f34
Fixing format
nvelozsavino 5f7fd1e
Adding .clang-format from LibreSolar to help formating
nvelozsavino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Format definition for Libre Solar firmware | ||
# | ||
# Use Clang-Format plugin in VS Code and add "editor.formatOnSave": true to settings | ||
|
||
# Generic format | ||
BasedOnStyle: LLVM | ||
UseTab: Never | ||
IndentWidth: 4 | ||
TabWidth: 4 | ||
ColumnLimit: 100 | ||
AccessModifierOffset: -4 | ||
|
||
# Indentation and alignment | ||
AllowShortEnumsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: false | ||
AllowShortIfStatementsOnASingleLine: false | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveMacros: true | ||
AlignEscapedNewlines: DontAlign | ||
BreakBeforeBinaryOperators: NonAssignment | ||
IndentCaseLabels: true | ||
|
||
# Braces | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterClass: true | ||
AfterControlStatement: MultiLine | ||
AfterEnum: true | ||
AfterStruct: true | ||
AfterFunction: true | ||
BeforeElse: true | ||
SplitEmptyFunction: false | ||
Cpp11BracedListStyle: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -38,6 +38,21 @@ bool pub_report_enable = false; | |||||
uint16_t pub_report_interval = 1000; | ||||||
bool pub_info_enable = true; | ||||||
|
||||||
// txt_statement | ||||||
static float txt_st_float_pos = 12.53; | ||||||
static float txt_st_float_neg = -2.3; | ||||||
static int8_t txt_st_int8_pos = 120; | ||||||
static int8_t txt_st_int8_neg = -123; | ||||||
static int16_t txt_st_int16_pos = 32760; | ||||||
static int16_t txt_st_int16_neg = -32750; | ||||||
static int32_t txt_st_int32_pos = 2147483568; | ||||||
static int32_t txt_st_int32_neg = -2147483450; | ||||||
static uint8_t txt_st_uint8 = 254; | ||||||
static uint16_t txt_st_uint16 = 64050; | ||||||
static uint32_t txt_st_uint32 = 3399612978; | ||||||
static bool txt_st_bool_true = true; | ||||||
static bool txt_st_bool_false = false; | ||||||
|
||||||
// exec | ||||||
void reset_function(void); | ||||||
void auth_function(void); | ||||||
|
@@ -240,6 +255,52 @@ struct ts_data_object data_objects[] = { | |||||
TS_ITEM_BOOL(0xF6, "wOnChange", &pub_info_enable, | ||||||
0xF5, TS_ANY_RW, 0), | ||||||
|
||||||
|
||||||
// TXT STATEMTENT DATA /////////////////////////////////////////////////////// | ||||||
|
||||||
TS_GROUP(ID_TXT,"TXT",TS_NO_CALLBACK,ID_ROOT), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
TS_ITEM_FLOAT(0x101, "rFloatPos", &txt_st_float_pos, 2, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
TS_ITEM_FLOAT(0x102, "rFloatNeg", &txt_st_float_neg, 2, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
TS_ITEM_INT8(0x103, "rInt8Pos", &txt_st_int8_pos, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
TS_ITEM_INT8(0x104, "rInt8Neg", &txt_st_int8_neg, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
TS_ITEM_INT16(0x105, "rInt16Pos", &txt_st_int16_pos, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
TS_ITEM_INT16(0x106, "rInt16Neg", &txt_st_int16_neg, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
TS_ITEM_INT32(0x107, "rInt32Pos", &txt_st_int32_pos, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
TS_ITEM_INT32(0x108, "rInt32Neg", &txt_st_int32_neg, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
TS_ITEM_UINT8(0x109, "rUint8", &txt_st_uint8, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
TS_ITEM_UINT16(0x10A, "rUint16", &txt_st_uint16, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
TS_ITEM_UINT32(0x10B, "rUint32", &txt_st_uint32, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
TS_ITEM_BOOL(0x10C, "rBoolTrue", &txt_st_bool_true, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
TS_ITEM_BOOL(0x10D, "rBoolFalse", &txt_st_bool_false, | ||||||
ID_TXT, TS_ANY_R, SUBSET_REPORT), | ||||||
|
||||||
|
||||||
|
||||||
// UNIT TEST DATA ///////////////////////////////////////////////////////// | ||||||
// using IDs >= 0x1000 | ||||||
|
||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -237,6 +237,40 @@ void test_txt_statement_record(void) | |||||
TEST_ASSERT_TXT_RESP(resp_len, expected); | ||||||
} | ||||||
|
||||||
|
||||||
|
||||||
Comment on lines
+240
to
+241
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary newlines. |
||||||
void test_txt_statement_item(void) | ||||||
{ | ||||||
|
||||||
const struct { | ||||||
const char* path; | ||||||
const char* value; | ||||||
} tests[] ={ | ||||||
{"TXT/rFloatPos","12.53"}, | ||||||
{"TXT/rFloatNeg","-2.30"}, | ||||||
{"TXT/rInt8Pos","120"}, | ||||||
{"TXT/rInt8Neg","-123"}, | ||||||
{"TXT/rInt16Pos","32760"}, | ||||||
{"TXT/rInt16Pos","-32750"}, | ||||||
{"TXT/rInt32Pos","2147483568"}, | ||||||
{"TXT/rInt32Pos","-2147483450"}, | ||||||
{"TXT/rUint8","254"}, | ||||||
{"TXT/rUint16","64050"}, | ||||||
{"TXT/rUint32","3399612978"}, | ||||||
{"TXT/rBoolTrue","true"}, | ||||||
{"TXT/rBoolFalse","false"}, | ||||||
}; | ||||||
|
||||||
for (size_t i=0;i<ARRAY_SIZE(tests);i++){ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
char expected[90]; | ||||||
const char* path = tests[i].path; | ||||||
const char* value = tests[i].value; | ||||||
snprintf(expected,sizeof(expected),"#%s %s",path,value); | ||||||
int resp_len = ts_txt_statement_by_path(&ts, (char *)resp_buf, TS_RESP_BUFFER_LEN, path); | ||||||
TEST_ASSERT_TXT_RESP(resp_len, expected); | ||||||
} | ||||||
} | ||||||
|
||||||
void test_txt_pub_list_channels(void) | ||||||
{ | ||||||
TEST_ASSERT_TXT_REQ("?_pub/", ":85 Content. [\"mReport\",\"Info\"]"); | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this check is not necessary as the maximum available size was already provided to
ts_json_serialize_value
before. So if no error occurred, the data will always fit into the buffer.