Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openmrn_arduino::Esp32WiFiManager Class Reference

This class provides a simple way for ESP32 nodes to manage the WiFi and mDNS systems of the ESP32, the node being a hub and connecting to an uplink node to participate in the CAN bus. More...

#include <Esp32WiFiManager.hxx>

Inheritance diagram for openmrn_arduino::Esp32WiFiManager:
DefaultConfigUpdateListener Service Singleton< Esp32WiFiManager > ConfigUpdateListener QMember

Classes

class  UplinkNotifiable
 This class provides a proxy for the Notifiable provided by the SocketClient. More...
 
class  WiFiStackFlow
 StateFlow that is responsible for startup and maintenance of the WiFi stack. More...
 

Public Member Functions

 Esp32WiFiManager (const char *station_ssid, const char *station_password, openlcb::SimpleStackBase *stack, const WiFiConfiguration &cfg, wifi_mode_t wifi_mode=WIFI_MODE_STA, uint8_t connection_mode=CONN_MODE_UPLINK_BIT, const char *hostname_prefix="esp32_", const char *sntp_server="pool.ntp.org", const char *timezone="UTC0", bool sntp_enabled=false, uint8_t softap_channel=1, wifi_auth_mode_t softap_auth_mode=WIFI_AUTH_OPEN, const char *softap_ssid="", const char *softap_password="")
 Constructor.
 
 ~Esp32WiFiManager ()
 Destructor.
 
void display_configuration ()
 Display the configuration settings in use.
 
void set_status_led (const Gpio *led=nullptr)
 Configures a Gpio to be used as a visual indication of the current WiFi status.
 
ConfigUpdateListener::UpdateAction apply_configuration (int fd, bool initial_load, BarrierNotifiable *done) override
 Updates the WiFiConfiguration settings used by this node.
 
void factory_reset (int fd) override
 Resets the WiFiConfiguration settings used by this node.
 
void enable_verbose_logging ()
 If called, sets the ESP32 wifi stack to log verbose information to the console.
 
void start_ssid_scan (Notifiable *n)
 Starts a scan for available SSIDs.
 
size_t get_ssid_scan_result_count ()
 
wifi_ap_record_t get_ssid_scan_result (size_t index)
 Returns one entry from the SSID scan.
 
void clear_ssid_scan_results ()
 Clears the SSID scan results.
 
void mdns_publish (std::string service, uint16_t port)
 Advertises a service via mDNS.
 
void mdns_unpublish (std::string service)
 Removes the advertisement of a service via mDNS.
 
void wait_for_ssid_connect (bool enable)
 Forces the Esp32WiFiManager to wait until SSID connection completes.
 
void set_tx_power (uint8_t power)
 Configures the WiFi maximum transmit power setting.
 
void register_network_up_callback (esp_network_up_callback_t callback)
 Registers a callback for when the WiFi connection is up.
 
void register_network_down_callback (esp_network_down_callback_t callback)
 Registers a callback for when the WiFi connection is down.
 
void register_network_init_callback (esp_network_init_callback_t callback)
 Registers a callback for when WiFi interfaces are being initialized.
 
void register_network_time_callback (esp_network_time_callback_t callback)
 Registers a callback for when SNTP updates are received.
 
void sync_time (time_t now)
 Time synchronization callback for SNTP.
 
Executor< 1 > * executor ()
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 
- Public Member Functions inherited from Service
 Service (ExecutorBase *e)
 Constructor.
 
 ~Service ()
 Destructor.
 
ExecutorBaseexecutor ()
 

Static Public Member Functions

static void process_idf_event (void *ctx, esp_event_base_t event_base, int32_t event_id, void *event_data)
 Processes an event coming from the ESP-IDF default event loop.
 
- Static Public Member Functions inherited from Singleton< Esp32WiFiManager >
static Esp32WiFiManager * instance ()
 
static bool exists ()
 

Private Member Functions

 Esp32WiFiManager ()
 Default constructor.
 
void stop_hub ()
 Shuts down the hub listener (if running) for this node.
 
void start_hub ()
 Creates a hub listener for this node after loading configuration details.
 
void stop_uplink ()
 Disconnects and shuts down the uplink connector socket (if running).
 
void start_uplink ()
 Creates an uplink connector socket that will automatically add the uplink to the node's hub.
 
void on_uplink_created (int fd, Notifiable *on_exit)
 Callback for the SocketClient to handle a newly connected outbound socket connection.
 
