diff --git a/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp b/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp index a3904bf8ab..f4a56df1e1 100644 --- a/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp +++ b/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp @@ -46,8 +46,8 @@ void MR60FDA2Component::setup() { this->get_radar_parameters(); - memset(this->current_frame_buf, 0, FRAME_BUF_MAX_SIZE); - memset(this->current_data_buf, 0, DATA_BUF_MAX_SIZE); + memset(this->current_frame_buf_, 0, FRAME_BUF_MAX_SIZE); + memset(this->current_data_buf_, 0, DATA_BUF_MAX_SIZE); ESP_LOGCONFIG(TAG, "Set up MR60FDA2 complete"); } @@ -59,7 +59,7 @@ void MR60FDA2Component::loop() { // Is there data on the serial port while (this->available()) { this->read_byte(&byte); - this->splitFrame(byte); // split data frame + this->split_frame_(byte); // split data frame } } @@ -73,7 +73,7 @@ void MR60FDA2Component::loop() { * @param len The length of the byte array. * @return The calculated checksum. */ -uint8_t MR60FDA2Component::calculateChecksum(const uint8_t *data, size_t len) { +uint8_t MR60FDA2Component::calculate_checksum_(const uint8_t *data, size_t len) { uint8_t checksum = 0; for (size_t i = 0; i < len; i++) { checksum ^= data[i]; @@ -93,11 +93,11 @@ uint8_t MR60FDA2Component::calculateChecksum(const uint8_t *data, size_t len) { * @param expected_checksum The expected checksum. * @return True if the checksum is valid, false otherwise. */ -bool MR60FDA2Component::validateChecksum(const uint8_t *data, size_t len, uint8_t expected_checksum) { - return calculateChecksum(data, len) == expected_checksum; +bool MR60FDA2Component::validate_checksum_(const uint8_t *data, size_t len, uint8_t expected_checksum) { + return calculate_checksum_(data, len) == expected_checksum; } -uint8_t MR60FDA2Component::find_nearest_index(float value, const float *arr, int size) { +uint8_t MR60FDA2Component::find_nearest_index_(float value, const float *arr, int size) { int nearest_index = 0; float min_diff = std::abs(value - arr[0]); for (int i = 1; i < size; ++i) { @@ -110,32 +110,32 @@ uint8_t MR60FDA2Component::find_nearest_index(float value, const float *arr, int return nearest_index; } -void MR60FDA2Component::splitFrame(uint8_t buffer) { +void MR60FDA2Component::split_frame_(uint8_t buffer) { switch (this->current_frame_locate_) { case LOCATE_FRAME_HEADER: // starting buffer if (buffer == FRAME_HEADER_BUFFER) { this->current_frame_len_ = 1; - this->current_frame_buf[this->current_frame_len_ - 1] = buffer; + this->current_frame_buf_[this->current_frame_len_ - 1] = buffer; this->current_frame_locate_++; } break; case LOCATE_ID_FRAME1: this->current_frame_id_ = buffer << 8; this->current_frame_len_++; - this->current_frame_buf[this->current_frame_len_ - 1] = buffer; + this->current_frame_buf_[this->current_frame_len_ - 1] = buffer; this->current_frame_locate_++; break; case LOCATE_ID_FRAME2: this->current_frame_id_ += buffer; this->current_frame_len_++; - this->current_frame_buf[this->current_frame_len_ - 1] = buffer; + this->current_frame_buf_[this->current_frame_len_ - 1] = buffer; this->current_frame_locate_++; break; case LOCATE_LENGTH_FRAME_H: this->current_data_frame_len_ = buffer << 8; if (this->current_data_frame_len_ == 0x00) { this->current_frame_len_++; - this->current_frame_buf[this->current_frame_len_ - 1] = buffer; + this->current_frame_buf_[this->current_frame_len_ - 1] = buffer; this->current_frame_locate_++; } else { // ESP_LOGD(TAG, "DATA_FRAME_LEN_H: 0x%02x", buffer); @@ -152,16 +152,16 @@ void MR60FDA2Component::splitFrame(uint8_t buffer) { this->current_frame_locate_ = LOCATE_FRAME_HEADER; } else { this->current_frame_len_++; - this->current_frame_buf[this->current_frame_len_ - 1] = buffer; + this->current_frame_buf_[this->current_frame_len_ - 1] = buffer; this->current_frame_locate_++; } break; case LOCATE_TYPE_FRAME1: this->current_frame_type_ = buffer << 8; this->current_frame_len_++; - this->current_frame_buf[this->current_frame_len_ - 1] = buffer; + this->current_frame_buf_[this->current_frame_len_ - 1] = buffer; this->current_frame_locate_++; - // ESP_LOGD(TAG, "GET LOCATE_TYPE_FRAME1: 0x%02x", this->current_frame_buf[this->current_frame_len_ - 1]); + // ESP_LOGD(TAG, "GET LOCATE_TYPE_FRAME1: 0x%02x", this->current_frame_buf_[this->current_frame_len_ - 1]); break; case LOCATE_TYPE_FRAME2: this->current_frame_type_ += buffer; @@ -170,41 +170,41 @@ void MR60FDA2Component::splitFrame(uint8_t buffer) { (this->current_frame_type_ == RUSULT_INSTALL_HEIGHT) || (this->current_frame_type_ == RUSULT_PARAMETERS) || (this->current_frame_type_ == RUSULT_HEIGHT_THRESHOLD) || (this->current_frame_type_ == RUSULT_SENSITIVITY)) { this->current_frame_len_++; - this->current_frame_buf[this->current_frame_len_ - 1] = buffer; + this->current_frame_buf_[this->current_frame_len_ - 1] = buffer; this->current_frame_locate_++; - // ESP_LOGD(TAG, "GET CURRENT_FRAME_TYPE: 0x%02x 0x%02x", this->current_frame_buf[this->current_frame_len_ - 2], - // this->current_frame_buf[this->current_frame_len_ - 1]); + // ESP_LOGD(TAG, "GET CURRENT_FRAME_TYPE: 0x%02x 0x%02x", this->current_frame_buf_[this->current_frame_len_ - 2], + // this->current_frame_buf_[this->current_frame_len_ - 1]); } else { // ESP_LOGD(TAG, "CURRENT_FRAME_TYPE NOT FOUND: 0x%02x 0x%02x", - // this->current_frame_buf[this->current_frame_len_ - 2], - // this->current_frame_buf[this->current_frame_len_ - 1]); + // this->current_frame_buf_[this->current_frame_len_ - 2], + // this->current_frame_buf_[this->current_frame_len_ - 1]); this->current_frame_locate_ = LOCATE_FRAME_HEADER; } break; case LOCATE_HEAD_CKSUM_FRAME: - if (this->validateChecksum(this->current_frame_buf, this->current_frame_len_, buffer)) { + if (this->validate_checksum_(this->current_frame_buf_, this->current_frame_len_, buffer)) { this->current_frame_len_++; - this->current_frame_buf[this->current_frame_len_ - 1] = buffer; + this->current_frame_buf_[this->current_frame_len_ - 1] = buffer; this->current_frame_locate_++; } else { ESP_LOGD(TAG, "HEAD_CKSUM_FRAME ERROR: 0x%02x", buffer); ESP_LOGD(TAG, "GET CURRENT_FRAME: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", - this->current_frame_buf[this->current_frame_len_ - 9], - this->current_frame_buf[this->current_frame_len_ - 8], - this->current_frame_buf[this->current_frame_len_ - 7], - this->current_frame_buf[this->current_frame_len_ - 6], - this->current_frame_buf[this->current_frame_len_ - 5], - this->current_frame_buf[this->current_frame_len_ - 4], - this->current_frame_buf[this->current_frame_len_ - 3], - this->current_frame_buf[this->current_frame_len_ - 2], - this->current_frame_buf[this->current_frame_len_ - 1], buffer); + this->current_frame_buf_[this->current_frame_len_ - 9], + this->current_frame_buf_[this->current_frame_len_ - 8], + this->current_frame_buf_[this->current_frame_len_ - 7], + this->current_frame_buf_[this->current_frame_len_ - 6], + this->current_frame_buf_[this->current_frame_len_ - 5], + this->current_frame_buf_[this->current_frame_len_ - 4], + this->current_frame_buf_[this->current_frame_len_ - 3], + this->current_frame_buf_[this->current_frame_len_ - 2], + this->current_frame_buf_[this->current_frame_len_ - 1], buffer); this->current_frame_locate_ = LOCATE_FRAME_HEADER; } break; case LOCATE_DATA_FRAME: this->current_frame_len_++; - this->current_frame_buf[this->current_frame_len_ - 1] = buffer; - this->current_data_buf[this->current_frame_len_ - LEN_TO_DATA_FRAME] = buffer; + this->current_frame_buf_[this->current_frame_len_ - 1] = buffer; + this->current_data_buf_[this->current_frame_len_ - LEN_TO_DATA_FRAME] = buffer; if (this->current_frame_len_ - LEN_TO_HEAD_CKSUM == this->current_data_frame_len_) { this->current_frame_locate_++; } @@ -214,23 +214,23 @@ void MR60FDA2Component::splitFrame(uint8_t buffer) { } break; case LOCATE_DATA_CKSUM_FRAME: - if (this->validateChecksum(this->current_data_buf, this->current_data_frame_len_, buffer)) { + if (this->validate_checksum_(this->current_data_buf_, this->current_data_frame_len_, buffer)) { this->current_frame_len_++; - this->current_frame_buf[this->current_frame_len_ - 1] = buffer; + this->current_frame_buf_[this->current_frame_len_ - 1] = buffer; this->current_frame_locate_++; - this->processFrame(); + this->process_frame_(); } else { ESP_LOGD(TAG, "DATA_CKSUM_FRAME ERROR: 0x%02x", buffer); ESP_LOGD(TAG, "GET CURRENT_FRAME: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", - this->current_frame_buf[this->current_frame_len_ - 9], - this->current_frame_buf[this->current_frame_len_ - 8], - this->current_frame_buf[this->current_frame_len_ - 7], - this->current_frame_buf[this->current_frame_len_ - 6], - this->current_frame_buf[this->current_frame_len_ - 5], - this->current_frame_buf[this->current_frame_len_ - 4], - this->current_frame_buf[this->current_frame_len_ - 3], - this->current_frame_buf[this->current_frame_len_ - 2], - this->current_frame_buf[this->current_frame_len_ - 1], buffer); + this->current_frame_buf_[this->current_frame_len_ - 9], + this->current_frame_buf_[this->current_frame_len_ - 8], + this->current_frame_buf_[this->current_frame_len_ - 7], + this->current_frame_buf_[this->current_frame_len_ - 6], + this->current_frame_buf_[this->current_frame_len_ - 5], + this->current_frame_buf_[this->current_frame_len_ - 4], + this->current_frame_buf_[this->current_frame_len_ - 3], + this->current_frame_buf_[this->current_frame_len_ - 2], + this->current_frame_buf_[this->current_frame_len_ - 1], buffer); this->current_frame_locate_ = LOCATE_FRAME_HEADER; } break; @@ -239,13 +239,13 @@ void MR60FDA2Component::splitFrame(uint8_t buffer) { } } -void MR60FDA2Component::processFrame() { +void MR60FDA2Component::process_frame_() { switch (this->current_frame_type_) { case IS_FALL_TYPE_BUFFER: if (this->is_fall_text_sensor_ != nullptr) { - if (this->current_frame_buf[LEN_TO_HEAD_CKSUM] == 0) { + if (this->current_frame_buf_[LEN_TO_HEAD_CKSUM] == 0) { this->is_fall_text_sensor_->publish_state("Normal"); - } else if (this->current_frame_buf[LEN_TO_HEAD_CKSUM] == 1) { + } else if (this->current_frame_buf_[LEN_TO_HEAD_CKSUM] == 1) { this->is_fall_text_sensor_->publish_state("Falling"); } } @@ -253,65 +253,71 @@ void MR60FDA2Component::processFrame() { break; case PEOPLE_EXIST_TYPE_BUFFER: if (this->people_exist_binary_sensor_ != nullptr) - this->people_exist_binary_sensor_->publish_state(this->current_frame_buf[LEN_TO_HEAD_CKSUM]); + this->people_exist_binary_sensor_->publish_state(this->current_frame_buf_[LEN_TO_HEAD_CKSUM]); this->current_frame_locate_ = LOCATE_FRAME_HEADER; break; case RUSULT_INSTALL_HEIGHT: - if (this->current_data_buf[0]) + if (this->current_data_buf_[0]) { ESP_LOGD(TAG, "Successfully set the mounting height"); - else + } + else { ESP_LOGD(TAG, "Failed to set the mounting height"); + } this->current_frame_locate_ = LOCATE_FRAME_HEADER; break; case RUSULT_HEIGHT_THRESHOLD: - if (this->current_data_buf[0]) + if (this->current_data_buf_[0]) { ESP_LOGD(TAG, "Successfully set the height threshold"); - else + } + else { ESP_LOGD(TAG, "Failed to set the height threshold"); + } this->current_frame_locate_ = LOCATE_FRAME_HEADER; break; case RUSULT_SENSITIVITY: - if (this->current_data_buf[0]) + if (this->current_data_buf_[0]) { ESP_LOGD(TAG, "Successfully set the sensitivity"); - else + } + else { ESP_LOGD(TAG, "Failed to set the sensitivity"); + } this->current_frame_locate_ = LOCATE_FRAME_HEADER; break; case RUSULT_PARAMETERS: // ESP_LOGD( // TAG, // "GET CURRENT_FRAME: 0x%02x 0x%02x 0x%02x 0x%02x, 0x%02x 0x%02x 0x%02x 0x%02x, 0x%02x 0x%02x 0x%02x 0x%02x", - // this->current_frame_buf[8], this->current_frame_buf[9], this->current_frame_buf[10], - // this->current_frame_buf[11], this->current_frame_buf[12], this->current_frame_buf[13], - // this->current_frame_buf[14], this->current_frame_buf[15], this->current_frame_buf[16], - // this->current_frame_buf[17], this->current_frame_buf[18], this->current_frame_buf[19]); + // this->current_frame_buf_[8], this->current_frame_buf_[9], this->current_frame_buf_[10], + // this->current_frame_buf_[11], this->current_frame_buf_[12], this->current_frame_buf_[13], + // this->current_frame_buf_[14], this->current_frame_buf_[15], this->current_frame_buf_[16], + // this->current_frame_buf_[17], this->current_frame_buf_[18], this->current_frame_buf_[19]); // ESP_LOGD( // TAG, // "GET CURRENT_FRAME_2: 0x%02x 0x%02x 0x%02x 0x%02x, 0x%02x 0x%02x 0x%02x 0x%02x, 0x%02x 0x%02x 0x%02x - // 0x%02x", this->current_data_buf[0], this->current_data_buf[1], this->current_data_buf[2], - // this->current_data_buf[3], this->current_data_buf[4], this->current_data_buf[5], this->current_data_buf[6], - // this->current_data_buf[7], this->current_data_buf[8], this->current_data_buf[9], - // this->current_data_buf[10], this->current_data_buf[11]); + // 0x%02x", this->current_data_buf_[0], this->current_data_buf_[1], this->current_data_buf_[2], + // this->current_data_buf_[3], this->current_data_buf_[4], this->current_data_buf_[5], this->current_data_buf_[6], + // this->current_data_buf_[7], this->current_data_buf_[8], this->current_data_buf_[9], + // this->current_data_buf_[10], this->current_data_buf_[11]); this->current_install_height_int_ = - (static_cast(current_data_buf[3]) << 24) | (static_cast(current_data_buf[2]) << 16) | - (static_cast(current_data_buf[1]) << 8) | static_cast(current_data_buf[0]); + (static_cast(current_data_buf_[3]) << 24) | (static_cast(current_data_buf_[2]) << 16) | + (static_cast(current_data_buf_[1]) << 8) | static_cast(current_data_buf_[0]); float install_height_float; memcpy(&install_height_float, ¤t_install_height_int_, sizeof(float)); - select_index_ = find_nearest_index(install_height_float, INSTALL_HEIGHT, 7); + select_index_ = find_nearest_index_(install_height_float, INSTALL_HEIGHT, 7); this->install_height_select_->publish_state(INSTALL_HEIGHT_STR[select_index_]); this->current_height_threshold_int_ = - (static_cast(current_data_buf[7]) << 24) | (static_cast(current_data_buf[6]) << 16) | - (static_cast(current_data_buf[5]) << 8) | static_cast(current_data_buf[4]); + (static_cast(current_data_buf_[7]) << 24) | (static_cast(current_data_buf_[6]) << 16) | + (static_cast(current_data_buf_[5]) << 8) | static_cast(current_data_buf_[4]); float height_threshold_float; memcpy(&height_threshold_float, ¤t_height_threshold_int_, sizeof(float)); - select_index_ = find_nearest_index(height_threshold_float, HEIGHT_THRESHOLD, 7); + select_index_ = find_nearest_index_(height_threshold_float, HEIGHT_THRESHOLD, 7); this->height_threshold_select_->publish_state(HEIGHT_THRESHOLD_STR[select_index_]); this->current_sensitivity_ = - (static_cast(current_data_buf[11]) << 24) | (static_cast(current_data_buf[10]) << 16) | - (static_cast(current_data_buf[9]) << 8) | static_cast(current_data_buf[8]); - select_index_ = find_nearest_index(this->current_sensitivity_, SENSITIVITY, 3); + (static_cast(current_data_buf_[11]) << 24) | (static_cast(current_data_buf_[10]) << 16) | + (static_cast(current_data_buf_[9]) << 8) | static_cast(current_data_buf_[8]); + select_index_ = find_nearest_index_(this->current_sensitivity_, SENSITIVITY, 3); this->sensitivity_select_->publish_state(SENSITIVITY_STR[select_index_]); - ESP_LOGD(TAG, "Mounting height: %.2f, Height threshold: %.2f, Sensitivity: %lu", install_height_float, + ESP_LOGD(TAG, "Mounting height: %.2f, Height threshold: %.2f, Sensitivity: %u", install_height_float, height_threshold_float, this->current_sensitivity_); this->current_frame_locate_ = LOCATE_FRAME_HEADER; break; @@ -331,7 +337,7 @@ void MR60FDA2Component::send_query_(uint8_t *query, size_t string_length) { this * @param value The float value to convert. * @param bytes The byte array to store the converted value. */ -void MR60FDA2Component::float_to_bytes(float value, unsigned char *bytes) { +void MR60FDA2Component::float_to_bytes_(float value, unsigned char *bytes) { union { float float_value; unsigned char byte_array[4]; @@ -349,7 +355,7 @@ void MR60FDA2Component::float_to_bytes(float value, unsigned char *bytes) { * @param value The 32-bit unsigned integer to convert. * @param bytes The byte array to store the converted value. */ -void MR60FDA2Component::int_to_bytes(uint32_t value, unsigned char *bytes) { +void MR60FDA2Component::int_to_bytes_(uint32_t value, unsigned char *bytes) { bytes[0] = value & 0xFF; bytes[1] = (value >> 8) & 0xFF; bytes[2] = (value >> 16) & 0xFF; @@ -358,17 +364,16 @@ void MR60FDA2Component::int_to_bytes(uint32_t value, unsigned char *bytes) { // Send Heartbeat Packet Command void MR60FDA2Component::set_install_height(uint8_t index) { - size_t send_data_len = 13; - uint8_t send_data[send_data_len] = {0x01, 0x00, 0x00, 0x00, 0x04, 0x0E, 0x04, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00}; + uint8_t send_data[13] = {0x01, 0x00, 0x00, 0x00, 0x04, 0x0E, 0x04, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t data_frame[4] = {0x00, 0x00, 0x00, 0x00}; - float_to_bytes(INSTALL_HEIGHT[index], &send_data[8]); + float_to_bytes_(INSTALL_HEIGHT[index], &send_data[8]); for (int i = 0; i < 4; i++) { data_frame[i] = send_data[i + 8]; } - send_data[12] = calculateChecksum(data_frame, 4); + send_data[12] = calculate_checksum_(data_frame, 4); this->send_query_(send_data, send_data_len); ESP_LOGD(TAG, "SEND INSTALL HEIGHT FRAME: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x " @@ -378,17 +383,16 @@ void MR60FDA2Component::set_install_height(uint8_t index) { } void MR60FDA2Component::set_height_threshold(uint8_t index) { - size_t send_data_len = 13; - uint8_t send_data[send_data_len] = {0x01, 0x00, 0x00, 0x00, 0x04, 0x0E, 0x08, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00}; + uint8_t send_data[13] = {0x01, 0x00, 0x00, 0x00, 0x04, 0x0E, 0x08, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t data_frame[4] = {0x00, 0x00, 0x00, 0x00}; - float_to_bytes(HEIGHT_THRESHOLD[index], &send_data[8]); + float_to_bytes_(HEIGHT_THRESHOLD[index], &send_data[8]); for (int i = 0; i < 4; i++) { data_frame[i] = send_data[i + 8]; } - send_data[12] = calculateChecksum(data_frame, 4); + send_data[12] = calculate_checksum_(data_frame, 4); this->send_query_(send_data, send_data_len); ESP_LOGD(TAG, "SEND HEIGHT THRESHOLD: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x " @@ -398,17 +402,16 @@ void MR60FDA2Component::set_height_threshold(uint8_t index) { } void MR60FDA2Component::set_sensitivity(uint8_t index) { - size_t send_data_len = 13; - uint8_t send_data[send_data_len] = {0x01, 0x00, 0x00, 0x00, 0x04, 0x0E, 0x0A, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00}; + uint8_t send_data[13] = {0x01, 0x00, 0x00, 0x00, 0x04, 0x0E, 0x0A, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t data_frame[4] = {0x00, 0x00, 0x00, 0x00}; - int_to_bytes(SENSITIVITY[index], &send_data[8]); + int_to_bytes_(SENSITIVITY[index], &send_data[8]); for (int i = 0; i < 4; i++) { data_frame[i] = send_data[i + 8]; } - send_data[12] = calculateChecksum(data_frame, 4); + send_data[12] = calculate_checksum_(data_frame, 4); this->send_query_(send_data, send_data_len); ESP_LOGD(TAG, "SEND SET SENSITIVITY: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x " @@ -418,16 +421,14 @@ void MR60FDA2Component::set_sensitivity(uint8_t index) { } void MR60FDA2Component::get_radar_parameters() { - size_t send_data_len = 8; - uint8_t send_data[send_data_len] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x06, 0xF6}; + uint8_t send_data[8] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x06, 0xF6}; this->send_query_(send_data, send_data_len); ESP_LOGD(TAG, "SEND GET PARAMETERS: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", send_data[0], send_data[1], send_data[2], send_data[3], send_data[4], send_data[5], send_data[6], send_data[7]); } void MR60FDA2Component::reset_radar() { - size_t send_data_len = 8; - uint8_t send_data[send_data_len] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0xCF}; + uint8_t send_data[8] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0xCF}; this->send_query_(send_data, send_data_len); ESP_LOGD(TAG, "SEND RESET: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", send_data[0], send_data[1], send_data[2], send_data[3], send_data[4], send_data[5], send_data[6], send_data[7]); diff --git a/esphome/components/seeed_mr60fda2/seeed_mr60fda2.h b/esphome/components/seeed_mr60fda2/seeed_mr60fda2.h index ececaada49..451e5dbbcf 100644 --- a/esphome/components/seeed_mr60fda2/seeed_mr60fda2.h +++ b/esphome/components/seeed_mr60fda2/seeed_mr60fda2.h @@ -77,8 +77,8 @@ class MR60FDA2Component : public Component, protected: uint8_t current_frame_locate_; - uint8_t current_frame_buf[FRAME_BUF_MAX_SIZE]; - uint8_t current_data_buf[DATA_BUF_MAX_SIZE]; + uint8_t current_frame_buf_[FRAME_BUF_MAX_SIZE]; + uint8_t current_data_buf_[DATA_BUF_MAX_SIZE]; uint16_t current_frame_id_; size_t current_frame_len_; size_t current_data_frame_len_; @@ -88,14 +88,14 @@ class MR60FDA2Component : public Component, uint32_t current_sensitivity_; uint8_t select_index_; - bool validateChecksum(const uint8_t *data, size_t len, uint8_t expected_checksum); - uint8_t calculateChecksum(const uint8_t *data, size_t len); - void splitFrame(uint8_t buffer); - void processFrame(); + bool validate_checksum_(const uint8_t *data, size_t len, uint8_t expected_checksum); + uint8_t calculate_checksum_(const uint8_t *data, size_t len); + void split_frame_(uint8_t buffer); + void process_frame_(); void send_query_(uint8_t *query, size_t string_length); - void float_to_bytes(float value, unsigned char *bytes); - void int_to_bytes(uint32_t value, unsigned char *bytes); - uint8_t find_nearest_index(float value, const float *arr, int size); + void float_to_bytes_(float value, unsigned char *bytes); + void int_to_bytes_(uint32_t value, unsigned char *bytes); + uint8_t find_nearest_index_(float value, const float *arr, int size); public: float get_setup_priority() const override { return esphome::setup_priority::LATE; }