/// <summary> /// 注册直连设备 /// </summary> /// <param name="IMEI">设备IMEI号码</param> /// <returns>设备Id</returns> public string RegisterDevice(string IMEI) { string url = $"{_apiRootUrl}/iocm/app/reg/v1.2.0/devices?appId={_appId}"; Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("app_key", _appId); headers.Add("Authorization", $"Bearer {_accessToken}"); Dictionary <string, object> paramters = new Dictionary <string, object>(); paramters.Add("appId", _appId); paramters.Add("verifyCode", IMEI); paramters.Add("nodeId", IMEI); paramters.Add("timeout", 0); string resData = HttpHelper.PostData(url, paramters, headers, ContentType.Json, _cerFile); string deviceId = JsonConvert.DeserializeObject <JObject>(resData)["deviceId"]?.ToString(); UpdateDeviceInfoReqDTO deviceInfo = new UpdateDeviceInfoReqDTO { name = IMEI, deviceType = "CarLock", model = "CarLockNBIOT", protocolType = "CoAP", manufacturerId = "wuxiang", manufacturerName = "wuxiang" }; ChangeDeviceInfo(deviceId, deviceInfo); return(deviceId); }
/// <summary> /// 修改设备信息 /// </summary> /// <param name="deviceId">设备ID</param> /// <param name="deviceInfo">设备信息</param> public void ChangeDeviceInfo(string deviceId, UpdateDeviceInfoReqDTO deviceInfo) { string url = $"{_apiRootUrl}/iocm/app/dm/v1.2.0/devices/{deviceId}"; Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("app_key", _appId); headers.Add("Authorization", $"Bearer {_accessToken}"); HttpHelper.RequestData("PUT", url, JsonConvert.SerializeObject(deviceInfo), "application/json", headers, _cerFile); }