Lupindo
Lupindo

Reputation: 19

get AT command call response

I'm trying a code to make a voice call using usb modem and it succeeded to make a call... now i want to get that call response to know if number is ringing,busy or unavailable

This is my used code:

      string number = textBox1.Text;

        po.PortName = "COM3";
        po.BaudRate = int.Parse("9600");
        po.DataBits = Convert.ToInt32("8");
        po.Parity = Parity.None;
        po.StopBits = StopBits.One;
        po.ReadTimeout = int.Parse("300");
        po.WriteTimeout = int.Parse("300");
        po.Encoding = Encoding.GetEncoding("iso-8859-1");
        po.Open();
        po.DtrEnable = true;
        po.RtsEnable = true;
        po.Write("ATDT "+number+";\r"); 

        System.Threading.Thread.Sleep(7000);

        po.WriteLine("ATH+CHUP;\r");
        po.DiscardInBuffer();
        po.DiscardOutBuffer();
        po.Close();

Upvotes: 0

Views: 1449

Answers (1)

ximingr
ximingr

Reputation: 111

After ATD, you need reading the port for kind of information called URC.

For voice call, there are the following possible response,

If no dialtone
NO DIALTONE

If busy,
BUSY

If connection cannot be set up:
NO CARRIER
NO ANSWER

And, before ATD, you'd better set the error format using at+cmee, for exam, at+cmee=2 will enable the string format.

EDIT:(Here is an example with python)

#! /usr/bin/env python
# -*- coding: utf8 -*-
from __future__ import print_function

import sys
import serial


NUM = "111111111"

ser = serial.Serial("com1", 115200)

ser.write('at+cmee=2\r')
ser.timeout = 10.0
res = "invalid"
while len(res) > 0:
    res = ser.read(1)
    print(res, end='')

ser.write('atd' + NUM + ';\r')
ser.timeout = 60.0
res = "invalid"
while len(res) > 0:
    res = ser.read(1)
    print(res, end='')

ser.write("AT+CHUP\r")
ser.timeout = 10.0
res = "invalid"
while len(res) > 0:
    res = ser.read(1)
    print(res, end='')

Its output is (I reject the call from the phone "111111111"),

at+cmee=2
OK
atd111111111;
OK

NO CARRIER
AT+CHUP
+CME ERROR: operation not allowed

And, after the output of 'no carrier', there is no more need to hang up.

Upvotes: 1

Related Questions