-
Notifications
You must be signed in to change notification settings - Fork 44
Proto: add "battery status" to channel state info. #607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2663,6 +2663,7 @@ typedef struct { | |
| #define SUPLA_CHANNELSTATE_FIELD_BRIDGENODESIGNALSTRENGTH 0x0040 | ||
| #define SUPLA_CHANNELSTATE_FIELD_UPTIME 0x0080 | ||
| #define SUPLA_CHANNELSTATE_FIELD_CONNECTIONUPTIME 0x0100 | ||
| // Use exclusively with SUPLA_CHANNELSTATE_FIELD_BATTERY_STATE | ||
| #define SUPLA_CHANNELSTATE_FIELD_BATTERYHEALTH 0x0200 | ||
| #define SUPLA_CHANNELSTATE_FIELD_BRIDGENODEONLINE 0x0400 | ||
| #define SUPLA_CHANNELSTATE_FIELD_LASTCONNECTIONRESETCAUSE 0x0800 | ||
|
|
@@ -2678,13 +2679,23 @@ typedef struct { | |
| // SWITCHCYCLECOUNT and defualtIconField are mutually exclusive. Use only one | ||
| // of them. | ||
| #define SUPLA_CHANNELSTATE_FIELD_SWITCHCYCLECOUNT 0x8000 | ||
| // Device battery level is used to inform server that channel's battery level | ||
| // should be applied to whole device | ||
| #define SUPLA_CHANNELSTATE_FIELD_DEVICE_BATTERYLEVEL 0x10000 | ||
| // Use exclusively with SUPLA_CHANNELSTATE_FIELD_BATTERYHEALTH | ||
| #define SUPLA_CHANNELSTATE_FIELD_BATTERY_STATE 0x20000 | ||
| // Device battery state is used to inform server that channel's battery state | ||
| // should be applied to whole device | ||
| #define SUPLA_CHANNELSTATE_FIELD_DEVICE_BATTERY_STATE 0x40000 | ||
|
|
||
| #define SUPLA_LASTCONNECTIONRESETCAUSE_UNKNOWN 0 | ||
| #define SUPLA_LASTCONNECTIONRESETCAUSE_ACTIVITY_TIMEOUT 1 | ||
| #define SUPLA_LASTCONNECTIONRESETCAUSE_WIFI_CONNECTION_LOST 2 | ||
| #define SUPLA_LASTCONNECTIONRESETCAUSE_SERVER_CONNECTION_LOST 3 | ||
|
|
||
| #define SUPLA_BATTERY_STATE_OK 0 | ||
| #define SUPLA_BATTERY_STATE_LOW 1 | ||
|
|
||
| typedef struct { | ||
| _supla_int_t ReceiverID; // Not used in extended values | ||
| union { | ||
|
|
@@ -2707,7 +2718,10 @@ typedef struct { | |
| unsigned char BridgeNodeSignalStrength; // 0 - 100% | ||
| unsigned _supla_int_t Uptime; // sec. | ||
| unsigned _supla_int_t ConnectionUptime; // sec. | ||
| unsigned char BatteryHealth; | ||
| union { | ||
| unsigned char BatteryHealth; // 0 - 100% | ||
| unsigned char BatteryState; // SUPLA_BATTERY_STATE_* | ||
| }; | ||
| unsigned char LastConnectionResetCause; // SUPLA_LASTCONNECTIONRESETCAUSE_* | ||
| unsigned _supla_int16_t LightSourceLifespan; // 0 - 65535 hours | ||
| union { | ||
|
|
@@ -3271,8 +3285,9 @@ typedef struct { | |
| Timeout; // 0 - not used, > 0 - time in 0.1 s, max 36000 | ||
| unsigned char Sensitivity; // 0 - not used, 1..101 - sensitivity 0..100 % | ||
| // value 1 (0 %) means "OFF" | ||
| unsigned char AlarmMuted; // 0 - not used, 1 - alarm is muted, 2 - alarm is | ||
| // not muted | ||
| unsigned char LocalAlarmIndication; // 0 - not used, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When building the server code that includes this header, Useful? React with 👍 / 👎. |
||
| // 1 - local alarm indication disabled, | ||
| // 2 - local alarm indication enabled | ||
| unsigned char | ||
| Reserved[29 - sizeof(unsigned char) - sizeof(unsigned _supla_int16_t) - | ||
| sizeof(unsigned char)]; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a device sets
SUPLA_CHANNELSTATE_FIELD_BATTERY_STATEorSUPLA_CHANNELSTATE_FIELD_DEVICE_BATTERY_STATE, the server receives the rawTDSC_ChannelState, but the persistence path serializes channel state throughsupla_channel_state::get_json()beforesupla_device_dao::update_channel_state, and that JSON code only handlesbatteryHealth/deviceBatteryLeveltoday. In that scenario the new battery status is dropped from the database and will be absent for clients that load channel state from persisted JSON after reconnect/restart, so the proto addition needs matching JSON serialization/deserialization for these flags.Useful? React with 👍 / 👎.