-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglucosemeter.h
127 lines (105 loc) · 3.24 KB
/
glucosemeter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* Copyright (c) 2009, 2012 Alexander Schrijver
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sqlite3.h>
#include <sys/queue.h>
#include <gtk/gtk.h>
/* parse.y */
#define GM_CONFIG_FILE "glucosemeter.conf"
struct gm_conf;
int parse_config(const char *, struct gm_conf *);
/* glucosemeter.c */
struct device;
struct gm_conf {
TAILQ_HEAD(, device) devices;
int devicemgmt_status;
sqlite3 *sqlite3_handle;
GtkTreeModel *measurements;
};
int meas_insert(struct gm_conf *conf, int glucose, char *date, char *device);
GtkTreeModel *meas_model(struct gm_conf *conf);
int meas_model_fill(struct gm_conf *conf, GtkListStore *store);
/* devicemgmt.c */
struct driver;
struct device {
struct driver *driver;
GIOChannel *channel;
struct gm_conf *conf;
size_t length;
TAILQ_ENTRY(device) entry;
int is_processing;
};
struct driver {
char *driver_name;
int (*driver_start_fn)(struct device *);
int (*driver_stop_fn)(struct device *);
int (*driver_input)(struct device *, GIOChannel *gio);
int (*driver_output)(struct device *, GIOChannel *gio);
int (*driver_error)(struct device *, GIOChannel *gio);
};
void devicemgmt_init(struct gm_conf *);
void devicemgmt_start(struct gm_conf *);
void devicemgmt_stop(struct gm_conf *);
int devicemgmt_status(struct gm_conf *);
gboolean devicemgmt_input(GIOChannel *gio, GIOCondition condition, gpointer data);
gboolean devicemgmt_output(GIOChannel *gio, GIOCondition condition, gpointer data);
gboolean devicemgmt_error(GIOChannel *gio, GIOCondition condition, gpointer data);
/* abfr.c */
#define ABFR_MAX_ENTRIES 450
// XXX: do these include the NULL terminator?
#define ABFR_ENTRYLEN 31
#define ABFR_TIMELEN 16
extern struct driver abfr_driver;
enum abfr_devtype {
ABFR_DEV_UNKNOWN,
ABFR_DEV_CDMK311_B0764, // FreeStyle Freedom Lite
ABFR_DEV_DAMH359_63524, // FreeStyle Mini
ABFR_DEV_DBMN169_C4824 // FreeStyle Lite
};
enum abfr_softrev {
ABFR_SOFT_UNKNOWN,
ABFR_SOFT_4_0100_P,
ABFR_SOFT_0_31_P1_B0764,
ABFR_SOFT_0_31_P, /* XXX: */
ABFR_SOFT_1_43_P,
};
struct abfr_entry {
int bloodglucose;
struct tm ptm;
int plasmatype;
SLIST_ENTRY(abfr_entry) next;
};
struct abfr_dev {
struct device device;
char *file;
enum abfr_protocol_state {
ABFR_SEND_MEM,
ABFR_DEVICE_TYPE,
ABFR_SOFTWARE_REVISION,
ABFR_CURRENTDATETIME,
ABFR_NUMBEROFRESULTS,
ABFR_RESULTLINE,
ABFR_END,
ABFR_EMPTY,
ABFR_FAIL,
ABFR_DONE,
} protocol_state;
uint16_t checksum;
int nresults;
int results_processed;
SLIST_HEAD(, abfr_entry) entries;
};
struct abfr_dev *abfr_init(char *);