0

I coded a program to dial automatically when phone is connected to the laptop and get the last call duration.I used AT+CLCC command to get current call status..Though it should return the Some string value as .......etc i got nothing like that so far...Here is my code..

        _serialPort.BaudRate = 9600;
        _serialPort.Parity = Parity.None;
        _serialPort.DataBits = 8;
        _serialPort.StopBits = StopBits.One;
        _serialPort.Handshake = Handshake.None;

        // Set the read/write timeouts
        _serialPort.ReadTimeout = 500;
        _serialPort.WriteTimeout = 500;

        _serialPort.Open();
        _serialPort.DtrEnable = true;
        _serialPort.RtsEnable = true;

        string phonenr = "";
      //  string mesaj;
        if (!_serialPort.IsOpen)
        {
            _serialPort.Open();
        }
        _serialPort.WriteLine("AT\r");

        {
            Console.WriteLine("Enter the phone number:", phonenr);
            phonenr = Console.ReadLine();
            _serialPort.WriteLine("ATD" + phonenr + ";" + "\r");
            Console.WriteLine("Ring...");
            Thread.Sleep(10000);

             _serialPort.WriteLine("AT+CLCC");
            _serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);


             //As a seperate function....
         private static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
       {   
        SerialPort sp = (SerialPort)sender;
        string indata = sp.ReadExisting();
        Console.WriteLine("Data Received:");
        Console.Write(indata);


    }

What is the wrong with this code????How can i get the response as the format ...etc ???

user3292311
  • 43
  • 1
  • 7

1 Answers1

3

AT+CLCC command does not provide information about the last call. It provides information during a call (during dialing/ringing/waiting etc). Read this for detailed information

I think you can make the phone to output last call details automatically to the terminal, when the call is disconnected but I'm not sure if it provides call duration. You might have to monitor/record the time manually with your application

I have seen other posts where you have asked similar questions. I would recommend using a simple serial port terminal (putty or terminal etc.) to communicate with the phone and grasp the AT commands concept, before moving on to controlling the phone using your own code.

Hamzahfrq
  • 696
  • 1
  • 6
  • 25