17 #define State_GoSleep 7 |
17 #define State_GoSleep 7 |
18 |
18 |
19 |
19 |
20 static TaskHandle_t xTaskBMP280 = NULL; |
20 static TaskHandle_t xTaskBMP280 = NULL; |
21 static TaskHandle_t xTaskINA219 = NULL; |
21 static TaskHandle_t xTaskINA219 = NULL; |
22 |
22 static TaskHandle_t xTaskWifi = NULL; |
23 |
23 |
24 extern BMP280_State *bmp280_state; ///< I2C state |
24 extern BMP280_State *bmp280_state; ///< I2C state |
25 extern SemaphoreHandle_t xSemaphoreBMP280; ///< I2C lock semaphore |
25 extern SemaphoreHandle_t xSemaphoreBMP280; ///< I2C lock semaphore |
26 extern bmp280_params_t bmp280_params; |
26 extern bmp280_params_t bmp280_params; |
27 extern bmp280_t bmp280_dev; |
27 extern bmp280_t bmp280_dev; |
28 extern SemaphoreHandle_t xSemaphoreINA219; |
28 extern SemaphoreHandle_t xSemaphoreINA219; |
29 extern ina219_t ina219_b_dev; |
29 extern ina219_t ina219_b_dev; |
30 extern ina219_t ina219_s_dev; |
30 extern ina219_t ina219_s_dev; |
|
31 extern SemaphoreHandle_t xSemaphoreWiFi; |
|
32 extern WIFI_State *wifi_state; ///< WiFi state |
|
33 |
31 |
34 |
32 |
35 |
33 void app_main(void) |
36 void app_main(void) |
34 { |
37 { |
35 #ifdef CONFIG_CODE_PRODUCTION |
38 #ifdef CONFIG_CODE_PRODUCTION |
83 |
86 |
84 /* |
87 /* |
85 * Create FreeRTOS tasks |
88 * Create FreeRTOS tasks |
86 */ |
89 */ |
87 xSemaphoreBMP280 = xSemaphoreCreateMutex(); |
90 xSemaphoreBMP280 = xSemaphoreCreateMutex(); |
88 |
91 xSemaphoreINA219 = xSemaphoreCreateMutex(); |
89 xTaskCreate(&task_bmp280, "task_bmp280", 2560, NULL, 8, &xTaskBMP280); |
92 |
90 xTaskCreate(&task_ina219, "task_ina219", 2560, NULL, 8, &xTaskINA219); |
93 |
|
94 xTaskCreate(&task_bmp280, "task_bmp280", 2560, NULL, 8, &xTaskBMP280); |
|
95 xTaskCreate(&task_ina219, "task_ina219", 2560, NULL, 8, &xTaskINA219); |
|
96 xTaskCreate(&task_wifi, "task_wifi", 4096, NULL, 3, &xTaskWifi); |
|
97 |
|
98 vTaskDelay(10 / portTICK_PERIOD_MS); |
91 |
99 |
92 /* |
100 /* |
93 * Main application loop. |
101 * Main application loop. |
94 */ |
102 */ |
95 int State = State_Init; |
103 int State = State_Init; |
105 request_ina219(); |
113 request_ina219(); |
106 // getTempBaro(); |
114 // getTempBaro(); |
107 // getLightValues(); |
115 // getLightValues(); |
108 // getVoltsCurrent(); |
116 // getVoltsCurrent(); |
109 State = State_Connect; |
117 State = State_Connect; |
|
118 request_WiFi(true); |
110 break; |
119 break; |
111 |
120 |
112 case State_Connect: // Wake WiFi ?? |
121 case State_Connect: // Wake WiFi ?? |
113 // if (NetworkConnect()) { |
122 // if (NetworkConnect()) { |
114 // State = State_Working; |
123 // State = State_Working; |