Skip to content

Commit 4183d4d

Browse files
Added code classification
1 parent b1276ca commit 4183d4d

File tree

1 file changed

+8
-8
lines changed
  • content/hardware/04.pro/boards/portenta-x8/tutorials/multi-protocol-gateway

1 file changed

+8
-8
lines changed

content/hardware/04.pro/boards/portenta-x8/tutorials/multi-protocol-gateway/content.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ This is the main Python script that will handle overall networking process. We w
196196

197197
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.
198198

199-
```
199+
```python
200200
#M4 Proxy Server Configuration
201201
# Fixed configuration parameters
202202
port = 8884
@@ -209,7 +209,7 @@ m4_proxy_port = 5001
209209

210210
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.
211211

212-
```
212+
```python
213213
def get_data_from_m4():
214214

215215
rpc_address = RpcAddress(m4_proxy_address, m4_proxy_port)
@@ -233,7 +233,7 @@ def get_data_from_m4():
233233

234234
For MQTT configuration, you will need to set the desired parameters. Below are the parameters we use for MQTT in this tutorial.
235235

236-
```
236+
```python
237237
mqtt_broker = 'broker.emqx.io'
238238
mqtt_port = 1883
239239
mqtt_topic = "multiPrGw/mqtt1"
@@ -245,7 +245,7 @@ mqtt_password = 'public'
245245

246246
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.
247247

248-
```
248+
```python
249249
# Obtained during first registration of the device
250250
SECRET_APP_EUI = 'XXXXXXXXXXXXXXXX'
251251
SECRET_APP_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
@@ -255,7 +255,7 @@ With these parameters configured, we have secured the connection between our dev
255255

256256
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.
257257

258-
```
258+
```python
259259
# MQTT protocol handler
260260
...
261261
def connect_mqtt() -> mqtt_client:
@@ -309,7 +309,7 @@ def subscribe(client: mqtt_client):
309309

310310
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.
311311

312-
```
312+
```python
313313
...
314314
frame = LppFrame()
315315
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
330330

331331
The following sketch is for the Arduino layer that will help us retrieve the data in between Arduino and Linux layer.
332332

333-
```
333+
```arduino
334334
# Arduino side sketch
335335
#include <RPC.h>
336336
#include <SerialRPC.h>
@@ -373,7 +373,7 @@ Additionally by exposing, it means you will bring forth the data received within
373373

374374
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.
375375

376-
```
376+
```arduino
377377
#include <ArduinoMqttClient.h>
378378
#include <WiFiNINA.h>
379379
#include "arduino_secrets.h"

0 commit comments

Comments
 (0)