mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 01:23:55 +08:00
Merge pull request #1245 from CaixyPromise/chore/setting-ota-firmware-in-old-version
chore: 支持在老版本激活设备时,OTA返回有效的硬件信息。
This commit is contained in:
+13
-7
@@ -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://xiaozhi.server.com: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配置
|
||||||
@@ -385,4 +391,4 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user