altos/test: Fix AES key format in test code
[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 int
14 main (int argc, char **argv)
15 {
16         struct altos_device     device;
17         struct altos_list       *list;
18         struct altos_bt_device  bt_device;
19         struct altos_bt_list    *bt_list;
20
21         altos_init();
22         list = altos_list_start();
23         while (altos_list_next(list, &device)) {
24                 struct altos_file       *file;
25                 int                     c;
26
27                 printf ("%04x:%04x %-20s %4d %s\n", device.vendor, device.product,
28                         device.name, device.serial, device.path);
29
30                 file = altos_open(&device);
31                 if (!file) {
32                         printf("altos_open failed\n");
33                         continue;
34                 }
35                 altos_puts(file,"v\nc s\n");
36                 altos_flush(file);
37                 while ((c = altos_getchar(file, 100)) >= 0) {
38                         putchar (c);
39                 }
40                 if (c != LIBALTOS_TIMEOUT)
41                         printf ("getchar returns %d\n", c);
42                 altos_close(file);
43         }
44         altos_list_finish(list);
45 #if HAS_BLUETOOTH
46         bt_list = altos_bt_list_start(8);
47         while (altos_bt_list_next(bt_list, &bt_device)) {
48                 printf ("%s %s\n", bt_device.name, bt_device.addr);
49                 if (strncmp(bt_device.name, "TeleBT", 6) == 0) {
50                         struct altos_file       *file;
51
52                         int                     c;
53                         file = altos_bt_open(&bt_device);
54                         if (!file) {
55                                 printf("altos_bt_open failed\n");
56                                 continue;
57                         }
58                         altos_puts(file,"v\nc s\n");
59                         altos_flush(file);
60                         while ((c = altos_getchar(file, 100)) >= 0) {
61                                 putchar(c);
62                         }
63                         if (c != LIBALTOS_TIMEOUT)
64                                 printf("getchar returns %d\n", c);
65                         altos_close(file);
66                 }
67         }
68         altos_bt_list_finish(bt_list);
69 #endif
70         altos_fini();
71         return 0;
72 }