From efad979b6fae76fb37a4de7e94e6bac0a85cb72c Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 30 十一月 2021 13:14:28 +0800 Subject: [PATCH] 2021-11-30 1.修复乐橙Android,没调用拒接接口问题。 --- HDL_ON/DAL/DriverLayer/A_Protocol_Common.cs | 227 ++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 147 insertions(+), 80 deletions(-) diff --git a/HDL_ON/DAL/DriverLayer/A_Protocol_Common.cs b/HDL_ON/DAL/DriverLayer/A_Protocol_Common.cs index 66b8de0..550bce8 100644 --- a/HDL_ON/DAL/DriverLayer/A_Protocol_Common.cs +++ b/HDL_ON/DAL/DriverLayer/A_Protocol_Common.cs @@ -5,90 +5,25 @@ { public class A_Protocal_Common { - public static A_Protocal_Common apc; - - public A_Protocal_Common() - { - apc = new A_Protocal_Common(); - } - /// <summary> - /// 鑾峰彇13浣嶆椂闂存埑 - /// </summary> - /// <param name="time">鏃堕棿</param> - /// <returns>long</returns> - public long Get_time_stamp() - { - //DateTime startTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); - long t = DateTime.Now.Ticks / 10000; //闄�10000璋冩暣涓�13浣� - return t; - } - /// <summary> - /// 杞崲閫氳鏁版嵁 - /// </summary> - public byte[] ConvertSendBodyData(string topic, string bodyDataString) - { - string topicString = "Topic:" + topic + "/r/n"; - byte[] bodyBytes = Encoding.ASCII.GetBytes(bodyDataString); - string lenghtString = "Length:" + bodyBytes.Length.ToString() + "/r/n" + "/r/n"; - - string sendDataString = topicString + lenghtString + bodyDataString; - byte[] sendDataBytes = Encoding.ASCII.GetBytes(sendDataString); - - return sendDataBytes; - } - /// <summary> - /// 杞崲鎺ユ敹鍒扮殑鏁版嵁 - /// </summary> - /// <returns></returns> - public string ConvertReceiveData(byte[] bytes) - { - string receiveString = ""; - - string topic = ""; - int lenght = 0; - - var reString = System.Text.Encoding.UTF8.GetString(bytes); - var res = reString.Split("/r/n/r/n"); - - - if (res.Length == 2) - { - var topics = res[0].Split("/r/n"); - foreach (var ts in topics) - { - var key = ts.Split(":"); - switch (key[0]) - { - case "Topic": - topic = key[1]; - break; - case "Lenght": - lenght = Convert.ToInt32(key[1]); - break; - } - } - - switch (topic) - { - case CommunicationTopic.SearchLoaclGateway: - var jt = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack>(res[1]); - if (jt != null) - { - var device = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.DeviceModule>(jt.objects.ToString()); - //Newtonsoft.Json.Linq.JObject.FromObject(jt.objects); - } - break; - } - - } - return receiveString; - } } + /// <summary> - /// 閫氳鍥炲鏁版嵁鍖� + /// 鏈湴閫氳鏁版嵁 + /// </summary> + public class LocalCommunicationData + { + public string Topic; + public int Length; + + public string BodyDataString; + + } + + /// <summary> + /// 閫氳鍥炲鏈夋晥鏁版嵁 /// </summary> public class ResponsePack { @@ -101,11 +36,143 @@ /// <summary> /// 閫氳涓婚 /// </summary> - public static class CommunicationTopic + public class CommunicationTopic { + static CommunicationTopic _ct; + public static CommunicationTopic ct + { + get + { + if (_ct == null) + { + _ct = new CommunicationTopic(); + } + return _ct; + } + } /// <summary> /// 鎼滅储鏈湴缃戝叧 /// </summary> public const string SearchLoaclGateway = "/user/all/custom/gateway/search"; + /// <summary> + /// 鎼滅储缃戝叧鍥炲 + /// </summary> + public const string SearchLoaclGatewayReply = "/user/all/custom/gateway/search_reply"; + /// <summary> + /// 缃戝叧骞挎挱鏁版嵁 + /// </summary> + public const string GatewayBroadcast = "/user/all/custom/gateway/broadcast"; + /// <summary> + /// 璋冭瘯杞欢涓婁紶oid鍒楄〃 + /// </summary> + public const string AddDeviceOids = "/user/onpro/custom/device/add"; + /// <summary> + /// 璋冭瘯杞欢涓婁紶鍔熻兘鍒楄〃 + /// </summary> + public const string AddFunctions = "/user/onpro/custom/function/attribute/add"; + /// <summary> + /// 璋冭瘯杞欢鑾峰彇appOid鍒楄〃 + /// </summary> + public const string BusPcGetAppOids = "/user/onpro/custom/device/list/get"; + /// <summary> + /// 璋冭瘯杞欢鑾峰彇appSid鍒楄〃 + /// </summary> + public const string BusPcGetAppSids = "/user/onpro/custom/function/list/get"; + + /// <summary> + /// 鏈湴鎺у埗鍔熻兘鐘舵�佷富棰� + /// </summary> + public string ControlFunctionTopic + { + get + { + return $"/base/{Control.Ins.GatewayId}/thing/property/down"; + } + } + /// <summary> + /// 鏈湴鎺у埗绾㈠璁惧鍔熻兘涓婚 + /// </summary> + public string ControlIrFunctionTopic + { + get + { + return $"/base/${Control.Ins.GatewayId}/thing/property/down"; + } + } + + /// <summary> + /// 璇诲彇鍔熻兘鐘舵�� + /// </summary> + public string ReadStatus + { + get + { + return $"/base/{Control.Ins.GatewayId}/thing/property/read"; + } + } + /// <summary> + /// 缃戝叧涓婃姤璁惧鐘舵�� + /// </summary> + public string GatewayUpStatus + { + get + { + return $"/base/{Control.Ins.GatewayId}/thing/property/up"; + } + } + + /// <summary> + /// 缃戝叧涓婃姤璁惧鐘舵�� + /// 鍘绘帀id瀵规瘮 + /// </summary> + public string GatewayUpSortTopic + { + get + { + return "/thing/property/up"; + } + } + + /// <summary> + /// 鍦烘櫙鎵ц + /// </summary> + public string ControlScene + { + get + { + return $"/user/{Control.Ins.GatewayId}/custom/scene/execute"; + } + } + + /// <summary> + /// 瀹夐槻鎺у埗 + /// </summary> + public string ControlSeurity + { + get + { + return $"/user/{Control.Ins.GatewayId}/custom/security/status/set"; + } + } + /// <summary> + /// 瀹夐槻鐘舵�佹洿鏂� + /// </summary> + public string SecurityStatusUp + { + get + { + return $"/user/{Control.Ins.GatewayId}/custom/security/status/up"; + }///user/1413055228417130497/custom/security/status/up + } + /// <summary> + /// 璇诲彇瀹夐槻鐘舵�佷俊鎭� + /// </summary> + public string ReadSecurityStatus + { + get + { + return $"/user/{Control.Ins.GatewayId}/custom/security/list/get"; + } + } } } \ No newline at end of file -- Gitblit v1.8.0