void enable_esp_wifi_logging ()
 Enables the esp_wifi logging, including the esp_wifi_internal APIs when available.
 
void start_mdns_system ()
 Initializes the mDNS system if it hasn't already been initialized.
 
void on_station_started ()
 Event handler called when the ESP32 Station interface has started.
 
void on_station_connected ()
 Event handler called when the ESP32 Station interface has connected to an SSID.
 
void on_station_disconnected (uint8_t reason)
 Event handler called when the ESP32 Station interface has lost it's connection to the SSID or failed to connect.
 
void on_station_ip_assigned (uint32_t ip_address)
 Event handler called when the ESP32 Station interface has received an IP address (DHCP or static).
 
void on_station_ip_lost ()
 Event handler called when the ESP32 Station interface has lost it's assigned IP address.
 
void on_softap_start ()
 Event handler called when the ESP32 SoftAP interface has started.
 
void on_softap_stop ()
 Event handler called when the ESP32 SoftAP interface has shutdown.
 
void on_softap_station_connected (uint8_t mac[6], uint8_t aid)
 Event handler called when a station connects to the ESP32 SoftAP.
 
void on_softap_station_disconnected (uint8_t mac[6], uint8_t aid)
 Event handler called when a station disconnects from the ESP32 SoftAP.
 
void on_wifi_scan_completed (uint32_t status, uint8_t count)
 Event handler called when a WiFi scan operation completes.
 
void configure_sntp ()
 Configures SNTP and TimeZone (if enabled).
 
void reconfigure_wifi_radio_sleep ()
 Reconfigures the WiFi radio sleep mode.
 
void reconfigure_wifi_tx_power ()
 Reconfigures the WiFi radio transmit power.
 
 DISALLOW_COPY_AND_ASSIGN (Esp32WiFiManager)
 

Static Private Member Functions

static void * wifi_manager_task (void *param)
 Background task used by the Esp32WiFiManager to maintain health of any connections to other nodes.
 

Private Attributes

std::string hostname_
 Dynamically generated hostname for this node, esp32_{node-id}.
 
std::string ssid_
 User provided SSID to connect to.
 
std::string password_
 User provided password for the SSID to connect to.
 
const WiFiConfiguration cfg_
 Persistent configuration that will be used for this node's WiFi usage.
 
openlcb::SimpleStackBasestack_
 OpenMRN stack for the Arduino system.
 
const GpiostatusLed_ {nullptr}
 WiFi connection status indicator Gpio instance.
 
const wifi_mode_t wifiMode_
 WiFi operating mode.
 
const uint8_t softAPChannel_
 Channel to use for the SoftAP interface.
 
wifi_auth_mode_t softAPAuthMode_
 Authentication mode to use for the SoftAP.
 
std::string softAPName_
 User provided name for the SoftAP when active, defaults to hostname_ when null.
 
std::string softAPPassword_
 User provided password for the SoftAP when active, defaults to password when null and softAPAuthMode_ is not WIFI_AUTH_OPEN.
 
const bool sntpEnabled_
 Enables SNTP polling.
 
std::string sntpServer_
 SNTP server address.
 
std::string timeZone_
 TimeZone of the node.
 
bool sntpConfigured_ {false}
 Tracks if SNTP has been configured.
 
int configFd_ {-1}
 Cached copy of the file descriptor passed into apply_configuration.
 
uint32_t configCrc32_ {0}
 Calculated CRC-32 of cfg_ data.
 
bool waitForStationConnect_ {true}
 If true, the esp32 will block startup until the SSID connection has successfully completed and upon failure (or timeout) the esp32 will be restarted.
 
bool verboseLogging_ {false}
 If true, request esp32 wifi to do verbose logging.
 
uint8_t connectionMode_ {CONN_MODE_UPLINK_BIT}
 Defines the WiFi connection mode to operate in.
 
uint8_t wifiTXPower_ {84}
 Maximum WiFi transmit power setting.
 
std::string hubServiceName_
 mDNS service name being advertised by the hub, if enabled.
 
std::unique_ptr< SocketClientuplink_
 SocketClient for this node's uplink connection.
 
int uplinkFd_ {-1}
 Socket handle used by the uplink connection.
 
NotifiableuplinkNotifiable_ {nullptr}
 Notifiable handle provided by the SocketClient once a connection has been established.
 
EventGroupHandle_t wifiStatusEventGroup_
 Internal event group used to track the IP assignment events.
 
std::vector< wifi_ap_record_t > ssidScanResults_
 WiFi SSID scan results holder.
 
