|
| 1 | +# QModem RPCD Interface |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The QModem RPCD interface provides ubus access to modem control functions. This allows other services and web interfaces to interact with modems through the ubus system. |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +The rpcd script is automatically installed with the qmodem package: |
| 10 | +- Script location: `/usr/libexec/rpcd/qmodem` |
| 11 | +- ACL configuration: `/usr/share/rpcd/acl.d/qmodem.json` |
| 12 | + |
| 13 | +After installation, restart rpcd: |
| 14 | +```bash |
| 15 | +killall -HUP rpcd |
| 16 | +``` |
| 17 | + |
| 18 | +## Available Methods |
| 19 | + |
| 20 | +### Information Methods (Read-only) |
| 21 | + |
| 22 | +#### base_info |
| 23 | +Get basic modem information. |
| 24 | +```bash |
| 25 | +ubus call qmodem base_info '{"config_section":"modem1"}' |
| 26 | +``` |
| 27 | + |
| 28 | +#### cell_info |
| 29 | +Get cellular network information. |
| 30 | +```bash |
| 31 | +ubus call qmodem cell_info '{"config_section":"modem1"}' |
| 32 | +``` |
| 33 | + |
| 34 | +#### info |
| 35 | +Get comprehensive modem information. |
| 36 | +```bash |
| 37 | +ubus call qmodem info '{"config_section":"modem1"}' |
| 38 | +``` |
| 39 | + |
| 40 | +#### network_info |
| 41 | +Get network connection information. |
| 42 | +```bash |
| 43 | +ubus call qmodem network_info '{"config_section":"modem1"}' |
| 44 | +``` |
| 45 | + |
| 46 | +#### sim_info |
| 47 | +Get SIM card information. |
| 48 | +```bash |
| 49 | +ubus call qmodem sim_info '{"config_section":"modem1"}' |
| 50 | +``` |
| 51 | + |
| 52 | +#### get_at_cfg |
| 53 | +Get AT command configuration and available ports. |
| 54 | +```bash |
| 55 | +ubus call qmodem get_at_cfg '{"config_section":"modem1"}' |
| 56 | +``` |
| 57 | + |
| 58 | +#### get_copyright |
| 59 | +Get copyright information. |
| 60 | +```bash |
| 61 | +ubus call qmodem get_copyright '{"config_section":"modem1"}' |
| 62 | +``` |
| 63 | + |
| 64 | +#### get_disabled_features |
| 65 | +Get list of disabled features for this modem. |
| 66 | +```bash |
| 67 | +ubus call qmodem get_disabled_features '{"config_section":"modem1"}' |
| 68 | +``` |
| 69 | + |
| 70 | +#### get_dns |
| 71 | +Get DNS server information. |
| 72 | +```bash |
| 73 | +ubus call qmodem get_dns '{"config_section":"modem1"}' |
| 74 | +``` |
| 75 | + |
| 76 | +#### get_imei |
| 77 | +Get modem IMEI number. |
| 78 | +```bash |
| 79 | +ubus call qmodem get_imei '{"config_section":"modem1"}' |
| 80 | +``` |
| 81 | + |
| 82 | +#### get_lockband |
| 83 | +Get current band lock configuration. |
| 84 | +```bash |
| 85 | +ubus call qmodem get_lockband '{"config_section":"modem1"}' |
| 86 | +``` |
| 87 | + |
| 88 | +#### get_mode |
| 89 | +Get current network mode (LTE/5G/etc). |
| 90 | +```bash |
| 91 | +ubus call qmodem get_mode '{"config_section":"modem1"}' |
| 92 | +``` |
| 93 | + |
| 94 | +#### get_neighborcell |
| 95 | +Get neighboring cell information. |
| 96 | +```bash |
| 97 | +ubus call qmodem get_neighborcell '{"config_section":"modem1"}' |
| 98 | +``` |
| 99 | + |
| 100 | +#### get_network_prefer |
| 101 | +Get network preference settings. |
| 102 | +```bash |
| 103 | +ubus call qmodem get_network_prefer '{"config_section":"modem1"}' |
| 104 | +``` |
| 105 | + |
| 106 | +#### get_reboot_caps |
| 107 | +Get available reboot methods (hard/soft). |
| 108 | +```bash |
| 109 | +ubus call qmodem get_reboot_caps '{"config_section":"modem1"}' |
| 110 | +``` |
| 111 | + |
| 112 | +#### get_sms |
| 113 | +Get SMS messages. |
| 114 | +```bash |
| 115 | +ubus call qmodem get_sms '{"config_section":"modem1"}' |
| 116 | +``` |
| 117 | + |
| 118 | +### Control Methods (Write) |
| 119 | + |
| 120 | +#### clear_dial_log |
| 121 | +Clear the dial log. |
| 122 | +```bash |
| 123 | +ubus call qmodem clear_dial_log '{"config_section":"modem1"}' |
| 124 | +``` |
| 125 | + |
| 126 | +#### delete_sms |
| 127 | +Delete SMS messages by index. |
| 128 | +```bash |
| 129 | +ubus call qmodem delete_sms '{"config_section":"modem1","index":"1 2 3"}' |
| 130 | +``` |
| 131 | + |
| 132 | +#### do_reboot |
| 133 | +Reboot the modem. |
| 134 | +```bash |
| 135 | +# Hard reboot |
| 136 | +ubus call qmodem do_reboot '{"config_section":"modem1","params":{"method":"hard"}}' |
| 137 | + |
| 138 | +# Soft reboot |
| 139 | +ubus call qmodem do_reboot '{"config_section":"modem1","params":{"method":"soft"}}' |
| 140 | +``` |
| 141 | + |
| 142 | +#### send_at |
| 143 | +Send AT command to modem. |
| 144 | +```bash |
| 145 | +ubus call qmodem send_at '{"config_section":"modem1","params":{"at":"AT+CGMM","port":"/dev/ttyUSB2"}}' |
| 146 | +``` |
| 147 | + |
| 148 | +#### send_raw_pdu |
| 149 | +Send raw PDU SMS. |
| 150 | +```bash |
| 151 | +ubus call qmodem send_raw_pdu '{"config_section":"modem1","cmd":"<PDU_STRING>"}' |
| 152 | +``` |
| 153 | + |
| 154 | +#### send_sms |
| 155 | +Send SMS message. |
| 156 | +```bash |
| 157 | +ubus call qmodem send_sms '{ |
| 158 | + "config_section":"modem1", |
| 159 | + "params":{ |
| 160 | + "phone_number":"+1234567890", |
| 161 | + "message_content":"Hello World" |
| 162 | + } |
| 163 | +}' |
| 164 | +``` |
| 165 | + |
| 166 | +#### set_imei |
| 167 | +Set modem IMEI (if supported). |
| 168 | +```bash |
| 169 | +ubus call qmodem set_imei '{"config_section":"modem1","imei":"123456789012345"}' |
| 170 | +``` |
| 171 | + |
| 172 | +#### set_lockband |
| 173 | +Set band lock configuration. |
| 174 | +```bash |
| 175 | +ubus call qmodem set_lockband '{ |
| 176 | + "config_section":"modem1", |
| 177 | + "params":{ |
| 178 | + "bands":"1,3,7,20" |
| 179 | + } |
| 180 | +}' |
| 181 | +``` |
| 182 | + |
| 183 | +#### set_mode |
| 184 | +Set network mode. |
| 185 | +```bash |
| 186 | +ubus call qmodem set_mode '{"config_section":"modem1","mode":"auto"}' |
| 187 | +``` |
| 188 | + |
| 189 | +#### set_neighborcell |
| 190 | +Configure neighboring cell settings. |
| 191 | +```bash |
| 192 | +ubus call qmodem set_neighborcell '{ |
| 193 | + "config_section":"modem1", |
| 194 | + "params":{ |
| 195 | + "enable":"1" |
| 196 | + } |
| 197 | +}' |
| 198 | +``` |
| 199 | + |
| 200 | +#### set_network_prefer |
| 201 | +Set network preference. |
| 202 | +```bash |
| 203 | +ubus call qmodem set_network_prefer '{ |
| 204 | + "config_section":"modem1", |
| 205 | + "params":{ |
| 206 | + "prefer":"lte" |
| 207 | + } |
| 208 | +}' |
| 209 | +``` |
| 210 | + |
| 211 | +#### set_sms_storage |
| 212 | +Set SMS storage location. |
| 213 | +```bash |
| 214 | +ubus call qmodem set_sms_storage '{"config_section":"modem1","storage":"SM"}' |
| 215 | +``` |
| 216 | + |
| 217 | +## HTTP Access via RPCD |
| 218 | + |
| 219 | +You can also access these methods via HTTP through rpcd: |
| 220 | + |
| 221 | +```bash |
| 222 | +# Example: Get modem info |
| 223 | +curl -X POST http://192.168.1.1/ubus \ |
| 224 | + -d '{ |
| 225 | + "jsonrpc": "2.0", |
| 226 | + "id": 1, |
| 227 | + "method": "call", |
| 228 | + "params": [ |
| 229 | + "<session_id>", |
| 230 | + "qmodem", |
| 231 | + "info", |
| 232 | + {"config_section":"modem1"} |
| 233 | + ] |
| 234 | + }' |
| 235 | +``` |
| 236 | + |
| 237 | +## Configuration |
| 238 | + |
| 239 | +### UCI Configuration Section |
| 240 | +The `config_section` parameter refers to a UCI configuration section in `/etc/config/qmodem`. For example: |
| 241 | + |
| 242 | +``` |
| 243 | +config modem 'modem1' |
| 244 | + option manufacturer 'Quectel' |
| 245 | + option platform 'RG500Q' |
| 246 | + option at_port '/dev/ttyUSB2' |
| 247 | + option path '1-1.4' |
| 248 | + ... |
| 249 | +``` |
| 250 | + |
| 251 | +### ACL Permissions |
| 252 | +Edit `/usr/share/rpcd/acl.d/qmodem.json` to configure access control for different user groups. |
| 253 | + |
| 254 | +## Caching |
| 255 | + |
| 256 | +Many information methods use caching (default 10 seconds) to avoid excessive modem queries. Cache files are stored in `/tmp/cache_*`. |
| 257 | + |
| 258 | +## Troubleshooting |
| 259 | + |
| 260 | +1. Check if rpcd is running: |
| 261 | +```bash |
| 262 | +ps | grep rpcd |
| 263 | +``` |
| 264 | + |
| 265 | +2. List available ubus objects: |
| 266 | +```bash |
| 267 | +ubus list qmodem |
| 268 | +``` |
| 269 | + |
| 270 | +3. Check rpcd logs: |
| 271 | +```bash |
| 272 | +logread | grep rpcd |
| 273 | +``` |
| 274 | + |
| 275 | +4. Verify script permissions: |
| 276 | +```bash |
| 277 | +ls -l /usr/libexec/rpcd/qmodem |
| 278 | +``` |
| 279 | +The script should be executable. |
| 280 | + |
| 281 | +5. Test the script directly: |
| 282 | +```bash |
| 283 | +echo '{"config_section":"modem1"}' | /usr/libexec/rpcd/qmodem call info |
| 284 | +``` |
| 285 | + |
| 286 | +## Migration from modem_ctrl.sh |
| 287 | + |
| 288 | +The rpcd interface replaces direct calls to `modem_ctrl.sh`: |
| 289 | + |
| 290 | +**Old way:** |
| 291 | +```bash |
| 292 | +/usr/share/qmodem/modem_ctrl.sh info modem1 |
| 293 | +``` |
| 294 | + |
| 295 | +**New way:** |
| 296 | +```bash |
| 297 | +ubus call qmodem info '{"config_section":"modem1"}' |
| 298 | +``` |
| 299 | + |
| 300 | +## Dependencies |
| 301 | + |
| 302 | +- libubox/jshn.sh - JSON handling |
| 303 | +- uci - Configuration management |
| 304 | +- jq - JSON processing |
| 305 | +- tom_modem - Modem communication tool |
| 306 | +- Vendor-specific scripts in `/usr/share/qmodem/vendor/` |
| 307 | + |
| 308 | +## Notes |
| 309 | + |
| 310 | +- All methods require a valid `config_section` parameter |
| 311 | +- The config_section must exist in `/etc/config/qmodem` |
| 312 | +- Vendor-specific functionality is loaded from `/usr/share/qmodem/vendor/` based on the modem manufacturer |
| 313 | +- AT command language (Chinese/English) is automatically selected based on system language settings |
0 commit comments