From 3f2515fdd28baf8d533fa1ee1998122b2594b84e Mon Sep 17 00:00:00 2001 From: Gibson-Ayden <77173178+Gibson-Ayden@users.noreply.github.com> Date: Thu, 29 Jul 2021 03:26:21 -0400 Subject: [PATCH] Add files via upload Added support for modification of bluetooth pin for security purposes --- ELM327_Emulator.cpp | 1 + SerialConsole.cpp | 8 +++++++- config.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ELM327_Emulator.cpp b/ELM327_Emulator.cpp index 6777e34..230563c 100644 --- a/ELM327_Emulator.cpp +++ b/ELM327_Emulator.cpp @@ -57,6 +57,7 @@ ELM327Emu::ELM327Emu() */ void ELM327Emu::setup() { serialBT.begin(settings.btName); + serialBT.setPin(settings.btPin); } void ELM327Emu::setWiFiClient(WiFiClient *client) diff --git a/SerialConsole.cpp b/SerialConsole.cpp index eea04f7..1c22e1a 100644 --- a/SerialConsole.cpp +++ b/SerialConsole.cpp @@ -107,6 +107,7 @@ void SerialConsole::printMenu() Logger::console("BTMODE=%i - Set mode for Bluetooth (0 = Off, 1 = On)", settings.enableBT); Logger::console("BTNAME=%s - Set advertised Bluetooth name", settings.btName); + Logger::console("BTPIN=%s - Set advertised Bluetooth pin", settings.btName); Serial.println(); Logger::console("LAWICEL=%i - Set whether to accept LAWICEL commands (0 = Off, 1 = On)", settings.enableLawicel); @@ -333,7 +334,11 @@ void SerialConsole::handleConfigCmd() Logger::console("Setting Bluetooth Mode to %i", newValue); settings.enableBT = newValue; writeEEPROM = true; - } else if (cmdString == String("LAWICEL")) { + } else if (cmdString == String("BTPIN")){ + Logger::console("Setting Bluetooth Pin to %s", newString); + strcpy((char *)settings.btPin, newString); + writeEEPROM = true; + }else if (cmdString == String("LAWICEL")) { if (newValue < 0) newValue = 0; if (newValue > 1) newValue = 1; Logger::console("Setting LAWICEL Mode to %i", newValue); @@ -420,6 +425,7 @@ void SerialConsole::handleConfigCmd() nvPrefs.putString("SSID", settings.SSID); nvPrefs.putString("wpa2Key", settings.WPA2Key); nvPrefs.putString("btname", settings.btName); + nvPrefs.putString("btpin", settings.SSID); nvPrefs.end(); } } diff --git a/config.h b/config.h index 1dbfff4..5982a8b 100644 --- a/config.h +++ b/config.h @@ -96,6 +96,7 @@ struct EEPROMSettings { boolean enableBT; //are we enabling bluetooth too? char btName[32]; + char btPin[6]; boolean enableLawicel;