Developer

API Reference

IBTPBAPServer

Brew Release
Brew MP 1.0.2
Description

Bluetooth Phone Book Access Profile, Server role (PSE)
This interface enables the server role (PSE) of Phone Book Access as Defined by the Bluetooth SIG.
When enabling a PBAP server, application must provide a security level, the server name, a phonebook repository and a boolean value indicating if it wants to receive client request related to Phonebook operations. PBAP server requires AEEBT_SEC_AUTHENTICATE as minimum security level. Once enabled, PBAP server is ready to accept connection request from potential PBAP clients. For each incoming connection application shall receive AEEBTPBAPSRV_EV_CONN_REQ event and application needs to respond by calling AcceptConnection API.
If OBEX authentication is required by the server or initiated by the client, application should expect and handle authentication request before a connection could be set up using IOBEXAuthentication interface.
Once a connection is set up, server can accept Phonebook download request, vCard listing request or Pull vCard request from the client. If application had set bNotifyCliReq flag to TRUE during registration, these requests shall be sent to application via AEEBTPBAPSRV_EV_PB_ACCESS_REQ event. Application needs to call AcceptPBAccessReq API to accept or reject these client requests. Also if application wants to compose the phonebook response instead of allowing underlying implementation to compose the response, it should send the phonebook data , length and a boolean value indicating if this is final packet as parameters to AcceptPBAccessReq() function. The maximum acceptable buffer size is indicated by maxInputLen field of AEEBTPBAPCliReqInfo which is sent as event data for the event AEEBTPBAPSRV_EV_PB_ACCESS_REQ.
If bNotifyCliReq flag was set to FALSE during registration, underlying implementation shall automatically handle all the client requests.
Usage

