| | |
| | | try { |
| | | busSocket.Bind (new IPEndPoint (IPAddress.Any, port)); |
| | | |
| | | busSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("224.0.168.188"))); |
| | | busSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.0.168.188"))); |
| | | } |
| | | catch{ |
| | | busSocket = null; |
| | | return; |
| | | } |
| | | |
| | | asyncBeginReceive (); |
| | | asyncBeginReceive(); |
| | | |
| | | MainPage.Log ($"udp port : {port}"); |
| | | } |
| | |
| | | Console.WriteLine($"asyncBeginReceive {e.Message}"); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 搜索网络设备触发的回调事件 |
| | | /// </summary> |
| | | public Action<string> SearchNetDeviceAction; |
| | | |
| | | /// <summary> |
| | | /// 异步接收数据结束 |
| | |
| | | jt.TryGetValue("objects", out jto); |
| | | if (jto != null) |
| | | { |
| | | var jt2 = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(jto.ToString()); |
| | | JToken model_id = null; |
| | | jt2.TryGetValue("model_id", out model_id); |
| | | if (model_id != null) |
| | | { |
| | | if (model_id.ToString() == "")//Bus网关 |
| | | { |
| | | var revIp = jt2.GetValue("ip_address").ToString(); |
| | | var revMac = jt2.GetValue("device_mac").ToString(); |
| | | var revName = jt2.GetValue("device_name").ToString(); |
| | | //if (revIp == Entity.DB_ResidenceData.residenceData.residenceGatewayMAC) |
| | | { |
| | | DriverLayer.Control.ins.reportIp = revIp; |
| | | DriverLayer.Control.ins.ChangeCommunicationMode(DriverLayer.CommunicationMode.tcp_local_client); |
| | | } |
| | | } |
| | | else if (model_id.ToString() == "4")//声必可语音面板 |
| | | { |
| | | |
| | | } |
| | | } |
| | | SearchNetDeviceAction?.Invoke(jto.ToString()); |
| | | } |
| | | } |
| | | } |