112 lines
2.8 KiB
C
112 lines
2.8 KiB
C
/// © MiroZ 2024
|
|
#ifndef __SENSOR_DATA_H__
|
|
#define __SENSOR_DATA_H__
|
|
|
|
#include <stdint.h>
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
struct MESSAGE_HEADER
|
|
{
|
|
uint8_t type;
|
|
uint32_t sec;
|
|
uint32_t usec;
|
|
uint8_t mac[6];
|
|
uint32_t group_id;
|
|
};
|
|
|
|
struct MESSAGE_TYPE_VAL_REASON
|
|
{
|
|
uint8_t type;
|
|
uint32_t val;
|
|
uint8_t reason;
|
|
};
|
|
|
|
struct RADAR
|
|
{
|
|
uint8_t type;
|
|
uint16_t vals[24];
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
#define HEADER_MESSAGE(name_) \
|
|
struct MESSAGE_HEADER name_; \
|
|
createHeader(&name_);
|
|
|
|
#define HEADER_MESSAGE_P(addr_) \
|
|
createHeader(addr_);
|
|
|
|
#define PRESSURE_MESSAGE(name_, val_, reason_) \
|
|
struct MESSAGE_TYPE_VAL_REASON name_; \
|
|
name_.type = MESSAGE_TYPE_PRESSURE; \
|
|
name_.val = val_; name_.reason = reason_;
|
|
|
|
#define PRESSURE_MESSAGE_P(addr_, val_, reason_) \
|
|
(addr)->type = MESSAGE_TYPE_PRESSURE; \
|
|
(addr)->val = val_; (addr)->reason = reason_;
|
|
|
|
#define LIGHT_MESSAGE(name_, val_, reason_) \
|
|
struct MESSAGE_TYPE_VAL_REASON name_; \
|
|
name_.type = MESSAGE_TYPE_LIGHT; \
|
|
name_.val = val_; name_.reason = reason_;
|
|
|
|
#define LIGHT_MESSAGE_P(addr_, val_, reason_) \
|
|
(addr_)->type = MESSAGE_TYPE_LIGHT; \
|
|
(addr_)->val = val_; (addr_)->reason = reason_;
|
|
|
|
#define TEMP_MESSAGE(name_, val_, reason_) \
|
|
struct MESSAGE_TYPE_VAL_REASON name_; \
|
|
name_.type = MESSAGE_TYPE_TEMP; \
|
|
name_.val = val_; name_.reason = reason_;
|
|
|
|
#define TEMP_MESSAGE_P(addr_, val_, reason_) \
|
|
(addr_)->type = MESSAGE_TYPE_TEMP; \
|
|
(addr_)->val = val_; (addr_)->reason = reason_;
|
|
|
|
#define HUM_MESSAGE(name_, val_, reason_) \
|
|
struct MESSAGE_TYPE_VAL_REASON name_; \
|
|
name_.type = MESSAGE_TYPE_HUMIDITY; \
|
|
name_.val = val_; name_.reason = reason_;
|
|
|
|
#define HUM_MESSAGE_P(addr_, val_, reason_) \
|
|
(addr_)->type = MESSAGE_TYPE_HUMIDITY; \
|
|
(addr_)->val = val_; (addr_)->reason = reason_;
|
|
|
|
#define GAS_IX_MESSAGE(name_, val_, reason_) \
|
|
struct MESSAGE_TYPE_VAL_REASON name_; \
|
|
name_.type = MESSAGE_TYPE_GAS_IX; \
|
|
name_.val = val_; name_.reason = reason_;
|
|
|
|
#define GAS_IX_MESSAGE_P(addr_, val_, reason_) \
|
|
(addr_)->type = MESSAGE_TYPE_GAS_IX; \
|
|
(addr_)->val = val_; (addr_)->reason = reason_;
|
|
|
|
#define GAS_VAL_MESSAGE(name_, val_, reason_) \
|
|
struct MESSAGE_TYPE_VAL_REASON name_; \
|
|
name_.type = MESSAGE_TYPE_GAS_VAL; \
|
|
name_.val = val_; name_.reason = reason_;
|
|
|
|
#define GAS_VAL_MESSAGE_P(addr_, val_, reason_) \
|
|
(addr_)->type = MESSAGE_TYPE_GAS_VAL; \
|
|
(addr_)->val = val_; (addr_)->reason = reason_;
|
|
|
|
#define RADAR_MESSAGE(name_) \
|
|
struct RADAR name_; \
|
|
name_.type = MESSAGE_TYPE_RADAR;
|
|
|
|
#define RADAR_MESSAGE_P(addr_) \
|
|
(addr_)->type = MESSAGE_TYPE_RADAR;
|
|
|
|
#define MESSAGE_TYPE_HEADER 0xa5
|
|
#define MESSAGE_TYPE_PRESSURE 0x04
|
|
#define MESSAGE_TYPE_RADAR 0x37
|
|
#define MESSAGE_TYPE_LIGHT 0x06
|
|
#define MESSAGE_TYPE_TEMP 0x07
|
|
#define MESSAGE_TYPE_HUMIDITY 0x08
|
|
#define MESSAGE_TYPE_GAS_IX 0x09
|
|
#define MESSAGE_TYPE_GAS_VAL 0x0a
|
|
|
|
void createHeader(struct MESSAGE_HEADER * header);
|
|
|
|
#endif |