stash
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
j3d1 2023-02-16 10:04:40 +01:00
parent b7a995e94b
commit 2b07102b69

View file

@ -46,8 +46,7 @@ static void publish_state(){
extern "C" void beat_task(void *pvParameters) {
TickType_t xLastWakeTime = xTaskGetTickCount();
while (1) {
while (true) {
vTaskDelayUntil(&xLastWakeTime, 20000 / portTICK_PERIOD_MS);
publish_state();
}
@ -216,7 +215,7 @@ static void topic_received(mqtt_message_data_t *md) {
publish_state();
}
static const char *get_my_id(void) {
static const char *get_my_id() {
// Use MAC address for Station as unique ID
static char my_id[13];
static bool my_id_done = false;
@ -225,7 +224,7 @@ static const char *get_my_id(void) {
if(my_id_done)
return my_id;
if(!sdk_wifi_get_macaddr(STATION_IF, (uint8_t *) my_id))
return NULL;
return nullptr;
for (i = 5; i >= 0; --i) {
x = my_id[i] & 0x0F;
if(x > 9) x += 7;
@ -241,7 +240,7 @@ static const char *get_my_id(void) {
extern "C" void mqtt_task(void *pvParameters) {
int ret = 0;
struct mqtt_network network;
mqtt_network network{};
mqtt_client_t client = mqtt_client_default;
char mqtt_client_id[20];
uint8_t mqtt_buf[1000];
@ -253,7 +252,7 @@ extern "C" void mqtt_task(void *pvParameters) {
strcpy(mqtt_client_id, "fiatlux-");
strcat(mqtt_client_id, get_my_id());
while (1) {
while (true) {
xSemaphoreTake(wifi_alive, portMAX_DELAY);
printf("%s: started\n\r", __func__);
printf("%s: (Re)connecting to MQTT server %s ... ", __func__,
@ -309,12 +308,11 @@ extern "C" void mqtt_task(void *pvParameters) {
}
}
while (1) {
while (true) {
char msg[PUB_MSG_LEN - 1] = "\0";
while (xQueueReceive(publish_queue, (void *) msg, 0) ==
pdTRUE) {
printf("got message to publish\r\n");
mqtt_message_t message;
message.payload = msg;
message.payloadlen = strlen(msg);