libpowermon 1.00
PowerMon Access Library
Loading...
Searching...
No Matches
Powermon Class Referenceabstract

Powermon is a class representing one PowerMon device (BLE or WiFi) and offers a set of functions for accessing all features of PowerMon battery monitors. More...

#include <powermon.h>

Classes

struct  AuthKey
 AuthKey is a structure representing an authentication key used to unlock a locked PowerMon device. More...
 
struct  DeviceIdentifier
 DeviceIdentifier is a structure containing all information used to identify a PowerMon device (either BLE or WiFi) More...
 
struct  DeviceInfo
 DeviceInfo is the information structure returned by PowerMon as response to the GetInfo request. More...
 
struct  FuelgaugeStatistics
 FuelgaugeStatistics is a structure containing battery statistics. More...
 
struct  LogFileDescriptor
 LogFileDescriptor represents a PowerMon log file. More...
 
struct  MonitorData
 MonitorData is a structure containing the real-time PowerMon data. More...
 
struct  MonitorStatistics
 MonitorStatistics is a structure containing power meter statistics. More...
 
struct  WifiAccessKey
 WifiAccessKey is a structure representing the access keys used to connect to a WiFi PowerMon remotely (via the cloud) More...
 
struct  WifiNetwork
 WifiNetwork represents all information required by PowerMon to connect to an access point. More...
 
struct  WifiScanResult
 WifiScanResult represents a WiFi network detected by PowerMon during WiFi scanning. More...
 

Public Types

enum  HardwareRevision : uint8_t {
  FAMILY_MASK = 0xF0 ,
  POWERMON = 0x20 ,
  POWERMON_5S = 0x30 ,
  POWERMON_W = 0x40
}
 HardwareRevision definitions (2 digit BCD format) More...
 
enum  State : uint8_t {
  Disconnected = 0 ,
  Connecting ,
  Connected
}
 State represents the PowerMon connection state. More...
 
enum  DisconnectReason : uint8_t {
  CLOSED = 0 ,
  NO_ROUTE ,
  FAILED ,
  UNEXPECTED_ERROR ,
  UNEXPECTED_RESPONSE ,
  WRITE_ERROR ,
  READ_ERROR
}
 DisconnectReason is an enumeration of all reasons a connection can be terminated.
 
enum  ResponseCode : uint16_t {
  RSP_SUCCESS = 0x0000 ,
  RSP_SUCCESS_MORE = 0x0100 ,
  RSP_INVALID_REQ = 0x0001 ,
  RSP_INVALID_PARAM = 0x0002 ,
  RSP_ERROR = 0x0003 ,
  RSP_LOCKED_USER = 0x0004 ,
  RSP_LOCKED_MASTER = 0x0005 ,
  RSP_CANNOT_UNLOCK = 0x0006 ,
  RSP_NOT_FOUND = 0x0007 ,
  RSP_TIMEOUT = 0x0008 ,
  RSP_INVALID = 0x0009 ,
  RSP_CANCELLED = 0x000A
}
 ResponseCodes is an enumeration of all possible response codes for requests to a PowerMon device.
 
enum  PowerStatus : uint8_t {
  PS_OFF = 0 ,
  PS_ON = 1 ,
  PS_LVD = 2 ,
  PS_OCD = 3 ,
  PS_HVD = 4 ,
  PS_FGD = 5 ,
  PS_NCH = 6 ,
  PS_LTD = 7 ,
  PS_HTD = 8
}
 PowerStatus is an enumeration of all possible power states. More...
 

Public Member Functions

virtual void connectWifi (const WifiAccessKey &key)=0
 Connects to a remote WiFi PowerMon.
 
virtual void connectWifi (uint32_t ipaddr)=0
 Connects to a local WiFi PowerMon.
 
virtual void connectBle (uint64_t ble_address)=0
 Connects to a local BLE PowerMon.
 
virtual void disconnect (void)=0
 Disconnects from a connected device.
 
virtual bool isLocalConnection (void) const =0
 Returns true if the current connection is local: BLE or WiFi.
 