OSMutex ssidScanResultsLock_
 Protects ssidScanResults_ vector.
 
NotifiablessidCompleteNotifiable_ {nullptr}
 Notifiable to be called when SSID scan completes.
 
OSMutex mdnsInitLock_
 Protects the mdnsInitialized_ flag and mdnsDeferredPublish_ map.
 
bool mdnsInitialized_ {false}
 Internal flag for tracking that the mDNS system has been initialized.
 
Executor< 1 > executor_ {NO_THREAD()}
 Executor to use for the uplink connections and callbacks.
 
std::map< std::string, uint16_t > mdnsDeferredPublish_
 Internal holder for mDNS entries which could not be published due to mDNS not being initialized yet.
 
OSMutex networkCallbacksLock_
 Protects the networkUpCallbacks_, networkDownCallbacks_, networkInitCallbacks_ and networkTimeCallbacks_ vectors.
 
std::vector< esp_network_up_callback_tnetworkUpCallbacks_
 Holder for callbacks to invoke when the WiFi connection is up.
 
std::vector< esp_network_down_callback_tnetworkDownCallbacks_
 Holder for callbacks to invoke when the WiFi connection is down.
 
std::vector< esp_network_init_callback_tnetworkInitCallbacks_
 Holder for callbacks to invoke when the WiFi subsystem has started.
 
std::vector< esp_network_time_callback_tnetworkTimeCallbacks_
 Holder for callbacks to invoke when network time synchronizes.
 
esp_netif_t * espNetIfaces_ [MAX_NETWORK_INTERFACES]
 Network interfaces that are managed by Esp32WiFiManager.
 
UplinkNotifiable uplinkNotifiableProxy_ {this}
 UplinkNotifiable to use for uplink connections.
 
WiFiStackFlow wifiStackFlow_ {this}
 Instance of WiFiStackFlow used for WiFi maintenance.
 

Static Private Attributes

static constexpr uint8_t MAX_HOSTNAME_LENGTH = 32
 Maximum length of the hostname for the ESP32.
 
static constexpr uint8_t CONN_MODE_UPLINK_BIT = BIT(0)
 Constant used to determine if the Uplink mode should be enabled.
 
static constexpr uint8_t CONN_MODE_HUB_BIT = BIT(1)
 Constant used to determine if the Hub mode should be enabled.
 

Additional Inherited Members

- Public Types inherited from ConfigUpdateListener
enum  UpdateAction { UPDATED = 0 , REINIT_NEEDED , REBOOT_NEEDED }
 Specifies what additional steps are needed to apply the new configuration. More...
 
- Protected Member Functions inherited from QMember
 QMember ()
 Constructor.
 
 ~QMember ()
 Destructor.
 
- Protected Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 

Detailed Description

This class provides a simple way for ESP32 nodes to manage the WiFi and mDNS systems of the ESP32, the node being a hub and connecting to an uplink node to participate in the CAN bus.

Definition at line 119 of file Esp32WiFiManager.hxx.

Constructor & Destructor Documentation

◆ Esp32WiFiManager()

openmrn_arduino::Esp32WiFiManager::Esp32WiFiManager ( const char *  station_ssid,
const char *  station_password,
openlcb::SimpleStackBase stack,
const WiFiConfiguration &  cfg,
wifi_mode_t  wifi_mode = WIFI_MODE_STA,
uint8_t  connection_mode = CONN_MODE_UPLINK_BIT,
const char *  hostname_prefix = "esp32_",
const char *  sntp_server = "pool.ntp.org",
const char *  timezone = "UTC0",
bool  sntp_enabled = false,
uint8_t  softap_channel = 1,
wifi_auth_mode_t  softap_auth_mode = WIFI_AUTH_OPEN,
const char *  softap_ssid = "",
const char *  softap_password = "" 
)

Constructor.

With this constructor the ESP32 WiFi and MDNS systems will be managed automatically by the Esp32WiFiManager class in addition to the inbound and outbound connections. The WiFi and MDNS systems will only be started after the initial loading of the CDI which occurs only after the application code calls OpenMRN::begin().

