void hiddevs_forall(void (*process)(bd_addr_t)) { int fd = open(HIDDEVS_FILE, O_RDONLY); if (fd < 0) { // printf("WARNING - could not open " HIDDEVS_FILE "\n"); } char buf[4096], *p; int n = read(fd, buf, sizeof(buf)); if (n == sizeof(buf)) { printf("WARNING - hiddevs file is ridiculously big, will be truncated\n"); n--; } buf[n] = '\0'; close(fd); bd_addr_t addr; char *pbuf = buf; while (p = strtok(pbuf, " ")) { pbuf = 0; if (strlen(p) != 17 || !sscanf_bd_addr(p, addr)) { printf("Malformatted line in %s: \"%s\"\n", HIDDEVS_FILE, p); return; } process(addr); // skip key p = strtok(NULL, "\n"); } }
int btstack_main(int argc, const char * argv[]){ int arg = 1; cmdline_addr_found = 0; while (arg < argc) { if(!strcmp(argv[arg], "-a") || !strcmp(argv[arg], "--address")){ arg++; cmdline_addr_found = sscanf_bd_addr(argv[arg], cmdline_addr); arg++; if (!cmdline_addr_found) exit(1); continue; } usage(argv[0]); return 0; } hci_event_callback_registration.callback = &hci_event_handler; hci_add_event_handler(&hci_event_callback_registration); l2cap_init(); gatt_client_init(); sm_init(); sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT); // turn on! hci_power_control(HCI_POWER_ON); return 0; }
int btstack_main(int argc, const char * argv[]){ #ifdef HAVE_BTSTACK_STDIN int arg = 1; cmdline_addr_found = 0; while (arg < argc) { if(!strcmp(argv[arg], "-a") || !strcmp(argv[arg], "--address")){ arg++; cmdline_addr_found = sscanf_bd_addr(argv[arg], cmdline_addr); arg++; continue; } usage(argv[0]); return 0; } #else (void)argc; (void)argv; #endif // setup ATT server - only needed if LE Peripheral does ATT queries on its own, e.g. Android phones att_server_init(profile_data, NULL, NULL); // setup GATT client gatt_client_setup(); // turn on! hci_power_control(HCI_POWER_ON); return 0; }
int btstack_main(int argc, const char * argv[]){ UNUSED(argc); (void)argv; /* Register for HCI events */ hci_event_callback_registration.callback = &packet_handler; hci_add_event_handler(&hci_event_callback_registration); l2cap_init(); // Initialize AVRCP COntroller avrcp_controller_init(); avrcp_controller_register_packet_handler(&packet_handler); // Initialize SDP sdp_init(); memset(sdp_avrcp_controller_service_buffer, 0, sizeof(sdp_avrcp_controller_service_buffer)); avrcp_controller_create_sdp_record(sdp_avrcp_controller_service_buffer, 0x10001, AVRCP_BROWSING_ENABLED, 1, NULL, NULL); sdp_register_service(sdp_avrcp_controller_service_buffer); gap_set_local_name("BTstack AVRCP Test"); gap_discoverable_control(1); // gap_set_class_of_device(0x200408); // parse human readable Bluetooth address sscanf_bd_addr(device_addr_string, device_addr); // turn on! hci_power_control(HCI_POWER_ON); #ifdef HAVE_BTSTACK_STDIN btstack_stdin_setup(stdin_process); #endif return 0; }
int btstack_main(int argc, const char * argv[]){ UNUSED(argc); (void)argv; /* Register for HCI events */ hci_event_callback_registration.callback = &packet_handler; hci_add_event_handler(&hci_event_callback_registration); l2cap_init(); // Initialize AVDTP Sink avdtp_source_init(&a2dp_source_context); avdtp_source_register_packet_handler(&packet_handler); sc.local_stream_endpoint = a2dp_source_create_stream_endpoint(AVDTP_AUDIO, AVDTP_CODEC_SBC, (uint8_t *) media_sbc_codec_capabilities, sizeof(media_sbc_codec_capabilities), (uint8_t*) media_sbc_codec_configuration, sizeof(media_sbc_codec_configuration)); media_tracker.local_seid = avdtp_local_seid(sc.local_stream_endpoint); media_tracker.remote_seid = 1; // Initialize SDP sdp_init(); memset(sdp_avdtp_source_service_buffer, 0, sizeof(sdp_avdtp_source_service_buffer)); a2dp_source_create_sdp_record(sdp_avdtp_source_service_buffer, 0x10002, 1, NULL, NULL); sdp_register_service(sdp_avdtp_source_service_buffer); gap_set_local_name("BTstack AVDTP Source PTS 00:00:00:00:00:00"); gap_discoverable_control(1); gap_set_class_of_device(0x200408); sscanf_bd_addr(device_addr_string, device_addr); #ifdef HAVE_BTSTACK_STDIN // parse human readable Bluetooth address sscanf_bd_addr(device_addr_string, device_addr); btstack_stdin_setup(stdin_process); #endif // turn on! hci_power_control(HCI_POWER_ON); return 0; }
int btstack_main(int argc, const char * argv[]){ (void)argc; (void)argv; hid_host_setup(); // parse human readable Bluetooth address sscanf_bd_addr(remote_addr_string, remote_addr); // Turn on the device hci_power_control(HCI_POWER_ON); return 0; }
int btstack_main(int argc, const char * argv[]){ UNUSED(argc); (void)argv; /* Register for HCI events */ hci_event_callback_registration.callback = &packet_handler; hci_add_event_handler(&hci_event_callback_registration); l2cap_init(); // Initialize AVDTP Sink avdtp_sink_init(&a2dp_sink_context); avdtp_sink_register_packet_handler(&packet_handler); avdtp_stream_endpoint_t * local_stream_endpoint = avdtp_sink_create_stream_endpoint(AVDTP_SINK, AVDTP_AUDIO); if (!local_stream_endpoint) { printf("AVDTP Sink: not enough memory to create local_stream_endpoint\n"); return 1; } local_seid = avdtp_local_seid(local_stream_endpoint); avdtp_sink_register_media_transport_category(local_seid); avdtp_sink_register_media_codec_category(local_seid, AVDTP_AUDIO, AVDTP_CODEC_SBC, media_sbc_codec_capabilities, sizeof(media_sbc_codec_capabilities)); avdtp_sink_register_media_handler(&handle_l2cap_media_data_packet); // Initialize SDP sdp_init(); memset(sdp_avdtp_sink_service_buffer, 0, sizeof(sdp_avdtp_sink_service_buffer)); a2dp_sink_create_sdp_record(sdp_avdtp_sink_service_buffer, 0x10001, 1, NULL, NULL); sdp_register_service(sdp_avdtp_sink_service_buffer); // printf("BTstack AVDTP Sink, supported features 0x%04x\n", ); gap_set_local_name("BTstack AVDTP Sink PTS 00:00:00:00:00:00"); gap_discoverable_control(1); gap_set_class_of_device(0x200408); #ifdef HAVE_BTSTACK_STDIN // parse human readable Bluetooth address sscanf_bd_addr(device_addr_string, device_addr); btstack_stdin_setup(stdin_process); #endif // turn on! hci_power_control(HCI_POWER_ON); return 0; }
int btstack_main(int argc, const char * argv[]){ #ifdef HAVE_BTSTACK_STDIN int arg = 1; cmdline_addr_found = 0; while (arg < argc) { if(!strcmp(argv[arg], "-a") || !strcmp(argv[arg], "--address")){ arg++; cmdline_addr_found = sscanf_bd_addr(argv[arg], cmdline_addr); arg++; if (!cmdline_addr_found) exit(1); continue; } usage(argv[0]); return 0; } #else (void)argc; (void)argv; #endif hci_event_callback_registration.callback = &hci_event_handler; hci_add_event_handler(&hci_event_callback_registration); l2cap_init(); gatt_client_init(); sm_init(); sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT); // use different connection parameters: conn interval min/max (* 1.25 ms), slave latency, supervision timeout, CE len min/max (* 0.6125 ms) // gap_set_connection_parameters(0x06, 0x06, 4, 1000, 0x01, 0x06 * 2); // turn on! hci_power_control(HCI_POWER_ON); return 0; }