From 14c282110d0db9dbe544a5a4fa69748afccab1d6 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 29 Apr 2019 09:58:40 +0200 Subject: [PATCH] [Bluetooth] CLEAR command added --- radio/src/bluetooth.cpp | 5 +++++ radio/src/bluetooth.h | 1 + radio/src/gui/128x64/model_setup.cpp | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/radio/src/bluetooth.cpp b/radio/src/bluetooth.cpp index db0775bee..b3fd28e3a 100644 --- a/radio/src/bluetooth.cpp +++ b/radio/src/bluetooth.cpp @@ -450,6 +450,11 @@ void Bluetooth::wakeup() /* else if (state == BLUETOOTH_STATE_DISCOVER_START && !strcmp(line, "OK+DISCE")) { state = BLUETOOTH_STATE_DISCOVER_END; } */ + else if (state == BLUETOOTH_STATE_CLEAR_REQUESTED) { + char command[] = "AT+CLEAR"; + writeString(command); + state = BLUETOOTH_STATE_IDLE; + } else if (state == BLUETOOTH_STATE_BIND_REQUESTED) { char command[32]; strAppend(strAppend(command, "AT+CON"), distantAddr); diff --git a/radio/src/bluetooth.h b/radio/src/bluetooth.h index 238fa1d88..e8e86e056 100644 --- a/radio/src/bluetooth.h +++ b/radio/src/bluetooth.h @@ -40,6 +40,7 @@ enum BluetoothStates { BLUETOOTH_STATE_CONNECT_SENT, BLUETOOTH_STATE_CONNECTED, BLUETOOTH_STATE_DISCONNECTED, + BLUETOOTH_STATE_CLEAR_REQUESTED, BLUETOOTH_STATE_FLASH_FIRMWARE }; diff --git a/radio/src/gui/128x64/model_setup.cpp b/radio/src/gui/128x64/model_setup.cpp index fb3c6841c..11973059a 100644 --- a/radio/src/gui/128x64/model_setup.cpp +++ b/radio/src/gui/128x64/model_setup.cpp @@ -1192,7 +1192,7 @@ void menuModelSetup(event_t event) lcdDrawText(INDENT_WIDTH, y+1, bluetooth.distantAddr, TINSIZE); lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, BUTTON(TR_CLEAR), attr); if (attr && event == EVT_KEY_FIRST(KEY_ENTER)) { - bluetooth.state = BLUETOOTH_STATE_OFF; + bluetooth.state = BLUETOOTH_STATE_CLEAR_REQUESTED; memclear(bluetooth.distantAddr, sizeof(bluetooth.distantAddr)); } } @@ -1203,6 +1203,7 @@ void menuModelSetup(event_t event) else lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_BUTTON_DISCOVER, attr); if (attr && event == EVT_KEY_FIRST(KEY_ENTER)) { + killEvents(KEY_ENTER); if (bluetooth.state < BLUETOOTH_STATE_IDLE) { bluetooth.state = BLUETOOTH_STATE_OFF; }