Added support for Bluetooth SPP-C module (#483)
This commit is contained in:
parent
9cd3b6a99f
commit
7b4d27ce89
|
@ -46,6 +46,8 @@ static void runCommands() {
|
||||||
if (!btProcessIsStarted)
|
if (!btProcessIsStarted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
chThdSleepMilliseconds(1000); // safety
|
||||||
|
|
||||||
// Store current serial port speed - we're going to change it
|
// Store current serial port speed - we're going to change it
|
||||||
int savedSerialSpeed = boardConfiguration->tunerStudioSerialSpeed;
|
int savedSerialSpeed = boardConfiguration->tunerStudioSerialSpeed;
|
||||||
|
|
||||||
|
@ -90,7 +92,8 @@ static void runCommands() {
|
||||||
// waiting for an answer
|
// waiting for an answer
|
||||||
bool wasAnswer = false;
|
bool wasAnswer = false;
|
||||||
if (sr5ReadDataTimeout(tsChannel, buffer, 2, btModuleTimeout) == 2) {
|
if (sr5ReadDataTimeout(tsChannel, buffer, 2, btModuleTimeout) == 2) {
|
||||||
wasAnswer = (buffer[0] == 'O' && buffer[1] == 'K');
|
wasAnswer = (buffer[0] == 'O' && buffer[1] == 'K') ||
|
||||||
|
(buffer[0] == '+' && (buffer[1] >= 'A' && buffer[1] <= 'Z'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait 1 second and skip all remaining response bytes from the bluetooth module
|
// wait 1 second and skip all remaining response bytes from the bluetooth module
|
||||||
|
@ -232,6 +235,12 @@ void bluetoothStart(ts_channel_s *tsChan, bluetooth_module_e moduleType, const c
|
||||||
chsnprintf(cmdName, sizeof(cmdName), "AT+NAME%s", name);
|
chsnprintf(cmdName, sizeof(cmdName), "AT+NAME%s", name);
|
||||||
chsnprintf(cmdPin, sizeof(cmdPin), "AT+PIN%s", pinCode);
|
chsnprintf(cmdPin, sizeof(cmdPin), "AT+PIN%s", pinCode);
|
||||||
break;
|
break;
|
||||||
|
case BLUETOOTH_SPP:
|
||||||
|
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;
|
||||||
default:
|
default:
|
||||||
// todo: add support for other BT module types
|
// todo: add support for other BT module types
|
||||||
scheduleMsg(&btLogger, "This Bluetooth module is currently not supported!");
|
scheduleMsg(&btLogger, "This Bluetooth module is currently not supported!");
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BLUETOOTH_HC_05,
|
BLUETOOTH_HC_05,
|
||||||
BLUETOOTH_HC_06,
|
BLUETOOTH_HC_06,
|
||||||
|
BLUETOOTH_SPP,
|
||||||
} bluetooth_module_e;
|
} bluetooth_module_e;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -177,6 +177,10 @@ static void bluetoothHC05(const char *baudRate, const char *name, const char *pi
|
||||||
static void bluetoothHC06(const char *baudRate, const char *name, const char *pinCode) {
|
static void bluetoothHC06(const char *baudRate, const char *name, const char *pinCode) {
|
||||||
bluetoothStart(&tsChannel, BLUETOOTH_HC_06, baudRate, name, pinCode);
|
bluetoothStart(&tsChannel, 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);
|
||||||
|
}
|
||||||
#endif /* EFI_BLUETOOTH_SETUP */
|
#endif /* EFI_BLUETOOTH_SETUP */
|
||||||
|
|
||||||
void tunerStudioDebug(const char *msg) {
|
void tunerStudioDebug(const char *msg) {
|
||||||
|
@ -863,6 +867,7 @@ void startTunerStudioConnectivity(void) {
|
||||||
// Example: "bluetooth_hc06 38400 rusefi 1234"
|
// Example: "bluetooth_hc06 38400 rusefi 1234"
|
||||||
addConsoleActionSSS("bluetooth_hc05", bluetoothHC05);
|
addConsoleActionSSS("bluetooth_hc05", bluetoothHC05);
|
||||||
addConsoleActionSSS("bluetooth_hc06", bluetoothHC06);
|
addConsoleActionSSS("bluetooth_hc06", bluetoothHC06);
|
||||||
|
addConsoleActionSSS("bluetooth_spp", bluetoothSPP);
|
||||||
addConsoleAction("bluetooth_cancel", bluetoothCancel);
|
addConsoleAction("bluetooth_cancel", bluetoothCancel);
|
||||||
#endif /* EFI_BLUETOOTH_SETUP */
|
#endif /* EFI_BLUETOOTH_SETUP */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue