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

Developer

API Reference

IBTDEVDBRECORD

Brew Release
Brew MP 1.0.2
See Also
Description
Bluetooth Device Database Record interface.
IBTDevDBRecord interface provides access to one entry in the database corresponding to a BDAddress. This interface can be retrieved using IBTDevDBRecord_GetDevEntryRecord() API of IBTDevDBControl interface.
This interface provides APIs to read the complete record data corresponding to the record, Get nick name and Name of the Device.These APIs can be accessed by the callers regardless of the privileges of the caller
The interface also provides few privileged API's Set the nickname of the device, keep and remove the device entry in persistent memory.
The interface also provides APIs to register a signal with the interface to receive notification whenever the device entry is updated.
Usage

Usage example:



   ===== To create an IBTDevDBRecord object, see the documentation of 
         IBTDevDBControl interface

   ===== To read entire record data associated with DeviceDB record
         IBTDevDBRecord_Read(piBTDevDBRec,
                             &devEntry); // address of AEEBTDevDBEntry
                                        // structure

   ===== To read Name of the device associated with the device entry
         // First get the len by passing NULL buffer with len = 0
         IBTDevDBRecord_GetDeviceName( piBTDevDBRec,
                                       NULL,
                                       0,
                                       &pszNameLenReq,
                                       &bShortName);
         char*pName = NULL; 
         IEnv_ErrMalloc (pIEnv, pszNameLenReq,(void**)&pName);

       if ( pName != NULL )
       {
            IBTDevDBRecord_GetDeviceName( piBTDevDBRec,
                                          pName,
                                          pszNameLenReq,
                                          &pszNameLenReq,
                                          &bShortName);
       }

   ===== To read Nick Name of the device associated with the device entry
         char *pszNickName = NULL;
         IEnv_ErrMalloc (pIEnv, 20,(void**)&pszNickName);

         IBTDevDBRecord_GetNickName(piBTDevDBRec,
                                    pszNickName,
                                    20,
                                    &pszNickNameLenReq);
          if ( pszNickNameLenReq > 20) // Check if the Buffer passed for
                                      // copying NickName was not large enough
           {
            //Realloc the buffer.
            IEnv_ErrRealloc(pIEnv, pszNickNameLenReq,(void**)&pszNickName);
            IBTDevDBRecord_GetNickName(piBTDevDBRec,
                                       pszNickName,
                                       pszNickNameLenReq,
                                       &pszNickNameLenReq);
          }

   ===== To register the signal with interface to receive the notification
         when Device record is updated
         // first create the signal;
         // for example, use ISignalCBFactory_CreateSignal()
         // then register the signals:		 
         IBTDevDBRecord_NotifyRecordUpdate(piBTDevDBRec, pISignal);
                                   
   ===== To keep the device record in the persistent memory
         IBTDevDBRecord_Keep(piBTDevDBRec);
                          
   ===== To remove the device record from the device database
         IBTDevDBRecord_Remove(piBTDevDBRec);
       
   ===== To update the nick name of the remote device in the entry 
         IBTDevDBRecord_SetNickName(piBTDevDBRec, "My Headset");		 
   
   ===== When done with IBTDevDBRecord object:
         IBTDevDBRecord_Release (piBTDevDBRec);