mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 15:38:11 +01:00
refactor(mr60bha2): static methods name
This commit is contained in:
parent
9d4bdb1ea1
commit
e7e1df2da4
2 changed files with 5 additions and 7 deletions
|
@ -60,7 +60,7 @@ void MR60BHA2Component::loop() {
|
||||||
* @param len The length of the byte array.
|
* @param len The length of the byte array.
|
||||||
* @return The calculated checksum.
|
* @return The calculated checksum.
|
||||||
*/
|
*/
|
||||||
uint8_t MR60BHA2Component::calculate_checksum_(const uint8_t *data, size_t len) {
|
static uint8_t calculate_checksum(const uint8_t *data, size_t len) {
|
||||||
uint8_t checksum = 0;
|
uint8_t checksum = 0;
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
checksum ^= data[i];
|
checksum ^= data[i];
|
||||||
|
@ -80,8 +80,8 @@ uint8_t MR60BHA2Component::calculate_checksum_(const uint8_t *data, size_t len)
|
||||||
* @param expected_checksum The expected checksum.
|
* @param expected_checksum The expected checksum.
|
||||||
* @return True if the checksum is valid, false otherwise.
|
* @return True if the checksum is valid, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool MR60BHA2Component::validate_checksum_(const uint8_t *data, size_t len, uint8_t expected_checksum) {
|
static bool validate_checksum(const uint8_t *data, size_t len, uint8_t expected_checksum) {
|
||||||
return calculate_checksum_(data, len) == expected_checksum;
|
return calculate_checksum(data, len) == expected_checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MR60BHA2Component::split_frame_(uint8_t buffer) {
|
void MR60BHA2Component::split_frame_(uint8_t buffer) {
|
||||||
|
@ -156,7 +156,7 @@ void MR60BHA2Component::split_frame_(uint8_t buffer) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LOCATE_HEAD_CKSUM_FRAME:
|
case LOCATE_HEAD_CKSUM_FRAME:
|
||||||
if (this->validate_checksum_(this->current_frame_buf_, this->current_frame_len_, buffer)) {
|
if (validate_checksum(this->current_frame_buf_, this->current_frame_len_, buffer)) {
|
||||||
this->current_frame_len_++;
|
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->current_frame_locate_++;
|
||||||
|
@ -182,7 +182,7 @@ void MR60BHA2Component::split_frame_(uint8_t buffer) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LOCATE_DATA_CKSUM_FRAME:
|
case LOCATE_DATA_CKSUM_FRAME:
|
||||||
if (this->validate_checksum_(this->current_data_buf_, this->current_data_frame_len_, buffer)) {
|
if (validate_checksum(this->current_data_buf_, this->current_data_frame_len_, buffer)) {
|
||||||
this->current_frame_len_++;
|
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->current_frame_locate_++;
|
||||||
|
|
|
@ -57,8 +57,6 @@ class MR60BHA2Component : public Component,
|
||||||
uint32_t current_heart_rate_int_;
|
uint32_t current_heart_rate_int_;
|
||||||
uint32_t current_distance_int_;
|
uint32_t current_distance_int_;
|
||||||
|
|
||||||
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 split_frame_(uint8_t buffer);
|
||||||
void process_frame_();
|
void process_frame_();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue