From a459eaf3e6a8d0e0f36c885c994819a296a64e71 Mon Sep 17 00:00:00 2001 From: Peter Harper Date: Mon, 13 Mar 2023 10:35:48 +0000 Subject: [PATCH] rp2/mpbthciport: Cancel existing alarms. Cancel any existing poll alarm before add a new one. Signed-off-by: Damien George --- ports/rp2/mpbthciport.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/rp2/mpbthciport.c b/ports/rp2/mpbthciport.c index ac05e4607e..d5b3c6073a 100644 --- a/ports/rp2/mpbthciport.c +++ b/ports/rp2/mpbthciport.c @@ -57,6 +57,9 @@ static int64_t mp_bluetooth_hci_timer_callback(alarm_id_t id, void *user_data) { } void mp_bluetooth_hci_poll_in_ms(uint32_t ms) { + if (poll_timer_id != 0) { + cancel_alarm(poll_timer_id); + } poll_timer_id = add_alarm_in_ms(ms, mp_bluetooth_hci_timer_callback, NULL, true); }