Initial IDF-4.0 port

SmartConfig and ETH need some work to adapt to the new API
This commit is contained in:
me-no-dev
2020-01-25 05:44:14 +02:00
parent be4d3b6cb8
commit 1bf59ac227
48 changed files with 401 additions and 267 deletions

View File

@ -23,9 +23,9 @@ if [ ! -d "$ARDUINO_ESP32_PATH" ]; then
git clone https://github.com/espressif/arduino-esp32.git esp32 > /dev/null 2>&1
fi
echo "Updating Submodules ..."
#echo "Updating Submodules ..."
cd esp32
git submodule update --init --recursive > /dev/null 2>&1
#git submodule update --init --recursive > /dev/null 2>&1
echo "Installing Platform Tools ..."
cd tools && python get.py

View File

@ -30,8 +30,8 @@ elif [ "$CHUNK_INDEX" -eq "$CHUNKS_CNT" ]; then
BUILD_PIO=1
fi
echo "Updating submodules ..."
git -C "$GITHUB_WORKSPACE" submodule update --init --recursive > /dev/null 2>&1
#echo "Updating submodules ..."
#git -C "$GITHUB_WORKSPACE" submodule update --init --recursive > /dev/null 2>&1
if [ "$BUILD_PIO" -eq 0 ]; then
# ArduinoIDE Test
@ -41,14 +41,12 @@ if [ "$BUILD_PIO" -eq 0 ]; then
if [ "$OS_IS_WINDOWS" == "1" ]; then
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino" && \
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/BLE/examples/BLE_server/BLE_server.ino" && \
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/AzureIoT/examples/GetStarted/GetStarted.ino" && \
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino"
elif [ "$OS_IS_MACOS" == "1" ]; then
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/WiFi/examples/WiFiClient/WiFiClient.ino" && \
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino" && \
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino" && \
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/BLE/examples/BLE_server/BLE_server.ino" && \
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/AzureIoT/examples/GetStarted/GetStarted.ino" && \
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino"
else
# CMake Test
@ -65,7 +63,6 @@ else
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino" && \
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino" && \
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/BLE/examples/BLE_server/BLE_server.ino" && \
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/AzureIoT/examples/GetStarted/GetStarted.ino" && \
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino"
#build_pio_sketches esp32dev "$PLATFORMIO_ESP32_PATH/libraries"
fi

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "libraries/AzureIoT"]
path = libraries/AzureIoT
url = https://github.com/VSChina/ESP32_AzureIoT_Arduino

View File