virtual void setOnConnectCallback (const std::function< void(void)> &cb)=0
 Sets the callback to be called by the driver when a connection to the PowerMon device is fully established.
 
virtual void setOnDisconnectCallback (const std::function< void(DisconnectReason)> &cb)=0
 Sets the callback to be called by the driver when a connection to the PowerMon device is disconnected.
 
virtual void setOnMonitorDataCallback (const std::function< void(const MonitorData &)> &cb)=0
 Sets the callback to be called by the driver when new monitor data is received. This applies to the BLE devices only. For the WiFi devices, use the request to retrieve the monitor data.
 
virtual void setOnWifiScanReportCallback (const std::function< void(const WifiScanResult *)> &cb)=0
 Sets the callback to be called by the driver when a new WiFi scan result is received from the PowerMon. This applies to the WiFi devices only. WiFi scanning can be initiated using requestStartWifiScan().
 
virtual const DeviceInfogetLastDeviceInfo (void) const =0
 Returns the last DeviceInfo retrieved from the PowerMon.
 
virtual void requestGetInfo (const std::function< void(ResponseCode, const DeviceInfo &)> &cb)=0
 Requests the device information.
 
virtual void requestGetMonitorData (const std::function< void(ResponseCode, const MonitorData &)> &cb)=0
 Requests the device monitor data. It only applies to the WiFi devices.
 
virtual void requestGetStatistics (const std::function< void(ResponseCode, const MonitorStatistics &)> &cb)=0
 Requests the device power monitor statistics data.
 
virtual void requestGetFgStatistics (const std::function< void(ResponseCode, const FuelgaugeStatistics &)> &cb)=0
 Requests the device battery statistics data.
 
virtual void requestUnlock (const AuthKey &key, std::function< void(ResponseCode)> cb)=0
 Requests unlocking a password protected device.
 
virtual void requestSetUserPasswordLock (const AuthKey &key, std::function< void(ResponseCode)> cb)=0
 Requests setting a user password lock.
 
virtual void requestSetMasterPasswordLock (const AuthKey &key, std::function< void(ResponseCode)> cb)=0
 Requests setting a master password lock on.
 
virtual void requestClearUserPasswordLock (std::function< void(ResponseCode)> cb)=0
 Requests clearing of the user password lock.
 
virtual void requestClearMasterPasswordLock (std::function< void(ResponseCode)> cb)=0
 Requests clearing of the master password lock.
 
virtual void requestGetAuthKey (std::function< void(ResponseCode, const AuthKey &)> cb)=0
 Requests the authentication key from the device. This key can be used to unlock a locked device. It acts the same way as the user password lock.
 
virtual void requestResetAuthKey (std::function< void(ResponseCode)> cb)=0
 Requests the reset of the device authentication key.
 
virtual void requestResetEnergyMeter (const std::function< void(ResponseCode)> &cb)=0
 Requests the reset of the energy meter.
 
virtual void requestResetCoulombMeter (const std::function< void(ResponseCode)> &cb)=0
 Requests the reset of the coulomb meter.
 
virtual void requestResetStatistics (const std::function< void(ResponseCode)> &cb)=0
 Requests the reset of the power meter statistics.
 
virtual void requestSetPowerState (bool state, const std::function< void(ResponseCode)> &cb)=0
 Requests changing the power state.
 
virtual void requestGetConfig (const std::function< void(ResponseCode, const PowermonConfig &)> &cb)=0
 Retrieves the device configuration structure.
 
virtual void requestSetConfig (const PowermonConfig &config, const std::function< void(ResponseCode)> &cb)=0
 Sends new configuration to the device.
 
virtual void requestResetConfig (const std::function< void(ResponseCode)> &cb)=0
 Resets the PowerMon configuration to factory settings This will also clear the data log, reset the name, authentication keys and access keys (for WiFi devices).
 
virtual void requestRename (const char *name, const std::function< void(ResponseCode)> &cb)=0
 Requests renaming the PowerMon device.
 
