Fixed mac address detection for bobbycar unique identifier

This commit is contained in:
2021-06-28 22:25:50 +02:00
parent 9bdd512057
commit f146deca05
11 changed files with 37 additions and 14 deletions

3
.gitmodules vendored
View File

@ -37,3 +37,6 @@
[submodule "components/fmt"] [submodule "components/fmt"]
path = components/fmt path = components/fmt
url = git@github.com:0xFEEDC0DE64/fmt.git url = git@github.com:0xFEEDC0DE64/fmt.git
[submodule "components/espwifistack"]
path = components/espwifistack
url = git@github.com:0xFEEDC0DE64/espwifistack.git

View File

@ -154,6 +154,7 @@ set(headers
feedbackparser.h feedbackparser.h
globals.h globals.h
htmlutils.h htmlutils.h
macros_bobbycar.h
modeinterface.h modeinterface.h
ota.h ota.h
serialhandler.h serialhandler.h
@ -167,6 +168,7 @@ set(headers
unifiedmodelmode.h unifiedmodelmode.h
utils.h utils.h
wifitexthelpers.h wifitexthelpers.h
wifi_bobbycar.h
) )
set(sources set(sources
@ -179,7 +181,7 @@ set(dependencies
# AsyncTCP # AsyncTCP
bobbycar-protocol cpputils cxx-ring-buffer date bobbycar-protocol cpputils cxx-ring-buffer date
# ESPAsyncWebServer # ESPAsyncWebServer
espchrono espcpputils expected fmt TFT_eSPI espchrono espcpputils espwifistack expected fmt TFT_eSPI
) )
idf_component_register( idf_component_register(

View File

@ -1,8 +1,10 @@
#pragma once #pragma once
// local includes
#include "actioninterface.h" #include "actioninterface.h"
#include "globals.h" #include "globals.h"
#include "utils.h" #include "utils.h"
#include "macros_bobbycar.h"
namespace { namespace {
class WifiSoftApAction : public virtual ActionInterface class WifiSoftApAction : public virtual ActionInterface

View File

@ -163,7 +163,7 @@ void StatusDisplay::redraw()
m_labelLimit1.redraw(std::to_string(controllers.front.command.left.iDcMax) + "A"); m_labelLimit1.redraw(std::to_string(controllers.front.command.left.iDcMax) + "A");
m_labelPerformance.redraw(std::to_string(performance.last)); m_labelPerformance.redraw(std::to_string(performance.last));
m_labelMode.redraw(currentMode->displayName()); m_labelMode.redraw(currentMode->displayName());
m_labelName.redraw(&deviceName[0]); m_labelName.redraw(deviceName);
const auto profile = settingsPersister.currentlyOpenProfileIndex(); const auto profile = settingsPersister.currentlyOpenProfileIndex();
m_labelProfile.redraw(profile ? std::to_string(*profile) : "-"); m_labelProfile.redraw(profile ? std::to_string(*profile) : "-");
} }

View File

@ -14,6 +14,7 @@
#endif #endif
#include <SPI.h> #include <SPI.h>
// 3rdparty lib includes
#include <espchrono.h> #include <espchrono.h>
#include <TFT_eSPI.h> #include <TFT_eSPI.h>
@ -23,6 +24,7 @@
#include "modeinterface.h" #include "modeinterface.h"
#include "settings.h" #include "settings.h"
#include "settingspersister.h" #include "settingspersister.h"
#include "macros_bobbycar.h"
namespace { namespace {
std::optional<int16_t> raw_gas, raw_brems; std::optional<int16_t> raw_gas, raw_brems;
@ -34,7 +36,7 @@ float gametrakX, gametrakY, gametrakDist;
#endif #endif
float avgSpeed, avgSpeedKmh, sumCurrent; float avgSpeed, avgSpeedKmh, sumCurrent;
char deviceName[32]; char deviceName[32] = STRING(DEVICE_PREFIX) "_ERR";
Settings settings; Settings settings;
SettingsPersister settingsPersister; SettingsPersister settingsPersister;

5
main/macros_bobbycar.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
// macros are a shit piece of software
#define STRING2(s) #s
#define STRING(s) STRING2(s)

View File

@ -3,6 +3,7 @@
// esp-idf includes // esp-idf includes
#include <esp_wifi_types.h> #include <esp_wifi_types.h>
#include <esp_log.h>
// Arduino includes // Arduino includes
#include <Arduino.h> #include <Arduino.h>
@ -10,10 +11,12 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <espchrono.h> #include <espchrono.h>
using namespace std::chrono_literals; using namespace std::chrono_literals;
#include <espwifistack.h>
// local includes // local includes
#include "bobbycar-common.h" #include "bobbycar-common.h"
#include "bobbycar-serial.h" #include "bobbycar-serial.h"
#include "macros_bobbycar.h"
#include "globals.h" #include "globals.h"
#include "modes/defaultmode.h" #include "modes/defaultmode.h"
#include "modes/tempomatmode.h" #include "modes/tempomatmode.h"
@ -176,13 +179,12 @@ extern "C" void app_main()
printMemoryStats("swapFronBack()"); printMemoryStats("swapFronBack()");
#endif #endif
//bootLabel.redraw("deviceName"); bootLabel.redraw("deviceName");
//{ if (const auto result = wifi_stack::get_default_mac_addr())
// uint8_t macAddress[6]; std::sprintf(deviceName, STRING(DEVICE_PREFIX) "_%02hhx%02hhx%02hhx", result->at(3), result->at(4), result->at(5));
// WiFi.macAddress(&macAddress[0]); else
// std::sprintf(deviceName, STRING(DEVICE_PREFIX) "_%02hhx%02hhx%02hhx", macAddress[3], macAddress[4], macAddress[5]); ESP_LOGE("MAIN", "get_default_mac_addr() failed: %.*s", result.error().size(), result.error().data());
//} printMemoryStats("deviceName");
//printMemoryStats("deviceName");
//bootLabel.redraw("setHostname"); //bootLabel.redraw("setHostname");
//if (!WiFi.setHostname(deviceName)) //if (!WiFi.setHostname(deviceName))

View File

@ -28,10 +28,6 @@
#include "can.h" #include "can.h"
#endif #endif
// macros are a shit piece of software
#define STRING2(s) #s
#define STRING(s) STRING2(s)
namespace { namespace {
bool currentlyReverseBeeping; bool currentlyReverseBeeping;
bool reverseBeepToggle; bool reverseBeepToggle;

8
main/wifi_bobbycar.h Normal file
View File

@ -0,0 +1,8 @@
#pragma once
// 3rdparty lib includes
#include <espwifistack.h>
namespace {
} // namespace

View File

@ -1,7 +1,9 @@
#pragma once #pragma once
// esp-idf includes
#include <esp_wifi_types.h> #include <esp_wifi_types.h>
// local includes
#include "accessorinterface.h" #include "accessorinterface.h"
namespace { namespace {