4#ifndef PROTOCORE_ENOCEAN_H
5#define PROTOCORE_ENOCEAN_H
44#define PROTOCORE_ERP_RORG_RPS 0xF6
45#define PROTOCORE_ERP_RORG_1BS 0xD5
46#define PROTOCORE_ERP_RORG_4BS 0xA5
47#define PROTOCORE_ERP_RORG_VLD 0xD2
48#define PROTOCORE_ERP_RORG_MSC 0xD1
49#define PROTOCORE_ERP_RORG_ADT 0xA6
50#define PROTOCORE_ERP_RORG_UTE 0xD4
53EMBED_ENUM_BYTE(protocore_esp3_type, ESP3_RADIO_ERP1 = 0x01, ESP3_RESPONSE = 0x02, ESP3_RADIO_SUB_TEL = 0x03,
54 ESP3_EVENT = 0x04, ESP3_COMMON_COMMAND = 0x05, ESP3_SMART_ACK = 0x06, ESP3_REMOTE_MAN = 0x07,
55 ESP3_RADIO_ERP2 = 0x0A, );
80 uint8_t (*
esp3_crc8)(
const uint8_t *,
const uint8_t *, uint16_t);
82 uint16_t (*
esp3_build)(uint8_t *, protocore_esp3_type,
const uint8_t *, uint16_t,
const uint8_t *, uint8_t,
85 uint16_t (*
erp1_build)(
const uint8_t *, uint8_t *, uint16_t, uint8_t,
const uint8_t *, uint8_t, uint32_t, uint8_t);
119 const uint8_t *opt, uint8_t opt_len, uint8_t *out, uint16_t cap);
142 const uint8_t *payload, uint8_t payload_len, uint32_t sender_id, uint8_t status);
uint8_t protocore_enocean_esp3_crc8(const uint8_t *work, const uint8_t *buf, uint16_t len)
CRC-8 used by ESP3 (polynomial 0x07, MSB-first, init 0x00).
EMBED_ENUM_BYTE(protocore_esp3_type, ESP3_RADIO_ERP1=0x01, ESP3_RESPONSE=0x02, ESP3_RADIO_SUB_TEL=0x03, ESP3_EVENT=0x04, ESP3_COMMON_COMMAND=0x05, ESP3_SMART_ACK=0x06, ESP3_REMOTE_MAN=0x07, ESP3_RADIO_ERP2=0x0A,)
ESP3 packet types (the common ones).
embed_bool protocore_enocean_erp1_parse(const uint8_t *work, const uint8_t *data, uint16_t len, protocore_erp1 *out)
Decode an ERP1 radio telegram: RORG + payload + 4-octet sender id + .
int protocore_enocean_esp3_parse(uint8_t *work, const uint8_t *raw, uint16_t len, protocore_esp3_packet *out)
Frame one ESP3 telegram from the front of raw.
uint16_t protocore_enocean_esp3_build(uint8_t *work, protocore_esp3_type type, const uint8_t *data, uint16_t data_len, const uint8_t *opt, uint8_t opt_len, uint8_t *out, uint16_t cap)
Assemble an ESP3 telegram into out.
uint16_t protocore_enocean_erp1_build(const uint8_t *work, uint8_t *out, uint16_t cap, uint8_t rorg, const uint8_t *payload, uint8_t payload_len, uint32_t sender_id, uint8_t status)
Assemble an ERP1 radio telegram (the inverse of .
#define PROTOCORE_UNUSED
Suppress the unused warning. Every module ends in a namespace most callers only partly use.
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Dispatch table. Addressed by offset, so the layout is asserted below.
int(* esp3_parse)(uint8_t *, const uint8_t *, uint16_t, protocore_esp3_packet *)
uint16_t(* erp1_build)(const uint8_t *, uint8_t *, uint16_t, uint8_t, const uint8_t *, uint8_t, uint32_t, uint8_t)
uint8_t(* esp3_crc8)(const uint8_t *, const uint8_t *, uint16_t)
embed_bool(* erp1_parse)(const uint8_t *, const uint8_t *, uint16_t, protocore_erp1 *)
uint16_t(* esp3_build)(uint8_t *, protocore_esp3_type, const uint8_t *, uint16_t, const uint8_t *, uint8_t, uint8_t *, uint16_t)
A decoded ERP1 radio telegram (the payload aliases the caller's buffer).
const uint8_t * payload
RORG-specific data, or nullptr if none.
uint8_t rorg
telegram type (PROTOCORE_ERP_RORG_*)
uint8_t status
status octet (repeater count + telegram-type bits)
uint32_t sender_id
4-octet sender id (big-endian)
uint8_t payload_len
payload octets (data length - 6)
A parsed ESP3 telegram (pointers alias the caller's buffer).
uint8_t opt_len
optional-data length
const uint8_t * data
data field
uint16_t data_len
data length
const uint8_t * opt
optional-data field
protocore_esp3_type type
packet type (protocore_esp3_type)