]> git.zerfleddert.de Git - hmcfgusb/blob - hm.h
firmware: fix maximum size
[hmcfgusb] / hm.h
1 /* HomeMatic defines and functions
2 *
3 * Copyright (c) 2014-16 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 LEN 0x00
25 #define MSGID 0x01
26 #define CTL 0x02
27 #define TYPE 0x03
28 #define PAYLOAD 0x0a
29
30 #define SRC(buf) (buf[0x06] | (buf[0x05] << 8) | (buf[0x04]) << 16)
31 #define DST(buf) (buf[0x09] | (buf[0x08] << 8) | (buf[0x07]) << 16)
32
33 #define SET_SRC(buf, src) do { buf[0x04] = (src >> 16) & 0xff; buf[0x05] = (src >> 8) & 0xff; buf[0x06] = src & 0xff; } while(0)
34 #define SET_DST(buf, dst) do { buf[0x07] = (dst >> 16) & 0xff; buf[0x08] = (dst >> 8) & 0xff; buf[0x09] = dst & 0xff; } while(0)
35
36 #define SET_LEN_FROM_PAYLOADLEN(buf, payloadlen) do { buf[0x00] = payloadlen + 0x09; } while(0)
37 #define PAYLOADLEN(buf) (buf[0x00] - 0x09)
38
39 enum device_type {
40 DEVICE_TYPE_HMCFGUSB,
41 DEVICE_TYPE_CULFW,
42 DEVICE_TYPE_HMUARTLGW,
43 };
44
45 struct hm_dev {
46 int type;
47 struct hmcfgusb_dev *hmcfgusb;
48 struct culfw_dev *culfw;
49 struct hmuartlgw_dev *hmuartlgw;
50 };
51
52 uint8_t* hm_sign(uint8_t *key, uint8_t *challenge, uint8_t *m_frame, uint8_t *exp_auth, uint8_t *resp);
Impressum, Datenschutz