API Reference | developer.brewmp.com API Reference | developer.brewmp.com

Developer

API Reference

IBTDEVDBCONTROL

Brew Release
Brew MP 1.0.2
See Also
Description
Bluetooth Device Database Control interface.
This interface allow for reading number of device entries and the corresponding BDAddress in the device database.
Application can retrieve commonly used fields of the device entry by calling IBTDevDBControl_GetDeviceShortEntry() API
Device Databse gets updated during various Bluetooth operations such as Inquiry, Bonding and Connection establishment
This interface also servers as factory interface to create an IBTDevDBRecord interface, which can be used to set or get data, associated with a particular device record. Based on the privilege of the caller, IBTDevDBControl_GetDeviceEntryRecord()API shall return either read only access IBTDevDBRecord or one with read and write access to the device record.

Usage

Usage example:



   ===== To create an IBTDevDBControl object, see instruction in class header file

   ===== To retrieve total number of entries and BDAddress of the entries
         in the device DB
         // Set the search criteria
         AEEBTDevDBSrchPattern searchPattern; 
         searchPattern.srchCriteria = AEEBT_DEVDB_SEARCH_ALL;  
       
         // First get the total number of devices
         IBTDevDBControl_GetNumDevEntries(piBTDevDBCtl,
                                          &searchPattern,
                                          NULL,
                                          0,
                                          &lenReq);

         // Now get the BDAddress of the entries  
         BDAddress *pBdAddrArr = NULL; 
         IEnv_ErrMalloc (pIEnv, lenReq * sizeof(BDAddress), (void**)&pBdAddrArr);

         IBTDevDBControl_GetNumDevEntries(piBTDevDBCtl,
                                         &searchPattern,
                                         pBdAddrArr,    // placeholder for BDAddress of device
                                                          entries
                                          len,          // num of entries in bdAddrArr
                                          &lenReq);
                                 
   ===== To retrieve number of entries and BDAddress of the entries
         in the device DB based on a Class of Device search criteria 
       (e.g search all headset Bluetooth devices)
          // Set the search criteria
       AEEBTDevDBSrchPattern searchPattern; 
       searchPattern.srchCriteria  = AEEBT_DEVDB_SEARCH_COS | 
                                   AEEBT_DEVDB_SEARCH_DC  |
                                   AEEBT_DEVDB_SEARCH_SDC;  
       searchPattern.cos         = AEEBT_COS_AUDIO;
       searchPattern.devClass    = AEEBT_DC_AUDIO;
       searchPattern.subDevClass = AEEBT_SDC_AUDIO_HEADSET;
       
       // First get the total number of matching devices
       IBTDevDBControl_GetNumDevEntries(piBTDevDBCtl,
                                        &searchPattern,
                                        NULL,
                                        0,
                                        &lenReq);

       // Now get the BDAddress of the entries  
       BDAddress *pBdAddrArr = NULL; 
       IEnv_ErrMalloc (pIEnv, lenReq * sizeof(BDAddress),(void**)&pBdAddrArr);
       IBTDevDBControl_GetNumDevEntries(piBTDevDBCtl,
                                       &searchPattern,
                                       pBdAddrArr,    // placeholder for BDAddress of device
                                                        entries
                                       len,          // num of entries in bdAddrArr
                                       &lenReq);
       
   ===== To retrieve number of entries in device DB based on BD Address mask
       (e.g To find all bonded devices whose BD addresses end with 1234)

       // Set the search criteria
       AEEBTDevDBSrchPattern searchPattern; 
       searchPattern.srchCriteria  = AEEBT_DEVDB_SEARCH_BDADDR |
                                   AEEBT_DEVDB_SEARCH_BONDED;
         searchPattern.bBonded     = TRUE; 
       searchPattern.bdAddrMask.uAddr[0] = 0x00; 
       searchPattern.bdAddrMask.uAddr[1] = 0x00; 
       searchPattern.bdAddrMask.uAddr[2] = 0x00; 
       searchPattern.bdAddrMask.uAddr[3] = 0x00; 
       searchPattern.bdAddrMask.uAddr[4] = 0xFF; 
       searchPattern.bdAddrMask.uAddr[5] = 0xFF;

       searchPattern.bdAddrValue.uAddr[4]= 0x12;
       searchPattern.bdAddrValue.uAddr[5]= 0x34;
       
       IBTDevDBControl_GetNumDevEntries(piBTDevDBCtl,
                                        &searchPattern,
                                        NULL,
                                        0,
                                        &lenReq);

       // Now get the BDAddress of the entries  
       BDAddress *pBdAddrArr = NULL; 
       IEnv_ErrMalloc (pIEnv, lenReq * sizeof(BDAddress),(void**)&pBdAddrArr);
       IBTDevDBControl_GetNumDevEntries(piBTDevDBCtl,
                                        &searchPattern,
                                        pBdAddrArr,    // placeholder for BDAddress of device
                                                         entries
                                        len,          // num of entries in bdAddrArr
                                        &lenReq);

   ===== To get the short entry (common fields) corresponding to a device entry
         IBTDevDBControl_GetDeviceShortEntry(piBTDevDBCtl, &bdAddr,&devDBShortEntry);
          
   ===== To get a IBTDeviceDBRecord handle corresponding to an entry
         IBTDevDBControl_GetDeviceEntryRecord(piBTDevDBCtl,
                                              &bdAddr,
                                              &pBTDevRecord); // Address of IBTDevDBRecord
                                                             // interface pointer

        
   ===== When done with IBTDevDBControl object:
   IBTDevDBControl_Release (piBTDevDBCtl);