From a68998850eecc59c3f466c4556431d956c8fe707 Mon Sep 17 00:00:00 2001 From: amatilda Date: Fri, 28 Jun 2024 21:35:01 +0300 Subject: [PATCH] add Association binary and sound --- .../cores/ZWSupport/ZWCCAssociation.cpp | 34 +++++++++++++++++++ .../arduino/zunoG2/cores/includes/Arduino.h | 2 ++ 2 files changed, 36 insertions(+) diff --git a/hardware/arduino/zunoG2/cores/ZWSupport/ZWCCAssociation.cpp b/hardware/arduino/zunoG2/cores/ZWSupport/ZWCCAssociation.cpp index 3eb7e34a..f5977eb4 100644 --- a/hardware/arduino/zunoG2/cores/ZWSupport/ZWCCAssociation.cpp +++ b/hardware/arduino/zunoG2/cores/ZWSupport/ZWCCAssociation.cpp @@ -15,6 +15,9 @@ #include "CommandQueue.h" #include "Debug.h" #include "ZWCCWindowCovering.h" +#include "ZWCCSwitchBinary.h" +#include "ZWCCTimer.h" +#include "ZWCCSoundSwitch.h" #define ASSOCIATION_GROUP_ID cmd->cmd[2] #define ASSOCIATION_GROUP_ID_EX(x) x->cmd[2] @@ -538,6 +541,37 @@ static void _send_group(ZUNOCommandPacketReport_t *frame, size_t len) { zunoSendZWPackage(&frame->packet); } +void zunoSendToGroupSoundSwitchCommand(uint8_t groupIndex, uint8_t toneIdentifier, uint8_t playCommandToneVolume) { + ZW_SOUND_SWITCH_TONE_PLAY_SET_V2_FRAME *lp; + ZUNOCommandPacketReport_t frame; + + if (_group_id(groupIndex) != ZUNO_UNKNOWN_CMD) + return ; + _init_group(&frame, groupIndex); + lp = (ZW_SOUND_SWITCH_TONE_PLAY_SET_V2_FRAME *)&frame.packet.cmd[0x0]; + lp->cmdClass = COMMAND_CLASS_SOUND_SWITCH; + lp->cmd = SOUND_SWITCH_TONE_PLAY_SET; + lp->toneIdentifier = toneIdentifier; + lp->playCommandToneVolume = playCommandToneVolume; + _send_group(&frame, sizeof(lp[0x0])); +} + +void zunoSendToGroupBinaryCommand(uint8_t groupIndex, uint8_t targetValue, size_t ms) { + ZwSwitchBinarySetV2Frame_t *lp; + ZUNOCommandPacketReport_t frame; + + if (_group_id(groupIndex) != ZUNO_UNKNOWN_CMD) + return ; + _init_group(&frame, groupIndex); + lp = (ZwSwitchBinarySetV2Frame_t *)&frame.packet.cmd[0x0]; + lp->cmdClass = COMMAND_CLASS_SWITCH_BINARY; + lp->cmd = SWITCH_BINARY_SET; + targetValue = targetValue ? 0xFF : 0x00;// Map the value right way + lp->targetValue = targetValue; + lp->duration = zuno_CCTimerTable8(ms); + _send_group(&frame, sizeof(lp[0x0])); +} + void zunoSendToGroupSetValueCommand(uint8_t groupIndex, uint8_t value) { ZwBasicSetFrame_t *lp; ZUNOCommandPacketReport_t frame; diff --git a/hardware/arduino/zunoG2/cores/includes/Arduino.h b/hardware/arduino/zunoG2/cores/includes/Arduino.h index febb52e9..36df1196 100644 --- a/hardware/arduino/zunoG2/cores/includes/Arduino.h +++ b/hardware/arduino/zunoG2/cores/includes/Arduino.h @@ -156,6 +156,8 @@ void zunoSendToGroupDimmingCommand(uint8_t groupIndex, uint8_t direction, uint8_ void zunoSendToGroupScene(uint8_t groupIndex, uint8_t scene); void zunoSendToGroupDoorlockControlTiming(uint8_t groupIndex, uint8_t open_close, uint16_t seconds); inline void zunoSendToGroupDoorlockControl(uint8_t groupIndex, uint8_t open_close) {return (zunoSendToGroupDoorlockControlTiming(groupIndex, open_close, 0x0));}; +void zunoSendToGroupBinaryCommand(uint8_t groupIndex, uint8_t targetValue, size_t ms); +void zunoSendToGroupSoundSwitchCommand(uint8_t groupIndex, uint8_t toneIdentifier, uint8_t playCommandToneVolume); /* Misc */ void WDOG_Feed();