Skip to content

Commit b608537

Browse files
committed
feat:update xiaozhi ota
1 parent 61705bf commit b608537

20 files changed

+520
-21
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ mysql,redis,emqx和influxdb环境。
8888
欢迎加入群聊一起交流讨论有关Aiot相关的话题,免费获取智控台的前端源码,链接过期了可以issue或email提醒一下作者。
8989

9090
<div style="width: 250px;margin: 0 auto;">
91-
<img src="./images/bb570f3da747f8c91314697b969271c0.jpg" width="250px"/>
91+
<img src="./images/c2cfd1c5bbbe84e9d5892823f7dc6789.jpg" width="250px"/>
9292
</div>
9393

9494

docs/_sidebar.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
- [:bookmark: 快速开始](get_started/quick_start.md#快速开始)
44
- [:bookmark_tabs: 创建物模型和设备接入](get_started/create_thingsmodel.md#创建物模型和设备接入)
55
- 接入小智
6-
- [:bookmark_tabs: 小智接入和OTA升级](xiaozhi/xiaozhi.md#小智接入和OTA升级)
6+
- [:bookmark_tabs: 小智接入](xiaozhi/xiaozhi.md#小智接入)
77
- Ota
8-
- [:bookmark_tabs: 常规OTA升级](ota/common.md#普通OTA升级)
8+
- [:bookmark_tabs: OTA升级](ota/common.md#OTA升级)
99
- Mcp protocol
1010
- [:bookmark_tabs: 连接mcp服务器](mcp/connect_mcpServer.md#连接mcp服务器)
1111

-163 KB
Binary file not shown.
167 KB
Loading

docs/ota/common.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ curl --location 'http://localhost:8080/api/v2/otaPassive' \
4949
--data '{
5050
"deviceName": "{deviceName}",
5151
"name": "{name}",
52+
"description": "{description}",
5253
"versionName": "{versionName}"
5354
}'
5455
```
5556

56-
替换{deviceName}为设备名称,{your token}为token,{name}为升级包名称,{versionName}为升级包指定的版本名称。
57+
替换{deviceName}为设备名称,{your token}为token,{name}为升级包名称,{versionName}为升级包指定的版本名称,{description}为升级包描述
5758

5859
* 3.设备端通过通过网络连接,通过以下接口获取待升级的固件信息:
5960

@@ -76,4 +77,22 @@ curl -X GET "http://localhost:8080/api/v2/otaPassiveEnable?deviceName={deviceNam
7677
}
7778
```
7879
* 4.设备端通过网络连接,下载升级包,并进行升级。
79-
【下载升级包地址】:http://localhost:8080/api/v2/micro/{fileName}
80+
【下载升级包地址】:http://localhost:8080/api/v2/micro/{fileName}
81+
## 小智OTA升级
82+
> 小智OTA升级,支持小智直接通过平台的小智OTA接口进行升级。适用于平台的小智升级场景。
83+
* 1.上传软件升级包到服务器,使用上述方法步骤进行上传。
84+
* 2.指定待升级的固件,请使用以下命令进行设置:
85+
86+
```bash
87+
curl -X POST "http://localhost:8080/api/v2/xiaozhi/otaPassive"
88+
-H "accept: */*"
89+
-H "Content-Type: application/json"
90+
--header 'Authorization: {your token}'
91+
-d "{\"otaId\":{otaId},\"productId\":{productId},\"versionName\":{versionName}}"
92+
```
93+
94+
替换{otaId}为固件id,{productId}为产品id,{your token}为token,{versionName}为升级包指定的版本名称。
95+
96+
* 3.设备端通过通过网络连接,通过以下接口获取待升级的固件信息:
97+
* http://localhost:8080/xiaozhi/ota/
98+
返回信息详情请见[小智ota介绍] (https://ccnphfhqs21z.feishu.cn/wiki/FjW6wZmisimNBBkov6OcmfvknVd)

docs/xiaozhi/xiaozhi.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ AI小智是由虾哥研发的一款以情感交互为核心的开源AI语音对
1414
ota:
1515
bin:
1616
path: D://temp-rainy//
17+
url: http://127.0.0.1:8080/api/v2/micro/(固件升级URL)
1718
xiaozhi:
1819
url: ws://127.0.0.1:8080(改成你部署的域名)
20+
version: 1.9.2 (改成你的版本号)
1921
```
2022
2123
3. 通过下面接口进行绑定

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ mysql,redis,emqx和influxdb环境,安装详情请看官方文档。
116116
欢迎加入群聊一起交流讨论有关Aiot相关的话题,免费获取智控台的前端源码,链接过期了可以issue或email提醒一下作者。
117117

118118
<div style="width: 250px;margin: 0 auto;">
119-
<img src="./docs/images/bb570f3da747f8c91314697b969271c0.jpg" width="250px"/>
119+
<img src="./docs/images/c2cfd1c5bbbe84e9d5892823f7dc6789.jpg" width="250px"/>
120120
</div>
121121

122122
## 致谢

src/main/java/top/rslly/iot/controllers/Tool.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import top.rslly.iot.services.*;
3131
import top.rslly.iot.services.agent.AiServiceImpl;
3232
import top.rslly.iot.services.agent.KnowledgeChatServiceImpl;
33+
import top.rslly.iot.services.agent.OtaXiaozhiPassiveServiceImpl;
3334
import top.rslly.iot.services.agent.OtaXiaozhiServiceImpl;
3435
import top.rslly.iot.services.iot.AlarmEventServiceImpl;
3536
import top.rslly.iot.services.iot.HardWareServiceImpl;
@@ -79,6 +80,8 @@ public class Tool {
7980
private OtaXiaozhiServiceImpl otaXiaozhiService;
8081
@Autowired
8182
private KnowledgeChatServiceImpl knowledgeChatService;
83+
@Autowired
84+
private OtaXiaozhiPassiveServiceImpl otaXiaozhiPassiveService;
8285

8386
@Operation(summary = "用于获取平台运行环境信息", description = "单位为百分比")
8487
@RequestMapping(value = "/machineMessage", method = RequestMethod.GET)
@@ -399,4 +402,37 @@ public JsonResult<?> getMcpPointTools(@RequestParam("productId") int productId,
399402
return aiService.getMcpPointTools(productId);
400403
}
401404

405+
@Operation(summary = "ota小智升级", description = "获取ota小智升级包详情")
406+
@RequestMapping(value = "/xiaozhi/otaPassive", method = RequestMethod.GET)
407+
public JsonResult<?> getXiaoZhiOtaPassive(@RequestHeader("Authorization") String header) {
408+
return otaXiaozhiPassiveService.otaXiaozhiPassiveList(header);
409+
}
410+
411+
@Operation(summary = "ota小智升级", description = "选择ota小智升级包")
412+
@RequestMapping(value = "/xiaozhi/otaPassive", method = RequestMethod.POST)
413+
public JsonResult<?> postXiaoZhiOtaPassive(
414+
@Valid @RequestBody OtaXiaozhiPassive otaXiaozhiPassive,
415+
@RequestHeader("Authorization") String header) {
416+
try {
417+
if (!safetyService.controlAuthorizeProduct(header, otaXiaozhiPassive.getProductId()))
418+
return ResultTool.fail(ResultCode.NO_PERMISSION);
419+
} catch (NullPointerException e) {
420+
return ResultTool.fail(ResultCode.PARAM_NOT_VALID);
421+
}
422+
return otaXiaozhiPassiveService.otaXiaozhiPassivePost(otaXiaozhiPassive);
423+
}
424+
425+
@Operation(summary = "ota小智升级", description = "删除ota小智升级包")
426+
@RequestMapping(value = "/xiaozhi/otaPassive", method = RequestMethod.DELETE)
427+
public JsonResult<?> deleteXiaoZhiOtaPassive(@RequestParam("id") int id,
428+
@RequestHeader("Authorization") String header) {
429+
try {
430+
if (!safetyService.controlAuthorizeXiaoZhiOtaPassive(header, id))
431+
return ResultTool.fail(ResultCode.NO_PERMISSION);
432+
} catch (NullPointerException e) {
433+
return ResultTool.fail(ResultCode.PARAM_NOT_VALID);
434+
}
435+
return otaXiaozhiPassiveService.otaXiaozhiPassiveDelete(id);
436+
}
437+
402438
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.dao;
21+
22+
import org.springframework.data.jpa.repository.JpaRepository;
23+
import org.springframework.transaction.annotation.Transactional;
24+
import top.rslly.iot.models.OtaXiaozhiPassiveEntity;
25+
26+
import java.util.List;
27+
28+
public interface OtaXiaozhiPassiveRepository
29+
extends JpaRepository<OtaXiaozhiPassiveEntity, Integer> {
30+
List<OtaXiaozhiPassiveEntity> findAllById(int id);
31+
32+
List<OtaXiaozhiPassiveEntity> findAllByProductId(int productId);
33+
34+
@Transactional
35+
List<OtaXiaozhiPassiveEntity> deleteAllById(int id);
36+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.models;
21+
22+
import javax.persistence.*;
23+
import java.util.Objects;
24+
25+
@Entity
26+
@Table(name = "ota_xiaozhi_passive", schema = "cwliot1.8", catalog = "")
27+
public class OtaXiaozhiPassiveEntity {
28+
private int id;
29+
private int otaId;
30+
private int productId;
31+
private String versionName;
32+
33+
@Id
34+
@GeneratedValue(strategy = GenerationType.IDENTITY)
35+
@Column(name = "id")
36+
public int getId() {
37+
return id;
38+
}
39+
40+
public void setId(int id) {
41+
this.id = id;
42+
}
43+
44+
@Basic
45+
@Column(name = "ota_id")
46+
public int getOtaId() {
47+
return otaId;
48+
}
49+
50+
public void setOtaId(int otaId) {
51+
this.otaId = otaId;
52+
}
53+
54+
@Basic
55+
@Column(name = "product_id")
56+
public int getProductId() {
57+
return productId;
58+
}
59+
60+
public void setProductId(int productId) {
61+
this.productId = productId;
62+
}
63+
64+
@Basic
65+
@Column(name = "version_name")
66+
public String getVersionName() {
67+
return versionName;
68+
}
69+
70+
public void setVersionName(String versionName) {
71+
this.versionName = versionName;
72+
}
73+
74+
75+
@Override
76+
public boolean equals(Object o) {
77+
if (this == o)
78+
return true;
79+
if (o == null || getClass() != o.getClass())
80+
return false;
81+
OtaXiaozhiPassiveEntity that = (OtaXiaozhiPassiveEntity) o;
82+
return id == that.id && otaId == that.otaId && productId == that.productId
83+
&& Objects.equals(versionName, that.versionName);
84+
}
85+
86+
@Override
87+
public int hashCode() {
88+
return Objects.hash(id, otaId, productId, versionName);
89+
}
90+
}

0 commit comments

Comments
 (0)