bttest.c revision 154f39e82e04e93cf2093ec8bd10de98ea03e32b
1/* 2** Copyright 2008 The Android Open Source Project 3** 4** Licensed under the Apache License, Version 2.0 (the "License"); 5** you may not use this file except in compliance with the License. 6** You may obtain a copy of the License at 7** 8** http://www.apache.org/licenses/LICENSE-2.0 9** 10** Unless required by applicable law or agreed to in writing, software 11** distributed under the License is distributed on an "AS IS" BASIS, 12** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13** See the License for the specific language governing permissions and 14** limitations under the License. 15*/ 16 17/** Bluedroid testing */ 18 19#include <stdlib.h> 20#include <stdio.h> 21#include <errno.h> 22#include <sys/uio.h> 23#include <unistd.h> 24 25#include <bluedroid/bluetooth.h> 26 27static int do_enable() { 28 int ret; 29 ret = bt_enable(); 30 printf("= %d\n", ret); 31 return ret; 32} 33 34static int do_disable() { 35 int ret; 36 ret = bt_disable(); 37 printf("= %d\n", ret); 38 return ret; 39} 40 41static int do_is_enabled() { 42 int ret; 43 ret = bt_is_enabled(); 44 printf("= %d\n", ret); 45 return ret; 46} 47 48struct { 49 char *name; 50 int (*ptr)(); 51} function_table[] = { 52 {"enable", do_enable}, 53 {"disable", do_disable}, 54 {"is_enabled", do_is_enabled}, 55 {NULL, NULL}, 56}; 57 58static void usage() { 59 int i; 60 61 printf("Usage:\n"); 62 for (i = 0; function_table[i].name; i++) { 63 printf("\tbttest %s\n", function_table[i].name); 64 } 65} 66 67int main(int argc, char **argv) { 68 int i; 69 70 if (argc != 2) { 71 usage(); 72 return -1; 73 } 74 for (i = 0; function_table[i].name; i++) { 75 if (!strcmp(argv[1], function_table[i].name)) { 76 printf("%s\n", function_table[i].name); 77 return (*function_table[i].ptr)(); 78 } 79 } 80 usage(); 81 return -1; 82} 83