publish something
This commit is contained in:
parent
f5ba1a4f7d
commit
77e83a3d44
@ -9,7 +9,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
extern const uint8_t MQTT_SOCK;
|
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) {
|
void mqttTestHandler(void *handle) {
|
||||||
static uint8_t state = 0;
|
static uint8_t state = 0;
|
||||||
static uint8_t message[] = "Hello world\n\r";
|
static uint8_t message[] = "Hello world\n\r";
|
||||||
@ -55,14 +59,26 @@ void mqttTestHandler(void *handle) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
coloredMsg(LOG_YELLOW, "mth, waiting");
|
coloredMsg(LOG_YELLOW, "mth, start mqtt loop");
|
||||||
|
schAdd(mqttLoopHandler, NULL, 0, 100);
|
||||||
|
state = 3;
|
||||||
break;
|
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:
|
case 255:
|
||||||
coloredMsg(LOG_YELLOW, "mth, error state, will stop here");
|
coloredMsg(LOG_YELLOW, "mth, error state, will stop here");
|
||||||
schDel(mqttTestHandler, NULL);
|
schDel(mqttTestHandler, NULL);
|
||||||
|
schDel(mqttLoopHandler, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user