virtual void requestSetTime (uint32_t time, const std::function< void(ResponseCode)> &cb)=0
 Requests setting the internal clock of the PowerMon device.
 
virtual void requestFgSynchronize (const std::function< void(ResponseCode)> &cb)=0
 Requests forcing the SoC to 100% (SoC synchronize)
 
virtual void requestStartWifiScan (const std::function< void(ResponseCode)> &cb)=0
 Requests starting the WiFi scan (only applies to the WiFi PowerMons). WiFi scanning will stop automatically after a max of 5 seconds.
 
virtual void requestWifiConfigure (const WifiNetwork &network, const std::function< void(ResponseCode)> &cb)=0
 Sends new WiFi network credentials to the PowerMon device. The new credentials will be saved by the device whether PowerMon can or cannot connect to that specified network.
 
virtual void requestGetAccessKeys (const std::function< void(ResponseCode, const WifiAccessKey &)> &cb)=0
 Requests the WiFi access keys (only applies to the WiFi PowerMons). The access keys are used to remotely access the device.
 
virtual void requestResetAccessKeys (const std::function< void(ResponseCode)> &cb)=0
 Requests resetting of the WiFi access keys (only applies to the WiFi PowerMons). This effectively severs the connection to all the paired clients.
 
virtual void requestZeroCurrentOffset (const std::function< void(ResponseCode)> &cb)=0
 Requests zeroing of the current reading offset.
 
virtual void requestCalibrateCurrent (float value, const std::function< void(ResponseCode)> &cb)=0
 Requests calibration of the current reading.
 
virtual void requestGetSchedules (const std::function< void(ResponseCode, const std::vector< PowermonSchedule > &)> &cb)=0
 Requests the list of all schedules stored in the device.
 
virtual void requestAddSchedules (const std::vector< PowermonSchedule > &schedules, const std::function< void(ResponseCode)> &cb)=0
 Requests adding new schedules.
 
virtual void requestUpdateSchedule (uint64_t old_schedule_descriptor, const PowermonSchedule &new_schedule, const std::function< void(ResponseCode)> &cb)=0
 Requests updating an existing schedule.
 
virtual void requestDeleteSchedule (uint64_t schedule_descriptor, const std::function< void(ResponseCode)> &cb)=0
 Requests deleting an existing schedule.
 
virtual void requestClearSchedules (const std::function< void(ResponseCode)> &cb)=0
 Requests clearing of all schedule.
 
virtual void requestCommitSchedules (const std::function< void(ResponseCode)> &cb)=0
 Requests committing the schedules to non-volatile memory.
 
virtual void requestGetFileList (const std::function< void(ResponseCode, const std::vector< LogFileDescriptor > &)> &cb)=0
 Requests the list of log files.
 
virtual void requestReadFile (uint32_t file_id, uint32_t offset, uint32_t read_size, const std::function< void(ResponseCode, const uint8_t *, size_t)> &cb)=0
 Requests reading of a log file.
 
virtual void requestUpdateFirmware (const uint8_t *firmware_image, uint32_t size, const std::function< bool(uint32_t, uint32_t)> &progress_cb, const std::function< void(ResponseCode)> &done_cb)=0
 Requests firmware update.
 

Static Public Member Functions

static PowermoncreateInstance (void)
 Creates an instance of the Powermon class.
 
static std::string getIpAddressString (uint32_t ip)
 Returns the IP address as string.
 
static std::string getMacAddressString (uint64_t mac)
 Returns the Bluetooth MAC address as string.
 
static uint64_t parseMacAddress (const char *address)
 Parses a MAC address string.
 
static std::string getHardwareString (uint8_t bcd)
 Returns the hardware name based on the hardware revision in BCD format.
 
static std::string getPowerStatusString (PowerStatus ps)
 Returns the power status string representation.
 
static bool hasVoltage2 (uint8_t bcd)
 Returns true if the PowerMon described by the BCD hardware revision has V2.
 
static bool hasConfigurableShunt (uint8_t bcd)
 Returns true if the PowerMon described by the BCD hardware revision supports configurable shunts.
 
static bool hasWifi (uint8_t bcd)
 Returns true if the PowerMon described by the BCD hardware revision has WiFi.
 
static bool checkBCD (uint16_t bcd)
 Returns true if the parameter is a valid BCD number.
 
static AuthKey getAuthKeyFromPassword (const char *password)
 Generates the SHA256 hash of a password.
 
static std::string getUpdateFirmwareImageUrl (uint8_t hardware_revision_bcd, uint16_t firmware_revision_bcd)
 Returns the update firmware image URL based on the hardware revision and firmware version.
 
static uint16_t checkFirmwareImage (const uint8_t *image, size_t size, uint8_t hardware_revision_bcd)
 Checks the validity of the firmware update image.
 

Detailed Description

Powermon is a class representing one PowerMon device (BLE or WiFi) and offers a set of functions for accessing all features of PowerMon battery monitors.

Member Enumeration Documentation

◆ HardwareRevision

HardwareRevision definitions (2 digit BCD format)

Enumerator
FAMILY_MASK 

Mask for the family part of the revision number.

POWERMON 

Original PowerMon (BLE)

POWERMON_5S 

PowerMon-5S (BLE)

POWERMON_W 

PowerMon-W (WiFi)

◆ PowerStatus

enum Powermon::PowerStatus : uint8_t

PowerStatus is an enumeration of all possible power states.

Enumerator
PS_OFF 

Power status is Off.

PS_ON 

Power status is On.

PS_LVD 

Power status is Low Voltage Disconnect.

PS_OCD 

Power status is Over-Current Disconnect.

PS_HVD 

Power status is High Voltage Disconnect.

PS_FGD 

Power status is Fuel Gauge Disconnect.

PS_NCH 

Power status is Not CHarging (for LiFePO4 charge manager only)

PS_LTD 

Power status is Low Temperature Disconnect.

PS_HTD 

Power status is High Temperature Disconnect.

◆ State

enum Powermon::State : uint8_t

State represents the PowerMon connection state.

Enumerator
Disconnected 

Device is not connected.

Connecting 

Device is in the process of connecting.

Connected 

Device is connected.

Member Function Documentation

◆ connectBle()

virtual void Powermon::connectBle ( uint64_t  ble_address)
pure virtual

Connects to a local BLE PowerMon.

Parameters
ble_addressThe Bluetooth address of the PowerMon device

◆ connectWifi() [1/2]

virtual void Powermon::connectWifi ( const WifiAccessKey key)
pure virtual

Connects to a remote WiFi PowerMon.

Parameters
keyThe access key used to connect

◆ connectWifi() [2/2]

virtual void Powermon::connectWifi ( uint32_t  ipaddr)
pure virtual

Connects to a local WiFi PowerMon.

Parameters
ipaddrThe IPv4 address of the local WiFi PowerMon device

◆ createInstance()

static Powermon * Powermon::createInstance ( void  )
static

Creates an instance of the Powermon class.

Returns
Pointer to the newly created Powermon object. Must be freed using delete().

◆ getAuthKeyFromPassword()

static AuthKey Powermon::getAuthKeyFromPassword ( const char *  password)
static

Generates the SHA256 hash of a password.

Parameters
passwordC string containing the password
Returns
Authentication key that can be used for the lock / unlock functions

◆ getLastDeviceInfo()

virtual const DeviceInfo & Powermon::getLastDeviceInfo ( void  ) const
pure virtual

Returns the last DeviceInfo retrieved from the PowerMon.

Returns
Reference to internal DeviceInfo structure. This is not valid before the first requestGetInfo() that returns success.

◆ requestAddSchedules()

virtual void Powermon::requestAddSchedules ( const std::vector< PowermonSchedule > &  schedules,
const std::function< void(ResponseCode)> &  cb 
)
pure virtual

Requests adding new schedules.

Parameters
schedulesA list of schedules to add
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestCalibrateCurrent()

virtual void Powermon::requestCalibrateCurrent ( float  value,
const std::function< void(ResponseCode)> &  cb 
)
pure virtual

Requests calibration of the current reading.

Parameters
valueThe actual current flowing through the shunt. An accurate multimeter is required to measure the current.
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestClearMasterPasswordLock()

virtual void Powermon::requestClearMasterPasswordLock ( std::function< void(ResponseCode)>  cb)
pure virtual

Requests clearing of the master password lock.

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestClearSchedules()

virtual void Powermon::requestClearSchedules ( const std::function< void(ResponseCode)> &  cb)
pure virtual

Requests clearing of all schedule.

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestClearUserPasswordLock()

virtual void Powermon::requestClearUserPasswordLock ( std::function< void(ResponseCode)>  cb)
pure virtual

Requests clearing of the user password lock.

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestCommitSchedules()

virtual void Powermon::requestCommitSchedules ( const std::function< void(ResponseCode)> &  cb)
pure virtual

Requests committing the schedules to non-volatile memory.

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestDeleteSchedule()

virtual void Powermon::requestDeleteSchedule ( uint64_t  schedule_descriptor,
const std::function< void(ResponseCode)> &  cb 
)
pure virtual

Requests deleting an existing schedule.

Parameters
schedule_descriptorThe descriptor of the schedule to delete
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestFgSynchronize()

virtual void Powermon::requestFgSynchronize ( const std::function< void(ResponseCode)> &  cb)
pure virtual

Requests forcing the SoC to 100% (SoC synchronize)

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestGetAccessKeys()

virtual void Powermon::requestGetAccessKeys ( const std::function< void(ResponseCode, const WifiAccessKey &)> &  cb)
pure virtual

Requests the WiFi access keys (only applies to the WiFi PowerMons). The access keys are used to remotely access the device.

Parameters
cbLambda of type void(ResponseCode, const WifiAccessKey&) that will be called to signal the result of the request

◆ requestGetAuthKey()

virtual void Powermon::requestGetAuthKey ( std::function< void(ResponseCode, const AuthKey &)>  cb)
pure virtual

Requests the authentication key from the device. This key can be used to unlock a locked device. It acts the same way as the user password lock.

Parameters
cbLambda of type void(ResponseCode, const AuthKey&) that will be called to signal the result of the request

◆ requestGetConfig()

virtual void Powermon::requestGetConfig ( const std::function< void(ResponseCode, const PowermonConfig &)> &  cb)
pure virtual

Retrieves the device configuration structure.

Parameters
cbLambda of type void(ResponseCode, const PowermonConfig&) that will be called to signal the result of the request

◆ requestGetFgStatistics()

virtual void Powermon::requestGetFgStatistics ( const std::function< void(ResponseCode, const FuelgaugeStatistics &)> &  cb)
pure virtual

Requests the device battery statistics data.

Parameters
cbLambda of type void(ResponseCode, const FuelgaugeStatistics&) that will be called to signal the result of the request

◆ requestGetFileList()

virtual void Powermon::requestGetFileList ( const std::function< void(ResponseCode, const std::vector< LogFileDescriptor > &)> &  cb)
pure virtual

Requests the list of log files.

Parameters
cbLambda of type void(ResponseCode, const std::vector<LogFileDescriptor>&) that will be called to signal the result of the request

◆ requestGetInfo()

virtual void Powermon::requestGetInfo ( const std::function< void(ResponseCode, const DeviceInfo &)> &  cb)
pure virtual

Requests the device information.

Parameters
cbLambda of type void(ResponseCode, const DeviceInfo&) that will be called to signal the result of the request

◆ requestGetMonitorData()

virtual void Powermon::requestGetMonitorData ( const std::function< void(ResponseCode, const MonitorData &)> &  cb)
pure virtual

Requests the device monitor data. It only applies to the WiFi devices.

Parameters
cbLambda of type void(ResponseCode, const MonitorData&) that will be called to signal the result of the request

◆ requestGetSchedules()

virtual void Powermon::requestGetSchedules ( const std::function< void(ResponseCode, const std::vector< PowermonSchedule > &)> &  cb)
pure virtual

