×
Namespaces

Variants
Actions
(Difference between revisions)

How to use different positioning methods in S60

From Nokia Developer Wiki
Jump to: navigation, search
mahbub_s60 (Talk | contribs)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Add ArticleMetaData)
 
(13 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Location]][[Category:Location Based Services]][[Category:Symbian C++]]
+
{{ArticleMetaData <!-- v1.2 -->
 +
|sourcecode= [[Media:N8LBSSample ModuleName.zip]] [[Media:Locationmethod.zip]]
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20100914
 +
|author= [[User:Mahbub s60]]
 +
}}
 +
[[Category:Location]][[Category:Symbian C++]][[Category:Code Examples]]
 
== Introduction ==
 
== Introduction ==
There are different kind of positioning methods available in Symbian platform. This article briefly describes those and how to use each method from Symbian C++ code.
+
There are different kind of positioning methods available in Symbian platform. This article briefly describes those and how to use each method from Symbian C++ application.
  
  
 
== Description ==
 
== Description ==
Four different methods are availabel in Symbian platform. Each having different response time, accuraccy and so on. Each location acuisation method is idetified with Uid and technology type. To use any of the method, we have to creates a session with the positioning server and then we create a sub-session with the positioning server. When we create sub-session we can instruct what positioning mechanism we are going to use. If we don't provide any specific positioning method then The server uses the positioning module with the highest priority by default. If the highest priority positioning module is not available or if it returns an error for a position request then the positioning module with the next highest priority is used. Following table describes different modules, name and it's Uid.
+
Four different methods are available in Symbian platform. Each having different response time, accuracy and so on. Each location accusation method is identified with Uid and technology type. To use any of the method, we have to create a session with the positioning server and then we create a sub-session with the positioning server. When we create sub-session we can instruct the framework what positioning mechanism we are going to use. If we don't provide any specific positioning method then the server uses the positioning module with the highest priority by default. If the highest priority positioning module is not available or if it returns an error for a position request then the positioning module with the next highest priority is used. Following table shows different modules, name and it's Uid.
  
  
 
<table border="1">
 
<table border="1">
 
<tr>
 
<tr>
<td>row 1, cell 1</td>
+
<td>Technology Name</td>
<td>row 1, cell 2</td>
+
<td>Used Uid</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
<td>row 2, cell 1</td>
+
<td>Network based</td>
<td>row 2, cell 2</td>
+
<td>0x10206915</td>
 
</tr>
 
</tr>
</table>
 
  
 +
<tr>
 +
<td>Assisted GPS</td>
 +
<td>0x101fe98c</td>
 +
</tr>
  
----
+
<tr>
Name                                                  Uid<br>
+
<td>Integrated GPS</td>
<br>
+
<td>0x101fe98a</td>
Network based                                    0x101fe98a<br>
+
</tr>
Assisted GPS                                      0x101fe98c<br>
+
Integrated GPS                                    0x101fe98a<br>
+
Bluetooth GPS                                    0x101fe999<br>
+
----
+
  
== Solution ==
+
<tr>
L2CAP transmits unit is configured  before connection. Once the connection has been established then the transmit unit will be used.  Inbound transmission unit  of local device is the same as out bound transmission unit of remote devices and outbound transmission unit is same  as inbound transmission unit of remote device.
+
<td>Bluetooth GPS</td>
<br>
+
<td>0x101fe999</td>
 +
</tr>
 +
</table>  
  
Code for configuring the L2CAP connection.<br>
+
== Detecting numbers of available modules ==
 +
Following code try to find the number of modules and identify the desired module id (set by UI) that is going to be used for positioning. In this example we use the position information to download map.
 
<code cpp>
 
<code cpp>
  
 +
    TUint module = 0;       
 +
    // Get the available numbers of modules
 +
    error = iPosServer.GetNumModules(module);
 +
    if(error != KErrNone)
 +
        {
 +
        iPosServer.Close();               
 +
        return;
 +
        }
 +
    TPositionModuleInfo info;   
  
     iLog.LogL(_L("Connecting to service"));
