void ble_init(void){ advertisements_enabled = 0; // setup central device db central_device_db_init(); sm_init(); // gap_random_address_set_update_period(300000); // gap_random_address_set_mode(GAP_RANDOM_ADDRESS_RESOLVABLE); sm_set_authentication_requirements( SM_AUTHREQ_BONDING | SM_AUTHREQ_MITM_PROTECTION); sm_set_request_security(1); //strcpy(gap_device_name, "BTstack"); sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT); // sm_register_oob_data_callback(get_oob_data_callback); // sm_set_encryption_key_size_range(7, 16); // sm_test_set_irk(test_irk); //gap_random_address_set_update_period(300000); //gap_random_address_set_mode(GAP_RANDOM_ADDRESS_RESOLVABLE); // setup ATT server att_server_init(profile_data, att_read_callback, att_write_callback); att_server_register_packet_handler(app_packet_handler); }
void setup(void){ /// GET STARTED with BTstack /// btstack_memory_init(); run_loop_init(RUN_LOOP_POSIX); // use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER); // init HCI #ifdef HAVE_UART_CSR hci_transport_t * transport = hci_transport_h4_instance(); hci_uart_config_t * config = &hci_uart_config; bt_control_t * control = bt_control_csr_instance(); #elif defined(HAVE_UART_CC256x) hci_transport_t * transport = hci_transport_h4_instance(); hci_uart_config_t * config = &hci_uart_config; bt_control_t * control = bt_control_cc256x_instance(); #else hci_transport_t * transport = hci_transport_usb_instance(); hci_uart_config_t * config = NULL; bt_control_t * control = NULL; #endif remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory; hci_init(transport, config, control, remote_db); // set up l2cap_le l2cap_init(); // setup central device db central_device_db_init(); // setup SM: Display only sm_init(); sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_ONLY); sm_set_authentication_requirements( SM_AUTHREQ_BONDING | SM_AUTHREQ_MITM_PROTECTION); // setup ATT server att_server_init(profile_data, att_read_callback, att_write_callback); att_write_queue_init(); att_attributes_init(); att_server_register_packet_handler(app_packet_handler); att_dump_attributes(); }