[FL-2705] App RPC Bug Fixes and redesign (#1491)

* Rpc: remove callback timer
* Rpc: simplify rpc event callback
* Rpc: migrate to new confirmation schema
* Rpc: migrate to new confirmation schema part2: finalize ibutton and rfid
* Rpc: migrate to new confirmation schema part3: finallize nfc and fix id in load
* Rpc: hardened sequencing check
* Rpc: migrate to new confirmation schema part4: finalize subghz
* iButton: properly handle exit
* Nfc: correct sequence for rpc exit send
* Rpc: fix review issues and nfc exit message
* Rpc: more logging and condition race fix in confirmation
* Rpc: migrate to new confirmation schema part5: finalize infrared
* Rpc: more logging
This commit is contained in:
あく
2022-08-02 21:54:12 +09:00
committed by GitHub
parent f9386b2649
commit f9745b4141
20 changed files with 378 additions and 270 deletions

View File

@@ -35,57 +35,38 @@ void subghz_tick_event_callback(void* context) {
scene_manager_handle_tick_event(subghz->scene_manager);
}
static bool subghz_rpc_command_callback(RpcAppSystemEvent event, const char* arg, void* context) {
static void subghz_rpc_command_callback(RpcAppSystemEvent event, void* context) {
furi_assert(context);
SubGhz* subghz = context;
if(!subghz->rpc_ctx) {
return false;
}
bool result = false;
furi_assert(subghz->rpc_ctx);
if(event == RpcAppEventSessionClose) {
rpc_system_app_set_callback(subghz->rpc_ctx, NULL, NULL);
subghz->rpc_ctx = NULL;
notification_message(subghz->notifications, &sequence_blink_stop);
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneExit);
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
subghz_tx_stop(subghz);
subghz_sleep(subghz);
}
result = true;
view_dispatcher_send_custom_event(
subghz->view_dispatcher, SubGhzCustomEventSceneRpcSessionClose);
} else if(event == RpcAppEventAppExit) {
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneExit);
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
subghz_tx_stop(subghz);
subghz_sleep(subghz);
}
result = true;
} else if(event == RpcAppEventLoadFile) {
if(arg) {
if(subghz_key_load(subghz, arg, false)) {
string_set_str(subghz->file_path, arg);
view_dispatcher_send_custom_event(
subghz->view_dispatcher, SubGhzCustomEventSceneRpcLoad);
result = true;
}
}
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneRpcLoad);
} else if(event == RpcAppEventButtonPress) {
if(subghz->txrx->txrx_state == SubGhzTxRxStateSleep) {
notification_message(subghz->notifications, &sequence_blink_start_magenta);
result = subghz_tx_start(subghz, subghz->txrx->fff_data);
}
view_dispatcher_send_custom_event(
subghz->view_dispatcher, SubGhzCustomEventSceneRpcButtonPress);
} else if(event == RpcAppEventButtonRelease) {
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
notification_message(subghz->notifications, &sequence_blink_stop);
subghz_tx_stop(subghz);
subghz_sleep(subghz);
result = true;
}
view_dispatcher_send_custom_event(
subghz->view_dispatcher, SubGhzCustomEventSceneRpcButtonRelease);
} else {
rpc_system_app_confirm(subghz->rpc_ctx, event, false);
}
}
return result;
void subghz_blink_start(SubGhz* instance) {
furi_assert(instance);
notification_message(instance->notifications, &sequence_blink_start_magenta);
}
void subghz_blink_stop(SubGhz* instance) {
furi_assert(instance);
notification_message(instance->notifications, &sequence_blink_stop);
}
SubGhz* subghz_alloc() {
@@ -237,7 +218,7 @@ void subghz_free(SubGhz* subghz) {
if(subghz->rpc_ctx) {
rpc_system_app_set_callback(subghz->rpc_ctx, NULL, NULL);
rpc_system_app_send_exited(subghz->rpc_ctx);
notification_message(subghz->notifications, &sequence_blink_stop);
subghz_blink_stop(subghz);
subghz->rpc_ctx = NULL;
}