pd_get_next_peripheral()

Retrieve the next peripheral from a list of peripherals.

Synopsis:

#include <peripheral_discovery.h>
 
int pd_get_next_peripheral(pd_peripheral_list_t *list, int *peripheral_id, pd_peripheral_t **peripheral)

Since:

BlackBerry 10.2.0

Arguments:

list

The list of peripherals created by pd_alloc_peripheral_list() and populated by pd_get_peripherals().

peripheral_id

The retrieved ID of the peripheral.

peripheral

The peripheral to pass to pd_get_peripheral_properties() to get more information.

Library:

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

Description:

This code sample shows how to retrieve a peripheral:
 pd_peripheral_list_t *peripheral_list;
 pd_peripheral_t *peripheral;
 int peripheral_id;

 if( (peripheral_list = pd_alloc_peripheral_list()) == NULL ) {
   printf( "Couldn't allocate peripheral list\n" );
   return;
 }

 if( pd_get_peripherals( PD_CLASS_SERIAL, peripheral_list ) == EOK ) {
   while( pd_get_next_peripheral( peripheral_list, &peripheral_id,
                                  &peripheral ) == EOK ) {
     printf( "Peripheral %d:\n", peripheral_id );
     // do something with peripheral
   }
 } else {
   printf( "Couldn't get peripherals\n" );
 }

 pd_free_peripheral_list( &peripheral_list );

Returns:

EOK on success, -1 if there are no further peripherals.