Changes for page MQTT Forward Instruction
Last modified by Kilight Cao on 2024/08/31 16:26
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -24,7 +24,6 @@ 24 24 25 25 26 26 27 - 28 28 = 2. Firmware Change Log for MQTT feature = 29 29 30 30 ... ... @@ -37,7 +37,6 @@ 37 37 38 38 39 39 40 - 41 41 = 3. MQTT forward operating principle = 42 42 43 43 ... ... @@ -46,8 +46,8 @@ 46 46 47 47 Below shows the network structure for MQTT forwarding. 48 48 49 -* For Uplink: The sensor sends data to LoRa Gateway via LoRa wireless, The gateway will process these data and forward to remote MQTT Broker via Internet. 50 -* For Downlink: The gateway subscribe a topic in the MQTT broker, when there is update on the topic, the gateway will know and broadcast the data to Local LoRa network, 47 +* **For Uplink:** The sensor sends data to LoRa Gateway via LoRa wireless, The gateway will process these data and forward to remote MQTT Broker via Internet. 48 +* **For Downlink:** The gateway subscribe a topic in the MQTT broker, when there is update on the topic, the gateway will know and broadcast the data to Local LoRa network, 51 51 52 52 [[image:image-20220527133547-1.png]] 53 53 ... ... @@ -54,12 +54,13 @@ 54 54 General MQTT structure 55 55 56 56 57 -== 3.2 How sensor data is forwarded == 55 +== 3.2 How sensor data is forwarded == 58 58 57 + 59 59 In this MQTT forward feature, the key point is how the gateway process the sensor data. 60 60 61 61 62 -=== 3.2.1 Upstream === 61 +=== 3.2.1 Upstream === 63 63 64 64 Assume there are two sensor nodes, their ID are Node1 ID: 6734 , Node2 ID: 7456. In the remote MQTT broker there are two topics: Topic1: /channel/765800, Topic2: /channel/367860. We can set up in the gateway to map Node1 to Topic1 and Node2 to Topic2. So when there is a sensor data from Node1, the gateway will forward the data to Topic1, when there is sensor data from Node2, the gateway will forward to Topic2. 65 65 ... ... @@ -71,10 +71,12 @@ 71 71 72 72 ((( 73 73 Upstream path 73 + 74 + 74 74 ))) 75 75 76 76 ((( 77 -Note: The sensor data can base or LoRa or other method, as long as there are data on the file /var/iot/channels. /span> 78 +(% style="color:red" %)**Note: The sensor data can base or LoRa or other method, as long as there are data on the file /var/iot/channels. /span>** 78 78 ))) 79 79 80 80 ((( ... ... @@ -81,8 +81,9 @@ 81 81 82 82 ))) 83 83 84 -=== 3.2.2 Downstream === 85 +=== 3.2.2 Downstream === 85 85 87 + 86 86 The gateway subscribes to a topic of the remote MQTT broker topic. When there is some one publish a value on this topic. The gateway will get it and broadcast to local LoRa Network. 87 87 88 88 ((( ... ... @@ -94,8 +94,9 @@ 94 94 Downstream path 95 95 96 96 97 -== 3.3 Macro Definition == 99 +== 3.3 Macro Definition == 98 98 101 + 99 99 The MQTT publish command use Macro settings to generate flexible upstream payload for MQTT publish. 100 100 101 101 ((( ... ... @@ -104,8 +104,9 @@ 104 104 105 105 ))) 106 106 107 -=== 3.3.1 -t topic macro === 110 +=== 3.3.1 -t topic macro === 108 108 112 + 109 109 * CHANNEL: Remote Channel ID 110 110 * CLIENTID: Client ID , Same as -i 111 111 * WRITE_API: Remote Channel Write API ... ... @@ -112,8 +112,12 @@ 112 112 * USERNAME: User ID (-u) 113 113 * HOSTNAME: Device Hostname 114 114 115 -=== 3.3.2 -m message macro === 116 116 120 + 121 + 122 +=== 3.3.2 -m message macro === 123 + 124 + 117 117 * HOSTNAME: Device Hostname 118 118 * CHANNEL: Remote Channel ID 119 119 * DATA: Sensor Data without time stamp and rssi ... ... @@ -120,14 +120,18 @@ 120 120 * META: Completely sensor data with time stamp and rssi 121 121 * JSON: Convert META to json format. 122 122 123 -=== 3.3.3 Example for Macro === 124 124 132 + 133 + 134 +=== 3.3.3 Example for Macro === 135 + 136 + 125 125 [[image:image-20220527134251-4.png]] 126 126 127 127 MQTT Publish configure 128 128 129 129 130 -Above screen shots shows below format: 142 +**Above screen shots shows below format:** 131 131 132 132 * -t: CLIENTID/CHANNEL/data 133 133 * -m: DATA ... ... @@ -144,8 +144,10 @@ 144 144 ))) 145 145 146 146 147 -== 3.4 Modify the MQTT to support more options == 148 148 160 +== 3.4 Modify the MQTT to support more options == 161 + 162 + 149 149 The MQTT Client Utility used in Dragino is **mosquitto_pub** and **mosquitto_sub**. User can add more options to the mqtt commands. User can check the valid options by command mosquitto_pub ~-~-help. as below: 150 150 151 151 (% class="box" %) ... ... @@ -163,9 +163,9 @@ 163 163 [-u username [-P password]] 164 164 [~-~-will-topic [~-~-will-payload payload] [~-~-will-qos qos] [~-~-will-retain]] 165 165 [{~-~-cafile file | ~-~-capath dir} [~-~-cert file] [~-~-key file] 166 - 167 - 168 - 180 + [~-~-ciphers ciphers] [~-~-insecure] 181 + [~-~-tls-alpn protocol] 182 + [~-~-tls-engine engine] [~-~-keyform keyform] [~-~-tls-engine-kpass-sha1]] 169 169 [~-~-psk hex-key ~-~-psk-identity identity [~-~-ciphers ciphers]] 170 170 [~-~-proxy socks-url] 171 171 [~-~-property command identifier value]