Skip to content

Commit

Permalink
Networking for ESP32. Refactoring of ESP8266 networking.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Nov 13, 2016
1 parent 0650172 commit 156e0aa
Show file tree
Hide file tree
Showing 53 changed files with 1,420 additions and 376 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ run.log
.TAGS
TAGS
\#*
*.pyc

tst/*/*/sdcard

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ ifeq ($(BOARD), nano32)
TESTS += $(addprefix tst/inet/, http_websocket_client \
http_websocket_server \
inet \
network_interface/wifi_esp \
ping)
endif

Expand Down
2 changes: 1 addition & 1 deletion doc/boards/arduino_due.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Below is the memory usage of two applications:
+==========================+===========+===========+
| minimal-configuration | 21276 | 5472 |
+--------------------------+-----------+-----------+
| default-configuration | 94264 | 11082 |
| default-configuration | 95024 | 11090 |
+--------------------------+-----------+-----------+

Default configuration
Expand Down
2 changes: 1 addition & 1 deletion doc/boards/arduino_mega.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Below is the memory usage of two applications:
+==========================+===========+===========+
| minimal-configuration | 13652 | 1053 |
+--------------------------+-----------+-----------+
| default-configuration | 58134 | 3737 |
| default-configuration | 58954 | 3737 |
+--------------------------+-----------+-----------+

Default configuration
Expand Down
4 changes: 2 additions & 2 deletions doc/boards/cygwin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ Below is the memory usage of two applications:
+--------------------------+-----------+-----------+
| Application | Flash | RAM |
+==========================+===========+===========+
| minimal-configuration | 305967 | 117376 |
| minimal-configuration | 306231 | 117312 |
+--------------------------+-----------+-----------+
| default-configuration | 391087 | 207584 |
| default-configuration | 393047 | 207520 |
+--------------------------+-----------+-----------+

Default configuration
Expand Down
2 changes: 1 addition & 1 deletion doc/boards/esp01.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Below is the memory usage of two applications:
+==========================+===========+===========+
| minimal-configuration | 269288 | 35732 |
+--------------------------+-----------+-----------+
| default-configuration | 313584 | 58980 |
| default-configuration | 313632 | 59824 |
+--------------------------+-----------+-----------+

Default configuration
Expand Down
2 changes: 1 addition & 1 deletion doc/boards/esp12e.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Below is the memory usage of two applications:
+==========================+===========+===========+
| minimal-configuration | 269288 | 35732 |
+--------------------------+-----------+-----------+
| default-configuration | 313584 | 59000 |
| default-configuration | 313632 | 59840 |
+--------------------------+-----------+-----------+

Default configuration
Expand Down
4 changes: 2 additions & 2 deletions doc/boards/linux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ Below is the memory usage of two applications:
+--------------------------+-----------+-----------+
| Application | Flash | RAM |
+==========================+===========+===========+
| minimal-configuration | 305871 | 117376 |
| minimal-configuration | 306103 | 117312 |
+--------------------------+-----------+-----------+
| default-configuration | 391023 | 207584 |
| default-configuration | 392919 | 207520 |
+--------------------------+-----------+-----------+

Default configuration
Expand Down
5 changes: 3 additions & 2 deletions doc/boards/nano32.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Drivers

Supported drivers for this board.

- :doc:`../library-reference/drivers/esp_wifi`
- :doc:`../library-reference/drivers/flash`
- :doc:`../library-reference/drivers/pin`
- :doc:`../library-reference/drivers/uart`
Expand Down Expand Up @@ -54,9 +55,9 @@ Below is the memory usage of two applications:
+--------------------------+-----------+-----------+
| Application | Flash | RAM |
+==========================+===========+===========+
| minimal-configuration | 167997 | 35220 |
| minimal-configuration | 187397 | 38480 |
+--------------------------+-----------+-----------+
| default-configuration | 198661 | 56496 |
| default-configuration | 218189 | 60972 |
+--------------------------+-----------+-----------+

