CLbsBtGpsConfig Class Reference

class CLbsBtGpsConfig : public CBase

LBS Bluetooth GPS Configuration API

API used to configure Bluetooth GPS devices for use with LBS, allowing a preferred list of devices to be maintined. When required, the LBS Bluetooth positioning plugin will attempt to connect to each device in the list in order, until a succesful connection to a GPS device is made.

Through this API an application can read, add to, remove from, and reorder the list of preferred Bluetooth GPS devices. Accessing this API requires the LocalServices capability, in addition, calling any methods which can modify the configuration requires the WriteDeviceData capability.

class CLbsBtGpsConfigExample : public CActive, public MLbsBtGpsConfigObserver
	{

public:

	CLbsBtGpsConfigExample() : CActive(CActive::EPriorityStandard)
		{
		CActiveScheduler::Add(this);
		
		// Create an instance of the API
		// NOTE: Our class implements the observer interface MLbsBtGpsConfigObserver
		iConfig = CLbsBtGpsConfig::NewL(*this);

		// ...
		  
		}

	~CLbsBtGpsConfigExample()
		{
		delete iConfig;
		iDeviceList.ResetAndDestroy();
		iDeviceList.Close();
		}
	
	void ExampleCode()
		{
		// Add a new device at the start of the list
		TInt err;
		TBTDevAddr deviceAddress;
		TLbsBtGpsEntryKey key;
		err = iConfig->AddDevice(deviceAddress, 0, key);
		// NOTE: key contains the unique device key, used to identify the device

		// Move the device around in the list
		// This will move it into 8th place (index is zero based), or, if there are 
		// currently less than 8 devices in the list, it will move it to the end. 
		iConfig->ReorderDevice(key, 7);

		// Remove the device from the list
		iConfig->RemoveDevice(key);
		}
	
	virtual void OnDeviceListUpdate()
		{
		test.Printf(_L(" --- OnDeviceListUpdate ---\n"));

		// Retrieve the list of devices
		iDeviceList.ResetAndDestroy();
		iConfig->GetDeviceListL(iDeviceList);

		// Loop through the devices
		for (TInt index=0; index<iDeviceList.Count(); ++index)
			{
			// Get at the device information from the list
			const TLbsBtGpsDeviceInfo* deviceInfo = iDeviceList[index];
			
			// Do something (e.g. display on a GUI)

			}

		// Destroy the retrieved copy of the list now we have finished using it
		iDeviceList.ResetAndDestroy();
		}

private:

	CLbsBtGpsConfig* iConfig;
	RPointerArray<TLbsBtGpsDeviceInfo> iDeviceList;

	// ...
	
	};

An application must wait for the RunL of the class implementing the MLbsBtGpsConfigObserver interface to return before calling any other public methods on this class.

Inherits from

Constructor & Destructor Documentation

CLbsBtGpsConfig()

CLbsBtGpsConfig()[protected]

Class constructor

CLbsBtGpsConfig(const CLbsBtGpsConfig &)

CLbsBtGpsConfig(const CLbsBtGpsConfig &)[private]

Prohibit copy constructor

Parameters

const CLbsBtGpsConfig &

~CLbsBtGpsConfig()

IMPORT_C~CLbsBtGpsConfig()[virtual]

Destructor

Member Functions Documentation

AddDevice(const TBTDevAddr &, TInt, TLbsBtGpsEntryKey &)

IMPORT_C TIntAddDevice(const TBTDevAddr &aAddress,
TIntaPosition,
TLbsBtGpsEntryKey &aKey
)

Adds a new device at the specified position index within the list

The new device will assume the specified position in the list, shifting exsiting devices at this position or below one place towards the end of the list in order to achieve this.

Specifying aPosition = 0 will result in the device being added to the start of the list. Specifying aPosition >= DeviceCount() will result in the device being added to the end of the list.

capability
LocalServices
capability
WriteDeviceData

Parameters

const TBTDevAddr & aAddress[In] Address of the new device.
TInt aPosition[In] Position in the list at which to add the device (where 0 indicates the start of the list).
TLbsBtGpsEntryKey & aKey[Out] Recieves the unique key assigned to identify the new device.

ConstructL(MLbsBtGpsConfigObserver *)

voidConstructL(MLbsBtGpsConfigObserver *aObserver)[protected]

Second phase constructor

leave
KErrPermissionDenied Client does not have the required capabilities.

Parameters

