Beispiel #1
0
        public LineStatus GetLineStatus()
        {
            var lineStatus = new LineStatus();

            WriteLine("show call");
            string s = ReadUntilPrompt();

            UmacCallState callState = new UmacCallState(s);

            lineStatus.StatusCode = callState.State;

            if (callState.State == LineStatusCode.Calling ||
                callState.State == LineStatusCode.ConnectedCalled ||
                callState.State == LineStatusCode.ConnectedReceived ||
                callState.State == LineStatusCode.ReceivingCall)
            {
                WriteLine("show call info");
                s = ReadUntilPrompt();

                var callInfo = new UmacCallInfo(s);

                lineStatus.RemoteAddress = callInfo.ConnectedTo;

                if (callState.TxProtocol == "idle" && callState.RxProtocol == "idle")
                {
                    lineStatus.IpCallType = IpCallType.Invalid;
                }
                else if (callState.TxProtocol == "idle" && callState.RxProtocol != "idle")
                {
                    lineStatus.IpCallType = IpCallType.UnicastUnidirectionalRx;
                }
                else if (callState.TxProtocol != "idle" && callState.RxProtocol == "idle")
                {
                    lineStatus.IpCallType = IpCallType.UnicastUnidirectionalTx;
                }
                else if (callState.TxProtocol != "idle" && callState.RxProtocol != "idle")
                {
                    lineStatus.IpCallType = IpCallType.UnicastBidirectional;
                }
            }
            else if (callState.State == LineStatusCode.Disconnected)
            {
                lineStatus.RemoteAddress = "";
                lineStatus.IpCallType    = IpCallType.Invalid;
            }

            return(lineStatus);
        }
Beispiel #2
0
        public bool Call(Call call)
        {
            bool   success;
            string s;

            // INFO: "config codec reset all" kan ta väldigt lång tid, upp mot 30 sekunder. Ibland går det dock snabbt. Behöver utredas.
            //WriteLine("config codec reset all");
            //ReadUntil(">", 60000);

            WriteLine("config codec 254 opus 48k mono 64k");
            ReadUntilPrompt();

            WriteLine("config codec 253 g722");
            ReadUntilPrompt();

            WriteLine("config codec 252 g711");
            ReadUntilPrompt();

            Write("config jb 150\r\n");
            ReadUntilPrompt();

            WriteLine(string.Format("sip {0}", call.Address));
            s = ReadUntilPrompt();

            // Om uppringningen misslyckas returneras "ERROR: sip call failed\n\radmin> "
            if (s.StartsWith("ERROR"))
            {
                success = false;
            }
            else
            {
                UmacCallState callState = new UmacCallState(s);
                success = callState.State == LineStatusCode.Calling;
            }

            return(success);
        }