NETXDUO

 Nx_MQTT_Client application description :


This application provides an example of Azure RTOS NetX/NetXDuo stack usage. It shows how to exchange data between client and server using MQTT protocol in an encrypted mode supporting TLS v1.2 .


The main entry function tx_application_define() is called by ThreadX during kernel start, at this stage, all NetX resources are created. 

  • NX_PACKET_POOLis allocated
  • NX_IP instance using that pool is initialized
  • The ARPICMPUDP and TCP protocols are enabled for the NX_IP instance
  • DHCP client is created.
The application then creates 3 threads with the different priorities:

AppMainThread (priority 10, PreemtionThreashold 10) : created with the TX_AUTO_START flag to start automatically.

AppMQTTClientThread (priority 3, PreemtionThreashold 3) : created with the TX_DONT_START flag to be started later.

AppSNTPThread (priority 5, PreemtionThreashold 5) : created with the TX_DONT_START flag to be started later


** The AppMainThread starts and perform the following actions: 

  • creates a dns_client with USER_DNS_ADDRESS (default value defined IP_ADDRESS(1, 1, 1, 1) on app_netxduo.h.
  • starts the DHCP client
  • waits for the IP address resolution
  • resumes the AppSNTPThread

** The AppSNTPThread, once started:

  • it connects to an SNTP server to get the current time.
  • resumes the AppMQTTClientThread


** The AppMQTTClientThread, once started:

  • creates an mqtt_client
  • connects mqtt_client to the online MQTT broker; connection with server will be secure and a tls_setup_callback will set TLS parametres. By default MQTT_PORT for encrypted mode is 8883

  • mqtt_client subscribes on a predefined topic TOPIC_NAME “Temperature” with a Quality Of Service QOS0
  • depending on the number of message “NB_MESSAGE” defined by user, mqtt_client will publish a random number generated by RNG. If NB_MESSAGE = 0, it means that number of messages is infinitely.
  • mqtt_client will get messages from the MQTT broker and print them.





link 2: https://github.com/STMicroelectronics/x-cube-azrtos-f4/tree/main/Projects/STM32F429ZI-Nucleo/Applications/NetXDuo/Nx_MQTT_Client



Commentaires

Posts les plus consultés de ce blog

Azure RTOS with Stm32

AZURE-RTOS ThreadX in the STM32Cube ecosystem

STM32F7_HAL_ETH_MQTT_CLIENT