main/task_wifi.c

changeset 1
ad2c8b13eb88
parent 0
b74b0e4902c3
child 22
90f22a101fc6
equal deleted inserted replaced
0:b74b0e4902c3 1:ad2c8b13eb88
17 wifi_ap_record_t *accessp_records; ///< [MAX_AP_NUM] records array with scan results. 17 wifi_ap_record_t *accessp_records; ///< [MAX_AP_NUM] records array with scan results.
18 wifi_config_t *task_wifi_ConfigSTA = NULL; ///< Current STA configuration. 18 wifi_config_t *task_wifi_ConfigSTA = NULL; ///< Current STA configuration.
19 WIFI_State *wifi_state = NULL; ///< Public state for other tasks. 19 WIFI_State *wifi_state = NULL; ///< Public state for other tasks.
20 20
21 21
22 uint8_t _wifi_ssid[33]; 22 uint8_t _wifi_ssid[33]; ///< Current SSID
23 bool _wifi_ScanAPs = false; 23 bool _wifi_ScanAPs = false; ///< Scanning
24 bool _wifi_ScanDone = false; 24 bool _wifi_ScanDone = false; ///< Scan ready
25 uint16_t _wifi_Scanned = 0; 25 uint16_t _wifi_Scanned = 0; ///< Total scanned APs.
26 26
27 extern int Main_Screen; ///< Current Screen number. 27 extern int Main_Screen; ///< Current Screen number.
28 extern sButton Buttons[MAXBUTTONS]; ///< Buttons definitions. 28 extern sButton Buttons[MAXBUTTONS]; ///< Buttons definitions.
29 extern uint32_t TimeSpent; ///< Counter that is increased each second. 29 extern uint32_t TimeSpent; ///< Counter that is increased each second.
30 30
33 const int TASK_WIFI_REQUEST_STA_CONNECT = BIT2; ///< When set, means a client requested to connect to an access point. 33 const int TASK_WIFI_REQUEST_STA_CONNECT = BIT2; ///< When set, means a client requested to connect to an access point.
34 34
35 const int TASK_WIFI_HAS_IP = BIT3; ///< Indicate that we have an IP address 35 const int TASK_WIFI_HAS_IP = BIT3; ///< Indicate that we have an IP address
36 const int TASK_WIFI_AP_STARTED = BIT4; ///< Indicate that the SoftAP is started 36 const int TASK_WIFI_AP_STARTED = BIT4; ///< Indicate that the SoftAP is started
37 const int TASK_WIFI_STA_FAILED = BIT5; ///< Indicate that we could not get a connection to AP as station. 37 const int TASK_WIFI_STA_FAILED = BIT5; ///< Indicate that we could not get a connection to AP as station.
38 const int TASK_WIFI_STA_DISCONNECTED = BIT6; ///* Indicate that we are disconnected from an ap station. 38 const int TASK_WIFI_STA_DISCONNECTED = BIT6; ///< Indicate that we are disconnected from an ap station.
39 const int TASK_WIFI_STA_CONNECTED = BIT7; ///< Indicate that we are connected to AP as station, flip of BIT6. 39 const int TASK_WIFI_STA_CONNECTED = BIT7; ///< Indicate that we are connected to AP as station, flip of BIT6.
40 40
41 41
42 /** 42 /**
43 * @brief Local function, save station configuration. 43 * @brief Local function, save station configuration.
51 */ 51 */
52 bool FetchStaConfig(void); 52 bool FetchStaConfig(void);
53 53
54 /** 54 /**
55 * @brief Local function, WiFi event handler. 55 * @brief Local function, WiFi event handler.
56 * @param ctx Context
57 * @param event The event
56 * @return Esp error code. 58 * @return Esp error code.
57 */ 59 */
58 esp_err_t task_wifi_EventHandler(void *ctx, system_event_t *event); 60 esp_err_t task_wifi_EventHandler(void *ctx, system_event_t *event);
59 61
60 62
261 return ESP_OK; 263 return ESP_OK;
262 } 264 }
263 265
264 266
265 267
266 /**
267 * @brief WiFi manager task
268 */
269 void task_wifi( void * pvParameters ) 268 void task_wifi( void * pvParameters )
270 { 269 {
271 esp_err_t ret; 270 esp_err_t ret;
272 271
273 ESP_LOGI(TAG, "Starting WiFi driver"); 272 ESP_LOGI(TAG, "Starting WiFi driver");
471 } /* for(;;) */ 470 } /* for(;;) */
472 vTaskDelay( (TickType_t)10); 471 vTaskDelay( (TickType_t)10);
473 } 472 }
474 473
475 474
475 /**
476 * @brief Array with AP security names
477 */
476 const char *apsec[] = { "Open", "WEP", "WPA", "WPA2", "WPA WPA2", "Enterprise" }; 478 const char *apsec[] = { "Open", "WEP", "WPA", "WPA2", "WPA WPA2", "Enterprise" };
477 479
478 480
479 /** 481 /**
480 * @brief Show an AP station as a button. The buttons are already defined. 482 * @brief Show an AP station as a button. The buttons are already defined.
481 * @param idx The index position on the display, 1 to 7. 483 * @param idx The index position on the display, 1 to 7.
482 * @param ap The AP information from the WiFi scan. 484 * @param ap The AP information from the WiFi scan.
483 * @param show, How to display. 0 is blank, 1 is unknown, 2 is known, 3 is a connected AP. 485 * @param show How to display. 0 is blank, 1 is unknown, 2 is known, 3 is a connected AP.
484 */ 486 */
485 void Show_AP(uint8_t idx, wifi_ap_record_t ap, int show) 487 void Show_AP(uint8_t idx, wifi_ap_record_t ap, int show)
486 { 488 {
487 char tmp[33]; 489 char tmp[33];
488 490

mercurial