MQTT(No Security) 통신연습
MQTT (Message Queuing Telemetry Transport) is a lightweight broker-based publish/subscribe messaging protocol.
It is a machine-to-machine (M2M)/”Internet of Things” connectivity protocol.
It was designed as an extremely lightweight publish/subscribe messaging transport.
It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium.
1. MQTT(No Security) 통신시스템
2. MQTT(No Security) 명령시퀀스
No | Command | Response | Description |
1 | PDP Context 설정 | ||
2 | AT+CMQTTSTART |
+CMQTTSTART: 0 OK |
Start MQTT service, activate PDP context |
3 | AT+CMQTTACCQ=0, “client test0” | OK |
Acquire one client which will connect to a MQTT server without SSL/TLS. |
4.1 | AT+CMQTTWILLTOPIC=0,10 | > | Set the topic of the will |
4.2 | >0123456789 | OK | Input 10 Character as topic |
5.1 | AT+CMQTTWILLMSG=0,6,1 | > | Set the will message |
5.2 | >qwerty | OK | Input 6 Character |
6 |
AT+CMQTTCONNECT=0, “tcp://test.mosquitto.org:1883”,60,1 |
OK +CMQTTCONNECT: 0,0 |
Connect to a MQTT server |
7.1 | AT+CMQTTSUB=0,10,1 | > | Subscribe one topic from the server |
7.2 | >simcomtest |
OK +CMQTTSUB: 0,0 |
Input topic to subscribe |
8.1 | AT+CMQTTTOPIC=0,10 | > | Set the topic for the PUBLISH message |
8.2 | >simcomtest | OK | Input topic to publish |
9.1 | AT+CMQTTPAYLOAD=0,8 | > | Set the payload for the PUBLISH message |
9.2 | >Hi, MOMO | OK | Input message |
10 | AT+CMQTTPUB=0,1,60 |
OK +CMQTTRXSTART: 0,10,8 +CMQTTPUB: 0,0 |
Publish a message(검정색)
Subscribed a Message(파랑색) – 자신이 발송한 메시지를 자신이 수신 |
11.1 | AT+CMQTTSUBTOPIC=0,9,1 | > | Set one topic for the SUBSCRIBE message |
11.2 | >123456789 | OK | |
12 | AT+CMQTTSUB=0 | OK +CMQTTSUB: 0,0 |
Subscribe a message |
13.1 | AT+CMQTTUNSUB=0,9,0 | > | Unsubscribe one topic from the server |
13.2 | >simcommsg |
OK +CMQTTUNSUB: 0,0 |
|
14 | AT+CMQTTDISC=0,120 |
OK +CMQTTDISC: 0,0 |
Disconnect from server <–> AT+CMATTCONNECT |
15 | AT+CMQTTREL=0 | OK | Release the client <–> AT+CMQTTACCQ |
16 | AT+CMQTTSTOP |
+CMQTTSTOP: 0 OK +CMQTTNONET |
Stop MQTT Service<–> AT+CMATTSTART |