forked from espressif/arduino-esp32
Initial Commit
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
#include <functional>
|
||||
extern "C" {
|
||||
#include "lwip/ip_addr.h"
|
||||
#include <tcpip_adapter.h>
|
||||
#include "esp_netif.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
}
|
||||
|
@ -51,9 +51,9 @@ License (MIT license):
|
||||
#define STR(tok) tok
|
||||
#endif
|
||||
|
||||
static void _on_sys_event(system_event_t *event){
|
||||
mdns_handle_system_event(NULL, event);
|
||||
}
|
||||
// static void _on_sys_event(system_event_t *event){
|
||||
// mdns_handle_system_event(NULL, event);
|
||||
// }
|
||||
|
||||
MDNSResponder::MDNSResponder() :results(NULL) {}
|
||||
MDNSResponder::~MDNSResponder() {
|
||||
@ -65,7 +65,7 @@ bool MDNSResponder::begin(const char* hostName){
|
||||
log_e("Failed starting MDNS");
|
||||
return false;
|
||||
}
|
||||
WiFi.onEvent(_on_sys_event);
|
||||
//WiFi.onEvent(_on_sys_event);
|
||||
_hostname = hostName;
|
||||
_hostname.toLowerCase();
|
||||
if(mdns_hostname_set(hostName)) {
|
||||
@ -173,7 +173,7 @@ bool MDNSResponder::addServiceTxt(char *name, char *proto, char *key, char *valu
|
||||
}
|
||||
|
||||
IPAddress MDNSResponder::queryHost(char *host, uint32_t timeout){
|
||||
struct ip4_addr addr;
|
||||
esp_ip4_addr_t addr;
|
||||
addr.addr = 0;
|
||||
|
||||
esp_err_t err = mdns_query_a(host, timeout, &addr);
|
||||
|
@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "SD_MMC.h"
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32S2 //SDMMC does not work on ESP32S2
|
||||
#include "vfs_api.h"
|
||||
|
||||
extern "C" {
|
||||
@ -24,7 +26,6 @@ extern "C" {
|
||||
#include "sdmmc_cmd.h"
|
||||
}
|
||||
#include "ff.h"
|
||||
#include "SD_MMC.h"
|
||||
|
||||
using namespace fs;
|
||||
/*
|
||||
@ -145,3 +146,4 @@ uint64_t SDMMCFS::usedBytes()
|
||||
}
|
||||
|
||||
SDMMCFS SD_MMC = SDMMCFS(FSImplPtr(new VFSImpl()));
|
||||
#endif /* CONFIG_IDF_TARGET_ESP32 */
|
||||
|
@ -14,6 +14,9 @@
|
||||
#ifndef _SDMMC_H_
|
||||
#define _SDMMC_H_
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32S2
|
||||
|
||||
#include "FS.h"
|
||||
#include "driver/sdmmc_types.h"
|
||||
#include "sd_defines.h"
|
||||
@ -40,4 +43,5 @@ public:
|
||||
|
||||
extern fs::SDMMCFS SD_MMC;
|
||||
|
||||
#endif /* CONFIG_IDF_TARGET_ESP32S2 */
|
||||
#endif /* _SDMMC_H_ */
|
||||
|
@ -50,10 +50,17 @@ void SPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss)
|
||||
}
|
||||
|
||||
if(sck == -1 && miso == -1 && mosi == -1 && ss == -1) {
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
_sck = (_spi_num == FSPI) ? SCK : -1;
|
||||
_miso = (_spi_num == FSPI) ? MISO : -1;
|
||||
_mosi = (_spi_num == FSPI) ? MOSI : -1;
|
||||
_ss = (_spi_num == FSPI) ? SS : -1;
|
||||
#else
|
||||
_sck = (_spi_num == VSPI) ? SCK : 14;
|
||||
_miso = (_spi_num == VSPI) ? MISO : 12;
|
||||
_mosi = (_spi_num == VSPI) ? MOSI : 13;
|
||||
_ss = (_spi_num == VSPI) ? SS : 15;
|
||||
#endif
|
||||
} else {
|
||||
_sck = sck;
|
||||
_miso = miso;
|
||||
@ -292,4 +299,9 @@ void SPIClass::writePattern_(const uint8_t * data, uint8_t size, uint8_t repeat)
|
||||
writeBytes(&buffer[0], bytes);
|
||||
}
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
SPIClass SPI(VSPI);
|
||||
#else
|
||||
SPIClass SPI(FSPI);
|
||||
#endif
|
||||
|
||||
|
@ -147,17 +147,19 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
|
||||
esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, eth_event_handler, this);
|
||||
//ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &got_ip_event_handler, NULL));
|
||||
|
||||
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
||||
mac_config.smi_mdc_gpio_num = mdc;
|
||||
mac_config.smi_mdio_gpio_num = mdio;
|
||||
//mac_config.sw_reset_timeout_ms = 1000;
|
||||
esp_eth_mac_t *eth_mac = NULL;
|
||||
#if CONFIG_ETH_SPI_ETHERNET_DM9051
|
||||
if(type == ETH_PHY_DM9051){
|
||||
return false;//todo
|
||||
} else {
|
||||
#endif
|
||||
#if CONFIG_ETH_USE_ESP32_EMAC
|
||||
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
||||
mac_config.smi_mdc_gpio_num = mdc;
|
||||
mac_config.smi_mdio_gpio_num = mdio;
|
||||
//mac_config.sw_reset_timeout_ms = 1000;
|
||||
eth_mac = esp_eth_mac_new_esp32(&mac_config);
|
||||
#endif
|
||||
#if CONFIG_ETH_SPI_ETHERNET_DM9051
|
||||
}
|
||||
#endif
|
||||
|
@ -32,7 +32,7 @@ extern "C" {
|
||||
#include <string.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_event_loop.h>
|
||||
#include <esp_event.h>
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,7 +35,7 @@ extern "C" {
|
||||
#include <string.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_event_loop.h>
|
||||
#include <esp_event.h>
|
||||
#include <lwip/ip_addr.h>
|
||||
#include "dhcpserver/dhcpserver_options.h"
|
||||
}
|
||||
@ -166,8 +166,8 @@ bool WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress
|
||||
lease.end_ip.addr = static_cast<uint32_t>(local_ip) + (11 << 24);
|
||||
|
||||
tcpip_adapter_dhcps_option(
|
||||
(tcpip_adapter_option_mode_t)TCPIP_ADAPTER_OP_SET,
|
||||
(tcpip_adapter_option_id_t)REQUESTED_IP_ADDRESS,
|
||||
(tcpip_adapter_dhcp_option_mode_t)TCPIP_ADAPTER_OP_SET,
|
||||
(tcpip_adapter_dhcp_option_id_t)REQUESTED_IP_ADDRESS,
|
||||
(void*)&lease, sizeof(dhcps_lease_t)
|
||||
);
|
||||
|
||||
|
@ -35,7 +35,7 @@ extern "C" {
|
||||
|
||||
#include <esp_err.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_event_loop.h>
|
||||
#include <esp_event.h>
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/err.h"
|
||||
@ -79,19 +79,19 @@ static void _network_event_task(void * arg){
|
||||
_network_event_task_handle = NULL;
|
||||
}
|
||||
|
||||
static esp_err_t _network_event_cb(void *arg, system_event_t *event){
|
||||
system_prov_event_t *sys_prov_data = (system_prov_event_t *)malloc(sizeof(system_prov_event_t));
|
||||
if(sys_prov_data == NULL) {
|
||||
return ESP_FAIL;
|
||||
static void _network_event_cb(void* arg, esp_event_base_t base, int32_t id, void* data) {
|
||||
if (xQueueSend(_network_event_queue, (system_event_t *)data, portMAX_DELAY) != pdPASS) {
|
||||
log_w("Network Event Queue Send Failed!");
|
||||
}
|
||||
sys_prov_data->sys_event = event;
|
||||
sys_prov_data->prov_event = NULL;
|
||||
if (postToSysQueue(sys_prov_data) != ESP_OK){
|
||||
free(sys_prov_data);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
// static esp_err_t _network_event_cb(void *arg, system_event_t *event){
|
||||
// if (xQueueSend(_network_event_queue, event, portMAX_DELAY) != pdPASS) {
|
||||
// log_w("Network Event Queue Send Failed!");
|
||||
// return ESP_FAIL;
|
||||
// }
|
||||
// return ESP_OK;
|
||||
// }
|
||||
ESP_EVENT_DEFINE_BASE(SYSTEM_EVENT);
|
||||
|
||||
static bool _start_network_event_task(){
|
||||
if(!_network_event_group){
|
||||
@ -116,7 +116,14 @@ static bool _start_network_event_task(){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return esp_event_loop_init(&_network_event_cb, NULL) == ESP_OK;
|
||||
|
||||
esp_err_t err = esp_event_loop_create_default();
|
||||
if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return esp_event_handler_register(SYSTEM_EVENT, ESP_EVENT_ANY_ID, _network_event_cb, NULL) == ESP_OK;
|
||||
//return esp_event_loop_init(&_network_event_cb, NULL) == ESP_OK;
|
||||
}
|
||||
|
||||
void tcpipInit(){
|
||||
@ -130,7 +137,7 @@ void tcpipInit(){
|
||||
}
|
||||
esp_event_loop_create_default();
|
||||
#endif
|
||||
tcpip_adapter_init();
|
||||
esp_netif_init();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#define ESP32WIFIGENERIC_H_
|
||||
|
||||
#include <esp_err.h>
|
||||
#include <esp_event_loop.h>
|
||||
#include <esp_event.h>
|
||||
#include <functional>
|
||||
#include "WiFiType.h"
|
||||
#include "IPAddress.h"
|
||||
|
@ -35,13 +35,13 @@ extern "C" {
|
||||
#include <string.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_event_loop.h>
|
||||
#include <esp_event.h>
|
||||
#include <esp32-hal.h>
|
||||
#include <lwip/ip_addr.h>
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/dns.h"
|
||||
#include <esp_smartconfig.h>
|
||||
#include <tcpip_adapter.h>
|
||||
#include <esp_netif.h>
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -36,7 +36,7 @@ extern "C" {
|
||||
#include <string.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_event_loop.h>
|
||||
#include <esp_event.h>
|
||||
#include <esp32-hal.h>
|
||||
#include <lwip/ip_addr.h>
|
||||
#include "lwip/err.h"
|
||||
|
Reference in New Issue
Block a user