Exemple #1
0
        private void ProcessSmsResult(bool ok)
        {
            if (!ok)
            {
                OutboundSMS sms = _outSmses.Peek();
                if (sms.Attempt < sms.MaxTries)
                {
                    NihLog.Write(NihLog.Level.Info, "Retrying sms...");
                    return;
                }

                NihLog.Write(NihLog.Level.Error, "Failed to send SMS: " + sms.ToString());
            }

            _outSmses.Dequeue();
        }
Exemple #2
0
        private void SendSmsNow()
        {
            OutboundSMS sms = _outSmses.Peek();

            sms.Attempt++;
            if (sms.Attempt > sms.MaxTries)
            {
                NihLog.Write(NihLog.Level.Error, "Failure to send after " + sms.MaxTries + " tries");
                _outSmses.Dequeue();
                return;
            }

            NihLog.Write(NihLog.Level.Info, "Sending SMS: " + sms.ToString());
            WriteToModem("AT+CMGS=\"" + sms.Destination + "\"\r");
            System.Threading.Thread.Sleep(500);
            WriteToModem(sms.Text);

            byte[] buffer = new byte[1];
            buffer[0] = 26;     // ^Z
            modemPort.Write(buffer, offset: 0, count: 1);

            CurrentModemState = ModemState.SendingSMS;
        }