目录
Background
Recently I need to setup an enviroment to test SIM7000G. In order to verify the modem stability in terms of hardwares, we will setup a workflow like this:
STEP1: Go online
AT command configration
MQTT APPLICATION NOTE
SSCOM_DOWNLOAD
Ger the modem online
I use NB-IoT protocol here, if the setup is LTE-CATM or GPRS, just check the sim7000x AT comnual.
COMMAND:
AT+CNMP=38//LTE模式
AT+CMNB=2//NB-IoT模式
AT+NBSC=1//打开扰码设置
AT+CSQ//网络信号质量
AT+CGATT?//查询网络是否附着
AT+CPSI?//查询网络注册信息
AT+CGNAPN//查询APN
AT+CSTT="iot.1nce.net"//设置对应的APN(根据自己卡的信息进行设置)
AT+CIICR//激活移动场景
AT+CIICR//获取本地IP地址
AT+CIPSHUT//关闭移动场景
Now we got the device online already
STEP2: Setup the Aliyun IoT
1. Register and log in to Aliyun IoT platform
2. Build a new product
3. Add a new device to the new product
4. Modem conects to the device via MQTT protocol
5. Set the Topic rule in Product page.
6. Publish or Subscribe packets to the topic
Build a new product
Add a new device to the new product
Modem conects to the device via MQTT protocol
COMMAND:
AT+CNACT=1,"iot.1nce.net"//设置APN for MQTT
AT+CNACT?//检查是否连接成功
AT+SMCONF="URL",iot-06z00a18ae93m7j.mqtt.iothub.aliyuncs.com,1883//设置mqtt_url
AT+SMCONF="KEEPTIME",60//保持时间60s
AT+SMCONF="USERNAME",7000c&i0skjc3rzVY//用户名设置
AT+SMCONF="PASSWORD",408c0124beac2d5ee1271ae710314e7d8edc212d1d992fd48a0ff03b0337d412//密码设置
AT+SMCONF="CLIENTID","i0skjc3rzVY.7000c|securemode=2,signmethod=hmacsha256timestamp=1670342856035|"//clientid设置
AT+SMCONN//连接到MQTT
AT+SMDISC//disconnect MQTT(optional)
After that, you will see the device online showed at the Aliyun.
Set the Topic rule
Subscribe topic
COMMANDS:
AT+SMSUB="/i0skjc3rzVY/7000c/user/send",1//Subscribe订阅topic:/i0skjc3rzVY/7000c/user/send
AT+SMUNSUB="/i0skjc3rzVY/7000c/user/send"//Unsubscribe取消订阅
AT+SMPUB="/i0skjc3rzVY/7000c/user/send",20,1,0//Publish发布信息,可用AT+SMPUB=?查询格式
Subscribe the topic
Then can find the Subscribed topic at Topic list
Two functions here:
- Check packets sended by device at “Device Log”
- Publish packets to device
Publish “ABCDEFG” to topic “/i0skjc3rzVY/7000c/user/send”
Got the packet !!!
STEP3: Multiple device pub$sub
Unfortunetely Aliyun has a wield configuration at MQTT broker. Different devices doesn’t share one broker.
Device_A has its own topic name rule
it means:
Device_A can only subscribe /…/Device_A/user/send
&
Device_B cannot publish packets to /…/Device_A/user/send
***But aliyun gave an annoying way to achieve that. — “DATA Forwading” *** GOOD JOBS 😦
Here I will use MQTT.fx as the Device B
Then we got two devices connected
- 7000c (MODEM)
- 7000G (MQTT.fx)
DATA Forwarding configuration
Create Parser:
Create Data Source
Then just follow the document in aliyun, it’s being changed. So it makes no sense to share too much details
Here also introduct the setup method but it’s old GUI.(Very useful)
https://blog.csdn.net/m0_55986434/article/details/127142854
Finally got MQTT.fx to modem done