You Are Here:

Community: Wiki

This page was last modified on 27 May 2008, at 16:14.

How to get all LBS parameters

From Forum Nokia Wiki


ID   Creation date: 27 May 2008  
Platform: Symbian C++   Tested on devices: Nokia N95  
Category: LBS, Symbian C++, Code Examples   Subcategory  


Keywords (APIs, classes, methods, functions): WLAN Info, CTelephony, Location API


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
 - BSSID
 - SSID
 - 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

Preconditions

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

CAPABILITIES

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.

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
return;
}
 
CleanupStack::Push(networkEngine);
 
TBuf<8192> bigBuf;
 
//Get GSM Information (XML format)
networkEngine->GetGSMInfoL(bigBuf);
//print or do whatever with bigBuf
 
//Get WLAN Information (XML format)
networkEngine->GetWLANInfo(bigBuf);
//print or do whatever with bigBuf
 
//Get GPS Information (TPosition)
TPosition pos;
pos = networkEngine->GetGPSCoordonates();
//do whatever with pos
}

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
{
public:
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
{
public:
//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);
~CNetworkEngine();
 
protected:
void ConstructL(MNetworkEngineObserver* aObserver);
CNetworkEngine();
 
private: //data
/**
* The GSMInfo objecet
*/
CGSMInfo *iGSMInfo;
 
/**
* The WLAN info object
*/
CWLANInfo *iWLANInfo;
 
/**
* The LBSInfo object
*/
CLBSInfo *iLBSInfo;
 
/**
* Event observer
*/
MNetworkEngineObserver *iNetworkEngineObserver;
 
 
/**
* For Position Updates
*/
TReal iLatitude, logLatitude;
TReal iLongitude, logLongitude;
TPosition iLastPosition;
 
};
 
#endif /*__NetworkEngine_H__*/

Source Files

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

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.

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fHowE5ftoE5fgetE5fallE5fE4cBSE5fparametersX qdcZpublisherQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fidE2fc764fd1cE2d8b06E2d499aE2d9a6aE2d17c3903d5a65E2fforumE5fnokiaE5fcrawlerE5fagentX qdcZtitleQSxHowE20toE20getE20allE20E4cBSE20parametersE20E2dE20ForumE20NokiaE20WikiX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qrssZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qfnZdistributionQUxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2fX qfnZtopicQUqfnTopicZconnectivityQRqmarsZrelevanceQNx100X qfnZtopicQUqfnTopicZgpsQRqdcZtypeQUqrdfsZE52esourceQRqmarsZrelevanceQNx100X qfnZtopicQUqfnTopicZlocationQRqmarsZrelevanceQNx100X qfnZtopicQUqfnTopicZwlanQRqdcZtypeQUqrdfsZE52esourceQRqmarsZrelevanceQNx100X qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZupdatedQDx2008E2d10E2d02X qfnZuserE5ftagQSxconnectivityX qfnZuserE5ftagQSxgpsX qfnZuserE5ftagQSxlocationE2dbasedE2dservicesX qfnZuserE5ftagQSxwlanX qmarsZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