SubGhz: refactoring RPC

This commit is contained in:
gid9798 2023-05-09 20:06:22 +03:00
parent 21cd94cc79
commit 752a11ba26
3 changed files with 7 additions and 11 deletions

View File

@ -362,11 +362,6 @@ void subghz_txrx_stop(SubGhzTxRx* instance) {
}
}
SubGhzTxRxState subghz_txrx_get_state(SubGhzTxRx* instance) {
furi_assert(instance);
return instance->txrx_state;
}
void subghz_txrx_hopper_update(SubGhzTxRx* instance) {
furi_assert(instance);

View File

@ -40,8 +40,6 @@ void subghz_txrx_rx_start(SubGhzTxRx* instance);
void subghz_txrx_stop(SubGhzTxRx* instance);
void subghz_txrx_sleep(SubGhzTxRx* instance);
SubGhzTxRxState subghz_txrx_get_state(SubGhzTxRx* instance);
void subghz_txrx_hopper_update(SubGhzTxRx* instance);
SubGhzHopperState subghz_txrx_hopper_get_state(SubGhzTxRx* instance);
void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state);

View File

@ -7,6 +7,7 @@
typedef enum {
SubGhzRpcStateIdle,
SubGhzRpcStateLoaded,
SubGhzRpcStateTx,
} SubGhzRpcState;
void subghz_scene_rpc_on_enter(void* context) {
@ -42,9 +43,9 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
view_dispatcher_stop(subghz->view_dispatcher);
} else if(event.event == SubGhzCustomEventSceneRpcButtonPress) {
bool result = false;
if((subghz_txrx_get_state(subghz->txrx) == SubGhzTxRxStateSleep) &&
(state == SubGhzRpcStateLoaded)) {
if((state == SubGhzRpcStateLoaded)) {
result = subghz_tx_start(subghz, subghz_txtx_get_fff_data(subghz->txrx));
state = SubGhzRpcStateTx;
if(result) subghz_blink_start(subghz);
}
if(!result) {
@ -56,9 +57,10 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventButtonPress, result);
} else if(event.event == SubGhzCustomEventSceneRpcButtonRelease) {
bool result = false;
if(subghz_txrx_get_state(subghz->txrx) == SubGhzTxRxStateTx) {
if(state == SubGhzRpcStateTx) {
subghz_txrx_stop(subghz->txrx);
subghz_blink_stop(subghz);
state = SubGhzRpcStateIdle;
result = true;
}
rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventButtonRelease, result);
@ -96,7 +98,8 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
void subghz_scene_rpc_on_exit(void* context) {
SubGhz* subghz = context;
if(subghz_txrx_get_state(subghz->txrx) == SubGhzTxRxStateTx) {
SubGhzRpcState state = scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneRpc);
if(state != SubGhzRpcStateIdle) {
subghz_txrx_stop(subghz->txrx);
subghz_blink_stop(subghz);
}