Hi,
I am trying to write my first firmware with MQTT interface, but I have probably some issue in my code or workflow.
My setup is: Core module + CO2 module + Humidity/Pressure tags connected to RPi USB port. RPi is running your distribution.
I would like ask you:
- Is my code below OK?
- Is it OK when
dfu-util
printInvalid DFU suffix signature
message prior to FW download? (process ends withFile downloaded succesfully
) - How I could communicate with Core modul from RPi? I am using commands like
mosquitto_pub -t 'muj01/led/-/state/set' -m '{"state": false}'
(ortrue
) for changing LED state, andmosquitto_pub -t 'muj01/led/-/state/get' -m ""
for reading; but I don’t see any response from module. I also try to runmosquitto_sub -v -t '#'
on second terminal – I see my payloads sent from RPi, but no response from Core module
My code is based on bc-core-module
project. I just replace app/application.c
source code and copy into app/usb_talk.*
files.
Content of app/application.c
:
#include <application.h>
#include <usb_talk.h>
#define PREFIX_TALK "muj01"
static bc_led_t led;
static bool led_state = false;
static void led_state_set(usb_talk_payload_t *payload);
static void led_state_get(usb_talk_payload_t *payload);
void application_init(void)
{
bc_led_init(&led, BC_GPIO_LED, false, false);
bc_led_set_mode(&led, BC_LED_MODE_ON);
usb_talk_init();
usb_talk_sub(PREFIX_TALK "/led/-/state/set", led_state_set);
usb_talk_sub(PREFIX_TALK "/led/-/state/get", led_state_get);
}
static void led_state_set(usb_talk_payload_t *payload)
{
if (!usb_talk_payload_get_bool(payload, &led_state))
{
return;
}
bc_led_set_mode(&led, led_state ? BC_LED_MODE_ON : BC_LED_MODE_OFF);
usb_talk_publish_led(PREFIX_TALK, &led_state);
}
static void led_state_get(usb_talk_payload_t *payload)
{
(void) payload;
usb_talk_publish_led(PREFIX_TALK, &led_state);
}