Skip to content

Commit 916723a

Browse files
committed
docs: add user guide for RPCD AT Daemon in English and Chinese
1 parent 8fc0b0c commit 916723a

File tree

4 files changed

+365
-19
lines changed

4 files changed

+365
-19
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
# QModem
1+
# QModem (English)
2+
3+
# Important Notice for WebUI Users and Developers:
4+
The ATD (AT Daemon) on the modem side is a legacy design with inconsistent implementations across different vendors, resulting in poor compatibility, concurrency issues, incomplete responses, and unstable service behavior.
5+
When using WebUI and QModem (or multiple modem management plugins) simultaneously, concurrent AT command execution can lead to incomplete information, ATD service crashes (typically due to vendor implementation issues), garbled output, AT command timeouts, and modem disconnections.
6+
7+
**For Users**: Choose one modem management solution and avoid using multiple plugins simultaneously.
8+
9+
**For WebUI Developers**: Consider using the ubus ATD plugin instead of relying on the modem's built-in ATD service. [Reference Documentation](docs/rpcd-at-daemon-userguide.md)
210

311
**[中文 README](README.zh-cn.md)** | **English README**
412

513
[![Auto compile with OpenWrt SDK](https://github.com/FUjr/modem_feeds/actions/workflows/main.yml/badge.svg)](https://github.com/FUjr/modem_feeds/actions/workflows/main.yml)
6-
[![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)
714

815
**QModem** is a comprehensive cellular modem management system for OpenWRT-based routers. It provides a LuCI-based web interface for easy administration and advanced control over various cellular modems.
916

README.zh-cn.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# QModem (中文)
22

3+
# 针对部分使用webui的用户和开发者的特别提示:
4+
模组端的atd是一个古老的设计,并且不同厂商有非常不同的实现,在兼容性和并发、返回完整性甚至atd服务的稳定性上都表现较差。
5+
因此当你同时使用 webui 和 qmodem (或者多个不同模组管理插件)时,会增加同时发送at指令的概率,造成 信息不全、atd服务崩溃(这通常是atd开发者的问题) 导致乱码、at卡死、模组掉线。
6+
如果你是用户,建议二选一,不要同时使用多个模组管理插件
7+
如果你是 webui 的开发者,我推荐你使用我开发的 ubus atd 插件来代替在模组端使用自建的 atd 服务,这样可以让qmodem兼容你的项目,并且节省您开发时间 [参考说明](docs/rpcd-at-daemon-userguide-cn.md)
8+
39
**中文 README** | **[English README](README.md)**
410

511
[![使用 OpenWrt SDK 自动编译](https://github.com/FUjr/modem_feeds/actions/workflows/main.yml/badge.svg)](https://github.com/FUjr/modem_feeds/actions/workflows/main.yml)
@@ -18,23 +24,7 @@
1824

1925
有关功能和能力的完整列表,请参阅[用户指南](docs/user-guide.zh-cn.md)
2026

21-
## 🏠 相关项目:Home Assistant 集成
22-
23-
想要在 Home Assistant 中监控您的 OpenWrt 路由器和 QModem 状态吗?请查看我们的配套项目:
24-
25-
### [OpenWrt Ubus Integration for Home Assistant](https://github.com/FUjr/homeassistant-openwrt-ubus)
26-
27-
一个自定义的 Home Assistant 集成,通过 ubus 接口连接到 OpenWrt 路由器,提供:
28-
29-
- **📱 设备跟踪**: 实时监控无线设备和 DHCP 客户端
30-
- **📊 系统监控**: 跟踪正常运行时间、负载平均值、内存使用情况
31-
- **📡 QModem 支持**: 监控 4G/LTE 调制解调器状态、信号强度和连接详情
32-
- **📶 无线站点**: 跟踪站点关联和信号信息
33-
- **🔧 简易设置**: 通过 Home Assistant UI 进行简单配置
34-
35-
![QModem Integration](https://github.com/FUjr/homeassistant-openwrt-ubus/blob/main/imgs/qmodem_info.png)
36-
37-
完美地将您的 QModem 驱动的 OpenWrt 路由器集成到智能家居生态系统中!
27+
## 相关项目: Home Assistant 的 OpenWrt 管理插件
3828

3929
[**在 GitHub 上查看 →**](https://github.com/FUjr/homeassistant-openwrt-ubus)
4030

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# RPCD AT Daemon 用户指南
2+
3+
## 为什么要使用这个服务
4+
1. **队列机制**:该服务实现了一个命令队列,可以较大程度确保同一时间只有一个AT指令运行,避免模组端的ATD出现并发错误
5+
2. **多种调用方式**:该服务可以借助 ubus 在路由端被其他服务调用,借助 rpcd 被 HTTP 服务调用,同时适合模组管理和 WebUI 开发
6+
3. **稳定性更好**:相比模组自带的 ATD 服务,该服务在不同厂商的模组上表现更加稳定可靠
7+
8+
## 使用方法
9+
10+
### 1. 添加 rpcd 权限配置
11+
为 at-daemon 添加 rpcd 权限(为了方便演示,下面添加的是免认证服务,生产环境请根据安全需求配置适当的认证)
12+
```bash
13+
echo << EOF > /usr/share/rpcd/acl.d/unauthenticated.json
14+
{
15+
"unauthenticated": {
16+
"description": "Access controls for unauthenticated requests",
17+
"read": {
18+
"ubus": {
19+
"session": [
20+
"access",
21+
"login"
22+
],
23+
"at-daemon" : ["list","open","sendat","close"]
24+
}
25+
}
26+
}
27+
}
28+
EOF
29+
```
30+
31+
### 2. 通过 HTTP 接口发送 AT 指令
32+
使用 curl 访问 rpcd 发送指令:
33+
34+
```bash
35+
curl -s -X POST -H "Content-Type: application/json" -d '
36+
{
37+
"jsonrpc":"2.0",
38+
"id":1,
39+
"method":"call",
40+
"params":["00000000000000000000000000000000","at-daemon","sendat",{"at_port":"/dev/ttyUSB0","at_cmd":"at+cgmm"}]
41+
}
42+
' http://192.168.1.1/ubus
43+
```
44+
45+
**响应示例:**
46+
```json
47+
{
48+
"jsonrpc": "2.0",
49+
"id": 1,
50+
"result": [
51+
0,
52+
{
53+
"port": "/dev/ttyUSB0",
54+
"command": "at+cgmm",
55+
"is_raw": 0,
56+
"sendonly": 0,
57+
"timeout": 5,
58+
"end_flag": "default",
59+
"end_flags_used": [
60+
"OK",
61+
"ERROR",
62+
"+CMS ERROR:",
63+
"+CME ERROR:",
64+
"NO CARRIER"
65+
],
66+
"status": "success",
67+
"response": "\r\nMH5000-82M\r\n\r\nOK\r\n",
68+
"response_length": 20,
69+
"end_flag_matched": "OK",
70+
"response_time_ms": 79
71+
}
72+
]
73+
}
74+
```
75+
76+
### 3. 通过 ubus 命令发送 AT 指令
77+
也可以直接在路由器上使用 ubus 命令:
78+
79+
```bash
80+
ubus call at-daemon sendat '{"at_port":"/dev/ttyUSB0","at_cmd":"at+cgmm"}'
81+
```
82+
83+
## API 参数详解
84+
```bash
85+
ubus -v list at-daemon
86+
'at-daemon' @de5d6d53
87+
"open":{"at_port":"String","baudrate":"Integer","databits":"Integer","parity":"Integer","stopbits":"Integer","timeout":"Integer"}
88+
"sendat":{"at_port":"String","timeout":"Integer","end_flag":"String","at_cmd":"String","raw_at_content":"String","sendonly":"Boolean"}
89+
"list":{}
90+
"close":{"at_port":"String"}
91+
```
92+
93+
### 方法说明
94+
95+
#### open - 打开串口
96+
打开指定的串口设备(通常使用 `sendat` 时会自动调用此方法)
97+
98+
**参数:**
99+
- `at_port` (String, 必需): 串口设备路径,如 `/dev/ttyUSB0`
100+
- `baudrate` (Integer, 可选): 波特率,默认 115200
101+
- `databits` (Integer, 可选): 数据位,默认 8
102+
- `parity` (Integer, 可选): 校验位,0=无校验,1=奇校验,2=偶校验
103+
- `stopbits` (Integer, 可选): 停止位,1 或 2
104+
- `timeout` (Integer, 可选): 超时时间(秒),默认 5
105+
106+
#### sendat - 发送 AT 指令
107+
发送 AT 指令到指定串口并接收响应
108+
109+
**参数:**
110+
- `at_port` (String, 必需): 串口设备路径
111+
- `at_cmd` (String, 可选): AT 指令内容,如 `at+cgmm`
112+
- `raw_at_content` (String, 可选): 16进制格式的原始内容,与 `at_cmd` 二选一
113+
- `timeout` (Integer, 可选): 超时时间(秒),默认 5
114+
- `sendonly` (Boolean, 可选): 是否只发送不接收响应,默认 false
115+
- `end_flag` (String, 可选): 自定义结束符,响应包含该字符时截断
116+
117+
**默认结束符:** `OK``ERROR``+CMS ERROR:``+CME ERROR:``NO CARRIER`
118+
119+
#### list - 列出串口
120+
列出所有已打开的串口连接
121+
122+
**参数:**
123+
124+
#### close - 关闭串口
125+
关闭指定的串口连接
126+
127+
**参数:**
128+
- `at_port` (String, 必需): 要关闭的串口设备路径
129+
130+
## 重要注意事项
131+
132+
### 1. 与 QModem 共享串口
133+
如果要与 QModem 共享串口,需要在 QModem 配置中启用 ubus at 模式,否则 ubus at 启动后会独占串口缓冲区,导致 QModem 无法获取信息。
134+
135+
**配置方法:**
136+
```bash
137+
uci set qmodem.1_1_2.use_ubus='1'
138+
uci commit qmodem
139+
```
140+
141+
### 2. 响应终止符
142+
在项目中调用 ubus-at-daemon 时,请确保 AT 命令返回包含以下终止符之一:
143+
- `OK`
144+
- `ERROR`
145+
- `+CMS ERROR:`
146+
- `+CME ERROR:`
147+
- `NO CARRIER`
148+
149+
或者手动通过 `end_flag` 参数指定终止符。否则请求会等待超时才返回,且 `status` 会返回错误。
150+
151+
### 3. 安全建议
152+
生产环境中不建议使用免认证的 rpcd 配置,请根据实际安全需求配置适当的认证机制。
153+
154+
## 使用示例
155+
156+
### 查询模组型号
157+
```bash
158+
ubus call at-daemon sendat '{"at_port":"/dev/ttyUSB0","at_cmd":"at+cgmm"}'
159+
```
160+
161+
### 查询信号强度
162+
```bash
163+
ubus call at-daemon sendat '{"at_port":"/dev/ttyUSB0","at_cmd":"at+csq"}'
164+
```
165+
166+
### 仅发送指令不等待响应
167+
```bash
168+
ubus call at-daemon sendat '{"at_port":"/dev/ttyUSB0","at_cmd":"at+cfun=1,1","sendonly":true}'
169+
```
170+
171+
### 自定义超时时间
172+
```bash
173+
ubus call at-daemon sendat '{"at_port":"/dev/ttyUSB0","at_cmd":"at+cgmm","timeout":10}'
174+
```

0 commit comments

Comments
 (0)