]> cvs.zerfleddert.de Git - hmcfgusb/blame - hmuartlgw.h
hmsniff: fix length-byte from HM-MOD-UART
[hmcfgusb] / hmuartlgw.h
CommitLineData
3e34d2ce
MG
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_UNSOL_CREDITS 0x05
29#define HMUARTLGW_OS_NORMAL_MODE 0x06
30#define HMUARTLGW_OS_UPDATE_MODE 0x07
31#define HMUARTLGW_OS_GET_CREDITS 0x08
32#define HMUARTLGW_OS_GET_SERIAL 0x0B
33#define HMUARTLGW_OS_SET_TIME 0x0E
34
35#define HMUARTLGW_APP_SET_HMID 0x00
36#define HMUARTLGW_APP_GET_HMID 0x01
37#define HMUARTLGW_APP_SEND 0x02
38#define HMUARTLGW_APP_SET_CURRENT_KEY 0x03 /* key index */
39#define HMUARTLGW_APP_ACK 0x04
40#define HMUARTLGW_APP_RECV 0x05
41#define HMUARTLGW_APP_ADD_PEER 0x06
42#define HMUARTLGW_APP_REMOVE_PEER 0x07
43#define HMUARTLGW_APP_PEER_ADD_AES 0x09
44#define HMUARTLGW_APP_PEER_REMOVE_AES 0x0A
45#define HMUARTLGW_APP_SET_OLD_KEY 0x0F /* key index */
46#define HMUARTLGW_APP_DEFAULT_HMID 0x10
47
48enum hmuartlgw_dst {
49 HMUARTLGW_OS = 0,
50 HMUARTLGW_APP = 1,
51};
52
53typedef int (*hmuartlgw_cb_fn)(enum hmuartlgw_dst dst, uint8_t *buf, int buf_len, void *data);
54
55struct hmuartlgw_dev {
56 int fd;
57 hmuartlgw_cb_fn cb;
58 void *cb_data;
59 uint8_t last_send_cnt;
60 uint8_t buf[1024];
61 int pos;
62 int unescape_next;
63};
64
65struct hmuartlgw_dev *hmuart_init(char *device, hmuartlgw_cb_fn cb, void *data);
66struct hmuartlgw_dev *hmlgw_init(char *device, hmuartlgw_cb_fn cb, void *data);
67int hmuartlgw_send_raw(struct hmuartlgw_dev *dev, uint8_t *frame, int framelen);
68int hmuartlgw_send(struct hmuartlgw_dev *dev, uint8_t *cmd, int cmdlen, enum hmuartlgw_dst dst);
69int hmuartlgw_poll(struct hmuartlgw_dev *dev, int timeout);
70void hmuartlgw_close(struct hmuartlgw_dev *dev);
71void hmuartlgw_flush(struct hmuartlgw_dev *dev);
72void hmuartlgw_enter_bootloader(struct hmuartlgw_dev *dev);
73void hmuartlgw_enter_app(struct hmuartlgw_dev *dev);
74void hmuartlgw_set_debug(int d);
Impressum, Datenschutz