@ -80,66 +80,6 @@ set(LIBRARY_SRCS
libraries/Wire/src/Wire.cpp
)
set(AZURE_SRCS
libraries/AzureIoT/src/az_iot/azureiotcerts.c
libraries/AzureIoT/src/az_iot/c-utility/pal/agenttime.c
libraries/AzureIoT/src/az_iot/c-utility/pal/dns_async.c
libraries/AzureIoT/src/az_iot/c-utility/pal/freertos/lock.c
libraries/AzureIoT/src/az_iot/c-utility/pal/freertos/threadapi.c
libraries/AzureIoT/src/az_iot/c-utility/pal/freertos/tickcounter.c
libraries/AzureIoT/src/az_iot/c-utility/pal/lwip/sntp_lwip.c
libraries/AzureIoT/src/az_iot/c-utility/pal/socket_async.c
libraries/AzureIoT/src/az_iot/c-utility/pal/src/platform_openssl_compact.c
libraries/AzureIoT/src/az_iot/c-utility/pal/src/tlsio_openssl_compact.c
libraries/AzureIoT/src/az_iot/c-utility/pal/tlsio_options.c
libraries/AzureIoT/src/az_iot/c-utility/src/base64.c
libraries/AzureIoT/src/az_iot/c-utility/src/buffer.c
libraries/AzureIoT/src/az_iot/c-utility/src/connection_string_parser.c
libraries/AzureIoT/src/az_iot/c-utility/src/consolelogger.c
libraries/AzureIoT/src/az_iot/c-utility/src/constbuffer.c
libraries/AzureIoT/src/az_iot/c-utility/src/constmap.c
libraries/AzureIoT/src/az_iot/c-utility/src/crt_abstractions.c
libraries/AzureIoT/src/az_iot/c-utility/src/doublylinkedlist.c
libraries/AzureIoT/src/az_iot/c-utility/src/gballoc.c
libraries/AzureIoT/src/az_iot/c-utility/src/gb_stdio.c
libraries/AzureIoT/src/az_iot/c-utility/src/gb_time.c
libraries/AzureIoT/src/az_iot/c-utility/src/hmac.c
libraries/AzureIoT/src/az_iot/c-utility/src/hmacsha256.c
libraries/AzureIoT/src/az_iot/c-utility/src/httpapiex.c
libraries/AzureIoT/src/az_iot/c-utility/src/httpapiexsas.c
libraries/AzureIoT/src/az_iot/c-utility/src/httpheaders.c
libraries/AzureIoT/src/az_iot/c-utility/src/http_proxy_io.c
libraries/AzureIoT/src/az_iot/c-utility/src/map.c
libraries/AzureIoT/src/az_iot/c-utility/src/optionhandler.c
libraries/AzureIoT/src/az_iot/c-utility/src/sastoken.c
libraries/AzureIoT/src/az_iot/c-utility/src/sha1.c
libraries/AzureIoT/src/az_iot/c-utility/src/sha224.c
libraries/AzureIoT/src/az_iot/c-utility/src/sha384-512.c
libraries/AzureIoT/src/az_iot/c-utility/src/singlylinkedlist.c
libraries/AzureIoT/src/az_iot/c-utility/src/strings.c
libraries/AzureIoT/src/az_iot/c-utility/src/string_tokenizer.c
libraries/AzureIoT/src/az_iot/c-utility/src/urlencode.c
libraries/AzureIoT/src/az_iot/c-utility/src/usha.c
libraries/AzureIoT/src/az_iot/c-utility/src/vector.c
libraries/AzureIoT/src/az_iot/c-utility/src/xio.c
libraries/AzureIoT/src/az_iot/c-utility/src/xlogging.c
libraries/AzureIoT/src/az_iot/iothub_client/src/blob.c
libraries/AzureIoT/src/az_iot/iothub_client/src/iothub_client_authorization.c
libraries/AzureIoT/src/az_iot/iothub_client/src/iothub_client.c
libraries/AzureIoT/src/az_iot/iothub_client/src/iothub_client_ll.c
libraries/AzureIoT/src/az_iot/iothub_client/src/iothub_client_retry_control.c
libraries/AzureIoT/src/az_iot/iothub_client/src/iothub_message.c
libraries/AzureIoT/src/az_iot/iothub_client/src/iothubtransport.c
libraries/AzureIoT/src/az_iot/iothub_client/src/iothubtransportmqtt.c
libraries/AzureIoT/src/az_iot/iothub_client/src/iothubtransport_mqtt_common.c
libraries/AzureIoT/src/az_iot/iothub_client/src/version.c
libraries/AzureIoT/src/az_iot/umqtt/src/mqtt_client.c
libraries/AzureIoT/src/az_iot/umqtt/src/mqtt_codec.c
libraries/AzureIoT/src/az_iot/umqtt/src/mqtt_message.c
libraries/AzureIoT/src/AzureIotHub.cpp
libraries/AzureIoT/src/Esp32MQTTClient.cpp
)
set(BLE_SRCS
libraries/BLE/src/BLE2902.cpp
libraries/BLE/src/BLE2904.cpp
@ -172,7 +112,7 @@ set(BLE_SRCS
libraries/BLE/src/GeneralUtils.cpp
)
set(COMPONENT_SRCS ${CORE_SRCS} ${LIBRARY_SRCS} ${AZURE_SRCS} ${BLE_SRCS})
set(COMPONENT_SRCS ${CORE_SRCS} ${LIBRARY_SRCS} ${BLE_SRCS})
set(COMPONENT_ADD_INCLUDEDIRS
variants/esp32/

View File

@ -118,7 +118,9 @@ typedef unsigned int word;
void setup(void);
void loop(void);
#ifdef __cplusplus
long random(long, long);
#endif
void randomSeed(unsigned long);
long map(long, long, long, long, long);

View File

@ -19,7 +19,6 @@
#include "Arduino.h"
#include "Esp.h"
#include "rom/spi_flash.h"
#include "esp_sleep.h"
#include "esp_spi_flash.h"
#include <memory>
@ -32,6 +31,17 @@ extern "C" {
}
#include <MD5Builder.h>
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/spi_flash.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/spi_flash.h"
#endif
/**
* User-defined Literals
* usage:

View File

@ -21,7 +21,17 @@
#include <WString.h>
#include <Stream.h>
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/md5_hash.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/md5_hash.h"
#endif
class MD5Builder
{

View File

@ -15,9 +15,7 @@
#include "esp32-hal-adc.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "rom/ets_sys.h"
#include "esp_attr.h"
#include "esp_intr.h"
#include "soc/rtc_io_reg.h"
#include "soc/rtc_cntl_reg.h"
#include "soc/sens_reg.h"
@ -25,6 +23,19 @@
#include "driver/adc.h"
#include "esp_adc_cal.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/ets_sys.h"
#include "esp_intr_alloc.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#include "esp_intr.h"
#endif
#define DEFAULT_VREF 1100
static esp_adc_cal_characteristics_t *__analogCharacteristics[2] = {NULL, NULL};
static uint8_t __analogAttenuation = 3;//11db

View File

@ -21,12 +21,22 @@
#include "esp_log.h"
#include "soc/rtc.h"
#include "soc/rtc_cntl_reg.h"
#include "rom/rtc.h"
#include "soc/apb_ctrl_reg.h"
#include "soc/efuse_reg.h"
#include "esp32-hal.h"
#include "esp32-hal-cpu.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/rtc.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/rtc.h"
#endif
typedef struct apb_change_cb_s {
struct apb_change_cb_s * prev;
struct apb_change_cb_s * next;

View File

@ -15,13 +15,24 @@
#include "esp32-hal-dac.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "rom/ets_sys.h"
#include "esp_attr.h"
#include "esp_intr.h"
#include "soc/rtc_io_reg.h"
#include "soc/rtc_cntl_reg.h"
#include "soc/sens_reg.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/ets_sys.h"
#include "esp_intr_alloc.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#include "esp_intr.h"
#endif
void IRAM_ATTR __dacWrite(uint8_t pin, uint8_t value)
{
if(pin < 25 || pin > 26){

View File

@ -15,15 +15,27 @@
#include "esp32-hal-gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "rom/ets_sys.h"
#include "esp_attr.h"
#include "esp_intr.h"
#include "rom/gpio.h"
#include "soc/gpio_reg.h"
#include "soc/io_mux_reg.h"
#include "soc/gpio_struct.h"
#include "soc/rtc_io_reg.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/ets_sys.h"
#include "esp32/rom/gpio.h"
#include "esp_intr_alloc.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#include "rom/gpio.h"
#include "esp_intr.h"
#endif
const int8_t esp32_adc2gpio[20] = {36, 37, 38, 39, 32, 33, 34, 35, -1, -1, 4, 0, 2, 15, 13, 12, 14, 27, 25, 26};
const DRAM_ATTR esp32_gpioMux_t esp32_gpioMux[GPIO_PIN_COUNT]={

View File

@ -18,13 +18,25 @@
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "freertos/event_groups.h"
#include "rom/ets_sys.h"
#include "driver/periph_ctrl.h"
#include "soc/i2c_reg.h"
#include "soc/i2c_struct.h"
#include "soc/dport_reg.h"
#include "esp_attr.h"
#include "esp32-hal-cpu.h" // cpu clock change support 31DEC2018
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/ets_sys.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#endif
//#define I2C_DEV(i) (volatile i2c_dev_t *)((i)?DR_REG_I2C1_EXT_BASE:DR_REG_I2C_EXT_BASE)
//#define I2C_DEV(i) ((i2c_dev_t *)(REG_I2C_BASE(i)))
#define I2C_SCL_IDX(p) ((p==0)?I2CEXT0_SCL_OUT_IDX:((p==1)?I2CEXT1_SCL_OUT_IDX:0))

View File

@ -16,12 +16,22 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "rom/ets_sys.h"
#include "esp32-hal-matrix.h"
#include "soc/dport_reg.h"
#include "soc/ledc_reg.h"
#include "soc/ledc_struct.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/ets_sys.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#endif
#if CONFIG_DISABLE_HAL_LOCKS
#define LEDC_MUTEX_LOCK()
#define LEDC_MUTEX_UNLOCK()

View File

@ -14,7 +14,17 @@
#include "esp32-hal-matrix.h"
#include "esp_attr.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/gpio.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/gpio.h"
#endif
#define MATRIX_DETACH_OUT_SIG 0x100
#define MATRIX_DETACH_IN_LOW_PIN 0x30

View File

@ -31,10 +31,20 @@
#include "soc/rtc.h"
#include "soc/rtc_cntl_reg.h"
#include "soc/apb_ctrl_reg.h"
#include "rom/rtc.h"
#include "esp_task_wdt.h"
#include "esp32-hal.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/rtc.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/rtc.h"
#endif
//Undocumented!!! Get chip temperature in Farenheit
//Source: https://github.com/pcbreflux/espressif/blob/master/esp32/arduino/sketchbook/ESP32_int_temp_sensor/ESP32_int_temp_sensor.ino
uint8_t temprature_sens_read();

View File

@ -1,11 +1,34 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "esp32-hal.h"
#if CONFIG_SPIRAM_SUPPORT
#include "esp_spiram.h"
#include "soc/efuse_reg.h"
#include "esp_heap_caps.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/spiram.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "esp_spiram.h"
#endif
static volatile bool spiramDetected = false;
static volatile bool spiramFailed = false;

View File

@ -241,7 +241,6 @@ bool rmtLoop(rmt_obj_t* rmt, rmt_data_t* data, size_t size)
return false;
}
int channel = rmt->channel;
int allocated_size = MAX_DATA_PER_CHANNEL * rmt->buffers;
if (size > allocated_size) {

View File

@ -16,11 +16,21 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "rom/ets_sys.h"
#include "esp32-hal-matrix.h"
#include "soc/gpio_sd_reg.h"
#include "soc/gpio_sd_struct.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/ets_sys.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#endif
#if CONFIG_DISABLE_HAL_LOCKS
#define SD_MUTEX_LOCK()

View File

@ -17,10 +17,7 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "rom/ets_sys.h"
#include "esp_attr.h"
#include "esp_intr.h"
#include "rom/gpio.h"
#include "soc/spi_reg.h"
#include "soc/spi_struct.h"
#include "soc/io_mux_reg.h"
@ -28,6 +25,21 @@
#include "soc/dport_reg.h"
#include "soc/rtc.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/ets_sys.h"
#include "esp32/rom/gpio.h"
#include "esp_intr_alloc.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#include "rom/gpio.h"
#include "esp_intr.h"
#endif
#define SPI_CLK_IDX(p) ((p==0)?SPICLK_OUT_IDX:((p==1)?SPICLK_OUT_IDX:((p==2)?HSPICLK_OUT_IDX:((p==3)?VSPICLK_OUT_IDX:0))))
#define SPI_MISO_IDX(p) ((p==0)?SPIQ_OUT_IDX:((p==1)?SPIQ_OUT_IDX:((p==2)?HSPIQ_OUT_IDX:((p==3)?VSPIQ_OUT_IDX:0))))
#define SPI_MOSI_IDX(p) ((p==0)?SPID_IN_IDX:((p==1)?SPID_IN_IDX:((p==2)?HSPID_IN_IDX:((p==3)?VSPID_IN_IDX:0))))
@ -428,14 +440,14 @@ spi_t * spiStartBus(uint8_t spi_num, uint32_t clockDiv, uint8_t dataMode, uint8_
#endif
if(spi_num == HSPI) {
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI_CLK_EN);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI_RST);
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI2_CLK_EN);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI2_RST);
} else if(spi_num == VSPI) {
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI_CLK_EN_2);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI_RST_2);
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI3_CLK_EN);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI3_RST);
} else {
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI_CLK_EN_1);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI_RST_1);
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI01_CLK_EN);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI01_RST);
}
SPI_MUTEX_LOCK();

View File

@ -16,11 +16,22 @@
#include "freertos/FreeRTOS.h"
#include "freertos/xtensa_api.h"
#include "freertos/task.h"
#include "rom/ets_sys.h"
#include "soc/timer_group_struct.h"
#include "soc/dport_reg.h"
#include "esp_attr.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/ets_sys.h"
#include "esp_intr_alloc.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#include "esp_intr.h"
#endif
#define HWTIMER_LOCK() portENTER_CRITICAL(timer->lock)
#define HWTIMER_UNLOCK() portEXIT_CRITICAL(timer->lock)

View File

@ -15,13 +15,24 @@
#include "esp32-hal-touch.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "rom/ets_sys.h"
#include "esp_attr.h"
#include "esp_intr.h"
#include "soc/rtc_io_reg.h"
#include "soc/rtc_cntl_reg.h"
#include "soc/sens_reg.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/ets_sys.h"
#include "esp_intr_alloc.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#include "esp_intr.h"
#endif
static uint16_t __touchSleepCycles = 0x1000;
static uint16_t __touchMeasureCycles = 0x1000;

View File

@ -18,10 +18,7 @@
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "rom/ets_sys.h"
#include "esp_attr.h"
#include "esp_intr.h"
#include "rom/uart.h"
#include "soc/uart_reg.h"
#include "soc/uart_struct.h"
#include "soc/io_mux_reg.h"
@ -30,6 +27,20 @@
#include "soc/rtc.h"
#include "esp_intr_alloc.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/ets_sys.h"
#include "esp32/rom/uart.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/ets_sys.h"
#include "rom/uart.h"
#include "esp_intr.h"
#endif
#define UART_REG_BASE(u) ((u==0)?DR_REG_UART_BASE:( (u==1)?DR_REG_UART1_BASE:( (u==2)?DR_REG_UART2_BASE:0)))
#define UART_RXD_IDX(u) ((u==0)?U0RXD_IN_IDX:( (u==1)?U1RXD_IN_IDX:( (u==2)?U2RXD_IN_IDX:0)))
#define UART_TXD_IDX(u) ((u==0)?U0TXD_OUT_IDX:( (u==1)?U1TXD_OUT_IDX:( (u==2)?U2TXD_OUT_IDX:0)))
@ -258,7 +269,7 @@ size_t uartResizeRxBuffer(uart_t * uart, size_t new_size) {
uart->queue = xQueueCreate(new_size, sizeof(uint8_t));
if(uart->queue == NULL) {
UART_MUTEX_UNLOCK();
return NULL;
return 0;
}
}
UART_MUTEX_UNLOCK();

View File

@ -34,6 +34,7 @@ extern "C" {
#include <math.h>
#include "sdkconfig.h"
#include "esp_system.h"
#include "esp_sleep.h"
#ifndef F_CPU
#define F_CPU (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000U)

View File

@ -547,7 +547,7 @@ std::string BLEAdvertisedDevice::toString() {
}
}
if (haveTXPower()) {
char val[4];
char val[6];
snprintf(val, sizeof(val), "%d", getTXPower());
res += ", txPower: ";
res += val;

View File

@ -499,7 +499,11 @@ gatts_event_handler BLEDevice::m_customGattsHandler = nullptr;
*/
void BLEDevice::whiteListAdd(BLEAddress address) {
log_v(">> whiteListAdd: %s", address.toString().c_str());
esp_err_t errRc = esp_ble_gap_update_whitelist(true, *address.getNative()); // True to add an entry.
#ifdef ESP_IDF_VERSION_MAJOR
esp_err_t errRc = esp_ble_gap_update_whitelist(true, *address.getNative(), BLE_WL_ADDR_TYPE_PUBLIC); // HACK!!! True to add an entry.
#else
esp_err_t errRc = esp_ble_gap_update_whitelist(true, *address.getNative()); // True to add an entry.
#endif
if (errRc != ESP_OK) {
log_e("esp_ble_gap_update_whitelist: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
}
@ -513,7 +517,11 @@ void BLEDevice::whiteListAdd(BLEAddress address) {
*/
void BLEDevice::whiteListRemove(BLEAddress address) {
log_v(">> whiteListRemove: %s", address.toString().c_str());
esp_err_t errRc = esp_ble_gap_update_whitelist(false, *address.getNative()); // False to remove an entry.
#ifdef ESP_IDF_VERSION_MAJOR
esp_err_t errRc = esp_ble_gap_update_whitelist(false, *address.getNative(), BLE_WL_ADDR_TYPE_PUBLIC); // HACK!!! False to remove an entry.
#else
esp_err_t errRc = esp_ble_gap_update_whitelist(false, *address.getNative()); // False to remove an entry.
#endif
if (errRc != ESP_OK) {
log_e("esp_ble_gap_update_whitelist: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
}

View File

@ -34,7 +34,7 @@ public:
BLERemoteCharacteristic* getCharacteristic(uint16_t uuid); // Get the specified characteristic reference.
std::map<std::string, BLERemoteCharacteristic*>* getCharacteristics();
std::map<uint16_t, BLERemoteCharacteristic*>* getCharacteristicsByHandle(); // Get the characteristics map.
void getCharacteristics(std::map<uint16_t, BLERemoteCharacteristic*>* pCharacteristicMap);
void getCharacteristics(std::map<uint16_t, BLERemoteCharacteristic*>** pCharacteristicMap);
BLEClient* getClient(void); // Get a reference to the client associated with this service.
uint16_t getHandle(); // Get the handle of this service.

View File

@ -257,7 +257,12 @@ void FreeRTOS::Semaphore::setName(std::string name) {
* @param [in] length The amount of storage to allocate for the ring buffer.
* @param [in] type The type of buffer. One of RINGBUF_TYPE_NOSPLIT, RINGBUF_TYPE_ALLOWSPLIT, RINGBUF_TYPE_BYTEBUF.
*/
Ringbuffer::Ringbuffer(size_t length, ringbuf_type_t type) {
#ifdef ESP_IDF_VERSION_MAJOR
Ringbuffer::Ringbuffer(size_t length, RingbufferType_t type)
#else
Ringbuffer::Ringbuffer(size_t length, ringbuf_type_t type)
#endif
{
m_handle = ::xRingbufferCreate(length, type);
} // Ringbuffer

View File

@ -60,7 +60,11 @@ public:
*/
class Ringbuffer {
public:
Ringbuffer(size_t length, ringbuf_type_t type = RINGBUF_TYPE_NOSPLIT);
#ifdef ESP_IDF_VERSION_MAJOR
Ringbuffer(size_t length, RingbufferType_t type = RINGBUF_TYPE_NOSPLIT);
#else
Ringbuffer(size_t length, ringbuf_type_t type = RINGBUF_TYPE_NOSPLIT);
#endif
~Ringbuffer();
void* receive(size_t* size, TickType_t wait = portMAX_DELAY);

View File

@ -14,7 +14,7 @@ String MACadd = "AA:BB:CC:11:22:33";
uint8_t address[6] = {0xAA, 0xBB, 0xCC, 0x11, 0x22, 0x33};
//uint8_t address[6] = {0x00, 0x1D, 0xA5, 0x02, 0xC3, 0x22};
String name = "OBDII";
char *pin = "1234"; //<- standard pin would be provided by default
const char *pin = "1234"; //<- standard pin would be provided by default
bool connected;
void setup() {

View File

@ -223,7 +223,11 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
{
case ESP_SPP_INIT_EVT:
log_i("ESP_SPP_INIT_EVT");
#ifdef ESP_IDF_VERSION_MAJOR
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
#else
esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
#endif
if (!_isMaster) {
log_i("ESP_SPP_INIT_EVT: slave: start");
esp_spp_start_srv(ESP_SPP_SEC_NONE, ESP_SPP_ROLE_SLAVE, 0, _spp_server_name);
@ -717,7 +721,11 @@ bool BluetoothSerial::connect(String remoteName)
_remote_name[ESP_BT_GAP_MAX_BDNAME_LEN] = 0;
log_i("master : remoteName");
// will first resolve name to address
esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
#ifdef ESP_IDF_VERSION_MAJOR
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
#else
esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
#endif
if (esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, INQ_LEN, INQ_NUM_RSPS) == ESP_OK) {
return waitForConnect(SCAN_TIMEOUT);
}
@ -757,7 +765,11 @@ bool BluetoothSerial::connect()
disconnect();
log_i("master : remoteName");
// will resolve name to address first - it may take a while
#ifdef ESP_IDF_VERSION_MAJOR
esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
#else
esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
#endif
if (esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, INQ_LEN, INQ_NUM_RSPS) == ESP_OK) {
return waitForConnect(SCAN_TIMEOUT);
}

View File

@ -53,10 +53,10 @@ void setup() {
Serial.println("------------------------------------\n");
// Clear variables
name = '\0';
rname[0] = '\0';
height = 0;
age = 0;
Serial.print("name: "); Serial.println(name);
Serial.print("name: "); Serial.println(rname);
Serial.print("height: "); Serial.println(height);
Serial.print("age: "); Serial.println(age);
Serial.println("------------------------------------\n");

View File

@ -56,11 +56,11 @@ static ra_filter_t ra_filter;
httpd_handle_t stream_httpd = NULL;
httpd_handle_t camera_httpd = NULL;
static mtmn_config_t mtmn_config = {0};
static mtmn_config_t mtmn_config;
static int8_t detection_enabled = 0;
static int8_t recognition_enabled = 0;
static int8_t is_enrolling = 0;
static face_id_list id_list = {0};
static face_id_list id_list;
static ra_filter_t * ra_filter_init(ra_filter_t * filter, size_t sample_size){
memset(filter, 0, sizeof(ra_filter_t));

View File

@ -12,7 +12,15 @@
* Evandro Luis Copercini - 2017
*/
#include <rom/rtc.h>
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "esp32/rom/rtc.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "rom/rtc.h"
#endif
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */

View File

@ -45,8 +45,7 @@ void setup() {
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide identity
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide username --> identity and username is same
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)); //provide password
esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT(); //set config settings to default
esp_wifi_sta_wpa2_ent_enable(&config); //set config settings to enable function
esp_wifi_sta_wpa2_ent_enable();
WiFi.begin(ssid); //connect to wifi
while (WiFi.status() != WL_CONNECTED) {
delay(500);

View File

@ -12,10 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "sd_diskio.h"
#include "esp_system.h"
extern "C" {
#include "diskio.h"
#include "ffconf.h"
#include "ff.h"
#include "diskio.h"
#ifdef ESP_IDF_VERSION_MAJOR
#include "diskio_impl.h"
#endif
//#include "esp_vfs.h"
#include "esp_vfs_fat.h"
char CRC7(const char* data, int length);

View File

@ -1,103 +0,0 @@
/*
This sketch shows how to configure different external or internal clock sources for the Ethernet PHY
*/
#include <ETH.h>
/*
* ETH_CLOCK_GPIO0_IN - default: external clock from crystal oscillator
* ETH_CLOCK_GPIO0_OUT - 50MHz clock from internal APLL output on GPIO0 - possibly an inverter is needed for LAN8720
* ETH_CLOCK_GPIO16_OUT - 50MHz clock from internal APLL output on GPIO16 - possibly an inverter is needed for LAN8720
* ETH_CLOCK_GPIO17_OUT - 50MHz clock from internal APLL inverted output on GPIO17 - tested with LAN8720
*/
#ifdef ETH_CLK_MODE
#undef ETH_CLK_MODE
#endif
#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
// Pin# of the enable signal for the external crystal oscillator (-1 to disable for internal APLL source)
#define ETH_POWER_PIN -1
// Type of the Ethernet PHY (LAN8720 or TLK110)
#define ETH_TYPE ETH_PHY_LAN8720
// I²C-address of Ethernet PHY (0 or 1 for LAN8720, 31 for TLK110)
#define ETH_ADDR 0
// Pin# of the I²C clock signal for the Ethernet PHY
#define ETH_MDC_PIN 15
// Pin# of the I²C IO signal for the Ethernet PHY
#define ETH_MDIO_PIN 2
static bool eth_connected = false;
void WiFiEvent(WiFiEvent_t event) {
switch (event) {
case SYSTEM_EVENT_ETH_START:
Serial.println("ETH Started");
//set eth hostname here
ETH.setHostname("esp32-ethernet");
break;
case SYSTEM_EVENT_ETH_CONNECTED:
Serial.println("ETH Connected");
break;
case SYSTEM_EVENT_ETH_GOT_IP:
Serial.print("ETH MAC: ");
Serial.print(ETH.macAddress());
Serial.print(", IPv4: ");
Serial.print(ETH.localIP());
if (ETH.fullDuplex()) {
Serial.print(", FULL_DUPLEX");
}
Serial.print(", ");
Serial.print(ETH.linkSpeed());
Serial.println("Mbps");
eth_connected = true;
break;
case SYSTEM_EVENT_ETH_DISCONNECTED:
Serial.println("ETH Disconnected");
eth_connected = false;
break;
case SYSTEM_EVENT_ETH_STOP:
Serial.println("ETH Stopped");
eth_connected = false;
break;
default:
break;
}
}
void testClient(const char * host, uint16_t port) {
Serial.print("\nconnecting to ");
Serial.println(host);
WiFiClient client;
if (!client.connect(host, port)) {
Serial.println("connection failed");
return;
}
client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
while (client.connected() && !client.available());
while (client.available()) {
Serial.write(client.read());
}
Serial.println("closing connection\n");
client.stop();
}
void setup() {
Serial.begin(115200);
WiFi.onEvent(WiFiEvent);
ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK_MODE);
}
void loop() {
if (eth_connected) {
testClient("google.com", 80);
}
delay(10000);
}

View File

@ -31,7 +31,6 @@ WPS
static esp_wps_config_t config;
void wpsInitConfig(){
config.crypto_funcs = &g_wifi_default_wps_crypto_funcs;
config.wps_type = ESP_WPS_MODE;
strcpy(config.factory_info.manufacturer, ESP_MANUFACTURER);
strcpy(config.factory_info.model_number, ESP_MODEL_NUMBER);

View File

@ -16,8 +16,7 @@ void setup() {
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide identity
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide username --> identity and username is same
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)); //provide password
esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT(); //set config settings to default
esp_wifi_sta_wpa2_ent_enable(&config); //set config settings to enable function
esp_wifi_sta_wpa2_ent_enable();
WiFi.begin(ssid); //connect to wifi
while (WiFi.status() != WL_CONNECTED) {
delay(500);

View File

@ -19,14 +19,21 @@
*/
#include "ETH.h"
#include "eth_phy/phy.h"
#include "eth_phy/phy_tlk110.h"
#include "eth_phy/phy_lan8720.h"
#include "esp_system.h"
#ifdef ESP_IDF_VERSION_MAJOR
#include "esp_eth.h"
#include "esp_eth_phy.h"
#else
#include "eth_phy/phy.h"
#include "eth_phy/phy_tlk110.h"
#include "eth_phy/phy_lan8720.h"
#endif
#include "lwip/err.h"
#include "lwip/dns.h"
extern void tcpipInit();
#ifndef ESP_IDF_VERSION_MAJOR
static int _eth_phy_mdc_pin = -1;
static int _eth_phy_mdio_pin = -1;
static int _eth_phy_power_pin = -1;
@ -48,6 +55,7 @@ static void _eth_phy_power_enable(bool enable)
digitalWrite(_eth_phy_power_pin, enable);
delay(1);
}
#endif
ETHClass::ETHClass():initialized(false),started(false),staticIP(false)
{
@ -56,6 +64,11 @@ ETHClass::ETHClass():initialized(false),started(false),staticIP(false)
ETHClass::~ETHClass()
{}
#ifdef ESP_IDF_VERSION_MAJOR
bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_type_t type){
return false;
}
#else
bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_type_t type, eth_clock_mode_t clock_mode)
{
esp_err_t err;
@ -108,6 +121,7 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
}
return false;
}
#endif
bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2)
{
@ -240,17 +254,29 @@ bool ETHClass::setHostname(const char * hostname)
bool ETHClass::fullDuplex()
{
#ifdef ESP_IDF_VERSION_MAJOR
return true;//todo
#else
return eth_config.phy_get_duplex_mode();
#endif
}
bool ETHClass::linkUp()
{
#ifdef ESP_IDF_VERSION_MAJOR
return true;//todo
#else
return eth_config.phy_check_link();
#endif
}
uint8_t ETHClass::linkSpeed()
{
#ifdef ESP_IDF_VERSION_MAJOR
return 100;//ToDo
#else
return eth_config.phy_get_speed_mode()?100:10;
#endif
}
bool ETHClass::enableIpV6()
@ -272,15 +298,23 @@ uint8_t * macAddress(uint8_t* mac)
if(!mac){
return NULL;
}
#ifdef ESP_IDF_VERSION_MAJOR
//ToDo
#else
esp_eth_get_mac(mac);
#endif
return mac;
}
String ETHClass::macAddress(void)
{
uint8_t mac[6];
uint8_t mac[6] = {0,0,0,0,0,0};//ToDo
char macStr[18] = { 0 };
#ifdef ESP_IDF_VERSION_MAJOR
//ToDo
#else
esp_eth_get_mac(mac);
#endif
sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return String(macStr);
}

View File

@ -22,6 +22,7 @@
#define _ETH_H_
#include "WiFi.h"
#include "esp_system.h"
#include "esp_eth.h"
#ifndef ETH_PHY_ADDR
@ -45,8 +46,12 @@
#endif
#ifndef ETH_CLK_MODE
#ifdef ESP_IDF_VERSION_MAJOR
#define ETH_CLK_MODE ESP_ETH_CLOCK_GPIO0_IN
#else
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_IN
#endif
#endif
typedef enum { ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_MAX } eth_phy_type_t;
@ -55,13 +60,21 @@ class ETHClass {
bool initialized;
bool started;
bool staticIP;
#ifdef ESP_IDF_VERSION_MAJOR
esp_eth_config_t eth_config;
#else
eth_config_t eth_config;
#endif
public:
ETHClass();
~ETHClass();
#ifdef ESP_IDF_VERSION_MAJOR
bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, eth_phy_type_t type=ETH_PHY_TYPE);
#else
bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE);
#endif
bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
const char * getHostname();

View File

@ -46,7 +46,11 @@ private:
return 0;
}
int count;
#ifdef ESP_IDF_VERSION_MAJOR
int res = lwip_ioctl(_fd, FIONREAD, &count);
#else
int res = lwip_ioctl_r(_fd, FIONREAD, &count);
#endif
if(res < 0) {
_failed = true;
return 0;
@ -227,7 +231,11 @@ int WiFiClient::connect(IPAddress ip, uint16_t port, int32_t timeout)
tv.tv_sec = 0;
tv.tv_usec = timeout * 1000;
#ifdef ESP_IDF_VERSION_MAJOR
int res = lwip_connect(sockfd, (struct sockaddr*)&serveraddr, sizeof(serveraddr));
#else
int res = lwip_connect_r(sockfd, (struct sockaddr*)&serveraddr, sizeof(serveraddr));
#endif
if (res < 0 && errno != EINPROGRESS) {
log_e("connect on fd %d, errno: %d, \"%s\"", sockfd, errno, strerror(errno));
close(sockfd);

View File

@ -687,7 +687,12 @@ bool WiFiSTAClass::beginSmartConfig() {
esp_wifi_disconnect();
esp_err_t err;
#ifdef ESP_IDF_VERSION_MAJOR
smartconfig_start_config_t conf = SMARTCONFIG_START_CONFIG_DEFAULT();
err = esp_smartconfig_start(&conf);
#else
err = esp_smartconfig_start(reinterpret_cast<sc_callback_t>(&WiFiSTAClass::_smartConfigCallback), 1);
#endif
if (err == ESP_OK) {
_smartConfigStarted = true;
_smartConfigDone = false;
@ -734,6 +739,7 @@ const char * sc_type_strings[] = {
#endif
void WiFiSTAClass::_smartConfigCallback(uint32_t st, void* result) {
#ifndef ESP_IDF_VERSION_MAJOR //todo
smartconfig_status_t status = (smartconfig_status_t) st;
log_d("Status: %s", sc_status_strings[st % 5]);
if (status == SC_STATUS_GETTING_SSID_PSWD) {
@ -757,4 +763,5 @@ void WiFiSTAClass::_smartConfigCallback(uint32_t st, void* result) {
}
WiFi.stopSmartConfig();
}
#endif
}

View File

@ -49,7 +49,11 @@ WiFiClient WiFiServer::available(){
else {
struct sockaddr_in _client;
int cs = sizeof(struct sockaddr_in);
#ifdef ESP_IDF_VERSION_MAJOR
client_sock = lwip_accept(sockfd, (struct sockaddr *)&_client, (socklen_t*)&cs);
#else
client_sock = lwip_accept_r(sockfd, (struct sockaddr *)&_client, (socklen_t*)&cs);
#endif
}
if(client_sock >= 0){
int val = 1;
@ -99,7 +103,11 @@ bool WiFiServer::hasClient() {
}
struct sockaddr_in _client;
int cs = sizeof(struct sockaddr_in);
#ifdef ESP_IDF_VERSION_MAJOR
_accepted_sockfd = lwip_accept(sockfd, (struct sockaddr *)&_client, (socklen_t*)&cs);
#else
_accepted_sockfd = lwip_accept_r(sockfd, (struct sockaddr *)&_client, (socklen_t*)&cs);
#endif
if (_accepted_sockfd >= 0) {
return true;
}
@ -107,7 +115,11 @@ bool WiFiServer::hasClient() {
}
void WiFiServer::end(){
#ifdef ESP_IDF_VERSION_MAJOR
lwip_close(sockfd);
#else
lwip_close_r(sockfd);
#endif
sockfd = -1;
_listening = false;
}

View File

@ -61,8 +61,7 @@ void setup() {
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_ANONYMOUS_IDENTITY, strlen(EAP_ANONYMOUS_IDENTITY)); //provide identity
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide username
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)); //provide password
esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT();
esp_wifi_sta_wpa2_ent_enable(&config);
esp_wifi_sta_wpa2_ent_enable();
WiFi.begin(ssid); //connect to wifi
while (WiFi.status() != WL_CONNECTED) {
delay(500);

View File

@ -54,49 +54,42 @@
"tools": [
{
"name": "xtensa-esp32-elf-gcc",
"version": "1.22.0-96-g2852398-5.2.0",
"version": "gcc8_2_0-esp-2019r2",
"systems": [
{
"host": "i686-mingw32",
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-96-g2852398-5.2.0.zip",
"archiveFileName": "xtensa-esp32-elf-win32-1.22.0-96-g2852398-5.2.0.zip",
"checksum": "SHA-256:8e2a2e25d4714ae6e4b992be1b1c261caed5b523b0cc0887b6749229c9febbb0",
"size": "125810912"
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-win32.zip",
"archiveFileName": "xtensa-esp32-elf-gcc8_2_0-esp-2019r2-win32.zip",
"checksum": "SHA-256:c9d5776a22516f0825a7c68d835ffacc2392f913136893b7646e1288937cc65e",
"size": "103850448"
},
{
"host": "x86_64-apple-darwin",
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-macos-1.22.0-96-g2852398-5.2.0.tar.gz",
"archiveFileName": "xtensa-esp32-elf-macos-1.22.0-96-g2852398-5.2.0.tar.gz",
"checksum": "SHA-256:6aeae9547f0cd7e442d1df21821cea8b15d0a6ce349bbd86466e2997b738a99c",
"size": "50520203"
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-macos.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_2_0-esp-2019r2-macos.tar.gz",
"checksum": "SHA-256:dc62be8dd16c6d9d28d64e2b3f831fa208f3548c2ca73cdbcbdf68f474d59521",
"size": "92150978"
},
{
"host": "x86_64-pc-linux-gnu",
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-96-g2852398-5.2.0.tar.gz",
"archiveFileName": "xtensa-esp32-elf-linux64-1.22.0-96-g2852398-5.2.0.tar.gz",
"checksum": "SHA-256:798a8638f11ad37f41b9640582f869c61ffb4da6d932279fde94a2b636ad2dac",
"size": "44211883"
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-amd64.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-amd64.tar.gz",
"checksum": "SHA-256:e6d47c1dbd8c8cbfe37271e5e2aac53ee88c9e347ae937e22bf0c73f530efbdf",
"size": "85459985"
},
{
"host": "i686-pc-linux-gnu",
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux32-1.22.0-96-g2852398-5.2.0.tar.gz",
"archiveFileName": "xtensa-esp32-elf-linux32-1.22.0-96-g2852398-5.2.0.tar.gz",
"checksum": "SHA-256:4eea601188aa8f3c3d45d7936ab4c0fabb75b4970dccf7a061de47dba49e377f",
"size": "45563578"
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-i686.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-i686.tar.gz",
"checksum": "SHA-256:36a9648c414dbd1c518c687ce5587d9f8eaa94324f45d92e9ec31a1433a04df8",
"size": "87438500"
},
{
"host": "arm-linux-gnueabihf",
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux-armel-1.22.0-96-g2852398-5.2.0.tar.gz",
"archiveFileName": "xtensa-esp32-elf-linux-armel-1.22.0-96-g2852398-5.2.0.tar.gz",
"checksum": "SHA-256:abfe06522f7c3479f6c7434c4bf926c50fa2039362b96abe95fa1f05ec519a9b",
"size": "50670980"
},
{
"host": "aarch64-linux-gnu",
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux-armel-1.22.0-96-g2852398-5.2.0.tar.gz",
"archiveFileName": "xtensa-esp32-elf-linux-armel-1.22.0-96-g2852398-5.2.0.tar.gz",
"checksum": "SHA-256:abfe06522f7c3479f6c7434c4bf926c50fa2039362b96abe95fa1f05ec519a9b",
"size": "50670980"
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-armel.tar.gz",
"archiveFileName": "xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-armel.tar.gz",
"checksum": "SHA-256:54a199c28f591da2466b21741911bc2ba77ddf82d3d2b66c6ce03c1a0c6835f0",
"size": "83647538"
}
]
},

View File

@ -25,10 +25,10 @@ compiler.sdk.path={runtime.platform.path}/tools/sdk
compiler.cpreprocessor.flags=-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DHAVE_CONFIG_H -DGCC_NOT_5_2_0=0 -DWITH_POSIX "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/app_trace" "-I{compiler.sdk.path}/include/app_update" "-I{compiler.sdk.path}/include/asio" "-I{compiler.sdk.path}/include/bootloader_support" "-I{compiler.sdk.path}/include/bt" "-I{compiler.sdk.path}/include/coap" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/driver" "-I{compiler.sdk.path}/include/efuse" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp32" "-I{compiler.sdk.path}/include/esp_adc_cal" "-I{compiler.sdk.path}/include/esp_event" "-I{compiler.sdk.path}/include/esp_http_client" "-I{compiler.sdk.path}/include/esp_http_server" "-I{compiler.sdk.path}/include/esp_https_ota" "-I{compiler.sdk.path}/include/esp_https_server" "-I{compiler.sdk.path}/include/esp_ringbuf" "-I{compiler.sdk.path}/include/esp_websocket_client" "-I{compiler.sdk.path}/include/espcoredump" "-I{compiler.sdk.path}/include/ethernet" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/fatfs" "-I{compiler.sdk.path}/include/freemodbus" "-I{compiler.sdk.path}/include/freertos" "-I{compiler.sdk.path}/include/heap" "-I{compiler.sdk.path}/include/idf_test" "-I{compiler.sdk.path}/include/jsmn" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/libsodium" "-I{compiler.sdk.path}/include/log" "-I{compiler.sdk.path}/include/lwip" "-I{compiler.sdk.path}/include/mbedtls" "-I{compiler.sdk.path}/include/mdns" "-I{compiler.sdk.path}/include/micro-ecc" "-I{compiler.sdk.path}/include/mqtt" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/nimble" "-I{compiler.sdk.path}/include/nvs_flash" "-I{compiler.sdk.path}/include/openssl" "-I{compiler.sdk.path}/include/protobuf-c" "-I{compiler.sdk.path}/include/protocomm" "-I{compiler.sdk.path}/include/pthread" "-I{compiler.sdk.path}/include/sdmmc" "-I{compiler.sdk.path}/include/smartconfig_ack" "-I{compiler.sdk.path}/include/soc" "-I{compiler.sdk.path}/include/spi_flash" "-I{compiler.sdk.path}/include/spiffs" "-I{compiler.sdk.path}/include/tcp_transport" "-I{compiler.sdk.path}/include/tcpip_adapter" "-I{compiler.sdk.path}/include/ulp" "-I{compiler.sdk.path}/include/unity" "-I{compiler.sdk.path}/include/vfs" "-I{compiler.sdk.path}/include/wear_levelling" "-I{compiler.sdk.path}/include/wifi_provisioning" "-I{compiler.sdk.path}/include/wpa_supplicant" "-I{compiler.sdk.path}/include/xtensa-debug-module" "-I{compiler.sdk.path}/include/esp-face" "-I{compiler.sdk.path}/include/esp32-camera" "-I{compiler.sdk.path}/include/esp-face" "-I{compiler.sdk.path}/include/fb_gfx"
compiler.c.cmd=xtensa-esp32-elf-gcc
compiler.c.flags=-std=gnu99 -Os -g3 -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wpointer-arith {compiler.warning_flags} -Wno-maybe-uninitialized -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-variable -Wno-deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -Wno-old-style-declaration -MMD -c
compiler.c.flags=-std=gnu99 -Os -g3 -Wno-frame-address -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -fstack-protector {compiler.warning_flags} -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wwrite-strings -Wno-old-style-declaration -Wno-implicit-fallthrough -mfix-esp32-psram-cache-issue -MMD -c
compiler.cpp.cmd=xtensa-esp32-elf-g++
compiler.cpp.flags=-std=gnu++11 -Os -g3 -Wpointer-arith -fexceptions -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib {compiler.warning_flags} -Wno-error=maybe-uninitialized -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-missing-field-initializers -Wno-sign-compare -fno-rtti -MMD -c
compiler.cpp.flags=-std=gnu++11 -Os -g3 -Wno-frame-address -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -fstack-protector {compiler.warning_flags} -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wwrite-strings -fexceptions -fno-rtti -mfix-esp32-psram-cache-issue -MMD -c
compiler.S.cmd=xtensa-esp32-elf-gcc
compiler.S.flags=-c -g3 -x assembler-with-cpp -MMD -mlongcalls

View File

@ -39,7 +39,8 @@ env.Append(
CFLAGS=[
"-std=gnu99",
"-Wno-old-style-declaration"
"-Wno-old-style-declaration",
"-Wno-implicit-fallthrough"
],
CCFLAGS=[
@ -58,9 +59,13 @@ env.Append(
"-Wno-error=unused-function",
"-Wno-unused-parameter",
"-Wno-sign-compare",
"-Wno-frame-address",
"-Wwrite-strings",
"-mfix-esp32-psram-cache-issue",
"-fstack-protector",
"-fexceptions",
"-Werror=reorder"
"-Werror=reorder",
"-MMD"
],
CXXFLAGS=[
@ -76,14 +81,21 @@ env.Append(
"-Wl,--undefined=uxTopUsedPriority",
"-Wl,--gc-sections",
"-Wl,-EL",
"-T", "esp32_out.ld",
"-T", "esp32.project.ld",
"-T", "esp32.rom.ld",
"-T", "esp32.peripherals.ld",
"-T", "esp32.rom.ld",
"-T", "esp32.rom.libgcc.ld",
"-T", "esp32.rom.spiram_incompatible_fns.ld",
"-T", "esp32.rom.syscalls.ld",
"-T", "esp32.rom.newlib-data.ld",
"-u", "ld_include_panic_highint_hdl",
"-u", "__cxa_guard_dummy",
"-u", "__cxx_fatal_exception"
"-u", "newlib_include_locks_impl",
"-u", "newlib_include_heap_impl",
"-u", "newlib_include_syscalls_impl",
"-u", "pthread_include_pthread_impl",
"-u", "pthread_include_pthread_cond_impl",
"-u", "pthread_include_pthread_local_storage_impl"
],
CPPDEFINES=[
@ -91,6 +103,8 @@ env.Append(
"ESP_PLATFORM",
("F_CPU", "$BOARD_F_CPU"),
"HAVE_CONFIG_H",
"_GNU_SOURCE",
("GCC_NOT_5_2_0", 1),
("MBEDTLS_CONFIG_FILE", '\\"mbedtls/esp_config.h\\"'),
("ARDUINO", 10805),
"ARDUINO_ARCH_ESP32",