From 22eb5a807393b7da99a69c532db21bfb953b9327 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Thu, 10 Mar 2022 12:45:56 -0500 Subject: [PATCH] Firmware support or user instructions for jdy-33 #3944 --- firmware/console/binary/bluetooth.cpp | 8 +++++- firmware/console/binary/bluetooth.h | 6 ++++- firmware/console/binary/tunerstudio.cpp | 35 ++++++++++--------------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/firmware/console/binary/bluetooth.cpp b/firmware/console/binary/bluetooth.cpp index 66d0c23199..dc3779aadb 100644 --- a/firmware/console/binary/bluetooth.cpp +++ b/firmware/console/binary/bluetooth.cpp @@ -239,12 +239,18 @@ void bluetoothStart(SerialTsChannelBase *btChan, bluetooth_module_e moduleType, chsnprintf(cmdName, sizeof(cmdName), "AT+NAME%s", name); chsnprintf(cmdPin, sizeof(cmdPin), "AT+PIN%s", pinCode); break; - case BLUETOOTH_SPP: + case BLUETOOTH_BK3231: chsnprintf(cmdHello, sizeof(cmdHello), "AT\r\n"); chsnprintf(cmdBaud, sizeof(cmdBaud), "AT+BAUD%c\r\n", '0' + setBaudIdx); chsnprintf(cmdName, sizeof(cmdName), "AT+NAME%s\r\n", name); chsnprintf(cmdPin, sizeof(cmdPin), "AT+PIN%s\r\n", pinCode); break; + case BLUETOOTH_JDY_3x: + chsnprintf(cmdHello, sizeof(cmdHello), "AT+VERSION\r\n"); + chsnprintf(cmdBaud, sizeof(cmdBaud), "AT+BAUD%c\r\n", '0' + setBaudIdx); + chsnprintf(cmdName, sizeof(cmdName), "AT+NAME%s\r\n", name); + chsnprintf(cmdPin, sizeof(cmdPin), "AT+PIN%s\r\n", pinCode); + break; default: // todo: add support for other BT module types efiPrintf("This Bluetooth module is currently not supported!"); diff --git a/firmware/console/binary/bluetooth.h b/firmware/console/binary/bluetooth.h index d7193d4098..18eabb308d 100644 --- a/firmware/console/binary/bluetooth.h +++ b/firmware/console/binary/bluetooth.h @@ -21,7 +21,11 @@ typedef enum { BLUETOOTH_HC_05, BLUETOOTH_HC_06, - BLUETOOTH_SPP, + /** + * See https://rusefi.com/forum/viewtopic.php?f=13&t=1999 + */ + BLUETOOTH_BK3231, + BLUETOOTH_JDY_3x, } bluetooth_module_e; /** diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index 5dcb4f5107..c031790438 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -134,24 +134,6 @@ static void setTsSpeed(int value) { printTsStats(); } -#if EFI_BLUETOOTH_SETUP - -// 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(getBluetoothChannel(), 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(getBluetoothChannel(), 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(getBluetoothChannel(), BLUETOOTH_SPP, baudRate, name, pinCode); -} -#endif /* EFI_BLUETOOTH_SETUP */ - #endif // EFI_TUNER_STUDIO void tunerStudioDebug(TsChannelBase* tsChannel, const char *msg) { @@ -842,11 +824,22 @@ void startTunerStudioConnectivity(void) { addConsoleActionI("set_ts_speed", setTsSpeed); #if EFI_BLUETOOTH_SETUP + // module initialization start (it waits for disconnect and then communicates to the module) // Usage: "bluetooth_hc06 " // Example: "bluetooth_hc06 38400 rusefi 1234" - addConsoleActionSSS("bluetooth_hc05", bluetoothHC05); - addConsoleActionSSS("bluetooth_hc06", bluetoothHC06); - addConsoleActionSSS("bluetooth_spp", bluetoothSPP); + // bluetooth_jdy 115200 alphax 1234 + addConsoleActionSSS("bluetooth_hc05", [](const char *baudRate, const char *name, const char *pinCode) { + bluetoothStart(getBluetoothChannel(), BLUETOOTH_HC_05, baudRate, name, pinCode); + }); + addConsoleActionSSS("bluetooth_hc06", [](const char *baudRate, const char *name, const char *pinCode) { + bluetoothStart(getBluetoothChannel(), BLUETOOTH_HC_06, baudRate, name, pinCode); + }); + addConsoleActionSSS("bluetooth_bk", [](const char *baudRate, const char *name, const char *pinCode) { + bluetoothStart(getBluetoothChannel(), BLUETOOTH_BK3231, baudRate, name, pinCode); + }); + addConsoleActionSSS("bluetooth_jdy", [](const char *baudRate, const char *name, const char *pinCode) { + bluetoothStart(getBluetoothChannel(), BLUETOOTH_JDY_3x, baudRate, name, pinCode); + }); addConsoleAction("bluetooth_cancel", bluetoothCancel); #endif /* EFI_BLUETOOTH_SETUP */ }