Parameters
station_ssidis the WiFi AP to connect to.
station_passwordis the password for the WiFi AP being connected to.
stackis the SimpleCanStackBase for this node. Must stay alive forever.
cfgis the WiFiConfiguration instance used for this node. This will be monitored for changes and the WiFi behavior altered accordingly.
wifi_modeis the WiFi operating mode, defaults to WIFI_MODE_STA. When set to WIFI_MODE_STA the Esp32WiFiManager will attempt to connect to the configured WiFi station_ssid. When wifi_mode is set to WIFI_MODE_AP the Esp32WiFiManager will create a SoftAP with the configured softap_ssid, softap_password, softap_channel, and softap_auth_mode. When set to WIFI_MODE_APSTA both the SoftAP and STATION interfaces will be enabled.
connection_modeis used as the default value for the CDI element of the same name which controls the uplink and hub operation.
sntp_serveris the SNTP server to poll for time updates, this defaults to pool.ntp.org.
timezoneis the POSIX formatted TimeZone of the node, this defaults to UTC0.
sntp_enabledEnables SNTP synchronization, defaults to false.
hostname_prefixis the hostname prefix to use for this node. The NodeID will be appended to this value. The maximum length for final hostname is 32 bytes.
softap_channelis the WiFi channel to use for the SoftAP.
softap_auth_modeis the authentication mode for the AP when wifi_mode is set to WIFI_MODE_AP or WIFI_MODE_APSTA.
softap_ssidis the name for the SoftAP, if null the node hostname will be used.
softap_passwordwill be used as the password for the SoftAP, if null and softap_auth_mode is not WIFI_AUTH_OPEN station_password will be used.

Member Function Documentation

◆ apply_configuration()

ConfigUpdateListener::UpdateAction openmrn_arduino::Esp32WiFiManager::apply_configuration ( int  fd,
bool  initial_load,
BarrierNotifiable done 
)
overridevirtual

Updates the WiFiConfiguration settings used by this node.

Parameters
fdis the file descriptor used for the configuration settings.
initial_loadis set to true when this node loads the configuration for the first time, otherwise it is an update to the configuration and may require a restart.
doneis the control used by the caller to track when all config consumers have completed their updates.
Returns
UPDATED when the configuration has been successfully updated, or REBOOT_NEEDED if the node needs to reboot for configuration to take effect.

Implements ConfigUpdateListener.

◆ enable_verbose_logging()

void openmrn_arduino::Esp32WiFiManager::enable_verbose_logging ( )
inline

If called, sets the ESP32 wifi stack to log verbose information to the console.

Definition at line 230 of file Esp32WiFiManager.hxx.

◆ executor()

Executor< 1 > * openmrn_arduino::Esp32WiFiManager::executor ( )
inline
Returns
the Executor used by the Esp32WiFiManager.

This can be used for other background tasks that should run periodically but not from the main OpenMRN stack Executor.

Definition at line 332 of file Esp32WiFiManager.hxx.

◆ factory_reset()

void openmrn_arduino::Esp32WiFiManager::factory_reset ( int  fd)
overridevirtual

Resets the WiFiConfiguration settings used by this node.

Parameters
fdis the file descriptor used for the configuration settings.

Implements ConfigUpdateListener.

◆ get_ssid_scan_result()

wifi_ap_record_t openmrn_arduino::Esp32WiFiManager::get_ssid_scan_result ( size_t  index)

Returns one entry from the SSID scan.

Parameters
indexis the index of the SSID to retrieve. If the index is invalid or no records exist a blank wifi_ap_record_t will be returned.

◆ get_ssid_scan_result_count()

size_t openmrn_arduino::Esp32WiFiManager::get_ssid_scan_result_count ( )
Returns
the number of SSIDs that were found via the scan.

◆ mdns_publish()

void openmrn_arduino::Esp32WiFiManager::mdns_publish ( std::string  service,
uint16_t  port 
)

Advertises a service via mDNS.

Parameters
serviceis the service name to publish.
portis the port for the service to be published.

Note: This will schedule a CallbackExecutable on the Executor used by the SimpleCanStackBase.

◆ mdns_unpublish()

void openmrn_arduino::Esp32WiFiManager::mdns_unpublish ( std::string  service)

Removes the advertisement of a service via mDNS.

Parameters
serviceis the service name to remove from advertising.

◆ on_softap_start()

void openmrn_arduino::Esp32WiFiManager::on_softap_start ( )
private

Event handler called when the ESP32 SoftAP interface has started.

This will handle the configuration of the SoftAP Static IP (if used).

◆ on_softap_station_connected()

void openmrn_arduino::Esp32WiFiManager::on_softap_station_connected ( uint8_t  mac[6],
uint8_t  aid 
)
private

Event handler called when a station connects to the ESP32 SoftAP.

Parameters
macStation MAC address.
aidStation access point identifier.

◆ on_softap_station_disconnected()

