/// <summary> /// /// </summary> /// <param name="pduData"></param> /// <param name="storeLocation"></param> /// <returns>index of stored message</returns> public int Cmgw(string pduData, CmgwStoreLocation storeLocation) { var length = GetPduDataLength(pduData); var response = ParseResponse(GetATCommandResponse(string.Format("AT+CMGW={0},{1}\r", length, (int)storeLocation))); //response should be ">" if (response != ">") { throw new IOException("Didn't get success response from device."); } response = ParseResponse(GetATCommandResponse(pduData + CtrlZ)); //response is "+CMGW: 5" var m = Regex.Match(response, @"^\+CMGW: (?<idx>\d+)$"); if (!m.Success || !m.Groups["idx"].Success || string.IsNullOrEmpty(m.Groups["idx"].Value)) { throw new IOException("Didn't get success response from device."); } try { return(int.Parse(m.Groups["idx"].Value)); } catch { throw new IOException("Didn't get success response from device."); } }
/// <summary> /// /// </summary> /// <param name="pduData"></param> /// <param name="storeLocation"></param> /// <returns>index of stored message</returns> public int Cmgw(string pduData, CmgwStoreLocation storeLocation) { var length = GetPduDataLength(pduData); var response = ParseResponse(GetATCommandResponse(string.Format("AT+CMGW={0},{1}\r", length, (int)storeLocation))); //response should be ">" if (response != ">") { throw new IOException("Didn't get success response from device."); } response = ParseResponse(GetATCommandResponse(pduData + CtrlZ)); //response is "+CMGW: 5" var m = Regex.Match(response, @"^\+CMGW: (?<idx>\d+)$"); if (!m.Success || !m.Groups["idx"].Success || string.IsNullOrEmpty(m.Groups["idx"].Value)) { throw new IOException("Didn't get success response from device."); } try { return int.Parse(m.Groups["idx"].Value); } catch { throw new IOException("Didn't get success response from device."); } }