mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-25 06:13:14 +03:00
[FL-3502] SubGhz: fix Protocol not found error message
This commit is contained in:
parent
9d7396ee63
commit
0ecec8a711
applications/main/subghz
helpers
scenes
lib/subghz
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#define TAG "SubGhzCreateProtocolKey"
|
#define TAG "SubGhzCreateProtocolKey"
|
||||||
|
|
||||||
bool subghz_txrx_gen_data_protocol(
|
SubGhzProtocolStatus subghz_txrx_gen_data_protocol(
|
||||||
void* context,
|
void* context,
|
||||||
const char* preset_name,
|
const char* preset_name,
|
||||||
uint32_t frequency,
|
uint32_t frequency,
|
||||||
@ -23,30 +23,29 @@ bool subghz_txrx_gen_data_protocol(
|
|||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
SubGhzTxRx* instance = context;
|
SubGhzTxRx* instance = context;
|
||||||
|
|
||||||
bool res = false;
|
SubGhzProtocolStatus ret = SubGhzProtocolStatusOk;
|
||||||
|
|
||||||
subghz_txrx_set_preset(instance, preset_name, frequency, NULL, 0);
|
subghz_txrx_set_preset(instance, preset_name, frequency, NULL, 0);
|
||||||
instance->decoder_result =
|
instance->decoder_result =
|
||||||
subghz_receiver_search_decoder_base_by_name(instance->receiver, protocol_name);
|
subghz_receiver_search_decoder_base_by_name(instance->receiver, protocol_name);
|
||||||
|
|
||||||
if(instance->decoder_result == NULL) {
|
if(instance->decoder_result == NULL) {
|
||||||
//TODO: Error
|
|
||||||
// furi_string_set(error_str, "Protocol not\nfound!");
|
|
||||||
// scene_manager_next_scene(scene_manager, SubGhzSceneShowErrorSub);
|
|
||||||
FURI_LOG_E(TAG, "Protocol not found!");
|
FURI_LOG_E(TAG, "Protocol not found!");
|
||||||
return false;
|
ret = SubGhzProtocolStatusErrorProtocolNotFound;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Stream* fff_data_stream = flipper_format_get_raw_stream(instance->fff_data);
|
Stream* fff_data_stream = flipper_format_get_raw_stream(instance->fff_data);
|
||||||
stream_clean(fff_data_stream);
|
stream_clean(fff_data_stream);
|
||||||
if(subghz_protocol_decoder_base_serialize(
|
ret = subghz_protocol_decoder_base_serialize(
|
||||||
instance->decoder_result, instance->fff_data, instance->preset) !=
|
instance->decoder_result, instance->fff_data, instance->preset);
|
||||||
SubGhzProtocolStatusOk) {
|
if(ret != SubGhzProtocolStatusOk) {
|
||||||
FURI_LOG_E(TAG, "Unable to serialize");
|
FURI_LOG_E(TAG, "Unable to serialize");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!flipper_format_update_uint32(instance->fff_data, "Bit", &bit, 1)) {
|
if(!flipper_format_update_uint32(instance->fff_data, "Bit", &bit, 1)) {
|
||||||
|
ret = SubGhzProtocolStatusErrorParserOthers;
|
||||||
FURI_LOG_E(TAG, "Unable to update Bit");
|
FURI_LOG_E(TAG, "Unable to update Bit");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -56,15 +55,15 @@ bool subghz_txrx_gen_data_protocol(
|
|||||||
key_data[sizeof(uint64_t) - i - 1] = (key >> (i * 8)) & 0xFF;
|
key_data[sizeof(uint64_t) - i - 1] = (key >> (i * 8)) & 0xFF;
|
||||||
}
|
}
|
||||||
if(!flipper_format_update_hex(instance->fff_data, "Key", key_data, sizeof(uint64_t))) {
|
if(!flipper_format_update_hex(instance->fff_data, "Key", key_data, sizeof(uint64_t))) {
|
||||||
|
ret = SubGhzProtocolStatusErrorParserOthers;
|
||||||
FURI_LOG_E(TAG, "Unable to update Key");
|
FURI_LOG_E(TAG, "Unable to update Key");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
res = true;
|
|
||||||
} while(false);
|
} while(false);
|
||||||
return res;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subghz_txrx_gen_data_protocol_and_te(
|
SubGhzProtocolStatus subghz_txrx_gen_data_protocol_and_te(
|
||||||
SubGhzTxRx* instance,
|
SubGhzTxRx* instance,
|
||||||
const char* preset_name,
|
const char* preset_name,
|
||||||
uint32_t frequency,
|
uint32_t frequency,
|
||||||
@ -73,18 +72,18 @@ bool subghz_txrx_gen_data_protocol_and_te(
|
|||||||
uint32_t bit,
|
uint32_t bit,
|
||||||
uint32_t te) {
|
uint32_t te) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
bool ret = false;
|
SubGhzProtocolStatus ret =
|
||||||
if(subghz_txrx_gen_data_protocol(instance, preset_name, frequency, protocol_name, key, bit)) {
|
subghz_txrx_gen_data_protocol(instance, preset_name, frequency, protocol_name, key, bit);
|
||||||
|
if(ret == SubGhzProtocolStatusOk) {
|
||||||
if(!flipper_format_update_uint32(instance->fff_data, "TE", (uint32_t*)&te, 1)) {
|
if(!flipper_format_update_uint32(instance->fff_data, "TE", (uint32_t*)&te, 1)) {
|
||||||
|
ret = SubGhzProtocolStatusErrorParserOthers;
|
||||||
FURI_LOG_E(TAG, "Unable to update Te");
|
FURI_LOG_E(TAG, "Unable to update Te");
|
||||||
} else {
|
|
||||||
ret = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subghz_txrx_gen_keeloq_protocol(
|
SubGhzProtocolStatus subghz_txrx_gen_keeloq_protocol(
|
||||||
SubGhzTxRx* instance,
|
SubGhzTxRx* instance,
|
||||||
const char* name_preset,
|
const char* name_preset,
|
||||||
uint32_t frequency,
|
uint32_t frequency,
|
||||||
@ -94,7 +93,7 @@ bool subghz_txrx_gen_keeloq_protocol(
|
|||||||
uint16_t cnt) {
|
uint16_t cnt) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
bool ret = false;
|
SubGhzProtocolStatus ret = SubGhzProtocolStatusError;
|
||||||
serial &= 0x0FFFFFFF;
|
serial &= 0x0FFFFFFF;
|
||||||
instance->transmitter =
|
instance->transmitter =
|
||||||
subghz_transmitter_alloc_init(instance->environment, SUBGHZ_PROTOCOL_KEELOQ_NAME);
|
subghz_transmitter_alloc_init(instance->environment, SUBGHZ_PROTOCOL_KEELOQ_NAME);
|
||||||
@ -108,13 +107,13 @@ bool subghz_txrx_gen_keeloq_protocol(
|
|||||||
cnt,
|
cnt,
|
||||||
name_sysmem,
|
name_sysmem,
|
||||||
instance->preset);
|
instance->preset);
|
||||||
ret = true;
|
ret = SubGhzProtocolStatusOk;
|
||||||
}
|
}
|
||||||
subghz_transmitter_free(instance->transmitter);
|
subghz_transmitter_free(instance->transmitter);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subghz_txrx_gen_secplus_v2_protocol(
|
SubGhzProtocolStatus subghz_txrx_gen_secplus_v2_protocol(
|
||||||
SubGhzTxRx* instance,
|
SubGhzTxRx* instance,
|
||||||
const char* name_preset,
|
const char* name_preset,
|
||||||
uint32_t frequency,
|
uint32_t frequency,
|
||||||
@ -123,10 +122,11 @@ bool subghz_txrx_gen_secplus_v2_protocol(
|
|||||||
uint32_t cnt) {
|
uint32_t cnt) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
bool ret = false;
|
SubGhzProtocolStatus ret = SubGhzProtocolStatusError;
|
||||||
instance->transmitter =
|
instance->transmitter =
|
||||||
subghz_transmitter_alloc_init(instance->environment, SUBGHZ_PROTOCOL_SECPLUS_V2_NAME);
|
subghz_transmitter_alloc_init(instance->environment, SUBGHZ_PROTOCOL_SECPLUS_V2_NAME);
|
||||||
subghz_txrx_set_preset(instance, name_preset, frequency, NULL, 0);
|
subghz_txrx_set_preset(instance, name_preset, frequency, NULL, 0);
|
||||||
|
|
||||||
if(instance->transmitter) {
|
if(instance->transmitter) {
|
||||||
subghz_protocol_secplus_v2_create_data(
|
subghz_protocol_secplus_v2_create_data(
|
||||||
subghz_transmitter_get_protocol_instance(instance->transmitter),
|
subghz_transmitter_get_protocol_instance(instance->transmitter),
|
||||||
@ -135,30 +135,27 @@ bool subghz_txrx_gen_secplus_v2_protocol(
|
|||||||
btn,
|
btn,
|
||||||
cnt,
|
cnt,
|
||||||
instance->preset);
|
instance->preset);
|
||||||
ret = true;
|
ret = SubGhzProtocolStatusOk;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subghz_txrx_gen_secplus_v1_protocol(
|
SubGhzProtocolStatus subghz_txrx_gen_secplus_v1_protocol(
|
||||||
SubGhzTxRx* instance,
|
SubGhzTxRx* instance,
|
||||||
const char* name_preset,
|
const char* name_preset,
|
||||||
uint32_t frequency) {
|
uint32_t frequency) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
bool ret = false;
|
|
||||||
uint32_t serial = (uint32_t)rand();
|
uint32_t serial = (uint32_t)rand();
|
||||||
while(!subghz_protocol_secplus_v1_check_fixed(serial)) {
|
while(!subghz_protocol_secplus_v1_check_fixed(serial)) {
|
||||||
serial = (uint32_t)rand();
|
serial = (uint32_t)rand();
|
||||||
}
|
}
|
||||||
if(subghz_txrx_gen_data_protocol(
|
|
||||||
instance,
|
return subghz_txrx_gen_data_protocol(
|
||||||
name_preset,
|
instance,
|
||||||
frequency,
|
name_preset,
|
||||||
SUBGHZ_PROTOCOL_SECPLUS_V1_NAME,
|
frequency,
|
||||||
(uint64_t)serial << 32 | 0xE6000000,
|
SUBGHZ_PROTOCOL_SECPLUS_V1_NAME,
|
||||||
42)) {
|
(uint64_t)serial << 32 | 0xE6000000,
|
||||||
ret = true;
|
42);
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
@ -11,9 +11,9 @@
|
|||||||
* @param protocol_name Name of protocol
|
* @param protocol_name Name of protocol
|
||||||
* @param key Key
|
* @param key Key
|
||||||
* @param bit Bit
|
* @param bit Bit
|
||||||
* @return bool True if success
|
* @return SubGhzProtocolStatus
|
||||||
*/
|
*/
|
||||||
bool subghz_txrx_gen_data_protocol(
|
SubGhzProtocolStatus subghz_txrx_gen_data_protocol(
|
||||||
void* context,
|
void* context,
|
||||||
const char* preset_name,
|
const char* preset_name,
|
||||||
uint32_t frequency,
|
uint32_t frequency,
|
||||||
@ -31,9 +31,9 @@ bool subghz_txrx_gen_data_protocol(
|
|||||||
* @param key Key
|
* @param key Key
|
||||||
* @param bit Bit
|
* @param bit Bit
|
||||||
* @param te Te
|
* @param te Te
|
||||||
* @return bool True if success
|
* @return SubGhzProtocolStatus
|
||||||
*/
|
*/
|
||||||
bool subghz_txrx_gen_data_protocol_and_te(
|
SubGhzProtocolStatus subghz_txrx_gen_data_protocol_and_te(
|
||||||
SubGhzTxRx* instance,
|
SubGhzTxRx* instance,
|
||||||
const char* preset_name,
|
const char* preset_name,
|
||||||
uint32_t frequency,
|
uint32_t frequency,
|
||||||
@ -52,9 +52,9 @@ bool subghz_txrx_gen_data_protocol_and_te(
|
|||||||
* @param serial Serial number
|
* @param serial Serial number
|
||||||
* @param btn Button
|
* @param btn Button
|
||||||
* @param cnt Counter
|
* @param cnt Counter
|
||||||
* @return bool True if success
|
* @return SubGhzProtocolStatus
|
||||||
*/
|
*/
|
||||||
bool subghz_txrx_gen_keeloq_protocol(
|
SubGhzProtocolStatus subghz_txrx_gen_keeloq_protocol(
|
||||||
SubGhzTxRx* instance,
|
SubGhzTxRx* instance,
|
||||||
const char* name_preset,
|
const char* name_preset,
|
||||||
uint32_t frequency,
|
uint32_t frequency,
|
||||||
@ -72,9 +72,9 @@ bool subghz_txrx_gen_keeloq_protocol(
|
|||||||
* @param serial Serial number
|
* @param serial Serial number
|
||||||
* @param btn Button
|
* @param btn Button
|
||||||
* @param cnt Counter
|
* @param cnt Counter
|
||||||
* @return bool True if success
|
* @return SubGhzProtocolStatus
|
||||||
*/
|
*/
|
||||||
bool subghz_txrx_gen_secplus_v2_protocol(
|
SubGhzProtocolStatus subghz_txrx_gen_secplus_v2_protocol(
|
||||||
SubGhzTxRx* instance,
|
SubGhzTxRx* instance,
|
||||||
const char* name_preset,
|
const char* name_preset,
|
||||||
uint32_t frequency,
|
uint32_t frequency,
|
||||||
@ -88,9 +88,9 @@ bool subghz_txrx_gen_secplus_v2_protocol(
|
|||||||
* @param instance Pointer to a SubGhzTxRx
|
* @param instance Pointer to a SubGhzTxRx
|
||||||
* @param name_preset Name of preset
|
* @param name_preset Name of preset
|
||||||
* @param frequency Frequency in Hz
|
* @param frequency Frequency in Hz
|
||||||
* @return bool True if success
|
* @return SubGhzProtocolStatus
|
||||||
*/
|
*/
|
||||||
bool subghz_txrx_gen_secplus_v1_protocol(
|
SubGhzProtocolStatus subghz_txrx_gen_secplus_v1_protocol(
|
||||||
SubGhzTxRx* instance,
|
SubGhzTxRx* instance,
|
||||||
const char* name_preset,
|
const char* name_preset,
|
||||||
uint32_t frequency);
|
uint32_t frequency);
|
@ -118,7 +118,7 @@ void subghz_scene_set_type_on_enter(void* context) {
|
|||||||
|
|
||||||
bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||||
SubGhz* subghz = context;
|
SubGhz* subghz = context;
|
||||||
bool generated_protocol = false;
|
SubGhzProtocolStatus generated_protocol = SubGhzProtocolStatusError;
|
||||||
|
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
uint32_t key = (uint32_t)rand();
|
uint32_t key = (uint32_t)rand();
|
||||||
@ -216,7 +216,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
|||||||
|
|
||||||
scene_manager_set_scene_state(subghz->scene_manager, SubGhzSceneSetType, event.event);
|
scene_manager_set_scene_state(subghz->scene_manager, SubGhzSceneSetType, event.event);
|
||||||
|
|
||||||
if(generated_protocol) {
|
if(generated_protocol == SubGhzProtocolStatusOk) {
|
||||||
subghz_file_name_clear(subghz);
|
subghz_file_name_clear(subghz);
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
||||||
return true;
|
return true;
|
||||||
|
@ -57,6 +57,7 @@ typedef enum {
|
|||||||
// Encoder issue
|
// Encoder issue
|
||||||
SubGhzProtocolStatusErrorEncoderGetUpload = (-12), ///< Payload encoder failure
|
SubGhzProtocolStatusErrorEncoderGetUpload = (-12), ///< Payload encoder failure
|
||||||
// Special Values
|
// Special Values
|
||||||
|
SubGhzProtocolStatusErrorProtocolNotFound = (-13), ///< Protocol not found
|
||||||
SubGhzProtocolStatusReserved = 0x7FFFFFFF, ///< Prevents enum down-size compiler optimization.
|
SubGhzProtocolStatusReserved = 0x7FFFFFFF, ///< Prevents enum down-size compiler optimization.
|
||||||
} SubGhzProtocolStatus;
|
} SubGhzProtocolStatus;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user