⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bttest.c

📁 bluetooth 驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
      perror("bt_send");      return -1;    }        close(btfd);  }  else if (sscanf(buf, "setbd %x:%x:%x:%x:%x:%x",                  &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) == 6)  {     for (i = 0; i < 6; i++)    {      bd[i] = (unsigned char)tmp[i];    }    bt_set_bd_addr(bt_cfd, &bd[0]);  }  else if (strncmp(buf, "readbd", 6) == 0)  {      read_local_bd(bt_cfd, bd);    printf("Local BD: %s\n", bd2str(bd));  }  else if(sscanf(buf, "role_switch %x:%x:%x:%x:%x:%x %d ",		 &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], 		 &tmp[5], &tmp[6])== 7)  {    for (i = 0; i < 6; i++)    {      bd[i] = (unsigned char)tmp[i];    }      role_switch(bt_cfd, &bd[0], tmp[6]);  }  else if (sscanf(buf, "force_ms %d", &tmp[0]) == 1)  {    printf("Setting force m/s switch to %d\n", tmp[0]);    bt_force_msswitch_as_server(bt_cfd, tmp[0]);  }#ifdef ECS_TEST_FUNCTIONS  else if (sscanf(buf, "ecs_testctrl %x,%x,%x,%x,%x,%x,%x,%x,%x",		  &tmp[0], &tmp[1], &tmp[2],		  &tmp[3], &tmp[4], &tmp[5],		  &tmp[6], &tmp[7], &tmp[8]) == 9)  {    ericsson_test_control(&tmp[0]);  }  else if (sscanf(buf, "ecs_entertest %x", &tmp[0]) == 1)  {    ericsson_enter_test_mode(&tmp[0]);      }  else if (sscanf(buf, "ecs_testcon %x:%x:%x:%x:%x:%x",             &bd[5], &bd[4], &bd[3], &bd[2], &bd[1], &bd[0]) == 6)  {    test_connection_req(&bd[0]);  }  else if (strncmp(buf, "enable_dut", 10) == 0)  {    printf("Enable device under test mode\n");    enable_dut(bt_cfd);    printf("done.\n");  }  else if (sscanf(buf, "ecs_txtest %x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x",		  &tmp[0], &tmp[1], &tmp[2],		  &tmp[3], &tmp[4], &tmp[5],		  &tmp[6], &tmp[7], &tmp[8],		  &tmp[9], &tmp[10]) == 11)  {    ericsson_tx_test(&tmp[0]);  }#endif  else if (strncmp(buf, "stat", 4) == 0)  {    bt_showstatus();  }  else if (sscanf(buf, "ping %x:%x:%x:%x:%x:%x %d",		  &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5], 		  &tmp[6]) == 7)  {    unsigned char buf[1024];    int count = tmp[6];    for (i = 0; i < 6; i++)    {      bd[i] = (unsigned char)tmp[i];    }     printf("Pinging: %s\n", bd2str(bd));    /* fill it with something */    memset(buf, 'A', count);    retval = bt_ping(bt_cfd, bd, (unsigned char*)&buf , (unsigned short)count);    }  else if (sscanf(buf, "getinfo %x:%x:%x:%x:%x:%x %d",		  &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5], 		  &tmp[6]) == 7)  {    unsigned short type = tmp[6];    for (i = 0; i < 6; i++)    {      bd[i] = (unsigned char)tmp[i];    }     printf("Get info from: %s\n", bd2str(bd));    bt_getinfo(bt_cfd, bd, type);  }#ifdef CONFIG_BLUETOOTH_UNPLUG_TEST  else if (strncmp(buf, "upt", 3) == 0)  {      retval = bt_testcmd(bt_cfd, buf+4);  }#endif  else if (sscanf(buf, "getinfo %x:%x:%x:%x:%x:%x %x",		  &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5], 		  &tmp[6]) == 7)  {    for (i = 0; i < 6; i++)    {      bd[i] = (unsigned char)tmp[i];    }     printf("Getinfo <%02X:%02X:%02X:%02X:%02X:%02X> type : %d\n",           bd[0], bd[1], bd[2],           bd[3], bd[4], bd[5], tmp[6]);    bt_getinfo(bt_cfd, bd, tmp[6]);  }  else if(sscanf(buf, "tcs_conn %x:%x:%x:%x:%x:%x",		 &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) == 6)  {        for (i = 0; i < 6; i++)    {      bd[i] = (unsigned char)tmp[i];    }    printf("Connecting TCS to bd : %02X:%02X:%02X:%02X:%02X:%02X\n",           bd[0], bd[1], bd[2],           bd[3], bd[4], bd[5]);    retval = bt_connect(bt_cfd, bd, (TCS_LAYER << 16) & 0xffff000);  }  /* FIXME so that we can specify which line to connect */  else if(sscanf(buf, "rf_conn %x:%x:%x:%x:%x:%x %d",		 &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5],		 &srv_ch) == 7)  {    for (i = 0; i < 6; i++)    {      bd[i] = (unsigned char)tmp[i];    }        printf("Connecting RFCOMM to bd : %02X:%02X:%02X:%02X:%02X:%02X\n",	   bd[0], bd[1], bd[2],	   bd[3], bd[4], bd[5]);        printf("RFCOMM server channel is %d\n", srv_ch);    retval = bt_connect(bt_cfd, bd, CREATE_RFCOMM_ID(0, srv_ch << 1));  }  else if(sscanf(buf, "sdp_conn %x:%x:%x:%x:%x:%x",		 &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) == 6)  {        for (i = 0; i < 6; i++)    {      bd[i] = (unsigned char)tmp[i];    }          printf("Connecting SDP to bd : %02X:%02X:%02X:%02X:%02X:%02X\n",           bd[0], bd[1], bd[2],           bd[3], bd[4], bd[5]);    retval = bt_connect(bt_cfd, bd, (SDP_LAYER << 16) & 0xFFFF0000);  }  else if(sscanf(buf, "test_conn %x:%x:%x:%x:%x:%x %x %d",		 &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5], &tmp[6], &tmp[7]) == 8)  {    for (i = 0; i < 6; i++)    {      bd[i] = (unsigned char)tmp[i];    }    printf("Connecting test layer (psm 0x%x, line %d) to bd : %02X:%02X:%02X:%02X:%02X:%02X\n", 	   tmp[6], tmp[7], bd[0], bd[1], bd[2], bd[3], bd[4], bd[5]);    retval = bt_connect(bt_cfd, bd, ((tmp[6] << 16) & 0xffff0000) | tmp[7]);  }  else if (sscanf(buf, "test_case_reject %x:%x:%x:%x:%x:%x",                  &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) == 6)  {    retval = bt_testcmd(bt_cfd, buf);  }  else if (sscanf(buf, "test_disc %x", &tmp[0]) == 1)  {    printf("Disconnecting layer (PSM: %x)\n", tmp[0]);    retval = bt_disconnect(bt_cfd, (tmp[0] << 16) & 0xffff0000);  }  else if(sscanf(buf, "bb_conn %x:%x:%x:%x:%x:%x",		 &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) == 6)  {    retval = bt_testcmd(bt_cfd, buf);  }  else if(sscanf(buf, "bb_disc %d", &i) == 1)  {    printf("Disconnecting hci handle %d\n", i);    retval = bt_testcmd(bt_cfd, buf);  }  else if(sscanf(buf, "lcid_disconnect %d", &i) == 1)  {    printf("Disconnecting lcid %d", i);    retval = bt_testcmd(bt_cfd, buf);  }  else if(sscanf(buf, "hotlist_set %d %x:%x:%x:%x:%x:%x",                  &tmp[6], &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]))  {    FILE *hotlist_fd;    int i, j;        if(tmp[6] > 9)    {      printf("Max number in hotlist is 9.\n");    }    else    {      hotlist[tmp[6]][0] = tmp[0];      hotlist[tmp[6]][1] = tmp[1];      hotlist[tmp[6]][2] = tmp[2];      hotlist[tmp[6]][3] = tmp[3];      hotlist[tmp[6]][4] = tmp[4];      hotlist[tmp[6]][5] = tmp[5];      if((hotlist_fd = fopen("/etc/.hotlist", "wb")))      {        for (i = 0; i < 10 ; i++)         {          for (j = 0 ; j < 6 ; j++)           {            fputc(hotlist[i][j], hotlist_fd);          }        }        fclose(hotlist_fd);      }    }  }  else if(strcmp(buf, "hotlist_show") == 0)  {    int i, j;    for(i = 0 ; i < 10 ; i++)    {      printf("%d: %02X:%02X:%02X:%02X:%02X:%02X\n", i,              hotlist[i][0], hotlist[i][1], hotlist[i][2], hotlist[i][3], hotlist[i][4], hotlist[i][5]);    }  }  else if(strcmp(buf, "test_case_disable_disconnect") == 0)  {    printf("Disabling sending of disconnect respons\n");    bt_testcmd(bt_cfd, buf);  }  else if(strcmp(buf, "test_case_enable_disconnect") == 0)  {    printf("Enabling sending of disconnect respons\n");    bt_testcmd(bt_cfd, buf);  }     else  {    printf("> error: command not recognized or wrong syntax\n");    show_menu();    return 0;  }          return 0;}/* readline replacement  - mfuchs */#if !defined(HAVE_READLINE) && !defined(HAVE_READLINE_READLINE)#define MAXLINE 100static void read_history(char *hist_file_name){}static void write_history(char *hist_file_name){}static void add_history(char *command){}static char *readline(char *promt){  int len;  char *line;  if ((line = malloc(MAXLINE)))  {    printf("%s", promt);    fflush(stdout);    *line = 0;    if ((len = read(STDIN_FILENO, line, MAXLINE-1)) >= 0)    {      line[len] = 0;    }  }  return line;}#endif /* !HAVE_READLINE *//* bttest.c *//* ============================================================== */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -