Skip to content

Commit

Permalink
change report for 'SET duration'
Browse files Browse the repository at this point in the history
  • Loading branch information
amatilda committed Sep 23, 2024
1 parent 8da90a5 commit 577174c
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 36 deletions.
10 changes: 5 additions & 5 deletions hardware/arduino/zunoG2/cores/ZWSupport/ZWCCBasic.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ void __zuno_BasicUniversalGetCurrentValueDurationTargetValue(uint8_t channel, ui

#ifdef WITH_CC_BASIC
size_t zuno_CCThermostatModeTobasic(size_t channel, size_t value);
int zuno_CCSoundSwitchBasicSet(size_t channel, size_t toneIdentifier);
static int _basic_set(byte channel, const ZwBasicSetFrame_t *paket) {
int zuno_CCSoundSwitchBasicSet(size_t channel, size_t toneIdentifier, const ZUNOCommandHandlerOption_t *options);
static int _basic_set(byte channel, const ZwBasicSetFrame_t *paket, const ZUNOCommandHandlerOption_t *options) {
size_t value;
size_t type;

Expand All @@ -170,7 +170,7 @@ static int _basic_set(byte channel, const ZwBasicSetFrame_t *paket) {
switch (type) {
#if defined(WITH_CC_SOUND_SWITCH)
case ZUNO_SOUND_SWITCH_CHANNEL_NUMBER:
return (zuno_CCSoundSwitchBasicSet(channel, value));
return (zuno_CCSoundSwitchBasicSet(channel, value, options));
break ;
#endif
}
Expand Down Expand Up @@ -228,15 +228,15 @@ static int _basic_get(byte channel, ZUNOCommandPacketReport_t *frame_report) {
return (ZUNO_COMMAND_ANSWERED);
}

int zuno_CCBasicHandler(byte channel, const ZUNOCommandCmd_t *cmd, ZUNOCommandPacketReport_t *frame_report) {
int zuno_CCBasicHandler(byte channel, const ZUNOCommandCmd_t *cmd, ZUNOCommandPacketReport_t *frame_report, const ZUNOCommandHandlerOption_t *options) {
int rs;

switch(ZW_CMD){
case BASIC_GET:
rs = _basic_get(channel, frame_report);
break ;
case BASIC_SET:
rs = _basic_set(channel, (const ZwBasicSetFrame_t *)cmd->cmd);
rs = _basic_set(channel, (const ZwBasicSetFrame_t *)cmd->cmd, options);
break ;
default:
rs = ZUNO_COMMAND_BLOCKED_NO_SUPPORT;
Expand Down
2 changes: 1 addition & 1 deletion hardware/arduino/zunoG2/cores/ZWSupport/ZWCCBasic.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ void __zuno_BasicUniversalTimerStop(uint8_t channel);
void __zuno_BasicUniversalDimingStop(uint8_t channel);
void __zuno_BasicUniversalGetCurrentValueDurationTargetValue(uint8_t channel, uint8_t *current_value, uint8_t *duration_table_8, uint8_t *target_value);

int zuno_CCBasicHandler(byte channel, const ZUNOCommandCmd_t *cmd, ZUNOCommandPacketReport_t *frame_report);
int zuno_CCBasicHandler(byte channel, const ZUNOCommandCmd_t *cmd, ZUNOCommandPacketReport_t *frame_report, const ZUNOCommandHandlerOption_t *options);
#endif // BASIC_CC_H
21 changes: 12 additions & 9 deletions hardware/arduino/zunoG2/cores/ZWSupport/ZWCCSoundSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static int _soundSwitchConfigurationSet(const ZW_SOUND_SWITCH_CONFIGURATION_SET_
return (ZUNO_COMMAND_PROCESSED);
}

static int _soundSwitchTonePlaySetAdd(size_t channel, size_t toneIdentifier, size_t playCommandToneVolume) {
static int _soundSwitchTonePlaySetAdd(size_t channel, size_t toneIdentifier, size_t playCommandToneVolume, const ZUNOCommandHandlerOption_t *options) {
uint16_t sec_duration;
uint64_t time_stamp;
const ZunoSoundSwitchParameterArray_t *parameter_array;
Expand Down Expand Up @@ -271,12 +271,12 @@ static int _soundSwitchTonePlaySetAdd(size_t channel, size_t toneIdentifier, siz
parameter_diming->current_value = playCommandToneVolume;
parameter_diming->target_value = toneIdentifier;
parameter_diming->type = zunoTimerTreadDimingTypeSoundSwitch;
zunoTimerTreadDimingAdd(parameter_diming);
zunoTimerTreadDimingAdd(parameter_diming, options);
_zunoSoundSwitchPlay(channel, toneIdentifier, playCommandToneVolume);
return (result);
}

static int _soundSwitchTonePlaySet(const ZwSoundSwitchTonePlayFrame_t *frame, size_t channel, size_t len) {
static int _soundSwitchTonePlaySet(const ZwSoundSwitchTonePlayFrame_t *frame, size_t channel, size_t len, const ZUNOCommandHandlerOption_t *options) {
size_t toneIdentifier;
size_t playCommandToneVolume;
ZwSoundSwitchSave_t switch_save;
Expand All @@ -295,10 +295,10 @@ static int _soundSwitchTonePlaySet(const ZwSoundSwitchTonePlayFrame_t *frame, si
return (ZUNO_COMMAND_BLOCKED_FAILL);
break ;
}
return (_soundSwitchTonePlaySetAdd(channel, toneIdentifier, playCommandToneVolume));
return (_soundSwitchTonePlaySetAdd(channel, toneIdentifier, playCommandToneVolume, options));
}

int zuno_CCSoundSwitchHandler(uint8_t channel, const ZUNOCommandCmd_t *cmd, ZUNOCommandPacketReport_t *frame_report) {
int zuno_CCSoundSwitchHandler(uint8_t channel, const ZUNOCommandCmd_t *cmd, ZUNOCommandPacketReport_t *frame_report, const ZUNOCommandHandlerOption_t *options) {
int rs;

switch (ZW_CMD) {
Expand All @@ -307,7 +307,7 @@ int zuno_CCSoundSwitchHandler(uint8_t channel, const ZUNOCommandCmd_t *cmd, ZUNO
rs = zuno_CCSoundSwitchReport(channel, &frame_report->info);
break ;
case SOUND_SWITCH_TONE_PLAY_SET_V2:
rs = _soundSwitchTonePlaySet((const ZwSoundSwitchTonePlayFrame_t *)&cmd->cmd[0x0], channel, cmd->len);
rs = _soundSwitchTonePlaySet((const ZwSoundSwitchTonePlayFrame_t *)&cmd->cmd[0x0], channel, cmd->len, options);
if (rs == ZUNO_COMMAND_PROCESSED)
_config_report_asyn(channel);
break ;
Expand All @@ -331,14 +331,17 @@ int zuno_CCSoundSwitchHandler(uint8_t channel, const ZUNOCommandCmd_t *cmd, ZUNO
}

void zuno_CCSoundSwitchPlay(uint8_t channel, uint8_t toneIdentifier, uint8_t playCommandToneVolume) {
ZUNOCommandHandlerOption_t options;

if (channel == 0x0)
return ;
channel--;
if (channel >= ZUNO_CFG_CHANNEL_COUNT)
return ;
if (ZUNO_CFG_CHANNEL(channel).type != ZUNO_SOUND_SWITCH_CHANNEL_NUMBER)
return ;
_soundSwitchTonePlaySetAdd(channel, toneIdentifier, playCommandToneVolume);
options = ZUNO_COMMAND_HANDLER_OPTIONS_DEFAULT();
_soundSwitchTonePlaySetAdd(channel, toneIdentifier, playCommandToneVolume, &options);
}

void zuno_CCSoundSwitchStop(uint8_t channel) {
Expand Down Expand Up @@ -381,11 +384,11 @@ bool zuno_CCSoundSwitchIsRun(uint8_t channel) {
return (true);
}

int zuno_CCSoundSwitchBasicSet(size_t channel, size_t toneIdentifier) {
int zuno_CCSoundSwitchBasicSet(size_t channel, size_t toneIdentifier, const ZUNOCommandHandlerOption_t *options) {
ZwSoundSwitchSave_t switch_save;

zunoSoundSwitchSaveGet(channel, &switch_save);
return (_soundSwitchTonePlaySetAdd(channel, toneIdentifier, switch_save.volume));
return (_soundSwitchTonePlaySetAdd(channel, toneIdentifier, switch_save.volume, options));
}

#include "ZWCCZWavePlusInfo.h"
Expand Down
2 changes: 1 addition & 1 deletion hardware/arduino/zunoG2/cores/ZWSupport/ZWCCSoundSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ typedef struct ZunoSoundSwitchParameterArray_s

bool zuno_CCSoundSwitchIsRun(uint8_t channel);

int zuno_CCSoundSwitchHandler(uint8_t channel, const ZUNOCommandCmd_t *cmd, ZUNOCommandPacketReport_t *frame_report);
int zuno_CCSoundSwitchHandler(uint8_t channel, const ZUNOCommandCmd_t *cmd, ZUNOCommandPacketReport_t *frame_report, const ZUNOCommandHandlerOption_t *options);
int zuno_CCSoundSwitchReport(uint8_t channel, ZUNOCommandPacket_t *packet);
void zuno_CCSoundSwitchPlay(uint8_t channel, uint8_t toneIdentifier, uint8_t playCommandToneVolume);
void zuno_CCSoundSwitchStop(uint8_t channel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static int _set(ZwSwitchBinarySetFrame_t *cmd, size_t len, size_t channel, ZUNOC
parameter->ticks_end = (rtcc_micros() / 1000) + duration;
parameter->target_value = targetValue;
parameter->type = zunoTimerTreadDimingTypeSwitchBinary;
zunoTimerTreadDimingAdd(parameter);
zunoTimerTreadDimingAdd(parameter, options);
return (ZUNO_COMMAND_PROCESSED);
break ;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static void _start_level_set(uint8_t channel, uint8_t current_level) {
__zuno_BasicUniversalSetter1P(channel, current_level);
}

static int _start_level(uint8_t channel, const ZUNOCommandCmd_t *cmd, ZUNOCommandPacketReport_t *frame_report) {// Prepare the structure for dimming
static int _start_level(uint8_t channel, const ZUNOCommandCmd_t *cmd, ZUNOCommandPacketReport_t *frame_report, const ZUNOCommandHandlerOption_t *options) {// Prepare the structure for dimming
const ZwSwitchMultilevelStartLevelChangeFrame_t *pk;
uint32_t step;
uint8_t current_level;
Expand Down Expand Up @@ -104,7 +104,7 @@ static int _start_level(uint8_t channel, const ZUNOCommandCmd_t *cmd, ZUNOComman
zuno_CCSupervisionAsyncProcessedSet(cmd, &parameter->super_vision);
}
parameter->flag = flag;
zunoTimerTreadDimingAdd(parameter);
zunoTimerTreadDimingAdd(parameter, options);
return (ZUNO_COMMAND_PROCESSED);
}

Expand Down Expand Up @@ -169,7 +169,7 @@ static int _set(SwitchMultilevelSetFrame_t *cmd, uint8_t len, uint8_t channel, Z
parameter->target_value = value;
parameter->type = zunoTimerTreadDimingTypeSwitchMultilevel;
parameter->channel = channel;
zunoTimerTreadDimingAdd(parameter);
zunoTimerTreadDimingAdd(parameter, options);
return (ZUNO_COMMAND_PROCESSED);
break ;
default:
Expand Down Expand Up @@ -222,7 +222,7 @@ int zuno_CCSwitchMultilevelHandler(byte channel, const ZUNOCommandCmd_t *cmd, ZU
(pk->v1.properties1 & (1 << 6)) == 0,
(uint8_t*) cmd);
}
rs = _start_level(channel, cmd, frame_report);
rs = _start_level(channel, cmd, frame_report, options);
break ;
case SWITCH_MULTILEVEL_STOP_LEVEL_CHANGE:
zcustom_SWLStartStopHandler(channel,
Expand Down
15 changes: 11 additions & 4 deletions hardware/arduino/zunoG2/cores/ZWSupport/ZWCCTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ zunoTimerTreadDiming_t *zunoTimerTreadDimingCreate(void) {
return (list);
}

void zunoTimerTreadDimingAdd(zunoTimerTreadDiming_t *list) {
void zunoTimerTreadDimingAdd(zunoTimerTreadDiming_t *list, const ZUNOCommandHandlerOption_t *options) {
zunoEnterCritical();
list->options = options[0x0];
list->next = _diming;
_diming = list;
g_sleep_data.latch++;
Expand Down Expand Up @@ -141,7 +142,6 @@ static bool _zunoTimerTreadDimingLoop_set(zunoTimerTreadDiming_t *list, uint8_t
__zuno_BasicUniversalSetter1P(list->channel, new_value);
break ;
}
zunoSendReport(list->channel + 0x1);
return (true);
}

Expand Down Expand Up @@ -170,8 +170,15 @@ static bool _zunoTimerTreadDimingLoop(zunoTimerTreadDiming_t *list) {
return (false);
}

void zunoTimerTreadDimingLoopReportSet(ZUNOCommandPacketReport_t *frame_report, const zunoTimerTreadDiming_t *list) {
if ((list->flag & ZUNO_TIMER_TREA_DIMING_FLAG_SUPERVISION) != 0x0)
zuno_CCSupervisionReportAsyncProcessed(frame_report, &list->super_vision);
zunoSendReportSet(list->channel, &list->options);
}

void zunoTimerTreadDimingLoop(ZUNOCommandPacketReport_t *frame_report) {
zunoTimerTreadDiming_t *list;
zunoTimerTreadDiming_t list_tmp;
zunoTimerTreadDiming_t *list_array[0x10];
zunoTimerTreadDiming_t *prev;
size_t i;
Expand Down Expand Up @@ -204,11 +211,11 @@ void zunoTimerTreadDimingLoop(ZUNOCommandPacketReport_t *frame_report) {
while (i < i_max) {
list = list_array[i];
i++;
if ((list->flag & ZUNO_TIMER_TREA_DIMING_FLAG_SUPERVISION) != 0x0)
zuno_CCSupervisionReportAsyncProcessed(frame_report, &list->super_vision);
zunoEnterCritical();
list_tmp = list[0x0];
_free_list(list);
zunoExitCritical();
zunoTimerTreadDimingLoopReportSet(frame_report, &list_tmp);
}
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion hardware/arduino/zunoG2/cores/ZWSupport/ZWCCTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ typedef struct zunoTimerTreadDiming_s
uint64_t ticks_end;
ZwCSuperVisionReportAsyncProcessed_t super_vision;
zunoTimerTreadDimingType_t type;
ZUNOCommandHandlerOption_t options;
uint8_t flag;
uint8_t channel;
uint8_t target_value;
Expand All @@ -40,7 +41,7 @@ bool zunoTimerTreadDimingGetValues(zunoTimerTreadDimingType_t type, uint8_t chan
bool zunoTimerTreadDimingGetValues(zunoTimerTreadDimingType_t type, uint8_t channel, uint8_t current_value, uint8_t *duration_table_8, uint8_t *target_value, const void *data, uint8_t length);
void zunoTimerTreadDimingStop(zunoTimerTreadDimingType_t type, uint8_t channel);
void zunoTimerTreadDimingStop(zunoTimerTreadDimingType_t type, uint8_t channel, const void *data, uint8_t length);
void zunoTimerTreadDimingAdd(zunoTimerTreadDiming_t *list);
void zunoTimerTreadDimingAdd(zunoTimerTreadDiming_t *list, const ZUNOCommandHandlerOption_t *options);
zunoTimerTreadDiming_t *zunoTimerTreadDimingCreate(void);

#define ZUNO_TIMER_SWITCH_MAX_VALUE 0x63//Maximum value when dimming
Expand Down
12 changes: 6 additions & 6 deletions hardware/arduino/zunoG2/cores/ZWSupport/ZWCCWindowCovering.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static int _set(uint8_t channel, const ZW_WINDOW_COVERING_SET_1BYTE_FRAME *paket
parameter->target_value = targetValue;
parameter->step = step;
parameter->ticks_end = (rtcc_micros() / 1000) + duration;
zunoTimerTreadDimingAdd(parameter);
zunoTimerTreadDimingAdd(parameter, options);
}
i++;
}
Expand Down Expand Up @@ -176,7 +176,7 @@ static int _get(uint8_t channel, const ZW_WINDOW_COVERING_GET_FRAME *paket, ZUNO
return (ZUNO_COMMAND_ANSWERED);
}

static int _start_level_sdfdsfgsd(uint8_t channel, uint8_t parameterId, uint8_t duration, uint8_t targetValue, uint8_t flag) {
static int _start_level_sdfdsfgsd(uint8_t channel, uint8_t parameterId, uint8_t duration, uint8_t targetValue, uint8_t flag, const ZUNOCommandHandlerOption_t *options) {
uint8_t currentValue;
size_t step;
zunoTimerTreadDiming_t *parameter;
Expand All @@ -202,11 +202,11 @@ static int _start_level_sdfdsfgsd(uint8_t channel, uint8_t parameterId, uint8_t
else
step = step * (currentValue - targetValue);
parameter->ticks_end = (rtcc_micros() / 1000) + step;
zunoTimerTreadDimingAdd(parameter);
zunoTimerTreadDimingAdd(parameter, options);
return (ZUNO_COMMAND_PROCESSED);
}

static int _start_level_change(uint8_t channel, const ZW_WINDOW_COVERING_START_LEVEL_CHANGE_FRAME *paket) {
static int _start_level_change(uint8_t channel, const ZW_WINDOW_COVERING_START_LEVEL_CHANGE_FRAME *paket, const ZUNOCommandHandlerOption_t *options) {
uint32_t mask;
uint8_t parameterId;
uint8_t targetValue;
Expand All @@ -224,7 +224,7 @@ static int _start_level_change(uint8_t channel, const ZW_WINDOW_COVERING_START_L
targetValue = 0x0;
flag = ZUNO_TIMER_TREA_DIMING_FLAG_MODE_DOWN;
}
return (_start_level_sdfdsfgsd(channel, parameterId, paket->duration, targetValue, flag));
return (_start_level_sdfdsfgsd(channel, parameterId, paket->duration, targetValue, flag, options));
}

static int _stop_level_change(uint8_t channel, const ZW_WINDOW_COVERING_STOP_LEVEL_CHANGE_FRAME *paket) {
Expand All @@ -249,7 +249,7 @@ int zuno_CCWindowCoveringHandler(uint8_t channel, const ZUNOCommandCmd_t *cmd, Z
rs = _get(channel, (const ZW_WINDOW_COVERING_GET_FRAME *)cmd->cmd, frame_report);
break ;
case WINDOW_COVERING_START_LEVEL_CHANGE:
rs = _start_level_change(channel, (const ZW_WINDOW_COVERING_START_LEVEL_CHANGE_FRAME *)cmd->cmd);
rs = _start_level_change(channel, (const ZW_WINDOW_COVERING_START_LEVEL_CHANGE_FRAME *)cmd->cmd, options);
break ;
case WINDOW_COVERING_STOP_LEVEL_CHANGE:
rs = _stop_level_change(channel, (const ZW_WINDOW_COVERING_STOP_LEVEL_CHANGE_FRAME *)cmd->cmd);
Expand Down
6 changes: 3 additions & 3 deletions hardware/arduino/zunoG2/cores/ZWSupport/ZWSupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,11 +1047,11 @@ int zuno_CommandHandler(ZUNOCommandCmd_t *cmd) {
LOGGING_UART.print("CHANNEL WAS FOUND:");
LOGGING_UART.println(zuno_ch);
#endif
options = ZUNO_COMMAND_HANDLER_DEFAULT(cmd->src_node, multi, supervision, ZW_CMD_CLASS);
options = ZUNO_COMMAND_HANDLER_OPTIONS(cmd->src_node, multi, supervision, ZW_CMD_CLASS);
switch(ZW_CMD_CLASS) {
#ifdef WITH_CC_BASIC
case COMMAND_CLASS_BASIC:
result = zuno_CCBasicHandler(zuno_ch, cmd, &frame_report);
result = zuno_CCBasicHandler(zuno_ch, cmd, &frame_report, &options);
break;
#endif
#ifdef WITH_CC_SWITCH_BINARY
Expand Down Expand Up @@ -1101,7 +1101,7 @@ int zuno_CommandHandler(ZUNOCommandCmd_t *cmd) {
#endif
#ifdef WITH_CC_SOUND_SWITCH
case COMMAND_CLASS_SOUND_SWITCH:
result = zuno_CCSoundSwitchHandler(zuno_ch, cmd, &frame_report);
result = zuno_CCSoundSwitchHandler(zuno_ch, cmd, &frame_report, &options);
break;
#endif
#ifdef WITH_CC_THERMOSTAT_MODE
Expand Down
10 changes: 9 additions & 1 deletion hardware/arduino/zunoG2/cores/ZWSupport/ZWSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,22 @@ typedef struct ZUNOCommandHandlerOption_s
uint8_t cmd_class;
} ZUNOCommandHandlerOption_t;

#define ZUNO_COMMAND_HANDLER_DEFAULT(_src_node, _multi, _supervision, _cmd_class) \
#define ZUNO_COMMAND_HANDLER_OPTIONS(_src_node, _multi, _supervision, _cmd_class) \
{ \
.src_node = _src_node, \
.multi = _multi, \
.supervision = _supervision, \
.cmd_class = _cmd_class, \
} \

#define ZUNO_COMMAND_HANDLER_OPTIONS_DEFAULT() \
{ \
.src_node = 0x0, \
.multi = false, \
.supervision = false, \
.cmd_class = COMMAND_CLASS_UNKNOWN, \
} \

typedef struct ZUNOCommandReport_t
{
node_id_t src_node;
Expand Down

0 comments on commit 577174c

Please sign in to comment.