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:
@@ -975,7 +975,9 @@ void EMSESP::process_deviceName(std::shared_ptr<const Telegram> telegram) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char name[16];
|
char name[16];
|
||||||
uint8_t len = telegram->offset + telegram->message_length - 27;
|
// 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);
|
strlcpy(name, (const char *)&telegram->message_data[27 - telegram->offset], len < 16 ? len : 16);
|
||||||
char * c = name;
|
char * c = name;
|
||||||
while (isprint(*c)) {
|
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;
|
flags = DeviceFlags::EMS_DEVICE_FLAG_CR120;
|
||||||
default_name = "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;
|
flags = DeviceFlags::EMS_DEVICE_FLAG_HMC310;
|
||||||
default_name = "HMC310";
|
default_name = "HMC310";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user