pd_get_event()

Gets the event from the server.

Synopsis:

#include <peripheral_discovery.h>
 
int pd_get_event(pd_event_type_t *type, int *peripheral_id, pd_peripheral_t *peripheral)

Since:

BlackBerry 10.2.0

Arguments:

type

The type of event.

peripheral_id

The peripheral id.

peripheral

The peripheral from pd_alloc_peripheral() to populate. This will not be populated on PD_EVENT_REMOVAL.

Library:

libperipheral_discovery (For the qcc command, use the -l peripheral_discovery option to link against this library)

Description:

Call this function after getting a notification event.

This code sample shows how to get an event:
 MsgReceive(chid, &pulse, sizeof(pulse), NULL);

 // If you populated the sigevent value pointer, retrieve it now.
 event_class = (pd_class_t) pulse.value.sival_ptr;

 // Get the event that woke this thread up.
 if( pd_get_event( &type, &peripheral_id, peripheral ) == EOK ) {
   switch( type ) {
     case PD_EVENT_INSERTION:
       printf( "Peripheral Insertion. id=%d, class=%d\n",
               peripheral_id, event_class );
       // do something with peripheral
       break;
     case PD_EVENT_REMOVAL:
       printf( "Peripheral Removal. id=%d, class=%d\n",
               peripheral_id, event_class );
       break;
   }
 }

Returns:

EOK on success.