example/gap_le_advertisements: reduce code

This commit is contained in:
Matthias Ringwald 2018-02-08 15:51:54 +01:00
parent 6fab74db98
commit 49999da9ce

View File

@ -72,6 +72,7 @@ static void gap_le_advertisements_setup(void){
hci_add_event_handler(&hci_event_callback_registration);
// Active scanning, 100% (scan interval = scan window)
gap_set_scan_parameters(1,48,48);
gap_start_scan();
}
/* LISTING_END */
@ -241,14 +242,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
if (packet_type != HCI_EVENT_PACKET) return;
switch (hci_event_packet_get_type(packet)) {
case BTSTACK_EVENT_STATE:
// BTstack activated, get started
if (btstack_event_state_get_state(packet) == HCI_STATE_WORKING){
printf("Start scaning!\n");
gap_set_scan_parameters(0,0x0030, 0x0030);
gap_start_scan();
}
break;
case GAP_EVENT_ADVERTISING_REPORT:{
bd_addr_t address;
gap_event_advertising_report_get_address(packet, address);
@ -281,4 +274,4 @@ int btstack_main(void)
return 0;
}
/* EXAMPLE_END */
/* EXAMPLE_END */