[FL-3656] Fix crash when exiting write mode (#3191)
This commit is contained in:
parent
47cc05dab4
commit
0131eb3aa2
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
enum iButtonCustomEvent {
|
typedef enum {
|
||||||
// Reserve first 100 events for button types and indexes, starting from 0
|
// Reserve first 100 events for button types and indexes, starting from 0
|
||||||
iButtonCustomEventReserved = 100,
|
iButtonCustomEventReserved = 100,
|
||||||
|
|
||||||
@ -10,8 +10,12 @@ enum iButtonCustomEvent {
|
|||||||
iButtonCustomEventByteEditResult,
|
iButtonCustomEventByteEditResult,
|
||||||
iButtonCustomEventWorkerEmulated,
|
iButtonCustomEventWorkerEmulated,
|
||||||
iButtonCustomEventWorkerRead,
|
iButtonCustomEventWorkerRead,
|
||||||
|
iButtonCustomEventWorkerWriteOK,
|
||||||
|
iButtonCustomEventWorkerWriteSameKey,
|
||||||
|
iButtonCustomEventWorkerWriteNoDetect,
|
||||||
|
iButtonCustomEventWorkerWriteCannotWrite,
|
||||||
|
|
||||||
iButtonCustomEventRpcLoad,
|
iButtonCustomEventRpcLoad,
|
||||||
iButtonCustomEventRpcExit,
|
iButtonCustomEventRpcExit,
|
||||||
iButtonCustomEventRpcSessionClose,
|
iButtonCustomEventRpcSessionClose,
|
||||||
};
|
} iButtonCustomEvent;
|
||||||
|
|||||||
@ -5,9 +5,26 @@ typedef enum {
|
|||||||
iButtonSceneWriteStateBlinkYellow,
|
iButtonSceneWriteStateBlinkYellow,
|
||||||
} iButtonSceneWriteState;
|
} iButtonSceneWriteState;
|
||||||
|
|
||||||
|
static inline iButtonCustomEvent
|
||||||
|
ibutton_scene_write_to_custom_event(iButtonWorkerWriteResult result) {
|
||||||
|
switch(result) {
|
||||||
|
case iButtonWorkerWriteOK:
|
||||||
|
return iButtonCustomEventWorkerWriteOK;
|
||||||
|
case iButtonWorkerWriteSameKey:
|
||||||
|
return iButtonCustomEventWorkerWriteSameKey;
|
||||||
|
case iButtonWorkerWriteNoDetect:
|
||||||
|
return iButtonCustomEventWorkerWriteNoDetect;
|
||||||
|
case iButtonWorkerWriteCannotWrite:
|
||||||
|
return iButtonCustomEventWorkerWriteCannotWrite;
|
||||||
|
default:
|
||||||
|
furi_crash();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void ibutton_scene_write_callback(void* context, iButtonWorkerWriteResult result) {
|
static void ibutton_scene_write_callback(void* context, iButtonWorkerWriteResult result) {
|
||||||
iButton* ibutton = context;
|
iButton* ibutton = context;
|
||||||
view_dispatcher_send_custom_event(ibutton->view_dispatcher, result);
|
view_dispatcher_send_custom_event(
|
||||||
|
ibutton->view_dispatcher, ibutton_scene_write_to_custom_event(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ibutton_scene_write_on_enter(void* context) {
|
void ibutton_scene_write_on_enter(void* context) {
|
||||||
@ -61,16 +78,14 @@ bool ibutton_scene_write_on_event(void* context, SceneManagerEvent event) {
|
|||||||
|
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
consumed = true;
|
consumed = true;
|
||||||
if((event.event == iButtonWorkerWriteOK) || (event.event == iButtonWorkerWriteSameKey)) {
|
if((event.event == iButtonCustomEventWorkerWriteOK) ||
|
||||||
|
(event.event == iButtonCustomEventWorkerWriteSameKey)) {
|
||||||
scene_manager_next_scene(scene_manager, iButtonSceneWriteSuccess);
|
scene_manager_next_scene(scene_manager, iButtonSceneWriteSuccess);
|
||||||
} else if(event.event == iButtonWorkerWriteNoDetect) {
|
} else if(event.event == iButtonCustomEventWorkerWriteNoDetect) {
|
||||||
ibutton_notification_message(ibutton, iButtonNotificationMessageEmulateBlink);
|
ibutton_notification_message(ibutton, iButtonNotificationMessageEmulateBlink);
|
||||||
} else if(event.event == iButtonWorkerWriteCannotWrite) {
|
} else if(event.event == iButtonCustomEventWorkerWriteCannotWrite) {
|
||||||
ibutton_notification_message(ibutton, iButtonNotificationMessageYellowBlink);
|
ibutton_notification_message(ibutton, iButtonNotificationMessageYellowBlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(event.type == SceneManagerEventTypeTick) {
|
|
||||||
consumed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return consumed;
|
return consumed;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user