Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
benclewett
Old
#1  
Member - OP
Thanks Meter 0
Posts: 58
Join Date: Jul 2003
Location: London
Default Signal Strength

I am sure this question has been asked and answered many times. However a simple search of my subject line in 'programmers corner' yeilds no results.

How is it possible to obtain the signal strength at the current time?

Thanks, Ben.
 
benclewett
Old
#2  
Member - OP
Thanks Meter 0
Posts: 58
Join Date: Jul 2003
Location: London
In reply to my own message, a quick hack at the ril.h and I have a solution to getting the signal strength. My apologies to the authors of ril.h, and thanks to IP Dashboard for unknowingly providing the calibration.

If anybody want to use this, and until such time as the correct solution is published, this is a hack which works.

Beware, possible bug with rill.dll?? When connected to GPRS, the signal strength is always returned as 69% (183) ???

In ril.h add the following structure:

typedef struct {
DWORD dwUnknown1;
DWORD dwUnknown2;
unsigned char ucSignalQuality;
} RIL_SIGNAL_QUALITY;

And uncomment / adjust the definition of RIL_GetSignalQuality to:

HRESULT RIL_GetSignalQuality(HRIL lphRil);

Add a couple of global variables:

DWORD m_dwSigQuality = 0;
HRESULT m_dwSigQualityID = 0;

Edit the ResultCallback to include this code:

if (hrCmdID == m_dwSigQualityID) {

if (dwCode == 1) {

RIL_SIGNAL_QUALITY *data;
data = (RIL_SIGNAL_QUALITY *)lpData;

m_dwSigQuality = (data->ucSignalQuality == 255)
? 0
: (data->ucSignalQuality * 9 / 7) - 166;

} else {

m_dwSigQuality = 0;
}

m_dwSigQualityID = 0;

}


Add your own method to get the signal strength:

void OnButSigStrengh()
{

m_dwSigQuality = 0;
m_dwSigQualityID = RIL_GetSignalQuality(g_hRil);

int iTimeout = 100;
while (m_dwSigQualityID && iTimeout--) Sleep(10);

CString s;
s.Format(TEXT("Signal Strength = %u%%"), m_dwSigQuality);
MessageBox(s);

}

Which should work.

Ben
 
hudsonmobile
Old
#3  
Junior Member
Thanks Meter 0
Posts: 3
Join Date: Sep 2003
Ben -

Nice work -- the code snippet you posted is more or less what we did to get signal strength up and running in IP Dashboard -- of course, I had to do the calibration manually by walking around New York City while a test app spit out readings from the SignalStrength function and I looked at the signal bars, but hey, it was fun. I don't visit often or I would have responded sooner.

Here are the calibration readings we use:

#define ID_PHONEINFO_SIGNALSTRENGTH_POOR 0x80
#define ID_PHONEINFO_SIGNALSTRENGTH_FAIR 0xa1
#define ID_PHONEINFO_SIGNALSTRENGTH_GOOD 0xad
#define ID_PHONEINFO_SIGNALSTRENGTH_EXCELLENT 0xbb
#define ID_PHONEINFO_SIGNALSTRENGTH_NOSIGNAL 0xff

Regards,
Noah
Hudson Mobile
(makers of IP Dashboard)
 
Yorch
Old
#4  
Senior Member
Thanks Meter 1
Posts: 170
Join Date: Feb 2003
Location: Miami
Hey Noah, you know a very good addition to your program could be.

In the same way that you have that "floating" network icon, that you can position it on top or the bottom, (you even provide exact location on top, which I find it pretty useful). You should make another icon for the signal, just like the one from the phone, but the advantage is that yours can hold any skinning done in the phone. I have tried PocketBlinds, Facelift and others and your Network icon stays where it should, whereas the radio signal icon stays behind the skinning. and the option of making this icon show at the bottom, makes it even better, some people (like me) prefer seeing the icons at the bottom and not on top. This would make a great addition for your program and would make a killer app. Well, that and the addition also of a battery metter

By the way, if you need any kind of help designing the icons let me know, I would like to help
visit http://www.yorch.net for Everything for your Pocket PC Phone Edition!
 
hudsonmobile
Old
#5  
Junior Member
Thanks Meter 0
Posts: 3
Join Date: Sep 2003
Yorch --

I saw your post at Wormhole Creations' website as well -- my apologies for not writing back, we are putting together our next product right now (tracker for phone voice minute usage) and things are hectic.

There is special code in IP Dashboard to make sure the taskbar icon floats above a skinned interface - we could potentially add a signal strength icon as well. Coincidentally, we really need ICON design help. If you are willing to design some cool icons for signal strength, I think we could probably work it into the product without too much difficulty over the next 1-2 releases. Let's take this to email -- I can be reached at nbreslow AT hudsonmobile.com

As for the Battery meter, we want to keep the product focused, but a simple battery meter function (line item that read: Battery X%) would be pretty easy to add as well.

Thanks for your interest and suggestions,
Noah
Hudson Mobile
 
finnjoy
Old
#6  
Junior Member
Thanks Meter 0
Posts: 13
Join Date: Oct 2003
Location: UK
Default Signal Strength

Guys - Try Phone Dashboard, a Today Plug-in - Part of it polls real-time signal strength and displays it in percentage terms - v.Useful if you need a real validation of the Signal Strength bar.
Al
 
Puff The Magic Wagon!
Old
#7  
Senior Member
Thanks Meter 3
Posts: 140
Join Date: Jul 2003
Location: UK
Ben

How you getting on?

Drop me a mail...
 
gatalec
Old
#8  
Junior Member
Thanks Meter 0
Posts: 2
Join Date: May 2005
Hello, the code above works like a charm!

I have however a side-effect: the radio icon on the top bar seems to indicate that the radio is off (I cannot receive calls) when I run the program. A couple of minutes after I close it, it goes back to normal.

This is my initialization line:

res = (*fpTAPIrilInit)(1, AsyncCallBack, NotifyCallBack, RIL_NCLASS_MISC, 0x55AA55AA, &hRil);

Any thoughts?

Many thanks for the help!
 
nutitija
Old
#9  
Member
Thanks Meter 0
Posts: 78
Join Date: Apr 2005
Location: Brisbane
why cant ppl just post source codes it would be sooo much helpfull !!!
 
knopper
Old
#10  
Member
Thanks Meter 0
Posts: 56
Join Date: Jul 2006
It need to get signal strength on my Universal, too. So
does it work with on HTC Universal with new WM 6 ?

thanks,
Knopper
===============
T-Mobile MDA Pro
Rom 1.30.113 GER
Radio: 1.10.03

T-Mobile MDA III

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...