Skip to content

Commit

Permalink
Fix the generation of signal files with custom presets (antirez#14)
Browse files Browse the repository at this point in the history
Fix the incomplete custom preset data and the line feed in the wrong location for the signal file generation code.
  • Loading branch information
thedroidgeek committed Jun 9, 2023
1 parent e0d6e97 commit adfdd01
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions signal_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,21 @@ bool save_signal(ProtoViewApp *app, const char *filename) {
furi_string_printf(custom,
"Custom_preset_module: CC1101\n"
"Custom_preset_data: ");
for (int j = 0; regs[j]; j += 2) {

/* We will know the size of the preset data once we reach the end
* of the registers (null address). For now it's INT_MAX. */
int preset_data_size = INT_MAX;
bool patable_reached = false;
for(int j = 0; j <= preset_data_size; j += 2) {
// End reached, set the size to write the remaining 8 bytes (PATABLE)
if (!patable_reached && regs[j] == 0) {
preset_data_size = j + 8;
patable_reached = true;
}
furi_string_cat_printf(custom, "%02X %02X ",
(int)regs[j], (int)regs[j+1]);
}
size_t len = furi_string_size(file_content);
size_t len = furi_string_size(custom);
furi_string_set_char(custom,len-1,'\n');
furi_string_cat(file_content,custom);
furi_string_free(custom);
Expand Down

0 comments on commit adfdd01

Please sign in to comment.