From eb3a8734fb11ed557ce7e4dafc7b02b69e98508b Mon Sep 17 00:00:00 2001 From: Sergey Gavrilov Date: Fri, 2 Dec 2022 04:28:46 +1000 Subject: [PATCH] Fix crash in iButton notifications routine (#2074) * iButton: send notifications less strictly * iButton: set notification callback earlier --- lib/one_wire/ibutton/ibutton_worker.c | 4 +++- lib/one_wire/ibutton/ibutton_worker_modes.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/one_wire/ibutton/ibutton_worker.c b/lib/one_wire/ibutton/ibutton_worker.c index 29126d84..9d5ea389 100644 --- a/lib/one_wire/ibutton/ibutton_worker.c +++ b/lib/one_wire/ibutton/ibutton_worker.c @@ -131,7 +131,9 @@ void ibutton_worker_switch_mode(iButtonWorker* worker, iButtonWorkerMode mode) { void ibutton_worker_notify_emulate(iButtonWorker* worker) { iButtonMessage message = {.type = iButtonMessageNotifyEmulate}; - furi_check(furi_message_queue_put(worker->messages, &message, 0) == FuriStatusOk); + // we're running in an interrupt context, so we can't wait + // and we can drop message if queue is full, that's ok for that message + furi_message_queue_put(worker->messages, &message, 0); } void ibutton_worker_set_key_p(iButtonWorker* worker, iButtonKey* key) { diff --git a/lib/one_wire/ibutton/ibutton_worker_modes.c b/lib/one_wire/ibutton/ibutton_worker_modes.c index 691aea9e..b1e5904c 100644 --- a/lib/one_wire/ibutton/ibutton_worker_modes.c +++ b/lib/one_wire/ibutton/ibutton_worker_modes.c @@ -222,8 +222,8 @@ void ibutton_worker_emulate_dallas_start(iButtonWorker* worker) { memcpy(device_id, key_id, key_size); onewire_slave_attach(worker->slave, worker->device); - onewire_slave_start(worker->slave); onewire_slave_set_result_callback(worker->slave, onewire_slave_callback, worker); + onewire_slave_start(worker->slave); } void ibutton_worker_emulate_dallas_stop(iButtonWorker* worker) {