31:ec5c7794dcd6 | 32:84e54b14e7db |
---|---|
31 static TaskHandle_t xTaskWifi = NULL; | 31 static TaskHandle_t xTaskWifi = NULL; |
32 #ifdef CONFIG_ENABLE_BLE_GATT | 32 #ifdef CONFIG_ENABLE_BLE_GATT |
33 static TaskHandle_t xTaskBLE = NULL; | 33 static TaskHandle_t xTaskBLE = NULL; |
34 #endif | 34 #endif |
35 static TaskHandle_t xTaskOUT = NULL; | 35 static TaskHandle_t xTaskOUT = NULL; |
36 static TaskHandle_t xTaskTEMP = NULL; | |
37 | |
36 | 38 |
37 #define DS_TIME 60 | 39 #define DS_TIME 60 |
38 #define DS_CURRENT 6.6 | 40 #define DS_CURRENT 6.6 |
39 #define MAX_LOOPS 32 | 41 #define MAX_LOOPS 32 |
40 #define SUB_TIME 1000 | 42 #define SUB_TIME 1000 |
57 uint8_t loops = 0; | 59 uint8_t loops = 0; |
58 uint8_t ST_LOOPS = 6; | 60 uint8_t ST_LOOPS = 6; |
59 | 61 |
60 int DisCounter = 0; | 62 int DisCounter = 0; |
61 | 63 |
64 extern TEMP_State *temp_state; | |
65 extern SemaphoreHandle_t xSemaphoreTEMP; | |
62 extern BMP280_State *bmp280_state; ///< I2C state | 66 extern BMP280_State *bmp280_state; ///< I2C state |
63 extern SemaphoreHandle_t xSemaphoreBMP280; ///< I2C lock semaphore | 67 extern SemaphoreHandle_t xSemaphoreBMP280; ///< I2C lock semaphore |
64 extern bmp280_params_t bmp280_params; | 68 extern bmp280_params_t bmp280_params; |
65 extern bmp280_t bmp280_dev; | 69 extern bmp280_t bmp280_dev; |
66 extern SemaphoreHandle_t xSemaphoreINA219; | 70 extern SemaphoreHandle_t xSemaphoreINA219; |
397 * Create FreeRTOS tasks | 401 * Create FreeRTOS tasks |
398 */ | 402 */ |
399 xSemaphoreBMP280 = xSemaphoreCreateMutex(); | 403 xSemaphoreBMP280 = xSemaphoreCreateMutex(); |
400 xSemaphoreINA219 = xSemaphoreCreateMutex(); | 404 xSemaphoreINA219 = xSemaphoreCreateMutex(); |
401 xSemaphoreAPDS9930 = xSemaphoreCreateMutex(); | 405 xSemaphoreAPDS9930 = xSemaphoreCreateMutex(); |
402 | 406 xSemaphoreTEMP = xSemaphoreCreateMutex(); |
403 | 407 |
404 xTaskCreate(&task_bmp280, "task_bmp280", 2560, NULL, 8, &xTaskBMP280); | 408 xTaskCreate(&task_bmp280, "task_bmp280", 2560, NULL, 8, &xTaskBMP280); |
405 xTaskCreate(&task_ina219, "task_ina219", 2560, NULL, 8, &xTaskINA219); | 409 xTaskCreate(&task_ina219, "task_ina219", 2560, NULL, 8, &xTaskINA219); |
406 xTaskCreate(&task_apds9930, "task_apds9930", 2560, NULL, 8, &xTaskAPDS9930); | 410 xTaskCreate(&task_apds9930, "task_apds9930", 2560, NULL, 8, &xTaskAPDS9930); |
407 xTaskCreate(&task_out, "task_out", 2560, NULL, 9, &xTaskOUT); | 411 xTaskCreate(&task_out, "task_out", 2560, NULL, 9, &xTaskOUT); |
408 xTaskCreate(&task_mqtt, "task_mqtt", 4096, NULL, 5, &xTaskMQTT); | 412 xTaskCreate(&task_mqtt, "task_mqtt", 4096, NULL, 5, &xTaskMQTT); |
409 xTaskCreate(&task_wifi, "task_wifi", 4096, NULL, 3, &xTaskWifi); | 413 xTaskCreate(&task_wifi, "task_wifi", 4096, NULL, 3, &xTaskWifi); |
410 #ifdef CONFIG_ENABLE_BLE_GATT | 414 #ifdef CONFIG_ENABLE_BLE_GATT |
411 xTaskCreate(&task_ble, "task_ble", 4096, NULL, 3, &xTaskBLE); | 415 xTaskCreate(&task_ble, "task_ble", 4096, NULL, 3, &xTaskBLE); |
412 #endif | 416 #endif |
417 xTaskCreate(&task_temp, "task_temp", 2560, NULL, 9, &xTaskTEMP); | |
413 | 418 |
414 vTaskDelay(10 / portTICK_PERIOD_MS); | 419 vTaskDelay(10 / portTICK_PERIOD_MS); |
415 | 420 |
416 /* | 421 /* |
417 * Main application loop. | 422 * Main application loop. |
419 int State = State_Init; | 424 int State = State_Init; |
420 int OldState = State_Init + 1; | 425 int OldState = State_Init + 1; |
421 uint8_t ds_time = DS_Time; | 426 uint8_t ds_time = DS_Time; |
422 | 427 |
423 | 428 |
424 while (1) { | 429 while (0) { |
430 request_temp(); | |
425 // request_bmp280(); | 431 // request_bmp280(); |
426 // request_ina219(); | 432 // request_ina219(); |
427 // request_apds9930(); | 433 // request_apds9930(); |
428 vTaskDelay(5000 / portTICK_PERIOD_MS); | 434 vTaskDelay(5000 / portTICK_PERIOD_MS); |
429 } | 435 } |
553 #ifdef CONFIG_CODE_TESTING | 559 #ifdef CONFIG_CODE_TESTING |
554 Alarm &= ~AL_ACCULOW; | 560 Alarm &= ~AL_ACCULOW; |
555 #endif | 561 #endif |
556 } | 562 } |
557 getTempBaro(); | 563 getTempBaro(); |
564 request_temp(); | |
558 vTaskDelay(2000 / portTICK_PERIOD_MS); | 565 vTaskDelay(2000 / portTICK_PERIOD_MS); |
559 publish(); | 566 publish(); |
560 State = State_WorkDone; | 567 State = State_WorkDone; |
561 /* | 568 /* |
562 * Wait an extra second so the publish message will reach | 569 * Wait an extra second so the publish message will reach |