mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-27 15:00:46 +00:00
Update pocsag pager app to new error system
This commit is contained in:
parent
056f2eb7d5
commit
db0c34f63e
3 changed files with 21 additions and 16 deletions
|
@ -21,12 +21,12 @@ void pcsg_block_generic_get_preset_name(const char* preset_name, FuriString* pre
|
|||
furi_string_set(preset_str, preset_name_temp);
|
||||
}
|
||||
|
||||
bool pcsg_block_generic_serialize(
|
||||
SubGhzProtocolStatus pcsg_block_generic_serialize(
|
||||
PCSGBlockGeneric* instance,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset) {
|
||||
furi_assert(instance);
|
||||
bool res = false;
|
||||
SubGhzProtocolStatus res = SubGhzProtocolStatusError;
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
do {
|
||||
|
@ -75,15 +75,16 @@ bool pcsg_block_generic_serialize(
|
|||
break;
|
||||
}
|
||||
|
||||
res = true;
|
||||
res = SubGhzProtocolStatusOk;
|
||||
} while(false);
|
||||
furi_string_free(temp_str);
|
||||
return res;
|
||||
}
|
||||
|
||||
bool pcsg_block_generic_deserialize(PCSGBlockGeneric* instance, FlipperFormat* flipper_format) {
|
||||
SubGhzProtocolStatus
|
||||
pcsg_block_generic_deserialize(PCSGBlockGeneric* instance, FlipperFormat* flipper_format) {
|
||||
furi_assert(instance);
|
||||
bool res = false;
|
||||
SubGhzProtocolStatus res = SubGhzProtocolStatusError;
|
||||
FuriString* temp_data = furi_string_alloc();
|
||||
FuriString* temp_data2 = furi_string_alloc();
|
||||
|
||||
|
@ -113,7 +114,7 @@ bool pcsg_block_generic_deserialize(PCSGBlockGeneric* instance, FlipperFormat* f
|
|||
instance->result_msg = furi_string_alloc_set(temp_data);
|
||||
}
|
||||
|
||||
res = true;
|
||||
res = SubGhzProtocolStatusOk;
|
||||
} while(0);
|
||||
|
||||
furi_string_free(temp_data);
|
||||
|
|
|
@ -35,7 +35,7 @@ void pcsg_block_generic_get_preset_name(const char* preset_name, FuriString* pre
|
|||
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
|
||||
* @return true On success
|
||||
*/
|
||||
bool pcsg_block_generic_serialize(
|
||||
SubGhzProtocolStatus pcsg_block_generic_serialize(
|
||||
PCSGBlockGeneric* instance,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset);
|
||||
|
@ -46,7 +46,8 @@ bool pcsg_block_generic_serialize(
|
|||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @return true On success
|
||||
*/
|
||||
bool pcsg_block_generic_deserialize(PCSGBlockGeneric* instance, FlipperFormat* flipper_format);
|
||||
SubGhzProtocolStatus
|
||||
pcsg_block_generic_deserialize(PCSGBlockGeneric* instance, FlipperFormat* flipper_format);
|
||||
|
||||
float pcsg_block_generic_fahrenheit_to_celsius(float fahrenheit);
|
||||
|
||||
|
|
|
@ -288,7 +288,7 @@ uint8_t subghz_protocol_decoder_pocsag_get_hash_data(void* context) {
|
|||
return hash;
|
||||
}
|
||||
|
||||
bool subghz_protocol_decoder_pocsag_serialize(
|
||||
SubGhzProtocolStatus subghz_protocol_decoder_pocsag_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset) {
|
||||
|
@ -296,26 +296,29 @@ bool subghz_protocol_decoder_pocsag_serialize(
|
|||
SubGhzProtocolDecoderPocsag* instance = context;
|
||||
uint32_t msg_len;
|
||||
|
||||
if(!pcsg_block_generic_serialize(&instance->generic, flipper_format, preset)) return false;
|
||||
if(SubGhzProtocolStatusOk !=
|
||||
pcsg_block_generic_serialize(&instance->generic, flipper_format, preset))
|
||||
return SubGhzProtocolStatusError;
|
||||
|
||||
msg_len = furi_string_size(instance->done_msg);
|
||||
if(!flipper_format_write_uint32(flipper_format, "MsgLen", &msg_len, 1)) {
|
||||
FURI_LOG_E(TAG, "Error adding MsgLen");
|
||||
return false;
|
||||
return SubGhzProtocolStatusError;
|
||||
}
|
||||
|
||||
uint8_t* s = (uint8_t*)furi_string_get_cstr(instance->done_msg);
|
||||
if(!flipper_format_write_hex(flipper_format, "Msg", s, msg_len)) {
|
||||
FURI_LOG_E(TAG, "Error adding Msg");
|
||||
return false;
|
||||
return SubGhzProtocolStatusError;
|
||||
}
|
||||
return true;
|
||||
return SubGhzProtocolStatusOk;
|
||||
}
|
||||
|
||||
bool subghz_protocol_decoder_pocsag_deserialize(void* context, FlipperFormat* flipper_format) {
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_pocsag_deserialize(void* context, FlipperFormat* flipper_format) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderPocsag* instance = context;
|
||||
bool ret = false;
|
||||
SubGhzProtocolStatus ret = SubGhzProtocolStatusError;
|
||||
uint32_t msg_len;
|
||||
uint8_t* buf;
|
||||
|
||||
|
@ -338,7 +341,7 @@ bool subghz_protocol_decoder_pocsag_deserialize(void* context, FlipperFormat* fl
|
|||
furi_string_set_strn(instance->done_msg, (const char*)buf, msg_len);
|
||||
free(buf);
|
||||
|
||||
ret = true;
|
||||
ret = SubGhzProtocolStatusOk;
|
||||
} while(false);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue