libpowermon 1.00
PowerMon Access Library
Loading...
Searching...
No Matches
powermon.h
1/* Copyright (C) 2020 - 2024, Thornwave Labs Inc
2 * Written by Razvan Turiac <razvan.turiac@thornwave.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 * documentation files (the “Software”), to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 *
9 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 * Attribution shall be given to Thornwave Labs Inc. and shall be made visible to the final user.
11 *
12 * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
13 * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
15 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16*/
17
18#ifndef _POWERMON_H
19#define _POWERMON_H
20
21
22#include <stdint.h>
23#include <string.h>
24
25#include <string>
26#include <vector>
27#include <functional>
28
29
30#include <powermon_config.h>
31#include <powermon_schedule.h>
32#include <powermon_log.h>
33
34
35#define MAX_WIFI_SSID_SIZE 32
36#define MAX_WIFI_PASSWORD_SIZE 64
37
38#define CHANNEL_ID_SIZE 16
39#define ENCRYPTION_KEY_SIZE 32
40
41#define MAX_BLE_NAME_LENGTH 8
42#define MAX_WIFI_NAME_LENGTH 32
43
44#define MAX_TIMER_NAME_LENGTH 16
45#define MAX_TIMER_COUNT 16
46
47#define FG_SOC_DISABLED 0xFF
48#define FG_SOC_UNKNOWN 0xFE
49
50#define FG_RUNTIME_DISABLED 0xFFFF
51#define FG_RUNTIME_UNKNOWN 0xFFFE
52#define FG_RUNTIME_MAX 0xFFF0
53
54
59{
60public:
64 enum HardwareRevision: uint8_t
65 {
66 FAMILY_MASK = 0xF0,
67
68 POWERMON = 0x20,
69 POWERMON_5S = 0x30,
70 POWERMON_W = 0x40
71 };
72
73
77 enum State: uint8_t
78 {
82 };
83
84
88 enum DisconnectReason: uint8_t
89 {
90 CLOSED = 0,
91 NO_ROUTE,
92 FAILED,
93 UNEXPECTED_ERROR,
94 UNEXPECTED_RESPONSE,
95 WRITE_ERROR,
96 READ_ERROR,
97 };
98
99
103 enum ResponseCode: uint16_t
104 {
105 RSP_SUCCESS = 0x0000,
106 RSP_SUCCESS_MORE = 0x0100,
107
108 RSP_INVALID_REQ = 0x0001,
109 RSP_INVALID_PARAM = 0x0002,
110 RSP_ERROR = 0x0003,
111 RSP_LOCKED_USER = 0x0004,
112 RSP_LOCKED_MASTER = 0x0005,
113 RSP_CANNOT_UNLOCK = 0x0006,
114 RSP_NOT_FOUND = 0x0007,
115
116 RSP_TIMEOUT = 0x0008,
117 RSP_INVALID = 0x0009,
118 RSP_CANCELLED = 0x000A,
119 };
120
121
125 enum PowerStatus: uint8_t
126 {
127 PS_OFF = 0,
128 PS_ON = 1,
129 PS_LVD = 2,
130 PS_OCD = 3,
131 PS_HVD = 4,
132 PS_FGD = 5,
133 PS_NCH = 6,
134 PS_LTD = 7,
135 PS_HTD = 8,
136 };
137
138
142 struct AuthKey
143 {
144 uint8_t data[32];
145 };
146
147
152 {
153 uint8_t channel_id[CHANNEL_ID_SIZE];
154 uint8_t encryption_key[ENCRYPTION_KEY_SIZE];
155 };
156
157
162 {
163 enum SecurityMode: uint8_t
164 {
165 OPEN = 0x0,
166 WEP = 0x1,
168 WPA2_PSK = 0x4,
169 WPA3_SAE = 0x6
170 };
171
172 uint8_t ssid_length;
173 uint8_t ssid[MAX_WIFI_SSID_SIZE];
174
175 uint8_t pass_length;
176 uint8_t pass[MAX_WIFI_PASSWORD_SIZE];
177
178 SecurityMode security;
179 };
180
181
186 {
187 uint8_t ssid_length;
188 uint8_t ssid[MAX_WIFI_SSID_SIZE];
189 uint8_t channel;
190
191 struct
192 {
193 uint8_t wep : 1;
194 uint8_t wpa : 1;
195 uint8_t wpa2 : 1;
196 uint8_t wpa3 : 1;
197 uint8_t pmf : 1;
198 uint8_t unused : 1;
199 uint8_t psk : 1;
200 uint8_t eap : 1;
201 }security;
202
203 int8_t rssi;
204
205 bool operator==(const WifiScanResult &rhs) const;
206 };
207
208
213 {
214 std::string name;
215
216 uint16_t firmware_version_bcd;
217 uint8_t hardware_revision_bcd;
218
219 uint64_t address;
220 uint64_t serial;
221
222 uint8_t ssid_length;
223 uint8_t ssid[MAX_WIFI_SSID_SIZE];
224 uint8_t flags;
225
226 bool isUserPasswordSet(void) const;
227 bool isMasterPasswordSet(void) const;
228 bool isUserLocked(void) const;
229 bool isMasterLocked(void) const;
230
231 bool isWifiConnecting(void) const;
232 bool isWifiConnected(void) const;
233 bool isWifiFailed(void) const;
234 };
235
236
241 {
242 std::string name;
243 uint64_t serial;
245 uint64_t address;
246
248
250
251 bool operator==(const DeviceIdentifier &rhs);
252
258 bool fromURL(const char* url);
259
264 std::string toURL(void);
265 };
266
267
272 {
275
276 uint32_t time;
277 uint32_t flags;
278
279 float voltage1;
280 float voltage2;
281 float current;
282 float power;
284
286 int64_t energy_meter;
287
289
290 uint8_t fg_soc;
291 uint16_t fg_runtime;
292
293 int16_t rssi = INT16_MIN;
294
298 bool isTemperatureExternal(void) const;
299 };
300
301
306 {
308
309 float voltage1_min;
310 float voltage1_max;
311
312 float voltage2_min;
313 float voltage2_max;
314
315 float peak_charge_current;
316 float peak_discharge_current;
317
320 };
321
322
327 {
328 uint32_t time_since_last_full_charge; //in seconds
329 float full_charge_capacity; //current total capacity in Ah
330
331 uint64_t total_discharge; //in mAh
332 uint64_t total_discharge_energy; //in mWh
333
334 uint64_t total_charge; //in mAh
335 uint64_t total_charge_energy; //in mWh
336
337 float min_voltage;
338 float max_voltage;
339 float max_discharge_current;
340 float max_charge_current;
341
342 float deepest_discharge; //in Ah
343 float last_discharge; //in Ah
344
345 float soc; //in percentage
346 uint32_t RESERVED;
347 };
348
349
354 {
355 uint32_t id;
356 uint32_t size;
357 };
358
359
365 virtual ~Powermon();
366
367
372 virtual void connectWifi(const WifiAccessKey &key) = 0;
373
374
379 virtual void connectWifi(uint32_t ipaddr) = 0;
380
381
386 virtual void connectBle(uint64_t ble_address) = 0;
387
388
392 virtual void disconnect(void) = 0;
393
394
398 virtual bool isLocalConnection(void) const = 0;
399
400
405 virtual void setOnConnectCallback(const std::function<void(void)> &cb) = 0;
406
407
412 virtual void setOnDisconnectCallback(const std::function<void(DisconnectReason)> &cb) = 0;
413
414
420 virtual void setOnMonitorDataCallback(const std::function<void(const MonitorData&)> &cb) = 0;
421
422
430 virtual void setOnWifiScanReportCallback(const std::function<void(const WifiScanResult*)> &cb) = 0;
431
432
437 virtual const DeviceInfo& getLastDeviceInfo(void) const = 0;
438
439
444 virtual void requestGetInfo(const std::function<void(ResponseCode, const DeviceInfo&)> &cb) = 0;
445
446
451 virtual void requestGetMonitorData(const std::function<void(ResponseCode, const MonitorData&)> &cb) = 0;
452
453
458 virtual void requestGetStatistics(const std::function<void(ResponseCode, const MonitorStatistics&)> &cb) = 0;
459
460
465 virtual void requestGetFgStatistics(const std::function<void(ResponseCode, const FuelgaugeStatistics&)> &cb) = 0;
466
467
473 virtual void requestUnlock(const AuthKey &key, std::function<void(ResponseCode)> cb) = 0;
474
475
481 virtual void requestSetUserPasswordLock(const AuthKey &key, std::function<void(ResponseCode)> cb) = 0;
482
483
489 virtual void requestSetMasterPasswordLock(const AuthKey &key, std::function<void(ResponseCode)> cb) = 0;
490
491
496 virtual void requestClearUserPasswordLock(std::function<void(ResponseCode)> cb) = 0;
497
498
503 virtual void requestClearMasterPasswordLock(std::function<void(ResponseCode)> cb) = 0;
504
505
510 virtual void requestGetAuthKey(std::function<void(ResponseCode, const AuthKey&)> cb) = 0;
511
512
517 virtual void requestResetAuthKey(std::function<void(ResponseCode)> cb) = 0;
518
519
524 virtual void requestResetEnergyMeter(const std::function<void(ResponseCode)> &cb) = 0;
525
526
531 virtual void requestResetCoulombMeter(const std::function<void(ResponseCode)> &cb) = 0;
532
533
538 virtual void requestResetStatistics(const std::function<void(ResponseCode)> &cb) = 0;
539
540
546 virtual void requestSetPowerState(bool state, const std::function<void(ResponseCode)> &cb) = 0;
547
548
553 virtual void requestGetConfig(const std::function<void(ResponseCode, const PowermonConfig&)> &cb) = 0;
554
555
561 virtual void requestSetConfig(const PowermonConfig &config, const std::function<void(ResponseCode)> &cb) = 0;
562
563
569 virtual void requestResetConfig(const std::function<void(ResponseCode)> &cb) = 0;
570
571
577 virtual void requestRename(const char* name, const std::function<void(ResponseCode)> &cb) = 0;
578
579
585 virtual void requestSetTime(uint32_t time, const std::function<void(ResponseCode)> &cb) = 0;
586
587
592 virtual void requestFgSynchronize(const std::function<void(ResponseCode)> &cb) = 0;
593
594
599 virtual void requestStartWifiScan(const std::function<void(ResponseCode)> &cb) = 0;
600
601
608 virtual void requestWifiConfigure(const WifiNetwork &network, const std::function<void(ResponseCode)> &cb) = 0;
609
610
615 virtual void requestGetAccessKeys(const std::function<void(ResponseCode, const WifiAccessKey&)> &cb) = 0;
616
617
622 virtual void requestResetAccessKeys(const std::function<void(ResponseCode)> &cb) = 0;
623
624
629 virtual void requestZeroCurrentOffset(const std::function<void(ResponseCode)> &cb) = 0;
630
631
637 virtual void requestCalibrateCurrent(float value, const std::function<void(ResponseCode)> &cb) = 0;
638
639
644 virtual void requestGetSchedules(const std::function<void(ResponseCode, const std::vector<PowermonSchedule>&)> &cb) = 0;
645
646
652 virtual void requestAddSchedules(const std::vector<PowermonSchedule> &schedules, const std::function<void(ResponseCode)> &cb) = 0;
653
654
661 virtual void requestUpdateSchedule(uint64_t old_schedule_descriptor, const PowermonSchedule &new_schedule, const std::function<void(ResponseCode)> &cb) = 0;
662
663
669 virtual void requestDeleteSchedule(uint64_t schedule_descriptor, const std::function<void(ResponseCode)> &cb) = 0;
670
671
676 virtual void requestClearSchedules(const std::function<void(ResponseCode)> &cb) = 0;
677
678
683 virtual void requestCommitSchedules(const std::function<void(ResponseCode)> &cb) = 0;
684
685
690 virtual void requestGetFileList(const std::function<void(ResponseCode, const std::vector<LogFileDescriptor>&)> &cb) = 0;
691
692
700 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;
701
702
711 virtual void requestUpdateFirmware(const uint8_t* firmware_image, uint32_t size, const std::function<bool(uint32_t, uint32_t)> &progress_cb,
712 const std::function<void(ResponseCode)> &done_cb) = 0;
713
714
718 static std::string getIpAddressString(uint32_t ip);
719
720
724 static std::string getMacAddressString(uint64_t mac);
725
726
730 static uint64_t parseMacAddress(const char* address);
731
732
736 static std::string getHardwareString(uint8_t bcd);
737
738
742 static std::string getPowerStatusString(PowerStatus ps);
743
744
748 static bool hasVoltage2(uint8_t bcd);
749
750
754 static bool hasConfigurableShunt(uint8_t bcd);
755
756
760 static bool hasWifi(uint8_t bcd);
761
762
766 static inline bool checkBCD(uint16_t bcd)
767 {
768 for(uint32_t i = 0; i < 4; i++)
769 {
770 if ((bcd & 0xF) > 0x9)
771 return false;
772 bcd >>= 4;
773 }
774
775 return true;
776 }
777
783 static AuthKey getAuthKeyFromPassword(const char* password);
784
788 static std::string getUpdateFirmwareImageUrl(uint8_t hardware_revision_bcd, uint16_t firmware_revision_bcd);
789
793 static uint16_t checkFirmwareImage(const uint8_t* image, size_t size, uint8_t hardware_revision_bcd);
794};
795
796
797#include <powermon_scanner.h>
798
799
800#endif
Powermon is a class representing one PowerMon device (BLE or WiFi) and offers a set of functions for ...
Definition powermon.h:59
static uint64_t parseMacAddress(const char *address)
Parses a MAC address string.
virtual void requestResetAuthKey(std::function< void(ResponseCode)> cb)=0
Requests the reset of the device authentication key.
HardwareRevision
HardwareRevision definitions (2 digit BCD format)
Definition powermon.h:65
@ POWERMON_W
PowerMon-W (WiFi)
Definition powermon.h:70
@ FAMILY_MASK
Mask for the family part of the revision number.
Definition powermon.h:66
@ POWERMON
Original PowerMon (BLE)
Definition powermon.h:68
@ POWERMON_5S
PowerMon-5S (BLE)
Definition powermon.h:69
virtual void requestGetConfig(const std::function< void(ResponseCode, const PowermonConfig &)> &cb)=0
Retrieves the device configuration structure.
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 requestSetPowerState(bool state, const std::function< void(ResponseCode)> &cb)=0
Requests changing the power state.
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 automat...
PowerStatus
PowerStatus is an enumeration of all possible power states.
Definition powermon.h:126
@ PS_LTD
Power status is Low Temperature Disconnect.
Definition powermon.h:134
@ PS_ON
Power status is On.
Definition powermon.h:128
@ PS_FGD
Power status is Fuel Gauge Disconnect.
Definition powermon.h:132
@ PS_HTD
Power status is High Temperature Disconnect.
Definition powermon.h:135
@ PS_NCH
Power status is Not CHarging (for LiFePO4 charge manager only)
Definition powermon.h:133
@ PS_OCD
Power status is Over-Current Disconnect.
Definition powermon.h:130
@ PS_LVD
Power status is Low Voltage Disconnect.
Definition powermon.h:129
@ PS_OFF
Power status is Off.
Definition powermon.h:127
@ PS_HVD
Power status is High Voltage Disconnect.
Definition powermon.h:131
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 sev...
virtual void requestSetConfig(const PowermonConfig &config, const std::function< void(ResponseCode)> &cb)=0
Sends new configuration to the device.
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 requestClearSchedules(const std::function< void(ResponseCode)> &cb)=0
Requests clearing of all schedule.
virtual void connectWifi(uint32_t ipaddr)=0
Connects to a local WiFi PowerMon.
virtual void requestGetStatistics(const std::function< void(ResponseCode, const MonitorStatistics &)> &cb)=0
Requests the device power monitor statistics data.
virtual void requestFgSynchronize(const std::function< void(ResponseCode)> &cb)=0
Requests forcing the SoC to 100% (SoC synchronize)
static std::string getPowerStatusString(PowerStatus ps)
Returns the power status string representation.
DisconnectReason
DisconnectReason is an enumeration of all reasons a connection can be terminated.
Definition powermon.h:89
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 d...
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 remot...
virtual void requestSetUserPasswordLock(const AuthKey &key, std::function< void(ResponseCode)> cb)=0
Requests setting a user password lock.
static std::string getIpAddressString(uint32_t ip)
Returns the IP address as string.
virtual void connectWifi(const WifiAccessKey &key)=0
Connects to a remote WiFi PowerMon.
virtual void requestClearUserPasswordLock(std::function< void(ResponseCode)> cb)=0
Requests clearing of the user password lock.
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.
static bool checkBCD(uint16_t bcd)
Returns true if the parameter is a valid BCD number.
Definition powermon.h:766
virtual void requestZeroCurrentOffset(const std::function< void(ResponseCode)> &cb)=0
Requests zeroing of the current reading offset.
virtual void requestAddSchedules(const std::vector< PowermonSchedule > &schedules, const std::function< void(ResponseCode)> &cb)=0
Requests adding new schedules.
static AuthKey getAuthKeyFromPassword(const char *password)
Generates the SHA256 hash of a password.
virtual const DeviceInfo & getLastDeviceInfo(void) const =0
Returns the last DeviceInfo retrieved from the PowerMon.
virtual void requestGetFgStatistics(const std::function< void(ResponseCode, const FuelgaugeStatistics &)> &cb)=0
Requests the device battery statistics data.
static bool hasWifi(uint8_t bcd)
Returns true if the PowerMon described by the BCD hardware revision has WiFi.
static std::string getMacAddressString(uint64_t mac)
Returns the Bluetooth MAC address as string.
ResponseCode
ResponseCodes is an enumeration of all possible response codes for requests to a PowerMon device.
Definition powermon.h:104
static bool hasVoltage2(uint8_t bcd)
Returns true if the PowerMon described by the BCD hardware revision has V2.
virtual void requestSetTime(uint32_t time, const std::function< void(ResponseCode)> &cb)=0
Requests setting the internal clock of the PowerMon device.
virtual void requestGetInfo(const std::function< void(ResponseCode, const DeviceInfo &)> &cb)=0
Requests the device information.
static Powermon * createInstance(void)
Creates an instance of the Powermon class.
virtual void requestCalibrateCurrent(float value, const std::function< void(ResponseCode)> &cb)=0
Requests calibration of the current reading.
virtual void requestDeleteSchedule(uint64_t schedule_descriptor, const std::function< void(ResponseCode)> &cb)=0
Requests deleting an existing schedule.
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 establ...
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.
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 PowerMo...
virtual void requestUnlock(const AuthKey &key, std::function< void(ResponseCode)> cb)=0
Requests unlocking a password protected device.
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.
virtual void requestResetEnergyMeter(const std::function< void(ResponseCode)> &cb)=0
Requests the reset of the energy meter.
virtual void requestResetStatistics(const std::function< void(ResponseCode)> &cb)=0
Requests the reset of the power meter statistics.
virtual void requestRename(const char *name, const std::function< void(ResponseCode)> &cb)=0
Requests renaming the PowerMon device.
virtual bool isLocalConnection(void) const =0
Returns true if the current connection is local: BLE or WiFi.
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...
static bool hasConfigurableShunt(uint8_t bcd)
Returns true if the PowerMon described by the BCD hardware revision supports configurable shunts.
virtual void requestClearMasterPasswordLock(std::function< void(ResponseCode)> cb)=0
Requests clearing of the master password lock.
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 connectBle(uint64_t ble_address)=0
Connects to a local BLE PowerMon.
static std::string getHardwareString(uint8_t bcd)
Returns the hardware name based on the hardware revision in BCD format.
virtual void requestGetFileList(const std::function< void(ResponseCode, const std::vector< LogFileDescriptor > &)> &cb)=0
Requests the list of log files.
State
State represents the PowerMon connection state.
Definition powermon.h:78
@ Connecting
Device is in the process of connecting.
Definition powermon.h:80
@ Disconnected
Device is not connected.
Definition powermon.h:79
@ Connected
Device is connected.
Definition powermon.h:81
virtual void requestResetConfig(const std::function< void(ResponseCode)> &cb)=0
Resets the PowerMon configuration to factory settings This will also clear the data log,...
virtual void requestSetMasterPasswordLock(const AuthKey &key, std::function< void(ResponseCode)> cb)=0
Requests setting a master password lock on.
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....
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 B...
static uint16_t checkFirmwareImage(const uint8_t *image, size_t size, uint8_t hardware_revision_bcd)
Checks the validity of the firmware update image.
virtual void disconnect(void)=0
Disconnects from a connected device.
virtual void requestCommitSchedules(const std::function< void(ResponseCode)> &cb)=0
Requests committing the schedules to non-volatile memory.
virtual void requestResetCoulombMeter(const std::function< void(ResponseCode)> &cb)=0
Requests the reset of the coulomb meter.
AuthKey is a structure representing an authentication key used to unlock a locked PowerMon device.
Definition powermon.h:143
DeviceIdentifier is a structure containing all information used to identify a PowerMon device (either...
Definition powermon.h:241
uint64_t serial
Device serial number.
Definition powermon.h:243
uint8_t hardware_revision_bcd
Identifies if it's a WiFi or BLE device.
Definition powermon.h:244
bool fromURL(const char *url)
Initializes the current object from a device link.
std::string toURL(void)
Saves the current PowerMon-W access structure to a link. Only remote access WiFi device identifiers c...
WifiAccessKey access_key
Contains the access keys for a remote WiFi device. In this case address is zero.
Definition powermon.h:247
std::string name
Device name.
Definition powermon.h:242
uint64_t address
contains the BLE MAC address for a BLE device of the IP address of a local WiFi device.
Definition powermon.h:245
DeviceInfo is the information structure returned by PowerMon as response to the GetInfo request.
Definition powermon.h:213
FuelgaugeStatistics is a structure containing battery statistics.
Definition powermon.h:327
LogFileDescriptor represents a PowerMon log file.
Definition powermon.h:354
uint32_t id
ID of the file (timestamp in UNIX time of the first sample in the file)
Definition powermon.h:355
uint32_t size
Size in bytes.
Definition powermon.h:356
MonitorData is a structure containing the real-time PowerMon data.
Definition powermon.h:272
float power
Power in Watts. Depending on the configuration, either V1 or V2 are used to compute this value.
Definition powermon.h:282
float temperature
Temperature in Celsius.
Definition powermon.h:283
uint16_t firmware_version_bcd
current firmware version in BCD format xx.yy
Definition powermon.h:273
int64_t energy_meter
Energy meter in mWh.
Definition powermon.h:286
uint16_t fg_runtime
Fuelgauge runtime in minutes. 0xFFFF means the FG is not enabled. The maximum valid value is 0xFFF0.
Definition powermon.h:291
float current
Current in Amperes.
Definition powermon.h:281
float voltage2
Voltage 2 in Volts.
Definition powermon.h:280
int64_t coulomb_meter
Coulomb meter in mAh.
Definition powermon.h:285
bool isTemperatureExternal(void) const
Returns true if the temperature is read from an external sensor.
int16_t rssi
RSSI as seen by the device in dBm.
Definition powermon.h:293
uint8_t fg_soc
Fuelgauge SoC (State of Charge) in percentage. 0xFF means the FG is not enabled. 0xFE means the SoC i...
Definition powermon.h:290
float voltage1
Voltage 1 in Volts.
Definition powermon.h:279
uint32_t flags
various flags - do not use directly
Definition powermon.h:277
uint8_t hardware_revision_bcd
current hardware revision in BCD format x.y
Definition powermon.h:274
uint32_t time
UNIX time in localtime (not UTC)
Definition powermon.h:276
PowerStatus power_status
Device power status.
Definition powermon.h:288
MonitorStatistics is a structure containing power meter statistics.
Definition powermon.h:306
float temperature_max
in Celsius
Definition powermon.h:319
uint32_t seconds_since_on
number of seconds since PowerMon was powered up
Definition powermon.h:307
float temperature_min
in Celsius
Definition powermon.h:318
WifiAccessKey is a structure representing the access keys used to connect to a WiFi PowerMon remotely...
Definition powermon.h:152
WifiNetwork represents all information required by PowerMon to connect to an access point.
Definition powermon.h:162
SecurityMode
Definition powermon.h:164
@ WPA2_WPA1_PSK
Use WPA1 or WPA2.
Definition powermon.h:167
@ WPA2_PSK
Use only WPA2.
Definition powermon.h:168
@ WEP
Use WEP.
Definition powermon.h:166
@ WPA3_SAE
Use WPA3 (STA mode only)
Definition powermon.h:169
@ OPEN
No security.
Definition powermon.h:165
WifiScanResult represents a WiFi network detected by PowerMon during WiFi scanning.
Definition powermon.h:186
uint8_t unused
Reserved, set to zero.
Definition powermon.h:198
uint8_t wep
Network supports WEP.
Definition powermon.h:193
uint8_t psk
Network supports Personal authentication.
Definition powermon.h:199
uint8_t wpa3
Network supports WPA3. If multiple WPA bits are set the network supports mixed mode.
Definition powermon.h:196
uint8_t wpa2
Network supports WPA2. If both WPA bits are set the network supports mixed mode.
Definition powermon.h:195
uint8_t eap
Network supports Enterprise authentication.
Definition powermon.h:200
uint8_t wpa
Network supports WPA. If both WPA bits are set the network supports mixed mode.
Definition powermon.h:194
uint8_t pmf
Networks requires use of Protected Management Frames.
Definition powermon.h:197
PowermonConfig is a structure containing the PowerMon configuration.
Definition powermon_config.h:30
PowermonSchedule is a structure containing one PowerMon schedule (timer)
Definition powermon_schedule.h:30