+
     for(TUint i = 0; i < module; i++)       
User::LeaveIfError(iSendingSocket.Open(iSocketServer, _L("L2CAP")));
+
        {
    TBTSockAddr address;
+
        error = iPosServer.GetModuleInfoByIndex(i,info);      
    address.SetBTAddr(iServiceSearcher->BTDevAddr());
+
        TBool isavailable = info.IsAvailable();
    address.SetPort(iServiceSearcher->Port());
+
        if(error == KErrNone && isavailable)
    TBuf<100> buf(0);  
+
            {       
    TL2CapConfigPkg  ConfigPkg = iL2CapAPIConfig;          
+
            TBuf<200> buf(0);
    ConfigPkg().SetMaxTransmitUnitSize(iMaxTransmitUnit);   // has been set or use some default value specified in constructor
+
            buf.SetLength(0);
    ConfigPkg().SetMaxReceiveUnitSize(iMaxReceivedUnit);    // has been set or use some default value specified in constructor       
+
            buf.FillZ();
    TInt rerr = iSendingSocket.SetOpt(KL2CAPUpdateChannelConfig, KSolBtL2CAP, ConfigPkg);  
+
            info.GetModuleName(buf);
    buf.Format(_L("SetOpt ret= %d"), rerr);       
+
       
    iSendingSocket.Connect(address, iStatus);
+
            if(!buf.Compare(_L("Network based")) && iELocModuleUsed == eNetwork)
 +
                {
 +
                iTargetModule = info.ModuleId();
 +
                break;               
 +
                }
 +
           
 +
            if(!buf.Compare(_L("Integrated GPS")) && iELocModuleUsed == eGPS)
 +
                {
 +
                iTargetModule = info.ModuleId();
 +
                break;               
 +
                }
  
#ifdef __WINS__
+
            if(!buf.Compare(_L("Assisted GPS")) && iELocModuleUsed == eAssisted)
    User::After(1);     // Fix to allow emulator client to connect to server
+
                {
#endif
+
                iTargetModule = info.ModuleId();
 
+
                break;
    SetActive();
+
                }           
 +
                                               
 +
                if(info.TechnologyType()& TPositionModuleInfo::ETechnologyTerminal)
 +
                    {                             
 +
                        TPositionModuleInfo::TDeviceLocation deviceLoc =  info.DeviceLocation();
 +
                        if (deviceLoc == TPositionModuleInfo::EDeviceInternal)
 +
                            {
 +
                            //Checked GPS is available, you can use the information to your app
 +
                            }
 +
                  }                   
 +
            }
 +
        else
 +
            {
 +
              //Checked GPS is available, you can use the information to your app
 +
            }
 +
        }       
  
 
</code>
 
</code>
  
 +
== Using the desired module ==
  
Code for  getting the configuration value from L2CAP link.<br>
+
Following code shows how to use the desired module to find the location. If the desired target type is set then that module id can be used to open a sub-session.<br>
This will return us the inbound  and outbound transmission unit  as well as inbound and outbound MTU.
+
  
 
<code cpp>
 
<code cpp>
  
      
+
     // Open subsession to the position server if it was targeted as Network based
    TInt rerr = KErrNone;
+
     if(iELocModuleUsed == eNetwork || iELocModuleUsed == eGPS || iELocModuleUsed == eAssisted)
    TPckgBuf<TInt> getOptBuf;
