-
Notifications
You must be signed in to change notification settings - Fork 1
/
fhz.h
46 lines (39 loc) · 927 Bytes
/
fhz.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
/*
* fhz2mqtt, a FHZ to MQTT bridge
*
* Copyright (c) Ralf Ramsauer, 2018
*
* Authors:
* Ralf Ramsauer <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*/
#include "fht.h"
#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])
#define __stringify(a) __str(a)
#define __str(a) #a
#define FHZ_MAGIC 0x81
#define BAUDRATE B9600
#define error(...) \
do { \
char error_buffer[128]; \
snprintf(error_buffer, sizeof(error_buffer), __VA_ARGS__); \
fprintf(stderr, error_buffer); \
} while(0)
struct payload {
unsigned char tt;
unsigned char len;
unsigned char data[256];
};
struct fhz_message {
enum {
FHT,
} machine;
union {
struct fht_message fht;
};
};
int fhz_open_serial(const char *device);
int fhz_send(int fd, const struct payload *payload);
int fhz_handle(int fd, struct fhz_message *message);