From b998fd869a1f6dbd31bff76aaf8dd3f65cf49ad5 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sun, 31 May 2020 00:07:30 +0200 Subject: [PATCH 1/2] Made device names unique --- src/actions/bluetoothbeginaction.h | 2 +- src/actions/bluetoothbeginmasteraction.h | 2 +- src/globals.h | 2 ++ src/main.cpp | 11 +++++++++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/actions/bluetoothbeginaction.h b/src/actions/bluetoothbeginaction.h index c73a562..0801fb7 100644 --- a/src/actions/bluetoothbeginaction.h +++ b/src/actions/bluetoothbeginaction.h @@ -11,7 +11,7 @@ class BluetoothBeginAction : public virtual ActionInterface public: void triggered() override { - if (!bluetoothSerial.begin("bobbyquad")) + if (!bluetoothSerial.begin(deviceName)) { Serial.println("Could not begin bluetooth"); // TODO: better error handling diff --git a/src/actions/bluetoothbeginmasteraction.h b/src/actions/bluetoothbeginmasteraction.h index d4b4253..3d862f2 100644 --- a/src/actions/bluetoothbeginmasteraction.h +++ b/src/actions/bluetoothbeginmasteraction.h @@ -11,7 +11,7 @@ class BluetoothBeginMasterAction : public virtual ActionInterface public: void triggered() override { - if (!bluetoothSerial.begin("bobbyquad", true)) + if (!bluetoothSerial.begin(deviceName, true)) { Serial.println("Could not begin bluetooth master"); // TODO: better error handling diff --git a/src/globals.h b/src/globals.h index 134402f..e36702c 100644 --- a/src/globals.h +++ b/src/globals.h @@ -24,6 +24,8 @@ float gametrakX, gametrakY, gametrakDist; #endif float avgSpeed, avgSpeedKmh, sumCurrent, sumAbsoluteCurrent; +char deviceName[16]; + Settings settings; SettingsSaver settingsSaver; diff --git a/src/main.cpp b/src/main.cpp index f45a2f4..1f83de8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -61,10 +63,15 @@ void setup() updateSwapFrontBack(); + { + uint8_t macAddress[6]; + WiFi.macAddress(&macAddress[0]); + std::sprintf(deviceName, "bobbyquad_%02hhx%02hhx%02hhx", macAddress[3], macAddress[4], macAddress[5]); + } + WiFi.mode(WIFI_AP_STA); - WiFi.softAP("bobbyquad", "Passwort_123"); + WiFi.softAP(deviceName, "Passwort_123"); WiFi.begin("realraum", "r3alraum"); - //WiFi.begin("McDonalds Free WiFi 2.4GHz", "Passwort_123"); BluetoothBeginMasterAction{}.triggered(); #ifdef FEATURE_BMS From 26d8d685cdb1e4675a53c04ffe9f3e785c9a6e49 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sun, 31 May 2020 00:41:09 +0200 Subject: [PATCH 2/2] Made the device name prefix configurable from platformio.ini --- platformio.ini | 5 +++++ src/main.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 6ef9b91..4d05774 100644 --- a/platformio.ini +++ b/platformio.ini @@ -68,6 +68,7 @@ build_flags = build_flags = ${common_env_data.build_flags} ${peters_platine.build_flags} + -DDEVICE_PREFIX=bobbyquad -DFEATURE_3WIRESW -DPINS_3WIRESW_OUT=0 -DPINS_3WIRESW_IN1=16 @@ -131,6 +132,7 @@ build_flags = ${common_env_data.build_flags} ${peters_platine.build_flags} ${default_limits.build_flags} + -DDEVICE_PREFIX=bobbycar -DDEFAULT_GASMIN=400 -DDEFAULT_GASMAX=2000 -DDEFAULT_BREMSMIN=600 @@ -179,6 +181,7 @@ upload_port = /dev/ttyUSB* build_flags = ${common_env_data.build_flags} ${peters_platine.build_flags} + -DDEVICE_PREFIX=bobbyquad ; -DFEATURE_3WIRESW ; -DPINS_3WIRESW_OUT=0 ; -DPINS_3WIRESW_IN1=16 @@ -214,6 +217,7 @@ upload_speed = 921600 build_flags = ${common_env_data.build_flags} + -DDEVICE_PREFIX=testbench -DILI9341_DRIVER=1 -DTFT_MOSI=22 -DTFT_SCLK=21 @@ -260,6 +264,7 @@ upload_speed = 921600 build_flags = ${common_env_data.build_flags} + -DDEVICE_PREFIX=bobbyquad -DUSER_SETUP_LOADED=1 -DRPI_DISPLAY_TYPE -DILI9486_DRIVER diff --git a/src/main.cpp b/src/main.cpp index 1f83de8..4a440b3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -66,7 +66,7 @@ void setup() { uint8_t macAddress[6]; WiFi.macAddress(&macAddress[0]); - std::sprintf(deviceName, "bobbyquad_%02hhx%02hhx%02hhx", macAddress[3], macAddress[4], macAddress[5]); + std::sprintf(deviceName, __STRINGIFY(DEVICE_PREFIX) "_%02hhx%02hhx%02hhx", macAddress[3], macAddress[4], macAddress[5]); } WiFi.mode(WIFI_AP_STA);