Retrieve the next peripheral from a list of peripherals.
#include <peripheral_discovery.h>
int pd_get_next_peripheral(pd_peripheral_list_t *list, int *peripheral_id, pd_peripheral_t **peripheral)
BlackBerry 10.2.0
The list of peripherals created by pd_alloc_peripheral_list() and populated by pd_get_peripherals().
The retrieved ID of the peripheral.
The peripheral to pass to pd_get_peripheral_properties() to get more information.
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 );
EOK on success, -1 if there are no further peripherals.