2 * C Implementation: testapp
7 * Author: root <root@ubuntu>, (C) 2008
9 * Copyright: See COPYING file that comes with this distribution
17 #include "tiny_bt_hci_core.h"
18 #include "tiny_bt_hci_cmd.h"
21 bt_address rem_bd_addr_array[HCI_MAX_DEV];
24 connection_hci connection,*p_connection=&connection;
27 void callback_app_read_bd_addr(bt_address *p_address){
28 printf("Read address is :");
30 tiny_bt_read_local_name(&(p_connection->master.name), callback_app_read_local_name);
33 void callback_app_read_local_name(char *p_name){
35 printf("read name is:");
37 printf("%c",*(p_name+i));
40 tiny_bt_inquiry(&rem_addr, callback_app_inquiry_RSSI, callback_app_inquiry_complete);
43 void callback_app_inquiry_RSSI(bt_address *p_address){
48 rem_bd_addr_array[0]=*p_address;
53 if(compare_bda(p_address,&rem_bd_addr_array[i])){
60 if(count < HCI_MAX_DEV){
61 rem_bd_addr_array[count]=*p_address;
62 printf("There is device:");
67 printf("Array full, there is more than 16 devices in surroundig area\n");
73 tiny_bt_inquiry_register_again(&rem_addr, callback_app_inquiry_RSSI);
77 void callback_app_inquiry_complete(void){
80 printf("inquiry complete\n");
81 for(i=0;i<glob_count;i++){
82 printf("remote dev ");
83 printba(&rem_bd_addr_array[i]);
85 p_connection->slave.bdaddr=rem_bd_addr_array[0];
86 tiny_bt_connect(&rem_bd_addr_array[0],&p_connection->handle, callback_app_connection_complete);
90 void callback_app_connection_complete(__u16 *p_handle){
91 connection_state state = CONNECT;
92 p_connection->con_state=state;
93 printf("Connection complete handle:%d\n",*p_handle);
102 printf("begin of main\n");
103 if(tiny_bt_read_bd_addr(&p_connection->master.bdaddr, callback_app_read_bd_addr)<0){
104 perror("tiny_bt_read_bd_addr error");
110 if(tiny_bt_process()<0){
111 perror("process error");