void openmrn_arduino::Esp32WiFiManager::on_softap_station_disconnected ( uint8_t  mac[6],
uint8_t  aid 
)
private

Event handler called when a station disconnects from the ESP32 SoftAP.

Parameters
macStation MAC address.
aidStation access point identifier.

◆ on_station_disconnected()

void openmrn_arduino::Esp32WiFiManager::on_station_disconnected ( uint8_t  reason)
private

Event handler called when the ESP32 Station interface has lost it's connection to the SSID or failed to connect.

Parameters
reasonThe reason for the disconnected event.

◆ on_station_started()

void openmrn_arduino::Esp32WiFiManager::on_station_started ( )
private

Event handler called when the ESP32 Station interface has started.

This will handle configuration of any static IP address, hostname, DNS and initiating the SSID connection process.

◆ on_uplink_created()

void openmrn_arduino::Esp32WiFiManager::on_uplink_created ( int  fd,
Notifiable on_exit 
)
private

Callback for the SocketClient to handle a newly connected outbound socket connection.

Parameters
fdis the connected socket descriptor.
on_exitis the Notifiable for when this socket has closed.

◆ on_wifi_scan_completed()

void openmrn_arduino::Esp32WiFiManager::on_wifi_scan_completed ( uint32_t  status,
uint8_t  count 
)
private

Event handler called when a WiFi scan operation completes.

Parameters
statusis the status of the WiFi scan request.
countis the number of access points found.

◆ process_idf_event()

static void openmrn_arduino::Esp32WiFiManager::process_idf_event ( void *  ctx,
esp_event_base_t  event_base,
int32_t  event_id,
void *  event_data 
)
static

Processes an event coming from the ESP-IDF default event loop.

Parameters
ctxcontext parameter (unused).
event_baseDetermines the category of event being sent.
event_idSpecific event from the event_base being sent.
event_dataData related to the event being sent, may be null.

NOTE: This is not intended to be called by the user.

◆ reconfigure_wifi_tx_power()

void openmrn_arduino::Esp32WiFiManager::reconfigure_wifi_tx_power ( )
private

Reconfigures the WiFi radio transmit power.

NOTE: This will only be called after the station connection has been established or after the SoftAP has been started. Before these events the transmit power will be configured to the maximum value.

◆ register_network_down_callback()

void openmrn_arduino::Esp32WiFiManager::register_network_down_callback ( esp_network_down_callback_t  callback)

Registers a callback for when the WiFi connection is down.

Parameters
callbackThe callback to invoke when the WiFi connection is down.

◆ register_network_init_callback()

void openmrn_arduino::Esp32WiFiManager::register_network_init_callback ( esp_network_init_callback_t  callback)

Registers a callback for when WiFi interfaces are being initialized.

Parameters
callbackThe callback to invoke when the WiFi interface is initializing.

NOTE: this will not be invoked for ESP_IF_WIFI_AP since there are no events raised between enabling the interface and when it is ready.

◆ register_network_time_callback()

void openmrn_arduino::Esp32WiFiManager::register_network_time_callback ( esp_network_time_callback_t  callback)

Registers a callback for when SNTP updates are received.

Parameters
callbackThe callback to invoke when SNTP updates are received.

◆ register_network_up_callback()

void openmrn_arduino::Esp32WiFiManager::register_network_up_callback ( esp_network_up_callback_t  callback)

Registers a callback for when the WiFi connection is up.

Parameters
callbackThe callback to invoke when the WiFi connection is up.

◆ set_status_led()

void openmrn_arduino::Esp32WiFiManager::set_status_led ( const Gpio led = nullptr)
inline

Configures a Gpio to be used as a visual indication of the current WiFi status.

Parameters
ledis the Gpio instance connected to the LED.

Definition at line 192 of file Esp32WiFiManager.hxx.

◆ set_tx_power()

void openmrn_arduino::Esp32WiFiManager::set_tx_power ( uint8_t  power)
inline

Configures the WiFi maximum transmit power setting.

Parameters
poweris the maximum transmit power in 0.25dBm units, range is 8-84 (2-20dBm).

NOTE: This should be called as early as possible, once the Station or SoftAP has been started this setting will not be used.

Definition at line 289 of file Esp32WiFiManager.hxx.

◆ start_hub()

void openmrn_arduino::Esp32WiFiManager::start_hub ( )
private

Creates a hub listener for this node after loading configuration details.

Note: This method will block until the hub is active.

◆ start_ssid_scan()

