Ejemplo n.º 1
0
 static void bgs_OnCurrentCallInfo(CallInfo list)
 {
     if (list.Status == CallState.alerting)
         waitEvent.Set();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// The execute command lists all current calls. If the command is successful, but no calls are available, no information response is sent to TE.
        /// </summary>
        /// <returns></returns>
        public CallInfo[] Call_Current_List()
        {
            GeneralResponse re = SendATCommand("AT+CLCC");
            if (re.IsSuccess)
            {
                CallInfo[] list = new CallInfo[re.PayLoad.Length];
                for (int i = 0; i < re.PayLoad.Length; i++)
                {
                    string[] temp = re.PayLoad[i].Split(',');
                    list[i] = new CallInfo();

                    if (temp[0].IndexOf("+CLCC") < 0)
                        continue;

                    list[i].CallIndex = int.Parse(temp[0].Split(' ')[1]);
                    list[i].Dir = (CallDir)int.Parse(temp[1]);
                    list[i].Status = (CallState)int.Parse(temp[2]);
                    list[i].CallMode = (CallMode)int.Parse(temp[3]);
                    list[i].IsMultipartyConferenceCall = temp[4] == "0" ? false : true;
                    if (temp.Length >= 7)
                    {
                        list[i].Number = temp[5].Split('"')[1];
                        list[i].NumberType = (CallNumberType)int.Parse(temp[6]);
                    }
                    if (temp.Length == 8)
                        list[i].EntryInPhonebook = temp[7].Split('"')[1];
                }
                return list;
            }

            return null;
        }
Ejemplo n.º 3
0
 static void m_OnCurrentCallList(CallInfo list)
 {
     Console.WriteLine(list.CallIndex);
     Console.WriteLine(list.CallMode);
     Console.WriteLine(list.Dir);
     Console.WriteLine(list.EntryInPhonebook);
     Console.WriteLine(list.IsMultipartyConferenceCall);
     Console.WriteLine(list.Number);
     Console.WriteLine(list.NumberType);
     Console.WriteLine(list.Status);
 }
Ejemplo n.º 4
0
        private void MessageProcessThread()
        {
            while (isRunning)
            {
                messageWait.WaitOne();

                lock (messageQueue)
                {
                    while (messageQueue.Count > 0)
                    {
                        string message = messageQueue.Dequeue();
                        //System.Diagnostics.Debug.WriteLine(message);
                        int start = message.IndexOf(": ");
                        if (start > 0)
                        {
                            string[] values = message.Substring(start + 2).Split(',');
                            switch (message.Substring(0, start))
                            {
                                // New SMS
                                case "+CMTI":
                                    if (OnNewSMSReceived != null)
                                    {
                                        if (values.Length == 2)
                                        {
                                            SMS sms = SMS_Peek(values[1]);
                                            sms.MessageID = values[1];
                                            OnNewSMSReceived(SMSStorageDetail.GetSMSStorageType(values[0]), sms);
                                        }
                                    }
                                    break;
                                // Network Registration Status
                                case "+CREG":
                                    if (OnNetworkRegistrationChanged != null)
                                    {
                                        if (values.Length == 1)
                                            OnNetworkRegistrationChanged((NetworkRegistrationStatus)int.Parse(values[0]), "-1", "-1");
                                        else
                                            OnNetworkRegistrationChanged((NetworkRegistrationStatus)int.Parse(values[0]), values[1].Split('"')[1], values[2].Split('"')[1]);
                                    }
                                    break;
                                // GPRS Network Registration Status
                                case "+CGREG":
                                    break;
                                // Inditor Control
                                case "+CIEV":
                                    switch (values[0])
                                    {
                                        case "signal":
                                            if (OnSignalBitErrorRateIndicator != null)
                                                OnSignalBitErrorRateIndicator(values[1]);
                                            break;
                                        case "service":
                                            if (OnServiceAvailabiliryIndicator != null)
                                                OnServiceAvailabiliryIndicator(values[1] == "0" ? false : true);
                                            break;
                                        case "sounder":
                                            if (OnSounderActivityIndicator != null)
                                                OnSounderActivityIndicator(values[1] == "0" ? false : true);
                                            break;
                                        case "message":
                                            if (OnUnreadReceivedMessageIndicator != null)
                                                OnUnreadReceivedMessageIndicator(values[1] == "0" ? false : true);
                                            break;
                                        case "call":
                                            if (OnCallInProcessIndicator != null)
                                                OnCallInProcessIndicator(values[1] == "0" ? false : true);
                                            break;
                                        case "roam":
                                            if (OnRoamingIndicator != null)
                                                OnRoamingIndicator(values[1] == "0" ? false : true);
                                            break;
                                        case "smsfull":
                                            if (OnSMSFullIndicator != null)
                                                OnSMSFullIndicator(values[1] == "0" ? false : true);
                                            break;
                                        case "rssi":
                                            if (OnSignalStrengthIndicator != null)
                                                if (values[1] == "99")
                                                    OnSignalStrengthIndicator("0");
                                                else OnSignalStrengthIndicator(values[1]);
                                            break;
                                        case "audio":
                                            if (OnAudioActivityIndicator != null)
                                                OnAudioActivityIndicator(values[1] == "0" ? false : true);
                                            break;
                                        case "simtray":
                                            if (OnSimtrayIndicator != null)
                                                OnSimtrayIndicator(values[1] == "0" ? false : true);
                                            break;
                                        case "eons":
                                            if (OnEnhancedOperatorIndicator != null)
                                                OnEnhancedOperatorIndicator(values[2].Split('"')[1], values[3].Split('"')[1]);
                                            break;
                                        case "nitz":
                                            if (OnNetworkTimeZoneIndicator != null)
                                            {
                                                try
                                                {
                                                    if (values.Length > 3)
                                                    {
                                                        string[] date = values[1].Split('"')[1].Split('/');
                                                        string[] t = values[2].Split('"')[0].Split(':');
                                                        DateTime time = new DateTime(int.Parse("20" + date[0]), int.Parse(date[1]), int.Parse(date[2]), int.Parse(t[0]), int.Parse(t[1]), int.Parse(t[2]));
                                                        time = time.AddHours(double.Parse(values[3]) / 4);
                                                        OnNetworkTimeZoneIndicator(time);
                                                    }
                                                }
                                                catch { }
                                            }
                                            break;
                                    }
                                    break;
                                // USSD
                                case "+CUSD":
                                    if (OnUSSDReceived != null)
                                    {
                                        string m = string.Empty;
                                        int s = message.IndexOf('"');
                                        if (s != -1)
                                            m = message.Substring(s, message.LastIndexOf('"') - s);
                                        OnUSSDReceived((USSDStatus)int.Parse(values[0]), m);
                                    }
                                    break;
                                // SMS full
                                case "^SMGO":
                                    if (OnSMSOverflow != null)
                                        OnSMSOverflow((SMSOverflowStatus)int.Parse(values[0]));
                                    break;
                                // Extrended Call List
                                case "^SLCC":
                                    if (OnCurrentCallInfo != null)
                                    {
                                        if (values.Length > 1)
                                        {
                                            CallInfo list = new CallInfo();
                                            list.CallIndex = int.Parse(values[0]);
                                            list.Dir = (CallDir)int.Parse(values[1]);
                                            list.Status = (CallState)int.Parse(values[2]);
                                            list.CallMode = (CallMode)int.Parse(values[3]);
                                            list.IsMultipartyConferenceCall = values[4] == "0" ? false : true;
                                            if (values.Length >= 8)
                                            {
                                                list.Number = values[6].Split('"')[1];
                                                list.NumberType = (CallNumberType)int.Parse(values[7]);
                                            }
                                            if (values.Length == 9)
                                                list.EntryInPhonebook = values[8].Split('"')[1];
                                            OnCurrentCallInfo(list);
                                        }
                                    }
                                    break;
                            }
                        }
                        else
                        {
                            switch (message)
                            {
                                case "CONNECT": //  1 link established
                                    break;
                                case "RING": //  2 ring detected
                                    if (OnIncomingCall != null)
                                    {
                                        CallInfo[] list = Call_Current_List();

                                        if (list != null)
                                        {
                                            foreach (CallInfo call in list)
                                                if (call.Status == CallState.incoming)
                                                {
                                                    OnIncomingCall(call);
                                                    break;
                                                }
                                        }
                                    }
                                    break;
                                case "NO CARRIER": //  3 link not established or disconnected
                                    break;
                                case "ERROR": //  4 invalid command or command line too long
                                    break;
                                case "NO DIALTONE": //  6 no dial tone, dialling impossible, wrong mode
                                    break;
                                case "BUSY": //  7 remote station busy
                                    break;
                                case "NO ANSWER": //  8 no answer
                                    break;
                                case "CONNECT 2400/RLP": //  47 link with 2400 bps and Radio Link Protocol
                                    break;
                                case "CONNECT 4800/RLP": //  48 link with 4800 bps and Radio Link Protocol
                                    break;
                                case "CONNECT 9600/RLP": //  49 link with 9600 bps and Radio Link Protocol
                                    break;
                                case "CONNECT 14400/RLP": //  50 link with 14400 bps and Radio Link Protocol
                                    break;
                                case "ALERTING": //  alerting at called phone
                                    break;
                                case "DIALING": //  mobile phone
                                    break;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
 static void m_OnIncomingCall(CallInfo call)
 {
     Console.WriteLine("In Coming Call");
     Console.WriteLine(call.CallIndex);
     Console.WriteLine(call.CallMode);
     Console.WriteLine(call.Dir);
     Console.WriteLine(call.EntryInPhonebook);
     Console.WriteLine(call.IsMultipartyConferenceCall);
     Console.WriteLine(call.Number);
     Console.WriteLine(call.NumberType);
     Console.WriteLine(call.Status);
 }