Ersa Wearable Platform
Embedded smartwatch firmware and application framework
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ersa::services::NetworkManager Class Reference

#include <network_manager.h>

Collaboration diagram for ersa::services::NetworkManager:
Collaboration graph
[legend]

Public Member Functions

 NetworkManager (events::EventBus &bus=events::EventBus::instance(), hal::IWifiRadio *wifi=nullptr)
 
Result< void > init ()
 
void tick (uint32_t currentUptimeMs)
 
NetworkHandle requestInternet ()
 
void acquire ()
 
void release ()
 
bool isConnected () const
 Return whether station networking is connected.
 
bool isConnecting () const
 Return whether a station connection is being established.
 
size_t getActiveHandleCount () const
 Return the number of active network leases.
 

Static Public Member Functions

static NetworkManager & instance ()
 Return the installed process-wide network manager.
 
static void setInstance (NetworkManager *instance)
 Install the process-wide network manager.
 

Private Attributes

events::EventBus & bus_
 
hal::IWifiRadio * wifi_
 
size_t activeHandles_ {0}
 
bool connected_ {false}
 
bool connecting_ {false}
 
uint32_t lastActivityMs_ {0}
 

Detailed Description

Coordinates Wi-Fi availability with independent service clients.

Each NetworkHandle is a scoped radio-use lease. The manager keeps the radio active while at least one lease exists and powers it down after the final lease and idle policy permit. This makes resource lifetime explicit and avoids one app disconnecting Wi-Fi while another service still needs it.

Constructor & Destructor Documentation

◆ NetworkManager()

ersa::services::NetworkManager::NetworkManager ( events::EventBus &  bus = events::EventBus::instance(),
hal::IWifiRadio *  wifi = nullptr 
)
explicit

Bind a radio and event bus; null radio provides a no-hardware host mode.

Member Function Documentation

◆ acquire()

void ersa::services::NetworkManager::acquire ( )

Increment an unscoped reference count for legacy/manual lifetime code.

◆ getActiveHandleCount()

size_t ersa::services::NetworkManager::getActiveHandleCount ( ) const

Return the number of active network leases.

◆ init()

Result< void > ersa::services::NetworkManager::init ( )

Subscribe to link transitions and initialize radio state if available.

◆ instance()

NetworkManager & ersa::services::NetworkManager::instance ( )
static

Return the installed process-wide network manager.

◆ isConnected()

bool ersa::services::NetworkManager::isConnected ( ) const

Return whether station networking is connected.

◆ isConnecting()

bool ersa::services::NetworkManager::isConnecting ( ) const

Return whether a station connection is being established.

◆ release()

void ersa::services::NetworkManager::release ( )

Decrement a prior raw acquisition; unmatched releases are ignored.

◆ requestInternet()

NetworkHandle ersa::services::NetworkManager::requestInternet ( )

Acquire an RAII lease; connectivity remains active until release.

◆ setInstance()

void ersa::services::NetworkManager::setInstance ( NetworkManager *  instance)
static

Install the process-wide network manager.

◆ tick()

void ersa::services::NetworkManager::tick ( uint32_t  currentUptimeMs)

Apply deferred link events and idle power-off using monotonic uptime.

Member Data Documentation

◆ activeHandles_

size_t ersa::services::NetworkManager::activeHandles_ {0}
private

◆ bus_

events::EventBus& ersa::services::NetworkManager::bus_
private

◆ connected_

bool ersa::services::NetworkManager::connected_ {false}
private

◆ connecting_

bool ersa::services::NetworkManager::connecting_ {false}
private

◆ lastActivityMs_

uint32_t ersa::services::NetworkManager::lastActivityMs_ {0}
private

◆ wifi_

hal::IWifiRadio* ersa::services::NetworkManager::wifi_
private

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