diff --git a/src/HeboTech.ATLib.Modems/Adafruit/Fona3G.cs b/src/HeboTech.ATLib.Modems/Adafruit/Fona3G.cs index ed0e1c3..0b5dc16 100644 --- a/src/HeboTech.ATLib.Modems/Adafruit/Fona3G.cs +++ b/src/HeboTech.ATLib.Modems/Adafruit/Fona3G.cs @@ -31,161 +31,5 @@ public override async Task SetRequiredSettingsAfterPinAsync() ModemResponse smsMessageFormat = await SetSmsMessageFormatAsync(SmsTextFormat.PDU).ConfigureAwait(false); return currentCharacterSet.Success && smsMessageFormat.Success; } - - //public override async Task> ReadSmsAsync(int index, SmsTextFormat smsTextFormat) - //{ - // switch (smsTextFormat) - // { - // case SmsTextFormat.PDU: - // AtResponse pduResponse = await channel.SendMultilineCommand($"AT+CMGR={index}", null).ConfigureAwait(false); - - // if (pduResponse.Success) - // { - // string line1 = pduResponse.Intermediates[0]; - // var line1Match = Regex.Match(line1, @"\+CMGR:\s(?\d),(""(?\w*)"")*,(?\d+)"); - // string line2 = pduResponse.Intermediates[1]; - // var line2Match = Regex.Match(line2, @"(?[0-9A-Z]*)"); - // if (line1Match.Success && line2Match.Success) - // { - // int statusCode = int.Parse(line1Match.Groups["status"].Value); - // SmsStatus status = (SmsStatus)statusCode; - - // string pdu = line2Match.Groups["status"].Value; - // SmsDeliver pduMessage = SmsDeliverDecoder.Decode(pdu.ToByteArray()); - - // return ModemResponse.IsResultSuccess(new Sms(status, pduMessage.SenderNumber, pduMessage.Timestamp, pduMessage.Message)); - // } - // if (AtErrorParsers.TryGetError(pduResponse.FinalResponse, out Error pduError)) - // return ModemResponse.HasResultError(pduError); - // } - // break; - // case SmsTextFormat.Text: - // AtResponse textResponse = await channel.SendMultilineCommand($"AT+CMGR={index}", null).ConfigureAwait(false); - - // if (textResponse.Success && textResponse.Intermediates.Count > 0) - // { - // string line = textResponse.Intermediates.First(); - // var match = Regex.Match(line, @"\+CMGR:\s""(?[A-Z\s]+)"",""(?\+\d+)"","""",""(?(?\d\d)/(?\d\d)/(?\d\d),(?\d\d):(?\d\d):(?\d\d)(?[-+]\d\d))"",(?\d+),(?\d),(?\d),(?\d),(?""\+\d+""),(?\d+),(?\d+)"); - // if (match.Success) - // { - // SmsStatus status = SmsStatusHelpers.ToSmsStatus(match.Groups["status"].Value); - // PhoneNumberDTO sender = new PhoneNumberDTO(match.Groups["sender"].Value); - // int year = int.Parse(match.Groups["year"].Value); - // int month = int.Parse(match.Groups["month"].Value); - // int day = int.Parse(match.Groups["day"].Value); - // int hour = int.Parse(match.Groups["hour"].Value); - // int minute = int.Parse(match.Groups["minute"].Value); - // int second = int.Parse(match.Groups["second"].Value); - // int zone = int.Parse(match.Groups["zone"].Value); - - // int addressType = int.Parse(match.Groups["addressType"].Value); - // int tpduFirstOctet = int.Parse(match.Groups["tpduFirstOctet"].Value); - // int protocolIdentifier = int.Parse(match.Groups["pid"].Value); - // int dataCodingScheme = int.Parse(match.Groups["dcs"].Value); - // string serviceCenterAddress = match.Groups["serviceCenterAddress"].Value; - // int serviceCenterAddressType = int.Parse(match.Groups["serviceCenterAddressType"].Value); - // int length = int.Parse(match.Groups["length"].Value); - - // DateTimeOffset received = new DateTimeOffset(2000 + year, month, day, hour, minute, second, TimeSpan.FromMinutes(15 * zone)); - // string message = textResponse.Intermediates.Last(); - - // CodingScheme dcs = (CodingScheme)dataCodingScheme; - // if (dcs == CodingScheme.UCS2) - // message = UCS2.Decode(message); - - // return ModemResponse.IsResultSuccess(new Sms(status, sender, received, message)); - // } - // } - // if (AtErrorParsers.TryGetError(textResponse.FinalResponse, out Error textError)) - // return ModemResponse.HasResultError(textError); - // break; - // default: - // throw new NotSupportedException("The format is not supported"); - // } - // return ModemResponse.HasResultError(); - //} - - //public override async Task>> ListSmssAsync(SmsStatus smsStatus) - //{ - // string command = currentSmsTextFormat switch - // { - // CurrentSmsTextFormat.Text => $"AT+CMGL=\"{SmsStatusHelpers.ToString(smsStatus)}\"", - // CurrentSmsTextFormat.PDU => $"AT+CMGL={(int)smsStatus}", - // _ => throw new Exception("Unknown SMS Text Format") - // }; - - // AtResponse response = await channel.SendMultilineCommand(command, null).ConfigureAwait(false); - - // List smss = new List(); - // if (response.Success) - // { - // switch (currentSmsTextFormat) - // { - // case CurrentSmsTextFormat.PDU: - // if ((response.Intermediates.Count % 2) != 0) - // return ModemResponse.HasResultError>(); - - // for (int i = 0; i < response.Intermediates.Count; i += 2) - // { - // string metaDataLine = response.Intermediates[i]; - // string messageLine = response.Intermediates[i + 1]; - // var match = Regex.Match(metaDataLine, @"\+CMGL:\s(?\d+),(?\d+),"""",(?\d+)"); - // if (match.Success) - // { - // int index = int.Parse(match.Groups["index"].Value); - // SmsStatus status = (SmsStatus)int.Parse(match.Groups["status"].Value); - - // // Sent when AT+CSDH=1 is set - // int length = int.Parse(match.Groups["length"].Value); - - // SmsDeliver sms = SmsDeliverDecoder.Decode(messageLine.ToByteArray()); - // smss.Add(new SmsWithIndex(index, status, sms.SenderNumber, sms.Timestamp, sms.Message)); - // } - // } - // break; - // case CurrentSmsTextFormat.Text: - // if ((response.Intermediates.Count % 2) != 0) - // return ModemResponse.HasResultError>(); - - // for (int i = 0; i < response.Intermediates.Count; i += 2) - // { - // string metaDataLine = response.Intermediates[i]; - // string messageLine = response.Intermediates[i + 1]; - // var match = Regex.Match(metaDataLine, @"\+CMGL:\s(?\d+),""(?[A-Z\s]+)"",""(?\+*\d+)"","""",""(?(?\d\d)/(?\d\d)/(?\d\d),(?\d\d):(?\d\d):(?\d\d)(?[-+]\d\d))"",(?\d+),(?\d),(?\d),(?\d),(?""\+\d+""),(?\d+),(?\d+)"); - // if (match.Success) - // { - // int index = int.Parse(match.Groups["index"].Value); - // SmsStatus status = SmsStatusHelpers.ToSmsStatus(match.Groups["status"].Value); - // PhoneNumberDTO sender = new PhoneNumberDTO(match.Groups["sender"].Value); - // int year = int.Parse(match.Groups["year"].Value); - // int month = int.Parse(match.Groups["month"].Value); - // int day = int.Parse(match.Groups["day"].Value); - // int hour = int.Parse(match.Groups["hour"].Value); - // int minute = int.Parse(match.Groups["minute"].Value); - // int second = int.Parse(match.Groups["second"].Value); - // int zone = int.Parse(match.Groups["zone"].Value); - - // // Sent when AT+CSDH=1 is set - // int addressType = int.Parse(match.Groups["addressType"].Value); - // int dataLength = int.Parse(match.Groups["length"].Value); - - // DateTimeOffset received = new DateTimeOffset(2000 + year, month, day, hour, minute, second, TimeSpan.FromMinutes(15 * zone)); - - // string message = messageLine; - // if (messageLine.Length != dataLength) - // message = UCS2.Decode(messageLine); - - // smss.Add(new SmsWithIndex(index, status, sender, received, message)); - // } - // } - // break; - // case CurrentSmsTextFormat.Unknown: - // break; - // default: - // break; - // } - // } - // return ModemResponse.IsResultSuccess(smss); - //} } }