update:更新文档

This commit is contained in:
hrz
2025-04-28 18:07:58 +08:00
parent b3f6efc7d0
commit 1cc470bc5a
2 changed files with 19 additions and 7 deletions
+2 -6
View File
@@ -106,10 +106,6 @@ VAD:
### 8、更多问题,可联系我们反馈 💬
我们的联系方式放在[百度网盘中,点击前往](https://pan.baidu.com/s/1x6USjvP1nTRsZ45XlJu65Q),提取码是`223y`
可以在[issues](https://github.com/xinnan-tech/xiaozhi-esp32-server/issues)提交您的问题
网盘里有"硬件烧录QQ群"、"开源服务端交流群"、"产品建议联系人" 三张图片,请根据需要选择加入。
- 硬件烧录QQ群:适用于硬件烧录问题
- 开源服务端交流群:适用于服务端问题
- 产品建议联系人:适用于产品功能、产品设计等建议
也可以发邮件我们取得联系:huangrongzhuang@xin-nan.com
@@ -52,8 +52,9 @@ public class OTAController {
clientId = deviceId;
}
String macAddress = deviceReportReqDTO.getMacAddress();
boolean macAddressValid = isMacAddressValid(macAddress);
// 设备Id和Mac地址应是一致的, 并且必须需要application字段
if (!deviceId.equals(macAddress) || deviceReportReqDTO.getApplication() == null) {
if (!deviceId.equals(macAddress) || !macAddressValid || deviceReportReqDTO.getApplication() == null) {
return createResponse(DeviceReportRespDTO.createError("Invalid OTA request"));
}
return createResponse(deviceService.checkDeviceActive(macAddress, clientId, deviceReportReqDTO));
@@ -100,4 +101,19 @@ public class OTAController {
.contentLength(jsonBytes.length)
.body(json);
}
/**
* 简单判断mac地址是否有效(非严格)
*
* @param macAddress
* @return
*/
private boolean isMacAddressValid(String macAddress) {
if (StringUtils.isBlank(macAddress)) {
return false;
}
// MAC地址通常为12位十六进制数字,可以包含冒号或连字符分隔符
String macPattern = "^([0-9A-Za-z]{2}[:-]){5}([0-9A-Za-z]{2})$";
return macAddress.matches(macPattern);
}
}