GPRS Signal Strength from .Net?

G

Guest

Hello,

We're trying to retrieve GRPS signal strength on an XDA device (running
PPC2003 phone edition). We started to look at the OpenNETCF.Net but that
seems to return signal strength for RF cards only. So our research tells us
we can use TAPI API's or use RIL. We've tried using TAPI but keep getting a
'NotSupportedException'. Before we spend days relearning eVC++, is there a
way of getting signal strength using .Net? Can we call RIL functions from
within .Net?

Thanks in advance,

Simon Neve
 
P

Peter Foot [MVP]

You can use TAPI from .NET - see Alex's wrapper:-
http://www.alexfeinman.com/download.asp?doc=tapi1.1.zip

A NotSupportedException probably indicates an incorrect type passed when
P/Invoking, commonly passing a long instead of an int (In .NET long is
64bits). If you post your code for the specific method which is causing you
problems we can take a look - but you may find it's already implemented in
the above.

Peter
 
G

Guest

That was exactly what we needed - thanks.

Unfortunately, I tried calling the function lineGetLineDevStatus in the
MakeCall function but it returned no line related data at all. I've posted
the code below, but unless there's anything you can see that I'm doing wrong,
it's back to the RIL via C++ i guess?

Thanks,
Simon



public Call MakeCall(string Destination, int CountryCode, /*LINECALLPARAMS*/
byte[] Params)
{
IAsyncResult ar = BeginMakeCall(Destination, CountryCode, Params, null,
null);
bSyncMakeCall = true;
MakeCallAsyncResult mc = ar as MakeCallAsyncResult;
bool bDone = false;
while ( !bDone )
{
Monitor.Enter(mc);
if ( mc.IsCompleted )
bDone = true;
Monitor.Exit(mc);
Application.DoEvents();
}
// if ( !(ar as MakeCallAsyncResult).IsCompleted )
// ar.AsyncWaitHandle.WaitOne();

// Start spn code changes
int i = Marshal.SizeOf(typeof(LINEDEVSTATUS));

LINEDEVSTATUS lds = new LINEDEVSTATUS(Marshal.SizeOf(typeof(LINEDEVSTATUS)));
byte[] data = new byte[Marshal.SizeOf(typeof(LINEDEVSTATUS))];

NativeTapi.lineGetLineDevStatus(m_hLine, data);

ByteCopy.ByteArrayToStruct(data, lds);

MessageBox.Show(lds.dwSignalLevel.ToString());

// End spn code changes

Call call = EndMakeCall(ar);
return call;
}
 
P

Peter Foot [MVP]

The first member in the LINEDEVSTATUS structure indicates the size of the
allocated structure, youprobably need to set this in the buffer you pass
into lineGetDevStatus so it knows how much space it has to write to.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org


Simon Neve said:
That was exactly what we needed - thanks.

Unfortunately, I tried calling the function lineGetLineDevStatus in the
MakeCall function but it returned no line related data at all. I've
posted
the code below, but unless there's anything you can see that I'm doing
wrong,
it's back to the RIL via C++ i guess?

Thanks,
Simon



public Call MakeCall(string Destination, int CountryCode,
/*LINECALLPARAMS*/
byte[] Params)
{
IAsyncResult ar = BeginMakeCall(Destination, CountryCode, Params, null,
null);
bSyncMakeCall = true;
MakeCallAsyncResult mc = ar as MakeCallAsyncResult;
bool bDone = false;
while ( !bDone )
{
Monitor.Enter(mc);
if ( mc.IsCompleted )
bDone = true;
Monitor.Exit(mc);
Application.DoEvents();
}
// if ( !(ar as MakeCallAsyncResult).IsCompleted )
// ar.AsyncWaitHandle.WaitOne();

// Start spn code changes
int i = Marshal.SizeOf(typeof(LINEDEVSTATUS));

LINEDEVSTATUS lds = new
LINEDEVSTATUS(Marshal.SizeOf(typeof(LINEDEVSTATUS)));
byte[] data = new byte[Marshal.SizeOf(typeof(LINEDEVSTATUS))];

NativeTapi.lineGetLineDevStatus(m_hLine, data);

ByteCopy.ByteArrayToStruct(data, lds);

MessageBox.Show(lds.dwSignalLevel.ToString());

// End spn code changes

Call call = EndMakeCall(ar);
return call;
}