Requests the list of all schedules stored in the device.

Parameters
cbLambda of type void(ResponseCode, const std::vector<PowermonSchedule>&) that will be called to signal the result of the request

◆ requestGetStatistics()

virtual void Powermon::requestGetStatistics ( const std::function< void(ResponseCode, const MonitorStatistics &)> &  cb)
pure virtual

Requests the device power monitor statistics data.

Parameters
cbLambda of type void(ResponseCode, const MonitorStatistics&) that will be called to signal the result of the request

◆ requestReadFile()

virtual void Powermon::requestReadFile ( uint32_t  file_id,
uint32_t  offset,
uint32_t  read_size,
const std::function< void(ResponseCode, const uint8_t *, size_t)> &  cb 
)
pure virtual

Requests reading of a log file.

Parameters
file_idID of the file to read (obtained from the LogFileDescriptor)
offsetOffset to read from
read_sizeRead size in bytes
cbLambda of type void(ResponseCode, const uint8_t*, size_t) that will be called to signal the result of the request

◆ requestRename()

virtual void Powermon::requestRename ( const char *  name,
const std::function< void(ResponseCode)> &  cb 
)
pure virtual

Requests renaming the PowerMon device.

Parameters
nameNew name. For Bluetooth PowerMons the name is limited to 8 characters. For WiFi PowerMons the name can be up to 32 characters in length.
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestResetAccessKeys()

virtual void Powermon::requestResetAccessKeys ( const std::function< void(ResponseCode)> &  cb)
pure virtual

Requests resetting of the WiFi access keys (only applies to the WiFi PowerMons). This effectively severs the connection to all the paired clients.

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestResetAuthKey()

virtual void Powermon::requestResetAuthKey ( std::function< void(ResponseCode)>  cb)
pure virtual

Requests the reset of the device authentication key.

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestResetConfig()

virtual void Powermon::requestResetConfig ( const std::function< void(ResponseCode)> &  cb)
pure virtual

Resets the PowerMon configuration to factory settings This will also clear the data log, reset the name, authentication keys and access keys (for WiFi devices).

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request.

◆ requestResetCoulombMeter()

virtual void Powermon::requestResetCoulombMeter ( const std::function< void(ResponseCode)> &  cb)
pure virtual

Requests the reset of the coulomb meter.

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestResetEnergyMeter()

virtual void Powermon::requestResetEnergyMeter ( const std::function< void(ResponseCode)> &  cb)
pure virtual

Requests the reset of the energy meter.

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestResetStatistics()

virtual void Powermon::requestResetStatistics ( const std::function< void(ResponseCode)> &  cb)
pure virtual

Requests the reset of the power meter statistics.

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestSetConfig()

virtual void Powermon::requestSetConfig ( const PowermonConfig config,
const std::function< void(ResponseCode)> &  cb 
)
pure virtual

Sends new configuration to the device.

Parameters
configNew configuration structure
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestSetMasterPasswordLock()

virtual void Powermon::requestSetMasterPasswordLock ( const AuthKey key,
std::function< void(ResponseCode)>  cb 
)
pure virtual

Requests setting a master password lock on.

Parameters
key32 bytes AuthKey type used to unlock the device. This is typically the SHA256 hash of a password.
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestSetPowerState()

virtual void Powermon::requestSetPowerState ( bool  state,
const std::function< void(ResponseCode)> &  cb 
)
pure virtual

Requests changing the power state.

Parameters
stateNew power state (ON / OFF)
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestSetTime()

virtual void Powermon::requestSetTime ( uint32_t  time,
const std::function< void(ResponseCode)> &  cb 
)
pure virtual

Requests setting the internal clock of the PowerMon device.

Parameters
timeNew clock in UNIX format (number of seconds since Jan 1st, 1970) in localtime (not UTC)
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestSetUserPasswordLock()

virtual void Powermon::requestSetUserPasswordLock ( const AuthKey key,
std::function< void(ResponseCode)>  cb 
)
pure virtual