Default configuration
Expand Down
2 changes: 1 addition & 1 deletion doc/boards/photon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Below is the memory usage of two applications:
+==========================+===========+===========+
| minimal-configuration | 16364 | 3360 |
+--------------------------+-----------+-----------+
| default-configuration | 59996 | 6762 |
| default-configuration | 60756 | 6770 |
+--------------------------+-----------+-----------+

Default configuration
Expand Down
2 changes: 1 addition & 1 deletion doc/boards/stm32f3discovery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Below is the memory usage of two applications:
+==========================+===========+===========+
| minimal-configuration | 16088 | 2896 |
+--------------------------+-----------+-----------+
| default-configuration | 58732 | 6254 |
| default-configuration | 59492 | 6262 |
+--------------------------+-----------+-----------+

Default configuration
Expand Down
2 changes: 1 addition & 1 deletion doc/boards/stm32vldiscovery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Below is the memory usage of two applications:
+==========================+===========+===========+
| minimal-configuration | 16796 | 3036 |
+--------------------------+-----------+-----------+
| default-configuration | 59528 | 6314 |
| default-configuration | 60288 | 6322 |
+--------------------------+-----------+-----------+

Default configuration
Expand Down
1 change: 1 addition & 0 deletions doc/developer-guide/testing-suites.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ Nano32
- :github-blob:`inet/http_websocket_client<tst/inet/http_websocket_client/main.c>`
- :github-blob:`inet/http_websocket_server<tst/inet/http_websocket_server/main.c>`
- :github-blob:`inet/inet<tst/inet/inet/main.c>`
- :github-blob:`inet/network_interface/wifi_esp<tst/inet/network_interface/wifi_esp/main.c>`
- :github-blob:`inet/ping<tst/inet/ping/main.c>`

