(Difference between revisions)

Archived:How to get all LBS parameters in S60 3rd Edition FP1

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix links)
Line 1: Line 1:
[[Category:Location]][[Category:Symbian C++]][[Category:S60 3rd Edition FP1]]
{{Archived|timestamp=20120313125325|user=roy.debjit| }}
{{Archived|timestamp=20120313125325|user=roy.debjit| }}
[[Category:Location]][[Category:Symbian C++]][[Category:S60 3rd Edition FP1]]
{{ArticleMetaData <!-- v1.2 -->
{{ArticleMetaData <!-- v1.2 -->
|sourcecode= [[Media:AllLBS.zip]]  
|sourcecode= [[Media:AllLBS.zip]]
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|devices= Nokia N95
|devices= Nokia N95

Latest revision as of 07:25, 29 June 2012

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}}.

Article Metadata
Code Example
Source file: Media:AllLBS.zip
Tested with
Devices(s): Nokia N95
Platform(s): S60 3rd Edition FP1
S60 3rd Edition FP1
Platform Security
Signing Required: DevCert
Capabilities: ReadDeviceData ReadUserData NetworkServices Location LocalServices UserEnvironment WriteUserData WriteDeviceData
Created: omarfr (27 May 2008)
Last edited: hamishwillee (29 Jun 2012)


[edit] Overview

This example will give you the code needed to get all needed LBS data from WLAN, GPS and GSM

This is not a complete example but the files posted here: File:AllLBS.zip are ready to be used in any application. Just unzip the archive and use the example code below to add this engine to your application. It is that simple.

All 3 engines (WLAN, GPS and GSM) are implemented as Active Objects so they run asynchronously, in a safe way. Each time you request an information you get the latest information possible without waiting.

For WLAN, you get:

 - all available Wireless networks
 - Power 
 - AP type
 - Security type

For GSM:

 - Power
 - MCC
 - MNC
 - LAC
 - Cell ID
 - Long Name

For GPS:

 - TPosition class wich gives altitude, latitude, longitude, time, speed, etc... look SDK

[edit] Preconditions

This example has been only tested on Nokia N95. This example assumes that the target device has WLAN and GPS.


This snippet requires capabilities. Self-signing is not possible because a Developer Certificate is needed. You can use Online Symbian-Signed.

ReadDeviceData ReadUserData NetworkServices Location LocalServices UserEnvironment WriteUserData WriteDeviceData

Libraries needed are specified in header files.

[edit] Network Engine

This is the main class. Construct an object of type CNetworkEngine in your program to get full access to all the functions from GPS, WLAN and GSM.

If you want to get notifications from the network engine implement the observer and pass it as a parameter like in the example, else pass a NULL.

Here it is an example:

//In your .h file you've implemented the interface MNetworkEngineObserver like this
#include "NetworkEngine.h"
public YourClass: public MNetworkEngineObserver
void YourFunctionL();
* Functions used to handle events from NetworkEngine
void HandleErrorL(TInt aError);
void HandleErrorL(TInt aError, const TDesC &aMessage);
void HandleMessageL(const TDesC &aMessage);
//In your .cpp file
void YourFunctionL()
CNetworkEngine *networkEngine;
TRAPD(err, (networkEngine = CNetworkEngine::NewL(this)));
if(err != KErrNone)
networkEngine = NULL;
//print err message
TBuf<8192> bigBuf;
//Get GSM Information (XML format)
//print or do whatever with bigBuf
//Get WLAN Information (XML format)
//print or do whatever with bigBuf
//Get GPS Information (TPosition)
TPosition pos;
pos = networkEngine->GetGPSCoordonates();
//do whatever with pos

[edit] Network Engine header file

* File NetworkEngine.h
* Contains definitions for CNetworkEngine class and MNetworkEngineObserver interface
#ifndef __NetworkEngine_H__
#define __NetworkEngine_H__
#include "GSMInfo.h"
#include "wlaninfo.h"
#include "LBSInfo.h"
//Log entry size
const TInt KLogEntrySize = 32768;
// EventObserver interface
class MNetworkEngineObserver
virtual void HandleErrorL(TInt aError) = 0;
virtual void HandleErrorL(TInt aError, const TDesC &aMessage) = 0;
virtual void HandleMessageL(const TDesC &aMessage) = 0;
class CNetworkEngine : public MGSMInfoObserver, public MWLANInfoObserver, public MPositionObserver
//From GSMInfo
void HandleGSMInfoErrorL(TInt aError);
void GetGSMInfoL(TDes &aNetworkInfo);
//From WLANInfo
void HandleWLANInfoErrorL(TInt aError);
void HandleWLANInfoMessage(TInt aReason);
void HandleWLANInfoMessage(const TDesC &aMessage);
void GetWLANInfo(TDes& aWLANInfo);
//From LBSInfo
void LBSPositionUpdatedL(TPositionInfoBase& aPosInfo);
void LBSErrorL(const TDesC& aErrorString);
void LBSMessageL(const TDesC& aMessage);
void LBSMessageL(TInt aCode, const TDesC& aMessage);
TPosition GetGPSCoordonates();
//Own functions
static CNetworkEngine* NewLC(MNetworkEngineObserver* aObserver);
static CNetworkEngine* NewL(MNetworkEngineObserver* aObserver);
void ConstructL(MNetworkEngineObserver* aObserver);
private: //data
* The GSMInfo objecet
CGSMInfo *iGSMInfo;
* The WLAN info object
* The LBSInfo object
CLBSInfo *iLBSInfo;
* Event observer
MNetworkEngineObserver *iNetworkEngineObserver;
* For Position Updates
TReal iLatitude, logLatitude;
TReal iLongitude, logLongitude;
TPosition iLastPosition;
#endif /*__NetworkEngine_H__*/

[edit] Source Files

All the source files for this example are in the archive attached: File:AllLBS.zip

[edit] Testing

As mentioned, this code has been testing in a Nokia N95 with very good results. It should work on any phone that supports S60 3rd edition FP1.

This page was last modified on 29 June 2012, at 07:25.
76 page views in the last 30 days.