Skip to content

Commit 29e118c

Browse files
committed
fix
1 parent c2e50be commit 29e118c

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

Distr/nrf24batch/CO2_mini.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ R: CO2 threshold*2=5,,0xC2
4545
W: CO2 threshold=,5,0x82
4646

4747
R: CO2 correct*2=7,,0xC2
48-
W: CO2 correct=,7,0x82
48+
W: CO2 correct*2=,7,0x82
4949

5050
R: FanLSB[10]=i:9#
5151
W: FanLSB=,i:9
@@ -66,7 +66,7 @@ S: LED=,0,0x40
6666
SBatch: LED On: LED=1
6767
SBatch: LED Off: LED=0
6868

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

7171
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
7272
WBatch: CO2: CO2 threshold=1000;CO2 correct=0

nrf24batch.c

+21-19
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,12 @@ bool nrf24_read_newpacket() {
481481
if(size == 0) furi_string_cat_printf(str, "%c", (char)var);
482482
else {
483483
char hex[9];
484-
snprintf(hex, sizeof(hex), "%lX", var);
484+
hex[0] = '\0';
485+
add_to_str_hex_bytes(hex, (uint8_t*)&var, size);
485486
if((cmd_array && cmd_array_hex) || furi_string_end_with_str(str, "0x")) furi_string_cat_str(str, hex);
486487
else {
487488
if(var >= 0 && var <= 9) furi_string_cat_printf(str, "%ld", var);
488-
else furi_string_cat_printf(str, "%ld (%s)", var, hex + (var < 0 ? 8 - size * 2 : 0));
489+
else furi_string_cat_printf(str, "%ld (%s)", var, hex);
489490
}
490491
}
491492
if(cmd_array) {
@@ -970,23 +971,24 @@ static void save_batch(void)
970971
if(p2 && *(p2-1) != '*') { // skip string
971972
if(*(p2-1) == ']') { // array
972973
char *p3 = strchr(p, '[');
973-
if(p3 == NULL) p3 = p2;
974-
stream_write(file_stream, (uint8_t*)p, p3 - p);
975-
stream_write_cstring(file_stream, "={");
976-
p = (p2 += 2);
977-
do {
978-
while(is_digit(p2, true) || *p2 == 'x') p2++;
979-
stream_write(file_stream, (uint8_t*)p, p2 - p);
980-
char c = *p2;
981-
if(c == '\0') break;
982-
if(c != ',') {
983-
p2 = strchr(p2, ',');
984-
if(p2 == NULL) break;
985-
}
986-
stream_write_char(file_stream, ',');
987-
p = ++p2;
988-
} while(1);
989-
stream_write_char(file_stream, '}');
974+
if(p3) {
975+
stream_write(file_stream, (uint8_t*)p, p3 - p - (*(p3-2) == '*' ? 2 : 0));
976+
stream_write_cstring(file_stream, "={");
977+
p = (p2 += 2);
978+
do {
979+
while(is_digit(p2, true) || *p2 == 'x') p2++;
980+
stream_write(file_stream, (uint8_t*)p, p2 - p);
981+
char c = *p2;
982+
if(c == '\0') break;
983+
if(c != ',') {
984+
p2 = strchr(p2, ',');
985+
if(p2 == NULL) break;
986+
}
987+
stream_write_char(file_stream, ',');
988+
p = ++p2;
989+
} while(1);
990+
stream_write_char(file_stream, '}');
991+
}
990992
} else {
991993
stream_write(file_stream, (uint8_t*)p, p2 - p - (*(p2-2) == '*' ? 2 : 0));
992994
stream_write_char(file_stream, '=');

0 commit comments

Comments
 (0)