Adding a Device to the Start of the List

This topic shows you how to add a device to the first position in the list.

The position of a device in the list is represented by a position index, where 0 indicates the start of the list, followed by 1 ,2, 3 and so on. Adding a device to the start of the list means that the device is the first device that the Bluetooth GPS PSY attempts to connect to.

To add a device to the list, its Bluetooth device address (TBTDevAddr) must be specified. A device's Bluetooth address is obtained by looking up the device in the Bluetooth Registry. Note that device addresses must be unique within the list.

Call CLbsBtGpsConfig::AddDevice(const TBTDevAddr&, TInt, TLbsBtGpsEntryKey&). This function takes the address of the new device and the position in the list as input. Set aPosition = 0 to add the device to the start of the list.
// Add a new device at the start of the list
TInt err;
TBTDevAddr deviceAddress;
TLbsBtGpsEntryKey key;
err = iConfig->AddDevice(deviceAddress, 0, key);

Upon success, this step returns KErrNone and the unique key (type TLbsBtGpsEntryKey) that identifies the new device. The key is returned via the key reference that is passed in. The key is used to identify the device in any future operations, such as moving or removing.

If the address of the device being added is the same as one already in the list, then KErrAlreadyExists is returned.

The device is added to the first position in the list. If the connection to this device fails, then the Bluetooth GPS PSY moves onto the next in the list.