Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vad7 committed Apr 4, 2023
1 parent c2e50be commit 29e118c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Distr/nrf24batch/CO2_mini.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ R: CO2 threshold*2=5,,0xC2
W: CO2 threshold=,5,0x82

R: CO2 correct*2=7,,0xC2
W: CO2 correct=,7,0x82
W: CO2 correct*2=,7,0x82

R: FanLSB[10]=i:9#
W: FanLSB=,i:9
Expand All @@ -66,7 +66,7 @@ S: LED=,0,0x40
SBatch: LED On: LED=1
SBatch: LED Off: LED=0

RBatch: Settings: ID;RxAddr;Ch;Send period;CO2 threshold;CO2 correct;FanLSB;nRF RETR;Send pause;Flags
RBatch: Settings: ID;RxAddr;Ch;Send period;CO2 threshold;CO2 correct;FanLSB;nRF RETR;Transmit pause;Flags

WBatch: Default: RxAddr=0xCF;Ch=122;Send period=30;CO2 threshold=1000;CO2 correct=0;FanLSB={0xC1,0,0,0,0,0,0,0};nRF RETR=0x3;Transmit pause=1;Flags=0;Reset
WBatch: CO2: CO2 threshold=1000;CO2 correct=0
Expand Down
40 changes: 21 additions & 19 deletions nrf24batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,12 @@ bool nrf24_read_newpacket() {
if(size == 0) furi_string_cat_printf(str, "%c", (char)var);
else {
char hex[9];
snprintf(hex, sizeof(hex), "%lX", var);
hex[0] = '\0';
add_to_str_hex_bytes(hex, (uint8_t*)&var, size);
if((cmd_array && cmd_array_hex) || furi_string_end_with_str(str, "0x")) furi_string_cat_str(str, hex);
else {
if(var >= 0 && var <= 9) furi_string_cat_printf(str, "%ld", var);
else furi_string_cat_printf(str, "%ld (%s)", var, hex + (var < 0 ? 8 - size * 2 : 0));
else furi_string_cat_printf(str, "%ld (%s)", var, hex);
}
}
if(cmd_array) {
Expand Down Expand Up @@ -970,23 +971,24 @@ static void save_batch(void)
if(p2 && *(p2-1) != '*') { // skip string
if(*(p2-1) == ']') { // array
char *p3 = strchr(p, '[');
if(p3 == NULL) p3 = p2;
stream_write(file_stream, (uint8_t*)p, p3 - p);
stream_write_cstring(file_stream, "={");
p = (p2 += 2);
do {
while(is_digit(p2, true) || *p2 == 'x') p2++;
stream_write(file_stream, (uint8_t*)p, p2 - p);
char c = *p2;
if(c == '\0') break;
if(c != ',') {
p2 = strchr(p2, ',');
if(p2 == NULL) break;
}
stream_write_char(file_stream, ',');
p = ++p2;
} while(1);
stream_write_char(file_stream, '}');
if(p3) {
stream_write(file_stream, (uint8_t*)p, p3 - p - (*(p3-2) == '*' ? 2 : 0));
stream_write_cstring(file_stream, "={");
p = (p2 += 2);
do {
while(is_digit(p2, true) || *p2 == 'x') p2++;
stream_write(file_stream, (uint8_t*)p, p2 - p);
char c = *p2;
if(c == '\0') break;
if(c != ',') {
p2 = strchr(p2, ',');
if(p2 == NULL) break;
}
stream_write_char(file_stream, ',');
p = ++p2;
} while(1);
stream_write_char(file_stream, '}');
}
} else {
stream_write(file_stream, (uint8_t*)p, p2 - p - (*(p2-2) == '*' ? 2 : 0));
stream_write_char(file_stream, '=');
Expand Down

0 comments on commit 29e118c

Please sign in to comment.