1 /* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the copyright holders nor the names of 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 4. Any redistribution, use, or modification is done solely for 17 * personal benefit and not for any commercial purpose or for 18 * monetary gain. 19 * 20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24 * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Please inquire about commercial licensing options at 34 * [email protected] 35 * 36 */ 37 38 #define __BTSTACK_FILE__ "panu_demo.c" 39 40 /* 41 * panu_demo.c 42 * Author: Ole Reinhardt <[email protected]> 43 */ 44 45 /* EXAMPLE_START(panu_demo): PANU Demo 46 * 47 * @text This example implements both a PANU client and a server. In server mode, it 48 * sets up a BNEP server and registers a PANU SDP record and waits for incoming connections. 49 * In client mode, it connects to a remote device, does an SDP Query to identify the PANU 50 * service and initiates a BNEP connection. 51 */ 52 53 #include "btstack_config.h" 54 55 #include <arpa/inet.h> 56 #include <errno.h> 57 #include <fcntl.h> 58 #include <ifaddrs.h> 59 #include <stdint.h> 60 #include <stdio.h> 61 #include <stdlib.h> 62 #include <string.h> 63 #include <unistd.h> 64 65 #include <net/if_arp.h> 66 67 #ifdef __APPLE__ 68 #include <net/if.h> 69 #include <net/if_types.h> 70 71 #include <netinet/if_ether.h> 72 #include <netinet/in.h> 73 #endif 74 75 #include <sys/ioctl.h> 76 #include <sys/param.h> 77 #include <sys/socket.h> 78 #include <sys/stat.h> 79 #include <sys/types.h> 80 81 #ifdef __linux 82 #include <linux/if.h> 83 #include <linux/if_tun.h> 84 #endif 85 86 #include "btstack.h" 87 88 static int record_id = -1; 89 static uint16_t bnep_l2cap_psm = 0; 90 static uint32_t bnep_remote_uuid = 0; 91 static uint16_t bnep_version = 0; 92 static uint16_t bnep_cid = 0; 93 94 static uint16_t sdp_bnep_l2cap_psm = 0; 95 static uint16_t sdp_bnep_version = 0; 96 static uint32_t sdp_bnep_remote_uuid = 0; 97 98 static uint8_t attribute_value[1000]; 99 static const unsigned int attribute_value_buffer_size = sizeof(attribute_value); 100 101 // MBP 2016 static const char * remote_addr_string = "F4-0F-24-3B-1B-E1"; 102 // Wiko Sunny 103 static const char * remote_addr_string = "A0:4C:5B:0F:B2:42"; 104 static bd_addr_t remote_addr; 105 106 static int tap_fd = -1; 107 static uint8_t network_buffer[BNEP_MTU_MIN]; 108 static size_t network_buffer_len = 0; 109 110 #ifdef __APPLE__ 111 // tuntaposx provides fixed set of tapX devices 112 static const char * tap_dev = "/dev/tap0"; 113 static char tap_dev_name[16] = "tap0"; 114 #endif 115 116 #ifdef __linux 117 // Linux uses single control device to bring up tunX or tapX interface 118 static const char * tap_dev = "/dev/net/tun"; 119 static char tap_dev_name[16] = "bnep%d"; 120 #endif 121 122 123 static btstack_data_source_t tap_dev_ds; 124 static btstack_packet_callback_registration_t hci_event_callback_registration; 125 126 /* @section Main application configuration 127 * 128 * @text In the application configuration, L2CAP and BNEP are initialized and a BNEP service, for server mode, 129 * is registered, before the Bluetooth stack gets started, as shown in Listing PanuSetup. 130 */ 131 132 /* LISTING_START(PanuSetup): Panu setup */ 133 static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); 134 static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); 135 136 static void panu_setup(void){ 137 138 // register for HCI events 139 hci_event_callback_registration.callback = &packet_handler; 140 hci_add_event_handler(&hci_event_callback_registration); 141 142 // Initialize L2CAP 143 l2cap_init(); 144 145 // Initialise BNEP 146 bnep_init(); 147 // Minimum L2CAP MTU for bnep is 1691 bytes 148 bnep_register_service(packet_handler, BLUETOOTH_SERVICE_CLASS_PANU, 1691); 149 } 150 /* LISTING_END */ 151 152 /* @section TUN / TAP interface routines 153 * 154 * @text This example requires a TUN/TAP interface to connect the Bluetooth network interface 155 * with the native system. It has been tested on Linux and OS X, but should work on any 156 * system that provides TUN/TAP with minor modifications. 157 * 158 * On Linux, TUN/TAP is available by default. On OS X, tuntaposx from 159 * http://tuntaposx.sourceforge.net needs to be installed. 160 * 161 * The *tap_alloc* function sets up a virtual network interface with the given Bluetooth Address. 162 * It is rather low-level as it sets up and configures a network interface. 163 */ 164 165 static int tap_alloc(char *dev, bd_addr_t bd_addr) 166 { 167 struct ifreq ifr; 168 int fd_dev; 169 int fd_socket; 170 171 if( (fd_dev = open(tap_dev, O_RDWR)) < 0 ) { 172 fprintf(stderr, "TAP: Error opening %s: %s\n", tap_dev, strerror(errno)); 173 return -1; 174 } 175 176 #ifdef __linux 177 memset(&ifr, 0, sizeof(ifr)); 178 179 ifr.ifr_flags = IFF_TAP | IFF_NO_PI; 180 if( *dev ) { 181 strncpy(ifr.ifr_name, dev, IFNAMSIZ); 182 } 183 184 int err; 185 if( (err = ioctl(fd_dev, TUNSETIFF, (void *) &ifr)) < 0 ) { 186 fprintf(stderr, "TAP: Error setting device name: %s\n", strerror(errno)); 187 close(fd_dev); 188 return -1; 189 } 190 strcpy(dev, ifr.ifr_name); 191 #endif 192 #ifdef __APPLE__ 193 dev = tap_dev_name; 194 #endif 195 196 fd_socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); 197 if (fd_socket < 0) { 198 close(fd_dev); 199 fprintf(stderr, "TAP: Error opening netlink socket: %s\n", strerror(errno)); 200 return -1; 201 } 202 203 // Configure the MAC address of the newly created bnep(x) 204 // device to the local bd_address 205 memset (&ifr, 0, sizeof(struct ifreq)); 206 strcpy(ifr.ifr_name, dev); 207 #ifdef __linux 208 ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; 209 memcpy(ifr.ifr_hwaddr.sa_data, bd_addr, sizeof(bd_addr_t)); 210 if (ioctl(fd_socket, SIOCSIFHWADDR, &ifr) == -1) { 211 close(fd_dev); 212 close(fd_socket); 213 fprintf(stderr, "TAP: Error setting hw addr: %s\n", strerror(errno)); 214 exit(1); 215 return -1; 216 } 217 #endif 218 #ifdef __APPLE__ 219 ifr.ifr_addr.sa_len = ETHER_ADDR_LEN; 220 ifr.ifr_addr.sa_family = AF_LINK; 221 (void)memcpy(ifr.ifr_addr.sa_data, bd_addr, ETHER_ADDR_LEN); 222 if (ioctl(fd_socket, SIOCSIFLLADDR, &ifr) == -1) { 223 close(fd_dev); 224 close(fd_socket); 225 fprintf(stderr, "TAP: Error setting hw addr: %s\n", strerror(errno)); 226 exit(1); 227 return -1; 228 } 229 #endif 230 231 // Bring the interface up 232 if (ioctl(fd_socket, SIOCGIFFLAGS, &ifr) == -1) { 233 close(fd_dev); 234 close(fd_socket); 235 fprintf(stderr, "TAP: Error reading interface flags: %s\n", strerror(errno)); 236 return -1; 237 } 238 239 if ((ifr.ifr_flags & IFF_UP) == 0) { 240 ifr.ifr_flags |= IFF_UP; 241 242 if (ioctl(fd_socket, SIOCSIFFLAGS, &ifr) == -1) { 243 close(fd_dev); 244 close(fd_socket); 245 fprintf(stderr, "TAP: Error set IFF_UP: %s\n", strerror(errno)); 246 return -1; 247 } 248 } 249 250 close(fd_socket); 251 252 return fd_dev; 253 } 254 255 /* 256 * @text Listing processTapData shows how a packet is received from the TAP network interface 257 * and forwarded over the BNEP connection. 258 * 259 * After successfully reading a network packet, the call to 260 * the *bnep_can_send_packet_now* function checks, if BTstack can forward 261 * a network packet now. If that's not possible, the received data stays 262 * in the network buffer and the data source elements is removed from the 263 * run loop. The *process_tap_dev_data* function will not be called until 264 * the data source is registered again. This provides a basic flow control. 265 */ 266 267 /* LISTING_START(processTapData): Process incoming network packets */ 268 static void process_tap_dev_data(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type) 269 { 270 UNUSED(ds); 271 UNUSED(callback_type); 272 273 ssize_t len; 274 len = read(ds->fd, network_buffer, sizeof(network_buffer)); 275 if (len <= 0){ 276 fprintf(stderr, "TAP: Error while reading: %s\n", strerror(errno)); 277 return; 278 } 279 280 network_buffer_len = len; 281 282 // disable reading from netif 283 btstack_run_loop_disable_data_source_callbacks(&tap_dev_ds, DATA_SOURCE_CALLBACK_READ); 284 285 // request permission to send 286 bnep_request_can_send_now_event(bnep_cid); 287 } 288 /* LISTING_END */ 289 290 // PANU client routines 291 static char * get_string_from_data_element(uint8_t * element){ 292 de_size_t de_size = de_get_size_type(element); 293 int pos = de_get_header_size(element); 294 int len = 0; 295 switch (de_size){ 296 case DE_SIZE_VAR_8: 297 len = element[1]; 298 break; 299 case DE_SIZE_VAR_16: 300 len = big_endian_read_16(element, 1); 301 break; 302 default: 303 break; 304 } 305 char * str = (char*)malloc(len+1); 306 memcpy(str, &element[pos], len); 307 str[len] ='\0'; 308 return str; 309 } 310 311 312 /* @section SDP parser callback 313 * 314 * @text The SDP parsers retrieves the BNEP PAN UUID as explained in 315 * Section [on SDP BNEP Query example](#sec:sdpbnepqueryExample}. 316 */ 317 static void handle_sdp_client_record_complete(void){ 318 319 printf("SDP BNEP Record complete\n"); 320 321 // accept first entry or if we foudn a NAP and only have a PANU yet 322 if ((bnep_remote_uuid == 0) || (sdp_bnep_remote_uuid == BLUETOOTH_SERVICE_CLASS_NAP && bnep_remote_uuid == BLUETOOTH_SERVICE_CLASS_PANU)){ 323 bnep_l2cap_psm = sdp_bnep_l2cap_psm; 324 bnep_remote_uuid = sdp_bnep_remote_uuid; 325 bnep_version = sdp_bnep_version; 326 } 327 } 328 329 static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) { 330 331 UNUSED(packet_type); 332 UNUSED(channel); 333 UNUSED(size); 334 335 des_iterator_t des_list_it; 336 des_iterator_t prot_it; 337 char *str; 338 339 switch (hci_event_packet_get_type(packet)){ 340 case SDP_EVENT_QUERY_ATTRIBUTE_VALUE: 341 // Handle new SDP record 342 if (sdp_event_query_attribute_byte_get_record_id(packet) != record_id) { 343 handle_sdp_client_record_complete(); 344 // next record started 345 record_id = sdp_event_query_attribute_byte_get_record_id(packet); 346 printf("SDP Record: Nr: %d\n", record_id); 347 } 348 349 if (sdp_event_query_attribute_byte_get_attribute_length(packet) <= attribute_value_buffer_size) { 350 attribute_value[sdp_event_query_attribute_byte_get_data_offset(packet)] = sdp_event_query_attribute_byte_get_data(packet); 351 352 if ((uint16_t)(sdp_event_query_attribute_byte_get_data_offset(packet)+1) == sdp_event_query_attribute_byte_get_attribute_length(packet)) { 353 354 switch(sdp_event_query_attribute_byte_get_attribute_id(packet)) { 355 case BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST: 356 if (de_get_element_type(attribute_value) != DE_DES) break; 357 for (des_iterator_init(&des_list_it, attribute_value); des_iterator_has_more(&des_list_it); des_iterator_next(&des_list_it)) { 358 uint8_t * element = des_iterator_get_element(&des_list_it); 359 if (de_get_element_type(element) != DE_UUID) continue; 360 uint32_t uuid = de_get_uuid32(element); 361 switch (uuid){ 362 case BLUETOOTH_SERVICE_CLASS_PANU: 363 case BLUETOOTH_SERVICE_CLASS_NAP: 364 case BLUETOOTH_SERVICE_CLASS_GN: 365 printf("SDP Attribute 0x%04x: BNEP PAN protocol UUID: %04x\n", sdp_event_query_attribute_byte_get_attribute_id(packet), uuid); 366 sdp_bnep_remote_uuid = uuid; 367 break; 368 default: 369 break; 370 } 371 } 372 break; 373 case 0x0100: 374 case 0x0101: 375 str = get_string_from_data_element(attribute_value); 376 printf("SDP Attribute: 0x%04x: %s\n", sdp_event_query_attribute_byte_get_attribute_id(packet), str); 377 free(str); 378 break; 379 case BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST: { 380 printf("SDP Attribute: 0x%04x\n", sdp_event_query_attribute_byte_get_attribute_id(packet)); 381 382 for (des_iterator_init(&des_list_it, attribute_value); des_iterator_has_more(&des_list_it); des_iterator_next(&des_list_it)) { 383 uint8_t *des_element; 384 uint8_t *element; 385 uint32_t uuid; 386 387 if (des_iterator_get_type(&des_list_it) != DE_DES) continue; 388 389 des_element = des_iterator_get_element(&des_list_it); 390 des_iterator_init(&prot_it, des_element); 391 element = des_iterator_get_element(&prot_it); 392 393 if (de_get_element_type(element) != DE_UUID) continue; 394 395 uuid = de_get_uuid32(element); 396 switch (uuid){ 397 case BLUETOOTH_PROTOCOL_L2CAP: 398 if (!des_iterator_has_more(&prot_it)) continue; 399 des_iterator_next(&prot_it); 400 de_element_get_uint16(des_iterator_get_element(&prot_it), &sdp_bnep_l2cap_psm); 401 break; 402 case BLUETOOTH_PROTOCOL_BNEP: 403 if (!des_iterator_has_more(&prot_it)) continue; 404 des_iterator_next(&prot_it); 405 de_element_get_uint16(des_iterator_get_element(&prot_it), &sdp_bnep_version); 406 break; 407 default: 408 break; 409 } 410 } 411 printf("l2cap_psm 0x%04x, bnep_version 0x%04x\n", bnep_l2cap_psm, bnep_version); 412 413 } 414 break; 415 default: 416 break; 417 } 418 } 419 } else { 420 fprintf(stderr, "SDP attribute value buffer size exceeded: available %d, required %d\n", attribute_value_buffer_size, sdp_event_query_attribute_byte_get_attribute_length(packet)); 421 } 422 break; 423 424 case SDP_EVENT_QUERY_COMPLETE: 425 handle_sdp_client_record_complete(); 426 fprintf(stderr, "General query done with status %d, bnep psm %04x.\n", sdp_event_query_complete_get_status(packet), bnep_l2cap_psm); 427 if (bnep_l2cap_psm){ 428 /* Create BNEP connection */ 429 bnep_connect(packet_handler, remote_addr, bnep_l2cap_psm, BLUETOOTH_SERVICE_CLASS_PANU, bnep_remote_uuid); 430 } else { 431 fprintf(stderr, "No BNEP service found\n"); 432 } 433 434 break; 435 } 436 } 437 438 /* 439 * @section Packet Handler 440 * 441 * @text The packet handler responds to various HCI Events. 442 */ 443 444 445 /* LISTING_START(packetHandler): Packet Handler */ 446 static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) 447 { 448 /* LISTING_PAUSE */ 449 UNUSED(channel); 450 451 int rc; 452 uint8_t event; 453 bd_addr_t event_addr; 454 bd_addr_t local_addr; 455 uint16_t uuid_source; 456 uint16_t uuid_dest; 457 uint16_t mtu; 458 459 /* LISTING_RESUME */ 460 switch (packet_type) { 461 case HCI_EVENT_PACKET: 462 event = hci_event_packet_get_type(packet); 463 switch (event) { 464 /* @text When BTSTACK_EVENT_STATE with state HCI_STATE_WORKING 465 * is received and the example is started in client mode, the remote SDP BNEP query is started. 466 */ 467 case BTSTACK_EVENT_STATE: 468 if (btstack_event_state_get_state(packet) == HCI_STATE_WORKING){ 469 printf("Start SDP BNEP query.\n"); 470 sdp_client_query_uuid16(&handle_sdp_client_query_result, remote_addr, BLUETOOTH_PROTOCOL_BNEP); 471 } 472 break; 473 474 /* LISTING_PAUSE */ 475 case HCI_EVENT_PIN_CODE_REQUEST: 476 // inform about pin code request 477 printf("Pin code request - using '0000'\n"); 478 hci_event_pin_code_request_get_bd_addr(packet, event_addr); 479 gap_pin_code_response(event_addr, "0000"); 480 break; 481 482 case HCI_EVENT_USER_CONFIRMATION_REQUEST: 483 // inform about user confirmation request 484 printf("SSP User Confirmation Request with numeric value '%06u'\n", little_endian_read_32(packet, 8)); 485 printf("SSP User Confirmation Auto accept\n"); 486 break; 487 488 /* LISTING_RESUME */ 489 490 /* @text BNEP_EVENT_CHANNEL_OPENED is received after a BNEP connection was established or 491 * or when the connection fails. The status field returns the error code. 492 * 493 * The TAP network interface is then configured. A data source is set up and registered with the 494 * run loop to receive Ethernet packets from the TAP interface. 495 * 496 * The event contains both the source and destination UUIDs, as well as the MTU for this connection and 497 * the BNEP Channel ID, which is used for sending Ethernet packets over BNEP. 498 */ 499 case BNEP_EVENT_CHANNEL_OPENED: 500 if (bnep_event_channel_opened_get_status(packet)) { 501 printf("BNEP channel open failed, status %02x\n", bnep_event_channel_opened_get_status(packet)); 502 } else { 503 bnep_cid = bnep_event_channel_opened_get_bnep_cid(packet); 504 uuid_source = bnep_event_channel_opened_get_source_uuid(packet); 505 uuid_dest = bnep_event_channel_opened_get_destination_uuid(packet); 506 mtu = bnep_event_channel_opened_get_mtu(packet); 507 //bt_flip_addr(event_addr, &packet[9]); 508 memcpy(&event_addr, &packet[11], sizeof(bd_addr_t)); 509 printf("BNEP connection open succeeded to %s source UUID 0x%04x dest UUID: 0x%04x, max frame size %u\n", bd_addr_to_str(event_addr), uuid_source, uuid_dest, mtu); 510 /* Create the tap interface */ 511 gap_local_bd_addr(local_addr); 512 tap_fd = tap_alloc(tap_dev_name, local_addr); 513 if (tap_fd < 0) { 514 printf("Creating BNEP tap device failed: %s\n", strerror(errno)); 515 } else { 516 printf("BNEP device \"%s\" allocated.\n", tap_dev_name); 517 /* Create and register a new runloop data source */ 518 btstack_run_loop_set_data_source_fd(&tap_dev_ds, tap_fd); 519 btstack_run_loop_set_data_source_handler(&tap_dev_ds, &process_tap_dev_data); 520 btstack_run_loop_add_data_source(&tap_dev_ds); 521 btstack_run_loop_enable_data_source_callbacks(&tap_dev_ds, DATA_SOURCE_CALLBACK_READ); 522 } 523 } 524 break; 525 526 /* @text If there is a timeout during the connection setup, BNEP_EVENT_CHANNEL_TIMEOUT will be received 527 * and the BNEP connection will be closed 528 */ 529 case BNEP_EVENT_CHANNEL_TIMEOUT: 530 printf("BNEP channel timeout! Channel will be closed\n"); 531 break; 532 533 /* @text BNEP_EVENT_CHANNEL_CLOSED is received when the connection gets closed. 534 */ 535 case BNEP_EVENT_CHANNEL_CLOSED: 536 printf("BNEP channel closed\n"); 537 btstack_run_loop_remove_data_source(&tap_dev_ds); 538 if (tap_fd > 0) { 539 close(tap_fd); 540 tap_fd = -1; 541 } 542 break; 543 544 /* @text BNEP_EVENT_CAN_SEND_NOW indicates that a new packet can be send. This triggers the send of a 545 * stored network packet. The tap datas source can be enabled again 546 */ 547 case BNEP_EVENT_CAN_SEND_NOW: 548 if (network_buffer_len > 0) { 549 bnep_send(bnep_cid, network_buffer, network_buffer_len); 550 network_buffer_len = 0; 551 // Re-enable the tap device data source 552 btstack_run_loop_enable_data_source_callbacks(&tap_dev_ds, DATA_SOURCE_CALLBACK_READ); 553 } 554 break; 555 556 default: 557 break; 558 } 559 break; 560 561 /* @text Ethernet packets from the remote device are received in the packet handler with type BNEP_DATA_PACKET. 562 * It is forwarded to the TAP interface. 563 */ 564 case BNEP_DATA_PACKET: 565 // Write out the ethernet frame to the tap device 566 if (tap_fd > 0) { 567 rc = write(tap_fd, packet, size); 568 if (rc < 0) { 569 fprintf(stderr, "TAP: Could not write to TAP device: %s\n", strerror(errno)); 570 } else 571 if (rc != size) { 572 fprintf(stderr, "TAP: Package written only partially %d of %d bytes\n", rc, size); 573 } 574 } 575 break; 576 577 default: 578 break; 579 } 580 } 581 /* LISTING_END */ 582 583 584 int btstack_main(int argc, const char * argv[]); 585 int btstack_main(int argc, const char * argv[]){ 586 587 (void)argc; 588 (void)argv; 589 590 panu_setup(); 591 592 // parse human readable Bluetooth address 593 sscanf_bd_addr(remote_addr_string, remote_addr); 594 595 // Turn on the device 596 hci_power_control(HCI_POWER_ON); 597 return 0; 598 } 599 600 /* EXAMPLE_END */ 601 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ 602 603