Due to some needed changes in the library, some files needed to be changed. These changes are not considered by the e2studios code generation. Therefore, the following needs to be done.
- open e2studio
- create a new workspace and import the project using the "Import existing projects" option
- make sure e2studio is set to FSP version 4.4.0
- open configuration.xml and generate the code
- open the project folder in your file explorer
e2studio/mqtt_mutual_auth_ra6m5
- copy the folder
ra
from thechanged-libaries
folder into thee2studio/mqtt_mutual_auth_ra6m5
folder - If asked replace the files
- Build the project
Important! Steps 5-8 need to be done every time the code is generated.
Mosquitto running on Ubuntu 22.04 VM
Mosquitto config:
per_listener_settings true
listener 8883
allow_anonymous true
cafile ./mosquitto/ca.crt
certfile ./mosquitto/server.crt
keyfile ./mosquitto/server.key
tls_version tlsv1.2
user_config.h
- MQTT Broker Hostname (see credentials), Port and Identifier
- MQTT Topic names
- Credentials in PEM Format
<hostname>
needs to be the same as the Common Name in the server certificate and the ip address/domain of the Broker
start broker: mosquitto -c <config file>
subscribe: mosquitto_sub -h <hostname> -t testTopic -p 8883 --cafile ./mosquitto/server.crt
publish: mosquitto_pub -h <hostname> -t instructionTopic -p 8883 --cafile ./mosquitto/server.crt -d -m "Test1"
Running order
- configures and initializes littlefs, mbedtls and provisions keys
- Initializes IP stack and gets IP (when using DHCP)
- Establishes TLS connection with multiple tries
- Creates MQTT Connection to Broker
- Subscribes to topic with multiple tries
- Publishes to a topic for a specified number of times and waits till it received a specified number of messages
- If sent and received the specified amount, disconnects the MQTT and TLS Connection and stops/deletes the task
- implementing Keep Alive, Quality of Service and Last Will
- MQTT Agent Thread
- CAN connection