mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 18:23:59 +08:00
chore: 支持在老版本激活设备时,OTA返回有效的硬件信息。
如果设备未激活,当前OTA会返回一个空的的firmware响应体。但老版本(如1.4.7)会因为缺少firmware响应体无法走通OTA版本检查流程。老版本相关代码如下
```CPP
// ota.cc - version 1.4.7 -line 131
cJSON *firmware = cJSON_GetObjectItem(root, "firmware");
if (firmware == NULL) { // firmware为空
ESP_LOGE(TAG, "Failed to get firmware object");
cJSON_Delete(root);
return false;
}
```
因此,在老版本激活设备时,OTA将直接返回的当前激活设备上传硬件的信息,以便老版本设备能够走通OTA版本检查流程。后续用户可以再通过智控台更新OTA版本。
This commit is contained in:
+12
-6
@@ -118,14 +118,20 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
|
|||||||
|
|
||||||
DeviceEntity deviceById = getDeviceByMacAddress(macAddress);
|
DeviceEntity deviceById = getDeviceByMacAddress(macAddress);
|
||||||
|
|
||||||
// 只有在设备已绑定且autoUpdate不为0的情况下才返回固件升级信息
|
// 设备未绑定,则返回当前上传的固件信息(不更新)以此兼容旧固件版本
|
||||||
if (deviceById != null && deviceById.getAutoUpdate() != 0) {
|
if (deviceById == null) {
|
||||||
String type = deviceReport.getBoard() == null ? null : deviceReport.getBoard().getType();
|
DeviceReportRespDTO.Firmware firmware = new DeviceReportRespDTO.Firmware();
|
||||||
DeviceReportRespDTO.Firmware firmware = buildFirmwareInfo(type,
|
firmware.setVersion(deviceReport.getApplication().getVersion());
|
||||||
deviceReport.getApplication() == null ? null : deviceReport.getApplication().getVersion());
|
firmware.setUrl("http://localhost:8002/xiaozhi/otaMag/download/NOT_ACTIVATED_FIRMWARE_THIS_IS_A_INVALID_URL");
|
||||||
response.setFirmware(firmware);
|
response.setFirmware(firmware);
|
||||||
} else {
|
} else {
|
||||||
response.setFirmware(null);
|
// 只有在设备已绑定且autoUpdate不为0的情况下才返回固件升级信息
|
||||||
|
if (deviceById.getAutoUpdate() != 0) {
|
||||||
|
String type = deviceReport.getBoard() == null ? null : deviceReport.getBoard().getType();
|
||||||
|
DeviceReportRespDTO.Firmware firmware = buildFirmwareInfo(type,
|
||||||
|
deviceReport.getApplication() == null ? null : deviceReport.getApplication().getVersion());
|
||||||
|
response.setFirmware(firmware);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加WebSocket配置
|
// 添加WebSocket配置
|
||||||
|
|||||||
Generated
+8837
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user