09-20-2011 03:40 PM
Hi, I found the method RadioInfo.getNumberOfPacketsSent and RadioInfo.getNumberOfPacketsReceived to get the bytes sent and received for IP packets. However from my testing, it includes the wifi bytes as well. This links confirms this: http://stackoverflow.com/questions/722146/blackber
However I could not think of a way to filter this wifi bytes out
1. If mobile data connection is not on, wifi is on. I could detect that and don't logging bytes from RadioInfo
2. However if both wifi and mobile data connection is on, I could not find a way to filter out wifi bytes since it could either at mobile data connection or wifi. I tried to look into some other classes and I didn't find one suitable to give me such difference.
It would be really appreciated if some one could shed some lights on this including some suggested research.
05-04-2012 03:08 PM
Hi - I am wondering if there has been any progress on this issue? As you stated, there are apps that seem to be distinguishing between the different data categories (WiFi, 3G, GPRS). There must be a way to count data usage for each connection type.
I'm thinking it is possible to set up a background process to detect when the connection type changes, then update the counter for the connection we are transitioning from, using getNumberOfPacketsSent() and getNumberOfPacketsReceived(). People tend to think this is not possible. Can anyone explain why?
05-07-2012 02:46 PM
Based on our research, there is really no way to differentate the mobile bytes and wifi bytes. Actually we also checked couple third party software and they could not differentate it as well (although they didn't state it at their app description). By the way, getNumberOfPacketsSent() and getNumberOfPacketsReceived() are not working on the CDMA phone as well. It is possible to listen to the connection events (such as mobile data and wifi connection) and when wifi connection is on, just won't count mobile bytes. In this way, you won't get an accurate count for mobile bytes, however you might get a count which is closer. I think that it may not be too bad since generally BIS and BES connection would fall back to wifi when wifi is on.
05-07-2012 03:12 PM
Hi pli, thanks very much for getting back to me. Regarding CDMA, it's not so important for me since the app is mainly for European users, although I know others are looking for a solution to that. Regarding the byte counting, we may or may not be allowed to aproximate the numbers for each connection type depending on the size of the discrepancy. As long as we can monitor the connection change, we can keep some basic tally of bytes in each category. If this is the best that is possible, perhaps it will be enough to deliver on our project.
Meanwhile, if anyone has discovered a silver bullet (workaround or otherwise) for reliable mobile-network data monitoring, I know a number of us would greatly welcome such information from my searches around the forum
Thanks again for your findings pli.
05-14-2012 05:44 PM
Just to confirm, there really is no way to determine if the data is going via WiFi or not. I think it is even more confusing than that.
Just looking at WiFi, if WiFi is on, then data could be going through WiFi or might not be. BIS-B and BES connections will go through WiFi, once the WiFi connection has been approved. It is possible to tell that BES is using WiFi from the ServiceBook, I am not sure if the same it true for BIS nor am I sure if there is a way of telling from the various APIs. But even if you could tell that BIS-B/BES communications were going through WiFi, I don't think you can be sure that the communication is using BIS-B, BES or WiFi and not going via some other mechanism (e.g. WAP), unless of course you know all other connection methods are not active.
And as noted, I think it gets more confusing.
Assume WiFi is off, so there is no confusion from that. So you want to accumulate wireless bytes. But are these free or chargeable bytes?
Most BB users, certainly in the UK, will have unlimited BIS-B/BES data. So there is no need to count this. But if WAP or Carrier TCP is available, then you don't know if the mobile data went BIS-B/BES or the alternatives. For example, streaming applications should use Carrier TCP even if BIS-B is available.
So even when you know that the data is going over the Mobile network, you don't really know if it is chargeable or not.
Apologies for throwing issues your way! One of my old bosses used to say, "Don't come into my office with the problem, come in with the solution"". In this case sorry, I only have problems.....
05-30-2012 10:41 AM
To keep this post on topic, I created a new one specifically about wireless connection changes. Just thought I'd link it here for those researching the same problem as me (and also say thanks for the answers above). The connection classes are numerous and seem to overlap a lot in functionality. So... new thread.