void openmrn_arduino::Esp32WiFiManager::start_ssid_scan ( Notifiable n)

Starts a scan for available SSIDs.

Parameters
nis the Notifiable to notify when the SSID scan completes.

◆ sync_time()

void openmrn_arduino::Esp32WiFiManager::sync_time ( time_t  now)

Time synchronization callback for SNTP.

Parameters
nowis the current time.

NOTE: This is not intended to be called by the user.

◆ wait_for_ssid_connect()

void openmrn_arduino::Esp32WiFiManager::wait_for_ssid_connect ( bool  enable)
inline

Forces the Esp32WiFiManager to wait until SSID connection completes.

Parameters
enablewhen true will force the Esp32WiFiManager to wait for successful SSID connection (including IP assignemnt), when false and the Esp32WiFiManager will not check the SSID connection process.

The default behavior is to wait for SSID connection to complete when the WiFi mode is WIFI_MODE_STA or WIFI_MODE_APSTA. When operating in WIFI_MODE_APSTA mode the application may opt to present a configuration portal to allow reconfiguration of the SSID.

Definition at line 277 of file Esp32WiFiManager.hxx.

◆ wifi_manager_task()

static void * openmrn_arduino::Esp32WiFiManager::wifi_manager_task ( void *  param)
staticprivate

Background task used by the Esp32WiFiManager to maintain health of any connections to other nodes.

Parameters
paramis a pointer to the Esp32WiFiManager instance.

Member Data Documentation

◆ cfg_

const WiFiConfiguration openmrn_arduino::Esp32WiFiManager::cfg_
private

Persistent configuration that will be used for this node's WiFi usage.

Definition at line 450 of file Esp32WiFiManager.hxx.

◆ configCrc32_

uint32_t openmrn_arduino::Esp32WiFiManager::configCrc32_ {0}
private

Calculated CRC-32 of cfg_ data.

Used to detect changes in configuration which may require the wifi_manager_task to reload config.

Definition at line 499 of file Esp32WiFiManager.hxx.

◆ configFd_

int openmrn_arduino::Esp32WiFiManager::configFd_ {-1}
private

Cached copy of the file descriptor passed into apply_configuration.

This is internally used by the wifi_manager_task to processed deferred configuration load.

Definition at line 495 of file Esp32WiFiManager.hxx.

◆ CONN_MODE_HUB_BIT

constexpr uint8_t openmrn_arduino::Esp32WiFiManager::CONN_MODE_HUB_BIT = BIT(1)
staticconstexprprivate

Constant used to determine if the Hub mode should be enabled.

Definition at line 579 of file Esp32WiFiManager.hxx.

◆ CONN_MODE_UPLINK_BIT

constexpr uint8_t openmrn_arduino::Esp32WiFiManager::CONN_MODE_UPLINK_BIT = BIT(0)
staticconstexprprivate

Constant used to determine if the Uplink mode should be enabled.

Definition at line 576 of file Esp32WiFiManager.hxx.

◆ connectionMode_

uint8_t openmrn_arduino::Esp32WiFiManager::connectionMode_ {CONN_MODE_UPLINK_BIT}
private

Defines the WiFi connection mode to operate in.

Definition at line 510 of file Esp32WiFiManager.hxx.

◆ espNetIfaces_

esp_netif_t* openmrn_arduino::Esp32WiFiManager::espNetIfaces_[MAX_NETWORK_INTERFACES]
private
Initial value:
{
nullptr, nullptr
}

Network interfaces that are managed by Esp32WiFiManager.

Definition at line 582 of file Esp32WiFiManager.hxx.

◆ executor_

Executor<1> openmrn_arduino::Esp32WiFiManager::executor_ {NO_THREAD()}
private

Executor to use for the uplink connections and callbacks.

Definition at line 550 of file Esp32WiFiManager.hxx.

◆ hostname_

std::string openmrn_arduino::Esp32WiFiManager::hostname_
private

Dynamically generated hostname for this node, esp32_{node-id}.

This is also used for the SoftAP SSID name (if enabled).

Definition at line 441 of file Esp32WiFiManager.hxx.

◆ hubServiceName_

std::string openmrn_arduino::Esp32WiFiManager::hubServiceName_
private

mDNS service name being advertised by the hub, if enabled.

Definition at line 516 of file Esp32WiFiManager.hxx.

◆ MAX_HOSTNAME_LENGTH

constexpr uint8_t openmrn_arduino::Esp32WiFiManager::MAX_HOSTNAME_LENGTH = 32
staticconstexprprivate

