I plan to use MQTT messages to communicate between the PSoC 62S2 and a local MQTT broker that I have running on an RPi4.
The PSoC 62S2 will subscribe to detection messages from the remote microwave sensor and publish classification and recognition messages.
The first thing that I need to verify is that I can send and receive messages (publish and subscribe to topics) to/from the broker.
Modus Toolbox includes an example to do that using an AWS broker - AnyCloud_MQTT_Client. I am running on my LAN with a private broker, so I need to make some minor tweaks to their example.
I just need to modify 2 configuration files:
wifi_config.h to add my wifi network name and password
mqtt_client_config.h to add the broker ip address and port and any TLS information
I thought this would be very easy because I don't run TLS when operating within my private LAN, so I wasn't going use TLS and didn't need to generate any certificates (I'll probably switch to that at some point). So, basically all I needed to do was indicate that I'm not using TLS and also switch the port number from (8883 to 1883).
There are 2 lines in the mqtt_client_config.h file:
#define MQTT_SECURE_CONNECTION ( 0 ) // change from 1 to 0
#define MQTT_PORT 1883 // change from 8883 to 1883 -> 8883 is the default TLS port
Of course, nothing is that easy. Just simply changing the MQTT_SECURE_CONNECTION to "0" would cause the build to fail (I had verified it would build with "1").
Here is the build error message:
source/mqtt_client_config.c:118:38: error: conflicting types for 'security_info'
118 | struct cy_awsport_ssl_credentials_t *security_info = NULL;
In file included from source/mqtt_client_config.c:44:
./configs/mqtt_client_config.h:192:39: note: previous declaration of 'security_info' was here
192 | extern cy_awsport_ssl_credentials_t *security_info;
I needed to delete the "struct" declaration so that line 118 in mqtt_client_config.c became
118 | cy_awsport_ssl_credentials_t *security_info = NULL;
That fixed the build error.
Application demo
In this particular application, the PSoC 62S2 both publishes and subscribes to the topic "ledstatus" which creates a message loopback. When the user button (SW2) is pressed the published message alternates between "TURN ON" or "TURN OFF" to the topic "ledstatus".
Since the board is also subscribed to the "ledstatus" topic, it responds to the message by turning the user LED on or off.
Here is the USB serial output in a PuTTY terminal window.
And a short video showing the interaction.
My next steps are to add the microwave sensor and the capability to display received messages on the E-Paper Display (EPD).