Skip to content

Commit

Permalink
supla-common update
Browse files Browse the repository at this point in the history
  • Loading branch information
przemyslawzygmunt committed Sep 1, 2020
1 parent e9fe9cc commit 272d3aa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
13 changes: 5 additions & 8 deletions supla-common/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ extern char sproto_tag[SUPLA_TAG_SIZE];
// CS - client -> server
// SC - server -> client

#define SUPLA_PROTO_VERSION 12
#define SUPLA_PROTO_VERSION 13
#define SUPLA_PROTO_VERSION_MIN 1
#if defined(ARDUINO_ARCH_AVR) // Arduino IDE for Arduino HW
#define SUPLA_MAX_DATA_SIZE 1248 // Registration header + 32 channels x 21 B
Expand Down Expand Up @@ -156,7 +156,7 @@ extern char sproto_tag[SUPLA_TAG_SIZE];
#define SUPLA_DS_CALL_DEVICE_CHANNEL_VALUE_CHANGED_C 103 // ver. >= 12
#define SUPLA_DS_CALL_DEVICE_CHANNEL_EXTENDEDVALUE_CHANGED 105 // ver. >= 10
#define SUPLA_SD_CALL_CHANNEL_SET_VALUE 110
#define SUPLA_SD_CALL_GROUP_SET_VALUE 115
#define SUPLA_SD_CALL_CHANNEL_SET_VALUE_B 115 // ver. >= 13
#define SUPLA_DS_CALL_CHANNEL_SET_VALUE_RESULT 120
#define SUPLA_SC_CALL_LOCATION_UPDATE 130
#define SUPLA_SC_CALL_LOCATIONPACK_UPDATE 140
Expand Down Expand Up @@ -440,8 +440,6 @@ extern char sproto_tag[SUPLA_TAG_SIZE];
0x02000000 // ver. >= 12
#define SUPLA_CHANNEL_FLAG_POSSIBLE_SLEEP_MODE 0x04000000 // ver. >= 12

#define SUPLA_DEVICE_FLAG_GROUP_CONTROL_EXPECTED 0x0001 // ver. >= 12

#pragma pack(push, 1)

typedef struct {
Expand Down Expand Up @@ -711,13 +709,12 @@ typedef struct {
// server -> device
_supla_int_t SenderID;
_supla_int_t GroupID;
unsigned char EOL; // End Of List
unsigned char ChannelNumber;
unsigned _supla_int_t DurationMS;

char value[SUPLA_CHANNELVALUE_SIZE];
unsigned char ChannelCount;
unsigned char
ChannelNumber[SUPLA_CHANNELMAXCOUNT]; // Last variable in struct!
} TSD_SuplaGroupNewValue;
} TSD_SuplaChannelNewValue_B; // v. >= 13

typedef struct {
// device -> server
Expand Down
29 changes: 11 additions & 18 deletions supla-common/srpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,14 +865,12 @@ char SRPC_ICACHE_FLASH srpc_getdata(void *_srpc, TsrpcReceivedData *rd,

break;

case SUPLA_SD_CALL_GROUP_SET_VALUE:
case SUPLA_SD_CALL_CHANNEL_SET_VALUE_B:

if (srpc->sdp.data_size >=
sizeof(TSD_SuplaGroupNewValue) -
(sizeof(unsigned char) * SUPLA_CHANNELMAXCOUNT) &&
srpc->sdp.data_size <= sizeof(TSD_SuplaGroupNewValue))
rd->data.sd_group_new_value =
(TSD_SuplaGroupNewValue *)malloc(sizeof(TSD_SuplaGroupNewValue));
if (srpc->sdp.data_size == sizeof(TSD_SuplaChannelNewValue_B))
rd->data.sd_channel_new_value_b =
(TSD_SuplaChannelNewValue_B *)malloc(
sizeof(TSD_SuplaChannelNewValue_B));

break;

Expand Down Expand Up @@ -1396,9 +1394,10 @@ srpc_call_min_version_required(void *_srpc, unsigned _supla_int_t call_type) {
case SUPLA_DS_CALL_DEVICE_CHANNEL_VALUE_CHANGED_C:
case SUPLA_DS_CALL_GET_CHANNEL_FUNCTIONS:
case SUPLA_SD_CALL_GET_CHANNEL_FUNCTIONS_RESULT:
case SUPLA_SD_CALL_GROUP_SET_VALUE:
case SUPLA_CS_CALL_GET_SUPERUSER_AUTHORIZATION_RESULT:
return 12;
case SUPLA_SD_CALL_CHANNEL_SET_VALUE_B:
return 13;
}

return 255;
Expand Down Expand Up @@ -1690,16 +1689,10 @@ srpc_sd_async_set_channel_value(void *_srpc, TSD_SuplaChannelNewValue *value) {
sizeof(TSD_SuplaChannelNewValue));
}

_supla_int_t SRPC_ICACHE_FLASH
srpc_sd_async_set_group_value(void *_srpc, TSD_SuplaGroupNewValue *value) {
_supla_int_t size = sizeof(TSD_SuplaGroupNewValue) -
(sizeof(unsigned char) * SUPLA_CHANNELMAXCOUNT) +
(sizeof(unsigned char) * value->ChannelCount);

if (size > sizeof(TSD_SuplaGroupNewValue)) return 0;

return srpc_async_call(_srpc, SUPLA_SD_CALL_GROUP_SET_VALUE, (char *)value,
size);
_supla_int_t SRPC_ICACHE_FLASH srpc_sd_async_set_channel_value_b(
void *_srpc, TSD_SuplaChannelNewValue_B *value) {
return srpc_async_call(_srpc, SUPLA_SD_CALL_CHANNEL_SET_VALUE_B,
(char *)value, sizeof(TSD_SuplaChannelNewValue_B));
}

_supla_int_t SRPC_ICACHE_FLASH
Expand Down
6 changes: 3 additions & 3 deletions supla-common/srpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ union TsrpcDataPacketData {
TSC_SuplaChannelValue *sc_channel_value;
TSC_SuplaEvent *sc_event;
TSD_SuplaChannelNewValue *sd_channel_new_value;
TSD_SuplaGroupNewValue *sd_group_new_value;
TSD_SuplaChannelNewValue_B *sd_channel_new_value_b;
TDS_SuplaChannelNewValueResult *ds_channel_new_value_result;
TCS_SuplaChannelNewValue *cs_channel_new_value;
TCS_SuplaChannelNewValue_B *cs_channel_new_value_b;
Expand Down Expand Up @@ -242,8 +242,8 @@ _supla_int_t SRPC_ICACHE_FLASH srpc_ds_async_channel_extendedvalue_changed(
TSuplaChannelExtendedValue *value);
_supla_int_t SRPC_ICACHE_FLASH
srpc_sd_async_set_channel_value(void *_srpc, TSD_SuplaChannelNewValue *value);
_supla_int_t SRPC_ICACHE_FLASH
srpc_sd_async_set_group_value(void *_srpc, TSD_SuplaGroupNewValue *value);
_supla_int_t SRPC_ICACHE_FLASH srpc_sd_async_set_channel_value_b(
void *_srpc, TSD_SuplaChannelNewValue_B *value); // ver. >= 13
_supla_int_t SRPC_ICACHE_FLASH
srpc_ds_async_set_channel_result(void *_srpc, unsigned char ChannelNumber,
_supla_int_t SenderID, char Success);
Expand Down

0 comments on commit 272d3aa

Please sign in to comment.