Requests setting a user password lock.

Parameters
key32 bytes AuthKey type used to unlock the device. This is typically the SHA256 hash of a password.
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestStartWifiScan()

virtual void Powermon::requestStartWifiScan ( const std::function< void(ResponseCode)> &  cb)
pure virtual

Requests starting the WiFi scan (only applies to the WiFi PowerMons). WiFi scanning will stop automatically after a max of 5 seconds.

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestUnlock()

virtual void Powermon::requestUnlock ( const AuthKey key,
std::function< void(ResponseCode)>  cb 
)
pure virtual

Requests unlocking a password protected device.

Parameters
key32 bytes AuthKey type used to unlock the device. This is typically the SHA256 hash of a password.
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestUpdateFirmware()

virtual void Powermon::requestUpdateFirmware ( const uint8_t *  firmware_image,
uint32_t  size,
const std::function< bool(uint32_t, uint32_t)> &  progress_cb,
const std::function< void(ResponseCode)> &  done_cb 
)
pure virtual

Requests firmware update.

Parameters
firmware_imageThe firmware update image
sizeSize of the firmware update image
progress_cbLambda of type bool(uint32_t progress, uint32_t total) that will be called regularly with updates about the progress. Returning false fronm the lambda will abort the update operation.
done_cbLambda of type void(ResponseCode) that will be called to signal the result of the request upon completion of the firmware update

◆ requestUpdateSchedule()

virtual void Powermon::requestUpdateSchedule ( uint64_t  old_schedule_descriptor,
const PowermonSchedule new_schedule,
const std::function< void(ResponseCode)> &  cb 
)
pure virtual

Requests updating an existing schedule.

Parameters
old_schedule_descriptorThe descriptor of the schedule to update
new_scheduleThe new schedule
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestWifiConfigure()

virtual void Powermon::requestWifiConfigure ( const WifiNetwork network,
const std::function< void(ResponseCode)> &  cb 
)
pure virtual

Sends new WiFi network credentials to the PowerMon device. The new credentials will be saved by the device whether PowerMon can or cannot connect to that specified network.

Parameters
networkWiFi network credentials
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ requestZeroCurrentOffset()

virtual void Powermon::requestZeroCurrentOffset ( const std::function< void(ResponseCode)> &  cb)
pure virtual

Requests zeroing of the current reading offset.

Parameters
cbLambda of type void(ResponseCode) that will be called to signal the result of the request

◆ setOnConnectCallback()

virtual void Powermon::setOnConnectCallback ( const std::function< void(void)> &  cb)
pure virtual

Sets the callback to be called by the driver when a connection to the PowerMon device is fully established.

Parameters
cbLambda of type void(void)

◆ setOnDisconnectCallback()

virtual void Powermon::setOnDisconnectCallback ( const std::function< void(DisconnectReason)> &  cb)
pure virtual

Sets the callback to be called by the driver when a connection to the PowerMon device is disconnected.

Parameters
cbLambda of type void(Powermmon::DisconnectReason)

◆ setOnMonitorDataCallback()

virtual void Powermon::setOnMonitorDataCallback ( const std::function< void(const MonitorData &)> &  cb)
pure virtual

Sets the callback to be called by the driver when new monitor data is received. This applies to the BLE devices only. For the WiFi devices, use the request to retrieve the monitor data.

Parameters
cbLambda of type void(Powermon::MonitorData&)

◆ setOnWifiScanReportCallback()

virtual void Powermon::setOnWifiScanReportCallback ( const std::function< void(const WifiScanResult *)> &  cb)
pure virtual

Sets the callback to be called by the driver when a new WiFi scan result is received from the PowerMon. This applies to the WiFi devices only. WiFi scanning can be initiated using requestStartWifiScan().

Parameters
cbLambda of type void(Powermon::WifiScanResult*)
resultPointer to a WiFiScanResult structure describing a WiFi network. The pointer is only valid inside the scope of the callback closure. Do not store this pointer. Result can be nullptr to signal the WiFi scan ending.

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