]> git.gag.com Git - fw/altos/blob - libaltos/cjnitest.c
altosdroid: convert rogue files to unix line endings
[fw/altos] / 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 #if HAS_BLUETOOTH
45         bt_list = altos_bt_list_start(8);
46         while (altos_bt_list_next(bt_list, &bt_device)) {
47                 printf ("%s %s\n", bt_device.name, bt_device.addr);
48                 if (strncmp(bt_device.name, "TeleBT", 6) == 0) {
49                         struct altos_file       *file;
50
51                         int                     c;
52                         file = altos_bt_open(&bt_device);
53                         if (!file) {
54                                 printf("altos_bt_open failed\n");
55                                 continue;
56                         }
57                         altos_puts(file,"v\nc s\n");
58                         altos_flush(file);
59                         while ((c = altos_getchar(file, 100)) >= 0) {
60                                 putchar(c);
61                         }
62                         if (c != LIBALTOS_TIMEOUT)
63                                 printf("getchar returns %d\n", c);
64                         altos_close(file);
65                 }
66         }
67         altos_bt_list_finish(bt_list);
68 #endif
69         altos_fini();
70         return 0;
71 }