diff --git a/CHANGELOG.md b/CHANGELOG.md index 480d75205..9908b23d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ - UL: Add GangQi protocol (static 34 bit) with button parsing and add manually (by @xMasterX & @Skorpionm) - UL: Add Hollarm protocol (static 42 bit) with button parsing and add manually (by @xMasterX & @Skorpionm) - UL: Add Hay21 protocol (dynamic 21 bit) with button parsing (by @xMasterX) - - UL: Princeton custom buttons support (0x1, 0x2, 0x4, 0x8, 0xF) (by @xMasterX) + - UL: Princeton custom buttons support (by @xMasterX) - NFC: - Add SmartRider Parser (#203 by @jaylikesbunda) - Add API to enforce ISO15693 mode (#225 by @aaronjamt) @@ -66,7 +66,6 @@ - OFW: GProxII Fix Writing and Rendering Conflict (by @zinongli) - Desktop: - Fallback Poweroff prompt when power settings is unavailable (by @Willy-JL) - - OFW: Autolock fixes (by @portasynthinca3) - Storage: - Fallback SD format prompt when storage settings is unavailable (by @Willy-JL) - OFW: Fix folder rename fails (by @portasynthinca3) diff --git a/applications/services/cli/cli_vcp.c b/applications/services/cli/cli_vcp.c index a74710284..cdabaaa05 100644 --- a/applications/services/cli/cli_vcp.c +++ b/applications/services/cli/cli_vcp.c @@ -2,10 +2,6 @@ #include #include #include -#include -#include -#include -#include #define TAG "CliVcp" @@ -47,13 +43,6 @@ typedef struct { FuriHalUsbInterface* usb_if_prev; uint8_t data_buffer[USB_CDC_PKT_LEN]; - - // CLI icon - Gui* gui; - ViewPort* view_port; - - // Autolocking inhibition - Desktop* desktop; } CliVcp; static int32_t vcp_worker(void* context); @@ -75,13 +64,6 @@ static CliVcp* vcp = NULL; static const uint8_t ascii_soh = 0x01; static const uint8_t ascii_eot = 0x04; -static void cli_vcp_icon_draw_callback(Canvas* canvas, void* context) { - furi_assert(canvas); - furi_assert(context); - const Icon* icon = context; - canvas_draw_icon(canvas, 0, 0, icon); -} - static void cli_vcp_init(void) { if(vcp == NULL) { vcp = malloc(sizeof(CliVcp)); @@ -121,15 +103,6 @@ static int32_t vcp_worker(void* context) { FURI_LOG_D(TAG, "Start"); vcp->running = true; - // GUI icon - vcp->desktop = furi_record_open(RECORD_DESKTOP); - const Icon* icon = &I_Console_active_8x8; - vcp->gui = furi_record_open(RECORD_GUI); - vcp->view_port = view_port_alloc(); - view_port_set_width(vcp->view_port, icon_get_width(icon)); - // casting const away. we know that we cast it right back in the callback - view_port_draw_callback_set(vcp->view_port, cli_vcp_icon_draw_callback, (void*)icon); - while(1) { uint32_t flags = furi_thread_flags_wait(VCP_THREAD_FLAG_ALL, FuriFlagWaitAny, FuriWaitForever); @@ -142,8 +115,6 @@ static int32_t vcp_worker(void* context) { if(vcp->connected == false) { vcp->connected = true; furi_stream_buffer_send(vcp->rx_stream, &ascii_soh, 1, FuriWaitForever); - gui_add_view_port(vcp->gui, vcp->view_port, GuiLayerStatusBarLeft); - desktop_api_add_external_inhibitor(vcp->desktop); } } @@ -155,8 +126,6 @@ static int32_t vcp_worker(void* context) { vcp->connected = false; furi_stream_buffer_receive(vcp->tx_stream, vcp->data_buffer, USB_CDC_PKT_LEN, 0); furi_stream_buffer_send(vcp->rx_stream, &ascii_eot, 1, FuriWaitForever); - gui_remove_view_port(vcp->gui, vcp->view_port); - desktop_api_remove_external_inhibitor(vcp->desktop); } } @@ -221,10 +190,6 @@ static int32_t vcp_worker(void* context) { } if(flags & VcpEvtStop) { - if(vcp->connected) { - gui_remove_view_port(vcp->gui, vcp->view_port); - desktop_api_remove_external_inhibitor(vcp->desktop); - } vcp->connected = false; vcp->running = false; furi_hal_cdc_set_callbacks(VCP_IF_NUM, NULL, NULL); @@ -238,11 +203,6 @@ static int32_t vcp_worker(void* context) { break; } } - - view_port_free(vcp->view_port); - furi_record_close(RECORD_DESKTOP); - furi_record_close(RECORD_GUI); - FURI_LOG_D(TAG, "End"); return 0; } diff --git a/applications/services/desktop/desktop.c b/applications/services/desktop/desktop.c index 02834a901..d618f14df 100644 --- a/applications/services/desktop/desktop.c +++ b/applications/services/desktop/desktop.c @@ -20,8 +20,6 @@ static void desktop_auto_lock_arm(Desktop*); static void desktop_auto_lock_inhibit(Desktop*); static void desktop_start_auto_lock_timer(Desktop*); static void desktop_apply_settings(Desktop*); -static void desktop_auto_lock_add_inhibitor(Desktop* desktop); -static void desktop_auto_lock_remove_inhibitor(Desktop* desktop); static void desktop_loader_callback(const void* message, void* context) { furi_assert(context); @@ -127,22 +125,16 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) { animation_manager_unload_and_stall_animation(desktop->animation_manager); } - desktop_auto_lock_add_inhibitor(desktop); + desktop_auto_lock_inhibit(desktop); desktop->app_running = true; furi_semaphore_release(desktop->animation_semaphore); } else if(event == DesktopGlobalAfterAppFinished) { animation_manager_load_and_continue_animation(desktop->animation_manager); - desktop_auto_lock_remove_inhibitor(desktop); + desktop_auto_lock_arm(desktop); desktop->app_running = false; - } else if(event == DesktopGlobalAddExternalInhibitor) { - desktop_auto_lock_add_inhibitor(desktop); - - } else if(event == DesktopGlobalRemoveExternalInhibitor) { - desktop_auto_lock_remove_inhibitor(desktop); - } else if(event == DesktopGlobalAutoLock) { if(!desktop->app_running && !desktop->locked) { desktop_lock(desktop, desktop->settings.auto_lock_with_pin); @@ -213,24 +205,6 @@ static void desktop_auto_lock_arm(Desktop* desktop) { } } -static void desktop_auto_lock_add_inhibitor(Desktop* desktop) { - furi_check(furi_semaphore_release(desktop->auto_lock_inhibitors) == FuriStatusOk); - FURI_LOG_D( - TAG, - "%lu autolock inhibitors (+1)", - furi_semaphore_get_count(desktop->auto_lock_inhibitors)); - desktop_auto_lock_inhibit(desktop); -} - -static void desktop_auto_lock_remove_inhibitor(Desktop* desktop) { - furi_check(furi_semaphore_acquire(desktop->auto_lock_inhibitors, 0) == FuriStatusOk); - uint32_t inhibitors = furi_semaphore_get_count(desktop->auto_lock_inhibitors); - FURI_LOG_D(TAG, "%lu autolock inhibitors (-1)", inhibitors); - if(inhibitors == 0) { - desktop_auto_lock_arm(desktop); - } -} - static void desktop_auto_lock_inhibit(Desktop* desktop) { desktop_stop_auto_lock_timer(desktop); if(desktop->input_events_subscription) { @@ -387,7 +361,6 @@ static Desktop* desktop_alloc(void) { desktop->input_events_pubsub = furi_record_open(RECORD_INPUT_EVENTS); desktop->ascii_events_pubsub = furi_record_open(RECORD_ASCII_EVENTS); - desktop->auto_lock_inhibitors = furi_semaphore_alloc(UINT32_MAX, 0); desktop->auto_lock_timer = furi_timer_alloc(desktop_auto_lock_timer_callback, FuriTimerTypeOnce, desktop); @@ -546,18 +519,6 @@ void desktop_api_set_settings(Desktop* instance, const DesktopSettings* settings view_dispatcher_send_custom_event(instance->view_dispatcher, DesktopGlobalSaveSettings); } -void desktop_api_add_external_inhibitor(Desktop* instance) { - furi_assert(instance); - view_dispatcher_send_custom_event( - instance->view_dispatcher, DesktopGlobalAddExternalInhibitor); -} - -void desktop_api_remove_external_inhibitor(Desktop* instance) { - furi_assert(instance); - view_dispatcher_send_custom_event( - instance->view_dispatcher, DesktopGlobalRemoveExternalInhibitor); -} - /* * Application thread */ diff --git a/applications/services/desktop/desktop.h b/applications/services/desktop/desktop.h index 4f1556f7c..e83bc3ee4 100644 --- a/applications/services/desktop/desktop.h +++ b/applications/services/desktop/desktop.h @@ -21,17 +21,3 @@ FuriPubSub* desktop_api_get_status_pubsub(Desktop* instance); void desktop_api_get_settings(Desktop* instance, DesktopSettings* settings); void desktop_api_set_settings(Desktop* instance, const DesktopSettings* settings); - -/** - * @brief Adds 1 to the count of active external autolock inhibitors - * - * Autolocking will not get triggered while there's at least 1 inhibitor - */ -void desktop_api_add_external_inhibitor(Desktop* instance); - -/** - * @brief Removes 1 from the count of active external autolock inhibitors - * - * Autolocking will not get triggered while there's at least 1 inhibitor - */ -void desktop_api_remove_external_inhibitor(Desktop* instance); diff --git a/applications/services/desktop/desktop_i.h b/applications/services/desktop/desktop_i.h index 46b35054c..10badcc07 100644 --- a/applications/services/desktop/desktop_i.h +++ b/applications/services/desktop/desktop_i.h @@ -74,7 +74,6 @@ struct Desktop { FuriPubSub* input_events_pubsub; FuriPubSubSubscription* input_events_subscription; - FuriSemaphore* auto_lock_inhibitors; FuriTimer* auto_lock_timer; FuriTimer* update_clock_timer; diff --git a/applications/services/desktop/views/desktop_events.h b/applications/services/desktop/views/desktop_events.h index cbacb8545..3f2896912 100644 --- a/applications/services/desktop/views/desktop_events.h +++ b/applications/services/desktop/views/desktop_events.h @@ -58,8 +58,6 @@ typedef enum { DesktopGlobalApiUnlock, DesktopGlobalSaveSettings, DesktopGlobalReloadSettings, - DesktopGlobalAddExternalInhibitor, - DesktopGlobalRemoveExternalInhibitor, DesktopMainEventLockKeypad, DesktopLockedEventOpenPowerOff, diff --git a/assets/icons/StatusBar/Console_active_8x8.png b/assets/icons/StatusBar/Console_active_8x8.png deleted file mode 100644 index f2230a374..000000000 Binary files a/assets/icons/StatusBar/Console_active_8x8.png and /dev/null differ diff --git a/lib/subghz/protocols/princeton.c b/lib/subghz/protocols/princeton.c index b14a0ee15..378c2bedd 100644 --- a/lib/subghz/protocols/princeton.c +++ b/lib/subghz/protocols/princeton.c @@ -138,9 +138,21 @@ static uint8_t subghz_protocol_princeton_get_btn_code(void) { case 0xF: btn = 0x2; break; + // Second encoding type + case 0x30: + btn = 0xC0; + break; + case 0xC0: + btn = 0x30; + break; + case 0x03: + btn = 0xC0; + break; + case 0x0C: + btn = 0xC0; + break; default: - btn = 0x2; break; } } else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_DOWN) { @@ -160,9 +172,21 @@ static uint8_t subghz_protocol_princeton_get_btn_code(void) { case 0xF: btn = 0x1; break; + // Second encoding type + case 0x30: + btn = 0x03; + break; + case 0xC0: + btn = 0x03; + break; + case 0x03: + btn = 0x30; + break; + case 0x0C: + btn = 0x03; + break; default: - btn = 0x1; break; } } else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_LEFT) { @@ -182,9 +206,21 @@ static uint8_t subghz_protocol_princeton_get_btn_code(void) { case 0xF: btn = 0x4; break; + // Second encoding type + case 0x30: + btn = 0x0C; + break; + case 0xC0: + btn = 0x0C; + break; + case 0x03: + btn = 0x0C; + break; + case 0x0C: + btn = 0x30; + break; default: - btn = 0x4; break; } } else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_RIGHT) { @@ -206,7 +242,6 @@ static uint8_t subghz_protocol_princeton_get_btn_code(void) { break; default: - btn = 0x8; break; } } @@ -227,8 +262,15 @@ static bool instance->generic.btn = subghz_protocol_princeton_get_btn_code(); // Reconstruction of the data - instance->generic.data = - ((uint64_t)instance->generic.serial << 4 | (uint64_t)instance->generic.btn); + // If we have 8bit button code move serial to left by 8 bits (and 4 if 4 bits) + if(instance->generic.btn == 0x30 || instance->generic.btn == 0xC0 || + instance->generic.btn == 0x03 || instance->generic.btn == 0x0C) { + instance->generic.data = + ((uint64_t)instance->generic.serial << 8 | (uint64_t)instance->generic.btn); + } else { + instance->generic.data = + ((uint64_t)instance->generic.serial << 4 | (uint64_t)instance->generic.btn); + } size_t index = 0; size_t size_upload = (instance->generic.data_count_bit * 2) + 2; @@ -268,8 +310,17 @@ static bool * @param instance Pointer to a SubGhzBlockGeneric* instance */ static void subghz_protocol_princeton_check_remote_controller(SubGhzBlockGeneric* instance) { - instance->serial = instance->data >> 4; - instance->btn = instance->data & 0xF; + // Parse button modes for second encoding type (and serial is smaller) + // Button code is 8bit and has fixed values of one of these + // Exclude button code for each type from serial number before parsing + if((instance->data & 0xFF) == 0x30 || (instance->data & 0xFF) == 0xC0 || + (instance->data & 0xFF) == 0x03 || (instance->data & 0xFF) == 0x0C) { + instance->serial = instance->data >> 8; + instance->btn = instance->data & 0xFF; + } else { + instance->serial = instance->data >> 4; + instance->btn = instance->data & 0xF; + } // Save original button for later use if(subghz_custom_btn_get_original() == 0) { @@ -537,19 +588,38 @@ void subghz_protocol_decoder_princeton_get_string(void* context, FuriString* out uint32_t data_rev = subghz_protocol_blocks_reverse_key( instance->generic.data, instance->generic.data_count_bit); - furi_string_cat_printf( - output, - "%s %dbit\r\n" - "Key:0x%08lX\r\n" - "Yek:0x%08lX\r\n" - "Sn:0x%05lX Btn:%01X\r\n" - "Te:%luus GT:Te*%lu\r\n", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data & 0xFFFFFF), - data_rev, - instance->generic.serial, - instance->generic.btn, - instance->te, - instance->guard_time); + if(instance->generic.btn == 0x30 || instance->generic.btn == 0xC0 || + instance->generic.btn == 0x03 || instance->generic.btn == 0x0C) { + furi_string_cat_printf( + output, + "%s %dbit\r\n" + "Key:0x%08lX\r\n" + "Yek:0x%08lX\r\n" + "Sn:0x%05lX Btn:%02X (8b)\r\n" + "Te:%luus GT:Te*%lu\r\n", + instance->generic.protocol_name, + instance->generic.data_count_bit, + (uint32_t)(instance->generic.data & 0xFFFFFF), + data_rev, + instance->generic.serial, + instance->generic.btn, + instance->te, + instance->guard_time); + } else { + furi_string_cat_printf( + output, + "%s %dbit\r\n" + "Key:0x%08lX\r\n" + "Yek:0x%08lX\r\n" + "Sn:0x%05lX Btn:%01X (4b)\r\n" + "Te:%luus GT:Te*%lu\r\n", + instance->generic.protocol_name, + instance->generic.data_count_bit, + (uint32_t)(instance->generic.data & 0xFFFFFF), + data_rev, + instance->generic.serial, + instance->generic.btn, + instance->te, + instance->guard_time); + } } diff --git a/scripts/serial_cli.py b/scripts/serial_cli.py index a48647bd5..8e35d57fa 100644 --- a/scripts/serial_cli.py +++ b/scripts/serial_cli.py @@ -13,9 +13,7 @@ def main(): parser.add_argument("-p", "--port", help="CDC Port", default="auto") args = parser.parse_args() if not (port := resolve_port(logger, args.port)): - logger.error( - "Is Flipper connected via USB, currently unlocked and not in DFU mode?" - ) + logger.error("Is Flipper connected via USB and not in DFU mode?") return 1 subprocess.call( [ diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 70fbad27a..f71e6d341 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -3911,7 +3911,6 @@ Variable,+,I_Circles_47x47,const Icon, Variable,+,I_Clock_18x18,const Icon, Variable,+,I_Connect_me_62x31,const Icon, Variable,+,I_Connected_62x31,const Icon, -Variable,+,I_Console_active_8x8,const Icon, Variable,+,I_Cos_9x7,const Icon, Variable,+,I_DFU_128x50,const Icon, Variable,+,I_DolphinDone_80x58,const Icon,