MLbsBtGpsConfigObserver * aObserver[IN] Optional observer, which will recieve update notifications.

EmptyDeviceList()

IMPORT_C TIntEmptyDeviceList()

Empties the device list, removing all device entries

capability
LocalServices
capability
WriteDeviceData

ExtendedInterface(TInt, TAny *, TAny *)

IMPORT_C TAny *ExtendedInterface(TIntaFunctionNumber,
TAny *aPtr1,
TAny *aPtr2
)[private, virtual]

This methods is reserved for future expansion and should not be used

capability
LocalServices

Parameters

TInt aFunctionNumberReserved for future expansion
TAny * aPtr1Reserved for future expansion
TAny * aPtr2Reserved for future expansion

GetDeviceCount(TInt &)

IMPORT_C TIntGetDeviceCount(TInt &aCount)

Returns the number of devices present in the list

capability
LocalServices

Parameters

TInt & aCount[Out] Revieves the number of devices in the list.

GetDeviceListL(RPointerArray< TLbsBtGpsDeviceInfo > &)

IMPORT_C voidGetDeviceListL(RPointerArray< TLbsBtGpsDeviceInfo > &aList)

Retrieves the list of devices

The passed list is populated with TLbsBtGpsDeviceInfo objects containing information for each device in the list. Ownership of these objects is returned, so they should be deleted by the client when they are no longer needed (this can be done easily using RPointerArray::ResetAndDestroy).

leave
KErrPermissionDenied if the client does not have the required capabilities.
capability
LocalServices

Parameters

RPointerArray< TLbsBtGpsDeviceInfo > & aList[Out] Reference to an empty RPointerArray to populate with device entries from the list.

NewL()

IMPORT_C CLbsBtGpsConfig *NewL()[static]

Static constructor (without observer) Creates an instance of the LBS Bluetooth GPS Configuration API. This version is for clients that do not require configuration update notifications.

leave
KErrPermissionDenied Client does not have the required capabilities.
capability
LocalServices

NewL(MLbsBtGpsConfigObserver &)

IMPORT_C CLbsBtGpsConfig *NewL(MLbsBtGpsConfigObserver &aObserver)[static]

Static constructor (with observer) Creates an instance of the LBS Bluetooth GPS Configuration API, specifying a callback to recieve update notifications.

leave
KErrPermissionDenied Client does not have the required capabilities.
MLbsBtGpsConfigObserver
capability
LocalServices

Parameters

MLbsBtGpsConfigObserver & aObserver[IN] Observer which will recieve update notifications.

RemoveDevice(TLbsBtGpsEntryKey)

IMPORT_C TIntRemoveDevice(TLbsBtGpsEntryKeyaKey)

Removes a device from the list

capability
LocalServices
capability
WriteDeviceData

Parameters

TLbsBtGpsEntryKey aKey[In] The key identifying the device.

ReorderDevice(TLbsBtGpsEntryKey, TInt)

IMPORT_C TIntReorderDevice(TLbsBtGpsEntryKeyaKey,
TIntaNewPosition
)

Reorders a device in the list by specifying a new position index

The device identified by the key will assume the specified position in the list, shifting exsiting devices as required in order to achieve this.

Specifying aNewPosition = 0 will result in the device being moved to the start of the list. Specifying aNewPosition >= DeviceCount() will result in the device being moved to the end of the list.

When a device is moved towards the start of the list, other devices located between the old and new positions will be shifted towards the end of the list by one place. For example, starting with a list {A,B,C,D,E}, moving device D to position 1 would result in {A,D,B,C,E}.

Similarly, when a device is moved towards the end of the list, other devices located between the old and new positions will be shifted towards the start of the list by one place. For example, starting with a list {A,B,C,D,E}, moving device B to position 3 would result in {A,C,D,B,E}

capability
LocalServices
capability
WriteDeviceData

Parameters

TLbsBtGpsEntryKey aKey[In] The key identifying the device.
TInt aNewPosition[In] New position index for the device in the list (where 0 indicates the start of the list).

operator=(const CLbsBtGpsConfig &)

CLbsBtGpsConfig &operator=(const CLbsBtGpsConfig &)[private]

Prohibit assigment operator

Parameters

const CLbsBtGpsConfig &

Member Data Documentation

CLbsBtGpsConfigImpl * iImpl

CLbsBtGpsConfigImpl *iImpl[protected]

Implementation pointer