private static string Parse(AtResponse response) { if (!response.IsOk) throw new XBeeException("Failed to read node identifier"); return Arrays.ToString(response.Value); }
public static ApiModes Parse(AtResponse response) { if (!response.IsOk) throw new XBeeException("Attempt to query AP parameter failed"); return (ApiModes) response.Value[0]; }
public static string Parse(AtResponse response) { if (!response.IsOk) throw new XBeeException("Attempt to query HV parameter failed"); return ByteUtils.ToBase16(response.Value); }
public void SendTemplateMessage(TemplateMessage request, TemplateMessageResponse response) { AtResponse wxr = GetAcc(); if (String.IsNullOrEmpty(wxr.Expires_in)) { throw new WeChatException("GET_ACCESSTOKEN_FAIL", "获取AccessToken失败"); } Hashtable s1 = new Hashtable { { @"keynote1", request.keynote1 }, { @"keynote2", request.keynote2 } }; string data = XmlAndJsonToHash.HashTableToXml(s1); Hashtable s2 = new Hashtable { { @"touser", request.touser }, { @"template_id", request.template_id }, { @"url", request.url }, { @"data", data } }; string postData = XmlAndJsonToHash.HashTableToXml(s2); String wxResult = HttpRequestUtil.HttpPost(string.Format(TemplateMessageUrl, wxr.Access_token), postData); TmResponse tr = JsonHelper.Deserialize <TmResponse>(wxResult); if (tr.errmsg.ToUpper() == "OK") { response.errcode = tr.errcode; response.errmsg = tr.errmsg; response.ResponseStatus.ErrorCode = "OK"; } else { throw new WeChatException("SendTemplateMessage_fail", "发送模板消息失败"); } }
public static HardwareVersions Parse(AtResponse response) { if (!response.IsOk) throw new XBeeException("Attempt to query remote HV parameter failed"); return (HardwareVersions)response.Value[0]; }
public static DiscoverResult Parse(AtResponse response) { if (response.Command != (ushort) AtCmd.NodeDiscover) throw new ArgumentException("This method is only applicable for the ND command"); // empty response is received after the last disovered node // this happens only with Wpan nodes, not Zigbee if (response.Value == null || response.Value.Length == 0) return null; var input = new InputStream(response.Value); var frame = new DiscoverResult { NodeInfo = new NodeInfo { NetworkAddress = new XBeeAddress16(input.Read(2)), SerialNumber = new XBeeAddress64(input.Read(8)), }, Rssi = -1 * input.Read() }; byte ch; // NI is terminated with 0 while ((ch = input.Read()) != 0) if (ch > 32 && ch < 126) frame.NodeInfo.NodeIdentifier += (char)ch; return frame; }
public static DiscoverResult Parse(AtResponse response) { if (response.Command != (ushort) AtCmd.NodeDiscover) throw new ArgumentException("This method is only applicable for the ND command"); var input = new InputStream(response.Value); var frame = new DiscoverResult { NodeInfo = new NodeInfo { NetworkAddress = new XBeeAddress16(input.Read(2)), SerialNumber = new XBeeAddress64(input.Read(8)) } }; byte ch; // NI is terminated with 0 while ((ch = input.Read()) != 0) if (ch > 32 && ch < 126) frame.NodeInfo.NodeIdentifier += (char)ch; frame.Parent = new XBeeAddress16(input.Read(2)); frame.NodeType = (NodeType) input.Read(); frame.Status = input.Read(); frame.ProfileId = input.Read(2); frame.MfgId = input.Read(2); return frame; }
/// <summary> /// TODO: Update Comments /// /// </summary> /// <param name="response" type="NETMF.OpenSource.XBee.Api.AtResponse"> /// <para> /// /// </para> /// </param> public static void Parse(AtResponse response) { if (!response.IsOk) { throw new XBeeException("Failed to save settings"); } }
public static HardwareVersions Parse(AtResponse response) { if (!response.IsOk) { throw new XBeeException("Attempt to query remote HV parameter failed"); } return((HardwareVersions)response.Value[0]); }
public static ApiModes Parse(AtResponse response) { if (!response.IsOk) { throw new XBeeException("Attempt to query AP parameter failed"); } return((ApiModes)response.Value[0]); }
private static string Parse(AtResponse response) { if (!response.IsOk) { throw new XBeeException("Failed to read node identifier"); } return(Arrays.ToString(response.Value)); }
private AtResponse GetAcc() { var appId = ConfigurationManager.AppSettings["APPID"]; var appsecret = ConfigurationManager.AppSettings["APPSECRET"]; String wxResult = HttpRequestUtil.HttpGet(string.Format(AccessTokenUrl, appId, appsecret)); AtResponse wxr = JsonHelper.Deserialize <AtResponse>(wxResult); return(wxr); }
public static string Parse(AtResponse response) { if (!response.IsOk) { throw new XBeeException("Attempt to query HV parameter failed"); } return(ByteUtils.ToBase16(response.Value)); }
private static XBeeAddress64 Parse(AtResponse sl, AtResponse sh) { if (!sh.IsOk || !sl.IsOk) throw new XBeeException("Failed to read serial number"); var data = new OutputStream(); data.Write(sh.Value); data.Write(sl.Value); return new XBeeAddress64(data.ToArray()); }
private static XBeeAddress64 Parse(AtResponse sl, AtResponse sh) { if (!sh.IsOk || !sl.IsOk) { throw new XBeeException("Failed to read serial number"); } var data = new OutputStream(); data.Write(sh.Value); data.Write(sl.Value); return(new XBeeAddress64(data.ToArray())); }
public static IoSampleResponse ParseIsSample(AtResponse response) { if (response.Command != (ushort)Common.AtCmd.ForceSample) { throw new ArgumentException("This is only applicable to the 'IS' AT command"); } var input = new InputStream(response.Value); var sample = new IoSampleResponse(); //sample.ParseIoSample(input); return(sample); }
public void GetAccessToken(AccessToken request, AccessTokenResponse response) { AtResponse wxr = GetAcc(); if (String.IsNullOrEmpty(wxr.Expires_in)) { response.ResponseStatus.ErrorCode = wxr.Errcode; response.ResponseStatus.Message = wxr.Errmsg; } else { response.AccessToken = wxr.Access_token; response.ExpiresIn = wxr.Expires_in; response.ResponseStatus.ErrorCode = "OK"; } }
public static DiscoverResult Parse(AtResponse response) { if (response.Command != (ushort)AtCmd.NodeDiscover) { throw new ArgumentException("This method is only applicable for the ND command"); } // empty response is received after the last disovered node // this happens only with Wpan nodes, not Zigbee if (response.Value == null || response.Value.Length == 0) { return(null); } var input = new InputStream(response.Value); var frame = new DiscoverResult { NodeInfo = new NodeInfo { NetworkAddress = new XBeeAddress16(input.Read(2)), SerialNumber = new XBeeAddress64(input.Read(8)), }, Rssi = -1 * input.Read() }; byte ch; // NI is terminated with 0 while ((ch = input.Read()) != 0) { if (ch > 32 && ch < 126) { frame.NodeInfo.NodeIdentifier += (char)ch; } } return(frame); }
public static DiscoverResult Parse(AtResponse response) { if (response.Command != (ushort)AtCmd.NodeDiscover) { throw new ArgumentException("This method is only applicable for the ND command"); } var input = new InputStream(response.Value); var frame = new DiscoverResult { NodeInfo = new NodeInfo { NetworkAddress = new XBeeAddress16(input.Read(2)), SerialNumber = new XBeeAddress64(input.Read(8)) } }; byte ch; // NI is terminated with 0 while ((ch = input.Read()) != 0) { if (ch > 32 && ch < 126) { frame.NodeInfo.NodeIdentifier += (char)ch; } } frame.Parent = new XBeeAddress16(input.Read(2)); frame.NodeType = (NodeType)input.Read(); frame.Status = input.Read(); frame.ProfileId = input.Read(2); frame.MfgId = input.Read(2); return(frame); }
/* * Returns error code from response * Assumes AT+CMEE=1 (numeric) mode */ public static AtCmeError GetCmeError(AtResponse response) { if (response.Success) { return(AtCmeError.CME_SUCCESS); } if (response.FinalResponse == null || !response.FinalResponse.StartsWith("+CME ERROR:")) { return(AtCmeError.CME_ERROR_NON_CME); } if (!AtTokenizer.TokenizeStart(response.FinalResponse, out string tokenizerResponse)) { return(AtCmeError.CME_ERROR_NON_CME); } if (!AtTokenizer.TokenizeNextInt(tokenizerResponse, out _, out int ret)) { return(AtCmeError.CME_ERROR_NON_CME); } return((AtCmeError)ret); }
public static IoSampleResponse ParseIsSample(AtResponse response) { if (response.Command != (ushort) Common.AtCmd.ForceSample) throw new ArgumentException("This is only applicable to the 'IS' AT command"); var input = new InputStream(response.Value); var sample = new IoSampleResponse(); //sample.ParseIoSample(input); return sample; }
/// <summary> /// TODO: Update Comments /// /// </summary> /// <param name="response" type="NETMF.OpenSource.XBee.Api.AtResponse"> /// <para> /// /// </para> /// </param> public static void Parse(AtResponse response) { if (!response.IsOk) throw new XBeeException("Failed to save settings"); }
protected int GetDiscoverTimeout(AtResponse response) { // ms + 1 extra second return(UshortUtils.ToUshort(response.Value) * 100 + 1000); }