diff options
| author | Keith Packard <keithp@keithp.com> | 2011-04-08 10:13:55 -0700 |
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2011-04-08 10:13:55 -0700 |
| commit | 8dd455204cf8712fa8c142b0c0517cec1bf5fd0f (patch) | |
| tree | b265bec35628bdcec11fe827dac3ed935a8d6e31 /altosui/libaltos/cjnitest.c | |
| parent | bf1c7df5301a1727e871a8447f835fe75bdce3fc (diff) | |
altosui: Add low-level Bluetooth APIs
Adds the JNI functions to query and connect to arbitrary
bluetooth devices.
Adds Java wrappers to construct a list of proximate bluetooth devices.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/libaltos/cjnitest.c')
| -rw-r--r-- | altosui/libaltos/cjnitest.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/altosui/libaltos/cjnitest.c b/altosui/libaltos/cjnitest.c index c6d6e069..79561643 100644 --- a/altosui/libaltos/cjnitest.c +++ b/altosui/libaltos/cjnitest.c @@ -14,6 +14,8 @@ main () { struct altos_device device; struct altos_list *list; + struct altos_bt_device bt_device; + struct altos_bt_list *bt_list; altos_init(); list = altos_list_start(); @@ -39,5 +41,29 @@ main () altos_close(file); } altos_list_finish(list); + bt_list = altos_bt_list_start(); + while (altos_bt_list_next(bt_list, &bt_device)) { + printf ("%s %s\n", bt_device.name, bt_device.addr); + if (strncmp(bt_device.name, "TeleBT", 6) == 0) { + struct altos_file *file; + + int c; + file = altos_bt_open(&bt_device); + if (!file) { + printf("altos_bt_open failed\n"); + continue; + } + altos_puts(file,"v\nc s\n"); + altos_flush(file); + while ((c = altos_getchar(file, 100)) >= 0) { + putchar(c); + } + if (c != LIBALTOS_TIMEOUT) + printf("getchar returns %d\n", c); + altos_close(file); + } + } + altos_bt_list_finish(bt_list); altos_fini(); + return 0; } |
