stash
This commit is contained in:
parent
55dad602c9
commit
b7a995e94b
2 changed files with 12 additions and 7 deletions
|
@ -81,7 +81,7 @@ namespace fiatlux {
|
|||
|
||||
void setup() {
|
||||
gpio_enable(2, GPIO_OUTPUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace relais {
|
||||
|
|
|
@ -36,16 +36,20 @@ bool is_on = true;
|
|||
|
||||
QueueHandle_t publish_queue;
|
||||
|
||||
static void publish_state(){
|
||||
char msg[PUB_MSG_LEN];
|
||||
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();
|
||||
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");
|
||||
}
|
||||
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