static void le_counter_setup(void){ // register for HCI events hci_event_callback_registration.callback = &packet_handler; hci_add_event_handler(&hci_event_callback_registration); l2cap_init(); // setup le device db le_device_db_init(); // setup SM: Display only sm_init(); // setup ATT server att_server_init(profile_data, att_read_callback, att_write_callback); att_server_register_packet_handler(packet_handler); // setup advertisements uint16_t adv_int_min = 0x0030; uint16_t adv_int_max = 0x0030; uint8_t adv_type = 0; bd_addr_t null_addr; memset(null_addr, 0, 6); gap_advertisements_set_params(adv_int_min, adv_int_max, adv_type, 0, null_addr, 0x07, 0x00); gap_advertisements_set_data(adv_data_len, (uint8_t*) adv_data); gap_advertisements_enable(1); // set one-shot timer heartbeat.process = &heartbeat_handler; btstack_run_loop_set_timer(&heartbeat, HEARTBEAT_PERIOD_MS); btstack_run_loop_add_timer(&heartbeat); }
static void sm_peripheral_setup(void){ // register for HCI events hci_event_callback_registration.callback = &packet_handler; hci_add_event_handler(&hci_event_callback_registration); l2cap_init(); // setup le device db le_device_db_init(); // setup SM: Display only sm_init(); sm_event_callback_registration.callback = &packet_handler; sm_add_event_handler(&sm_event_callback_registration); /** * Choose ONE of the following configurations */ // LE Legacy Pairing, Just Works sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_YES_NO); sm_set_authentication_requirements(0); // LE Legacy Pairing, Passkey entry initiator enter, responder (us) displays // sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_ONLY); // sm_set_authentication_requirements(SM_AUTHREQ_MITM_PROTECTION); #ifdef ENABLE_LE_SECURE_CONNECTIONS // LE Secure Connetions, Just Works // sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_YES_NO); // sm_set_authentication_requirements(SM_AUTHREQ_SECURE_CONNECTION); // LE Secure Connections, Numeric Comparison // sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_YES_NO); // sm_set_authentication_requirements(SM_AUTHREQ_SECURE_CONNECTION|SM_AUTHREQ_MITM_PROTECTION); // LE Legacy Pairing, Passkey entry initiator enter, responder (us) displays // sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_ONLY); // sm_set_authentication_requirements(SM_AUTHREQ_SECURE_CONNECTION|SM_AUTHREQ_MITM_PROTECTION); #endif // setup ATT server att_server_init(profile_data, NULL, NULL); att_server_register_packet_handler(packet_handler); // setup advertisements uint16_t adv_int_min = 0x0030; uint16_t adv_int_max = 0x0030; uint8_t adv_type = 0; bd_addr_t null_addr; memset(null_addr, 0, 6); gap_advertisements_set_params(adv_int_min, adv_int_max, adv_type, 0, null_addr, 0x07, 0x00); gap_advertisements_set_data(adv_data_len, (uint8_t*) adv_data); gap_advertisements_enable(1); }
int btstack_main(void) { // register for HCI events hci_event_callback_registration.callback = &packet_handler; hci_add_event_handler(&hci_event_callback_registration); l2cap_init(); rfcomm_init(); rfcomm_register_service(packet_handler, RFCOMM_SERVER_CHANNEL, 0xffff); // init SDP, create record for SPP and register with SDP sdp_init(); memset(spp_service_buffer, 0, sizeof(spp_service_buffer)); spp_create_sdp_record(spp_service_buffer, 0x10001, RFCOMM_SERVER_CHANNEL, "SPP Counter"); sdp_register_service(spp_service_buffer); printf("SDP service record size: %u\n", de_get_len(spp_service_buffer)); gap_set_local_name("SPP and LE Counter 00:00:00:00:00:00"); gap_ssp_set_io_capability(SSP_IO_CAPABILITY_DISPLAY_YES_NO); gap_discoverable_control(1); // setup le device db le_device_db_init(); // setup SM: Display only sm_init(); // setup ATT server att_server_init(profile_data, att_read_callback, att_write_callback); att_server_register_packet_handler(packet_handler); // set one-shot timer heartbeat.process = &heartbeat_handler; btstack_run_loop_set_timer(&heartbeat, HEARTBEAT_PERIOD_MS); btstack_run_loop_add_timer(&heartbeat); // setup advertisements uint16_t adv_int_min = 0x0030; uint16_t adv_int_max = 0x0030; uint8_t adv_type = 0; bd_addr_t null_addr; memset(null_addr, 0, 6); gap_advertisements_set_params(adv_int_min, adv_int_max, adv_type, 0, null_addr, 0x07, 0x00); gap_advertisements_set_data(adv_data_len, (uint8_t*) adv_data); gap_advertisements_enable(1); // beat once beat(); // turn on! hci_power_control(HCI_POWER_ON); return 0; }
static void le_streamer_setup(void){ l2cap_init(); // setup le device db le_device_db_init(); // setup SM: Display only sm_init(); // setup ATT server att_server_init(profile_data, NULL, att_write_callback); att_server_register_packet_handler(packet_handler); // setup advertisements uint16_t adv_int_min = 0x0030; uint16_t adv_int_max = 0x0030; uint8_t adv_type = 0; bd_addr_t null_addr; memset(null_addr, 0, 6); gap_advertisements_set_params(adv_int_min, adv_int_max, adv_type, 0, null_addr, 0x07, 0x00); gap_advertisements_set_data(adv_data_len, (uint8_t*) adv_data); gap_advertisements_enable(1); }