| | |
| | | /// 红外码学习 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static void CodeStudy(string deviceId, AttributesStatus buttonObj,Action<ResponsePackNew> action) |
| | | public static void CodeStudy(Control control, AttributesStatus buttonObj, Action<Cloud> action) |
| | | { |
| | | var job = new JObject { }; |
| | | job.Add("key", buttonObj.key); |
| | |
| | | job.Add("value", valuejArray); |
| | | var jArray = new JArray { }; |
| | | jArray.Add(job); |
| | | var jObject = new JObject { { "homeId", HomeId }, { "deviceId", deviceId }, { "attributes", jArray } }; |
| | | ResponsePackNew responsePackNew = null; |
| | | var jObject = new JObject { { "homeId", HomeId }, { "deviceId", control.deviceId }, { "attributes", jArray } }; |
| | | Cloud cloud = null; |
| | | new System.Threading.Thread(() => |
| | | { |
| | | |
| | | try |
| | | { |
| | | //发送红外码学习命令 |
| | | responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_CodeStudy); |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_CodeStudy); |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | Method method = new Method(); |
| | | Method.buttondata = ""; |
| | | cloud = method.MqttDate("按键", control.sid, 25); |
| | | } |
| | | else |
| | | { |
| | | Method method = new Method(); |
| | | method.ErrorShow(responsePackNew, ""); |
| | | } |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | action(responsePackNew); |
| | | action(cloud); |
| | | }); |
| | | } |
| | | |
| | |
| | | { IsBackground = true }.Start(); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | ///请求服务器(与住宅有关:例如;homeId) |
| | | /// </summary> |