1. 优化了cpp_json的内容,使其更modern
2. 稍微优化了一下系统配置类 3. 增加了系统版本号,便于区分系统版本,方便OTA 4. 重写OTA的逻辑,完成了Cpp的OTA封装,测试通过
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <esp_efuse_table.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
|
||||
static const char *TAG = "ToolsClass";
|
||||
|
||||
@@ -39,4 +40,31 @@ std::string ToolsClass::getChipMAC() {
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
// 1. 去掉 mac 中的冒号
|
||||
// 2. 拼接 chipID
|
||||
// 3. 取前 24 字符并转大写
|
||||
std::string ToolsClass::GenerateSN(const std::string& mac, const std::string& chipID)
|
||||
{
|
||||
// 1. 去掉 MAC 里的冒号
|
||||
std::string plainMac;
|
||||
plainMac.reserve(mac.size());
|
||||
for (char ch : mac)
|
||||
if (ch != ':') plainMac.push_back(ch);
|
||||
|
||||
// 2. 拼接
|
||||
std::string raw = plainMac + chipID;
|
||||
|
||||
// 3. 取前 24 位并转大写
|
||||
if (raw.size() > 24) raw.resize(24);
|
||||
std::transform(raw.begin(), raw.end(), raw.begin(),
|
||||
[](unsigned char c){ return std::toupper(c); });
|
||||
return raw;
|
||||
}
|
||||
|
||||
std::string ToolsClass::device_version = "Beta0.3";
|
||||
std::string ToolsClass::getDeviceVersion() {
|
||||
return device_version;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user