Fix: JK BMS: BMS name is second part of product ID

This commit is contained in:
Bernhard Kirchen 2024-04-18 13:55:25 +02:00 committed by Bernhard Kirchen
parent 4cd690de66
commit 1d4bea24ff
2 changed files with 6 additions and 1 deletions

View File

@ -333,7 +333,12 @@ void JkBmsBatteryStats::updateFrom(JkBms::DataPointContainer const& dp)
_manufacturer = "JKBMS"; _manufacturer = "JKBMS";
auto oProductId = dp.get<Label::ProductId>(); auto oProductId = dp.get<Label::ProductId>();
if (oProductId.has_value()) { if (oProductId.has_value()) {
_manufacturer = oProductId->c_str(); // the first twelve chars are expected to be the "User Private Data"
// setting (see smartphone app). the remainder is expected be the BMS
// name, which can be changed at will using the smartphone app. so
// there is not always a "JK" in this string. if there is, we still cut
// the string there to avoid possible regressions.
_manufacturer = oProductId->substr(12).c_str();
auto pos = oProductId->rfind("JK"); auto pos = oProductId->rfind("JK");
if (pos != std::string::npos) { if (pos != std::string::npos) {
_manufacturer = oProductId->substr(pos).c_str(); _manufacturer = oProductId->substr(pos).c_str();

Binary file not shown.