List of commits:
Subject Hash Author Date (UTC)
simple wifi demo 3b49d1710d647028a95144d22eaf92ead994cd4f zhanzr 2018-08-04 18:33:49
maintaince eab2557c1c0fbfb1df5b8b38af229b810be691fc zhanzr 2018-08-04 18:08:39
maintaince 9735c9025f877485b7fba7d68cee37342eb2bc41 zhanzr 2018-08-04 18:07:52
maintaince 1045165526407dec48797d66751a06dbe94257fb zhanzr 2018-08-04 18:06:59
hellow word, printf from serial port. 6818f08e563aefc70c9bc9ef18852149e080d237 zhanzr 2018-08-04 18:03:27
blink demo. bc35d066c34d62eb527f29af81a9907a960e23bd zhanzr 2018-08-04 17:34:03
Commit 3b49d1710d647028a95144d22eaf92ead994cd4f - simple wifi demo
Author: zhanzr
Author date (UTC): 2018-08-04 18:33
Committer name: zhanzr
Committer date (UTC): 2018-08-04 18:33
Parent(s): eab2557c1c0fbfb1df5b8b38af229b810be691fc
Signing key:
Tree: aa7b94fb46e1d6a573b3e5e1def34ae3fb582892
File Lines added Lines deleted
simple_wifi/Makefile 1 1
simple_wifi/main/Kconfig.projbuild 37 0
simple_wifi/main/component.mk 8 0
simple_wifi/main/simple_wifi.c 147 0
simple_wifi/sdkconfig 6 1
File simple_wifi/Makefile copied from file blink/Makefile (similarity 84%) (mode: 100644) (index 6f8b9fa..b9ced39)
3 3 # project subdirectory. # project subdirectory.
4 4 # #
5 5
6 PROJECT_NAME := blink
6 PROJECT_NAME := simple_wifi
7 7
8 8 include $(IDF_PATH)/make/project.mk include $(IDF_PATH)/make/project.mk
9 9
File simple_wifi/main/Kconfig.projbuild added (mode: 100644) (index 0000000..67bb867)
1 menu "Example Configuration"
2
3 choice ESP_WIFI_MODE
4 prompt "AP or STA"
5 default ESP_WIFI_IS_STATION
6 help
7 Whether the esp32 is softAP or station.
8
9 config ESP_WIFI_IS_SOFTAP
10 bool "SoftAP"
11 config ESP_WIFI_IS_STATION
12 bool "Station"
13 endchoice
14
15 config ESP_WIFI_MODE_AP
16 bool
17 default y if ESP_WIFI_IS_SOFTAP
18 default n if ESP_WIFI_IS_STATION
19
20 config ESP_WIFI_SSID
21 string "WiFi SSID"
22 default "myssid"
23 help
24 SSID (network name) for the example to connect to.
25
26 config ESP_WIFI_PASSWORD
27 string "WiFi Password"
28 default "mypassword"
29 help
30 WiFi password (WPA or WPA2) for the example to use.
31
32 config MAX_STA_CONN
33 int "Max STA conn"
34 default 4
35 help
36 Max number of the STA connects to AP.
37 endmenu
File simple_wifi/main/component.mk added (mode: 100644) (index 0000000..61f8990)
1 #
2 # Main component makefile.
3 #
4 # This Makefile can be left empty. By default, it will take the sources in the
5 # src/ directory, compile them and link them into lib(subdirectory_name).a
6 # in the build directory. This behaviour is entirely configurable,
7 # please read the ESP-IDF documents if you need to do this.
8 #
File simple_wifi/main/simple_wifi.c added (mode: 100644) (index 0000000..ccc5590)
1 /* Simple WiFi Example
2
3 This example code is in the Public Domain (or CC0 licensed, at your option.)
4
5 Unless required by applicable law or agreed to in writing, this
6 software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7 CONDITIONS OF ANY KIND, either express or implied.
8 */
9 #include <string.h>
10 #include "freertos/FreeRTOS.h"
11 #include "freertos/task.h"
12 #include "freertos/event_groups.h"
13 #include "esp_system.h"
14 #include "esp_wifi.h"
15 #include "esp_event_loop.h"
16 #include "esp_log.h"
17 #include "nvs_flash.h"
18
19 #include "lwip/err.h"
20 #include "lwip/sys.h"
21
22 /* The examples use simple WiFi configuration that you can set via
23 'make menuconfig'.
24
25 If you'd rather not, just change the below entries to strings with
26 the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid"
27 */
28 #define EXAMPLE_ESP_WIFI_MODE_AP CONFIG_ESP_WIFI_MODE_AP //TRUE:AP FALSE:STA
29 #define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID
30 #define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD
31 #define EXAMPLE_MAX_STA_CONN CONFIG_MAX_STA_CONN
32
33 /* FreeRTOS event group to signal when we are connected*/
34 static EventGroupHandle_t wifi_event_group;
35
36 /* The event group allows multiple bits for each event,
37 but we only care about one event - are we connected
38 to the AP with an IP? */
39 const int WIFI_CONNECTED_BIT = BIT0;
40
41 static const char *TAG = "simple wifi";
42
43 static esp_err_t event_handler(void *ctx, system_event_t *event)
44 {
45 switch(event->event_id) {
46 case SYSTEM_EVENT_STA_START:
47 esp_wifi_connect();
48 break;
49 case SYSTEM_EVENT_STA_GOT_IP:
50 ESP_LOGI(TAG, "got ip:%s",
51 ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip));
52 xEventGroupSetBits(wifi_event_group, WIFI_CONNECTED_BIT);
53 break;
54 case SYSTEM_EVENT_AP_STACONNECTED:
55 ESP_LOGI(TAG, "station:"MACSTR" join, AID=%d",
56 MAC2STR(event->event_info.sta_connected.mac),
57 event->event_info.sta_connected.aid);
58 break;
59 case SYSTEM_EVENT_AP_STADISCONNECTED:
60 ESP_LOGI(TAG, "station:"MACSTR"leave, AID=%d",
61 MAC2STR(event->event_info.sta_disconnected.mac),
62 event->event_info.sta_disconnected.aid);
63 break;
64 case SYSTEM_EVENT_STA_DISCONNECTED:
65 esp_wifi_connect();
66 xEventGroupClearBits(wifi_event_group, WIFI_CONNECTED_BIT);
67 break;
68 default:
69 break;
70 }
71 return ESP_OK;
72 }
73
74 void wifi_init_softap()
75 {
76 wifi_event_group = xEventGroupCreate();
77
78 tcpip_adapter_init();
79 ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL));
80
81 wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
82 ESP_ERROR_CHECK(esp_wifi_init(&cfg));
83 wifi_config_t wifi_config = {
84 .ap = {
85 .ssid = EXAMPLE_ESP_WIFI_SSID,
86 .ssid_len = strlen(EXAMPLE_ESP_WIFI_SSID),
87 .password = EXAMPLE_ESP_WIFI_PASS,
88 .max_connection = EXAMPLE_MAX_STA_CONN,
89 .authmode = WIFI_AUTH_WPA_WPA2_PSK
90 },
91 };
92 if (strlen(EXAMPLE_ESP_WIFI_PASS) == 0) {
93 wifi_config.ap.authmode = WIFI_AUTH_OPEN;
94 }
95
96 ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
97 ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config));
98 ESP_ERROR_CHECK(esp_wifi_start());
99
100 ESP_LOGI(TAG, "wifi_init_softap finished.SSID:%s password:%s",
101 EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
102 }
103
104 void wifi_init_sta()
105 {
106 wifi_event_group = xEventGroupCreate();
107
108 tcpip_adapter_init();
109 ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL) );
110
111 wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
112 ESP_ERROR_CHECK(esp_wifi_init(&cfg));
113 wifi_config_t wifi_config = {
114 .sta = {
115 .ssid = EXAMPLE_ESP_WIFI_SSID,
116 .password = EXAMPLE_ESP_WIFI_PASS
117 },
118 };
119
120 ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
121 ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );
122 ESP_ERROR_CHECK(esp_wifi_start() );
123
124 ESP_LOGI(TAG, "wifi_init_sta finished.");
125 ESP_LOGI(TAG, "connect to ap SSID:%s password:%s",
126 EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
127 }
128
129 void app_main()
130 {
131 //Initialize NVS
132 esp_err_t ret = nvs_flash_init();
133 if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
134 ESP_ERROR_CHECK(nvs_flash_erase());
135 ret = nvs_flash_init();
136 }
137 ESP_ERROR_CHECK(ret);
138
139 #if EXAMPLE_ESP_WIFI_MODE_AP
140 ESP_LOGI(TAG, "ESP_WIFI_MODE_AP");
141 wifi_init_softap();
142 #else
143 ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
144 wifi_init_sta();
145 #endif /*EXAMPLE_ESP_WIFI_MODE_AP*/
146
147 }
File simple_wifi/sdkconfig copied from file blink/sdkconfig (similarity 98%) (mode: 100644) (index 418813c..ca4d2c0)
... ... CONFIG_MONITOR_BAUD=115200
79 79 # #
80 80 # Example Configuration # Example Configuration
81 81 # #
82 CONFIG_BLINK_GPIO=5
82 CONFIG_ESP_WIFI_IS_SOFTAP=
83 CONFIG_ESP_WIFI_IS_STATION=y
84 CONFIG_ESP_WIFI_MODE_AP=
85 CONFIG_ESP_WIFI_SSID="702"
86 CONFIG_ESP_WIFI_PASSWORD="702702702"
87 CONFIG_MAX_STA_CONN=4
83 88
84 89 # #
85 90 # Partition Table # Partition Table
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/zhanzr/esp32_radio_demo

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/zhanzr/esp32_radio_demo

Clone this repository using git:
git clone git://git.rocketgit.com/user/zhanzr/esp32_radio_demo

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main