]> granicus.if.org Git - esp-idf/commitdiff
modify static variables and README file
authorzhangyanjiao <zhangyanjiao@espressif.com>
Wed, 29 Aug 2018 12:48:16 +0000 (20:48 +0800)
committerzhangyanjiao <zhangyanjiao@espressif.com>
Thu, 30 Aug 2018 11:52:10 +0000 (19:52 +0800)
examples/wifi/smart_config/README.md
examples/wifi/smart_config/main/smartconfig_main.c

index 9453edbb60b28d16659fe1f91d989bb22ceda12a..7f8ee90c7d83596a4c329076ccc97787a88fd79b 100644 (file)
@@ -1,16 +1,39 @@
 # smartconfig Example
 
-This example shows how ESP32 connects to AP with ESPTOUCH. Example does the following steps:
+This example shows how ESP32 connects to a target AP with ESPTOUCH.
 
-* Download ESPTOUCH APP from app store. [Android source code](https://github.com/EspressifApp/EsptouchForAndroid) and [iOS source code](https://github.com/EspressifApp/EsptouchForIOS) is available.
+## How to use example
 
-* Compile this example and upload it to an ESP32.
+### Hardware Required
 
-* Make sure your phone connect to target AP (2.4GHz).
+Download ESPTOUCH APP from app store: 
+[Android source code](https://github.com/EspressifApp/EsptouchForAndroid)
+[iOS source code](https://github.com/EspressifApp/EsptouchForIOS) is available.
 
-* Open ESPTOUCH app and input password. There will be success message after few sec.
+### Configure the project
+
+```
+make menuconfig
+```
+
+* Set serial port under Serial Flasher Options.
+
+### Build and Flash
+
+Build the project and flash it to the board, then run monitor tool to view serial output:
 
-### Example output
+```
+make -j4 flash monitor
+```
+
+(To exit the serial monitor, type ``Ctrl-]``.)
+
+See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
+
+## Example output
+
+* Make sure your phone connect to the target AP (2.4GHz).
+* Open ESPTOUCH app and input password. There will be success message after few sec.
 
 Here is an example of smartconfig console output.
 ```
index 3cbf8737d4c523865f7eb354617e7f9ff45eb972..71e9365e473029456239c2da3b063c37b6ed1afb 100644 (file)
@@ -22,7 +22,7 @@
 #include "esp_smartconfig.h"
 
 /* FreeRTOS event group to signal when we are connected & ready to make a request */
-static EventGroupHandle_t wifi_event_group;
+static EventGroupHandle_t s_wifi_event_group;
 
 /* The event group allows multiple bits for each event,
    but we only care about one event - are we connected
@@ -40,11 +40,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
         xTaskCreate(smartconfig_example_task, "smartconfig_example_task", 4096, NULL, 3, NULL);
         break;
     case SYSTEM_EVENT_STA_GOT_IP:
-        xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
+        xEventGroupSetBits(s_wifi_event_group, CONNECTED_BIT);
         break;
     case SYSTEM_EVENT_STA_DISCONNECTED:
         esp_wifi_connect();
-        xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
+        xEventGroupClearBits(s_wifi_event_group, CONNECTED_BIT);
         break;
     default:
         break;
@@ -55,7 +55,7 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
 static void initialise_wifi(void)
 {
     tcpip_adapter_init();
-    wifi_event_group = xEventGroupCreate();
+    s_wifi_event_group = xEventGroupCreate();
     ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
 
     wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
@@ -93,7 +93,7 @@ static void sc_callback(smartconfig_status_t status, void *pdata)
                 memcpy(phone_ip, (uint8_t* )pdata, 4);
                 ESP_LOGI(TAG, "Phone ip: %d.%d.%d.%d\n", phone_ip[0], phone_ip[1], phone_ip[2], phone_ip[3]);
             }
-            xEventGroupSetBits(wifi_event_group, ESPTOUCH_DONE_BIT);
+            xEventGroupSetBits(s_wifi_event_group, ESPTOUCH_DONE_BIT);
             break;
         default:
             break;
@@ -106,7 +106,7 @@ void smartconfig_example_task(void * parm)
     ESP_ERROR_CHECK( esp_smartconfig_set_type(SC_TYPE_ESPTOUCH) );
     ESP_ERROR_CHECK( esp_smartconfig_start(sc_callback) );
     while (1) {
-        uxBits = xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT | ESPTOUCH_DONE_BIT, true, false, portMAX_DELAY); 
+        uxBits = xEventGroupWaitBits(s_wifi_event_group, CONNECTED_BIT | ESPTOUCH_DONE_BIT, true, false, portMAX_DELAY); 
         if(uxBits & CONNECTED_BIT) {
             ESP_LOGI(TAG, "WiFi Connected to ap");
         }