altos: Add distinct LED pattern before writing log data
[fw/altos] / altosui / libaltos / libaltos.h
1 /*
2  * Copyright © 2010 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 #ifndef _LIBALTOS_H_
19 #define _LIBALTOS_H_
20
21 #include <stdlib.h>
22
23 #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
24 # ifndef BUILD_STATIC
25 #  ifdef BUILD_DLL
26 #   define PUBLIC __declspec(dllexport)
27 #  else
28 #   define PUBLIC __declspec(dllimport)
29 #  endif
30 # endif /* BUILD_STATIC */
31 #endif
32
33 #ifndef PUBLIC
34 # define PUBLIC
35 #endif
36
37 struct altos_device {
38         //%immutable;
39         int                             vendor;
40         int                             product;
41         int                             serial;
42         char                            name[256];
43         char                            path[256];
44         //%mutable;
45 };
46
47 struct altos_bt_device {
48         //%immutable;
49         char                            name[256];
50         char                            addr[20];
51         //%mutable;
52 };
53
54 struct altos_error {
55         int                             code;
56         char                            string[1024];
57 };
58
59 #define LIBALTOS_SUCCESS        0
60 #define LIBALTOS_ERROR          -1
61 #define LIBALTOS_TIMEOUT        -2
62
63 /* Returns 0 for success, < 0 on error */
64 PUBLIC int
65 altos_init(void);
66
67 PUBLIC void
68 altos_fini(void);
69
70 PUBLIC void
71 altos_get_last_error(struct altos_error *error);
72
73 PUBLIC struct altos_list *
74 altos_list_start(void);
75
76 /* Returns 1 for success, zero on end of list */
77 PUBLIC int
78 altos_list_next(struct altos_list *list, struct altos_device *device);
79
80 PUBLIC void
81 altos_list_finish(struct altos_list *list);
82
83 PUBLIC struct altos_file *
84 altos_open(struct altos_device *device);
85
86 PUBLIC void
87 altos_close(struct altos_file *file);
88
89 PUBLIC void
90 altos_free(struct altos_file *file);
91
92 /* Returns < 0 for error */
93 PUBLIC int
94 altos_putchar(struct altos_file *file, char c);
95
96 /* Returns < 0 for error */
97 PUBLIC int
98 altos_flush(struct altos_file *file);
99
100 /* Returns < 0 for error or timeout. timeout of 0 == wait forever */
101 PUBLIC int
102 altos_getchar(struct altos_file *file, int timeout);
103
104 PUBLIC struct altos_bt_list *
105 altos_bt_list_start(int inquiry_time);
106
107 PUBLIC int
108 altos_bt_list_next(struct altos_bt_list *list, struct altos_bt_device *device);
109
110 PUBLIC void
111 altos_bt_list_finish(struct altos_bt_list *list);
112
113 PUBLIC void
114 altos_bt_fill_in(char *name, char *addr, struct altos_bt_device *device);
115
116 PUBLIC struct altos_file *
117 altos_bt_open(struct altos_bt_device *device);
118
119 #endif /* _LIBALTOS_H_ */