+
         {         
    TInt getOptValue = 0;
+
         if(iTargetModule != TUid::Null())
    TBuf<100> buf(0);
+
   
+
   
+
   
+
 
+
     if(rerr == KErrNone)
+
         {
+
         rerr = iSendingSocket.GetOpt(KL2CAPGetOutboundMTU, KSolBtL2CAP, getOptBuf);
+
         if(rerr == KErrNone)
+
 
             {
 
             {
             getOptValue = getOptBuf();           
+
             error = iPositioner.Open(iPosServer, iTargetModule);
            buf.Format(_L("Out MTU %d"), getOptValue);           
+
            iLog.LogL(buf);
+
 
             }
 
             }
         }
+
         else
   
+
   
+
    if(rerr == KErrNone)
+
        {
+
        rerr = iSendingSocket.GetOpt(KL2CAPInboundMTU, KSolBtL2CAP, getOptBuf);
+
        if(rerr == KErrNone)
+
 
             {
 
             {
             getOptValue = getOptBuf();           
+
             // Open subsession to the position server if it was targetted as default
             buf.Format(_L("In MTU %d"), getOptValue);             
+
             error = iPositioner.Open(iPosServer);             
            iLog.LogL(buf);
+
 
             }
 
             }
 
         }
 
         }
 
+
     else
     if(rerr == KErrNone)
+
 
         {
 
         {
         rerr = iSendingSocket.GetOpt(KL2CAPGetMaxOutboundMTU, KSolBtL2CAP, getOptBuf);
+
         // Open subsession to the position server if it was targetted as default
        if(rerr == KErrNone)
+
         error = iPositioner.Open(iPosServer);      
            {
+
            getOptValue = getOptBuf();
+
            buf.Format(_L("Max Out MTU %d"), getOptValue);           
+
            iLog.LogL(buf);                       
+
            }
+
         }
+
 
+
    if(rerr == KErrNone)
+
        {
+
        rerr = iSendingSocket.GetOpt(KL2CAPGetMaxInboundMTU, KSolBtL2CAP, getOptBuf);
+
        if(rerr == KErrNone)
+
            {
+
            getOptValue = getOptBuf();
+
            buf.Format(_L("Max In MTU %d"), getOptValue);           
+
            iLog.LogL(buf);                                               
+
            }
+
 
         }     
 
         }     
   
+
</code>
  
 +
== How to detect if a device support specific technology type ==
 +
 +
A device can support several technology type, that can be detected by application. Each technology can be enabled/disabled in the positioning settings of the devices.
 +
ETechnologyTerminal means the device has integrated GPS,  ETechnologyNetwork means positioning technology is network based and so on. More information in LbsCommon.h in SDK.
 +
 +
<code cpp>
 +
                if(info.TechnologyType()& TPositionModuleInfo::ETechnologyTerminal)
 +
                    {                             
 +
                        TPositionModuleInfo::TDeviceLocation deviceLoc =  info.DeviceLocation();
 +
                        if (deviceLoc == TPositionModuleInfo::EDeviceInternal)
 +
                            {
 +
                            //Checked GPS is available, you can use the information to your app
 +
                            }
 +
              }
 
</code>
 
</code>
  
== Required Capability and Example ==
+
== Using the Example ==
LocalServices capability is necessary to use this software..
+
 
[[Image:L2cap_Config.zip]]
+
We can ask this example to get the location From UI and the location is used to download map. The obtained location is the center of the map. So first half of the operation is location accusation and second half is obtaining map from Google. When we use network based solution then we should not see the satellite icon (for example in N97) on the other hand when we use GPS (a relatively longer process) to acquire location then we should not see the network connection icon. In this example, we see the network connection icon when we download the map and use network based or assisted GPS.
 +
<br>
 +
 
 +
<gallery widths=320px heights=240px perrow=2>
 +
File:Screenshot0038_.jpg|Select location technology type
 +
File:Screenshot0039_.jpg|Getting location
 +
File:Screenshot0040_.jpg|Location received
 +
File:Screenshot0041_.jpg|Map received
 +
</gallery>
 +
 
 +
* Download the example: [[File:Locationmethod.zip]]
 +
* Download the example for N8: [[File:N8LBSSample ModuleName.zip]]

Latest revision as of 02:07, 26 July 2012

Article Metadata
Code ExampleArticle
Created: mahbub_s60 (14 Sep 2010)
Last edited: hamishwillee (26 Jul 2012)

Contents

[edit] Introduction

There are different kind of positioning methods available in Symbian platform. This article briefly describes those and how to use each method from Symbian C++ application.


[edit] Description

