Introduction
With the version 8.0a the Publish&Subscribe API was introduced. This API simplifies the communication between multiple processes. Besides this new API replaced the access to the Bluetooth Host Controler Interface.
The Host Controler Interface (HCI) offers an access to the Bluetooth baseband and permits to read the Bluetooth address or to shift the mobile telephone into another dicoverbility mode. If you try to address the Host Controler Interface like in former times via the socket, then the method SetIoctl throws the error KErrNotSupported.
The use of the Publish&Subscribe API is shown here. However the usage of the Publish&Subscribe API in connection with the host controller interface isn’t described anythere.
How to use the api
In the header file bt_subscribe.h of the SDK variables are specified, which can be used in connection with the Publish&Subsribe API to access the HCI:
// For Bluetooth notifications via Publish & Subscribe
const TUid KPropertyUidBluetoothCategory = {0x101FD916};
//to send properties *to* the stack
const TUid KPropertyUidBluetoothControlCategory = {0x101FD917};
// enumerate keys here
const TUint KPropertyKeyBluetoothLocalDeviceAddress = 0;
const TUint KPropertyKeyBluetoothPHYCount = 1;
const TUint KPropertyKeyBluetoothConnecting = 2;
const TUint KPropertyKeyBluetoothScanning = 3;
const TUint KPropertyKeyBluetoothLimitedDiscoverable = 4;
const TUint KPropertyKeyBluetoothDeviceClass = 5;
const TUint KPropertyKeyBluetoothRegistryTableChange = 0x1000;
// the values for the keys
//RegistryTableChanges
const TUint KRegistryChangeRemoteTable = 0;
const TUint KRegistryChangeLocalTable = 1;
const TUint KRegistryChangeCSYTable = 2;
To read the Bluetooth addresse for example the following call can be accomplished:
TPckgBuf<TBTDevAddr> aDevAddrPckg;
TInt error = RProperty::Get(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothLocalDeviceAddress, aDevAddrPckg);
For writing a Properties it firstly has to be defined. The next example shows how to set the discoverbility mode:
RProperty::Define(KPropertyUidBluetoothControlCategory, KPropertyKeyBluetoothLimitedDiscoverable, RProperty::EByteArray);
TPckgBuf <TUint32> type = KLIAC;// KGIAC
return RProperty::Set(KPropertyUidBluetoothControlCategory, KPropertyKeyBluetoothLimitedDiscoverable, type);
Conclusion
The Publish&Subscirbe API provides an ease way to access the Host Controller interface. Unfortunately the API in connection with the Host Controler Interface isn’t described anywhere. If you now how the Publish&Subscibes API simplyfies the access to the HCI.
|