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

Developer

API Reference

IOBEXCLI

Brew Release
Brew MP 1.0.2
See Also
Description
(Generic) OBEX Profile
This interface enables BREW applications to use OBEX protocol to exchange data objects with a remote device.Each instance of IOBEXCli supports one connection in a client role.A BREW application can instantiate multiple client objects each being in a connection simultaneously.
The Client can communicate with an OBEX server over different transports The supported transports can be obtained by calling IOBEXCli_GetSupportedTransports().
The OBEX client should set the transport and information related to the server it intends to communicate with, by calling IOBEXCli_SetTransport(). It can then initiate OBEX operations like CONNECT, GET, PUT. Commands are sent along with the optional OBEX header list.
The application is notified of the completion of an operation or other asynchronous events via the signal that is registered via IOBEXCli_OnEventNotify().Events can be obtained by calling IOBEXCli_GetEvent(). An OBEX operation can be aborted by calling IOBEXCli_Abort().
The client can initiate authentication for a particular operation by calling IOBEXCli_Authenticate() followed by the command The implementation is responsible for forming the digest-challenge and adding the authentication challenge header to the header list. If the client initiates authentication, it will be notified when the server responds with the authentication response header via the event AEEOBEX_EVT_AUTH_RESPONSE.The client should indicate to the implementation, the password by calling IOBEXCli_SetUidPassword(). The result of the authentication procedure is indicated by AEEOBEX_EVT_AUTH_COMPL event.
The server can authenticate the client when the client initiates an operation .AEEOBEX_EVT_AUTH_CHALENGE is sent to the application when the authentication challenge header is received. On receiving this event, the application should indicate to the underlying implementation the User id and password required for authentication. This is done by calling IOBEXCli_SetUidPassword().Creation of the digest-response and the authentication response headers is handled by the OBEX implementation.
Usage

Usage example:

 
   ===== To Register for events;

   // create a signal for example, use ISignalCBFactory_CreateSignal()
   IOBEXCli_OnEventNotify(pMe->piCli, piSignal);

   ===== To connect to server:

   // see if the transport is supported 
   IOBEXCli_GetSupportedTransports(pMe->piCli, &transport, transLen, &reqTransLen);

   // set the required transport parameters.For E.g if transport is Bluetooth RFCOMM
   IOBEXCli_SetTransport(pMe->piCli, AEEOBEX_TRANS_BT_RFCOMM,"server_channel=10;bd_address=9abc17101710");

   // Connect to the OBEX server
   IOBEXCli_Connect(pMe->piCli, NULL);
   
   // wait for AEEOBEX_EVT_CLI_CONN_RESP

   ===== To retrieve and handle events when signal is triggered:

   // re-enable signal
   ISignalCtl_Enable (pMe->piCliSignalCtl); 
   
   while (IOBEXCli_GetEvent (pMe->piCli, &piHdr, &event, &cmdStat, &flag) != AEE_ENOMORE)
   {
      switch (event)
      {
         case AEEOBEX_EVT_CLI_CONN_RESP:
         ...
         case AEEOBEX_EVT_CLI_GET_RESP:
         ...
         case AEEOBEX_EVT_ERROR:
      }
   }
   
   ===== To authenticate the server before connection

   // see if the transport is supported 
   IOBEXCli_GetSupportedTransports(pMe->piCli, &transport, transLen, &reqTransLen);

   // set the req transport parameters.For E.g if transport is Bluetooth RFCOMM
   IOBEXCli_SetTransport(pMe->piCli, AEEOBEX_TRANS_BT_RFCOMM,"server_channel=10;bd_address=9abc17101710");

   IOBEXCli_Authenticate(pMe->piCli,0, NULL, 0, TRUE, TRUE);

   // Connect to the OBEX server
   IOBEXCli_Connect(pMe->piCli, NULL);

   ===== To handle authentication challenge event 

   // In the event handler 
   switch (event)
   {
      case AEEOBEX_EVT_CLI_CONN_RESP:
      ...

      case AEEOBEX_EVT_AUTH_CHALLENGE:

      // server has requested for authentication
      IOBEXCli_GetAuthChallenge(pMe->piCli,&uid,&acs,&charSet, &bufRealm, bufRelamLen, &reqLen);

      // get the password and user id ( if required) from the user. Call
      IOBEXCli_SetUidPassword(pMe->piCli,uid, uidLen, pswd, pswdLen);

   }
   
   ===== To handle authentication response event 

   // In the event handler 
   switch (event)
   {
      case AEEOBEX_EVT_CLI_CONN_RESP:
      ...

      case AEEOBEX_EVT_AUTH_RESPONSE:

      // client had requested for authentication 
      IOBEXCli_GetAuthResponse(pMe->piCli,&authResp);

      // get the password from the user
      IOBEXCli_SetUidPassword(pMe->piCli,NULL,0, pswd, pswdLen);
   }

   ===== To send requests to the server 

   ret = IOBEXCli_CreateHeaderList(pMe->pCli, &piHdr);

   if (AEE_SUCCESS == ret)
   {
      IOBEXHeader_AddByteSeq(piHdr, AEEOBEX_HDR_BODY, data, dataLen);
      
      IOBEXCli_Put(pMe->pCli, piHdr, FALSE);

      // done sending the header list
      IOBEXHeader_Release(piHdr);

      // now wait for the AEEOBEX_EVT_CLI_PUT_RESP event
      ...
   }

   ===== To fetch response received from the server

   ret = IOBEXCli_GetEvent(pMe->pCli, &event, &piHdr, &cmdStatus, &flags);

   // In the event handler 
   switch (event)
   {
      case AEEOBEX_EVT_CLI_GET_RESP:

      if (piHdr != NULL)
      {
         // optionally get the list
         IOBEXHeader_GetList(piHdr, pHdrList, 0, hdrListLen, &reqHdrListLen);
   
         IOBEXHeader_GetByteSeq(piHdr, AEEOBEX_HDR_BODY, &buf, bufLen, &reqBufLen);
   
         // done with the received header list
         IOBEXHeader_Release(piHdr);
      }
      ...
   }