Usage example:



   ===== To create an IBTPBAPServer object, see instruction in class header file
  
   ===== To register signal
   // first create the signals;
   // for example, use ISignalCBFactory_CreateSignal()
   // then register the signals:
   IBTPBAPServer_OnEventNotify (piBTPBAPSrv, piSignal);
 
 
   ===== To enable PBAP server:
   IBTPBAPServer_Enable  (piBTPBAPSrv, AEEBT_SEC_AUTHENTICATE, 
                          "PBAP Server", AEEBTPBAP_REPOSITORY_LOCAL_AND_SIM ,TRUE)
 
   =====To Accept the incoming connection request 
   IBTPBAPServer_AcceptConnection (piBTPBAPSrv,TRUE );
 
 ===== To get IOBEXAuthentication object
   IBTPBAPServer_QueryInterface(piBTPBAPSrv, AEEIID_IOBEXAuthentication,
                                   (void**)&piAuth);
                   
   ===== To Register for OBEX Authentication Requests from client
   // first create the signals;
   // for example, use ISignalCBFactory_CreateSignal()
   // then register the signals:
   IOBEXAuthentication_OnRequest(piAuth, pSigAuthReq);

   ===== To handle the OBEX Authentication requests from client
   ISignalCtl_Enable (pSigAuthReq);
   // Get Password and Uid(if required) from user
   IOBEXAuthentication_Authenticate(piAuth,
                                NULL, // Uid
                                0,   // Uid len
                                (uint8 *)szPasswd,  //Password
                                STRLEN(szUserData) // password len 
                                );
   
   ===== To Configure OBEX Authentication related parameters 
    IOBEXAuthentication_Config( piAuth,
                          MIBENUM_CHARSET_US_ASCII, // character set for realm str
                          NULL,                     // Realm str
                          0,                        // realm str len len
                          FALSE,                    //UID is should not be used  
                          TRUE,                     // Full access
                          FALSE                     // This config data should NOT be considered invalid
                                                    // after one operation  
                          );

   ===== To Register for OBEX authenticate response from client
   // first create the signals;
   // for example, use ISignalCBFactory_CreateSignal()
   // then register the signals:
   IOBEXAuthentication_OnResponse(piAuth, pSigAuthResp);

   ===== To handle the OBEX Authentication response from client
   ISignalCtl_Enable (pSigAuthResp);
   // Get Password and Uid(if required) from user
   IOBEXAuthentication_Authenticate(piAuth,
                                NULL, // Uid
                                0,   // Uid len
                                (uint8 *)szPasswd,  //Password
                                STRLEN(szUserData) // password len 
                                );
                 
   ===== To retrieve and handle events when Event signal is triggered:
  while( IBTPBAPServer_GetEvent (piBTPBAPSrv, &eventData) != AEE_ENOMORE )
  {
    switch( eventData.event )
    {
      case AEEBTPBAPSRV_EV_ENABLED:
      case AEEBTPBAPSRV_EV_DISABLED:
      case AEEBTPBAPSRV_EV_PB_OP_DONE:
        // check eventData.cResult to see if it was successful
        break;

      case AEEBTPBAPSRV_EV_CONN_REQ:
        // eventData.bdAddr tells who the client (PCE) is
    // Incase OBEX Authentication is required, perform OBEX authentication
    // using IOBEXAuthentication interface.
        // Else prompt user "PBAP conn req.
        // Accept ? "
        // Based on user input set bAccept to TRUE or FALSE
        IBTPBAPServer_AcceptConnection (piBTPBAPSrv, bAccept);
        break;

      case AEEBTPBAPSRV_EV_CONNECTED: 
      case AEEBTPBAPSRV_EV_DISCONNECTED:
        // eventData.bdAddr tells which client (PCE) has connected/disconnected
        break;

      case AEEBTPBAPSRV_EV_PB_ACCESS_REQ:
        // Remote client (PCE) asked for some service
        //eventData.bdAddr tells BD address of client.
        // retrieve which operation was requested from eventData.opType
        
        / To reject the request call 
        IBTPBAPServer_AcceptPBAccessReq (piBTPBAPSrv,
                                         AEEBTPBAP_RESP_TYPE_REJECT_REQ,  // reject the request
                                         NULL,
                                         0 ,
                                         0,
                                         0,
                                         TRUE,
                                         AEEBT_RESULT_SUCCESS);
        
        // To service the call and let implementation handle composing of data
        IBTPBAPServer_AcceptPBAccessReq (piBTPBAPSrv,AEEBTPBAP_RESP_TYPE_ACCEPT_REQ,
                                         NULL, 0,0,0,TRUE,
                                         AEEBT_RESULT_SUCCESS);
        
        // To service the call and send the data from application
        // First retrieve the client request info
        IBTPBAPServer_GetClientReqInfo(piBTPBAPSrv,
                                       eventData.opType,          // op type 
                                       &cliReqInfo,               // address of client req info 
                                       SearchValueBuf,            // buffer to store search value
                                       SerachValLen,              // size of buffer
                                       &SearchValLenReq,          // out param to store actual length of
                                                                  // search value 
                                       userFldrBuf,               // buffer to store user defined folder(if any)
                                       userFldrLen,               // size of buffer
                                       &userFldrLenReq);          // out param to store actual length of
                                                                  // user folder len 
        // cliReqInfo shall be filled with the details of client request.
        // In case of vCard listing operation or Pull-v Card operation
        // it is adviced that App calls this API twice , first to get the size
        // of search text by passing a NULL buffer (srchValue param should be 
        // set to NULL and srchValueLen param should be set to 0)
        // and second time retrieve actual text.

        // In case of objType is AEEBTPBAP_OBJTYPE_USER_DEFINED,it is adviced
        // that App calls this API twice , first to get the length of folder string 
        // by passing a NULL buffer (szUserFolder param should be set to NULL
        // and szUserFolderLen param should be set to 0)
        // and second time retrieve actual search text.

        // To respond to the request in a single packet, 
        IBTPBAPServer_AcceptPBAccessReq (piBTPBAPSrv,
                                        AEEBTPBAP_RESP_TYPE_APP_SERVICE_REQ,
                                        pbData,      // phonebook data
                                        pbDataLen ,  // length of the pbData buffer 
                                        200,         // number of phonebook entries. 
                                        0,           // no unchecked missed calls
                                        TRUE ,       // Last packet = TRUE;
                                        AEEBT_RESULT_SUCCESS);
        // To service the call and send the data from application
        // in multiple packets (Note that application shall receive 
        // AEEBTPBAPSRV_EV_PB_ACCESS_REQ events until bFinal flag is set to TRUE) 
        IBTPBAPServer_AcceptPBAccessReq (piBTPBAPSrv,
                                         AEEBTPBAP_RESP_TYPE_APP_SERVICE_REQ,
                                         pbData,      // phonebook data
                                         pbDataLen ,  // length of the pbData buffer 
                                         200,         // number of phonebook entries. 
                                         0,           // no unchecked missed calls
                                         FALSE,       // Last packet = FALSE;
                                         AEEBT_RESULT_SUCCESS);        
        break;

      case AEEBTPBAPSRV_EV_PB_OP_DONE:
        // A Phonebook Operation is done. Fetch the details of 
        // operation and status from eventData.opResult
        break;

      case AEEBTPBAPSRV_EV_EVENT_Q_OVERFLOW:
        // eventData.nDroppedEvents tells how many events got dropped
        // since previous GetEvent()
        break;
    }
  } 
ISignalCtl_Enable (piSignalCtl); // re-enable signal


===== When done with PBAP server:
IBTPBAPServer_ForceDisconnect (piBTPBAPSrv);
IBTOPPServer_Disable (piBTPBAPSrv);
IBTOPPServer_Release (piBTPBAPSrv);

  • Follow