Four different methods are available in Symbian platform. Each having different response time, accuracy and so on. Each location accusation method is identified with Uid and technology type. To use any of the method, we have to create a session with the positioning server and then we create a sub-session with the positioning server. When we create sub-session we can instruct the framework what positioning mechanism we are going to use. If we don't provide any specific positioning method then the server uses the positioning module with the highest priority by default. If the highest priority positioning module is not available or if it returns an error for a position request then the positioning module with the next highest priority is used. Following table shows different modules, name and it's Uid.


Technology Name Used Uid
Network based 0x10206915
Assisted GPS 0x101fe98c
Integrated GPS 0x101fe98a
Bluetooth GPS 0x101fe999

[edit] Detecting numbers of available modules

Following code try to find the number of modules and identify the desired module id (set by UI) that is going to be used for positioning. In this example we use the position information to download map.

    TUint module = 0;        
// Get the available numbers of modules
error = iPosServer.GetNumModules(module);
if(error != KErrNone)
{
iPosServer.Close();
return;
}
TPositionModuleInfo info;
 
for(TUint i = 0; i < module; i++)
{
error = iPosServer.GetModuleInfoByIndex(i,info);
TBool isavailable = info.IsAvailable();
if(error == KErrNone && isavailable)
{
TBuf<200> buf(0);
buf.SetLength(0);
buf.FillZ();
info.GetModuleName(buf);
 
if(!buf.Compare(_L("Network based")) && iELocModuleUsed == eNetwork)
{
iTargetModule = info.ModuleId();
break;
}
 
if(!buf.Compare(_L("Integrated GPS")) && iELocModuleUsed == eGPS)
{
iTargetModule = info.ModuleId();
break;
}
 
if(!buf.Compare(_L("Assisted GPS")) && iELocModuleUsed == eAssisted)
{
iTargetModule = info.ModuleId();
break;
}
 
if(info.TechnologyType()& TPositionModuleInfo::ETechnologyTerminal)
{
TPositionModuleInfo::TDeviceLocation deviceLoc = info.DeviceLocation();
if (deviceLoc == TPositionModuleInfo::EDeviceInternal)
{
//Checked GPS is available, you can use the information to your app
}
}
}
else
{
//Checked GPS is available, you can use the information to your app
}
}

[edit] Using the desired module

Following code shows how to use the desired module to find the location. If the desired target type is set then that module id can be used to open a sub-session.

    // Open subsession to the position server if it was targeted as Network based
if(iELocModuleUsed == eNetwork || iELocModuleUsed == eGPS || iELocModuleUsed == eAssisted)
{
if(iTargetModule != TUid::Null())
{
error = iPositioner.Open(iPosServer, iTargetModule);
}
else
{
// Open subsession to the position server if it was targetted as default
error = iPositioner.Open(iPosServer);
}
}
else
{
// Open subsession to the position server if it was targetted as default
error = iPositioner.Open(iPosServer);
}

[edit] How to detect if a device support specific technology type

A device can support several technology type, that can be detected by application. Each technology can be enabled/disabled in the positioning settings of the devices. ETechnologyTerminal means the device has integrated GPS, ETechnologyNetwork means positioning technology is network based and so on. More information in LbsCommon.h in SDK.

                if(info.TechnologyType()& TPositionModuleInfo::ETechnologyTerminal)
{
TPositionModuleInfo::TDeviceLocation deviceLoc = info.DeviceLocation();
if (deviceLoc == TPositionModuleInfo::EDeviceInternal)
{
//Checked GPS is available, you can use the information to your app
}
}

[edit] Using the Example

We can ask this example to get the location From UI and the location is used to download map. The obtained location is the center of the map. So first half of the operation is location accusation and second half is obtaining map from Google. When we use network based solution then we should not see the satellite icon (for example in N97) on the other hand when we use GPS (a relatively longer process) to acquire location then we should not see the network connection icon. In this example, we see the network connection icon when we download the map and use network based or assisted GPS.

This page was last modified on 26 July 2012, at 02:07.
97 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×