×
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)
(This article shows how to use different technology to find location)
 
mahbub_s60 (Talk | contribs)
Line 1: Line 1:
 
[[Category:Location]][[Category:Location Based Services]][[Category:Symbian C++]]
 
[[Category:Location]][[Category:Location Based Services]][[Category:Symbian C++]]
 +
== 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.
 +
 +
 +
== 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.
 +
 +
 +
----
 +
Name                                                  Uid
 +
 +
Network based                                    0x101fe98a
 +
Assisted GPS                                      0x101fe98c
 +
Integrated GPS                                    0x101fe98a
 +
Bluetooth GPS                                    0x101fe999
 +
----
 +
 +
== Solution ==
 +
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.
 +
<br>
 +
 +
Code for configuring the L2CAP connection.<br>
 +
<code cpp>
 +
 +
 +
    iLog.LogL(_L("Connecting to service"));
 +
User::LeaveIfError(iSendingSocket.Open(iSocketServer, _L("L2CAP")));
 +
    TBTSockAddr address;
 +
    address.SetBTAddr(iServiceSearcher->BTDevAddr());
 +
    address.SetPort(iServiceSearcher->Port());
 +
    TBuf<100> buf(0);   
 +
    TL2CapConfigPkg  ConfigPkg = iL2CapAPIConfig;           
 +
    ConfigPkg().SetMaxTransmitUnitSize(iMaxTransmitUnit);    // has been set or use some default value specified in constructor
 +
    ConfigPkg().SetMaxReceiveUnitSize(iMaxReceivedUnit);    // has been set or use some default value specified in constructor       
 +
    TInt rerr = iSendingSocket.SetOpt(KL2CAPUpdateChannelConfig, KSolBtL2CAP, ConfigPkg);
 +
    buf.Format(_L("SetOpt ret= %d"), rerr);       
 +
    iSendingSocket.Connect(address, iStatus);
 +
 +
#ifdef __WINS__
 +
    User::After(1);    // Fix to allow emulator client to connect to server
 +
#endif
 +
 +
    SetActive();
 +
 +
</code>
 +
 +
 +
Code for  getting the configuration value from L2CAP link.<br>
 +
This will return us the inbound  and outbound transmission unit  as well as inbound and outbound MTU.
 +
 +
<code cpp>
 +
 +
   
 +
    TInt rerr = KErrNone;
 +
    TPckgBuf<TInt> getOptBuf;
 +
    TInt getOptValue = 0;
 +
    TBuf<100> buf(0);
 +
   
 +
   
 +
   
 +
 +
    if(rerr == KErrNone)
 +
        {
 +
        rerr = iSendingSocket.GetOpt(KL2CAPGetOutboundMTU, KSolBtL2CAP, getOptBuf);
 +
        if(rerr == KErrNone)
 +
            {
 +
            getOptValue = getOptBuf();           
 +
            buf.Format(_L("Out MTU %d"), getOptValue);           
 +
            iLog.LogL(buf);
 +
            }
 +
        }
 +
   
 +
   
 +
    if(rerr == KErrNone)
 +
        {
 +
        rerr = iSendingSocket.GetOpt(KL2CAPInboundMTU, KSolBtL2CAP, getOptBuf);
 +
        if(rerr == KErrNone)
 +
            {
 +
            getOptValue = getOptBuf();           
 +
            buf.Format(_L("In MTU %d"), getOptValue);           
 +
            iLog.LogL(buf);
 +
            }
 +
        }
 +
 +
    if(rerr == KErrNone)
 +
        {
 +
        rerr = iSendingSocket.GetOpt(KL2CAPGetMaxOutboundMTU, KSolBtL2CAP, getOptBuf);
 +
        if(rerr == KErrNone)
 +
            {
 +
            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>
 +
 +
== Required Capability and Example ==
 +
LocalServices capability is necessary to use this software..
 +
[[Image:L2cap_Config.zip]]

Revision as of 15:01, 14 September 2010

Contents

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.


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.



Name Uid

Network based 0x101fe98a Assisted GPS 0x101fe98c Integrated GPS 0x101fe98a Bluetooth GPS 0x101fe999


Solution

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.

Code for configuring the L2CAP connection.

    iLog.LogL(_L("Connecting to service"));
User::LeaveIfError(iSendingSocket.Open(iSocketServer, _L("L2CAP")));
TBTSockAddr address;
address.SetBTAddr(iServiceSearcher->BTDevAddr());
address.SetPort(iServiceSearcher->Port());
TBuf<100> buf(0);
TL2CapConfigPkg ConfigPkg = iL2CapAPIConfig;
ConfigPkg().SetMaxTransmitUnitSize(iMaxTransmitUnit); // has been set or use some default value specified in constructor
ConfigPkg().SetMaxReceiveUnitSize(iMaxReceivedUnit); // has been set or use some default value specified in constructor
TInt rerr = iSendingSocket.SetOpt(KL2CAPUpdateChannelConfig, KSolBtL2CAP, ConfigPkg);
buf.Format(_L("SetOpt ret= %d"), rerr);
iSendingSocket.Connect(address, iStatus);
 
#ifdef __WINS__
User::After(1); // Fix to allow emulator client to connect to server
#endif
 
SetActive();


Code for getting the configuration value from L2CAP link.
This will return us the inbound and outbound transmission unit as well as inbound and outbound MTU.

 
TInt rerr = KErrNone;
TPckgBuf<TInt> getOptBuf;
TInt getOptValue = 0;
TBuf<100> buf(0);
 
 
 
 
if(rerr == KErrNone)
{
rerr = iSendingSocket.GetOpt(KL2CAPGetOutboundMTU, KSolBtL2CAP, getOptBuf);
if(rerr == KErrNone)
{
getOptValue = getOptBuf();
buf.Format(_L("Out MTU %d"), getOptValue);
iLog.LogL(buf);
}
}
 
 
if(rerr == KErrNone)
{
rerr = iSendingSocket.GetOpt(KL2CAPInboundMTU, KSolBtL2CAP, getOptBuf);
if(rerr == KErrNone)
{
getOptValue = getOptBuf();
buf.Format(_L("In MTU %d"), getOptValue);
iLog.LogL(buf);
}
}
 
if(rerr == KErrNone)
{
rerr = iSendingSocket.GetOpt(KL2CAPGetMaxOutboundMTU, KSolBtL2CAP, getOptBuf);
if(rerr == KErrNone)
{
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);
}
}

Required Capability and Example

LocalServices capability is necessary to use this software.. File:L2cap Config.zip

52 page views in the last 30 days.