Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions supla-common/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Comment on lines +2686 to +2689
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Persist the new battery-state flags

When a device sets SUPLA_CHANNELSTATE_FIELD_BATTERY_STATE or SUPLA_CHANNELSTATE_FIELD_DEVICE_BATTERY_STATE, the server receives the raw TDSC_ChannelState, but the persistence path serializes channel state through supla_channel_state::get_json() before supla_device_dao::update_channel_state, and that JSON code only handles batteryHealth / deviceBatteryLevel today. 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 👍 / 👎.


#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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep the binary sensor config member name compatible

When building the server code that includes this header, supla-server/src/jsonconfig/channel/binary_sensor_config.cpp and its tests still access TChannelConfig_BinarySensor::AlarmMuted; after this rename the struct no longer has that member, so those targets fail to compile as soon as they include the updated protocol header. Either keep the existing member name or update all users in the same change.

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)];
Expand Down