88e40d739bc0e469af9e3680186df4ce846a6118
[fw/altos] / altosui / libaltos / cjnitest.c
1 #include <stdio.h>
2 #include "libaltos.h"
3
4 static void
5 altos_puts(struct altos_file *file, char *string)
6 {
7         char    c;
8
9         while ((c = *string++))
10                 altos_putchar(file, c);
11 }
12
13 main ()
14 {
15         struct altos_device     device;
16         struct altos_list       *list;
17         struct altos_bt_device  bt_device;
18         struct altos_bt_list    *bt_list;
19
20         altos_init();
21         list = altos_list_start();
22         while (altos_list_next(list, &device)) {
23                 struct altos_file       *file;
24                 int                     c;
25
26                 printf ("%04x:%04x %-20s %4d %s\n", device.vendor, device.product,
27                         device.name, device.serial, device.path);
28
29                 file = altos_open(&device);
30                 if (!file) {
31                         printf("altos_open failed\n");
32                         continue;
33                 }
34                 altos_puts(file,"v\nc s\n");
35                 altos_flush(file);
36                 while ((c = altos_getchar(file, 100)) >= 0) {
37                         putchar (c);
38                 }
39                 if (c != LIBALTOS_TIMEOUT)
40                         printf ("getchar returns %d\n", c);
41                 altos_close(file);
42         }
43         altos_list_finish(list);
44         bt_list = altos_bt_list_start(8);
45         while (altos_bt_list_next(bt_list, &bt_device)) {
46                 printf ("%s %s\n", bt_device.name, bt_device.addr);
47                 if (strncmp(bt_device.name, "TeleBT", 6) == 0) {
48                         struct altos_file       *file;
49
50                         int                     c;
51                         file = altos_bt_open(&bt_device);
52                         if (!file) {
53                                 printf("altos_bt_open failed\n");
54                                 continue;
55                         }
56                         altos_puts(file,"v\nc s\n");
57                         altos_flush(file);
58                         while ((c = altos_getchar(file, 100)) >= 0) {
59                                 putchar(c);
60                         }
61                         if (c != LIBALTOS_TIMEOUT)
62                                 printf("getchar returns %d\n", c);
63                         altos_close(file);
64                 }
65         }
66         altos_bt_list_finish(bt_list);
67         altos_fini();
68         return 0;
69 }