You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/04.pro/boards/portenta-x8/tutorials/multi-protocol-gateway/content.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -196,7 +196,7 @@ This is the main Python script that will handle overall networking process. We w
196
196
197
197
First up, the configuration for the M4 Proxy Server, which are the parameters that handles communication with the M4 core that extends the Arduino layer. The `m4_proxy_port` is configured to `5001`, as it is the port used by clients to send the data to the M4.
198
198
199
-
```
199
+
```python
200
200
#M4 Proxy Server Configuration
201
201
# Fixed configuration parameters
202
202
port =8884
@@ -209,7 +209,7 @@ m4_proxy_port = 5001
209
209
210
210
The next function is dedicated to retrieve data from the M4 (Arduino layer). It will help you set the variables, such as sensor data, to then be pulled and be exposed to the Linux layer. With this, you will have the information available to be used within the Python script.
For MQTT configuration, you will need to set the desired parameters. Below are the parameters we use for MQTT in this tutorial.
235
235
236
-
```
236
+
```python
237
237
mqtt_broker ='broker.emqx.io'
238
238
mqtt_port =1883
239
239
mqtt_topic ="multiPrGw/mqtt1"
@@ -245,7 +245,7 @@ mqtt_password = 'public'
245
245
246
246
These 2 parameters are required to establish a connection with The Things Network. The `APP_EUI` and `APP_KEY` are required to be configured, as they are provided from The Things Network for example or from the LoRaWAN platform that you may try extablishing connection to. Additionally, the `DEV_EUI` will be predefined as the device will request and apply the EUI. However, if it requires to use different `DEV_EUI`, you can make the change in this section.
247
247
248
-
```
248
+
```python
249
249
# Obtained during first registration of the device
250
250
SECRET_APP_EUI='XXXXXXXXXXXXXXXX'
251
251
SECRET_APP_KEY='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
@@ -255,7 +255,7 @@ With these parameters configured, we have secured the connection between our dev
255
255
256
256
Following tasks are the main processes that will be used to handle MQTT protocol. This will be able to decode incoming packets from the subscribed device and buffer the data if timeout has occurred while waiting on the MQTT packet. This will help to receive sensor data from any external device, for example using Arduino MKR WiFi 1010 with a sensor attached, using MQTT protocol.
For LoRa connectivity to establish communication with The Things Network, we are going to use the Cayenne Low Power Payload Encoder as part of the process in this build.
311
311
312
-
```
312
+
```python
313
313
...
314
314
frame = LppFrame()
315
315
frame.add_temperature(0, rpc_data[0])
@@ -330,7 +330,7 @@ For the full Arduino scripts please refer to the files found inside [this compre
330
330
331
331
The following sketch is for the Arduino layer that will help us retrieve the data in between Arduino and Linux layer.
332
332
333
-
```
333
+
```arduino
334
334
# Arduino side sketch
335
335
#include <RPC.h>
336
336
#include <SerialRPC.h>
@@ -373,7 +373,7 @@ Additionally by exposing, it means you will bring forth the data received within
373
373
374
374
For MQTT publishing, we have also included a sketch that can be used with Arduino MKR WiFi 1010 to test the gateway build. Of course, the code can be extended and be modified according the requirements of the device that will collect data from a certain sensor to send over MQTT protocol.
0 commit comments