| | |
| | | /// 新发现的网关通知 |
| | | /// </summary> |
| | | public static Action<ZigBee.Device.ZbGateway> NewGateWayAction; |
| | | /// <summary>
|
| | | /// 上一次的住宅ID
|
| | | /// </summary> |
| | | private static string oldHomeID = string.Empty; |
| | | |
| | | public static void Init() |
| | | { |
| | |
| | | { |
| | | var gateWayList = new List<ZbGateway> { }; |
| | | var searchCount = 6; |
| | | var oldHomeID = string.Empty; |
| | | var broadBytes = new byte[44];// byteHomeId[0] ,//H |
| | | broadBytes[0] = 0xfe; |
| | | broadBytes[1] = 0x29; |
| | |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(Shared.Common.Config.Instance.HomeId)) |
| | | { |
| | | {
|
| | | //住宅ID为空只有一种可能就是退出了登录,这里的上一次住宅ID要清空
|
| | | oldHomeID = "?"; |
| | | System.Threading.Thread.Sleep(1000); |
| | | continue; |
| | | } |
| | |
| | | ZbGateway.IsRemote = true;
|
| | | for (int i = 0; i < ZbGateway.GateWayList.Count; i++) |
| | | {
|
| | | ZbGateway.GateWayList[i].DisConnectLocalMqttClient("1"); |
| | | ZbGateway.GateWayList[i].DisConnectLocalMqttClient("1"); |
| | | }
|
| | | }
|
| | | |
| | |
| | | try |
| | | { |
| | | //定时检测远程连接情况 |
| | | await ZbGateway.StartRemoteMqtt(); |
| | | await ZbGateway.StartRemoteMqtt();
|
| | | if (!ZbGateway.IsRemote) |
| | | { |
| | | System.Threading.Thread.Sleep(500); |
| | | continue; |
| | | } |
| | | var gateWayList =ZbGateway.GateWayList.FindAll(obj => obj.getGatewayBaseInfo.HomeId == Shared.Common.Config.Instance.HomeId); |
| | | var gateWayList = ZbGateway.GateWayList.FindAll(obj => obj.getGatewayBaseInfo.HomeId == Shared.Common.Config.Instance.HomeId); |
| | | |
| | | if (gateWayList.Count == 1) |
| | | { |
| | |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | /// <summary>
|
| | | /// 重新搜索,注意:调用该方法,则促使全部网关的mqtt全部断开,然后重新搜索(可能会有1秒延迟)
|
| | | /// </summary> |
| | | public static void ReSearch()
|
| | | {
|
| | | //为了那么多少万分之一的几率,这里设置成别的另一类的值
|
| | | oldHomeID = "**";
|
| | | } |
| | | |
| | | /// <summary> |
| | | /// 接收处理UDP数据包 |