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

Developer

API Reference

IOBEXSRV

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 IOBEXSrv represents an OBEX server.A BREW application can instantiate multiple Server Objects each servicing multiple clients provided the underlying implementation supports this. Requests from a client are handled by the IOBEXSrvSession Interface. The server can be registered over different transports.The supported transports are available to the application via IOBEXSrv_GetSupportedTransports().
IOBEXSrv_OnEventNotify() should be called to register a signal that will be set when the application is to be notified of an event.The event is retrieved by calling IOBEXSrv_GetEvent(). An OBEX server can be registered by calling IOBEX_ServerRegister().When the server receives a request from a new client, AEEOBEX_EVT_SRV_NEW_CLI is sent to the application. The data corresponding to this event is a pointer to session object.The application can service requests from this client using the session object. To deregister the server, the application should call IOBEXSrv_Deregister() De registering the server will terminate any sessions that were being serviced.
Usage

Usage example:


  
   ===== To Register for events;

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

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

   // re-enable signal
   ISignalCtl_Enable (pMe->piSrvSignalCtl); 
   
   while ((retValue = IOBEXSrv_GetEvent (pMe->piSrv, &event, &cmdStat, &pSsn)) != AEE_ENOMORE)
   {
      // if retValue == AEE_SUCCESS;

      switch (event)
      {
         case AEEOBEX_EVT_SRV_REG_CMPL:
         ...
         case AEEOBEX_EVT_SRV_DEREG_CMPL:
         ...
         case AEEOBEX_EVT_SRV_NEW_CLI:
      }
   }
   ===== To Register a server:

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

   // set the required transport parameters.For E.g if transport is Bluetooth RFCOMM
   IOBEXSrv_Register(pMe->piSrv,
                     AEEOBEX_TRANS_BT_RFCOMM, NULL, 0,
                     "service_name=ftp server;bt_security=1;uuid16=08"

   ===== To DeRegister a server:

   // disconnect and release any existing sessions
   if (pMe->pSsn) 
   {
      IOBEXSrvSession_Disconnect(pMe->pSsn);
      IOBEXSrvSession_Release(pMe->pSsn);
   }

   IOBEXSrv_Deregister(pMe->piSrv, NULL);

   ===== To handle new session
   // in event handler

   switch (event)
   {
      case AEEOBEX_EVT_SRV_NEW_CLI:
      // new session
      // create a signal for example, use ISignalCBFactory_CreateSignal()
      IOBEXSrvSession_OnEventNotify(piSsn, piSignal);

      // Handle session events
      ...
   }