Peter Foot said:
You can use TAPI from .NET - see Alex's wrapper:-
http://www.alexfeinman.com/download.asp?doc=tapi1.1.zip

A NotSupportedException probably indicates an incorrect type passed when
P/Invoking, commonly passing a long instead of an int (In .NET long is
64bits). If you post your code for the specific method which is causing
you
problems we can take a look - but you may find it's already implemented
in
the above.

Peter
 
A

Alex Feinman [MVP]

Here is roughly what you want to do:

Tapi tapi = new Tapi();

int lineNo = tapi.Initialize();

Line line = null;

for( int i= 0; i < lineNo; i++)

{

LINEDEVCAPS dc;

if ( tapi.GetDevCaps(i, out dc) == 0 )

{

if ( dc.ProviderName == CellTSP.CELLTSP_PROVIDERINFO_STRING )

{

line = tapi.CreateLine(i, LINEMEDIAMODE.INTERACTIVEVOICE,
LINECALLPRIVILEGE.NONE);

}

}

}

if ( line != null )

{

LINEDEVSTATUS status = new LINEDEVSTATUS(1024);

status.Store();

NativeTapi.lineGetLineDevStatus(line.hLine, status.Data);

status.Load();

label1.Text = "Signal strength is: " + status.dwSignalLevel.ToString();

}

line.Dispose();

tapi.Shutdown();


--
Alex Feinman
---
Visit http://www.opennetcf.org
Simon Neve said:
That was exactly what we needed - thanks.

Unfortunately, I tried calling the function lineGetLineDevStatus in the
MakeCall function but it returned no line related data at all. I've
posted
the code below, but unless there's anything you can see that I'm doing
wrong,
it's back to the RIL via C++ i guess?

Thanks,
Simon



public Call MakeCall(string Destination, int CountryCode,
/*LINECALLPARAMS*/
byte[] Params)
{
IAsyncResult ar = BeginMakeCall(Destination, CountryCode, Params, null,
null);
bSyncMakeCall = true;
MakeCallAsyncResult mc = ar as MakeCallAsyncResult;
bool bDone = false;
while ( !bDone )
{
Monitor.Enter(mc);
if ( mc.IsCompleted )
bDone = true;
Monitor.Exit(mc);
Application.DoEvents();
}
// if ( !(ar as MakeCallAsyncResult).IsCompleted )
// ar.AsyncWaitHandle.WaitOne();

// Start spn code changes
int i = Marshal.SizeOf(typeof(LINEDEVSTATUS));

LINEDEVSTATUS lds = new
LINEDEVSTATUS(Marshal.SizeOf(typeof(LINEDEVSTATUS)));
byte[] data = new byte[Marshal.SizeOf(typeof(LINEDEVSTATUS))];

NativeTapi.lineGetLineDevStatus(m_hLine, data);

ByteCopy.ByteArrayToStruct(data, lds);

MessageBox.Show(lds.dwSignalLevel.ToString());

// End spn code changes

Call call = EndMakeCall(ar);
return call;
}

Peter Foot said:
You can use TAPI from .NET - see Alex's wrapper:-
http://www.alexfeinman.com/download.asp?doc=tapi1.1.zip

A NotSupportedException probably indicates an incorrect type passed when
P/Invoking, commonly passing a long instead of an int (In .NET long is
64bits). If you post your code for the specific method which is causing
you
problems we can take a look - but you may find it's already implemented
in
the above.