Maximum length of the hostname for the ESP32.

Definition at line 573 of file Esp32WiFiManager.hxx.

◆ mdnsDeferredPublish_

std::map<std::string, uint16_t> openmrn_arduino::Esp32WiFiManager::mdnsDeferredPublish_
private

Internal holder for mDNS entries which could not be published due to mDNS not being initialized yet.

Definition at line 554 of file Esp32WiFiManager.hxx.

◆ mdnsInitialized_

bool openmrn_arduino::Esp32WiFiManager::mdnsInitialized_ {false}
private

Internal flag for tracking that the mDNS system has been initialized.

Definition at line 547 of file Esp32WiFiManager.hxx.

◆ mdnsInitLock_

OSMutex openmrn_arduino::Esp32WiFiManager::mdnsInitLock_
private

Protects the mdnsInitialized_ flag and mdnsDeferredPublish_ map.

Definition at line 544 of file Esp32WiFiManager.hxx.

◆ networkCallbacksLock_

OSMutex openmrn_arduino::Esp32WiFiManager::networkCallbacksLock_
private

Protects the networkUpCallbacks_, networkDownCallbacks_, networkInitCallbacks_ and networkTimeCallbacks_ vectors.

Definition at line 558 of file Esp32WiFiManager.hxx.

◆ networkDownCallbacks_

std::vector<esp_network_down_callback_t> openmrn_arduino::Esp32WiFiManager::networkDownCallbacks_
private

Holder for callbacks to invoke when the WiFi connection is down.

Definition at line 564 of file Esp32WiFiManager.hxx.

◆ networkInitCallbacks_

std::vector<esp_network_init_callback_t> openmrn_arduino::Esp32WiFiManager::networkInitCallbacks_
private

Holder for callbacks to invoke when the WiFi subsystem has started.

Definition at line 567 of file Esp32WiFiManager.hxx.

◆ networkTimeCallbacks_

std::vector<esp_network_time_callback_t> openmrn_arduino::Esp32WiFiManager::networkTimeCallbacks_
private

Holder for callbacks to invoke when network time synchronizes.

Definition at line 570 of file Esp32WiFiManager.hxx.

◆ networkUpCallbacks_

std::vector<esp_network_up_callback_t> openmrn_arduino::Esp32WiFiManager::networkUpCallbacks_
private

Holder for callbacks to invoke when the WiFi connection is up.

Definition at line 561 of file Esp32WiFiManager.hxx.

◆ password_

std::string openmrn_arduino::Esp32WiFiManager::password_
private

User provided password for the SSID to connect to.

Definition at line 447 of file Esp32WiFiManager.hxx.

◆ sntpConfigured_

bool openmrn_arduino::Esp32WiFiManager::sntpConfigured_ {false}
private

Tracks if SNTP has been configured.

Definition at line 490 of file Esp32WiFiManager.hxx.

◆ sntpEnabled_

const bool openmrn_arduino::Esp32WiFiManager::sntpEnabled_
private

Enables SNTP polling.

Definition at line 481 of file Esp32WiFiManager.hxx.

◆ sntpServer_

std::string openmrn_arduino::Esp32WiFiManager::sntpServer_
private

SNTP server address.

Definition at line 484 of file Esp32WiFiManager.hxx.

◆ softAPAuthMode_

wifi_auth_mode_t openmrn_arduino::Esp32WiFiManager::softAPAuthMode_
private

Authentication mode to use for the SoftAP.

If not set to WIFI_AUTH_OPEN softAPPassword_ will be used.

Definition at line 466 of file Esp32WiFiManager.hxx.

◆ softAPChannel_

const uint8_t openmrn_arduino::Esp32WiFiManager::softAPChannel_
private

Channel to use for the SoftAP interface.

Definition at line 462 of file Esp32WiFiManager.hxx.

◆ softAPName_

std::string openmrn_arduino::Esp32WiFiManager::softAPName_
private

User provided name for the SoftAP when active, defaults to hostname_ when null.

NOTE: Only used when wifiMode_ is set to WIFI_MODE_AP or WIFI_MODE_APSTA.

Definition at line 472 of file Esp32WiFiManager.hxx.

◆ softAPPassword_

std::string openmrn_arduino::Esp32WiFiManager::softAPPassword_
private

User provided password for the SoftAP when active, defaults to password when null and softAPAuthMode_ is not WIFI_AUTH_OPEN.

