diff --git a/applications/main/subghz/helpers/subghz_custom_event.h b/applications/main/subghz/helpers/subghz_custom_event.h index 350e68ee6..9ac4552f5 100644 --- a/applications/main/subghz/helpers/subghz_custom_event.h +++ b/applications/main/subghz/helpers/subghz_custom_event.h @@ -64,6 +64,7 @@ typedef enum { SubGhzCustomEventViewReceiverBack, SubGhzCustomEventViewReceiverOffDisplay, SubGhzCustomEventViewReceiverUnlock, + SubGhzCustomEventViewReceiverDeleteItem, SubGhzCustomEventViewReadRAWBack, SubGhzCustomEventViewReadRAWIDLE, diff --git a/applications/main/subghz/scenes/subghz_scene_ext_module_settings.c b/applications/main/subghz/scenes/subghz_scene_ext_module_settings.c index 4627c57be..86e1ff2a0 100644 --- a/applications/main/subghz/scenes/subghz_scene_ext_module_settings.c +++ b/applications/main/subghz/scenes/subghz_scene_ext_module_settings.c @@ -3,6 +3,7 @@ uint8_t value_index; uint8_t value_index2; +uint8_t value_index3; #define EXT_MODULES_COUNT (sizeof(radio_modules_variables_text) / sizeof(char* const)) const char* const radio_modules_variables_text[] = { @@ -16,6 +17,13 @@ const char* const debug_pin_text[DEBUG_P_COUNT] = { "17(1W)", }; +#define DEBUG_COUNTER_COUNT 3 +const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = { + "+1", + "+5", + "+10", +}; + static void subghz_scene_ext_module_changed(VariableItem* item) { SubGhz* subghz = variable_item_get_context(item); value_index = variable_item_get_current_value_index(item); @@ -37,6 +45,26 @@ static void subghz_scene_receiver_config_set_debug_pin(VariableItem* item) { subghz->txrx->debug_pin_state = index == 1; } +static void subghz_scene_receiver_config_set_debug_counter(VariableItem* item) { + uint8_t index = variable_item_get_current_value_index(item); + + variable_item_set_current_value_text(item, debug_counter_text[index]); + + switch(index) { + case 0: + furi_hal_subghz_set_rolling_counter_mult(1); + break; + case 1: + furi_hal_subghz_set_rolling_counter_mult(5); + break; + case 2: + furi_hal_subghz_set_rolling_counter_mult(10); + break; + default: + break; + } +} + void subghz_scene_ext_module_settings_on_enter(void* context) { SubGhz* subghz = context; @@ -62,6 +90,28 @@ void subghz_scene_ext_module_settings_on_enter(void* context) { value_index2 = subghz->txrx->debug_pin_state; variable_item_set_current_value_index(item, value_index2); variable_item_set_current_value_text(item, debug_pin_text[value_index2]); + + item = variable_item_list_add( + subghz->variable_item_list, + "Counter Mult:", + DEBUG_COUNTER_COUNT, + subghz_scene_receiver_config_set_debug_counter, + subghz); + switch(furi_hal_subghz_get_rolling_counter_mult()) { + case 1: + value_index3 = 0; + break; + case 5: + value_index3 = 1; + break; + case 10: + value_index3 = 2; + break; + default: + break; + } + variable_item_set_current_value_index(item, value_index3); + variable_item_set_current_value_text(item, debug_counter_text[value_index3]); } view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList); diff --git a/applications/main/subghz/scenes/subghz_scene_receiver.c b/applications/main/subghz/scenes/subghz_scene_receiver.c index e1ea08497..ba1e2faed 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver.c @@ -204,6 +204,23 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { DOLPHIN_DEED(DolphinDeedSubGhzReceiverInfo); consumed = true; break; + case SubGhzCustomEventViewReceiverDeleteItem: + subghz->txrx->idx_menu_chosen = + subghz_view_receiver_get_idx_menu(subghz->subghz_receiver); + if(subghz->txrx->idx_menu_chosen == 0) { + subghz_history_delete_item(subghz->txrx->history, subghz->txrx->idx_menu_chosen); + subghz_view_receiver_set_idx_menu( + subghz->subghz_receiver, subghz->txrx->idx_menu_chosen); + } else { + subghz_history_delete_item( + subghz->txrx->history, subghz->txrx->idx_menu_chosen + 1); + subghz_view_receiver_set_idx_menu( + subghz->subghz_receiver, subghz->txrx->idx_menu_chosen); + } + + subghz_scene_receiver_update_statusbar(subghz); + consumed = true; + break; case SubGhzCustomEventViewReceiverConfig: subghz->state_notifications = SubGhzNotificationStateIDLE; subghz->txrx->idx_menu_chosen = diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_info.c b/applications/main/subghz/scenes/subghz_scene_receiver_info.c index e5b037f2e..4f4924b06 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_info.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_info.c @@ -2,6 +2,7 @@ #include "../helpers/subghz_custom_event.h" #include #include +#include void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, void* context) { furi_assert(context); @@ -233,6 +234,8 @@ void subghz_scene_receiver_info_on_exit(void* context) { widget_reset(subghz->widget); keeloq_reset_mfname(); keeloq_reset_kl_type(); + keeloq_reset_original_btn(); + alutech_reset_original_btn(); star_line_reset_mfname(); star_line_reset_kl_type(); } diff --git a/applications/main/subghz/scenes/subghz_scene_rpc.c b/applications/main/subghz/scenes/subghz_scene_rpc.c index 68f2e0199..0ff801d79 100644 --- a/applications/main/subghz/scenes/subghz_scene_rpc.c +++ b/applications/main/subghz/scenes/subghz_scene_rpc.c @@ -1,6 +1,7 @@ #include "../subghz_i.h" #include #include +#include typedef enum { SubGhzRpcStateIdle, @@ -110,6 +111,8 @@ void subghz_scene_rpc_on_exit(void* context) { keeloq_reset_mfname(); keeloq_reset_kl_type(); + keeloq_reset_original_btn(); + alutech_reset_original_btn(); star_line_reset_mfname(); star_line_reset_kl_type(); } diff --git a/applications/main/subghz/scenes/subghz_scene_transmitter.c b/applications/main/subghz/scenes/subghz_scene_transmitter.c index dff4f8384..b1d1f467b 100644 --- a/applications/main/subghz/scenes/subghz_scene_transmitter.c +++ b/applications/main/subghz/scenes/subghz_scene_transmitter.c @@ -2,6 +2,7 @@ #include "../views/transmitter.h" #include #include +#include #include void subghz_scene_transmitter_callback(SubGhzCustomEvent event, void* context) { @@ -89,6 +90,22 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) { subghz_tx_stop(subghz); subghz_sleep(subghz); } + if(keeloq_get_custom_btn() != 0) { + keeloq_set_btn(0); + alutech_set_btn(0); + // Calling restore! + if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) { + subghz_rx_end(subghz); + } + if((subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) || + (subghz->txrx->txrx_state == SubGhzTxRxStateSleep)) { + if(!subghz_tx_start(subghz, subghz->txrx->fff_data)) { + scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx); + } + } + subghz_tx_stop(subghz); + subghz_sleep(subghz); + } return true; } else if(event.event == SubGhzCustomEventViewTransmitterBack) { subghz->state_notifications = SubGhzNotificationStateIDLE; @@ -113,6 +130,8 @@ void subghz_scene_transmitter_on_exit(void* context) { subghz->state_notifications = SubGhzNotificationStateIDLE; keeloq_reset_mfname(); keeloq_reset_kl_type(); + keeloq_reset_original_btn(); + alutech_reset_original_btn(); star_line_reset_mfname(); star_line_reset_kl_type(); } diff --git a/applications/main/subghz/subghz_history.c b/applications/main/subghz/subghz_history.c index 184146698..1df7d0238 100644 --- a/applications/main/subghz/subghz_history.c +++ b/applications/main/subghz/subghz_history.c @@ -88,6 +88,30 @@ void subghz_history_reset(SubGhzHistory* instance) { instance->code_last_hash_data = 0; } +void subghz_history_delete_item(SubGhzHistory* instance, uint16_t item_id) { + furi_assert(instance); + + SubGhzHistoryItemArray_it_t it; + SubGhzHistoryItem* target_item = SubGhzHistoryItemArray_get(instance->history->data, item_id); + SubGhzHistoryItemArray_it_last(it, instance->history->data); + while(!SubGhzHistoryItemArray_end_p(it)) { + SubGhzHistoryItem* item = SubGhzHistoryItemArray_ref(it); + + if(strcmp( + furi_string_get_cstr(item->item_str), + furi_string_get_cstr(target_item->item_str)) == 0) { + furi_string_free(item->item_str); + furi_string_free(item->preset->name); + free(item->preset); + flipper_format_free(item->flipper_string); + item->type = 0; + SubGhzHistoryItemArray_remove(instance->history->data, it); + } + SubGhzHistoryItemArray_previous(it); + } + instance->last_index_write--; +} + uint16_t subghz_history_get_item(SubGhzHistory* instance) { furi_assert(instance); return instance->last_index_write; diff --git a/applications/main/subghz/subghz_history.h b/applications/main/subghz/subghz_history.h index 4b01f5aef..1f2f8d246 100644 --- a/applications/main/subghz/subghz_history.h +++ b/applications/main/subghz/subghz_history.h @@ -27,6 +27,8 @@ void subghz_history_free(SubGhzHistory* instance); */ void subghz_history_reset(SubGhzHistory* instance); +void subghz_history_delete_item(SubGhzHistory* instance, uint16_t item_id); + /** Get frequency to history[idx] * * @param instance - SubGhzHistory instance diff --git a/applications/main/subghz/views/receiver.c b/applications/main/subghz/views/receiver.c index f981a2eef..74c7d749b 100644 --- a/applications/main/subghz/views/receiver.c +++ b/applications/main/subghz/views/receiver.c @@ -427,6 +427,54 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) { true); } else if(event->key == InputKeyLeft && event->type == InputTypeShort) { subghz_receiver->callback(SubGhzCustomEventViewReceiverConfig, subghz_receiver->context); + } else if(event->key == InputKeyRight && event->type == InputTypeLong) { + with_view_model( + subghz_receiver->view, + SubGhzViewReceiverModel * model, + { + if(model->history_item != 0) { + SubGhzReceiverMenuItemArray_it_t it; + SubGhzReceiverMenuItem* target_item = + SubGhzReceiverMenuItemArray_get(model->history->data, model->idx); + SubGhzReceiverMenuItemArray_it_last(it, model->history->data); + while(!SubGhzReceiverMenuItemArray_end_p(it)) { + SubGhzReceiverMenuItem* item = SubGhzReceiverMenuItemArray_ref(it); + + if(strcmp( + furi_string_get_cstr(item->item_str), + furi_string_get_cstr(target_item->item_str)) == 0) { + furi_string_free(item->item_str); + item->type = 0; + SubGhzReceiverMenuItemArray_remove(model->history->data, it); + if(model->history_item == 5) { + if(model->idx >= 2) { + model->idx = model->history_item - 1; + } + } + if(model->idx == model->history_item - 1) { + if(model->idx != 0) { + model->idx--; + } + } + } + + SubGhzReceiverMenuItemArray_previous(it); + } + } + }, + true); + + with_view_model( + subghz_receiver->view, + SubGhzViewReceiverModel * model, + { + if(model->history_item != 0) { + subghz_receiver->callback( + SubGhzCustomEventViewReceiverDeleteItem, subghz_receiver->context); + model->history_item--; + } + }, + true); } else if(event->key == InputKeyOk && event->type == InputTypeShort) { with_view_model( subghz_receiver->view, diff --git a/applications/main/subghz/views/transmitter.c b/applications/main/subghz/views/transmitter.c index 102639924..218bf8f7e 100644 --- a/applications/main/subghz/views/transmitter.c +++ b/applications/main/subghz/views/transmitter.c @@ -4,6 +4,9 @@ #include #include +#include +#include + struct SubGhzViewTransmitter { View* view; SubGhzViewTransmitterCallback callback; @@ -15,6 +18,8 @@ typedef struct { FuriString* preset_str; FuriString* key_str; uint8_t show_button; + FuriString* temp_button_id; + bool draw_temp_button; } SubGhzViewTransmitterModel; void subghz_view_transmitter_set_callback( @@ -89,6 +94,12 @@ void subghz_view_transmitter_draw(Canvas* canvas, SubGhzViewTransmitterModel* mo canvas_draw_str(canvas, 78, 7, furi_string_get_cstr(model->frequency_str)); canvas_draw_str(canvas, 113, 7, furi_string_get_cstr(model->preset_str)); + if(model->draw_temp_button) { + canvas_set_font(canvas, FontBatteryPercent); + canvas_draw_str(canvas, 117, 40, furi_string_get_cstr(model->temp_button_id)); + canvas_set_font(canvas, FontSecondary); + } + if(model->show_button) { canvas_draw_str(canvas, 58, 62, furi_hal_subghz_get_radio_type() ? "R: Ext" : "R: Int"); subghz_view_transmitter_button_right(canvas, "Send"); @@ -108,7 +119,9 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { furi_string_reset(model->frequency_str); furi_string_reset(model->preset_str); furi_string_reset(model->key_str); + furi_string_reset(model->temp_button_id); model->show_button = 0; + model->draw_temp_button = false; }, false); return false; @@ -125,6 +138,14 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { true); if(can_be_sent && event->key == InputKeyOk && event->type == InputTypePress) { + with_view_model( + subghz_transmitter->view, + SubGhzViewTransmitterModel * model, + { + furi_string_reset(model->temp_button_id); + model->draw_temp_button = false; + }, + true); subghz_transmitter->callback( SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); return true; @@ -134,6 +155,111 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) { return true; } + // Temp Buttons (UP) + if(can_be_sent && event->key == InputKeyUp && event->type == InputTypePress) { + keeloq_set_btn(1); + alutech_set_btn(1); + with_view_model( + subghz_transmitter->view, + SubGhzViewTransmitterModel * model, + { + furi_string_reset(model->temp_button_id); + if(keeloq_get_original_btn() != 0) { + furi_string_printf(model->temp_button_id, "%01X", keeloq_get_original_btn()); + model->draw_temp_button = true; + } else if(alutech_get_original_btn() != 0) { + furi_string_printf(model->temp_button_id, "%01X", alutech_get_original_btn()); + model->draw_temp_button = true; + } + }, + true); + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); + return true; + } else if(can_be_sent && event->key == InputKeyUp && event->type == InputTypeRelease) { + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + return true; + } + // Down + if(can_be_sent && event->key == InputKeyDown && event->type == InputTypePress) { + keeloq_set_btn(2); + alutech_set_btn(2); + with_view_model( + subghz_transmitter->view, + SubGhzViewTransmitterModel * model, + { + furi_string_reset(model->temp_button_id); + if(keeloq_get_original_btn() != 0) { + furi_string_printf(model->temp_button_id, "%01X", keeloq_get_original_btn()); + model->draw_temp_button = true; + } else if(alutech_get_original_btn() != 0) { + furi_string_printf(model->temp_button_id, "%01X", alutech_get_original_btn()); + model->draw_temp_button = true; + } + }, + true); + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); + return true; + } else if(can_be_sent && event->key == InputKeyDown && event->type == InputTypeRelease) { + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + return true; + } + // Left + if(can_be_sent && event->key == InputKeyLeft && event->type == InputTypePress) { + keeloq_set_btn(3); + alutech_set_btn(3); + with_view_model( + subghz_transmitter->view, + SubGhzViewTransmitterModel * model, + { + furi_string_reset(model->temp_button_id); + if(keeloq_get_original_btn() != 0) { + furi_string_printf(model->temp_button_id, "%01X", keeloq_get_original_btn()); + model->draw_temp_button = true; + } else if(alutech_get_original_btn() != 0) { + furi_string_printf(model->temp_button_id, "%01X", alutech_get_original_btn()); + model->draw_temp_button = true; + } + }, + true); + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); + return true; + } else if(can_be_sent && event->key == InputKeyLeft && event->type == InputTypeRelease) { + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + return true; + } + // Right + if(can_be_sent && event->key == InputKeyRight && event->type == InputTypePress) { + keeloq_set_btn(4); + alutech_set_btn(4); + with_view_model( + subghz_transmitter->view, + SubGhzViewTransmitterModel * model, + { + furi_string_reset(model->temp_button_id); + if(keeloq_get_original_btn() != 0) { + furi_string_printf(model->temp_button_id, "%01X", keeloq_get_original_btn()); + model->draw_temp_button = true; + } else if(alutech_get_original_btn() != 0) { + furi_string_printf(model->temp_button_id, "%01X", alutech_get_original_btn()); + model->draw_temp_button = true; + } + }, + true); + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context); + return true; + } else if(can_be_sent && event->key == InputKeyRight && event->type == InputTypeRelease) { + subghz_transmitter->callback( + SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context); + return true; + } + return true; } @@ -166,6 +292,7 @@ SubGhzViewTransmitter* subghz_view_transmitter_alloc() { model->frequency_str = furi_string_alloc(); model->preset_str = furi_string_alloc(); model->key_str = furi_string_alloc(); + model->temp_button_id = furi_string_alloc(); }, true); return subghz_transmitter; @@ -181,6 +308,7 @@ void subghz_view_transmitter_free(SubGhzViewTransmitter* subghz_transmitter) { furi_string_free(model->frequency_str); furi_string_free(model->preset_str); furi_string_free(model->key_str); + furi_string_free(model->temp_button_id); }, true); view_free(subghz_transmitter->view); diff --git a/applications/main/unirfremix/unirfremix_app.c b/applications/main/unirfremix/unirfremix_app.c index 1db9a13c5..81d8ceb1a 100644 --- a/applications/main/unirfremix/unirfremix_app.c +++ b/applications/main/unirfremix/unirfremix_app.c @@ -19,6 +19,7 @@ #include #include #include +#include #define UNIRFMAP_FOLDER "/ext/unirf" #define UNIRFMAP_EXTENSION ".txt" @@ -481,6 +482,8 @@ void unirfremix_tx_stop(UniRFRemix* app) { keeloq_reset_mfname(); keeloq_reset_kl_type(); + keeloq_reset_original_btn(); + alutech_reset_original_btn(); star_line_reset_mfname(); star_line_reset_kl_type(); } diff --git a/applications/plugins/swd_probe/model/model_chip.h b/applications/plugins/swd_probe/model/model_chip.h index ed96105af..4061b8522 100644 --- a/applications/plugins/swd_probe/model/model_chip.h +++ b/applications/plugins/swd_probe/model/model_chip.h @@ -1,420 +1,108 @@ #define NUM_VERTICES 136 float vertexCoords[NUM_VERTICES][3] = { - {1.000000, 1.000000, 0.152153}, - {-1.000000, 1.000000, 0.152153}, - {-1.000000, -1.000000, 0.152153}, - {1.000000, -1.000000, 0.152153}, - {1.000000, -1.000000, -0.185787}, - {-1.000000, -1.000000, -0.185787}, - {-1.000000, 1.000000, -0.185787}, - {1.000000, 1.000000, -0.185787}, - {-1.000043, -0.785071, -0.015780}, - {-1.155724, -0.785071, -0.015780}, - {-1.155724, -0.918718, -0.015780}, - {-1.000043, -0.918718, -0.015780}, - {-1.155724, -0.785071, 0.127052}, - {-1.000043, -0.785071, 0.127052}, - {-1.000043, -0.918718, 0.127052}, - {-1.155724, -0.918718, 0.127052}, - {-1.234192, -0.918846, -0.087021}, - {-1.234397, -0.785201, -0.086336}, - {-1.235319, -0.784943, -0.229143}, - {-1.235114, -0.918588, -0.229828}, - {-1.388133, -0.919573, -0.078673}, - {-1.389056, -0.919314, -0.221479}, - {-1.389261, -0.785669, -0.220795}, - {-1.388338, -0.785927, -0.077988}, - {-1.000043, -0.219627, -0.015780}, - {-1.155724, -0.219627, -0.015780}, - {-1.155724, -0.353273, -0.015780}, - {-1.000043, -0.353273, -0.015780}, - {-1.155724, -0.219627, 0.127052}, - {-1.000043, -0.219627, 0.127052}, - {-1.000043, -0.353273, 0.127052}, - {-1.155724, -0.353273, 0.127052}, - {-1.234192, -0.353402, -0.087021}, - {-1.234397, -0.219756, -0.086336}, - {-1.235319, -0.219498, -0.229143}, - {-1.235114, -0.353143, -0.229828}, - {-1.388133, -0.354128, -0.078673}, - {-1.389056, -0.353870, -0.221479}, - {-1.389261, -0.220224, -0.220795}, - {-1.388338, -0.220482, -0.077988}, - {-1.000043, 0.345818, -0.015780}, - {-1.155724, 0.345818, -0.015780}, - {-1.155724, 0.212172, -0.015780}, - {-1.000043, 0.212172, -0.015780}, - {-1.155724, 0.345818, 0.127052}, - {-1.000043, 0.345818, 0.127052}, - {-1.000043, 0.212172, 0.127052}, - {-1.155724, 0.212172, 0.127052}, - {-1.234192, 0.212043, -0.087021}, - {-1.234397, 0.345689, -0.086336}, - {-1.235319, 0.345947, -0.229143}, - {-1.235114, 0.212301, -0.229828}, - {-1.388133, 0.211317, -0.078673}, - {-1.389056, 0.211575, -0.221479}, - {-1.389261, 0.345221, -0.220795}, - {-1.388338, 0.344962, -0.077988}, - {-1.000043, 0.911263, -0.015780}, - {-1.155724, 0.911263, -0.015780}, - {-1.155724, 0.777617, -0.015780}, - {-1.000043, 0.777617, -0.015780}, - {-1.155724, 0.911263, 0.127052}, - {-1.000043, 0.911263, 0.127052}, - {-1.000043, 0.777617, 0.127052}, - {-1.155724, 0.777617, 0.127052}, - {-1.234192, 0.777488, -0.087021}, - {-1.234397, 0.911133, -0.086336}, - {-1.235319, 0.911392, -0.229143}, - {-1.235114, 0.777746, -0.229828}, - {-1.388133, 0.776762, -0.078673}, - {-1.389056, 0.777020, -0.221479}, - {-1.389261, 0.910665, -0.220795}, - {-1.388338, 0.910407, -0.077988}, - {1.000043, -0.785071, -0.015780}, - {1.000043, -0.918718, -0.015780}, - {1.155723, -0.918718, -0.015780}, - {1.155723, -0.785071, -0.015780}, - {1.155723, -0.785071, 0.127052}, - {1.155723, -0.918718, 0.127052}, - {1.000043, -0.918718, 0.127052}, - {1.000043, -0.785071, 0.127052}, - {1.234397, -0.785201, -0.086336}, - {1.234192, -0.918846, -0.087021}, - {1.235114, -0.918588, -0.229828}, - {1.235319, -0.784943, -0.229143}, - {1.388133, -0.919573, -0.078673}, - {1.388338, -0.785927, -0.077988}, - {1.389260, -0.785669, -0.220795}, - {1.389056, -0.919314, -0.221479}, - {1.000043, -0.219627, -0.015780}, - {1.000043, -0.353273, -0.015780}, - {1.155723, -0.353273, -0.015780}, - {1.155723, -0.219627, -0.015780}, - {1.155723, -0.219627, 0.127052}, - {1.155723, -0.353273, 0.127052}, - {1.000043, -0.353273, 0.127052}, - {1.000043, -0.219627, 0.127052}, - {1.234397, -0.219756, -0.086336}, - {1.234192, -0.353402, -0.087021}, - {1.235114, -0.353143, -0.229828}, - {1.235319, -0.219498, -0.229143}, - {1.388133, -0.354128, -0.078673}, - {1.388338, -0.220482, -0.077988}, - {1.389260, -0.220224, -0.220795}, - {1.389056, -0.353870, -0.221479}, - {1.000043, 0.345818, -0.015780}, - {1.000043, 0.212172, -0.015780}, - {1.155723, 0.212172, -0.015780}, - {1.155723, 0.345818, -0.015780}, - {1.155723, 0.345818, 0.127052}, - {1.155723, 0.212172, 0.127052}, - {1.000043, 0.212172, 0.127052}, - {1.000043, 0.345818, 0.127052}, - {1.234397, 0.345689, -0.086336}, - {1.234192, 0.212043, -0.087021}, - {1.235114, 0.212301, -0.229828}, - {1.235319, 0.345947, -0.229143}, - {1.388133, 0.211317, -0.078673}, - {1.388338, 0.344962, -0.077988}, - {1.389260, 0.345221, -0.220795}, - {1.389056, 0.211575, -0.221479}, - {1.000043, 0.911263, -0.015780}, - {1.000043, 0.777616, -0.015780}, - {1.155723, 0.777616, -0.015780}, - {1.155723, 0.911263, -0.015780}, - {1.155723, 0.911263, 0.127052}, - {1.155723, 0.777616, 0.127052}, - {1.000043, 0.777616, 0.127052}, - {1.000043, 0.911263, 0.127052}, - {1.234397, 0.911133, -0.086336}, - {1.234192, 0.777488, -0.087021}, - {1.235114, 0.777746, -0.229828}, - {1.235319, 0.911392, -0.229143}, - {1.388133, 0.776762, -0.078673}, - {1.388338, 0.910407, -0.077988}, - {1.389260, 0.910665, -0.220795}, - {1.389056, 0.777020, -0.221479}, -};int edgeIndices[][3] = { - {0, 1}, - {1, 2}, - {2, 3}, - {3, 0}, - {4, 3}, - {3, 2}, - {2, 5}, - {5, 4}, - {5, 2}, - {2, 1}, - {1, 6}, - {6, 5}, - {6, 7}, - {7, 4}, - {4, 5}, - {5, 6}, - {7, 0}, - {0, 3}, - {3, 4}, - {4, 7}, - {6, 1}, - {1, 0}, - {0, 7}, - {7, 6}, - {8, 9}, - {9, 10}, - {10, 11}, - {11, 8}, - {12, 13}, - {13, 14}, - {14, 15}, - {15, 12}, - {13, 8}, - {8, 11}, - {11, 14}, - {14, 13}, - {12, 15}, - {15, 16}, - {16, 17}, - {17, 12}, - {10, 9}, - {9, 18}, - {18, 19}, - {19, 10}, - {20, 21}, - {21, 22}, - {22, 23}, - {23, 20}, - {17, 16}, - {16, 20}, - {20, 23}, - {23, 17}, - {19, 18}, - {18, 22}, - {22, 21}, - {21, 19}, - {24, 25}, - {25, 26}, - {26, 27}, - {27, 24}, - {28, 29}, - {29, 30}, - {30, 31}, - {31, 28}, - {29, 24}, - {24, 27}, - {27, 30}, - {30, 29}, - {28, 31}, - {31, 32}, - {32, 33}, - {33, 28}, - {26, 25}, - {25, 34}, - {34, 35}, - {35, 26}, - {36, 37}, - {37, 38}, - {38, 39}, - {39, 36}, - {33, 32}, - {32, 36}, - {36, 39}, - {39, 33}, - {35, 34}, - {34, 38}, - {38, 37}, - {37, 35}, - {40, 41}, - {41, 42}, - {42, 43}, - {43, 40}, - {44, 45}, - {45, 46}, - {46, 47}, - {47, 44}, - {45, 40}, - {40, 43}, - {43, 46}, - {46, 45}, - {44, 47}, - {47, 48}, - {48, 49}, - {49, 44}, - {42, 41}, - {41, 50}, - {50, 51}, - {51, 42}, - {52, 53}, - {53, 54}, - {54, 55}, - {55, 52}, - {49, 48}, - {48, 52}, - {52, 55}, - {55, 49}, - {51, 50}, - {50, 54}, - {54, 53}, - {53, 51}, - {56, 57}, - {57, 58}, - {58, 59}, - {59, 56}, - {60, 61}, - {61, 62}, - {62, 63}, - {63, 60}, - {61, 56}, - {56, 59}, - {59, 62}, - {62, 61}, - {60, 63}, - {63, 64}, - {64, 65}, - {65, 60}, - {58, 57}, - {57, 66}, - {66, 67}, - {67, 58}, - {68, 69}, - {69, 70}, - {70, 71}, - {71, 68}, - {65, 64}, - {64, 68}, - {68, 71}, - {71, 65}, - {67, 66}, - {66, 70}, - {70, 69}, - {69, 67}, - {72, 73}, - {73, 74}, - {74, 75}, - {75, 72}, - {76, 77}, - {77, 78}, - {78, 79}, - {79, 76}, - {79, 78}, - {78, 73}, - {73, 72}, - {72, 79}, - {76, 80}, - {80, 81}, - {81, 77}, - {77, 76}, - {74, 82}, - {82, 83}, - {83, 75}, - {75, 74}, - {84, 85}, - {85, 86}, - {86, 87}, - {87, 84}, - {80, 85}, - {85, 84}, - {84, 81}, - {81, 80}, - {82, 87}, - {87, 86}, - {86, 83}, - {83, 82}, - {88, 89}, - {89, 90}, - {90, 91}, - {91, 88}, - {92, 93}, - {93, 94}, - {94, 95}, - {95, 92}, - {95, 94}, - {94, 89}, - {89, 88}, - {88, 95}, - {92, 96}, - {96, 97}, - {97, 93}, - {93, 92}, - {90, 98}, - {98, 99}, - {99, 91}, - {91, 90}, - {100, 101}, - {101, 102}, - {102, 103}, - {103, 100}, - {96, 101}, - {101, 100}, - {100, 97}, - {97, 96}, - {98, 103}, - {103, 102}, - {102, 99}, - {99, 98}, - {104, 105}, - {105, 106}, - {106, 107}, - {107, 104}, - {108, 109}, - {109, 110}, - {110, 111}, - {111, 108}, - {111, 110}, - {110, 105}, - {105, 104}, - {104, 111}, - {108, 112}, - {112, 113}, - {113, 109}, - {109, 108}, - {106, 114}, - {114, 115}, - {115, 107}, - {107, 106}, - {116, 117}, - {117, 118}, - {118, 119}, - {119, 116}, - {112, 117}, - {117, 116}, - {116, 113}, - {113, 112}, - {114, 119}, - {119, 118}, - {118, 115}, - {115, 114}, - {120, 121}, - {121, 122}, - {122, 123}, - {123, 120}, - {124, 125}, - {125, 126}, - {126, 127}, - {127, 124}, - {127, 126}, - {126, 121}, - {121, 120}, - {120, 127}, - {124, 128}, - {128, 129}, - {129, 125}, - {125, 124}, - {122, 130}, - {130, 131}, - {131, 123}, - {123, 122}, - {132, 133}, - {133, 134}, - {134, 135}, - {135, 132}, - {128, 133}, - {133, 132}, - {132, 129}, - {129, 128}, - {130, 135}, - {135, 134}, - {134, 131}, - {131, 130}, + {1.000000, 1.000000, 0.152153}, {-1.000000, 1.000000, 0.152153}, + {-1.000000, -1.000000, 0.152153}, {1.000000, -1.000000, 0.152153}, + {1.000000, -1.000000, -0.185787}, {-1.000000, -1.000000, -0.185787}, + {-1.000000, 1.000000, -0.185787}, {1.000000, 1.000000, -0.185787}, + {-1.000043, -0.785071, -0.015780}, {-1.155724, -0.785071, -0.015780}, + {-1.155724, -0.918718, -0.015780}, {-1.000043, -0.918718, -0.015780}, + {-1.155724, -0.785071, 0.127052}, {-1.000043, -0.785071, 0.127052}, + {-1.000043, -0.918718, 0.127052}, {-1.155724, -0.918718, 0.127052}, + {-1.234192, -0.918846, -0.087021}, {-1.234397, -0.785201, -0.086336}, + {-1.235319, -0.784943, -0.229143}, {-1.235114, -0.918588, -0.229828}, + {-1.388133, -0.919573, -0.078673}, {-1.389056, -0.919314, -0.221479}, + {-1.389261, -0.785669, -0.220795}, {-1.388338, -0.785927, -0.077988}, + {-1.000043, -0.219627, -0.015780}, {-1.155724, -0.219627, -0.015780}, + {-1.155724, -0.353273, -0.015780}, {-1.000043, -0.353273, -0.015780}, + {-1.155724, -0.219627, 0.127052}, {-1.000043, -0.219627, 0.127052}, + {-1.000043, -0.353273, 0.127052}, {-1.155724, -0.353273, 0.127052}, + {-1.234192, -0.353402, -0.087021}, {-1.234397, -0.219756, -0.086336}, + {-1.235319, -0.219498, -0.229143}, {-1.235114, -0.353143, -0.229828}, + {-1.388133, -0.354128, -0.078673}, {-1.389056, -0.353870, -0.221479}, + {-1.389261, -0.220224, -0.220795}, {-1.388338, -0.220482, -0.077988}, + {-1.000043, 0.345818, -0.015780}, {-1.155724, 0.345818, -0.015780}, + {-1.155724, 0.212172, -0.015780}, {-1.000043, 0.212172, -0.015780}, + {-1.155724, 0.345818, 0.127052}, {-1.000043, 0.345818, 0.127052}, + {-1.000043, 0.212172, 0.127052}, {-1.155724, 0.212172, 0.127052}, + {-1.234192, 0.212043, -0.087021}, {-1.234397, 0.345689, -0.086336}, + {-1.235319, 0.345947, -0.229143}, {-1.235114, 0.212301, -0.229828}, + {-1.388133, 0.211317, -0.078673}, {-1.389056, 0.211575, -0.221479}, + {-1.389261, 0.345221, -0.220795}, {-1.388338, 0.344962, -0.077988}, + {-1.000043, 0.911263, -0.015780}, {-1.155724, 0.911263, -0.015780}, + {-1.155724, 0.777617, -0.015780}, {-1.000043, 0.777617, -0.015780}, + {-1.155724, 0.911263, 0.127052}, {-1.000043, 0.911263, 0.127052}, + {-1.000043, 0.777617, 0.127052}, {-1.155724, 0.777617, 0.127052}, + {-1.234192, 0.777488, -0.087021}, {-1.234397, 0.911133, -0.086336}, + {-1.235319, 0.911392, -0.229143}, {-1.235114, 0.777746, -0.229828}, + {-1.388133, 0.776762, -0.078673}, {-1.389056, 0.777020, -0.221479}, + {-1.389261, 0.910665, -0.220795}, {-1.388338, 0.910407, -0.077988}, + {1.000043, -0.785071, -0.015780}, {1.000043, -0.918718, -0.015780}, + {1.155723, -0.918718, -0.015780}, {1.155723, -0.785071, -0.015780}, + {1.155723, -0.785071, 0.127052}, {1.155723, -0.918718, 0.127052}, + {1.000043, -0.918718, 0.127052}, {1.000043, -0.785071, 0.127052}, + {1.234397, -0.785201, -0.086336}, {1.234192, -0.918846, -0.087021}, + {1.235114, -0.918588, -0.229828}, {1.235319, -0.784943, -0.229143}, + {1.388133, -0.919573, -0.078673}, {1.388338, -0.785927, -0.077988}, + {1.389260, -0.785669, -0.220795}, {1.389056, -0.919314, -0.221479}, + {1.000043, -0.219627, -0.015780}, {1.000043, -0.353273, -0.015780}, + {1.155723, -0.353273, -0.015780}, {1.155723, -0.219627, -0.015780}, + {1.155723, -0.219627, 0.127052}, {1.155723, -0.353273, 0.127052}, + {1.000043, -0.353273, 0.127052}, {1.000043, -0.219627, 0.127052}, + {1.234397, -0.219756, -0.086336}, {1.234192, -0.353402, -0.087021}, + {1.235114, -0.353143, -0.229828}, {1.235319, -0.219498, -0.229143}, + {1.388133, -0.354128, -0.078673}, {1.388338, -0.220482, -0.077988}, + {1.389260, -0.220224, -0.220795}, {1.389056, -0.353870, -0.221479}, + {1.000043, 0.345818, -0.015780}, {1.000043, 0.212172, -0.015780}, + {1.155723, 0.212172, -0.015780}, {1.155723, 0.345818, -0.015780}, + {1.155723, 0.345818, 0.127052}, {1.155723, 0.212172, 0.127052}, + {1.000043, 0.212172, 0.127052}, {1.000043, 0.345818, 0.127052}, + {1.234397, 0.345689, -0.086336}, {1.234192, 0.212043, -0.087021}, + {1.235114, 0.212301, -0.229828}, {1.235319, 0.345947, -0.229143}, + {1.388133, 0.211317, -0.078673}, {1.388338, 0.344962, -0.077988}, + {1.389260, 0.345221, -0.220795}, {1.389056, 0.211575, -0.221479}, + {1.000043, 0.911263, -0.015780}, {1.000043, 0.777616, -0.015780}, + {1.155723, 0.777616, -0.015780}, {1.155723, 0.911263, -0.015780}, + {1.155723, 0.911263, 0.127052}, {1.155723, 0.777616, 0.127052}, + {1.000043, 0.777616, 0.127052}, {1.000043, 0.911263, 0.127052}, + {1.234397, 0.911133, -0.086336}, {1.234192, 0.777488, -0.087021}, + {1.235114, 0.777746, -0.229828}, {1.235319, 0.911392, -0.229143}, + {1.388133, 0.776762, -0.078673}, {1.388338, 0.910407, -0.077988}, + {1.389260, 0.910665, -0.220795}, {1.389056, 0.777020, -0.221479}, +}; +int edgeIndices[][3] = { + {0, 1}, {1, 2}, {2, 3}, {3, 0}, {4, 3}, {3, 2}, {2, 5}, {5, 4}, + {5, 2}, {2, 1}, {1, 6}, {6, 5}, {6, 7}, {7, 4}, {4, 5}, {5, 6}, + {7, 0}, {0, 3}, {3, 4}, {4, 7}, {6, 1}, {1, 0}, {0, 7}, {7, 6}, + {8, 9}, {9, 10}, {10, 11}, {11, 8}, {12, 13}, {13, 14}, {14, 15}, {15, 12}, + {13, 8}, {8, 11}, {11, 14}, {14, 13}, {12, 15}, {15, 16}, {16, 17}, {17, 12}, + {10, 9}, {9, 18}, {18, 19}, {19, 10}, {20, 21}, {21, 22}, {22, 23}, {23, 20}, + {17, 16}, {16, 20}, {20, 23}, {23, 17}, {19, 18}, {18, 22}, {22, 21}, {21, 19}, + {24, 25}, {25, 26}, {26, 27}, {27, 24}, {28, 29}, {29, 30}, {30, 31}, {31, 28}, + {29, 24}, {24, 27}, {27, 30}, {30, 29}, {28, 31}, {31, 32}, {32, 33}, {33, 28}, + {26, 25}, {25, 34}, {34, 35}, {35, 26}, {36, 37}, {37, 38}, {38, 39}, {39, 36}, + {33, 32}, {32, 36}, {36, 39}, {39, 33}, {35, 34}, {34, 38}, {38, 37}, {37, 35}, + {40, 41}, {41, 42}, {42, 43}, {43, 40}, {44, 45}, {45, 46}, {46, 47}, {47, 44}, + {45, 40}, {40, 43}, {43, 46}, {46, 45}, {44, 47}, {47, 48}, {48, 49}, {49, 44}, + {42, 41}, {41, 50}, {50, 51}, {51, 42}, {52, 53}, {53, 54}, {54, 55}, {55, 52}, + {49, 48}, {48, 52}, {52, 55}, {55, 49}, {51, 50}, {50, 54}, {54, 53}, {53, 51}, + {56, 57}, {57, 58}, {58, 59}, {59, 56}, {60, 61}, {61, 62}, {62, 63}, {63, 60}, + {61, 56}, {56, 59}, {59, 62}, {62, 61}, {60, 63}, {63, 64}, {64, 65}, {65, 60}, + {58, 57}, {57, 66}, {66, 67}, {67, 58}, {68, 69}, {69, 70}, {70, 71}, {71, 68}, + {65, 64}, {64, 68}, {68, 71}, {71, 65}, {67, 66}, {66, 70}, {70, 69}, {69, 67}, + {72, 73}, {73, 74}, {74, 75}, {75, 72}, {76, 77}, {77, 78}, {78, 79}, {79, 76}, + {79, 78}, {78, 73}, {73, 72}, {72, 79}, {76, 80}, {80, 81}, {81, 77}, {77, 76}, + {74, 82}, {82, 83}, {83, 75}, {75, 74}, {84, 85}, {85, 86}, {86, 87}, {87, 84}, + {80, 85}, {85, 84}, {84, 81}, {81, 80}, {82, 87}, {87, 86}, {86, 83}, {83, 82}, + {88, 89}, {89, 90}, {90, 91}, {91, 88}, {92, 93}, {93, 94}, {94, 95}, {95, 92}, + {95, 94}, {94, 89}, {89, 88}, {88, 95}, {92, 96}, {96, 97}, {97, 93}, {93, 92}, + {90, 98}, {98, 99}, {99, 91}, {91, 90}, {100, 101}, {101, 102}, {102, 103}, {103, 100}, + {96, 101}, {101, 100}, {100, 97}, {97, 96}, {98, 103}, {103, 102}, {102, 99}, {99, 98}, + {104, 105}, {105, 106}, {106, 107}, {107, 104}, {108, 109}, {109, 110}, {110, 111}, {111, 108}, + {111, 110}, {110, 105}, {105, 104}, {104, 111}, {108, 112}, {112, 113}, {113, 109}, {109, 108}, + {106, 114}, {114, 115}, {115, 107}, {107, 106}, {116, 117}, {117, 118}, {118, 119}, {119, 116}, + {112, 117}, {117, 116}, {116, 113}, {113, 112}, {114, 119}, {119, 118}, {118, 115}, {115, 114}, + {120, 121}, {121, 122}, {122, 123}, {123, 120}, {124, 125}, {125, 126}, {126, 127}, {127, 124}, + {127, 126}, {126, 121}, {121, 120}, {120, 127}, {124, 128}, {128, 129}, {129, 125}, {125, 124}, + {122, 130}, {130, 131}, {131, 123}, {123, 122}, {132, 133}, {133, 134}, {134, 135}, {135, 132}, + {128, 133}, {133, 132}, {132, 129}, {129, 128}, {130, 135}, {135, 134}, {134, 131}, {131, 130}, }; diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index d0df7c79d..d0948b9a8 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -498,6 +498,10 @@ Function,+,acquire_mutex,void*,"ValueMutex*, uint32_t" Function,-,aligned_alloc,void*,"size_t, size_t" Function,+,aligned_free,void,void* Function,+,aligned_malloc,void*,"size_t, size_t" +Function,-,alutech_get_custom_btn,uint8_t, +Function,-,alutech_get_original_btn,uint8_t, +Function,-,alutech_reset_original_btn,void, +Function,-,alutech_set_btn,void,uint8_t Function,-,arc4random,__uint32_t, Function,-,arc4random_buf,void,"void*, size_t" Function,-,arc4random_uniform,__uint32_t,__uint32_t @@ -1351,6 +1355,7 @@ Function,+,furi_hal_subghz_flush_rx,void, Function,+,furi_hal_subghz_flush_tx,void, Function,+,furi_hal_subghz_get_lqi,uint8_t, Function,+,furi_hal_subghz_get_radio_type,SubGhzRadioType, +Function,+,furi_hal_subghz_get_rolling_counter_mult,uint8_t, Function,+,furi_hal_subghz_get_rssi,float, Function,+,furi_hal_subghz_idle,void, Function,-,furi_hal_subghz_init,void, @@ -1372,6 +1377,7 @@ Function,+,furi_hal_subghz_set_frequency,uint32_t,uint32_t Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath Function,+,furi_hal_subghz_set_radio_type,_Bool,SubGhzRadioType +Function,+,furi_hal_subghz_set_rolling_counter_mult,void,uint8_t Function,-,furi_hal_subghz_shutdown,void, Function,+,furi_hal_subghz_sleep,void, Function,+,furi_hal_subghz_start_async_rx,void,"FuriHalSubGhzCaptureCallback, void*" @@ -1742,8 +1748,12 @@ Function,-,j1f,float,float Function,-,jn,double,"int, double" Function,-,jnf,float,"int, float" Function,-,jrand48,long,unsigned short[3] +Function,-,keeloq_get_custom_btn,uint8_t, +Function,-,keeloq_get_original_btn,uint8_t, Function,-,keeloq_reset_kl_type,void, Function,-,keeloq_reset_mfname,void, +Function,-,keeloq_reset_original_btn,void, +Function,-,keeloq_set_btn,void,uint8_t Function,-,l64a,char*,long Function,-,labs,long,long Function,-,lcong48,void,unsigned short[7] diff --git a/firmware/targets/f7/furi_hal/furi_hal_subghz.c b/firmware/targets/f7/furi_hal/furi_hal_subghz.c index 20b8d0839..451cda439 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_subghz.c +++ b/firmware/targets/f7/furi_hal/furi_hal_subghz.c @@ -39,6 +39,7 @@ volatile FuriHalSubGhz furi_hal_subghz = { .radio_type = SubGhzRadioInternal, .spi_bus_handle = &furi_hal_spi_bus_handle_subghz, .cc1101_g0_pin = &gpio_cc1101_g0, + .rolling_counter_mult = 1, }; bool furi_hal_subghz_set_radio_type(SubGhzRadioType state) { @@ -62,6 +63,14 @@ SubGhzRadioType furi_hal_subghz_get_radio_type(void) { return furi_hal_subghz.radio_type; } +uint8_t furi_hal_subghz_get_rolling_counter_mult(void) { + return furi_hal_subghz.rolling_counter_mult; +} + +void furi_hal_subghz_set_rolling_counter_mult(uint8_t mult) { + furi_hal_subghz.rolling_counter_mult = mult; +} + void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) { furi_hal_subghz.async_mirror_pin = pin; } diff --git a/firmware/targets/f7/furi_hal/furi_hal_subghz.h b/firmware/targets/f7/furi_hal/furi_hal_subghz.h index b19a71f9a..8ede17d32 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_subghz.h +++ b/firmware/targets/f7/furi_hal/furi_hal_subghz.h @@ -77,6 +77,7 @@ typedef struct { SubGhzRadioType radio_type; FuriHalSpiBusHandle* spi_bus_handle; const GpioPin* cc1101_g0_pin; + uint8_t rolling_counter_mult; } FuriHalSubGhz; extern volatile FuriHalSubGhz furi_hal_subghz; @@ -309,6 +310,16 @@ void furi_hal_subghz_enable_ext_power(void); */ void furi_hal_subghz_disable_ext_power(void); +/** Get the current rolling protocols counter ++ value + * @return uint8_t current value + */ +uint8_t furi_hal_subghz_get_rolling_counter_mult(void); + +/** Set the current rolling protocols counter ++ value + * @param mult uint8_t = 1, 2, 4, 8 + */ +void furi_hal_subghz_set_rolling_counter_mult(uint8_t mult); + #ifdef __cplusplus } #endif diff --git a/lib/subghz/protocols/alutech_at_4n.c b/lib/subghz/protocols/alutech_at_4n.c index f8e6eb873..a3d5a4dd4 100644 --- a/lib/subghz/protocols/alutech_at_4n.c +++ b/lib/subghz/protocols/alutech_at_4n.c @@ -77,6 +77,25 @@ const SubGhzProtocol subghz_protocol_alutech_at_4n = { .encoder = &subghz_protocol_alutech_at_4n_encoder, }; +static uint8_t al_btn_temp_id; +static uint8_t al_btn_temp_id_original; + +void alutech_set_btn(uint8_t b) { + al_btn_temp_id = b; +} + +uint8_t alutech_get_original_btn() { + return al_btn_temp_id_original; +} + +uint8_t alutech_get_custom_btn() { + return al_btn_temp_id; +} + +void alutech_reset_original_btn() { + al_btn_temp_id_original = 0; +} + void* subghz_protocol_encoder_alutech_at_4n_alloc(SubGhzEnvironment* environment) { UNUSED(environment); SubGhzProtocolEncoderAlutech_at_4n* instance = @@ -255,8 +274,6 @@ static uint64_t subghz_protocol_alutech_at_4n_encrypt(uint64_t data, const char* static bool subghz_protocol_alutech_at_4n_gen_data( SubGhzProtocolEncoderAlutech_at_4n* instance, uint8_t btn) { - UNUSED(btn); - uint64_t data = subghz_protocol_blocks_reverse_key(instance->generic.data, 64); data = subghz_protocol_alutech_at_4n_decrypt( @@ -269,13 +286,13 @@ static bool subghz_protocol_alutech_at_4n_gen_data( } if(instance->generic.cnt < 0xFFFF) { - instance->generic.cnt++; + instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult(); } else if(instance->generic.cnt >= 0xFFFF) { instance->generic.cnt = 0; } crc = subghz_protocol_alutech_at_4n_decrypt_data_crc((uint8_t)(instance->generic.cnt & 0xFF)); data = (uint64_t)crc << 56 | (uint64_t)instance->generic.serial << 24 | - (uint32_t)instance->generic.cnt << 8 | instance->generic.btn; + (uint32_t)instance->generic.cnt << 8 | btn; data = subghz_protocol_alutech_at_4n_encrypt( data, instance->alutech_at_4n_rainbow_table_file_name); @@ -306,7 +323,7 @@ bool subghz_protocol_alutech_at_4n_create_data( /** * Generating an upload from data. - * @param instance Pointer to a SubGhzProtocolEncoderKeeloq instance + * @param instance Pointer to a SubGhzProtocolEncoderAlutech instance * @return true On success */ static bool subghz_protocol_encoder_alutech_at_4n_get_upload( @@ -314,6 +331,104 @@ static bool subghz_protocol_encoder_alutech_at_4n_get_upload( uint8_t btn) { furi_assert(instance); + // Save original button for later use + if(al_btn_temp_id_original == 0) { + al_btn_temp_id_original = btn; + } + + // Set custom button + if(al_btn_temp_id == 1) { + switch(al_btn_temp_id_original) { + case 0x11: + btn = 0x22; + break; + case 0x22: + btn = 0x11; + break; + case 0xFF: + btn = 0x11; + break; + case 0x44: + btn = 0x11; + break; + case 0x33: + btn = 0x11; + break; + + default: + break; + } + } + if(al_btn_temp_id == 2) { + switch(al_btn_temp_id_original) { + case 0x11: + btn = 0x44; + break; + case 0x22: + btn = 0x44; + break; + case 0xFF: + btn = 0x44; + break; + case 0x44: + btn = 0xFF; + break; + case 0x33: + btn = 0x44; + break; + + default: + break; + } + } + if(al_btn_temp_id == 3) { + switch(al_btn_temp_id_original) { + case 0x11: + btn = 0x33; + break; + case 0x22: + btn = 0x33; + break; + case 0xFF: + btn = 0x33; + break; + case 0x44: + btn = 0x33; + break; + case 0x33: + btn = 0x22; + break; + + default: + break; + } + } + if(al_btn_temp_id == 4) { + switch(al_btn_temp_id_original) { + case 0x11: + btn = 0xFF; + break; + case 0x22: + btn = 0xFF; + break; + case 0xFF: + btn = 0x22; + break; + case 0x44: + btn = 0x22; + break; + case 0x33: + btn = 0xFF; + break; + + default: + break; + } + } + + if((al_btn_temp_id == 0) && (al_btn_temp_id_original != 0)) { + btn = al_btn_temp_id_original; + } //gen new key if(subghz_protocol_alutech_at_4n_gen_data(instance, btn)) { //ToDo if you need to add a callback to automatically update the data on the display @@ -608,6 +723,11 @@ static void subghz_protocol_alutech_at_4n_remote_controller( instance->cnt = 0; instance->serial = 0; } + + // Save original button for later use + if(al_btn_temp_id_original == 0) { + al_btn_temp_id_original = instance->btn; + } } uint8_t subghz_protocol_decoder_alutech_at_4n_get_hash_data(void* context) { diff --git a/lib/subghz/protocols/alutech_at_4n.h b/lib/subghz/protocols/alutech_at_4n.h index 520e7289d..b0ac056dd 100644 --- a/lib/subghz/protocols/alutech_at_4n.h +++ b/lib/subghz/protocols/alutech_at_4n.h @@ -10,6 +10,14 @@ extern const SubGhzProtocolDecoder subghz_protocol_alutech_at_4n_decoder; extern const SubGhzProtocolEncoder subghz_protocol_alutech_at_4n_encoder; extern const SubGhzProtocol subghz_protocol_alutech_at_4n; +// Custom buttons +void alutech_set_btn(uint8_t b); + +uint8_t alutech_get_original_btn(); +uint8_t alutech_get_custom_btn(); + +void alutech_reset_original_btn(); + /** * Allocate SubGhzProtocolEncoderAlutech_at_4n. * @param environment Pointer to a SubGhzEnvironment instance diff --git a/lib/subghz/protocols/came_atomo.c b/lib/subghz/protocols/came_atomo.c index d12e5976c..e50130a75 100644 --- a/lib/subghz/protocols/came_atomo.c +++ b/lib/subghz/protocols/came_atomo.c @@ -136,7 +136,7 @@ static void uint8_t pack[8] = {}; if(instance->generic.cnt < 0xFFFF) { - instance->generic.cnt++; + instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult(); } else if(instance->generic.cnt >= 0xFFFF) { instance->generic.cnt = 0; } diff --git a/lib/subghz/protocols/faac_slh.c b/lib/subghz/protocols/faac_slh.c index 7572bd8ab..4b69ae73d 100644 --- a/lib/subghz/protocols/faac_slh.c +++ b/lib/subghz/protocols/faac_slh.c @@ -110,7 +110,7 @@ void subghz_protocol_encoder_faac_slh_free(void* context) { } static bool subghz_protocol_faac_slh_gen_data(SubGhzProtocolEncoderFaacSLH* instance) { - instance->generic.cnt++; + instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult(); uint32_t fix = instance->generic.serial << 4 | instance->generic.btn; uint32_t hop = 0; uint32_t decrypt = 0; diff --git a/lib/subghz/protocols/keeloq.c b/lib/subghz/protocols/keeloq.c index a0970de4d..0c601c256 100644 --- a/lib/subghz/protocols/keeloq.c +++ b/lib/subghz/protocols/keeloq.c @@ -85,7 +85,25 @@ const SubGhzProtocol subghz_protocol_keeloq = { }; static const char* mfname; -static int kl_type; +static uint8_t kl_type; +static uint8_t btn_temp_id; +static uint8_t btn_temp_id_original; + +void keeloq_set_btn(uint8_t b) { + btn_temp_id = b; +} + +uint8_t keeloq_get_original_btn() { + return btn_temp_id_original; +} + +uint8_t keeloq_get_custom_btn() { + return btn_temp_id; +} + +void keeloq_reset_original_btn() { + btn_temp_id_original = 0; +} void keeloq_reset_mfname() { mfname = ""; @@ -136,11 +154,16 @@ void subghz_protocol_encoder_keeloq_free(void* context) { * @param instance Pointer to a SubGhzProtocolEncoderKeeloq* instance * @param btn Button number, 4 bit */ -static bool subghz_protocol_keeloq_gen_data(SubGhzProtocolEncoderKeeloq* instance, uint8_t btn) { - if(instance->generic.cnt < 0xFFFF) { - instance->generic.cnt++; - } else if(instance->generic.cnt >= 0xFFFF) { - instance->generic.cnt = 0; +static bool subghz_protocol_keeloq_gen_data( + SubGhzProtocolEncoderKeeloq* instance, + uint8_t btn, + bool counter_up) { + if(counter_up) { + if(instance->generic.cnt < 0xFFFF) { + instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult(); + } else if(instance->generic.cnt >= 0xFFFF) { + instance->generic.cnt = 0; + } } uint32_t fix = (uint32_t)btn << 28 | instance->generic.serial; uint32_t decrypt = (uint32_t)btn << 28 | @@ -176,9 +199,9 @@ static bool subghz_protocol_keeloq_gen_data(SubGhzProtocolEncoderKeeloq* instanc hop = code_found_reverse & 0x00000000ffffffff; } else if(strcmp(instance->manufacture_name, "AN-Motors") == 0) { hop = (instance->generic.cnt & 0xFF) << 24 | (instance->generic.cnt & 0xFF) << 16 | - (instance->generic.btn & 0xF) << 12 | 0x404; + (btn & 0xF) << 12 | 0x404; } else if(strcmp(instance->manufacture_name, "HCS101") == 0) { - hop = instance->generic.cnt << 16 | (instance->generic.btn & 0xF) << 12 | 0x000; + hop = instance->generic.cnt << 16 | (btn & 0xF) << 12 | 0x000; } else { for M_EACH(manufacture_code, *subghz_keystore_get_data(instance->keystore), SubGhzKeyArray_t) { @@ -261,7 +284,7 @@ bool subghz_protocol_keeloq_create_data( instance->generic.cnt = cnt; instance->manufacture_name = manufacture_name; instance->generic.data_count_bit = 64; - bool res = subghz_protocol_keeloq_gen_data(instance, btn); + bool res = subghz_protocol_keeloq_gen_data(instance, btn, false); if(res) { res = subghz_block_generic_serialize(&instance->generic, flipper_format, preset); } @@ -286,7 +309,7 @@ bool subghz_protocol_keeloq_bft_create_data( instance->manufacture_name = manufacture_name; instance->generic.data_count_bit = 64; // roguuemaster don't steal.!!!! - bool res = subghz_protocol_keeloq_gen_data(instance, btn); + bool res = subghz_protocol_keeloq_gen_data(instance, btn, false); if(res) { res = subghz_block_generic_serialize(&instance->generic, flipper_format, preset); } @@ -302,8 +325,107 @@ static bool subghz_protocol_encoder_keeloq_get_upload(SubGhzProtocolEncoderKeeloq* instance, uint8_t btn) { furi_assert(instance); + // Save original button + if(btn_temp_id_original == 0) { + btn_temp_id_original = btn; + } + + // Set custom button + if(btn_temp_id == 1) { + switch(btn_temp_id_original) { + case 0x1: + btn = 0x2; + break; + case 0x2: + btn = 0x1; + break; + case 0xA: + btn = 0x1; + break; + case 0x4: + btn = 0x1; + break; + case 0x8: + btn = 0x1; + break; + + default: + break; + } + } + if(btn_temp_id == 2) { + switch(btn_temp_id_original) { + case 0x1: + btn = 0x4; + break; + case 0x2: + btn = 0x4; + break; + case 0xA: + btn = 0x4; + break; + case 0x4: + btn = 0xA; + break; + case 0x8: + btn = 0x4; + break; + + default: + break; + } + } + if(btn_temp_id == 3) { + switch(btn_temp_id_original) { + case 0x1: + btn = 0x8; + break; + case 0x2: + btn = 0x8; + break; + case 0xA: + btn = 0x8; + break; + case 0x4: + btn = 0x8; + break; + case 0x8: + btn = 0x2; + break; + + default: + break; + } + } + if(btn_temp_id == 4) { + switch(btn_temp_id_original) { + case 0x1: + btn = 0xA; + break; + case 0x2: + btn = 0xA; + break; + case 0xA: + btn = 0x2; + break; + case 0x4: + btn = 0x2; + break; + case 0x8: + btn = 0xA; + break; + + default: + break; + } + } + + if((btn_temp_id == 0) && (btn_temp_id_original != 0)) { + btn = btn_temp_id_original; + } + //gen new key - if(subghz_protocol_keeloq_gen_data(instance, btn)) { + if(subghz_protocol_keeloq_gen_data(instance, btn, true)) { //ToDo if you need to add a callback to automatically update the data on the display } else { return false; @@ -974,6 +1096,11 @@ static void subghz_protocol_keeloq_check_remote_controller( instance->serial = key_fix & 0x0FFFFFFF; instance->btn = key_fix >> 28; + + // Save original button for later use + if(btn_temp_id_original == 0) { + btn_temp_id_original = instance->btn; + } } uint8_t subghz_protocol_decoder_keeloq_get_hash_data(void* context) { diff --git a/lib/subghz/protocols/keeloq.h b/lib/subghz/protocols/keeloq.h index 7b0cfc3bd..9ddf17d89 100644 --- a/lib/subghz/protocols/keeloq.h +++ b/lib/subghz/protocols/keeloq.h @@ -15,6 +15,13 @@ void keeloq_reset_mfname(); void keeloq_reset_kl_type(); +void keeloq_set_btn(uint8_t b); + +uint8_t keeloq_get_original_btn(); +uint8_t keeloq_get_custom_btn(); + +void keeloq_reset_original_btn(); + /** * Allocate SubGhzProtocolEncoderKeeloq. * @param environment Pointer to a SubGhzEnvironment instance diff --git a/lib/subghz/protocols/kinggates_stylo_4k.c b/lib/subghz/protocols/kinggates_stylo_4k.c index 5f2a83d77..28af1b7c9 100644 --- a/lib/subghz/protocols/kinggates_stylo_4k.c +++ b/lib/subghz/protocols/kinggates_stylo_4k.c @@ -156,7 +156,7 @@ static bool subghz_protocol_kinggates_stylo_4k_gen_data( instance->generic.cnt = decrypt & 0xFFFF; if(instance->generic.cnt < 0xFFFF) { - instance->generic.cnt++; + instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult(); } else if(instance->generic.cnt >= 0xFFFF) { instance->generic.cnt = 0; } diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 2d31c46af..67d3311cf 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -136,7 +136,7 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload( } if(instance->generic.cnt < 0xFFFF) { - instance->generic.cnt++; + instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult(); } else if(instance->generic.cnt >= 0xFFFF) { instance->generic.cnt = 0; } diff --git a/lib/subghz/protocols/secplus_v2.c b/lib/subghz/protocols/secplus_v2.c index bcef90dad..d4fd9d13c 100644 --- a/lib/subghz/protocols/secplus_v2.c +++ b/lib/subghz/protocols/secplus_v2.c @@ -379,7 +379,7 @@ static void subghz_protocol_secplus_v2_encode(SubGhzProtocolEncoderSecPlus_v2* i uint8_t roll_1[9] = {0}; uint8_t roll_2[9] = {0}; - instance->generic.cnt++; + instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult(); //ToDo it is not known what value the counter starts if(instance->generic.cnt > 0xFFFFFFF) instance->generic.cnt = 0xE500000; uint32_t rolling = subghz_protocol_blocks_reverse_key(instance->generic.cnt, 28); diff --git a/lib/subghz/protocols/somfy_keytis.c b/lib/subghz/protocols/somfy_keytis.c index ab9202cc3..5d3516570 100644 --- a/lib/subghz/protocols/somfy_keytis.c +++ b/lib/subghz/protocols/somfy_keytis.c @@ -131,7 +131,7 @@ static bool instance->generic.serial = data & 0xFFFFFF; if(instance->generic.cnt < 0xFFFF) { - instance->generic.cnt++; + instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult(); } else if(instance->generic.cnt >= 0xFFFF) { instance->generic.cnt = 0; } diff --git a/lib/subghz/protocols/somfy_telis.c b/lib/subghz/protocols/somfy_telis.c index 96997c581..db44c0661 100644 --- a/lib/subghz/protocols/somfy_telis.c +++ b/lib/subghz/protocols/somfy_telis.c @@ -104,7 +104,7 @@ static bool instance->generic.serial = data & 0xFFFFFF; // address if(instance->generic.cnt < 0xFFFF) { - instance->generic.cnt++; + instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult(); } else if(instance->generic.cnt >= 0xFFFF) { instance->generic.cnt = 0; } diff --git a/lib/subghz/protocols/star_line.c b/lib/subghz/protocols/star_line.c index 3066c6e2b..7d5fbb2be 100644 --- a/lib/subghz/protocols/star_line.c +++ b/lib/subghz/protocols/star_line.c @@ -139,7 +139,7 @@ void subghz_protocol_encoder_star_line_free(void* context) { static bool subghz_protocol_star_line_gen_data(SubGhzProtocolEncoderStarLine* instance, uint8_t btn) { if(instance->generic.cnt < 0xFFFF) { - instance->generic.cnt++; + instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult(); } else if(instance->generic.cnt >= 0xFFFF) { instance->generic.cnt = 0; }