Help me!!

Apr 23, 2010 at 6:54 AM

Hello everyone,
I had a problem with Liberia OpenNETCF.Telephony. Is there someone who can help me?

I have to make a data call and say that I can do it, the problem is that the state of the call remains on "Proceeding" using the following configuration:

LineCallParam.BearerMode = BearerMode.Voice;
LineCallParam.MediaMode = MediaMode.DataModem;

if you understand what mistake I post the code.
I I program in C # that's why I'm using this freedom to make a data call.

Thank you.

May 10, 2010 at 2:29 PM
Edited May 11, 2010 at 10:01 AM
Hello,

I also made a data call but I don't use BearerMode.Voice but BearerMode.Data instead.
Can you try with BearerMode.Data ?

Excuse me for the delay, I have just sign in this forum.

Benoît
May 11, 2010 at 7:06 AM
Hello bends, Meanwhile thanks for your reply. I tried to do as you say is true and I get the call status as "Connected". Only now I can not send data ... I've seen on various forums that you can use the WriteLine method, and so I tried that method but I can not, tells me that the handle is invalid. In this method I tried to pass the handle of the line chimeras and even what you get from a variable of type Tapi. Can you help me? You're the only one so far has given me a useful tip ...
May 11, 2010 at 10:00 AM
Edited May 11, 2010 at 10:01 AM
To read and write data from/to the line I use an handle. I get it from the deviceId with lineGetID method.

Once I have the handle I use ReadFile and WriteFile native methods.

Hope next sample code will help you.

IntPtr handlePort;

void call_Connected(Call call, CallState callState)
{
VarString deviceId = new VarString(Marshal.SizeOf(typeof(VarString)) + 1024);
deviceId.StringOffset = Marshal.SizeOf(typeof(VarString));
deviceId.Store();
NativeMethods.lineGetID(line.hLine, call.Info.AddressID, call.Handle, CallSelect.CALL, deviceId.Data, "comm/datamodem");

deviceId.Load();
handlePort = BitConverter.ToInt32(deviceId.Data, deviceId.StringOffset);
}

ReadFile(handlePort, buffer, (uint)count, out numberOfBytesRead, IntPtr.Zero);
WriteFile(handlePort, buffer, count, out numWritten, IntPtr.Zero);

I create an HandleStream class derive from System.IO.Stream class to manage handle read and write like a stream.

Benoît
May 11, 2010 at 1:54 PM
Hello bends, thanks again for your reply. Listen I have another problem. The type VarString there on the library so I have to create it myself?
May 11, 2010 at 2:57 PM
No, it is defined in Struct.cs file of OpenNETCF.Telephony.

Maybe it is defined internal so you have to set it public.

Can you check it ?

Benoît
May 11, 2010 at 3:14 PM
Edited May 11, 2010 at 3:26 PM
Ok ... I feel and I can tell bends! Thanks again for your help.
May 11, 2010 at 3:54 PM
Hello bends, I tried to do as you say. When the two devices are connected to call the method that you gave me but I handleport returns a zero and therefore I can not send data. Use WriteFile to send data but implemented in this way (to be exact): / / This is the definition [DllImport ("coredll", SetLastError = true)] public static extern bool WriteFile (IntPtr hFile, string data, int length, out int lpNumberOfBytesWritten, IntPtr b); However although this method is not exactly get the handle before calling this method! Sorry if I ask for more help.
May 12, 2010 at 6:53 AM
Hello bends, Yesterday I tried to make changes to the code that you gave me and I managed to send data. Thank you for your invaluable help. If I still need now I know who to ask. Thank you again.
May 12, 2010 at 8:36 AM
Great ! You are welcome, I am pleased to share my experience !

See you again,
Benoît
May 12, 2010 at 10:20 AM
Hello bends, I'm back. I have a problem. When I go to send the data there are no problems if it tried to receive tells me that the handle is invalid. Why?
May 12, 2010 at 3:26 PM
Edited May 12, 2010 at 3:36 PM
: \

Have you got the invalid handle message on calling ReadFile function ?
The handle you use is the same for Write and Read operations ?
Could you show me some part of your code which create the line and get the handle ?

