Skip to content

Commit

Permalink
Set ext PAN ID work
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Aug 8, 2024
1 parent 86c9fd5 commit 71bc8b0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
3 changes: 2 additions & 1 deletion core/class/AbeilleCmdProcess.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2512,7 +2512,8 @@ function processCmd($Command) {
$extPanId = $Command['extPanId'];
cmdLog('debug', " zgSetExtendedPanId: extPanId=${extPanId}");

// WARNING: This does not work. Network must not be running to change ext Pan ID but how to do that ??
/* Note: This is NOT FUNCTIONAL.
Zigate always answers 04/busy. Probably because network started automatically */

$this->addCmdToQueue2(PRIO_NORM, $dest, $zgCmd, $extPanId, "0000");
return;
Expand Down
2 changes: 2 additions & 0 deletions core/class/AbeilleCmdQueue.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ function processCmdQueues() {
$GLOBALS['zigates'][$zgId]['cmdQueue'][$priority][$sendIdx]['sentTime'] = time();
$GLOBALS['zigates'][$zgId]['cmdQueue'][$priority][$sendIdx]['try']--;
$GLOBALS['zigates'][$zgId]['tp_time'] = microtime(true) + 0.1; // Next avail time in 100ms
if ($cmd['cmd'] == "0011") // Special case: soft reset
$GLOBALS['zigates'][$zgId]['availTime'] = microtime(true) + 1.0; // Zg will be free in 1sec

if (isset($GLOBALS["dbgMonitorAddr"]) && ($cmd['addr'] != "") && ($GLOBALS["dbgMonitorAddr"] != "") && !strncasecmp($cmd['addr'], $GLOBALS["dbgMonitorAddr"], 4))
monMsgToZigate($cmd['addr'], $cmd['cmd'].'-'.$cmd['datas']); // Monitor this addr ?
Expand Down
45 changes: 29 additions & 16 deletions core/php/AbeilleCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,33 +175,46 @@ function configureZigate($zgId) {
return;
}

msgToCmd("CmdAbeille".$zgId."/0000/zgSoftReset", "");
// msgToCmd("CmdAbeille".$zgId."/0000/zgSoftReset", "");
AbeilleCmdQueue::pushZigateCmd($zgId, PRIO_HIGH, "0011", "", "0000", null);
// Following cmds delayed by 1sec to wait for chip reset

// Extended PAN ID change must be done BEFORE starting network
msgToCmd("TempoCmdAbeille".$zgId."/0000/zgSetExtendedPanId&tempo=".(time()+1), "extPanId=21758D1900481200");
// Note: STILL NOT FUNCTIONAL. Zigate always says "BUSY" !!! Network seems to be automatically started after soft reset even without 0024/Start cmd.
// Note: Experiement was done for Livolo TI0001 case with channel 26 and specific EPANID
// msgToCmd("TempoCmdAbeille".$zgId."/0000/zgSetExtendedPanId&tempo=".(time()+1), "extPanId=21758D1900481200");
// AbeilleCmdQueue::pushZigateCmd($zgId, PRIO_HIGH, "0020", "21758D1900481200", "0000", null);

global $config;
if (isset($config['ab::gtwChan'.$zgId])) {
$chan = $config['ab::gtwChan'.$zgId];
if ($chan == 0)
$mask = 0x7fff800; // All channels = auto
else
$mask = 1 << $chan;
$mask = sprintf("%08X", $mask);
cmdLog('debug', " Settings chan ".$chan." (mask=".$mask.") for zigate ".$zgId);
msgToCmd("TempoCmdAbeille".$zgId."/0000/zgSetChannelMask&tempo=".(time()+1), "mask=".$mask);
}
msgToCmd("TempoCmdAbeille".$zgId."/0000/zgSetTimeServer&tempo=".(time()+1), "");
$chan = isset($config['ab::gtwChan'.$zgId]) ? $config['ab::gtwChan'.$zgId] : 0; // Default = auto (all channels)
if ($chan == 0)
$mask = 0x7fff800; // All channels = auto
else
$mask = 1 << $chan;
$mask = sprintf("%08X", $mask);
cmdLog('debug', " Settings chan ".$chan." (mask=".$mask.") for zigate ".$zgId);
// msgToCmd("TempoCmdAbeille".$zgId."/0000/zgSetChannelMask&tempo=".(time()+1), "mask=".$mask);
AbeilleCmdQueue::pushZigateCmd($zgId, PRIO_HIGH, "0021", $mask, "0000", null);

// msgToCmd("TempoCmdAbeille".$zgId."/0000/zgSetTimeServer&tempo=".(time()+1), "");
$zgRef = mktime(0, 0, 0, 1, 1, 2000); // 2000-01-01 00:00:00
$zgTime = time() - $zgRef;
$data = sprintf("%08s", dechex($zgTime));
AbeilleCmdQueue::pushZigateCmd($zgId, PRIO_HIGH, "0016", $data, "0000", null);

if (isset($config['ab::forceZigateHybridMode']) && ($config['ab::forceZigateHybridMode'] == "Y")) {
$mode = "hybrid";
} else
$mode2 = "02";
} else {
$mode = "raw";
$mode2 = "01";
}
cmdLog('debug', " Configuring Zigate ${zgId} in ${mode} mode");
msgToCmd("TempoCmdAbeille".$zgId."/0000/zgSetMode&tempo=".(time()+1), "mode=${mode}");
// msgToCmd("TempoCmdAbeille".$zgId."/0000/zgSetMode&tempo=".(time()+1), "mode=${mode}");
AbeilleCmdQueue::pushZigateCmd($zgId, PRIO_HIGH, "0002", $mode2, "0000", null);

msgToCmd("TempoCmdAbeille".$zgId."/0000/zgStartNetwork&tempo=".(time()+10), "");
// msgToCmd("TempoCmdAbeille".$zgId."/0000/zgStartNetwork&tempo=".(time()+10), "");
AbeilleCmdQueue::pushZigateCmd($zgId, PRIO_HIGH, "0024", "", "0000", null);

msgToCmd("TempoCmdAbeille".$zgId."/0000/zgGetVersion&tempo=".(time()+10), "");
}
Expand Down
1 change: 1 addition & 0 deletions docs/fr_FR/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Correction: Cmd: Status TX corrigé en 'ok' meme si 'rx OFF when idle'.
- Amélioration: Zigate: Tentative d'ajout possibilité de changer 'Extended PAN ID' pour cas Livolo. Ne fonctionne pas !
- Amélioration: Cmd->Zigate: Cas Zigate 'busy'.
- Amélioration: Cmd/config Zigate.

## 240802-BETA-1

Expand Down

0 comments on commit 71bc8b0

Please sign in to comment.