forked from nkolban/esp32-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kolban
committed
Dec 24, 2016
1 parent
3670639
commit b232989
Showing
7 changed files
with
215 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#The ESP FS | ||
A fantastic project by Mr SpriteTM can be found here: | ||
|
||
[https://github.com/Spritetm/libesphttpd/tree/master/espfs](https://github.com/Spritetm/libesphttpd/tree/master/espfs) | ||
|
||
This provides an ESP File System that is read only and stored on flash. | ||
|
||
Here, you will find a copy of those core files that have been massaged to utilize ESP32 technologies. | ||
Primarily, we use flash memory mapping to access the data as opposed to individual flash reads. In addition, | ||
and the primary intent, a new method was added with the signature: | ||
|
||
``` | ||
int espFsAccess(EspFsFile *fh, char *buf, size_t *len) | ||
``` | ||
|
||
This function returns a pointer to the whole content of the file which is stored in buf. The | ||
length of the file is stored in len and also returned from the function as a whole. | ||
The data is accessed directly from flash without any RAM copies. | ||
In addition, the function called: | ||
|
||
``` | ||
EspFsInitResult espFsInit(void *flashAddress, size_t size) | ||
``` | ||
|
||
was augmented to include the size of the flash storage to map. | ||
|
||
For full details and background, see the following thread on the ESP32 forum: | ||
|
||
[http://esp32.com/viewtopic.php?f=13&t=698](http://esp32.com/viewtopic.php?f=13&t=698) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Test being an access point. When we run this app, watch the console and look | ||
* for a message of the form: | ||
* | ||
* event: SYSTEM_EVENT_AP_START | ||
* | ||
* This means that we have started being an access point. | ||
* | ||
* Now connect your WiFi client device (phone/PC) and we should see a message: | ||
* | ||
* event: SYSTEM_EVENT_AP_STACONNECTED, mac:7c:dd:90:9e:b5:62, aid:1 | ||
* | ||
* This says that we have now connected. | ||
* | ||
*/ | ||
#include <esp_event.h> | ||
#include <esp_event_loop.h> | ||
#include <esp_log.h> | ||
#include <esp_system.h> | ||
#include <esp_wifi.h> | ||
#include <freertos/FreeRTOS.h> | ||
#include <nvs_flash.h> | ||
|
||
//static char tag[] = "access-point"; | ||
|
||
/** | ||
* An ESP32 WiFi event handler. | ||
* The types of events that can be received here are: | ||
* | ||
* SYSTEM_EVENT_AP_PROBEREQRECVED | ||
* SYSTEM_EVENT_AP_STACONNECTED | ||
* SYSTEM_EVENT_AP_STADISCONNECTED | ||
* SYSTEM_EVENT_AP_START | ||
* SYSTEM_EVENT_AP_STOP | ||
* SYSTEM_EVENT_SCAN_DONE | ||
* SYSTEM_EVENT_STA_AUTHMODE_CHANGE | ||
* SYSTEM_EVENT_STA_CONNECTED | ||
* SYSTEM_EVENT_STA_DISCONNECTED | ||
* SYSTEM_EVENT_STA_GOT_IP | ||
* SYSTEM_EVENT_STA_START | ||
* SYSTEM_EVENT_STA_STOP | ||
* SYSTEM_EVENT_WIFI_READY | ||
*/ | ||
esp_err_t esp32_wifi_eventHandler(void *ctx, system_event_t *event) { | ||
// Your event handling code here... | ||
return ESP_OK; | ||
} | ||
|
||
void access_point_task(void *ignore) { | ||
nvs_flash_init(); | ||
tcpip_adapter_init(); | ||
ESP_ERROR_CHECK( esp_event_loop_init(esp32_wifi_eventHandler, NULL) ); | ||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); | ||
ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); | ||
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); | ||
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_AP) ); | ||
wifi_config_t apConfig = { | ||
.ap = { | ||
.ssid="ESP32_TESTAP", | ||
.ssid_len=0, | ||
.password="", | ||
.channel=0, | ||
.authmode=WIFI_AUTH_OPEN, | ||
.ssid_hidden=0, | ||
.max_connection=4, | ||
.beacon_interval=100 | ||
} | ||
}; | ||
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_AP, &apConfig) ); | ||
ESP_ERROR_CHECK( esp_wifi_start() ); | ||
vTaskDelete(NULL); | ||
} |