Opening a Session with the Bluetooth GPS PSY

This topic describes how to open a session with the Bluetooth GPS PSY.

Required background

Knowledge of the Location Acquisition API is helpful in understanding this topic.

Introduction

To use the Bluetooth GPS PSY a Location Acquisition API client opens an RPositioner subsession using one of the following methods:

  • Using the Default PSY

  • Using the Bluetooth PSY explicitly

These methods are described in more detail below.

Procedure

  • To use the Default PSY, open a session without specifying a PSY UID, as shown in the following example code:

    The Default PSY reads a list of all the PSYs installed in the device. If the Bluetooth GPS PSY is installed, the Default PSY uses it in preference to all other PSYs.

    If the Bluetooth GPS PSY cannot provide a position fix (for example, because it is unable to connect to a GPS device), the Default PSY tries to use alternative PSYs (if installed). Opening a session using the Default PSY does not guarantee that a position fix will be obtained from the Bluetooth GPS PSY.

    
    #include <lbs.h>
    #include <lbserrors.h>
    
    ...
    
    RPositionServer server;
    RPositioner positioner;
    
    //Create a session with the Location Server
    
    User::LeaveIfError(server.Connect());
    CleanupClosePushL(server);
    
    // Location Server uses the default PSY, which preferentially uses the Bluetooth GPS PSY
    
    User::LeaveIfError(positioner.Open(server);
    CleanupClosePushL(positioner);
    
    // Use Location Acquisition API as normal
    // Call RPositioner::NotifyPositionUpdate() - see API documentation for more details
    
    ...
    
    // Close the session
    
    CleanupStack::PopAndDestroy(&positioner);
    CleanupStack::PopAndDestroy(&server);
    
    1. See Default PSY for information about how a PSY is selected.

    2. See How to Get Location Information for more information about using the Location Acquisition API.

  • To specify that the Bluetooth GPS PSY must be used, open a session using its implementation UID (0x101FE999), as shown in the following example code:

    
    #include <lbs.h>
    #include <lbserrors.h>
    
    
    const TInt KBTPSYImplUid = 0x101FE999;
    
    ...
    
    RPositionServer server;
    RPositioner positioner;
    
    //Create a session with the Location Server
    
    User::LeaveIfError(server.Connect());
    CleanupClosePushL(server);
    
    // Create a subsession with the Location Server using the Bluetooth PSY
    
    User::LeaveIfError(positioner.Open(server, TUid::Uid(KBTPSYImplUid)));
    CleanupClosePushL(positioner);
    
    // Use Location Acquisition API as normal - see API documentation for more details
    
    ...
    
    // Close the session
    
    CleanupStack::PopAndDestroy(&positioner);
    CleanupStack::PopAndDestroy(&server);
    

    If the Bluetooth PSY cannot provide a position fix, the location request will fail. An error code other than KErrNone will be returned to the client application.

    The Bluetooth GPS PSY supports the class types TPositionInfo, TPositionCourseInfo, TPositionSatelliteInfo and HPositionGenericInfo. The argument to RPositioner::NotifyPositionUpdate() must be one of these classes. HPositionGenericInfo, TPositionCourseInfo and TPositionSatelliteInfo are all derived from TPositionInfo.