From 6882764221b31fc1b0b7d168ff882f6b1352c140 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 3 May 2020 01:43:39 -0400 Subject: [PATCH] steps towards BT --- firmware/console/binary/tunerstudio.cpp | 23 ++++++++++++++++++++--- firmware/console/console_io.cpp | 4 ++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index a3a514db8a..1ecc39e39f 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -176,17 +176,34 @@ static void setTsSpeed(int value) { } #if EFI_BLUETOOTH_SETUP + +#if defined(CONSOLE_USB_DEVICE) + /** + * we run BT on "primary" channel which is TTL if we have USB console + */ + extern ts_channel_s primaryChannel; + #define BT_CHANNEL primaryChannel +#else + /** + * if we run two TTL channels we run BT on 2nd TTL channel + */ + #define BT_CHANNEL tsChannel +#endif + + // Bluetooth HC-05 module initialization start (it waits for disconnect and then communicates to the module) static void bluetoothHC05(const char *baudRate, const char *name, const char *pinCode) { - bluetoothStart(&tsChannel, BLUETOOTH_HC_05, baudRate, name, pinCode); + bluetoothStart(&BT_CHANNEL, BLUETOOTH_HC_05, baudRate, name, pinCode); } + // Bluetooth HC-06 module initialization start (it waits for disconnect and then communicates to the module) static void bluetoothHC06(const char *baudRate, const char *name, const char *pinCode) { - bluetoothStart(&tsChannel, BLUETOOTH_HC_06, baudRate, name, pinCode); + bluetoothStart(&BT_CHANNEL, BLUETOOTH_HC_06, baudRate, name, pinCode); } + // Bluetooth SPP-C module initialization start (it waits for disconnect and then communicates to the module) static void bluetoothSPP(const char *baudRate, const char *name, const char *pinCode) { - bluetoothStart(&tsChannel, BLUETOOTH_SPP, baudRate, name, pinCode); + bluetoothStart(&BT_CHANNEL, BLUETOOTH_SPP, baudRate, name, pinCode); } #endif /* EFI_BLUETOOTH_SETUP */ diff --git a/firmware/console/console_io.cpp b/firmware/console/console_io.cpp index ccc7ba53bc..7d96feacd1 100644 --- a/firmware/console/console_io.cpp +++ b/firmware/console/console_io.cpp @@ -131,7 +131,7 @@ static bool getConsoleLine(BaseSequentialStream *chp, char *line, unsigned size) CommandHandler console_line_callback; #if (defined(EFI_CONSOLE_SERIAL_DEVICE) && ! EFI_SIMULATOR ) -static SerialConfig serialConfig = { 0, 0, USART_CR2_STOP1_BITS | USART_CR2_LINEN, 0 }; +SerialConfig serialConfig = { 0, 0, USART_CR2_STOP1_BITS | USART_CR2_LINEN, 0 }; #endif #if (defined(EFI_CONSOLE_UART_DEVICE) && ! EFI_SIMULATOR ) @@ -227,7 +227,7 @@ bool isCommandLineConsoleReady(void) { #if !defined(EFI_CONSOLE_NO_THREAD) -static ts_channel_s primaryChannel; +ts_channel_s primaryChannel; static THD_WORKING_AREA(consoleThreadStack, 3 * UTILITY_THREAD_STACK_SIZE); static THD_FUNCTION(consoleThreadEntryPoint, arg) {