Click here to Skip to main content
15,891,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every one;

I try to develop a c# make call application using AT commands but, i am facing a problem when i try to execute my application,i can see the out going call from my mobile but, with in a second in my mobile it says "Disconnected" "Error in Connection" i don't know why is that.

This is my code,

C++
//check voice mode
 this.serialPort.Write("AT+FCLASS=8" + System.Convert.ToChar(13).ToString());

 //start calling 
 this.serialPort.Write("ATDT123456" + System.Convert.ToChar(13).ToString());
 System.Threading.Thread.Sleep(20000);
                    
 //Enter Voice-Transmission Mode
 this.serialPort.Write("AT+VTX" + System.Convert.ToChar(13).ToString());
                   
bool MSwitch = false;
 byte[] buffer = new byte[20000];
 FileStream strm = new FileStream(@"C:\Users\Master\Desktop\Prmpt445.wav", System.IO.FileMode.Open);
 MemoryStream ms = new MemoryStream();
 int count = ms.Read(buffer, 44, buffer.Length - 44);
 BinaryReader rdr = new BinaryReader(strm);
 while (!MSwitch)
 {
     byte[] bt = new byte[1024];
     bt = rdr.ReadBytes(1024);
     if (bt.Length == 0)
     {
         MSwitch = true;
         break;
     }
                        
 }
 strm.Close();
 strm.Dispose();


Thank you in Advance;
Zakirox123
Posted
Updated 21-Jul-12 0:43am
v2
Comments
Abdul Quader Mamun 21-Jul-12 6:43am    
Edited for code block.
zakirox123 21-Jul-12 6:59am    
i cant understand
Abdul Quader Mamun 21-Jul-12 7:07am    
You should place your code in a code block.
zakirox123 21-Jul-12 7:14am    
here is my full source code please help me.


CallClass

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.IO.Ports;
using System.IO;
using System.Windows.Forms;
namespace call
{
class SmsClass
{
SerialPort serialPort;
public SmsClass(string comPort)
{
this.serialPort = new SerialPort();
this.serialPort.PortName = comPort;
this.serialPort.BaudRate = 9600;
this.serialPort.Parity = Parity.None;
this.serialPort.DataBits = 8;
this.serialPort.StopBits = StopBits.One;
this.serialPort.Handshake = Handshake.RequestToSend;
this.serialPort.DtrEnable = true;
this.serialPort.RtsEnable = true;
this.serialPort.NewLine = System.Environment.NewLine;
}



public bool makecall() {
if (this.serialPort.IsOpen == true)
{
try
{

//check voice mode
//this.serialPort.WriteLine("AT+FCLASS=8" + System.Convert.ToChar(13).ToString());

//start calling
this.serialPort.WriteLine("ATDT 0757933652" + System.Convert.ToChar(13).ToString());
Thread.Sleep(19000);
//this.serialPort.WriteLine("ATH+CHUP");
//this.serialPort.WriteLine("AT" + System.Convert.ToChar(13).ToString());
this.serialPort.WriteLine("AT+VTX" + System.Convert.ToChar(13).ToString()); this.serialPort.WriteLine("AT+VTX" + System.Convert.ToChar(13).ToString());
}

catch (Exception ex)
{
MessageBox.Show(ex.Source);
}
return true;
}
else
return false;
}



public void Opens()
{
if (this.serialPort.IsOpen == false)
{
this.serialPort.Open();
}
}
public void Closes()
{
if (this.serialPort.IsOpen == true)
{
this.serialPort.Close();
}
}
}
}


WindowsForm

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using System.IO;

namespace call
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
loadPorts();
}
private void loadPorts()
{
string[] ports = SerialPort.GetPortNames();
foreach (string port in ports)
{
cboPorts.Items.Add(port);
}
}


private void button1_Click(object sender, EventArgs e)
{

makephonecall();

}

public void makephonecall()
{

SmsClass call = new SmsClass(cboPorts.Text);
call.Opens();
call.makecall();
call.Closes();


}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900