123 lines
2.5 KiB
Markdown
123 lines
2.5 KiB
Markdown
# MQTT Data Upload Configuration via AT Commands
|
|
|
|
## Overview
|
|
|
|
Configure device data upload functionality using `AT+UPLOADDATA_PARM` and `AT+UPLOADDATA_TYPE` commands. Configuration is saved to Flash and persists across power cycles.
|
|
|
|
---
|
|
|
|
## Configuration Steps
|
|
|
|
### Step 1: Set Server Address and Upload Frequency
|
|
|
|
**Command:** `AT+UPLOADDATA_PARM=SET`
|
|
|
|
**Format:**
|
|
```
|
|
AT+UPLOADDATA_PARM=SET,<freq>,<ip>,<port>\r\n
|
|
```
|
|
|
|
**Parameters:**
|
|
|
|
| Parameter | Description | Values |
|
|
|-----------|-------------|--------|
|
|
| freq | Upload frequency | 0=OFF, 1=1s, 2=2s, 5=5s, 10=10s, 255=Follow GGA rate |
|
|
| ip | Server address | IP or domain name, max 99 bytes |
|
|
| port | Server port | 1~65535 |
|
|
|
|
**Example:**
|
|
```
|
|
AT+UPLOADDATA_PARM=SET,1,mqtt.example.com,1883
|
|
```
|
|
|
|
**Response:**
|
|
```
|
|
OK
|
|
```
|
|
|
|
---
|
|
|
|
### Step 2: Set Protocol Type to MQTT and Configure Authentication
|
|
|
|
**Command:** `AT+UPLOADDATA_TYPE=SET`
|
|
|
|
**Format:**
|
|
```
|
|
AT+UPLOADDATA_TYPE=SET,2,USERNAME,<user>,PASSWORD,<password>,CLIENTID,<clientid>,TOPIC,<topic>\r\n
|
|
```
|
|
|
|
**Parameters:**
|
|
|
|
| Parameter | Description | Max Length |
|
|
|-----------|-------------|------------|
|
|
| type | Protocol type, use `2` for MQTT | — |
|
|
| USERNAME | MQTT username | 63 bytes |
|
|
| PASSWORD | MQTT password | 63 bytes |
|
|
| CLIENTID | MQTT client ID | 63 bytes |
|
|
| TOPIC | Publish topic | 63 bytes |
|
|
|
|
**Example:**
|
|
```
|
|
AT+UPLOADDATA_TYPE=SET,2,USERNAME,myuser,PASSWORD,mypass,CLIENTID,device001,TOPIC,/gnss/data
|
|
```
|
|
|
|
**Response:**
|
|
```
|
|
OK
|
|
```
|
|
|
|
---
|
|
|
|
## Query Current Configuration
|
|
|
|
### Query Server Parameters
|
|
|
|
```
|
|
AT+UPLOADDATA_PARM=GET\r\n
|
|
```
|
|
|
|
**Response Format:**
|
|
```
|
|
AT+UPLOADDATA_PARM=GET,<freq>,<ip>,<port>
|
|
OK
|
|
```
|
|
|
|
### Query Protocol Type and MQTT Parameters
|
|
|
|
```
|
|
AT+UPLOADDATA_TYPE=GET\r\n
|
|
```
|
|
|
|
**Response Format (MQTT):**
|
|
```
|
|
AT+UPLOADDATA_TYPE=GET,2,USERNAME,<user>,PASSWORD,<pass>,CLIENTID,<id>,TOPIC,<topic>,SUBTOPIC,<subtopic>
|
|
OK
|
|
```
|
|
|
|
---
|
|
|
|
## Protocol Type Reference
|
|
|
|
| type | Protocol | Description |
|
|
|------|----------|-------------|
|
|
| 0 | TCP | Raw TCP connection, no additional parameters |
|
|
| 1 | HTTP | HTTP POST upload, requires USERNAME/PASSWORD |
|
|
| 2 | MQTT | MQTT publish, requires USERNAME/PASSWORD/CLIENTID/TOPIC |
|
|
| 3 | JT808 | JT808 protocol |
|
|
|
|
---
|
|
|
|
## Complete Configuration Example
|
|
|
|
```
|
|
# 1. Set server address with 1-second upload interval
|
|
AT+UPLOADDATA_PARM=SET,1,mqtt.example.com,1883
|
|
|
|
# 2. Set MQTT protocol and authentication
|
|
AT+UPLOADDATA_TYPE=SET,2,USERNAME,myuser,PASSWORD,mypass,CLIENTID,device001,TOPIC,/gnss/data
|
|
|
|
# 3. Verify configuration
|
|
AT+UPLOADDATA_PARM=GET
|
|
AT+UPLOADDATA_TYPE=GET
|
|
```
|