Peter
 
G

Guest

It worked! Seems like I wasn't calling the .Load function on the
LINEDEVSTATUS object. Thanks very much Alex and Peter, it saved me a week of
work - appreciate it.

(for anybody wanting to use the code below, i had to change:

for( int i= 0; i < lineNo; i++)
.... for ...
for( int i= 0; i < tapi.NumDevices; i++)

)

Alex Feinman said:
Here is roughly what you want to do:

Tapi tapi = new Tapi();

int lineNo = tapi.Initialize();

Line line = null;

for( int i= 0; i < lineNo; i++)

{

LINEDEVCAPS dc;

if ( tapi.GetDevCaps(i, out dc) == 0 )

{

if ( dc.ProviderName == CellTSP.CELLTSP_PROVIDERINFO_STRING )

{

line = tapi.CreateLine(i, LINEMEDIAMODE.INTERACTIVEVOICE,
LINECALLPRIVILEGE.NONE);

}

}

}

if ( line != null )

{

LINEDEVSTATUS status = new LINEDEVSTATUS(1024);

status.Store();

NativeTapi.lineGetLineDevStatus(line.hLine, status.Data);

status.Load();

label1.Text = "Signal strength is: " + status.dwSignalLevel.ToString();

}

line.Dispose();

tapi.Shutdown();


--
Alex Feinman
---
Visit http://www.opennetcf.org
Simon Neve said:
That was exactly what we needed - thanks.

Unfortunately, I tried calling the function lineGetLineDevStatus in the
MakeCall function but it returned no line related data at all. I've
posted
the code below, but unless there's anything you can see that I'm doing
wrong,
it's back to the RIL via C++ i guess?

Thanks,
Simon



public Call MakeCall(string Destination, int CountryCode,
/*LINECALLPARAMS*/
byte[] Params)
{
IAsyncResult ar = BeginMakeCall(Destination, CountryCode, Params, null,
null);
bSyncMakeCall = true;
MakeCallAsyncResult mc = ar as MakeCallAsyncResult;
bool bDone = false;
while ( !bDone )
{
Monitor.Enter(mc);
if ( mc.IsCompleted )
bDone = true;
Monitor.Exit(mc);
Application.DoEvents();
}
// if ( !(ar as MakeCallAsyncResult).IsCompleted )
// ar.AsyncWaitHandle.WaitOne();

// Start spn code changes
int i = Marshal.SizeOf(typeof(LINEDEVSTATUS));

LINEDEVSTATUS lds = new
LINEDEVSTATUS(Marshal.SizeOf(typeof(LINEDEVSTATUS)));
byte[] data = new byte[Marshal.SizeOf(typeof(LINEDEVSTATUS))];

NativeTapi.lineGetLineDevStatus(m_hLine, data);

ByteCopy.ByteArrayToStruct(data, lds);

MessageBox.Show(lds.dwSignalLevel.ToString());

// End spn code changes

Call call = EndMakeCall(ar);
return call;
}

Peter Foot said:
You can use TAPI from .NET - see Alex's wrapper:-
http://www.alexfeinman.com/download.asp?doc=tapi1.1.zip

A NotSupportedException probably indicates an incorrect type passed when
P/Invoking, commonly passing a long instead of an int (In .NET long is
64bits). If you post your code for the specific method which is causing
you
problems we can take a look - but you may find it's already implemented
in
the above.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Hello,

We're trying to retrieve GRPS signal strength on an XDA device (running
PPC2003 phone edition). We started to look at the OpenNETCF.Net but
that
seems to return signal strength for RF cards only. So our research
tells
us
we can use TAPI API's or use RIL. We've tried using TAPI but keep
getting
a
'NotSupportedException'. Before we spend days relearning eVC++, is
there
a
way of getting signal strength using .Net? Can we call RIL functions
from
within .Net?

Thanks in advance,

Simon Neve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top