]> cvs.zerfleddert.de Git - hmcfgusb/blob - hmuartlgw.h
Makefile: remove objects for flash-hmmoduart on clean
[hmcfgusb] / hmuartlgw.h
1 /* HM-MOD-UART/HM-LGW-O-TW-W-EU driver
2 *
3 * Copyright (c) 2016 Michael Gernoth <michael@gernoth.net>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #define HMUARTLGW_OS_GET_APP 0x00
25 #define HMUARTLGW_OS_GET_FIRMWARE 0x02
26 #define HMUARTLGW_OS_CHANGE_APP 0x03
27 #define HMUARTLGW_OS_ACK 0x04
28 #define HMUARTLGW_OS_UPDATE_FIRMWARE 0x05
29 #define HMUARTLGW_OS_UNSOL_CREDITS 0x05
30 #define HMUARTLGW_OS_NORMAL_MODE 0x06
31 #define HMUARTLGW_OS_UPDATE_MODE 0x07
32 #define HMUARTLGW_OS_GET_CREDITS 0x08
33 #define HMUARTLGW_OS_GET_SERIAL 0x0B
34 #define HMUARTLGW_OS_SET_TIME 0x0E
35
36 #define HMUARTLGW_APP_SET_HMID 0x00
37 #define HMUARTLGW_APP_GET_HMID 0x01
38 #define HMUARTLGW_APP_SEND 0x02
39 #define HMUARTLGW_APP_SET_CURRENT_KEY 0x03 /* key index */
40 #define HMUARTLGW_APP_ACK 0x04
41 #define HMUARTLGW_APP_RECV 0x05
42 #define HMUARTLGW_APP_ADD_PEER 0x06
43 #define HMUARTLGW_APP_REMOVE_PEER 0x07
44 #define HMUARTLGW_APP_GET_PEERS 0x08
45 #define HMUARTLGW_APP_PEER_ADD_AES 0x09
46 #define HMUARTLGW_APP_PEER_REMOVE_AES 0x0A
47 #define HMUARTLGW_APP_SET_OLD_KEY 0x0F /* key index */
48 #define HMUARTLGW_APP_DEFAULT_HMID 0x10
49
50 #define HMUARTLGW_ACK_EINPROGRESS 0x08
51
52 enum hmuartlgw_dst {
53 HMUARTLGW_OS = 0,
54 HMUARTLGW_APP = 1,
55 };
56
57 typedef int (*hmuartlgw_cb_fn)(enum hmuartlgw_dst dst, uint8_t *buf, int buf_len, void *data);
58
59 struct hmuartlgw_dev {
60 int fd;
61 hmuartlgw_cb_fn cb;
62 void *cb_data;
63 uint8_t last_send_cnt;
64 uint8_t buf[1024];
65 int pos;
66 int unescape_next;
67 };
68
69 struct hmuartlgw_dev *hmuart_init(char *device, hmuartlgw_cb_fn cb, void *data, int app);
70 struct hmuartlgw_dev *hmlgw_init(char *device, hmuartlgw_cb_fn cb, void *data);
71 int hmuartlgw_send_raw(struct hmuartlgw_dev *dev, uint8_t *frame, int framelen);
72 int hmuartlgw_send(struct hmuartlgw_dev *dev, uint8_t *cmd, int cmdlen, enum hmuartlgw_dst dst);
73 int hmuartlgw_poll(struct hmuartlgw_dev *dev, int timeout);
74 void hmuartlgw_close(struct hmuartlgw_dev *dev);
75 void hmuartlgw_flush(struct hmuartlgw_dev *dev);
76 void hmuartlgw_enter_bootloader(struct hmuartlgw_dev *dev);
77 void hmuartlgw_enter_app(struct hmuartlgw_dev *dev);
78 void hmuartlgw_set_debug(int d);
Impressum, Datenschutz