mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
fix deviceName length (#2482), formatting
This commit is contained in:
@@ -974,8 +974,10 @@ void EMSESP::process_deviceName(std::shared_ptr<const Telegram> telegram) {
|
||||
if (telegram->offset > 27 || (telegram->offset + telegram->message_length) < 29) {
|
||||
return;
|
||||
}
|
||||
char name[16];
|
||||
uint8_t len = telegram->offset + telegram->message_length - 27;
|
||||
char name[16];
|
||||
// len including zero terminator, if there is one, otherwise copy to end of telegram
|
||||
// https://github.com/emsesp/EMS-ESP32/discussions/2482#discussioncomment-12649817
|
||||
uint8_t len = telegram->offset + telegram->message_length - 26;
|
||||
strlcpy(name, (const char *)&telegram->message_data[27 - telegram->offset], len < 16 ? len : 16);
|
||||
char * c = name;
|
||||
while (isprint(*c)) {
|
||||
@@ -1314,7 +1316,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
|
||||
flags = DeviceFlags::EMS_DEVICE_FLAG_CR120;
|
||||
default_name = "CR120";
|
||||
}
|
||||
if (product_id == 158 && strncmp(version,"73",2) == 0) {
|
||||
if (product_id == 158 && strncmp(version, "73", 2) == 0) {
|
||||
flags = DeviceFlags::EMS_DEVICE_FLAG_HMC310;
|
||||
default_name = "HMC310";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user