Implemented wifi stack with AP
This commit is contained in:
@ -92,6 +92,7 @@ using namespace std::chrono_literals;
|
|||||||
#ifdef FEATURE_CLOUD
|
#ifdef FEATURE_CLOUD
|
||||||
#include "cloud.h"
|
#include "cloud.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "wifi_bobbycar.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
ModeInterface *lastMode{};
|
ModeInterface *lastMode{};
|
||||||
@ -173,12 +174,6 @@ extern "C" void app_main()
|
|||||||
}
|
}
|
||||||
printMemoryStats("loadSettings()");
|
printMemoryStats("loadSettings()");
|
||||||
|
|
||||||
#ifdef FEATURE_SERIAL
|
|
||||||
bootLabel.redraw("swap front back");
|
|
||||||
updateSwapFrontBack();
|
|
||||||
printMemoryStats("swapFronBack()");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bootLabel.redraw("deviceName");
|
bootLabel.redraw("deviceName");
|
||||||
if (const auto result = wifi_stack::get_default_mac_addr())
|
if (const auto result = wifi_stack::get_default_mac_addr())
|
||||||
std::sprintf(deviceName, STRING(DEVICE_PREFIX) "_%02hhx%02hhx%02hhx", result->at(3), result->at(4), result->at(5));
|
std::sprintf(deviceName, STRING(DEVICE_PREFIX) "_%02hhx%02hhx%02hhx", result->at(3), result->at(4), result->at(5));
|
||||||
@ -186,40 +181,15 @@ extern "C" void app_main()
|
|||||||
ESP_LOGE("MAIN", "get_default_mac_addr() failed: %.*s", result.error().size(), result.error().data());
|
ESP_LOGE("MAIN", "get_default_mac_addr() failed: %.*s", result.error().size(), result.error().data());
|
||||||
printMemoryStats("deviceName");
|
printMemoryStats("deviceName");
|
||||||
|
|
||||||
//bootLabel.redraw("setHostname");
|
bootLabel.redraw("wifi");
|
||||||
//if (!WiFi.setHostname(deviceName))
|
wifi_begin();
|
||||||
//{
|
printMemoryStats("wifi_begin()");
|
||||||
//Serial.println("Could not setHostname");
|
|
||||||
//}
|
|
||||||
//printMemoryStats("setHostname()");
|
|
||||||
|
|
||||||
//bootLabel.redraw("softAPsetHostname");
|
#ifdef FEATURE_SERIAL
|
||||||
//if (!WiFi.softAPsetHostname(deviceName))
|
bootLabel.redraw("swap front back");
|
||||||
//{
|
updateSwapFrontBack();
|
||||||
//Serial.println("Could not softAPsetHostname");
|
printMemoryStats("swapFronBack()");
|
||||||
//}
|
#endif
|
||||||
//printMemoryStats("softAPsetHostname()");
|
|
||||||
|
|
||||||
//bootLabel.redraw("WiFi mode");
|
|
||||||
//if (!WiFi.mode(settings.wifiSettings.autoWifiMode))
|
|
||||||
//{
|
|
||||||
//Serial.println("Could not set mode to WIFI_AP_STA");
|
|
||||||
//}
|
|
||||||
//printMemoryStats("WiFi.mode()");
|
|
||||||
|
|
||||||
//if (settings.wifiSettings.autoEnableAp)
|
|
||||||
//{
|
|
||||||
//bootLabel.redraw("WiFi softAp");
|
|
||||||
//WifiSoftApAction{}.triggered();
|
|
||||||
//printMemoryStats("WifiSoftApAction()");
|
|
||||||
//}
|
|
||||||
|
|
||||||
//bootLabel.redraw("WiFi begin");
|
|
||||||
//if (!WiFi.begin("realraum", "r3alraum"))
|
|
||||||
//{
|
|
||||||
//Serial.println("Could not begin WiFi");
|
|
||||||
//}
|
|
||||||
//printMemoryStats("WiFi.begin()");
|
|
||||||
|
|
||||||
#ifdef FEATURE_BLUETOOTH
|
#ifdef FEATURE_BLUETOOTH
|
||||||
if (settings.bluetoothSettings.autoBluetoothMode == BluetoothMode::Master)
|
if (settings.bluetoothSettings.autoBluetoothMode == BluetoothMode::Master)
|
||||||
@ -305,6 +275,8 @@ extern "C" void app_main()
|
|||||||
|
|
||||||
const auto now = espchrono::millis_clock::now();
|
const auto now = espchrono::millis_clock::now();
|
||||||
|
|
||||||
|
wifi_update();
|
||||||
|
|
||||||
#ifdef FEATURE_DPAD
|
#ifdef FEATURE_DPAD
|
||||||
dpad::update();
|
dpad::update();
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,6 +3,93 @@
|
|||||||
// 3rdparty lib includes
|
// 3rdparty lib includes
|
||||||
#include <espwifistack.h>
|
#include <espwifistack.h>
|
||||||
|
|
||||||
namespace {
|
// local includes
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
wifi_stack::config wifi_create_config()
|
||||||
|
{
|
||||||
|
return wifi_stack::config {
|
||||||
|
.wifiEnabled = true,
|
||||||
|
.hostname = deviceName,
|
||||||
|
.wifis = std::array<wifi_stack::wifi_entry, 10> {
|
||||||
|
wifi_stack::wifi_entry { .ssid = "realraum", .key = "r3alraum" },
|
||||||
|
wifi_stack::wifi_entry { .ssid = "McDonalds Free WiFi", .key = "Passwort_123" },
|
||||||
|
wifi_stack::wifi_entry { .ssid = "***REMOVED***", .key = "***REMOVED***" },
|
||||||
|
wifi_stack::wifi_entry { .ssid = {}, .key = {} },
|
||||||
|
wifi_stack::wifi_entry { .ssid = {}, .key = {} },
|
||||||
|
wifi_stack::wifi_entry { .ssid = {}, .key = {} },
|
||||||
|
wifi_stack::wifi_entry { .ssid = {}, .key = {} },
|
||||||
|
wifi_stack::wifi_entry { .ssid = {}, .key = {} },
|
||||||
|
wifi_stack::wifi_entry { .ssid = {}, .key = {} },
|
||||||
|
wifi_stack::wifi_entry { .ssid = {}, .key = {} }
|
||||||
|
},
|
||||||
|
.sta_ip = {
|
||||||
|
.dhcpEnabled = true,
|
||||||
|
.staticIp = {},
|
||||||
|
.staticGateway = {},
|
||||||
|
.staticSubnet = {},
|
||||||
|
.staticDns1 = {},
|
||||||
|
.staticDns2 = {}
|
||||||
|
},
|
||||||
|
.ap = {
|
||||||
|
{
|
||||||
|
.ssid = deviceName,
|
||||||
|
.key = STRING(AP_PASSWORD)
|
||||||
|
},
|
||||||
|
.channel = 1,
|
||||||
|
.authmode = WIFI_AUTH_WPA2_PSK,
|
||||||
|
.ssid_hidden = false,
|
||||||
|
.max_connection = 4,
|
||||||
|
.beacon_interval = 100,
|
||||||
|
.ip = {10, 0, 0, 1},
|
||||||
|
.subnet = {255, 255, 255, 0}
|
||||||
|
},
|
||||||
|
.min_rssi = -90
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void wifi_begin()
|
||||||
|
{
|
||||||
|
wifi_stack::init(wifi_create_config());
|
||||||
|
//bootLabel.redraw("setHostname");
|
||||||
|
//if (!WiFi.setHostname(deviceName))
|
||||||
|
//{
|
||||||
|
//Serial.println("Could not setHostname");
|
||||||
|
//}
|
||||||
|
//printMemoryStats("setHostname()");
|
||||||
|
|
||||||
|
//bootLabel.redraw("softAPsetHostname");
|
||||||
|
//if (!WiFi.softAPsetHostname(deviceName))
|
||||||
|
//{
|
||||||
|
//Serial.println("Could not softAPsetHostname");
|
||||||
|
//}
|
||||||
|
//printMemoryStats("softAPsetHostname()");
|
||||||
|
|
||||||
|
//bootLabel.redraw("WiFi mode");
|
||||||
|
//if (!WiFi.mode(settings.wifiSettings.autoWifiMode))
|
||||||
|
//{
|
||||||
|
//Serial.println("Could not set mode to WIFI_AP_STA");
|
||||||
|
//}
|
||||||
|
//printMemoryStats("WiFi.mode()");
|
||||||
|
|
||||||
|
//if (settings.wifiSettings.autoEnableAp)
|
||||||
|
//{
|
||||||
|
//bootLabel.redraw("WiFi softAp");
|
||||||
|
//WifiSoftApAction{}.triggered();
|
||||||
|
//printMemoryStats("WifiSoftApAction()");
|
||||||
|
//}
|
||||||
|
|
||||||
|
//bootLabel.redraw("WiFi begin");
|
||||||
|
//if (!WiFi.begin("realraum", "r3alraum"))
|
||||||
|
//{
|
||||||
|
//Serial.println("Could not begin WiFi");
|
||||||
|
//}
|
||||||
|
//printMemoryStats("WiFi.begin()");
|
||||||
|
}
|
||||||
|
|
||||||
|
void wifi_update()
|
||||||
|
{
|
||||||
|
wifi_stack::update(wifi_create_config());
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
# Name, Type, SubType, Offset, Size, Flags
|
# Name, Type, SubType, Offset, Size, Flags
|
||||||
nvs, data, nvs, 0x10000, 0x40000,
|
nvs, data, nvs, 0x10000, 0x40000,
|
||||||
nvsFac, data, nvs, 0x50000, 0x40000,
|
#nvsFac, data, nvs, 0x50000, 0x40000,
|
||||||
phy_init, data, phy, 0x90000, 0x1000,
|
phy_init, data, phy, 0x90000, 0x1000,
|
||||||
otadata, data, ota, 0x91000, 0x2000,
|
otadata, data, ota, 0x91000, 0x2000,
|
||||||
# PADDING FOR APP ALIGN 0x93000, 0xD000,
|
# PADDING FOR APP ALIGN 0x93000, 0xD000,
|
||||||
factory, app, factory, 0xA0000, 0x100000,
|
#factory, app, factory, 0xA0000, 0x100000,
|
||||||
app_0, app, ota_0, 0x1A0000, 0x400000,
|
app_0, app, ota_0, 0x1A0000, 0x400000,
|
||||||
app_1, app, ota_1, 0x5A0000, 0x400000,
|
app_1, app, ota_1, 0x5A0000, 0x400000,
|
||||||
nvs_key, data, nvs_keys, 0x9A0000, 0x1000, encrypted
|
nvs_key, data, nvs_keys, 0x9A0000, 0x1000, encrypted
|
||||||
|
|
Reference in New Issue
Block a user