### Install QModem IPK Packages Source: https://github.com/fujr/qmodem/blob/main/docs/user-guide.md Install QModem packages using opkg. Use '--force-depends' with caution for kernel version mismatches. ```bash # Example installation opkg install luci-app-qmodem.ipk # Example of a forced installation (use with caution) opkg install luci-app-qmodem.ipk --force-depends ``` -------------------------------- ### Starting Quectel Connection Manager Source: https://github.com/fujr/qmodem/blob/main/driver/quectel_MHI/src/log/QMI_OVER_PCIE.txt This command starts the Quectel Connection Manager application in the background. It is used to manage the modem's connection and QMI services. ```bash ./quectel-CM & ``` -------------------------------- ### Start Quectel QMI Proxy Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/qmi_wwan_q_qmap=4.txt Starts the Quectel QMI proxy service in the background. This service facilitates communication between the host system and the modem's QMI interface. ```bash root@ZhuoTK:~# quectel-qmi-proxy & ``` -------------------------------- ### OpenWrt Network Configuration Example Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/gobinet_qmap=4_bridge.txt Provides an example of how to configure a network interface for DHCP in OpenWrt. This snippet suggests modifying the '/etc/config/network' file to set up a WAN interface named 'usb0.2'. ```text config interface wan option ifname usb0.2 option proto dhcp ``` -------------------------------- ### Start Quectel CM Service Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/pcie_mhi_mbim.txt Initiates the Quectel Connection Manager service with a specified APN ('cment'). This command starts the process of establishing a network connection. ```bash root@OpenWrt:/# quectel-CM -s cment & ``` -------------------------------- ### Setup Data Call with Quectel-CM Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/qmi_wwan_qmap=4.txt Initiates a data call using quectel-CM, specifying the QMI proxy and network service. Use '-p qmi-proxy' if using libqmi's proxy. ```bash # quectel-CM -p quectel-qmi-proxy -n 4 -s cmnet4 # quectel-CM -p quectel-qmi-proxy -n 1 -s cmnet ``` -------------------------------- ### Get Available Reboot Methods Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Query the modem for its supported reboot capabilities (e.g., hard, soft). ```bash ubus call qmodem get_reboot_caps '{"config_section":"modem1"}' ``` -------------------------------- ### Start Quectel CM with Network Arguments Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/usage_of_argument/m.txt Initiates the Quectel CM service in the background with specified network parameters (-n, -m, -s). This is typically used for establishing a cellular data connection. ```bash quectel-CM -n 1 -m 4 -s cmnet & ``` -------------------------------- ### Start udhcpc client for rmnet_mhi0.1 Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/pcie_mhi_qmap=1.txt This command manually starts the udhcpc client to obtain an IP address for the 'rmnet_mhi0.1' interface. It uses specific options for foreground execution, no waiting for lease, and a limited number of retries. ```bash busybox udhcpc -f -n -q -t 5 -i rmnet_mhi0.1 ``` -------------------------------- ### Main Executable Configuration Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/CMakeLists.txt Defines the main 'quectel-CM' executable, including its source files and conditional QRTR support. Links against the pthread library and installs the executable to the 'bin' directory. ```cmake cmake_minimum_required(VERSION 2.4) project(quectel-CM) add_definitions(-Wall -Wextra -Werror -O1) option(USE_QRTR "Enable QRTR" OFF) set( QL_CM_SRC QmiWwanCM.c GobiNetCM.c main.c MPQMUX.c QMIThread.c util.c qmap_bridge_mode.c mbim-cm.c device.c atc.c atchannel.c at_tok.c udhcpc.c ) if(USE_QRTR) add_definitions(-DCONFIG_QRTR) set( QRTR_SRC qrtr.c rmnetctl.c) endif() add_executable(quectel-CM ${QL_CM_SRC} ${QRTR_SRC}) target_link_libraries(quectel-CM PUBLIC pthread) install (TARGETS quectel-CM DESTINATION bin) ``` -------------------------------- ### Get SIM Card Information Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Fetch information related to the SIM card installed in the modem. ```bash ubus call qmodem sim_info '{"config_section":"modem1"}' ``` -------------------------------- ### QMI Proxy Executable Configuration Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/CMakeLists.txt Defines the 'quectel-qmi-proxy' executable, linking against the pthread library and installing it to the 'bin' directory. ```cmake add_executable(quectel-qmi-proxy quectel-qmi-proxy.c) target_link_libraries(quectel-qmi-proxy PUBLIC pthread) install (TARGETS quectel-qmi-proxy DESTINATION bin) ``` -------------------------------- ### Start Quectel CM for 4gnet Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/gobinet_qmap=4_bridge.txt Initiates the Quectel Connection Manager (quectel-CM) to establish a data connection using the '4gnet' profile. The '-n 2' flag likely specifies the modem instance or profile number, and '&' runs the process in the background. ```bash quectel-CM -n 2 -s 4gnet & ``` -------------------------------- ### Start Quectel Connection Manager Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/gobinet_qmap=1.txt Launches the Quectel Connection Manager (quectel-CM) in the background for the 'cmnet' connection. This command is typically used after the GobiNet module is loaded. ```bash quectel-CM -s cmnet & ``` -------------------------------- ### Get AT Command Configuration and Ports Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Retrieve the AT command configuration and a list of available serial ports for the modem. ```bash ubus call qmodem get_at_cfg '{"config_section":"modem1"}' ``` -------------------------------- ### QRTR Proxy Executable Configuration Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/CMakeLists.txt Defines the 'quectel-qrtr-proxy' executable, linking against the pthread library and installing it to the 'bin' directory. ```cmake add_executable(quectel-qrtr-proxy quectel-qrtr-proxy.c) target_link_libraries(quectel-qrtr-proxy PUBLIC pthread) install (TARGETS quectel-qrtr-proxy DESTINATION bin) ``` -------------------------------- ### QFirehose Executable Build Source: https://github.com/fujr/qmodem/blob/main/application/qfirehose/src/CMakeLists.txt Defines the source files for the QFirehose executable and links it against the pthread library. Specifies the installation destination for the executable. ```cmake set( QFirehose_SRCS firehose_protocol.c qfirehose.c sahara.c usb_linux.c stream_download_protocol.c md5.c usb2tcp.c ) add_executable(QFirehose ${QFirehose_SRCS}) target_link_libraries(QFirehose PUBLIC pthread) install (TARGETS QFirehose DESTINATION bin) ``` -------------------------------- ### Start Quectel CM for cmnet Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/gobinet_qmap=4_bridge.txt Initiates the Quectel Connection Manager (quectel-CM) to establish a data connection using the 'cmnet' profile. The '-n 1' flag likely specifies the modem instance or profile number, and '&' runs the process in the background. ```bash quectel-CM -n 1 -s cmnet -b & ``` -------------------------------- ### Quectel QMI Proxy for QMAP Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/ReleaseNote.txt Command to run the quectel-qmi-proxy before starting quectel-CM when QMI_WWAN's QMAP IP Mux function is enabled. Ensure to replace 'X' with the correct device number. ```bash quectel-qmi-proxy -d /dev/cdc-wdmX ``` -------------------------------- ### MBIM Proxy Executable Configuration Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/CMakeLists.txt Defines the 'quectel-mbim-proxy' executable, linking against the pthread library and installing it to the 'bin' directory. ```cmake add_executable(quectel-mbim-proxy quectel-mbim-proxy.c) target_link_libraries(quectel-mbim-proxy PUBLIC pthread) install (TARGETS quectel-mbim-proxy DESTINATION bin) ``` -------------------------------- ### AT Debug Class Initialization Source: https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem/luasrc/view/qmodem/modem_debug.htm Initializes the AtDebug class, inheriting from ModemConfig. Sets up actions for getting and setting AT configurations and initializes UI elements. ```javascript class AtDebug extends ModemConfig { constructor(cfg_id){ super(cfg_id,"<%:AT Debug%> "); this.config_name = "at_cfg"; this.get_action = "get_at_cfg"; this.set_action = "send_at"; this.at_port=null; this.last_choice_cmd = null; this.render(); } update(){ this.get_config(); } } ``` -------------------------------- ### Get Copyright Information Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Retrieve copyright details associated with the modem firmware or software. ```bash ubus call qmodem get_copyright '{"config_section":"modem1"}' ``` -------------------------------- ### Access QModem Methods via HTTP RPCD Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Example of how to call the 'info' method for a modem using cURL to interact with the rpcd service over HTTP. ```bash # Example: Get modem info curl -X POST http://192.168.1.1/ubus \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "", "qmodem", "info", {"config_section":"modem1"} ] }' ``` -------------------------------- ### DHCP Client Execution Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/gobinet_qmap=4_bridge.txt Manually starts a busybox DHCP client for the 'usb0.2' interface. This is an alternative to relying on OpenWrt's network configuration for obtaining an IP address. ```bash busybox udhcpc -f -n -q -t 5 -i usb0.2 ``` -------------------------------- ### DialMode Class Constructor and Initialization Source: https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem/luasrc/view/qmodem/modem_debug.htm Constructor for the DialMode class, setting up actions for getting and setting the modem's dial mode, and initializing the configuration table. ```javascript class DialMode extends ModemConfig { constructor(cfg_id){ super(cfg_id,"<%:Dial Mode%>"); this.config_name = ""; this.get_action = "get_mode"; this.set_action = "set_mode"; this.avalibale_mode = []; this.selected_mode = null; this.init_table(); this.td_map = { "current_mode": null, "radio_div": null, } this.cb_get = (data) => { this.render(); } this.cb_set = (data) => { this.get_config(); } } ``` -------------------------------- ### ATC Proxy Executable Configuration Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/CMakeLists.txt Defines the 'quectel-atc-proxy' executable, including its source files, linking against the pthread library, and installing it to the 'bin' directory. ```cmake add_executable(quectel-atc-proxy quectel-atc-proxy.c atchannel.c at_tok.c util.c) target_link_libraries(quectel-atc-proxy PUBLIC pthread) install (TARGETS quectel-atc-proxy DESTINATION bin) ``` -------------------------------- ### RAT Preference Class Constructor Source: https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem/luasrc/view/qmodem/modem_debug.htm Initializes the RAT Prefer configuration class. Sets up actions for getting and setting network preferences and prepares the table for rendering checkboxes. ```javascript constructor(cfg_id){ super(cfg_id, "<%:Rat Prefer%>"); this.config_name = "network_prefer"; this.get_action = "get_network_prefer"; this.set_action = "set_network_prefer"; this.selected_rat = []; this.available_rat = []; this.init_table(); this.create_submit_btn(); } ``` -------------------------------- ### Manual DHCP Client on USB0 Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/gobinet_qmap=1.txt Manually starts a busybox DHCP client on the 'usb0' interface. This is an alternative to automatic network configuration and is often used in embedded systems. ```bash busybox udhcpc -f -n -q -t 5 -i usb0 ``` -------------------------------- ### Quectel CM Initialization Log Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/usage_of_argument/m.txt This log output details the initialization process of Quectel CM, including device detection, driver information, QMI mode status, client initialization, and network registration status. ```log [04-13_05:12:07:455] Quectel_QConnectManager_Linux_V1.6.0.25 [04-13_05:12:07:458] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x003 [04-13_05:12:07:459] Auto find qmichannel = /dev/qcqmi0 [04-13_05:12:07:459] Auto find usbnet_adapter = usb0 [04-13_05:12:07:467] netcard driver = GobiNet, driver version = V1.6.2.13 [04-13_05:12:07:467] qmap_mode = 4, qmap_version = 5, qmap_size = 4096, muxid = 0x84, qmap_netcard = usb0.4 [04-13_05:12:07:467] Modem works in QMI mode [04-13_05:12:07:495] Get clientWDS = 7 [04-13_05:12:07:529] Get clientDMS = 8 [04-13_05:12:07:561] Get clientNAS = 9 [04-13_05:12:07:591] Get clientUIM = 10 [04-13_05:12:07:623] requestBaseBandVersion EC25EFAR06A11M4G [04-13_05:12:07:752] requestGetSIMStatus SIMStatus: SIM_READY [04-13_05:12:07:752] requestSetProfile[1] cmnet///0 [04-13_05:12:07:817] requestGetProfile[1] cmnet///0 [04-13_05:12:07:849] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE [04-13_05:12:07:881] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED [04-13_05:12:07:881] ifconfig usb0 down [04-13_05:12:07:892] ifconfig usb0.4 0.0.0.0 [04-13_05:12:07:903] ifconfig usb0.4 down [04-13_05:12:07:944] requestSetupDataCall WdsConnectionIPv4Handle: 0x87265c40 [ 52.020000] net usb0: link_state 0x0 -> 0x8 [04-13_05:12:08:077] ifconfig usb0 up [04-13_05:12:08:096] ifconfig usb0.4 up ``` -------------------------------- ### OpenWrt Network Configuration for USB0 Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/gobinet_qmap=1.txt Example configuration for an OpenWrt network interface named 'wan' using the 'usb0' device. This setup uses DHCP to obtain an IP address. ```uci config interface wan option ifname usb0 option proto dhcp ``` -------------------------------- ### Build OpenWRT Firmware with QModem Source: https://github.com/fujr/qmodem/blob/main/docs/user-guide.md Build the OpenWRT firmware after selecting QModem packages in 'make menuconfig'. ```bash make -j$(nproc) ``` -------------------------------- ### Run QMI Proxy Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/qmi_wwan_qmap=4.txt Launches the QMI proxy program. This can be either the Quectel-specific version or the one provided by libqmi. ```bash # quectel-CM/quectel-qmi-proxy -d /dev/cdc-wdm0 or libqmi's qmi-proxy, if use libqmi's qmi-proxy, you can use qmicli to setup data call. # /usr/libexec/qmi-proxy --verbose --no-exit ``` -------------------------------- ### Start udhcpc for Network Interface Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/usage_of_argument/m.txt Manually starts the udhcpc client to obtain an IP address for the 'usb0.4' interface. This is often used when automatic DHCP configuration is not working or needs to be triggered. ```bash busybox udhcpc -f -n -q -t 5 -i usb0.4 ``` -------------------------------- ### info Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Get general information about the modem. ```APIDOC ## POST /ubus ### Description Get modem information. ### Method POST ### Endpoint /ubus ### Parameters #### Request Body - **jsonrpc** (string) - Required - "2.0" - **id** (number) - Required - Request ID - **method** (string) - Required - "call" - **params** (array) - Required - Array containing session ID, service name, method name, and method arguments. - **session_id** (string) - Required - The session ID for the ubus call. - **service** (string) - Required - "qmodem" - **method_name** (string) - Required - "info" - **method_args** (object) - Required - Arguments for the info method. - **config_section** (string) - Required - The UCI configuration section for the modem. ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "", "qmodem", "info", { "config_section": "modem1" } ] } ``` ### Response #### Success Response (200) - **result** (array) - The result of the ubus call, containing modem information. - **id** (number) - The request ID. #### Response Example ```json { "result": [ 0, { "manufacturer": "Quectel", "platform": "RG500Q", "at_port": "/dev/ttyUSB2", "path": "1-1.4" } ], "id": 1 } ``` ``` -------------------------------- ### Load GobiNet Driver with qmap_mode Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/gobinet_qmap=4_bridge.txt Loads the GobiNet kernel module with the qmap_mode parameter set to 4. This is typically the first step in enabling the Quectel modem's network functionality. ```bash insmod GobiNet.ko qmap_mode=4 ``` -------------------------------- ### Get SMS Messages Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Retrieve stored SMS messages from the modem. ```bash ubus call qmodem get_sms '{"config_section":"modem1"}' ``` -------------------------------- ### Get Disabled Features Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md List features that are currently disabled for the specified modem. ```bash ubus call qmodem get_disabled_features '{"config_section":"modem1"}' ``` -------------------------------- ### Quectel CM Help Message Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/ReleaseNote.txt Displays the usage instructions and available options for the quectel-CM command-line tool. Use this to understand how to configure data connections, logging, and network protocols. ```bash root@ubuntu:# ./quectel-CM -h [02-26_10:39:21:353] Usage: ./quectel-CM [options] [02-26_10:39:21:353] -s [apn [user password auth]] Set apn/user/password/auth get from your network provider [02-26_10:39:21:353] -p pincode Verify sim card pin if sim card is locked [02-26_10:39:21:353] -f logfilename Save log message of this program to file [02-26_10:39:21:353] -i interface Specify network interface(default auto-detect) [02-26_10:39:21:353] -4 IPv4 protocol [02-26_10:39:21:353] -6 IPv6 protocol [02-26_10:39:21:353] -m muxID Specify muxid when set multi-pdn data connection. [02-26_10:39:21:353] -n channelID Specify channelID when set multi-pdn data connection(default 1). [02-26_10:39:21:353] [Examples] [02-26_10:39:21:353] Example 1: ./quectel-CM [02-26_10:39:21:353] Example 2: ./quectel-CM -s 3gnet [02-26_10:39:21:353] Example 3: ./quectel-CM -s 3gnet carl 1234 0 -p 1234 -f gobinet_log.txt root@ubuntu:# ``` -------------------------------- ### Get Network Preference Settings Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Retrieve the modem's preferred network settings. ```bash ubus call qmodem get_network_prefer '{"config_section":"modem1"}' ``` -------------------------------- ### Show Module Configuration Source: https://github.com/fujr/qmodem/blob/main/docs/user-guide.md Displays the current configuration of the qmodem module. This is useful for verifying settings. ```bash uci show qmodem # Show module configuration ``` -------------------------------- ### Get Network Connection Information Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Retrieve details about the current network connection of the modem. ```bash ubus call qmodem network_info '{"config_section":"modem1"}' ``` -------------------------------- ### Running Quectel-CM with IPv4 and IPv6 Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/usage_of_argument/6.txt This command initiates the Quectel connection manager with settings for the 'cmnet' APN, enabling both IPv4 and IPv6 connectivity. Observe the log output for detailed connection status and modem information. ```bash root@OpenWrt:~# quectel-CM -s cmnet -4 -6 ``` -------------------------------- ### Get Comprehensive Modem Information Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Obtain a complete set of information for a specified modem. ```bash ubus call qmodem info '{"config_section":"modem1"}' ``` -------------------------------- ### Get Band Lock Configuration Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Retrieve the current band lock settings applied to the modem. ```bash ubus call qmodem get_lockband '{"config_section":"modem1"}' ``` -------------------------------- ### Get Cellular Network Information Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Fetch detailed cellular network status for a given modem. ```bash ubus call qmodem cell_info '{"config_section":"modem1"}' ``` -------------------------------- ### Quectel CM Protocol Options Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/ReleaseNote.txt Demonstrates how to specify IP protocol versions for data calls. Use '-4' for IPv4 only, '-6' for IPv6 only, or '-4 -6' for both IPv4 and IPv6. ```bash ./quectel-CM -4(or no argument) only IPV4 -6 only IPV6 -4 -6 IPV4 && IPV6 ``` -------------------------------- ### List available ubus objects Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Display all available ubus objects, useful for confirming the 'qmodem' object is registered. ```bash ubus list qmodem ``` -------------------------------- ### Get Basic Modem Information Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Retrieve fundamental information about a specific modem configuration section. ```bash ubus call qmodem base_info '{"config_section":"modem1"}' ``` -------------------------------- ### Get Neighboring Cell Information Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Fetch information about nearby cellular base stations detected by the modem. ```bash ubus call qmodem get_neighborcell '{"config_section":"modem1"}' ``` -------------------------------- ### Network Interface Configuration Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/qmi_wwan_qmap=4.txt Commands to bring down the wwan0 interface, enable raw IP mode, and add QMAP multiplexing interfaces. ```bash # ifconfig wwan0 down # echo Y > /sys/class/net/wwan0/qmi/raw_ip # echo 1 > /sys/class/net/wwan0/qmi/add_mux # echo 2 > /sys/class/net/wwan0/qmi/add_mux # echo 3 > /sys/class/net/wwan0/qmi/add_mux # echo 4 > /sys/class/net/wwan0/qmi/add_mux ``` -------------------------------- ### Get Modem IMEI Number Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Fetch the International Mobile Equipment Identity (IMEI) number of the modem. ```bash ubus call qmodem get_imei '{"config_section":"modem1"}' ``` -------------------------------- ### AT Debug Callback for Configuration Update Source: https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem/luasrc/view/qmodem/modem_debug.htm Handles the callback for retrieving configuration, clearing existing port and command options, and populating them from the received config data. ```javascript cb_get(){ //clear ports while (this.at_port_selector.firstChild) { this.at_port_selector.removeChild(this.at_port_selector.firstChild); } //clear cmds while (this.cmd_prompt_selector.firstChild) { this.cmd_prompt_selector.removeChild(this.cmd_prompt_selector.firstChild); } //empty option var empty_option1=document.createElement("option"); empty_option1.value = ""; empty_option1.innerHTML = "<%:-- custom ---%> "; var empty_option2=document.createElement("option"); empty_option2.value = ""; empty_option2.innerHTML = "<%:-- custom ---%> "; this.cmd_prompt_selector.appendChild(empty_option1); this.at_port_selector.appendChild(empty_option2); var ports=this.config.ports; var other_ttys=this.config.other_ttys; var valid_ports=this.config.valid_ports; var using_port=this.config.using_port; var cmds = this.config.cmds; //append empty option to at_port_selector for (let port of other_ttys) { let select; let displayport = port; if (ports.includes(port) == false) { displayport += "<%:(Not belong to this modem)%> "; } else{ if (valid_ports.includes(port) == false) { displayport += "<%:(invalid)%> "; } else{ displayport += "<%:(valid)%> "; } if (port == using_port) { displayport += "<%:(using)%> "; select = true; } } var option = document.createElement('option'); option.value = port; option.innerHTML = displayport; if (select) { option.selected = true; this.at_port = port; } this.at_port_selector.appendChild(option); } for (let cmd of cmds) { var option = document.createElement('option'); option.value = cmd.value; option.innerHTML = cmd.name; this.cmd_prompt_selector.appendChild(option); } this.cmd_prompt_selector.dispatchEvent(new Event('change')); this.at_port_selecto ``` -------------------------------- ### Send AT Command (Signal Quality) Source: https://github.com/fujr/qmodem/blob/main/docs/tom-modem-manual.md Use this snippet to check the modem's signal quality by sending the AT+CSQ command. Ensure the correct TTY device path is provided. ```bash tom_modem /dev/ttyUSB2 -c "AT+CSQ" ``` ```bash tom_modem /dev/ttyUSB2 "AT+CSQ" ``` -------------------------------- ### Get Current Network Mode Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Determine the current operating network mode of the modem (e.g., LTE, 5G). ```bash ubus call qmodem get_mode '{"config_section":"modem1"}' ``` -------------------------------- ### Get DNS Server Information Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Retrieve the configured DNS server addresses for the modem's network connection. ```bash ubus call qmodem get_dns '{"config_section":"modem1"}' ``` -------------------------------- ### Lockband Class Initialization Source: https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem/luasrc/view/qmodem/modem_debug.htm Initializes the Lockband class, setting up configuration, actions, and event callbacks for managing modem band locking. ```javascript class Lockband extends ModemConfig{ constructor(cfg_id){ super(cfg_id, "<%:Lock Band%> "); this.config_name = "lockband"; this.get_action = "get_lockband"; this.set_action = "set_lockband"; this.lockband_config = {}; this.checkboxes = {}; this.available_bandid = {}; this.band_class_map = {}; this.init_table(); this.cb_get = (data) => { this.render(); } this.cb_set = (data) => { this.get_config(); } } set lock(config){ var band_class = config.band_class; var band_id = config.band_id; if (!this.lockband_config[band_class].includes(band_id)){ this.lockband_config[band_class].push(band_id) } this.checkboxes[band_class][band_id].checked = true; } set unlock(config){ var band_class = config.band_class; var band_id = config.band_id; this.lockband_config[band_class] = this.lockband_config[band_class].filter(x => x != band_id); //set checkbox this.checkboxes[band_class][band_id].checked = false; } createCheckbox(band_class,band_name,band_id){ let checkbox = document.createElement('input'); checkbox.classList = ["cbi-input-checkbox"]; checkbox.type = "checkbox"; checkbox.value = band_id; checkbox.setAttribute("display-band",band_name); checkbox.addEventListener("change",() => { if (checkbox.checked){ this.lock = { "band_class": band_class, "band_id": band_id }; } else{ this.unlock = { "band_class": band_class, "band_id": band_id }; } }); this.checkboxes[band_class][band_id] = checkbox; if (this.lockband_config[band_class].includes(band_id)) { this.lock = { "band_class": band_class, "band_id": band_id }; } } createcheckboxes(band_class){ var band = this.config[band_class]; var available_band = band.available_band; var lock_band = band.lock_band; this.lockband_config[band_class] = lock_band; if ( available_band.length == 0) { return; } if (this.checkboxes[band_class] == undefined) { this.checkboxes[band_class] = {}; } if (this.available_bandid[band_class] == undefined) { this.available_bandid[band_class] = [] } for (let band_cfg of available_band) { let band_name = band_cfg.band_name; let band_id = band_cfg.band_id; if (this.available_bandid[band_class].includes(band_id) == false) { this.available_bandid[band_class].push(band_id); } this.createCheckbox(band_class,band_name,band_id); } } submit(band_class) { var sorted = this.lockband_config[band_class].sort(); var config = ''; for (let band_id of sorted) { config += band_id + ","; } var lockband_cfg = { "band_class": band_class, "lock_band": config.slice(0,-1) } var cfg_string = JSON.stringify(lockband_cfg); this.set_config(cfg_string); } select_all(band_class){ //if all selected, then unselect all let lockall = this.lockband_config[band_class].length != this.available_bandid[band_class].length; for (let band_id of this.available_bandid[band_class]) { if (lockall) { this.lock = { "band_class": band_class, "band_id": band_id }; } else{ this.unlock = ``` -------------------------------- ### Get Traffic Reset Schedule Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Read the configuration for the automatic traffic reset schedule. If none is set, a default structure is returned. ```bash ubus call qmodem get_traffic_reset_schedule '{"config_section":"modem1"}' ``` -------------------------------- ### Configure Modem Debug Settings Source: https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem/luasrc/view/qmodem/modem_debug.htm Sets up input fields and buttons for configuring modem parameters like RAT, PCI, ARFCN, Band, and SCS. Includes functionality to submit settings and scan for neighbor cells. ```html T%>"); d = this.createTD(); d.appendChild(rat_input); rat_tr.appendChild(td); rat_tr.appendChild(td1); pci_tr = this.createTR(); d = this.createTD("<%:PCI%>\n"); pci_input = this.createInput("pci", ""); d1 = this.createTD(); d1.appendChild(pci_input); pci_tr.appendChild(td); pci_tr.appendChild(td1); arfcn_tr = this.createTR(); d = this.createTD("<%:ARFCN%>\n"); arfcn_input = this.createInput("arfcn", ""); d1 = this.createTD(); d1.appendChild(arfcn_input); arfcn_tr.appendChild(td); arfcn_tr.appendChild(td1); band_tr = this.createTR(); d = this.createTD("<%:Band%>\n"); band_input = this.createInput("band", ""); d1 = this.createTD(); d1.appendChild(band_input); band_tr.appendChild(td); band_tr.appendChild(td1); scs_tr = this.createTR(); d = this.createTD("<%:SCS%>\n"); scs_input = this.createDroplist({0:"15KHZ",1:"30KHZ"}); d1 = this.createTD(); d1.appendChild(scs_input); scs_tr.appendChild(td); scs_tr.appendChild(td1); status_th = this.createTH("<%:Status%>\n"); status_trh = this.createTRHeader(); status_trh.appendChild(status_th); this.status_table.appendChild(status_trh); this.pci_input = pci_input; this.arfcn_input = arfcn_input; this.band_input = band_input; this.scs_input = scs_input; this.rat_input = rat_input; this.band_tr = band_tr; this.scs_tr = scs_tr; this.band_tr.style.display = "none"; this.scs_tr.style.display = "none"; this.rat_input.addEventListener('change',()=>{ this.nr_options(); }); var submit_btn = this.createBTN("<%:Submit%>",() => { var config = { "rat": this.rat_input.selectedIndex, "pci": this.pci_input.value, "arfcn": this.arfcn_input.value, "band": this.band_input.value, "scs": this.scs_input.selectedIndex } this.set_config(JSON.stringify(config)); }); //add scan button var scan_btn = this.createBTN("<%:Scan%>",() => { this.scan_neighborcell(); }); this.setting_table.appendChild(header); this.setting_table.appendChild(rat_tr); this.setting_table.appendChild(pci_tr); this.setting_table.appendChild(arfcn_tr); this.setting_table.appendChild(band_tr); this.setting_table.appendChild(scs_tr); this.setting_table.appendChild(scan_btn); this.setting_table.appendChild(submit_btn); } ``` -------------------------------- ### Configure OpenWrt Network Interface Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/pcie_mhi_qmap=4.txt Example configuration for an OpenWrt network interface using DHCP on rmnet_mhi0.2. This is typically done by modifying /etc/config/network. ```bash config interface wan option ifname rmnet_mhi0.2 option proto dhcp ``` -------------------------------- ### Initialize SMS Storage Table Source: https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem-sms/luasrc/view/modem_sms/modem_sms.htm Sets up the data and references for the SMS storage table, including options for different storage types (ME, SM, ETC). ```javascript this.sms_storage_table.data = data; this.reading_storage = reading_storage; this.writing_storage = writing_storage; this.etc_storage = etc_storage; this.opt_mt1 = storages[0].querySelector('option[value="ME"]'); this.opt_sm1 = storages[0].querySelector('option[value="SM"]'); this.opt_mt2 = storages[1].querySelector('option[value="ME"]'); this.opt_sm2 = storages[1].querySelector('option[value="SM"]'); this.opt_mt3 = storages[2].querySelector('option[value="ME"]'); this.opt_sm3 = storages[2].querySelector('option[value="SM"]') ``` -------------------------------- ### NeighborCell Class Constructor Source: https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem/luasrc/view/qmodem/modem_debug.htm Constructor for the NeighborCell class, setting up actions for getting and setting neighbor cell information and initializing the relevant tables. ```javascript class NeighborCell extends ModemConfig { constructor(cfg_id){ super(cfg_id,"<%:Neighbor Cell%>"); this.config_name = "neighborcell"; this.get_action = "get_neighborcell"; this.set_action = "set_neighborcell"; this.task = null; this.init_nc_table(); } ``` -------------------------------- ### QModem Project Structure Source: https://github.com/fujr/qmodem/blob/main/docs/developer-guide.md Overview of the directory structure for the luci-app-qmodem LuCI application. ```plaintext luci-app-qmodem/ ├── Makefile # Build instructions for the package ├── htdocs/ │ └── luci-static/ # Static web assets (JS, CSS, images) │ └── resources/ │ └── qmodem/ │ ├── modem.js # Main JavaScript for frontend logic │ └── ... # Other JS files ├── luasrc/ │ ├── controller/ │ │ └── qmodem.lua # Main controller, handles API requests and page rendering │ ├── model/ │ │ └── cbi/ │ │ └── qmodem/ # CBI models for configuration pages │ │ ├── dial_config.lua │ │ ├── modem_cfg.lua │ │ └── ... │ └── view/ │ └── qmodem/ # HTML templates for the views │ ├── modem_status.htm │ └── ... └── root/ └── etc/ ├── config/ │ └── qmodem # Default configuration file └── uci-defaults/ └── luci-qmodem # Script to set up default configs ``` -------------------------------- ### Get Modem Traffic Statistics Source: https://github.com/fujr/qmodem/blob/main/docs/qmodem-rpcd-interface.md Retrieve traffic statistics for the modem. This method is primarily for Quectel modems; others may return unavailable. ```bash ubus call qmodem get_stats '{"config_section":"modem1"}' ``` -------------------------------- ### Manually Start DHCP Client Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/pcie_mhi_qmap=4.txt Manually initiating a DHCP client for a specific interface (rmnet_mhi0.2) with options for non-blocking, quiet operation, and a limited number of retries. ```bash busybox udhcpc -f -n -q -t 5 -i rmnet_mhi0.2 ``` -------------------------------- ### Send AT Command via HTTP Source: https://github.com/fujr/qmodem/blob/main/docs/rpcd-at-daemon-userguide.md Demonstrates how to send an AT command to the modem using the HTTP interface through rpcd. This method is useful for WebUI development and external service integration. ```APIDOC ## POST /ubus ### Description Sends an AT command to the modem via the HTTP interface exposed by rpcd. This allows for remote management and control of modem AT commands. ### Method POST ### Endpoint /ubus ### Parameters #### Request Body - **jsonrpc** (string) - Required - JSON-RPC protocol version. - **id** (integer) - Required - Request ID. - **method** (string) - Required - The RPC method to call, should be "call". - **params** (array) - Required - Parameters for the RPC call. - **0** (string) - Required - Authentication token (e.g., "00000000000000000000000000000000" for unauthenticated). - **1** (string) - Required - Service name, "at-daemon". - **2** (string) - Required - Method name, e.g., "sendat". - **3** (object) - Required - Arguments for the "sendat" method. - **at_port** (string) - Required - Serial port device path, e.g., "/dev/ttyUSB0". - **at_cmd** (string) - Required - AT command to send, e.g., "at+cgmm". ### Request Example ```json { "jsonrpc":"2.0", "id":1, "method":"call", "params":["00000000000000000000000000000000","at-daemon","sendat",{"at_port":"/dev/ttyUSB0","at_cmd":"at+cgmm"}] } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - JSON-RPC protocol version. - **id** (integer) - Request ID. - **result** (array) - The result of the RPC call. - **0** (integer) - Status code (0 for success). - **1** (object) - Result details. - **port** (string) - Serial port used. - **command** (string) - The AT command sent. - **is_raw** (integer) - Indicates if the command was raw. - **sendonly** (integer) - Indicates if only sending was performed. - **timeout** (integer) - Timeout in seconds. - **end_flag** (string) - The termination flag used. - **end_flags_used** (array) - List of termination flags. - **status** (string) - Operation status (e.g., "success"). - **response** (string) - The modem's response. - **response_length** (integer) - Length of the response. - **end_flag_matched** (string) - The termination flag that was matched. - **response_time_ms** (integer) - Time taken to receive the response in milliseconds. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": [ 0, { "port": "/dev/ttyUSB0", "command": "at+cgmm", "is_raw": 0, "sendonly": 0, "timeout": 5, "end_flag": "default", "end_flags_used": [ "OK", "ERROR", "+CMS ERROR:", "+CME ERROR:", "NO CARRIER" ], "status": "success", "response": "\r\nMH5000-82M\r\n\r\nOK\r\n", "response_length": 20, "end_flag_matched": "OK", "response_time_ms": 79 } ] } ``` ``` -------------------------------- ### Pinging an IPv6 Host Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/usage_of_argument/6.txt This command tests IPv6 connectivity by pinging 'www.qq.com'. The output shows the success of the ping request, including the sequence number, time-to-live, and round-trip time. ```bash root@OpenWrt:~# ping6 www.qq.com ``` -------------------------------- ### List PCIe Devices Source: https://github.com/fujr/qmodem/blob/main/docs/user-guide.md Lists all connected PCIe devices. Use this to verify if your PCIe modem is recognized. ```bash lspci # List PCIe devices ``` -------------------------------- ### Bring up rmnet_mhi0.1 Interface Source: https://github.com/fujr/qmodem/blob/main/driver/quectel_MHI/src/log/QMI_OVER_PCIE.txt This command brings the rmnet_mhi0.1 network interface up. ```shell ifconfig rmnet_mhi0.1 up ``` -------------------------------- ### Get Disabled Features for Quectel RM500U-CN Source: https://github.com/fujr/qmodem/blob/main/docs/developer-guide.md This function retrieves disabled features for the Quectel RM500U-CN modem. It specifically adds 'LockBand' to the disabled features list if the modem name matches. ```bash vendor_get_disabled_features() { if [ "$modem_name" = "rm500u-cn" ]; then json_add_string "" "LockBand" fi # You can combine conditions if [ "$platform" = "unisoc" ]; then json_add_string "" "NeighborCell" fi } ``` -------------------------------- ### ModemDialOverview Class Initialization Source: https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem/luasrc/view/qmodem/dial_overview.htm Initializes the ModemDialOverview class, setting up UI elements for modem status and logs. ```javascript class ModemDialOverview { constructor(){ this.modem_state_field=new LuciField(["cbi-section","cbi-section-modem-state"],"<%:Modem Status%>").field; this.modem_log_tab_data_field = document.createElement('div'); this.modem_log_tab_menu_field = document.createElement('ul'); this.modem_log_tab_menu_field.classList.add("tabs") this.modem_log_field=new LuciField(["cbi-section","cbi-section-modem-log"],"<%:Modem Log%>").field; this.modems_state = [] this.modems_logs = {}; this.modems_logs_menu = {}; this.activated_section = ""; this.modem_log_field.appendChild(this.modem_log_tab_menu_field); this.modem_log_field.appendChild(this.modem_log_tab ``` -------------------------------- ### Use External RMnet-NSS Driver Source: https://github.com/fujr/qmodem/blob/main/driver/quectel_MHI/src/ReleaseNote.txt Uses the rmnet_nss.c driver from 'qsdk/qca/src/data-kernel/drivers/rmnet-nss/' instead of the internal one. pcie_mhi.ko must load after rmnet_nss.ko. ```plaintext 3. use 'qsdk/qca/src/data-kernel/drivers/rmnet-nss/rmnet_nss.c' instead myself rmnet_nss.c and pcie_mhi.ko must load after then rmnet_nss.ko ``` -------------------------------- ### Configure and Bring Up Bridge Interface Source: https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/log/gobinet_qmap=4_bridge.txt Brings the 'br0' network bridge interface up. This command is typically run after configuring the bridge and its member interfaces. ```bash ifconfig br0 up ```