LE is independent of scan mode

This commit is contained in:
matthias.ringwald@gmail.com 2013-10-17 13:22:20 +00:00
parent 75b4335b82
commit 5c3b5f6339

View File

@ -102,7 +102,8 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
case BTSTACK_EVENT_STATE:
// bt stack activated, get started - set local name
if (packet[2] == HCI_STATE_WORKING) {
printf("Working!\n");
printf("Working!\n");
// into hci.c
hci_send_cmd(&hci_write_le_host_supported, 1, 1);
}
break;
@ -145,39 +146,41 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
break;
}
if (COMMAND_COMPLETE_EVENT(packet, hci_write_le_host_supported)){
// into hci.c
hci_send_cmd(&hci_le_set_event_mask, 0xffffffff, 0xffffffff);
break;
}
if (COMMAND_COMPLETE_EVENT(packet, hci_le_set_event_mask)){
// into hci.c
hci_send_cmd(&hci_le_read_buffer_size);
break;
}
if (COMMAND_COMPLETE_EVENT(packet, hci_le_read_buffer_size)){
printf("LE buffer size: %u, count %u\n", READ_BT_16(packet,6), packet[8]);
hci_send_cmd(&hci_le_read_supported_states);
break;
printf("LE buffer size: %u, count %u\n", READ_BT_16(packet,6), packet[8]);
// not needed
hci_send_cmd(&hci_le_read_supported_states);
break;
}
if (COMMAND_COMPLETE_EVENT(packet, hci_le_read_supported_states)){
hci_send_cmd(&hci_le_set_advertising_parameters, 0x0400, 0x0800, 0, 0, 0, &addr, 0x07, 0);
break;
// only needed for BLE Peripheral, consider sending these as a default
hci_send_cmd(&hci_le_set_advertising_parameters, 0x0400, 0x0800, 0, 0, 0, &addr, 0x07, 0);
break;
}
if (COMMAND_COMPLETE_EVENT(packet, hci_le_set_advertising_parameters)){
hci_send_cmd(&hci_le_set_advertising_data, sizeof(adv_data), adv_data);
break;
// only needed for BLE Peripheral
hci_send_cmd(&hci_le_set_advertising_data, sizeof(adv_data), adv_data);
break;
}
if (COMMAND_COMPLETE_EVENT(packet, hci_le_set_advertising_data)){
// only needed for BLE Peripheral
hci_send_cmd(&hci_le_set_scan_response_data, 10, adv_data);
break;
}
if (COMMAND_COMPLETE_EVENT(packet, hci_le_set_scan_response_data)){
// only needed for BLE Peripheral
hci_send_cmd(&hci_le_set_advertise_enable, 1);
break;
}
if (COMMAND_COMPLETE_EVENT(packet, hci_le_set_advertise_enable)){
hci_discoverable_control(1);
break;
}
}
}
}