stash
This commit is contained in:
parent
55dad602c9
commit
b7a995e94b
2 changed files with 12 additions and 7 deletions
|
@ -36,16 +36,20 @@ bool is_on = true;
|
|||
|
||||
QueueHandle_t publish_queue;
|
||||
|
||||
extern "C" void beat_task(void *pvParameters) {
|
||||
TickType_t xLastWakeTime = xTaskGetTickCount();
|
||||
static void publish_state(){
|
||||
char msg[PUB_MSG_LEN];
|
||||
|
||||
while (1) {
|
||||
vTaskDelayUntil(&xLastWakeTime, 10000 / portTICK_PERIOD_MS);
|
||||
snprintf(msg, PUB_MSG_LEN, R"({"state":"%s", "brightness":%d})", is_on ? "ON" : "OFF", light_value >> 4);
|
||||
if(xQueueSend(publish_queue, (void *) msg, 0) == pdFALSE) {
|
||||
printf("Publish queue overflow.\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void beat_task(void *pvParameters) {
|
||||
TickType_t xLastWakeTime = xTaskGetTickCount();
|
||||
|
||||
while (1) {
|
||||
vTaskDelayUntil(&xLastWakeTime, 20000 / portTICK_PERIOD_MS);
|
||||
publish_state();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,6 +213,7 @@ static void topic_received(mqtt_message_data_t *md) {
|
|||
printf("expected ',' or '}'\n");
|
||||
return;
|
||||
}
|
||||
publish_state();
|
||||
}
|
||||
|
||||
static const char *get_my_id(void) {
|
||||
|
|
Loading…
Reference in a new issue