From ff5928f778e7e9ef7957c2f3bf0b8e12ae5dfa47 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 19 Feb 2019 13:59:06 +0100 Subject: [PATCH] Bluetooth cosmetics, traces removed etc. --- radio/src/bluetooth.cpp | 37 +--------------------------- radio/src/gui/128x64/model_setup.cpp | 5 +--- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/radio/src/bluetooth.cpp b/radio/src/bluetooth.cpp index 0be1249d4..476aeba38 100644 --- a/radio/src/bluetooth.cpp +++ b/radio/src/bluetooth.cpp @@ -346,67 +346,44 @@ void bluetoothWakeup() if (now < bluetoothWakeupTime) return; - if (!usbPlugged()) { - bluetoothWakeupTime += 1000; // 10s - return; - } - bluetoothWakeupTime = now + 5; /* 50ms default */ - static uint8_t oldbluetooth = 255; - - if (oldbluetooth != bluetoothState) { - TRACE("State %d", bluetoothState); - oldbluetooth = bluetoothState; - } - if (g_eeGeneral.bluetoothMode == BLUETOOTH_OFF || (g_eeGeneral.bluetoothMode == BLUETOOTH_TRAINER && !IS_BLUETOOTH_TRAINER())) { - //TRACE_NOCRLF("A"); if (bluetoothState != BLUETOOTH_STATE_OFF) { - //TRACE_NOCRLF("Z"); bluetoothDone(); bluetoothState = BLUETOOTH_STATE_OFF; } bluetoothWakeupTime = now + 10; /* 100ms */ } else if (bluetoothState == BLUETOOTH_STATE_OFF) { - //TRACE_NOCRLF("B"); bluetoothInit(BLUETOOTH_FACTORY_BAUDRATE); bluetoothState = BLUETOOTH_STATE_FACTORY_BAUDRATE_INIT; } if (bluetoothState != BLUETOOTH_STATE_OFF) { - //TRACE_NOCRLF("C"); bluetoothWriteWakeup(); if (bluetoothIsWriting()) { - //TRACE_NOCRLF("D"); return; } } if (bluetoothState == BLUETOOTH_STATE_FACTORY_BAUDRATE_INIT) { - //TRACE_NOCRLF("F"); bluetoothWriteString("AT+BAUD4\r\n"); bluetoothState = BLUETOOTH_STATE_BAUDRATE_SENT; bluetoothWakeupTime = now + 10; /* 100ms */ } else if (bluetoothState == BLUETOOTH_STATE_BAUDRATE_SENT) { - //TRACE_NOCRLF("G"); bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE); bluetoothState = BLUETOOTH_STATE_BAUDRATE_INIT; bluetoothReadline(false); bluetoothWakeupTime = now + 10; /* 100ms */ } else if (bluetoothState == BLUETOOTH_STATE_CONNECTED) { - //TRACE_NOCRLF("H"); if (g_eeGeneral.bluetoothMode == BLUETOOTH_TRAINER && g_model.trainerData.mode == TRAINER_MODE_MASTER_BLUETOOTH) { - //TRACE_NOCRLF("I"); bluetoothReceiveTrainer(); } else { - //TRACE_NOCRLF("J"); if (g_eeGeneral.bluetoothMode == BLUETOOTH_TRAINER && g_model.trainerData.mode == TRAINER_MODE_SLAVE_BLUETOOTH) { - TRACE_NOCRLF("S"); bluetoothSendTrainer(); bluetoothWakeupTime = now + 2; /* 20ms */ } @@ -414,13 +391,11 @@ void bluetoothWakeup() } } else { - //TRACE_NOCRLF("L"); char * line = bluetoothReadline(); if (line) { TRACE("BT %s", line); } if (bluetoothState == BLUETOOTH_STATE_BAUDRATE_INIT) { - //TRACE_NOCRLF("M"); char command[32]; char * cur = strAppend(command, BLUETOOTH_COMMAND_NAME); uint8_t len = ZLEN(g_eeGeneral.bluetoothName); @@ -433,7 +408,7 @@ void bluetoothWakeup() #if defined(PCBHORUS) cur = strAppend(cur, "Horus"); #else - cur = strAppend(cur, "taranis"); + cur = strAppend(cur, "taranis"); // TODO capital letter once allowed by BT module #endif } strAppend(cur, "\r\n"); @@ -441,12 +416,10 @@ void bluetoothWakeup() bluetoothState = BLUETOOTH_STATE_NAME_SENT; } else if (bluetoothState == BLUETOOTH_STATE_NAME_SENT && (!strncmp(line, "OK+", 3) || !strncmp(line, "Central:", 8) || !strncmp(line, "Peripheral:", 11))) { - //TRACE_NOCRLF("N"); bluetoothWriteString("AT+TXPW\r\n"); bluetoothState = BLUETOOTH_STATE_POWER_SENT; } else if (bluetoothState == BLUETOOTH_STATE_POWER_SENT && (!strncmp(line, "Central:", 8) || !strncmp(line, "Peripheral:", 11))) { - //TRACE_NOCRLF("O"); if (g_eeGeneral.bluetoothMode == BLUETOOTH_TRAINER && g_model.trainerData.mode == TRAINER_MODE_MASTER_BLUETOOTH) bluetoothWriteString("AT+ROLE1\r\n"); else @@ -454,35 +427,28 @@ void bluetoothWakeup() bluetoothState = BLUETOOTH_STATE_ROLE_SENT; } else if (bluetoothState == BLUETOOTH_STATE_ROLE_SENT && (!strncmp(line, "Central:", 8) || !strncmp(line, "Peripheral:", 11))) { - //TRACE_NOCRLF("P"); bluetoothState = BLUETOOTH_STATE_IDLE; } else if (bluetoothState == BLUETOOTH_STATE_DISCOVER_REQUESTED) { - //TRACE_NOCRLF("Q"); bluetoothWriteString("AT+DISC?\r\n"); bluetoothState = BLUETOOTH_STATE_DISCOVER_SENT; } else if (bluetoothState == BLUETOOTH_STATE_DISCOVER_SENT && !strcmp(line, "OK+DISCS")) { - //TRACE_NOCRLF("R"); bluetoothState = BLUETOOTH_STATE_DISCOVER_START; } else if (bluetoothState == BLUETOOTH_STATE_DISCOVER_START && !strncmp(line, "OK+DISC:", 8)) { - //TRACE_NOCRLF("S"); strcpy(bluetoothDistantAddr, &line[8]); // TODO quick & dirty } else if (bluetoothState == BLUETOOTH_STATE_DISCOVER_START && !strcmp(line, "OK+DISCE")) { - //TRACE_NOCRLF("T"); bluetoothState = BLUETOOTH_STATE_DISCOVER_END; } else if (bluetoothState == BLUETOOTH_STATE_BIND_REQUESTED) { - //TRACE_NOCRLF("U"); char command[32]; strAppend(strAppend(strAppend(command, "AT+CON"), bluetoothDistantAddr), "\r\n"); bluetoothWriteString(command); bluetoothState = BLUETOOTH_STATE_CONNECT_SENT; } else if ((bluetoothState == BLUETOOTH_STATE_IDLE || bluetoothState == BLUETOOTH_STATE_DISCONNECTED || bluetoothState == BLUETOOTH_STATE_CONNECT_SENT) && !strncmp(line, "Connected:", 10)) { - //TRACE_NOCRLF("V"); strcpy(bluetoothDistantAddr, &line[10]); // TODO quick & dirty bluetoothState = BLUETOOTH_STATE_CONNECTED; if (g_model.trainerData.mode == TRAINER_MODE_SLAVE_BLUETOOTH) { @@ -490,7 +456,6 @@ void bluetoothWakeup() } } else if (bluetoothState == BLUETOOTH_STATE_DISCONNECTED && !line) { - //TRACE_NOCRLF("W"); char command[32]; strAppend(strAppend(strAppend(command, "AT+CON"), bluetoothDistantAddr), "\r\n"); bluetoothWriteString(command); diff --git a/radio/src/gui/128x64/model_setup.cpp b/radio/src/gui/128x64/model_setup.cpp index 05a4924d2..bc68bd15f 100644 --- a/radio/src/gui/128x64/model_setup.cpp +++ b/radio/src/gui/128x64/model_setup.cpp @@ -1218,9 +1218,6 @@ void menuModelSetup(event_t event) } break; - DEF - break; - case ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_1_PINMAP: case ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_2_PINMAP: case ITEM_MODEL_EXTERNAL_MODULE_PXX2_RECEIVER_1_PINMAP: @@ -1896,4 +1893,4 @@ void menuModelPinmap(event_t event) if (++pin > sentModuleChannels(g_moduleIdx)) break; } -} \ No newline at end of file +}