publish something

This commit is contained in:
Wolfgang Hottgenroth 2020-11-13 14:22:26 +01:00
parent f5ba1a4f7d
commit 77e83a3d44
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F

View File

@ -9,7 +9,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
extern const uint8_t MQTT_SOCK;
@ -26,6 +26,10 @@ static void mqttCallback(char *topic, uint8_t *payload, uint16_t payloadLength)
}
void mqttLoopHandler(void *handle) {
mqttLoop(&mqttClient);
}
void mqttTestHandler(void *handle) {
static uint8_t state = 0;
static uint8_t message[] = "Hello world\n\r";
@ -55,14 +59,26 @@ void mqttTestHandler(void *handle) {
break;
case 2:
coloredMsg(LOG_YELLOW, "mth, waiting");
coloredMsg(LOG_YELLOW, "mth, start mqtt loop");
schAdd(mqttLoopHandler, NULL, 0, 100);
state = 3;
break;
case 3:
coloredMsg(LOG_YELLOW, "mth, publish something");
res = publish(&mqttClient, "wiznet/hello", message, strlen(message), false);
coloredMsg(LOG_YELLOW, "mth, publish returned %d", res);
state = 4;
break;
case 4:
coloredMsg(LOG_YELLOW, "mth, waiting");
break;
case 255:
coloredMsg(LOG_YELLOW, "mth, error state, will stop here");
schDel(mqttTestHandler, NULL);
schDel(mqttLoopHandler, NULL);
break;
}
} else {