Skip to content

Commit

Permalink
Tuya Zosung
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Oct 9, 2023
1 parent f1e6420 commit c96ab80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/php/AbeilleCmd-Tuya.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ function tuyaZosungCrc($message) {
$len = strlen($message) / 2;
for($i = 0; $i < $len; $i++) {
$c = substr($message, $i * 2, 2);
cmdLog('debug', " c=${c}, crc=".bin2hex($crc));
$crc += pack("H*", $c);
// cmdLog('debug', " c=${c}, crc=".dechex($crc));
$crc += hexdec($c);
$crc %= 0x100;
}
// cmdLog('debug', " crc=".dechex($crc));
return sprintf("%02X", $crc);
}

Expand Down
14 changes: 14 additions & 0 deletions core/php/AbeilleParser-Tuya.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,20 @@ function tuyaDecodeZosungCmd($net, $addr, $ep, $cmdId, $pl, &$toMon) {
$data = '00'.$seq.'0000';
msgToCmd(PRIO_NORM, "Cmd".$net."/".$addr."/cmd-Generic", "ep=".$ep."&clustId=ED00&cmd=04&data=${data}");
}
} else if ($cmdId == "04") {
// Cmd 04 reminder
// {name: 'zero0', type: DataType.uint8},
// {name: 'seq', type: DataType.uint16},
// {name: 'zero1', type: DataType.uint16},
$seq = substr($pl, 2, 4);
$seqR = AbeilleTools::reverseHex($seq);
parserLog("debug", " Tuya-Zosung cmd ED00-04: Seq=${seqR} => Replying with cmd ED00-05");

// Cmd 05 reminder
// {name: 'seq', type: DataType.uint16},
// {name: 'zero', type: DataType.uint16},
$data = $seq.'0000';
msgToCmd(PRIO_NORM, "Cmd".$net."/".$addr."/cmd-Generic", "ep=".$ep."&clustId=ED00&cmd=05&data=${data}");
} else if ($cmdId == "05") {
// Cmd 05 reminder
// {name: 'seq', type: DataType.uint16},
Expand Down

0 comments on commit c96ab80

Please sign in to comment.