Particle IO Photon
Expand Down
14 changes: 9 additions & 5 deletions make/platformio.sconscript
Original file line number Diff line number Diff line change
Expand Up @@ -1470,11 +1470,11 @@ BOARDS = {
"3pp/esp32/esp-idf/components/freertos/include",
"3pp/esp32/esp-idf/components/nvs_flash/include",
"3pp/esp32/esp-idf/components/spi_flash/include",
"3pp/esp32/esp-idf/components/tcpip_adapter/include",
"3pp/esp32/esp-idf/components/lwip/include/lwip",
"3pp/esp32/esp-idf/components/lwip/include/lwip/port",
"src",
"src/drivers/ports/esp32",
"3pp/lwip-1.4.1/src/include",
"3pp/lwip-1.4.1/src/include/ipv4",
"src/inet",
"src/kernel/ports/esp32/gnu",
"3pp/spiffs-0.3.5/src"
],
Expand All @@ -1491,14 +1491,12 @@ BOARDS = {
"lib": [
"hal",
"core",
"crypto",
"net80211",
"phy",
"pp",
"rtc",
"smartconfig",
"wpa",
"crypto",
"bt",
"driver",
"esp32",
Expand All @@ -1509,10 +1507,12 @@ BOARDS = {
"mbedtls",
"newlib",
"nghttp",
"openssl",
"nvs_flash",
"spi_flash",
"tcpip_adapter",
"vfs",
"wpa_supplicant",
"gcc",
"g",
"c_rom",
Expand Down Expand Up @@ -1540,6 +1540,9 @@ BOARDS = {
"src/debug/log.c",
"src/debug/harness.c",
"src/drivers/flash.c",
"src/drivers/esp_wifi.c",
"src/drivers/esp_wifi/station.c",
"src/drivers/esp_wifi/softap.c",
"src/drivers/pin.c",
"src/drivers/uart.c",
"src/encode/base64.c",
Expand All @@ -1556,6 +1559,7 @@ BOARDS = {
"src/inet/network_interface/wifi.c",
"src/inet/socket.c",
"src/inet/ping.c",
"src/inet/network_interface/driver/esp.c",
"src/kernel/sys.c",
"src/kernel/thrd.c",
"src/kernel/time.c",
Expand Down
24 changes: 14 additions & 10 deletions src/drivers/esp_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* @section License
*
* The MIT License (MIT)
*
*
* Copyright (c) 2014-2016, Erik Moqvist
*
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
Expand All @@ -30,7 +30,7 @@

#include "simba.h"

#include "espressif/esp_wifi.h"
#include "esp_wifi_port.i"

struct module_t {
int initialized;
Expand All @@ -39,7 +39,7 @@ struct module_t {
#endif
};

struct module_t module;
static struct module_t module;

#if CONFIG_FS_CMD_ESP_WIFI_STATUS == 1

Expand Down Expand Up @@ -76,27 +76,27 @@ int esp_wifi_module_init(void)

#endif

return (0);
return (esp_wifi_port_module_init());
}

int esp_wifi_set_op_mode(enum esp_wifi_op_mode_t mode)
{
return (!wifi_set_opmode_current(mode));
return (esp_wifi_port_set_op_mode(mode));
}

enum esp_wifi_op_mode_t esp_wifi_get_op_mode()
{
return (wifi_get_opmode());
return (esp_wifi_port_get_op_mode());
}

int esp_wifi_set_phy_mode(enum esp_wifi_phy_mode_t mode)
{
return (!wifi_set_phy_mode(mode));
return (esp_wifi_port_set_phy_mode(mode));
}

enum esp_wifi_phy_mode_t esp_wifi_get_phy_mode()
{
return (wifi_get_phy_mode());
return (esp_wifi_port_get_phy_mode());
}

void esp_wifi_print(void *chout_p)
Expand All @@ -105,6 +105,7 @@ void esp_wifi_print(void *chout_p)

int i;
int number_of_infos;
int number_of_connections;
struct esp_wifi_softap_station_info_t info[4];
struct inet_if_ip_info_t ip_info;
char buf[16];
Expand Down Expand Up @@ -181,7 +182,9 @@ void esp_wifi_print(void *chout_p)
op_mode_p,
phy_mode_p);

memset(&ip_info, 0, sizeof(ip_info));
esp_wifi_softap_get_ip_info(&ip_info);
number_of_connections = esp_wifi_softap_get_number_of_connected_stations();
number_of_infos = esp_wifi_softap_get_station_info(info,
membersof(info));

Expand All @@ -200,7 +203,7 @@ void esp_wifi_print(void *chout_p)
FSTR(" Gateway: %s\r\n"
" Number of connections: %d\r\n"),
inet_ntoa(&ip_info.gateway, &buf[0]),
number_of_infos);
number_of_connections);

for (i = 0; i < number_of_infos; i++) {
std_fprintf(chout_p,
Expand Down Expand Up @@ -264,6 +267,7 @@ void esp_wifi_print(void *chout_p)
break;
}

memset(&ip_info, 0, sizeof(ip_info));
esp_wifi_station_get_ip_info(&ip_info);

std_fprintf(chout_p,
Expand Down
7 changes: 4 additions & 3 deletions src/drivers/esp_wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ enum esp_wifi_dhcp_status_t {
int esp_wifi_module_init(void);

/**
* Set the WiFi operating mode to Station, SoftAP or Station +
* Set the WiFi operating mode to None, Station, SoftAP or Station +
* SoftAP. The default mode is SoftAP.
*
* @param[in] mode Operating mode to set.
Expand All @@ -83,9 +83,10 @@ int esp_wifi_module_init(void);
int esp_wifi_set_op_mode(enum esp_wifi_op_mode_t mode);

/**
* Get the current WiFi operating mode.
* Get the current WiFi operating mode. The operating mode can be
* None, Station, SoftAP, or Station + SoftAP.
*
* @return Operating mode.
* @return Current operating mode.
*/
enum esp_wifi_op_mode_t esp_wifi_get_op_mode(void);

Expand Down
Loading

0 comments on commit 156e0aa

Please sign in to comment.