mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-24 05:34:45 -07:00
Update pocsag pager app to new error system
This commit is contained in:
@@ -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);
|
furi_string_set(preset_str, preset_name_temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pcsg_block_generic_serialize(
|
SubGhzProtocolStatus pcsg_block_generic_serialize(
|
||||||
PCSGBlockGeneric* instance,
|
PCSGBlockGeneric* instance,
|
||||||
FlipperFormat* flipper_format,
|
FlipperFormat* flipper_format,
|
||||||
SubGhzRadioPreset* preset) {
|
SubGhzRadioPreset* preset) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
bool res = false;
|
SubGhzProtocolStatus res = SubGhzProtocolStatusError;
|
||||||
FuriString* temp_str;
|
FuriString* temp_str;
|
||||||
temp_str = furi_string_alloc();
|
temp_str = furi_string_alloc();
|
||||||
do {
|
do {
|
||||||
@@ -75,15 +75,16 @@ bool pcsg_block_generic_serialize(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = true;
|
res = SubGhzProtocolStatusOk;
|
||||||
} while(false);
|
} while(false);
|
||||||
furi_string_free(temp_str);
|
furi_string_free(temp_str);
|
||||||
return res;
|
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);
|
furi_assert(instance);
|
||||||
bool res = false;
|
SubGhzProtocolStatus res = SubGhzProtocolStatusError;
|
||||||
FuriString* temp_data = furi_string_alloc();
|
FuriString* temp_data = furi_string_alloc();
|
||||||
FuriString* temp_data2 = 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);
|
instance->result_msg = furi_string_alloc_set(temp_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = true;
|
res = SubGhzProtocolStatusOk;
|
||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
furi_string_free(temp_data);
|
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
|
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
|
||||||
* @return true On success
|
* @return true On success
|
||||||
*/
|
*/
|
||||||
bool pcsg_block_generic_serialize(
|
SubGhzProtocolStatus pcsg_block_generic_serialize(
|
||||||
PCSGBlockGeneric* instance,
|
PCSGBlockGeneric* instance,
|
||||||
FlipperFormat* flipper_format,
|
FlipperFormat* flipper_format,
|
||||||
SubGhzRadioPreset* preset);
|
SubGhzRadioPreset* preset);
|
||||||
@@ -46,7 +46,8 @@ bool pcsg_block_generic_serialize(
|
|||||||
* @param flipper_format Pointer to a FlipperFormat instance
|
* @param flipper_format Pointer to a FlipperFormat instance
|
||||||
* @return true On success
|
* @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);
|
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;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subghz_protocol_decoder_pocsag_serialize(
|
SubGhzProtocolStatus subghz_protocol_decoder_pocsag_serialize(
|
||||||
void* context,
|
void* context,
|
||||||
FlipperFormat* flipper_format,
|
FlipperFormat* flipper_format,
|
||||||
SubGhzRadioPreset* preset) {
|
SubGhzRadioPreset* preset) {
|
||||||
@@ -296,26 +296,29 @@ bool subghz_protocol_decoder_pocsag_serialize(
|
|||||||
SubGhzProtocolDecoderPocsag* instance = context;
|
SubGhzProtocolDecoderPocsag* instance = context;
|
||||||
uint32_t msg_len;
|
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);
|
msg_len = furi_string_size(instance->done_msg);
|
||||||
if(!flipper_format_write_uint32(flipper_format, "MsgLen", &msg_len, 1)) {
|
if(!flipper_format_write_uint32(flipper_format, "MsgLen", &msg_len, 1)) {
|
||||||
FURI_LOG_E(TAG, "Error adding MsgLen");
|
FURI_LOG_E(TAG, "Error adding MsgLen");
|
||||||
return false;
|
return SubGhzProtocolStatusError;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* s = (uint8_t*)furi_string_get_cstr(instance->done_msg);
|
uint8_t* s = (uint8_t*)furi_string_get_cstr(instance->done_msg);
|
||||||
if(!flipper_format_write_hex(flipper_format, "Msg", s, msg_len)) {
|
if(!flipper_format_write_hex(flipper_format, "Msg", s, msg_len)) {
|
||||||
FURI_LOG_E(TAG, "Error adding Msg");
|
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);
|
furi_assert(context);
|
||||||
SubGhzProtocolDecoderPocsag* instance = context;
|
SubGhzProtocolDecoderPocsag* instance = context;
|
||||||
bool ret = false;
|
SubGhzProtocolStatus ret = SubGhzProtocolStatusError;
|
||||||
uint32_t msg_len;
|
uint32_t msg_len;
|
||||||
uint8_t* buf;
|
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);
|
furi_string_set_strn(instance->done_msg, (const char*)buf, msg_len);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
ret = true;
|
ret = SubGhzProtocolStatusOk;
|
||||||
} while(false);
|
} while(false);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user