GPRS Status
| Sat, 2005-03-26 01:47 | |
|
I'm trying to programatically get the GPRS status on a P800/P900 phone, but I'm not having any luck. If you click on the little network status icon in the lower left corner of the screen, it says something like "GPRS: Attached" or "GPRS: Detached". This is exactly what I need to know - whether GPRS is attached or detached.
I tried the following code that I found in a Series 60 forum, but GetState always returns -19. Can anyone help me out? Code: const TInt KUidGprsStatusValue = 0x100052DB; const TUid KUidGprsStatus = {KUidGprsStatusValue}; RSystemAgent iIndicatorSystemAgent; iIndicatorSystemAgent.Connect(); iIndicatorSystemAgent.GetState(KUidGprsStatus); |
|






Forum posts: 4
Craig
Forum posts: 5
RConnection iConnect;
RSocketServ iSocketServ;
TPckgBuf<TInterfaceNotification> iNotification;
in source files:
iSocketServ.Connect();
iConnect.Open(iSocketServ);
TBool connected = EFalse;
TUint connectionCount;
//Enumerate currently active connections across all socket servers
User::LeaveIfError(iConnect.EnumerateConnections(connectionCount));
if (connectionCount){
TPckgBuf<TConnectionInfoV2> connectionInfo;
for (TUint i = 1; i <= connectionCount; ++i){
//to do: add code to check is it GPRS
iConnect.GetConnectionInfo(i, connectionInfo);
connected = ETrue;
aIap = connectionInfo().iIapId;
break;
}
}
To be notified for connection changes use
iConnect.AllInterfaceNotification(iNotification, iStatus);
Forum posts: 19
I am facing problems in getting "AllInterfaceNotification" function to work. Could you please give more information on its usage?
Whenever I call this function, I immediately get a notification once with iStatus = KErrInUse (-14). And after that nothing happens.
On renewing the request, I keep getting iStatus = -14 only.
Did it work for you properly? Moreover - does this function provide you notifications on network coming up/going down?
TIA,
isymdev
RConnection iConnect;
RSocketServ iSocketServ;
TPckgBuf<TInterfaceNotification> iNotification;
in source files:
iSocketServ.Connect();
iConnect.Open(iSocketServ);
TBool connected = EFalse;
TUint connectionCount;
//Enumerate currently active connections across all socket servers
User::LeaveIfError(iConnect.EnumerateConnections(connectionCount));
if (connectionCount){
TPckgBuf<TConnectionInfoV2> connectionInfo;
for (TUint i = 1; i <= connectionCount; ++i){
//to do: add code to check is it GPRS
iConnect.GetConnectionInfo(i, connectionInfo);
connected = ETrue;
aIap = connectionInfo().iIapId;
break;
}
}
To be notified for connection changes use
iConnect.AllInterfaceNotification(iNotification, iStatus);
Forum posts: 5
I am facing problems in getting "AllInterfaceNotification" function to work. Could you please give more information on its usage?
Whenever I call this function, I immediately get a notification once with iStatus = KErrInUse (-14). And after that nothing happens.
On renewing the request, I keep getting iStatus = -14 only.
Did it work for you properly? Moreover - does this function provide you notifications on network coming up/going down?
TIA,
isymdev
In main class write this
iMyConnection.Open(iSocketServ);
iConnectionNotifier = CConnectionNotifier::NewL(anything you want to pass as the argument(s));
and in class CConnectionNotifier (extends public CActive) these are the main things. (iMyConnection can be passed as argument to this class)
CConnectionNotifier::CConnectionNotifier(anything you want to pass as the argument(s))
: CActive(CActive::EPriorityStandard) {
CActiveScheduler::Add(this);
}
void CConnectionNotifier::ConstructL()
{
iMyConnection().AllInterfaceNotification(iNotification, iStatus);
SetActive();
}
void CConnectionNotifier::RunL()
{
if (iNotification().iState == EInterfaceUp){
//i.e. display that you are connected
}
else if (iNotification().iState == EInterfaceDown){
//i.e. display that you are discconnected
}
iMyConnection().AllInterfaceNotification(iNotification, iStatus);
SetActive();
}
Forum posts: 19
Thanks for your reply. It works for me now.
But I had to run this code as a separate example to get it working. Writing this code in the same gprs example program, gives me -14 in the notification always.
any idea why.
thanks again
isymdev
Forum posts: 4
Did you find out what went wrong? Did you find out how to monitor the connection in one application and not to do it externally?
Thanks for your reply,
Dominik
Forum posts: 4
As you said, you needed a new application to make it work.
Thanks for that! This led me to the following idea:
Creating a new RConnection object in one and the same application. So one RConnection - say activeConn - is used to keep a handle for the active connection you previously set up with activeConn.Start() - and then a second one - let's call it monitorConn - used for monitoring.
When you create an ActiveObject (maybe: CConnStateMonitor) and call AllInterfacesNotification on monitorConn now then SetActive(), RunL gets called when the state of a connection changes. In this way I get notified of any connection going down or up and the TInterfaceNotification member is updated in the CConnStateMonitor object.
Now you have to filter out whether it was your own connection going down or coming up,
by use of the iConnectionInfo member of TInterfaceNotification, something like:
iWrappedNotification().iState == EInterfaceDown; // or EInterfaceUp
HTH, and good luck,
Dominik
Forum posts: 1
Does anyone know where the const KUidGprsStatus=0x100052DB comes from ?
This is known as "undocumented constants for getting GPRS Context" in this forum.
This value does not work with SystemAgent on UIQ, I just want to make sure the value is correct.
thanks.
Forum posts: 4
if (connectionCount){
TPckgBuf
for (TUint i = 1; i <= connectionCount; ++i){
//to do: add code to check is it GPRS
iConnect.GetConnectionInfo(i, connectionInfo);
connected = ETrue;
aIap = connectionInfo().iIapId;
break;
}
}
Hi Boris and all:
//to do: add code to check is it GPRS
How can I achieve this. Using Conn Info I will get only IAP id and INetId. But I don't know how to get conn type
based on this.
I guess I have to relate this with some tables.
Could some one plz help me in this regard.
Suggest some material where I can get complete database tables interaction.
Thanks
bytes
Forum posts: 4
Frns,
I got the answer:
I have to lookup in to IAP table for IAp Id whose "service_type" is "OutgoingGprs", then its GPRS connection.
-Venu
Forum posts: 19
hello friends
really a great and healthy discussion over .By following this i am able to get the notification of active gprs connnection in the background .in
if (iNotification().iState == EInterfaceUp)
{
//i.e. display that you are connected
}
now i want to moniter the data upload or download in that gprs transaction. But i don't want to actively open the connection via my application .
how could i monitor that .
as i know RConnectionMonitor is the api for that and
iMonitor.GetUintAttribute(elem.iConnectionId, elem.iSubConnectionId, KDownlinkData, iDataTransfer, iStatus);
is method for that but struggling to implement it.
Or there could me other way also to get this information .
pls guide me ..
regard's
vivek
Forum posts: 19
first thing i want to know that how will i find the connection index of the of that gprs which we are not opening via our application
waiting for the reply
thanks vivek
Forum posts: 1
Hi,
Anyone can please give me the code for finding whether GPRS data connection or not?
I am not finding much information about "service_type" and "OutgoingGprs".