Benoît
May 12, 2010 at 3:49 PM
Edited May 13, 2010 at 7:27 AM
hello bends, gives me error when I call the ReadFile method. C # tells me that the error is an exception not supported but when I try the method GetLastError () get value as 6 which means that the handle is invalid. The handle that I use is the same that I use to write.
May 12, 2010 at 4:27 PM
Edited May 12, 2010 at 4:33 PM
So I create the line and make the call: varTapi.Initialize();
if (varLine != null)
varLine.Dispose();
if (cmbLine.SelectedIndex < 0)
return;
varLine = varTapi.CreateLine((cmbLine.SelectedItem as LineDescriptor).ID, MediaMode.DataModem, CallPrivilege.None);

try
{

CallParameters LineCallParam = new CallParameters(varLine.MakeCall(txtNumber.Text, 0, null).Info.Data.Length);
LineCallParam.MinimumRate = 9600;
LineCallParam.MaximumRate = 9600;
LineCallParam.BearerMode = BearerMode.Data;
LineCallParam.MediaMode = MediaMode.DataModem;
LineCallParam.CallParamFlags = CallParameterFlags.Idle;
LineCallParam.AddressID = 0;
LineCallParam.DialParams.DialSpeed = 0;
LineCallParam.DialParams.DigitDuration = 0;
LineCallParam.DialParams.DialPause = 0;
LineCallParam.DialParams.WaitForDialtone = 0;
LineCallParam.Store();

MessageBox.Show("si, lascia passare un pò di tempo");
Call1 = varLine.MakeCall(txtNumber.Text, 0, LineCallParam.Data);
MessageBox.Show("Chiamata avviata...");

while (Call1.State != CallState.Connected)
{
//aspetto che lo stato della chiamata sia su Connected
}
//e poi chiamo
call_Connected(Call1, Call1.State);

To create the handle using the method you gave me:

void call_Connected(Call call, CallState callState)
{
VarString deviceId = new VarString(Marshal.SizeOf(typeof(VarString)) + 1024);
deviceId.StringOffset = Marshal.SizeOf(typeof(VarString));
deviceId.Store();
int y = NativeMethods.lineGetID(varLine.hLine/*IntPtr.Zero*/, call.Info.AddressID, call.Handle, CallSelect.CALL, deviceId.Data, "comm/datamodem");
MessageBox.Show(y.ToString());
deviceId.Load();
int c = BitConverter.ToInt32(deviceId.Data, deviceId.StringOffset);
handlePort = (IntPtr)c;
}

To read use by pressing the button and call the ReadFile method:

private void button1_Click_1(object sender, EventArgs e)
{
if (handlePort != IntPtr.Zero)
{
byte[] data = new byte[32];
int byteRead;
try
{
bool b = ReadFile(handlePort, out data, (uint)32, out byteRead, IntPtr.Zero);

for (int i = 0; i < data.Length; i++)
{
txtRead.Text += data[i];
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
int c = GetLastError();
}
}
}
May 13, 2010 at 9:25 AM
Hello bends, I solved this problem too. Thanks anyway for availability. Without your help we would not succeed. Thanks again.
May 17, 2010 at 12:06 PM
Edited May 17, 2010 at 12:06 PM
Well,

don't forget to explain how you resolve your problem to help futur OpenNETCF.Telephony developers.

Benoît
Jan 11, 2011 at 8:59 AM

Hello bends,
I still need your help. Play :-) I can now send data from one device to another but I can not understand when I send the data. Do you know if there is a flag that shows me where the line is ready to send or receive data?
I tried using the flag of the STATUS variable CALL. but it was just part of the call becomes CONNECTED.

Jan 12, 2011 at 9:37 PM

Hello !

unfortunately I no longer work on this project and I can't access to the source code, I quit my job... Sorry I have too few remains to help you : \

Benoît

 

Jan 13, 2011 at 7:22 AM

Hello bends,
I'm sorry that you left your job :-(... Well thank you again for your help ... You have been fundamental ... Have a good life.
Hello Bends, Good day!