NOTE: Only used when wifiMode_ is set to WIFI_MODE_AP or WIFI_MODE_APSTA.

Definition at line 478 of file Esp32WiFiManager.hxx.

◆ ssid_

std::string openmrn_arduino::Esp32WiFiManager::ssid_
private

User provided SSID to connect to.

Definition at line 444 of file Esp32WiFiManager.hxx.

◆ ssidCompleteNotifiable_

Notifiable* openmrn_arduino::Esp32WiFiManager::ssidCompleteNotifiable_ {nullptr}
private

Notifiable to be called when SSID scan completes.

Definition at line 541 of file Esp32WiFiManager.hxx.

◆ ssidScanResults_

std::vector<wifi_ap_record_t> openmrn_arduino::Esp32WiFiManager::ssidScanResults_
private

WiFi SSID scan results holder.

Definition at line 535 of file Esp32WiFiManager.hxx.

◆ ssidScanResultsLock_

OSMutex openmrn_arduino::Esp32WiFiManager::ssidScanResultsLock_
private

Protects ssidScanResults_ vector.

Definition at line 538 of file Esp32WiFiManager.hxx.

◆ stack_

openlcb::SimpleStackBase* openmrn_arduino::Esp32WiFiManager::stack_
private

OpenMRN stack for the Arduino system.

Definition at line 453 of file Esp32WiFiManager.hxx.

◆ statusLed_

const Gpio* openmrn_arduino::Esp32WiFiManager::statusLed_ {nullptr}
private

WiFi connection status indicator Gpio instance.

Definition at line 456 of file Esp32WiFiManager.hxx.

◆ timeZone_

std::string openmrn_arduino::Esp32WiFiManager::timeZone_
private

TimeZone of the node.

Definition at line 487 of file Esp32WiFiManager.hxx.

◆ uplink_

std::unique_ptr<SocketClient> openmrn_arduino::Esp32WiFiManager::uplink_
private

SocketClient for this node's uplink connection.

Definition at line 519 of file Esp32WiFiManager.hxx.

◆ uplinkFd_

int openmrn_arduino::Esp32WiFiManager::uplinkFd_ {-1}
private

Socket handle used by the uplink connection.

Definition at line 522 of file Esp32WiFiManager.hxx.

◆ uplinkNotifiable_

Notifiable* openmrn_arduino::Esp32WiFiManager::uplinkNotifiable_ {nullptr}
private

Notifiable handle provided by the SocketClient once a connection has been established.

This will be called by UplinkNotifiable when not null and the connection needs to be re-established. This will be set to null when the uplink is intentionally disconnected by configuration updates.

Definition at line 529 of file Esp32WiFiManager.hxx.

◆ uplinkNotifiableProxy_

UplinkNotifiable openmrn_arduino::Esp32WiFiManager::uplinkNotifiableProxy_ {this}
private

UplinkNotifiable to use for uplink connections.

Definition at line 618 of file Esp32WiFiManager.hxx.

◆ verboseLogging_

bool openmrn_arduino::Esp32WiFiManager::verboseLogging_ {false}
private

If true, request esp32 wifi to do verbose logging.

Definition at line 507 of file Esp32WiFiManager.hxx.

◆ waitForStationConnect_

bool openmrn_arduino::Esp32WiFiManager::waitForStationConnect_ {true}
private

If true, the esp32 will block startup until the SSID connection has successfully completed and upon failure (or timeout) the esp32 will be restarted.

Definition at line 504 of file Esp32WiFiManager.hxx.

◆ wifiMode_

const wifi_mode_t openmrn_arduino::Esp32WiFiManager::wifiMode_
private

WiFi operating mode.

Definition at line 459 of file Esp32WiFiManager.hxx.

◆ wifiStackFlow_

WiFiStackFlow openmrn_arduino::Esp32WiFiManager::wifiStackFlow_ {this}
private

Instance of WiFiStackFlow used for WiFi maintenance.

Definition at line 682 of file Esp32WiFiManager.hxx.

◆ wifiStatusEventGroup_

EventGroupHandle_t openmrn_arduino::Esp32WiFiManager::wifiStatusEventGroup_
private

Internal event group used to track the IP assignment events.

Definition at line 532 of file Esp32WiFiManager.hxx.

◆ wifiTXPower_

uint8_t openmrn_arduino::Esp32WiFiManager::wifiTXPower_ {84}
private

Maximum WiFi transmit power setting.

Definition at line 513 of file Esp32WiFiManager.hxx.


The documentation for this class was generated from the following file: