示例#1
0
        static void Main(string[] args)
        {
            Modem modem = new Modem("COM3", 115200);

            while (true)
            {
                PrintMenu();
                ConsoleKeyInfo key = Console.ReadKey(true);
                SMSSubmit      sms = new SMSSubmit();

                switch (key.KeyChar)
                {
                case '1':
                    sms = SampleMessage.PlainText();
                    break;

                case '2':
                    sms = SampleMessage.FlashMessage();
                    break;

                case '3':
                    sms = SampleMessage.ReplacebleMessage("This message will be replaced: FOO");
                    break;

                case '4':
                    sms = SampleMessage.ReplacebleMessage("This is replacement message: BAR");
                    break;

                case '5':
                    sms = SampleMessage.ActivateVoicemailIndication();
                    break;

                case '6':
                    sms = SampleMessage.DeactivateVoicemailIndication();
                    break;

                case '7':
                    sms = SampleMessage.ServiceIndicationMessage();
                    break;

                case '8':
                    sms = SampleMessage.ServiceLoadingMessage();
                    break;

                case '9':
                    sms = SampleMessage.WapPushConfiguration();
                    break;

                case '0':
                    return;
                }

                Console.Write("\nEnter phone number: ");
                sms.PhoneNumber = Console.ReadLine();

                modem.SendSMS(sms);
            }
        }
示例#2
0
        public static SMSSubmit DeactivateVoicemailIndication()
        {
            SMSSubmit sms = new SMSSubmit(new TextMessage());

            sms.Indication.Operation = MessageIndicationOperation.Discard;
            sms.Indication.Type      = IndicationType.Voicemail;
            sms.Indication.IsActive  = false;

            return(sms);
        }
示例#3
0
        public static SMSSubmit ReplacebleMessage(string text)
        {
            TextMessage textMessage = new TextMessage();

            textMessage.Text = text;

            SMSSubmit sms = new SMSSubmit();

            sms.MessageToSend = textMessage;

            sms.ProtocolIdentifier = new ProtocoldentifierBuilder(ShortMessageType.ReplaceMessageType1).ToByte();

            return(sms);
        }
示例#4
0
        public static SMSSubmit FlashMessage()
        {
            TextMessage textMessage = new TextMessage();

            textMessage.DataEncoding = DataEncoding.Default7bit;
            textMessage.Text         = "Flash message from SharpSMS!";

            SMSSubmit sms = new SMSSubmit();

            sms.MessageToSend    = textMessage;
            sms.Indication.Class = MessageClass.ImmediateDisplay;

            return(sms);
        }
示例#5
0
        /// <summary>
        /// Send given message to the serial port and initialize modem
        /// </summary>
        /// <param name="sms"></param>
        public void SendSMS(SMSSubmit sms)
        {
            List <byte[]> messageList = sms.GetPDUList();

            if (!InitModem())
            {
                Console.WriteLine("Error: No response from modem.");
            }

            foreach (byte[] messagePart in messageList)
            {
                SendMessageToModem(messagePart);
                Thread.Sleep(500);
                Console.WriteLine("Message sent to modem.");
            }
        }
示例#6
0
        public static SMSSubmit ActivateVoicemailIndication()
        {
            TextMessage textMessage = new TextMessage();

            textMessage.Text = "You have a voicemail.";

            SMSSubmit sms = new SMSSubmit();

            sms.MessageToSend = textMessage;

            sms.Indication.Operation = MessageIndicationOperation.Discard;
            sms.Indication.Type      = IndicationType.Voicemail;
            sms.Indication.IsActive  = true;

            return(sms);
        }
示例#7
0
        public static SMSSubmit PlainText()
        {
            TextMessage textMessage = new TextMessage();

            textMessage.DataEncoding = DataEncoding.Default7bit;
            textMessage.Text         = "Hello World from SharpSMS!";

            SMSSubmit sms = new SMSSubmit();

            sms.MessageToSend = textMessage;

            // SMS center will retry the delivery for 5 days
            sms.ValidityPeriod = new TimeSpan(5, 0, 0, 0);

            return(sms);
        }