RPC App: state message and GUI update (#1423)
* RPC App: state message and GUI update * Protobuf submodule update Co-authored-by: SG <who.just.the.doctor@gmail.com> Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -46,6 +46,8 @@ typedef enum {
|
||||
SubGhzCustomEventSceneExit,
|
||||
SubGhzCustomEventSceneStay,
|
||||
|
||||
SubGhzCustomEventSceneRpcLoad,
|
||||
|
||||
SubGhzCustomEventViewReceiverOK,
|
||||
SubGhzCustomEventViewReceiverConfig,
|
||||
SubGhzCustomEventViewReceiverBack,
|
||||
|
@@ -2,24 +2,40 @@
|
||||
|
||||
void subghz_scene_rpc_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
Widget* widget = subghz->widget;
|
||||
Popup* popup = subghz->popup;
|
||||
|
||||
widget_add_text_box_element(
|
||||
widget, 0, 0, 128, 28, AlignCenter, AlignCenter, "RPC mode", false);
|
||||
popup_set_header(popup, "Sub-GHz", 82, 28, AlignCenter, AlignBottom);
|
||||
popup_set_text(popup, "RPC mode", 82, 32, AlignCenter, AlignTop);
|
||||
|
||||
popup_set_icon(popup, 2, 14, &I_Warning_30x23); // TODO: icon
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdPopup);
|
||||
|
||||
notification_message(subghz->notifications, &sequence_display_backlight_on);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdWidget);
|
||||
}
|
||||
|
||||
bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
Popup* popup = subghz->popup;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
if(event.event == SubGhzCustomEventSceneExit) {
|
||||
view_dispatcher_stop(subghz->view_dispatcher);
|
||||
} else if(event.event == SubGhzCustomEventSceneRpcLoad) {
|
||||
string_t file_name;
|
||||
string_init(file_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
|
||||
snprintf(
|
||||
subghz->file_name_tmp,
|
||||
SUBGHZ_MAX_LEN_NAME,
|
||||
"loaded\n%s",
|
||||
string_get_cstr(file_name));
|
||||
popup_set_text(popup, subghz->file_name_tmp, 82, 32, AlignCenter, AlignTop);
|
||||
|
||||
string_clear(file_name);
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
@@ -27,8 +43,9 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
void subghz_scene_rpc_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
Popup* popup = subghz->popup;
|
||||
|
||||
//subghz_rpc_exit_callback(subghz);
|
||||
|
||||
widget_reset(subghz->widget);
|
||||
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
|
||||
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 0, NULL);
|
||||
}
|
||||
|
@@ -5,6 +5,18 @@
|
||||
#include "subghz_i.h"
|
||||
#include <lib/toolbox/path.h>
|
||||
|
||||
static const NotificationSequence sequence_blink_start_magenta = {
|
||||
&message_blink_start_10,
|
||||
&message_blink_set_color_magenta,
|
||||
&message_do_not_reset,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const NotificationSequence sequence_blink_stop = {
|
||||
&message_blink_stop,
|
||||
NULL,
|
||||
};
|
||||
|
||||
bool subghz_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
@@ -36,6 +48,7 @@ static bool subghz_rpc_command_callback(RpcAppSystemEvent event, const char* arg
|
||||
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);
|
||||
@@ -53,15 +66,19 @@ static bool subghz_rpc_command_callback(RpcAppSystemEvent event, const char* arg
|
||||
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;
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
} 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;
|
||||
@@ -83,8 +100,6 @@ SubGhz* subghz_alloc() {
|
||||
// View Dispatcher
|
||||
subghz->view_dispatcher = view_dispatcher_alloc();
|
||||
view_dispatcher_enable_queue(subghz->view_dispatcher);
|
||||
view_dispatcher_attach_to_gui(
|
||||
subghz->view_dispatcher, subghz->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
subghz->scene_manager = scene_manager_alloc(&subghz_scene_handlers, subghz);
|
||||
view_dispatcher_set_event_callback_context(subghz->view_dispatcher, subghz);
|
||||
@@ -218,6 +233,8 @@ 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->rpc_ctx = NULL;
|
||||
}
|
||||
|
||||
@@ -322,24 +339,33 @@ int32_t subghz_app(void* p) {
|
||||
if(sscanf(p, "RPC %lX", &rpc_ctx) == 1) {
|
||||
subghz->rpc_ctx = (void*)rpc_ctx;
|
||||
rpc_system_app_set_callback(subghz->rpc_ctx, subghz_rpc_command_callback, subghz);
|
||||
rpc_system_app_send_started(subghz->rpc_ctx);
|
||||
view_dispatcher_attach_to_gui(
|
||||
subghz->view_dispatcher, subghz->gui, ViewDispatcherTypeDesktop);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneRpc);
|
||||
} else if(subghz_key_load(subghz, p, true)) {
|
||||
string_set_str(subghz->file_path, p);
|
||||
|
||||
if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) {
|
||||
//Load Raw TX
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWLoad;
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
|
||||
} else {
|
||||
//Load transmitter TX
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTransmitter);
|
||||
}
|
||||
} else {
|
||||
//exit app
|
||||
scene_manager_stop(subghz->scene_manager);
|
||||
view_dispatcher_stop(subghz->view_dispatcher);
|
||||
view_dispatcher_attach_to_gui(
|
||||
subghz->view_dispatcher, subghz->gui, ViewDispatcherTypeFullscreen);
|
||||
if(subghz_key_load(subghz, p, true)) {
|
||||
string_set_str(subghz->file_path, p);
|
||||
|
||||
if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) {
|
||||
//Load Raw TX
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWLoad;
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
|
||||
} else {
|
||||
//Load transmitter TX
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTransmitter);
|
||||
}
|
||||
} else {
|
||||
//exit app
|
||||
scene_manager_stop(subghz->scene_manager);
|
||||
view_dispatcher_stop(subghz->view_dispatcher);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
view_dispatcher_attach_to_gui(
|
||||
subghz->view_dispatcher, subghz->gui, ViewDispatcherTypeFullscreen);
|
||||
string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
|
||||
if(load_database) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneStart);
|
||||
|
Reference in New Issue
Block a user