Skip to content

catie-aq/6tron_training-mqtt-publish-subscribe

Repository files navigation

Basic MQTT example

Basic Mbed OS MQTT example.

Requirements

Hardware requirements

The following boards are required:

Software requirements

This app makes use of the following libraries:

Usage

Windows

  • Open VS Code IDE.

  • Clone the repository directly in a Dev Container, in the desited volume: Dev Containers: Clone Repository in Named Container Volume

Important

Cloning to a container volume in WSL increases massively the performance.

Linux

  • Clone the project:

    git clone https://gitlab.com/catie_estia-students/mbed-os-basic-template.git YOUR_PROJECT_NAME
    cd YOUR_PROJECT_NAME
  • Open the project in VS Code IDE:

    cd YOUR_PROJECT_NAME
    code .
  • Launch the Dev Container:

    Dev Containers: Reopen in Container
    
  • In a VS Code terminal, export the project:

    mbed export -i vscode_gcc_arm

Configure

Edit main.cpp to set your GROUP_NAME.

The group name is used to select the topics to which the device will subscribe and publish.

Working from command line

Compile the project:

mbed compile

Program the target device (eg. STM32L4A6RG for the Zest_Core_STM32L4A6RG) with a J-Link debug probe:

python dist/program.py STM32L4A6RG BUILD/ZEST_CORE_STM32L4A6RG/GCC_ARM/basic-mqtt-example.elf

Build and Flash

  • Compile the project:

    mbed deploy # Deploy the dependencies
    mbed compile
  • Program the target device with the compiled binary using a J-Link debug probe:

    sixtron_flash

Export to your repository

Modify the remote URL to point to your repository and push the source code:

git remote set-url origin YOUR_REPOSITORY_URL
git push -u origin main