×
Namespaces

Variants
Actions

Archived:Getting Network properties in Flash Lite

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.

Article Metadata
Article
Created: Risalmin (03 Dec 2007)
Last edited: hamishwillee (14 May 2013)

This article demonstrates how to get network properties in Flash lite, in particular the speed and price of the active network connection.The information can be obtained using the fscommand2() function.

Contents

How's the coverage

Since the Signal level returns an ambigous value, it needs to be quantified to something like a percentage of the maximum. So both GetMaxSignalLevel and GetSignalLevel need to be used.

This function simply gets those two pieces of data and returns an integer between 0 and 100

function GetSignalLevel(){
var SignalLevel:Number;
var MaxSignal:Number;
var CurrentSignal:Number;
CurrentSignal= fscommand2("GetSignalLevel");
MaxSignal = fscommand2("GetMaxSignalLevel");
SignalLevel = Math.round(CurrentSignal/MaxSignal )*100;
return SignalLevel;
}

How fast is fast

If you need to know how fast the network is, you can use the GetNetworkGeneration command. It returns a number and bigger is better, in this case more recent generation. See the function below for more.

function GetNetworkSpeed(){
var netGeneration:String = fscommand2("GetNetworkGeneration")
switch(netGeneration){
case -1:
netGeneration = "No Network";
break;
case 0:
netGeneration = "Can't tell";
break;
case 1:
netGeneration = "2G";
break;
case 2:
netGeneration = "2.5G";
break;
case 3:
netGeneration = "3G";
break;
}
return netGeneration;
}

How much is this going to cost

Of course you cannot get the pricing information directly, but you can find out if the device is currently in it's home network or roaming. This would at least allow you to prompt the user before downloading megabytes of data while roaming...

This function uses the fscommand2() function and commands GetNetworkStatus and GetConnectionStatus to find out the information.

function GetNetworkSpeed(){
netStat = fscommand2("GetNetworkStatus");
var netStatus:String
switch(netStat) {
case -1:
netStatus = "network status not supported" add newline;
break;
case 0:
netStatus = "no network registered" add newline;
break;
case 1:
netStatus = "on home network" add newline;
break;
case 2:
netStatus = "on extended home network" add newline;
break;
case 3:
netStatus = "roaming" add newline;
break;
}
conStat = fscommand2("GetConnectionStatus");
var conStatus:String
switch(conStat) {
case -1:
conStatus = "network status not supported" add newline;
break;
case 0:
conStatus = "no network registered" add newline;
break;
case 1:
conStatus = "on home network" add newline;
break;
case 2:
conStatus = "on extended home network" add newline;
break;
case 3:
conStatus = "roaming" add newline;
break;
}
statusnetName = fscommand2("GetNetworkName", "netName")
if(netName =="undefined") {
netName = "";
}
return "Network Status: " +newline + netName + newline+ netStatus;
}

But is it working?

All of this information does not help you if the service is down or not available, so you might want to try a real http-request and see what happens. The GetNetworkRequestStatus command comes in handy here.

var httpStat:Number;
httpStat= fscommand2("GetNetworkRequestStatus");

The values you get for httpStat are interpreted as follows:

-1: Command not supported
 0: Network connected, host name resolved, server connected. Request pending
 1: Network being connected. Request pending.
 2: Network not connected. Request pending.
 3: Network connected, host name beingresolved. Request pending.
 4: Network error. Request failed.
 5: Server connection error. Request failed.
 6: HTTP error (for example, 404)
 7: DNS server not found or Name not resolved. Reques failed.
 8: Success
 9: Timeout
10: No request made

How does all this help

When combine and cross reference the different network related fscommands, you can get a significant amount of information about the network where the device with your Flash Lite application is. With this information at your disposal, you can decide on actions like "to update data or not to update data" or at least provide some data for the user to decide on.

Risalmin

This page was last modified on 14 May 2013, at 09:22.
70 page views in the last 30 days.
×