Developer

API Reference

IBTImagePushInitiator

Brew Release
Brew MP 1.0.2
Description

Bluetooth Basic Imaging Profile version 1.0, Image Push Initiator role
This interface allows application to make use of the Image Push feature defined by Bluetooth BIP specifications. The typical use case is a mobile phone as Image initiator and a wristwatch, or PC, or another mobile phone as Image responder. Depending on the responder's capabilities, images can be pushed for the purpose of storing, printing, or displaying.
For more information, refer to http://bluetooth.com/Bluetooth/Technology/Works/BIP.htm
Usage

Usage example:



   ===== To create an IBTImagePushInitiator object, see instruction in 
         class header file
 
 
   ===== To register signal
   // first create the signals;
   // for example, use ISignalCBFactory_CreateSignal()
   // then register the signals:
   IBTImagePushInitiator_OnEventNotify(piInitiator, piSignal);
 
 
   ===== To retrieve and handle events when Event signal is triggered:
   while (IBTImagePushInitiator_GetEvent(piInitiator, 
                                         &eventData) != AEE_ENOMORE)
   {
      switch (eventData.cEvent)
      {
         case AEEBTBIPI_EV_CONNECTED:
         case AEEBTBIPI_EV_DISCONNECTED:
            break;

         case AEEBTBIPI_EV_GET_FUNCS_DONE:
            if (AEEBT_RESULT_SUCCESS != eventData.cResult)
            {
               pMe->cSupportedFuncs = eventData.cFunc;
            }
            break;

         case AEEBTBIPI_EV_OP_INITIATED:
            // eventData.cFunc is the function associated with 
            // the operation that just started
            break;

         case AEEBTBIPI_EV_OP_COMPLETED:
            if (AEEBT_RESULT_SUCCESS != eventData.cResult)
            {
               // something went wrong
            }
            else
            {
               appHandleOpComplete(); // see sample code below
            }
            break;

         case AEEBTBIPI_EV_OP_PROGRESS:
            // eventData.cFunc tells the function associated with this op
            // eventData.nSize tells number of data bytes received so far
            break;

         case AEEBTBIPI_EV_EVENT_Q_OVERFLOW:
            // eventData.nSize tells how many events got dropped
            // since previous GetEvent()
            break;
      }
   }
   ISignalCtl_Enable (piSignalCtl); // re-enable signal
 
 
   ===== To get an associated IOBEXAuthentication object:
   IBTImagePushInitiator_QueryInterface(piInitiator, 
                                        AEEIID_IOBEXAuthentication,
                                        (void**)&pMe->piAuth);

   // prepare for authentication initiated by responder
   IOBEXAuthentication_OnRequest(pMe->piAuth, piAuthReqSig);

   // prepare to initiate authentication; this tells initiator object
   // to authenticate responder prior to initiating the next operation
   char szRealm[] = "James Cellphone";
   IOBEXAuthentication_Config(pMe->piAuth,
                              MIBENUM_CHARSET_US_ASCII,
                              (uint8*)szRealm,
                              STRLEN (szRealm),
                              bUserIDRequired,
                              FALSE, // allow responder only read access
                              TRUE); // config data invalid after next operation
   IOBEXAuthentication_OnResponse(pMe->piAuth, piAuthRespSig);


   ===== To prepare the object for communication with Image Push responder:
   IBTImagePushInitiator_Config(
      piInitiator, 
      responderBDAddr, 
      0,  // server channel unknown in this example
      AEEBT_SEC_SM4_MEDIUM, 
      5); // maximum 5 seconds idle


   ===== To find out responder's supported functions:
   IBTImagePushInitiator_GetSupportedFuncs(piInitiator);


   ===== To find out responder's imaging capability:
   if (pMe->cSupportedFuncs & AEEBTBIP_FUNC_GET_CAPABILITIES)
   {
      IBTImagePushInitiator_GetCapabilities(piInitiator, (IPort1*)piCapFile);
   }


   ===== To push an image to the Image Push responder:
   if (pMe->cSupportedFuncs & AEEBTBIP_FUNC_PUT_IMAGE)
   {
      IBTImagePushInitiator_PutImage(
         piInitiator, 
         (IPort1*)piImageFile,   // result of IFileSystem2_Open()
         szImageDescriptor,
         wImageName,
         NULL); // in this example, thumbnail version is not provided
   }


   ===== sample appHandleOpComplete(eventData):
   switch (eventData.cFunc)
   {
      case AEEBTBIP_FUNC_GET_CAPABILITIES:
      {
         // eventData.nSize holds the length of the capabilities string
         // which can be extracted from the file object given to
         // the call to IBTImagePullInitiator_GetCapabilities()
         break;
      }
      case AEEBTBIP_FUNC_PUT_IMAGE:
      {
         pMe->currentHandle = eventData.handle;
         // this handle is valid until connection is brought down

         if ((pMe->cSupportedFuncs & AEEBTBIP_FUNC_PUT_LINKED_ATTACHMENT) &&
             (0 < appGetAttachmentCount(pMe->currentHandle)))
         {
            IBTImagePushInitiator_PutAttachment(piInitiator, 
                                                &pMe->currentHandle,
                                                (IPort1*)piAttachmentFile,
                                                szAttachmentDescriptor);
         }
         break;
      }
      case AEEBTBIP_FUNC_PUT_LINKED_ATTACHMENT:
         // nothing to do
         break;
   }


   ===== To cancel the current operation:
   IBTImagePushInitiator_Cancel(piInitiator);


   ===== To disconnect before the idle time expires:
   IBTImagePushInitiator_Disconnect(piInitiator);


   ===== When done with Image Push Initiator:
   IBTImagePushInitiator_Release(piInitiator);

   
  • Follow