ESPHome  2024.12.0
seeed_mr60bha2.h
Go to the documentation of this file.
1 #pragma once
3 #include "esphome/core/defines.h"
4 #ifdef USE_SENSOR
6 #endif
9 #include "esphome/core/helpers.h"
10 
11 #include <map>
12 
13 namespace esphome {
14 namespace seeed_mr60bha2 {
15 
16 static const uint8_t DATA_BUF_MAX_SIZE = 12;
17 static const uint8_t FRAME_BUF_MAX_SIZE = 21;
18 static const uint8_t LEN_TO_HEAD_CKSUM = 8;
19 static const uint8_t LEN_TO_DATA_FRAME = 9;
20 
21 static const uint8_t FRAME_HEADER_BUFFER = 0x01;
22 static const uint16_t BREATH_RATE_TYPE_BUFFER = 0x0A14;
23 static const uint16_t HEART_RATE_TYPE_BUFFER = 0x0A15;
24 static const uint16_t DISTANCE_TYPE_BUFFER = 0x0A16;
25 
34  LOCATE_HEAD_CKSUM_FRAME, // Header checksum: [from the first byte to the previous byte of the HEAD_CKSUM bit]
36  LOCATE_DATA_CKSUM_FRAME, // Data checksum: [from the first to the previous byte of the DATA_CKSUM bit]
38 };
39 
41  public uart::UARTDevice { // The class name must be the name defined by text_sensor.py
42 #ifdef USE_SENSOR
43  SUB_SENSOR(breath_rate);
44  SUB_SENSOR(heart_rate);
45  SUB_SENSOR(distance);
46 #endif
47 
48  public:
49  float get_setup_priority() const override { return esphome::setup_priority::LATE; }
50  void dump_config() override;
51  void loop() override;
52 
53  protected:
54  bool validate_message_();
55  void process_frame_(uint16_t frame_id, uint16_t frame_type, const uint8_t *data, size_t length);
56 
57  std::vector<uint8_t> rx_message_;
58 };
59 
60 } // namespace seeed_mr60bha2
61 } // namespace esphome
void process_frame_(uint16_t frame_id, uint16_t frame_type, const uint8_t *data, size_t length)
const float LATE
For components that should be initialized at the very end of the setup process.
Definition: component.cpp:28
uint16_t length
Definition: tt21100.cpp:12
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7