Added actions to start and stop softAp
This commit is contained in:
22
src/actions/wifisoftapaction.h
Normal file
22
src/actions/wifisoftapaction.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <HardwareSerial.h>
|
||||||
|
#include <WiFi.h>
|
||||||
|
|
||||||
|
#include "actioninterface.h"
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class WifiSoftApAction : public virtual ActionInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void triggered() override
|
||||||
|
{
|
||||||
|
if (!WiFi.softAP(deviceName, "Passwort_123"))
|
||||||
|
{
|
||||||
|
Serial.println("Could not softAP WiFi");
|
||||||
|
// TODO: better error handling
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
21
src/actions/wifisoftapdisconnectaction.h
Normal file
21
src/actions/wifisoftapdisconnectaction.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <HardwareSerial.h>
|
||||||
|
#include <WiFi.h>
|
||||||
|
|
||||||
|
#include "actioninterface.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class WifiSoftApDisconnectAction : public virtual ActionInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void triggered() override
|
||||||
|
{
|
||||||
|
if (!WiFi.softAPdisconnect())
|
||||||
|
{
|
||||||
|
Serial.println("Could not softAPdisconnect WiFi");
|
||||||
|
// TODO: better error handling
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
21
src/actions/wifisoftapdisconnectwifioffaction.h
Normal file
21
src/actions/wifisoftapdisconnectwifioffaction.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <HardwareSerial.h>
|
||||||
|
#include <WiFi.h>
|
||||||
|
|
||||||
|
#include "actioninterface.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class WifiSoftApDisconnectWifioffAction : public virtual ActionInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void triggered() override
|
||||||
|
{
|
||||||
|
if (!WiFi.softAPdisconnect(true))
|
||||||
|
{
|
||||||
|
Serial.println("Could not softAPdisconnect wifioff WiFi");
|
||||||
|
// TODO: better error handling
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@@ -4,6 +4,9 @@
|
|||||||
#include "staticmenudefinition.h"
|
#include "staticmenudefinition.h"
|
||||||
#include "menuitem.h"
|
#include "menuitem.h"
|
||||||
#include "actions/dummyaction.h"
|
#include "actions/dummyaction.h"
|
||||||
|
#include "actions/wifisoftapaction.h"
|
||||||
|
#include "actions/wifisoftapdisconnectaction.h"
|
||||||
|
#include "actions/wifisoftapdisconnectwifioffaction.h"
|
||||||
#include "actions/wifisoftapenableipv6action.h"
|
#include "actions/wifisoftapenableipv6action.h"
|
||||||
#include "actions/switchscreenaction.h"
|
#include "actions/switchscreenaction.h"
|
||||||
#include "icons/back.h"
|
#include "icons/back.h"
|
||||||
@@ -20,16 +23,19 @@ class AccessPointWifiSettingsMenu :
|
|||||||
public StaticText<TEXT_ACCESSPOINTWIFISETTINGS>,
|
public StaticText<TEXT_ACCESSPOINTWIFISETTINGS>,
|
||||||
public BackActionInterface<SwitchScreenAction<WifiSettingsMenu>>,
|
public BackActionInterface<SwitchScreenAction<WifiSettingsMenu>>,
|
||||||
public StaticMenuDefinition<
|
public StaticMenuDefinition<
|
||||||
makeComponent<MenuItem, WifiSoftApGetStationNumText, StaticFont<2>, DisabledColor, DummyAction>,
|
makeComponent<MenuItem, StaticText<TEXT_WIFISOFTAP>, WifiSoftApAction>,
|
||||||
makeComponent<MenuItem, WifiSoftApIpText, StaticFont<2>, DisabledColor, DummyAction>,
|
makeComponent<MenuItem, StaticText<TEXT_WIFISOFTAPDISCONNECT>, WifiSoftApDisconnectAction>,
|
||||||
makeComponent<MenuItem, WifiSoftApBroadcastIpText, StaticFont<2>, DisabledColor, DummyAction>,
|
makeComponent<MenuItem, StaticText<TEXT_WIFISOFTAPDISCONNECTWIFIOFF>, WifiSoftApDisconnectWifioffAction>,
|
||||||
makeComponent<MenuItem, WifiSoftApNetworkIdText, StaticFont<2>, DisabledColor, DummyAction>,
|
makeComponent<MenuItem, WifiSoftApGetStationNumText, StaticFont<2>, DisabledColor, DummyAction>,
|
||||||
makeComponent<MenuItem, WifiSoftApSubnetCidrText, StaticFont<2>, DisabledColor, DummyAction>,
|
makeComponent<MenuItem, WifiSoftApIpText, StaticFont<2>, DisabledColor, DummyAction>,
|
||||||
makeComponent<MenuItem, StaticText<TEXT_WIFISOFTAPENABLEIPV6>, WifiSoftApEnableIpV6Action>,
|
makeComponent<MenuItem, WifiSoftApBroadcastIpText, StaticFont<2>, DisabledColor, DummyAction>,
|
||||||
makeComponent<MenuItem, WifiSoftApIpV6Text, StaticFont<2>, DisabledColor, DummyAction>,
|
makeComponent<MenuItem, WifiSoftApNetworkIdText, StaticFont<2>, DisabledColor, DummyAction>,
|
||||||
makeComponent<MenuItem, WifiSoftApHostnameText, StaticFont<2>, DisabledColor, DummyAction>,
|
makeComponent<MenuItem, WifiSoftApSubnetCidrText, StaticFont<2>, DisabledColor, DummyAction>,
|
||||||
makeComponent<MenuItem, WifiSoftApMacAddressText, StaticFont<2>, DisabledColor, DummyAction>,
|
makeComponent<MenuItem, StaticText<TEXT_WIFISOFTAPENABLEIPV6>, WifiSoftApEnableIpV6Action>,
|
||||||
makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<WifiSettingsMenu>, StaticMenuItemIcon<&icons::back>>
|
makeComponent<MenuItem, WifiSoftApIpV6Text, StaticFont<2>, DisabledColor, DummyAction>,
|
||||||
|
makeComponent<MenuItem, WifiSoftApHostnameText, StaticFont<2>, DisabledColor, DummyAction>,
|
||||||
|
makeComponent<MenuItem, WifiSoftApMacAddressText, StaticFont<2>, DisabledColor, DummyAction>,
|
||||||
|
makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<WifiSettingsMenu>, StaticMenuItemIcon<&icons::back>>
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include "ota.h"
|
#include "ota.h"
|
||||||
#include "presets.h"
|
#include "presets.h"
|
||||||
#include "statistics.h"
|
#include "statistics.h"
|
||||||
|
#include "actions/wifisoftapaction.h"
|
||||||
#include "actions/bluetoothbeginaction.h"
|
#include "actions/bluetoothbeginaction.h"
|
||||||
#include "actions/bluetoothbeginmasteraction.h"
|
#include "actions/bluetoothbeginmasteraction.h"
|
||||||
#include "actions/bluetoothconnectbmsaction.h"
|
#include "actions/bluetoothconnectbmsaction.h"
|
||||||
@@ -90,8 +91,7 @@ void setup()
|
|||||||
if (!WiFi.mode(WIFI_AP_STA))
|
if (!WiFi.mode(WIFI_AP_STA))
|
||||||
Serial.println("Could not set mode to WIFI_AP_STA");
|
Serial.println("Could not set mode to WIFI_AP_STA");
|
||||||
|
|
||||||
if (!WiFi.softAP(deviceName, "Passwort_123"))
|
WifiSoftApAction{}.triggered();
|
||||||
Serial.println("Could not softAP");
|
|
||||||
|
|
||||||
if (!WiFi.begin("realraum", "r3alraum"))
|
if (!WiFi.begin("realraum", "r3alraum"))
|
||||||
Serial.println("Could not begin WiFi");
|
Serial.println("Could not begin WiFi");
|
||||||
|
@@ -7,6 +7,9 @@ constexpr char TEXT_BACK[] = "Back";
|
|||||||
|
|
||||||
//AccessPointWifiSettingsMenu
|
//AccessPointWifiSettingsMenu
|
||||||
constexpr char TEXT_ACCESSPOINTWIFISETTINGS[] = "Access Point WiFi settings";
|
constexpr char TEXT_ACCESSPOINTWIFISETTINGS[] = "Access Point WiFi settings";
|
||||||
|
constexpr char TEXT_WIFISOFTAP[] = "softAP()";
|
||||||
|
constexpr char TEXT_WIFISOFTAPDISCONNECT[] = "softAPdisconnect()";
|
||||||
|
constexpr char TEXT_WIFISOFTAPDISCONNECTWIFIOFF[] = "softAPdisconnect() wifioff";
|
||||||
constexpr char TEXT_WIFISOFTAPENABLEIPV6[] = "softAPenableIpV6()";
|
constexpr char TEXT_WIFISOFTAPENABLEIPV6[] = "softAPenableIpV6()";
|
||||||
//constexpr char TEXT_BACK[] = "Back";
|
//constexpr char TEXT_BACK[] = "Back";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user