mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-06-25 18:01:33 +02:00
Compare commits
89 Commits
1.0.4
...
idf-releas
Author | SHA1 | Date | |
---|---|---|---|
d011dd7ef5 | |||
475208e535 | |||
2bf655b658 | |||
2fbbae762b | |||
d2761a9eab | |||
8c8d8610f4 | |||
c2da05050e | |||
3746ef9df9 | |||
92eb1a2264 | |||
b47b0dc966 | |||
2271c7726d | |||
9afee31462 | |||
f15a6ac205 | |||
176077b133 | |||
60f20a7869 | |||
8817e536fd | |||
d1e3122d87 | |||
856e596c79 | |||
2a88f72c4e | |||
354e485c4b | |||
5d9a22eb3a | |||
1c4966566c | |||
4bb60f68da | |||
a9fa894f0d | |||
251d5ef92b | |||
41ba143063 | |||
8c723be135 | |||
b50a1755c8 | |||
bb0a194bb7 | |||
ed59ae6482 | |||
b4a9684a74 | |||
1977370e6f | |||
307b1368dd | |||
32d5654aa6 | |||
7637a739cc | |||
cd85239252 | |||
ac9d04a400 | |||
2195109ecc | |||
8d938c849d | |||
cb005fc8b5 | |||
89351e3ade | |||
86de90fe24 | |||
5960cd3e2a | |||
82e208c8c9 | |||
e7c9813625 | |||
dd78794311 | |||
0607d36734 | |||
6e77f7f3e5 | |||
915d45de7d | |||
c2b37d95e0 | |||
2f13a960ac | |||
579e04be25 | |||
5443d7ca93 | |||
7b3c1dfd50 | |||
85ef51ffbc | |||
36075257c2 | |||
7de1717640 | |||
8869d39d79 | |||
cfe8526ec8 | |||
c09ec5bd3d | |||
d8b2098461 | |||
3fc974f3aa | |||
9ad860758c | |||
cec3fca4ad | |||
dac493fb92 | |||
bc3d11364f | |||
f41beb92bf | |||
8c4ca5a235 | |||
b3085d4a8b | |||
547c2d3346 | |||
7d2632c024 | |||
e59355df71 | |||
ec63d09e54 | |||
188560e7f3 | |||
91e095f5a7 | |||
c8d8dc2265 | |||
b847f41e24 | |||
611ba8ea8a | |||
0cab2483e6 | |||
79e4339582 | |||
a35035f827 | |||
9ef3e2d2a6 | |||
0cdfb0b193 | |||
e50613622e | |||
24b277ad92 | |||
c2b3f2d6af | |||
8fb8e7d060 | |||
048b26547a | |||
b10ed77aaf |
@ -23,9 +23,9 @@ if [ ! -d "$ARDUINO_ESP32_PATH" ]; then
|
|||||||
git clone https://github.com/espressif/arduino-esp32.git esp32 > /dev/null 2>&1
|
git clone https://github.com/espressif/arduino-esp32.git esp32 > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Updating Submodules ..."
|
#echo "Updating Submodules ..."
|
||||||
cd esp32
|
cd esp32
|
||||||
git submodule update --init --recursive > /dev/null 2>&1
|
#git submodule update --init --recursive > /dev/null 2>&1
|
||||||
|
|
||||||
echo "Installing Platform Tools ..."
|
echo "Installing Platform Tools ..."
|
||||||
cd tools && python get.py
|
cd tools && python get.py
|
||||||
|
3
.github/scripts/install-arduino-ide.sh
vendored
3
.github/scripts/install-arduino-ide.sh
vendored
@ -40,6 +40,9 @@ ARDUINO_CACHE_DIR="$HOME/.arduino/cache.tmp"
|
|||||||
if [ "$OS_IS_MACOS" == "1" ]; then
|
if [ "$OS_IS_MACOS" == "1" ]; then
|
||||||
export ARDUINO_IDE_PATH="/Applications/Arduino.app/Contents/Java"
|
export ARDUINO_IDE_PATH="/Applications/Arduino.app/Contents/Java"
|
||||||
export ARDUINO_USR_PATH="$HOME/Documents/Arduino"
|
export ARDUINO_USR_PATH="$HOME/Documents/Arduino"
|
||||||
|
elif [ "$OS_IS_WINDOWS" == "1" ]; then
|
||||||
|
export ARDUINO_IDE_PATH="$HOME/arduino_ide"
|
||||||
|
export ARDUINO_USR_PATH="$HOME/Documents/Arduino"
|
||||||
else
|
else
|
||||||
export ARDUINO_IDE_PATH="$HOME/arduino_ide"
|
export ARDUINO_IDE_PATH="$HOME/arduino_ide"
|
||||||
export ARDUINO_USR_PATH="$HOME/Arduino"
|
export ARDUINO_USR_PATH="$HOME/Arduino"
|
||||||
|
7
.github/scripts/on-push.sh
vendored
7
.github/scripts/on-push.sh
vendored
@ -30,8 +30,8 @@ elif [ "$CHUNK_INDEX" -eq "$CHUNKS_CNT" ]; then
|
|||||||
BUILD_PIO=1
|
BUILD_PIO=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Updating submodules ..."
|
#echo "Updating submodules ..."
|
||||||
git -C "$GITHUB_WORKSPACE" submodule update --init --recursive > /dev/null 2>&1
|
#git -C "$GITHUB_WORKSPACE" submodule update --init --recursive > /dev/null 2>&1
|
||||||
|
|
||||||
if [ "$BUILD_PIO" -eq 0 ]; then
|
if [ "$BUILD_PIO" -eq 0 ]; then
|
||||||
# ArduinoIDE Test
|
# ArduinoIDE Test
|
||||||
@ -41,14 +41,12 @@ if [ "$BUILD_PIO" -eq 0 ]; then
|
|||||||
if [ "$OS_IS_WINDOWS" == "1" ]; 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/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/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"
|
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino"
|
||||||
elif [ "$OS_IS_MACOS" == "1" ]; then
|
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/WiFi/examples/WiFiClient/WiFiClient.ino" && \
|
||||||
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.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/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/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"
|
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino"
|
||||||
else
|
else
|
||||||
# CMake Test
|
# 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/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/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/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_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino"
|
||||||
#build_pio_sketches esp32dev "$PLATFORMIO_ESP32_PATH/libraries"
|
#build_pio_sketches esp32dev "$PLATFORMIO_ESP32_PATH/libraries"
|
||||||
fi
|
fi
|
||||||
|
9
.github/workflows/push.yml
vendored
9
.github/workflows/push.yml
vendored
@ -19,6 +19,9 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
- uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
- name: Build Sketches
|
- name: Build Sketches
|
||||||
run: bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} 15
|
run: bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} 15
|
||||||
|
|
||||||
@ -32,6 +35,9 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
- uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
- name: Build Sketches
|
- name: Build Sketches
|
||||||
run: bash ./.github/scripts/on-push.sh
|
run: bash ./.github/scripts/on-push.sh
|
||||||
|
|
||||||
@ -45,5 +51,8 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
- uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
- name: Build Sketches
|
- name: Build Sketches
|
||||||
run: bash ./.github/scripts/on-push.sh 1 1 #equal and non-zero to trigger PIO
|
run: bash ./.github/scripts/on-push.sh 1 1 #equal and non-zero to trigger PIO
|
||||||
|
3
.github/workflows/release.yml
vendored
3
.github/workflows/release.yml
vendored
@ -11,6 +11,9 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
|
- uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
- name: Build Release
|
- name: Build Release
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
|||||||
[submodule "libraries/AzureIoT"]
|
|
||||||
path = libraries/AzureIoT
|
|
||||||
url = https://github.com/VSChina/ESP32_AzureIoT_Arduino
|
|
||||||
|
@ -78,66 +78,6 @@ set(LIBRARY_SRCS
|
|||||||
libraries/Wire/src/Wire.cpp
|
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
|
set(BLE_SRCS
|
||||||
libraries/BLE/src/BLE2902.cpp
|
libraries/BLE/src/BLE2902.cpp
|
||||||
libraries/BLE/src/BLE2904.cpp
|
libraries/BLE/src/BLE2904.cpp
|
||||||
@ -170,14 +110,13 @@ set(BLE_SRCS
|
|||||||
libraries/BLE/src/GeneralUtils.cpp
|
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
|
set(COMPONENT_ADD_INCLUDEDIRS
|
||||||
variants/esp32/
|
variants/esp32/
|
||||||
cores/esp32/
|
cores/esp32/
|
||||||
libraries/ArduinoOTA/src
|
libraries/ArduinoOTA/src
|
||||||
libraries/AsyncUDP/src
|
libraries/AsyncUDP/src
|
||||||
libraries/AzureIoT/src
|
|
||||||
libraries/BLE/src
|
libraries/BLE/src
|
||||||
libraries/BluetoothSerial/src
|
libraries/BluetoothSerial/src
|
||||||
libraries/DNSServer/src
|
libraries/DNSServer/src
|
||||||
@ -205,12 +144,7 @@ set(COMPONENT_ADD_INCLUDEDIRS
|
|||||||
|
|
||||||
set(COMPONENT_PRIV_INCLUDEDIRS cores/esp32/libb64)
|
set(COMPONENT_PRIV_INCLUDEDIRS cores/esp32/libb64)
|
||||||
|
|
||||||
set(COMPONENT_REQUIRES spi_flash mbedtls mdns ethernet)
|
set(COMPONENT_REQUIRES spi_flash mbedtls mdns esp_adc_cal)
|
||||||
set(COMPONENT_PRIV_REQUIRES fatfs nvs_flash app_update spiffs bootloader_support openssl bt)
|
set(COMPONENT_PRIV_REQUIRES fatfs nvs_flash app_update spiffs bootloader_support openssl bt)
|
||||||
|
|
||||||
register_component()
|
register_component()
|
||||||
|
|
||||||
set_source_files_properties(libraries/AzureIoT/src/az_iot/iothub_client/src/iothubtransport_mqtt_common.c
|
|
||||||
PROPERTIES COMPILE_FLAGS
|
|
||||||
-Wno-maybe-uninitialized
|
|
||||||
)
|
|
||||||
|
@ -36,12 +36,12 @@ You can use [EspExceptionDecoder](https://github.com/me-no-dev/EspExceptionDecod
|
|||||||
### Issue/Bug report template
|
### Issue/Bug report template
|
||||||
Before reporting an issue, make sure you've searched for similar one that was already created. Also make sure to go through all the issues labelled as [for reference](https://github.com/espressif/arduino-esp32/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3A%22for%20reference%22%20).
|
Before reporting an issue, make sure you've searched for similar one that was already created. Also make sure to go through all the issues labelled as [for reference](https://github.com/espressif/arduino-esp32/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3A%22for%20reference%22%20).
|
||||||
|
|
||||||
Finally, if you're sure no one else had the issue, follow the [ISSUE_TEMPLATE](docs/ISSUE_TEMPLATE.md) while reporting any issue.
|
Finally, if you are sure no one else had the issue, follow the [ISSUE_TEMPLATE](docs/ISSUE_TEMPLATE.md) while reporting any issue.
|
||||||
|
|
||||||
### ESP32Dev Board PINMAP
|
### ESP32Dev Board PINMAP
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Hint
|
### Tip
|
||||||
|
|
||||||
Sometimes to program ESP32 via serial you must keep GPIO0 LOW during the programming process
|
Sometimes to program ESP32 via serial you must keep GPIO0 LOW during the programming process
|
||||||
|
563
boards.txt
563
boards.txt
@ -324,7 +324,7 @@ tinypico.serial.disableRTS=true
|
|||||||
tinypico.build.mcu=esp32
|
tinypico.build.mcu=esp32
|
||||||
tinypico.build.core=esp32
|
tinypico.build.core=esp32
|
||||||
tinypico.build.variant=pico32
|
tinypico.build.variant=pico32
|
||||||
tinypico.build.board=ESP32_PICO
|
tinypico.build.board=TINYPICO
|
||||||
|
|
||||||
tinypico.build.f_cpu=240000000L
|
tinypico.build.f_cpu=240000000L
|
||||||
tinypico.build.flash_size=4MB
|
tinypico.build.flash_size=4MB
|
||||||
@ -334,6 +334,15 @@ tinypico.build.boot=dio
|
|||||||
tinypico.build.partitions=default
|
tinypico.build.partitions=default
|
||||||
tinypico.build.defines=
|
tinypico.build.defines=
|
||||||
|
|
||||||
|
tinypico.menu.PartitionScheme.default=Default
|
||||||
|
tinypico.menu.PartitionScheme.default.build.partitions=default
|
||||||
|
tinypico.menu.PartitionScheme.no_ota=No OTA (Large APP)
|
||||||
|
tinypico.menu.PartitionScheme.no_ota.build.partitions=no_ota
|
||||||
|
tinypico.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
|
||||||
|
tinypico.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
|
||||||
|
tinypico.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
|
||||||
|
tinypico.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
|
||||||
|
|
||||||
tinypico.menu.UploadSpeed.921600=921600
|
tinypico.menu.UploadSpeed.921600=921600
|
||||||
tinypico.menu.UploadSpeed.921600.upload.speed=921600
|
tinypico.menu.UploadSpeed.921600.upload.speed=921600
|
||||||
tinypico.menu.UploadSpeed.115200=115200
|
tinypico.menu.UploadSpeed.115200=115200
|
||||||
@ -1382,6 +1391,15 @@ node32s.build.boot=dio
|
|||||||
node32s.build.partitions=default
|
node32s.build.partitions=default
|
||||||
node32s.build.defines=
|
node32s.build.defines=
|
||||||
|
|
||||||
|
node32s.menu.PartitionScheme.default=Default
|
||||||
|
node32s.menu.PartitionScheme.default.build.partitions=default
|
||||||
|
node32s.menu.PartitionScheme.no_ota=No OTA (Large APP)
|
||||||
|
node32s.menu.PartitionScheme.no_ota.build.partitions=no_ota
|
||||||
|
node32s.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
|
||||||
|
node32s.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
|
||||||
|
node32s.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
|
||||||
|
node32s.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
|
||||||
|
|
||||||
node32s.menu.FlashFreq.80=80MHz
|
node32s.menu.FlashFreq.80=80MHz
|
||||||
node32s.menu.FlashFreq.80.build.flash_freq=80m
|
node32s.menu.FlashFreq.80.build.flash_freq=80m
|
||||||
node32s.menu.FlashFreq.40=40MHz
|
node32s.menu.FlashFreq.40=40MHz
|
||||||
@ -1402,6 +1420,19 @@ node32s.menu.UploadSpeed.460800.upload.speed=460800
|
|||||||
node32s.menu.UploadSpeed.512000.windows=512000
|
node32s.menu.UploadSpeed.512000.windows=512000
|
||||||
node32s.menu.UploadSpeed.512000.upload.speed=512000
|
node32s.menu.UploadSpeed.512000.upload.speed=512000
|
||||||
|
|
||||||
|
node32s.menu.DebugLevel.none=None
|
||||||
|
node32s.menu.DebugLevel.none.build.code_debug=0
|
||||||
|
node32s.menu.DebugLevel.error=Error
|
||||||
|
node32s.menu.DebugLevel.error.build.code_debug=1
|
||||||
|
node32s.menu.DebugLevel.warn=Warn
|
||||||
|
node32s.menu.DebugLevel.warn.build.code_debug=2
|
||||||
|
node32s.menu.DebugLevel.info=Info
|
||||||
|
node32s.menu.DebugLevel.info.build.code_debug=3
|
||||||
|
node32s.menu.DebugLevel.debug=Debug
|
||||||
|
node32s.menu.DebugLevel.debug.build.code_debug=4
|
||||||
|
node32s.menu.DebugLevel.verbose=Verbose
|
||||||
|
node32s.menu.DebugLevel.verbose.build.code_debug=5
|
||||||
|
|
||||||
##############################################################
|
##############################################################
|
||||||
|
|
||||||
hornbill32dev.name=Hornbill ESP32 Dev
|
hornbill32dev.name=Hornbill ESP32 Dev
|
||||||
@ -3085,8 +3116,8 @@ CoreESP32.upload.maximum_size=1310720
|
|||||||
CoreESP32.upload.maximum_data_size=327680
|
CoreESP32.upload.maximum_data_size=327680
|
||||||
CoreESP32.upload.wait_for_upload_port=true
|
CoreESP32.upload.wait_for_upload_port=true
|
||||||
|
|
||||||
CoreESP32.serial.disableDTR=true
|
CoreESP32.serial.disableDTR=false
|
||||||
CoreESP32.serial.disableRTS=true
|
CoreESP32.serial.disableRTS=false
|
||||||
|
|
||||||
CoreESP32.build.mcu=esp32
|
CoreESP32.build.mcu=esp32
|
||||||
CoreESP32.build.core=esp32
|
CoreESP32.build.core=esp32
|
||||||
@ -3100,6 +3131,24 @@ CoreESP32.build.boot=dio
|
|||||||
CoreESP32.build.partitions=default
|
CoreESP32.build.partitions=default
|
||||||
CoreESP32.build.defines=
|
CoreESP32.build.defines=
|
||||||
|
|
||||||
|
CoreESP32.menu.PSRAM.disabled=Disabled
|
||||||
|
CoreESP32.menu.PSRAM.disabled.build.defines=
|
||||||
|
CoreESP32.menu.PSRAM.enabled=Enabled
|
||||||
|
CoreESP32.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue
|
||||||
|
|
||||||
|
CoreESP32.menu.PartitionScheme.default=Default
|
||||||
|
CoreESP32.menu.PartitionScheme.default.build.partitions=default
|
||||||
|
CoreESP32.menu.PartitionScheme.minimal=Minimal (2MB FLASH)
|
||||||
|
CoreESP32.menu.PartitionScheme.minimal.build.partitions=minimal
|
||||||
|
CoreESP32.menu.PartitionScheme.no_ota=No OTA (Large APP)
|
||||||
|
CoreESP32.menu.PartitionScheme.no_ota.build.partitions=no_ota
|
||||||
|
CoreESP32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
|
||||||
|
CoreESP32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
|
||||||
|
CoreESP32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
|
||||||
|
CoreESP32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
|
||||||
|
CoreESP32.menu.PartitionScheme.fatflash=16M Fat
|
||||||
|
CoreESP32.menu.PartitionScheme.fatflash.build.partitions=ffat
|
||||||
|
|
||||||
CoreESP32.menu.FlashFreq.80=80MHz
|
CoreESP32.menu.FlashFreq.80=80MHz
|
||||||
CoreESP32.menu.FlashFreq.80.build.flash_freq=80m
|
CoreESP32.menu.FlashFreq.80.build.flash_freq=80m
|
||||||
CoreESP32.menu.FlashFreq.40=40MHz
|
CoreESP32.menu.FlashFreq.40=40MHz
|
||||||
@ -3120,6 +3169,19 @@ CoreESP32.menu.UploadSpeed.460800.upload.speed=460800
|
|||||||
CoreESP32.menu.UploadSpeed.512000.windows=512000
|
CoreESP32.menu.UploadSpeed.512000.windows=512000
|
||||||
CoreESP32.menu.UploadSpeed.512000.upload.speed=512000
|
CoreESP32.menu.UploadSpeed.512000.upload.speed=512000
|
||||||
|
|
||||||
|
CoreESP32.menu.DebugLevel.none=None
|
||||||
|
CoreESP32.menu.DebugLevel.none.build.code_debug=0
|
||||||
|
CoreESP32.menu.DebugLevel.error=Error
|
||||||
|
CoreESP32.menu.DebugLevel.error.build.code_debug=1
|
||||||
|
CoreESP32.menu.DebugLevel.warn=Warn
|
||||||
|
CoreESP32.menu.DebugLevel.warn.build.code_debug=2
|
||||||
|
CoreESP32.menu.DebugLevel.info=Info
|
||||||
|
CoreESP32.menu.DebugLevel.info.build.code_debug=3
|
||||||
|
CoreESP32.menu.DebugLevel.debug=Debug
|
||||||
|
CoreESP32.menu.DebugLevel.debug.build.code_debug=4
|
||||||
|
CoreESP32.menu.DebugLevel.verbose=Verbose
|
||||||
|
CoreESP32.menu.DebugLevel.verbose.build.code_debug=5
|
||||||
|
|
||||||
##############################################################
|
##############################################################
|
||||||
|
|
||||||
|
|
||||||
@ -4204,6 +4266,51 @@ vintlabs-devkit-v1.menu.UploadSpeed.460800.upload.speed=460800
|
|||||||
vintlabs-devkit-v1.menu.UploadSpeed.512000.windows=512000
|
vintlabs-devkit-v1.menu.UploadSpeed.512000.windows=512000
|
||||||
vintlabs-devkit-v1.menu.UploadSpeed.512000.upload.speed=512000
|
vintlabs-devkit-v1.menu.UploadSpeed.512000.upload.speed=512000
|
||||||
|
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.default.build.partitions=default
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.default_8MB=8M Flash (3MB APP/1.5MB FAT)
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.minimal.build.partitions=minimal
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.no_ota.build.partitions=no_ota
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.huge_app.build.partitions=huge_app
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT)
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.fatflash.build.partitions=ffat
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS)
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
|
||||||
|
vintlabs-devkit-v1.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
|
||||||
|
|
||||||
|
vintlabs-devkit-v1.menu.FlashSize.4M=4MB (32Mb)
|
||||||
|
vintlabs-devkit-v1.menu.FlashSize.4M.build.flash_size=4MB
|
||||||
|
vintlabs-devkit-v1.menu.FlashSize.8M=8MB (64Mb)
|
||||||
|
vintlabs-devkit-v1.menu.FlashSize.8M.build.flash_size=8MB
|
||||||
|
vintlabs-devkit-v1.menu.FlashSize.8M.build.partitions=default_8MB
|
||||||
|
vintlabs-devkit-v1.menu.FlashSize.2M=2MB (16Mb)
|
||||||
|
vintlabs-devkit-v1.menu.FlashSize.2M.build.flash_size=2MB
|
||||||
|
vintlabs-devkit-v1.menu.FlashSize.2M.build.partitions=minimal
|
||||||
|
vintlabs-devkit-v1.menu.FlashSize.16M=16MB (128Mb)
|
||||||
|
vintlabs-devkit-v1.menu.FlashSize.16M.build.flash_size=16MB
|
||||||
|
|
||||||
vintlabs-devkit-v1.menu.DebugLevel.none=None
|
vintlabs-devkit-v1.menu.DebugLevel.none=None
|
||||||
vintlabs-devkit-v1.menu.DebugLevel.none.build.code_debug=0
|
vintlabs-devkit-v1.menu.DebugLevel.none.build.code_debug=0
|
||||||
vintlabs-devkit-v1.menu.DebugLevel.error=Error
|
vintlabs-devkit-v1.menu.DebugLevel.error=Error
|
||||||
@ -4217,3 +4324,453 @@ vintlabs-devkit-v1.menu.DebugLevel.debug.build.code_debug=4
|
|||||||
|
|
||||||
##############################################################
|
##############################################################
|
||||||
|
|
||||||
|
honeylemon.name=HONEYLemon
|
||||||
|
|
||||||
|
honeylemon.upload.tool=esptool_py
|
||||||
|
honeylemon.upload.maximum_size=1310720
|
||||||
|
honeylemon.upload.maximum_data_size=327680
|
||||||
|
honeylemon.upload.wait_for_upload_port=true
|
||||||
|
|
||||||
|
honeylemon.serial.disableDTR=true
|
||||||
|
honeylemon.serial.disableRTS=true
|
||||||
|
|
||||||
|
honeylemon.build.mcu=esp32
|
||||||
|
honeylemon.build.core=esp32
|
||||||
|
honeylemon.build.variant=honeylemon
|
||||||
|
honeylemon.build.board=HONEYLEMON
|
||||||
|
|
||||||
|
honeylemon.build.f_cpu=240000000L
|
||||||
|
honeylemon.build.flash_mode=dio
|
||||||
|
honeylemon.build.flash_size=4MB
|
||||||
|
honeylemon.build.boot=dio
|
||||||
|
honeylemon.build.partitions=default
|
||||||
|
honeylemon.build.defines=
|
||||||
|
|
||||||
|
honeylemon.menu.FlashFreq.80=80MHz
|
||||||
|
honeylemon.menu.FlashFreq.80.build.flash_freq=80m
|
||||||
|
honeylemon.menu.FlashFreq.40=40MHz
|
||||||
|
honeylemon.menu.FlashFreq.40.build.flash_freq=40m
|
||||||
|
|
||||||
|
honeylemon.menu.UploadSpeed.921600=921600
|
||||||
|
honeylemon.menu.UploadSpeed.921600.upload.speed=921600
|
||||||
|
honeylemon.menu.UploadSpeed.115200=115200
|
||||||
|
honeylemon.menu.UploadSpeed.115200.upload.speed=115200
|
||||||
|
honeylemon.menu.UploadSpeed.256000.windows=256000
|
||||||
|
honeylemon.menu.UploadSpeed.256000.upload.speed=256000
|
||||||
|
honeylemon.menu.UploadSpeed.230400.windows.upload.speed=256000
|
||||||
|
honeylemon.menu.UploadSpeed.230400=230400
|
||||||
|
honeylemon.menu.UploadSpeed.230400.upload.speed=230400
|
||||||
|
honeylemon.menu.UploadSpeed.460800.linux=460800
|
||||||
|
honeylemon.menu.UploadSpeed.460800.macosx=460800
|
||||||
|
honeylemon.menu.UploadSpeed.460800.upload.speed=460800
|
||||||
|
honeylemon.menu.UploadSpeed.512000.windows=512000
|
||||||
|
honeylemon.menu.UploadSpeed.512000.upload.speed=512000
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
mgbot-iotik32a.name=MGBOT IOTIK 32A
|
||||||
|
|
||||||
|
mgbot-iotik32a.upload.tool=esptool_py
|
||||||
|
mgbot-iotik32a.upload.maximum_size=1310720
|
||||||
|
mgbot-iotik32a.upload.maximum_data_size=327680
|
||||||
|
mgbot-iotik32a.upload.wait_for_upload_port=true
|
||||||
|
|
||||||
|
mgbot-iotik32a.serial.disableDTR=true
|
||||||
|
mgbot-iotik32a.serial.disableRTS=true
|
||||||
|
|
||||||
|
mgbot-iotik32a.build.mcu=esp32
|
||||||
|
mgbot-iotik32a.build.core=esp32
|
||||||
|
mgbot-iotik32a.build.variant=mgbot-iotik32a
|
||||||
|
mgbot-iotik32a.build.board=MGBOT_IOTIK32A
|
||||||
|
|
||||||
|
mgbot-iotik32a.build.f_cpu=240000000L
|
||||||
|
mgbot-iotik32a.build.flash_size=4MB
|
||||||
|
mgbot-iotik32a.build.flash_freq=40m
|
||||||
|
mgbot-iotik32a.build.flash_mode=dio
|
||||||
|
mgbot-iotik32a.build.boot=dio
|
||||||
|
mgbot-iotik32a.build.partitions=default
|
||||||
|
mgbot-iotik32a.build.defines=
|
||||||
|
|
||||||
|
mgbot-iotik32a.menu.PSRAM.disabled=Disabled
|
||||||
|
mgbot-iotik32a.menu.PSRAM.disabled.build.defines=
|
||||||
|
mgbot-iotik32a.menu.PSRAM.enabled=Enabled
|
||||||
|
mgbot-iotik32a.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue
|
||||||
|
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.default.build.partitions=default
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.default_8MB=8M Flash (3MB APP/1.5MB FAT)
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.minimal.build.partitions=minimal
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.no_ota.build.partitions=no_ota
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.huge_app.build.partitions=huge_app
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT)
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.fatflash.build.partitions=ffat
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS)
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
|
||||||
|
mgbot-iotik32a.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
|
||||||
|
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.240=240MHz (WiFi/BT)
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.240.build.f_cpu=240000000L
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.160=160MHz (WiFi/BT)
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.160.build.f_cpu=160000000L
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.80=80MHz (WiFi/BT)
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.80.build.f_cpu=80000000L
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.40=40MHz (40MHz XTAL)
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.40.build.f_cpu=40000000L
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.26=26MHz (26MHz XTAL)
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.26.build.f_cpu=26000000L
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.20=20MHz (40MHz XTAL)
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.20.build.f_cpu=20000000L
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.13=13MHz (26MHz XTAL)
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.13.build.f_cpu=13000000L
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.10=10MHz (40MHz XTAL)
|
||||||
|
mgbot-iotik32a.menu.CPUFreq.10.build.f_cpu=10000000L
|
||||||
|
|
||||||
|
mgbot-iotik32a.menu.FlashMode.qio=QIO
|
||||||
|
mgbot-iotik32a.menu.FlashMode.qio.build.flash_mode=dio
|
||||||
|
mgbot-iotik32a.menu.FlashMode.qio.build.boot=qio
|
||||||
|
mgbot-iotik32a.menu.FlashMode.dio=DIO
|
||||||
|
mgbot-iotik32a.menu.FlashMode.dio.build.flash_mode=dio
|
||||||
|
mgbot-iotik32a.menu.FlashMode.dio.build.boot=dio
|
||||||
|
mgbot-iotik32a.menu.FlashMode.qout=QOUT
|
||||||
|
mgbot-iotik32a.menu.FlashMode.qout.build.flash_mode=dout
|
||||||
|
mgbot-iotik32a.menu.FlashMode.qout.build.boot=qout
|
||||||
|
mgbot-iotik32a.menu.FlashMode.dout=DOUT
|
||||||
|
mgbot-iotik32a.menu.FlashMode.dout.build.flash_mode=dout
|
||||||
|
mgbot-iotik32a.menu.FlashMode.dout.build.boot=dout
|
||||||
|
|
||||||
|
mgbot-iotik32a.menu.FlashFreq.80=80MHz
|
||||||
|
mgbot-iotik32a.menu.FlashFreq.80.build.flash_freq=80m
|
||||||
|
mgbot-iotik32a.menu.FlashFreq.40=40MHz
|
||||||
|
mgbot-iotik32a.menu.FlashFreq.40.build.flash_freq=40m
|
||||||
|
|
||||||
|
mgbot-iotik32a.menu.FlashSize.4M=4MB (32Mb)
|
||||||
|
mgbot-iotik32a.menu.FlashSize.4M.build.flash_size=4MB
|
||||||
|
mgbot-iotik32a.menu.FlashSize.8M=8MB (64Mb)
|
||||||
|
mgbot-iotik32a.menu.FlashSize.8M.build.flash_size=8MB
|
||||||
|
mgbot-iotik32a.menu.FlashSize.8M.build.partitions=default_8MB
|
||||||
|
mgbot-iotik32a.menu.FlashSize.2M=2MB (16Mb)
|
||||||
|
mgbot-iotik32a.menu.FlashSize.2M.build.flash_size=2MB
|
||||||
|
mgbot-iotik32a.menu.FlashSize.2M.build.partitions=minimal
|
||||||
|
mgbot-iotik32a.menu.FlashSize.16M=16MB (128Mb)
|
||||||
|
mgbot-iotik32a.menu.FlashSize.16M.build.flash_size=16MB
|
||||||
|
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.921600=921600
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.921600.upload.speed=921600
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.115200=115200
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.115200.upload.speed=115200
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.256000.windows=256000
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.256000.upload.speed=256000
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.230400.windows.upload.speed=256000
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.230400=230400
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.230400.upload.speed=230400
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.460800.linux=460800
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.460800.macosx=460800
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.460800.upload.speed=460800
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.512000.windows=512000
|
||||||
|
mgbot-iotik32a.menu.UploadSpeed.512000.upload.speed=512000
|
||||||
|
|
||||||
|
mgbot-iotik32a.menu.DebugLevel.none=None
|
||||||
|
mgbot-iotik32a.menu.DebugLevel.none.build.code_debug=0
|
||||||
|
mgbot-iotik32a.menu.DebugLevel.error=Error
|
||||||
|
mgbot-iotik32a.menu.DebugLevel.error.build.code_debug=1
|
||||||
|
mgbot-iotik32a.menu.DebugLevel.warn=Warn
|
||||||
|
mgbot-iotik32a.menu.DebugLevel.warn.build.code_debug=2
|
||||||
|
mgbot-iotik32a.menu.DebugLevel.info=Info
|
||||||
|
mgbot-iotik32a.menu.DebugLevel.info.build.code_debug=3
|
||||||
|
mgbot-iotik32a.menu.DebugLevel.debug=Debug
|
||||||
|
mgbot-iotik32a.menu.DebugLevel.debug.build.code_debug=4
|
||||||
|
mgbot-iotik32a.menu.DebugLevel.verbose=Verbose
|
||||||
|
mgbot-iotik32a.menu.DebugLevel.verbose.build.code_debug=5
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
mgbot-iotik32b.name=MGBOT IOTIK 32B
|
||||||
|
|
||||||
|
mgbot-iotik32b.upload.tool=esptool_py
|
||||||
|
mgbot-iotik32b.upload.maximum_size=1310720
|
||||||
|
mgbot-iotik32b.upload.maximum_data_size=327680
|
||||||
|
mgbot-iotik32b.upload.wait_for_upload_port=true
|
||||||
|
|
||||||
|
mgbot-iotik32b.serial.disableDTR=true
|
||||||
|
mgbot-iotik32b.serial.disableRTS=true
|
||||||
|
|
||||||
|
mgbot-iotik32b.build.mcu=esp32
|
||||||
|
mgbot-iotik32b.build.core=esp32
|
||||||
|
mgbot-iotik32b.build.variant=mgbot-iotik32b
|
||||||
|
mgbot-iotik32b.build.board=MGBOT_IOTIK32B
|
||||||
|
|
||||||
|
mgbot-iotik32b.build.f_cpu=240000000L
|
||||||
|
mgbot-iotik32b.build.flash_size=4MB
|
||||||
|
mgbot-iotik32b.build.flash_freq=40m
|
||||||
|
mgbot-iotik32b.build.flash_mode=dio
|
||||||
|
mgbot-iotik32b.build.boot=dio
|
||||||
|
mgbot-iotik32b.build.partitions=default
|
||||||
|
mgbot-iotik32b.build.defines=
|
||||||
|
|
||||||
|
mgbot-iotik32b.menu.PSRAM.disabled=Disabled
|
||||||
|
mgbot-iotik32b.menu.PSRAM.disabled.build.defines=
|
||||||
|
mgbot-iotik32b.menu.PSRAM.enabled=Enabled
|
||||||
|
mgbot-iotik32b.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue
|
||||||
|
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.default.build.partitions=default
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.default_8MB=8M Flash (3MB APP/1.5MB FAT)
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.minimal.build.partitions=minimal
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.no_ota.build.partitions=no_ota
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.huge_app.build.partitions=huge_app
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT)
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.fatflash.build.partitions=ffat
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS)
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
|
||||||
|
mgbot-iotik32b.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
|
||||||
|
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.240=240MHz (WiFi/BT)
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.240.build.f_cpu=240000000L
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.160=160MHz (WiFi/BT)
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.160.build.f_cpu=160000000L
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.80=80MHz (WiFi/BT)
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.80.build.f_cpu=80000000L
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.40=40MHz (40MHz XTAL)
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.40.build.f_cpu=40000000L
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.26=26MHz (26MHz XTAL)
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.26.build.f_cpu=26000000L
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.20=20MHz (40MHz XTAL)
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.20.build.f_cpu=20000000L
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.13=13MHz (26MHz XTAL)
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.13.build.f_cpu=13000000L
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.10=10MHz (40MHz XTAL)
|
||||||
|
mgbot-iotik32b.menu.CPUFreq.10.build.f_cpu=10000000L
|
||||||
|
|
||||||
|
mgbot-iotik32b.menu.FlashMode.qio=QIO
|
||||||
|
mgbot-iotik32b.menu.FlashMode.qio.build.flash_mode=dio
|
||||||
|
mgbot-iotik32b.menu.FlashMode.qio.build.boot=qio
|
||||||
|
mgbot-iotik32b.menu.FlashMode.dio=DIO
|
||||||
|
mgbot-iotik32b.menu.FlashMode.dio.build.flash_mode=dio
|
||||||
|
mgbot-iotik32b.menu.FlashMode.dio.build.boot=dio
|
||||||
|
mgbot-iotik32b.menu.FlashMode.qout=QOUT
|
||||||
|
mgbot-iotik32b.menu.FlashMode.qout.build.flash_mode=dout
|
||||||
|
mgbot-iotik32b.menu.FlashMode.qout.build.boot=qout
|
||||||
|
mgbot-iotik32b.menu.FlashMode.dout=DOUT
|
||||||
|
mgbot-iotik32b.menu.FlashMode.dout.build.flash_mode=dout
|
||||||
|
mgbot-iotik32b.menu.FlashMode.dout.build.boot=dout
|
||||||
|
|
||||||
|
mgbot-iotik32b.menu.FlashFreq.80=80MHz
|
||||||
|
mgbot-iotik32b.menu.FlashFreq.80.build.flash_freq=80m
|
||||||
|
mgbot-iotik32b.menu.FlashFreq.40=40MHz
|
||||||
|
mgbot-iotik32b.menu.FlashFreq.40.build.flash_freq=40m
|
||||||
|
|
||||||
|
mgbot-iotik32b.menu.FlashSize.4M=4MB (32Mb)
|
||||||
|
mgbot-iotik32b.menu.FlashSize.4M.build.flash_size=4MB
|
||||||
|
mgbot-iotik32b.menu.FlashSize.8M=8MB (64Mb)
|
||||||
|
mgbot-iotik32b.menu.FlashSize.8M.build.flash_size=8MB
|
||||||
|
mgbot-iotik32b.menu.FlashSize.8M.build.partitions=default_8MB
|
||||||
|
mgbot-iotik32b.menu.FlashSize.2M=2MB (16Mb)
|
||||||
|
mgbot-iotik32b.menu.FlashSize.2M.build.flash_size=2MB
|
||||||
|
mgbot-iotik32b.menu.FlashSize.2M.build.partitions=minimal
|
||||||
|
mgbot-iotik32b.menu.FlashSize.16M=16MB (128Mb)
|
||||||
|
mgbot-iotik32b.menu.FlashSize.16M.build.flash_size=16MB
|
||||||
|
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.921600=921600
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.921600.upload.speed=921600
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.115200=115200
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.115200.upload.speed=115200
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.256000.windows=256000
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.256000.upload.speed=256000
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.230400.windows.upload.speed=256000
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.230400=230400
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.230400.upload.speed=230400
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.460800.linux=460800
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.460800.macosx=460800
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.460800.upload.speed=460800
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.512000.windows=512000
|
||||||
|
mgbot-iotik32b.menu.UploadSpeed.512000.upload.speed=512000
|
||||||
|
|
||||||
|
mgbot-iotik32b.menu.DebugLevel.none=None
|
||||||
|
mgbot-iotik32b.menu.DebugLevel.none.build.code_debug=0
|
||||||
|
mgbot-iotik32b.menu.DebugLevel.error=Error
|
||||||
|
mgbot-iotik32b.menu.DebugLevel.error.build.code_debug=1
|
||||||
|
mgbot-iotik32b.menu.DebugLevel.warn=Warn
|
||||||
|
mgbot-iotik32b.menu.DebugLevel.warn.build.code_debug=2
|
||||||
|
mgbot-iotik32b.menu.DebugLevel.info=Info
|
||||||
|
mgbot-iotik32b.menu.DebugLevel.info.build.code_debug=3
|
||||||
|
mgbot-iotik32b.menu.DebugLevel.debug=Debug
|
||||||
|
mgbot-iotik32b.menu.DebugLevel.debug.build.code_debug=4
|
||||||
|
mgbot-iotik32b.menu.DebugLevel.verbose=Verbose
|
||||||
|
mgbot-iotik32b.menu.DebugLevel.verbose.build.code_debug=5
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
piranha_esp-32.name=Piranha ESP-32
|
||||||
|
|
||||||
|
piranha_esp-32.upload.tool=esptool_py
|
||||||
|
piranha_esp-32.upload.maximum_size=1310720
|
||||||
|
piranha_esp-32.upload.maximum_data_size=327680
|
||||||
|
piranha_esp-32.upload.wait_for_upload_port=true
|
||||||
|
|
||||||
|
piranha_esp-32.serial.disableDTR=true
|
||||||
|
piranha_esp-32.serial.disableRTS=true
|
||||||
|
|
||||||
|
piranha_esp-32.build.mcu=esp32
|
||||||
|
piranha_esp-32.build.core=esp32
|
||||||
|
piranha_esp-32.build.variant=piranha_esp-32
|
||||||
|
piranha_esp-32.build.board=Piranha
|
||||||
|
|
||||||
|
piranha_esp-32.build.f_cpu=240000000L
|
||||||
|
piranha_esp-32.build.flash_mode=dio
|
||||||
|
piranha_esp-32.build.flash_size=4MB
|
||||||
|
piranha_esp-32.build.boot=dio
|
||||||
|
piranha_esp-32.build.partitions=default
|
||||||
|
piranha_esp-32.build.defines=
|
||||||
|
|
||||||
|
piranha_esp-32.menu.PartitionScheme.default=Default
|
||||||
|
piranha_esp-32.menu.PartitionScheme.default.build.partitions=default
|
||||||
|
piranha_esp-32.menu.PartitionScheme.no_ota=No OTA (Large APP)
|
||||||
|
piranha_esp-32.menu.PartitionScheme.no_ota.build.partitions=no_ota
|
||||||
|
piranha_esp-32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
|
||||||
|
piranha_esp-32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
|
||||||
|
piranha_esp-32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
|
||||||
|
piranha_esp-32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
|
||||||
|
|
||||||
|
piranha_esp-32.menu.FlashFreq.80=80MHz
|
||||||
|
piranha_esp-32.menu.FlashFreq.80.build.flash_freq=80m
|
||||||
|
piranha_esp-32.menu.FlashFreq.40=40MHz
|
||||||
|
piranha_esp-32.menu.FlashFreq.40.build.flash_freq=40m
|
||||||
|
|
||||||
|
piranha_esp-32.menu.UploadSpeed.921600=921600
|
||||||
|
piranha_esp-32.menu.UploadSpeed.921600.upload.speed=921600
|
||||||
|
piranha_esp-32.menu.UploadSpeed.115200=115200
|
||||||
|
piranha_esp-32.menu.UploadSpeed.115200.upload.speed=115200
|
||||||
|
piranha_esp-32.menu.UploadSpeed.256000.windows=256000
|
||||||
|
piranha_esp-32.menu.UploadSpeed.256000.upload.speed=256000
|
||||||
|
piranha_esp-32.menu.UploadSpeed.230400.windows.upload.speed=256000
|
||||||
|
piranha_esp-32.menu.UploadSpeed.230400=230400
|
||||||
|
piranha_esp-32.menu.UploadSpeed.230400.upload.speed=230400
|
||||||
|
piranha_esp-32.menu.UploadSpeed.460800.linux=460800
|
||||||
|
piranha_esp-32.menu.UploadSpeed.460800.macosx=460800
|
||||||
|
piranha_esp-32.menu.UploadSpeed.460800.upload.speed=460800
|
||||||
|
piranha_esp-32.menu.UploadSpeed.512000.windows=512000
|
||||||
|
piranha_esp-32.menu.UploadSpeed.512000.upload.speed=512000
|
||||||
|
|
||||||
|
piranha_esp-32.menu.DebugLevel.none=None
|
||||||
|
piranha_esp-32.menu.DebugLevel.none.build.code_debug=0
|
||||||
|
piranha_esp-32.menu.DebugLevel.error=Error
|
||||||
|
piranha_esp-32.menu.DebugLevel.error.build.code_debug=1
|
||||||
|
piranha_esp-32.menu.DebugLevel.warn=Warn
|
||||||
|
piranha_esp-32.menu.DebugLevel.warn.build.code_debug=2
|
||||||
|
piranha_esp-32.menu.DebugLevel.info=Info
|
||||||
|
piranha_esp-32.menu.DebugLevel.info.build.code_debug=3
|
||||||
|
piranha_esp-32.menu.DebugLevel.debug=Debug
|
||||||
|
piranha_esp-32.menu.DebugLevel.debug.build.code_debug=4
|
||||||
|
piranha_esp-32.menu.DebugLevel.verbose=Verbose
|
||||||
|
piranha_esp-32.menu.DebugLevel.verbose.build.code_debug=5
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
metro_esp-32.name=Metro ESP-32
|
||||||
|
|
||||||
|
metro_esp-32.upload.tool=esptool_py
|
||||||
|
metro_esp-32.upload.maximum_size=1310720
|
||||||
|
metro_esp-32.upload.maximum_data_size=327680
|
||||||
|
metro_esp-32.upload.wait_for_upload_port=true
|
||||||
|
|
||||||
|
metro_esp-32.serial.disableDTR=true
|
||||||
|
metro_esp-32.serial.disableRTS=true
|
||||||
|
|
||||||
|
metro_esp-32.build.mcu=esp32
|
||||||
|
metro_esp-32.build.core=esp32
|
||||||
|
metro_esp-32.build.variant=metro_esp-32
|
||||||
|
metro_esp-32.build.board=Metro
|
||||||
|
|
||||||
|
metro_esp-32.build.f_cpu=240000000L
|
||||||
|
metro_esp-32.build.flash_mode=dio
|
||||||
|
metro_esp-32.build.flash_size=4MB
|
||||||
|
metro_esp-32.build.boot=dio
|
||||||
|
metro_esp-32.build.partitions=default
|
||||||
|
metro_esp-32.build.defines=
|
||||||
|
|
||||||
|
metro_esp-32.menu.PartitionScheme.default=Default
|
||||||
|
metro_esp-32.menu.PartitionScheme.default.build.partitions=default
|
||||||
|
metro_esp-32.menu.PartitionScheme.no_ota=No OTA (Large APP)
|
||||||
|
metro_esp-32.menu.PartitionScheme.no_ota.build.partitions=no_ota
|
||||||
|
metro_esp-32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
|
||||||
|
metro_esp-32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
|
||||||
|
metro_esp-32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
|
||||||
|
metro_esp-32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
|
||||||
|
|
||||||
|
metro_esp-32.menu.FlashFreq.80=80MHz
|
||||||
|
metro_esp-32.menu.FlashFreq.80.build.flash_freq=80m
|
||||||
|
metro_esp-32.menu.FlashFreq.40=40MHz
|
||||||
|
metro_esp-32.menu.FlashFreq.40.build.flash_freq=40m
|
||||||
|
|
||||||
|
metro_esp-32.menu.UploadSpeed.921600=921600
|
||||||
|
metro_esp-32.menu.UploadSpeed.921600.upload.speed=921600
|
||||||
|
metro_esp-32.menu.UploadSpeed.115200=115200
|
||||||
|
metro_esp-32.menu.UploadSpeed.115200.upload.speed=115200
|
||||||
|
metro_esp-32.menu.UploadSpeed.256000.windows=256000
|
||||||
|
metro_esp-32.menu.UploadSpeed.256000.upload.speed=256000
|
||||||
|
metro_esp-32.menu.UploadSpeed.230400.windows.upload.speed=256000
|
||||||
|
metro_esp-32.menu.UploadSpeed.230400=230400
|
||||||
|
metro_esp-32.menu.UploadSpeed.230400.upload.speed=230400
|
||||||
|
metro_esp-32.menu.UploadSpeed.460800.linux=460800
|
||||||
|
metro_esp-32.menu.UploadSpeed.460800.macosx=460800
|
||||||
|
metro_esp-32.menu.UploadSpeed.460800.upload.speed=460800
|
||||||
|
metro_esp-32.menu.UploadSpeed.512000.windows=512000
|
||||||
|
metro_esp-32.menu.UploadSpeed.512000.upload.speed=512000
|
||||||
|
|
||||||
|
metro_esp-32.menu.DebugLevel.none=None
|
||||||
|
metro_esp-32.menu.DebugLevel.none.build.code_debug=0
|
||||||
|
metro_esp-32.menu.DebugLevel.error=Error
|
||||||
|
metro_esp-32.menu.DebugLevel.error.build.code_debug=1
|
||||||
|
metro_esp-32.menu.DebugLevel.warn=Warn
|
||||||
|
metro_esp-32.menu.DebugLevel.warn.build.code_debug=2
|
||||||
|
metro_esp-32.menu.DebugLevel.info=Info
|
||||||
|
metro_esp-32.menu.DebugLevel.info.build.code_debug=3
|
||||||
|
metro_esp-32.menu.DebugLevel.debug=Debug
|
||||||
|
metro_esp-32.menu.DebugLevel.debug.build.code_debug=4
|
||||||
|
metro_esp-32.menu.DebugLevel.verbose=Verbose
|
||||||
|
metro_esp-32.menu.DebugLevel.verbose.build.code_debug=5
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
@ -118,7 +118,9 @@ typedef unsigned int word;
|
|||||||
void setup(void);
|
void setup(void);
|
||||||
void loop(void);
|
void loop(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
long random(long, long);
|
long random(long, long);
|
||||||
|
#endif
|
||||||
void randomSeed(unsigned long);
|
void randomSeed(unsigned long);
|
||||||
long map(long, long, long, long, long);
|
long map(long, long, long, long, long);
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "Esp.h"
|
#include "Esp.h"
|
||||||
#include "rom/spi_flash.h"
|
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
#include "esp_spi_flash.h"
|
#include "esp_spi_flash.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -32,6 +31,17 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#include <MD5Builder.h>
|
#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
|
* User-defined Literals
|
||||||
* usage:
|
* usage:
|
||||||
|
@ -131,11 +131,34 @@ int HardwareSerial::read(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HardwareSerial::flush()
|
// read characters into buffer
|
||||||
|
// terminates if size characters have been read, or no further are pending
|
||||||
|
// returns the number of characters placed in the buffer
|
||||||
|
// the buffer is NOT null terminated.
|
||||||
|
size_t HardwareSerial::read(uint8_t *buffer, size_t size)
|
||||||
|
{
|
||||||
|
size_t avail = available();
|
||||||
|
if (size < avail) {
|
||||||
|
avail = size;
|
||||||
|
}
|
||||||
|
size_t count = 0;
|
||||||
|
while(count < avail) {
|
||||||
|
*buffer++ = uartRead(_uart);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HardwareSerial::flush(void)
|
||||||
{
|
{
|
||||||
uartFlush(_uart);
|
uartFlush(_uart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HardwareSerial::flush(bool txOnly)
|
||||||
|
{
|
||||||
|
uartFlushTxOnly(_uart, txOnly);
|
||||||
|
}
|
||||||
|
|
||||||
size_t HardwareSerial::write(uint8_t c)
|
size_t HardwareSerial::write(uint8_t c)
|
||||||
{
|
{
|
||||||
uartWrite(_uart, c);
|
uartWrite(_uart, c);
|
||||||
|
@ -62,10 +62,19 @@ public:
|
|||||||
int availableForWrite(void);
|
int availableForWrite(void);
|
||||||
int peek(void);
|
int peek(void);
|
||||||
int read(void);
|
int read(void);
|
||||||
|
size_t read(uint8_t *buffer, size_t size);
|
||||||
|
inline size_t read(char * buffer, size_t size)
|
||||||
|
{
|
||||||
|
return read((uint8_t*) buffer, size);
|
||||||
|
}
|
||||||
void flush(void);
|
void flush(void);
|
||||||
|
void flush( bool txOnly);
|
||||||
size_t write(uint8_t);
|
size_t write(uint8_t);
|
||||||
size_t write(const uint8_t *buffer, size_t size);
|
size_t write(const uint8_t *buffer, size_t size);
|
||||||
|
inline size_t write(const char * buffer, size_t size)
|
||||||
|
{
|
||||||
|
return write((uint8_t*) buffer, size);
|
||||||
|
}
|
||||||
inline size_t write(const char * s)
|
inline size_t write(const char * s)
|
||||||
{
|
{
|
||||||
return write((uint8_t*) s, strlen(s));
|
return write((uint8_t*) s, strlen(s));
|
||||||
@ -97,10 +106,12 @@ protected:
|
|||||||
uart_t* _uart;
|
uart_t* _uart;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern void serialEventRun(void) __attribute__((weak));
|
||||||
|
|
||||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
|
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
|
||||||
extern HardwareSerial Serial;
|
extern HardwareSerial Serial;
|
||||||
extern HardwareSerial Serial1;
|
extern HardwareSerial Serial1;
|
||||||
extern HardwareSerial Serial2;
|
extern HardwareSerial Serial2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif // HardwareSerial_h
|
||||||
|
@ -21,7 +21,17 @@
|
|||||||
|
|
||||||
#include <WString.h>
|
#include <WString.h>
|
||||||
#include <Stream.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"
|
#include "rom/md5_hash.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
class MD5Builder
|
class MD5Builder
|
||||||
{
|
{
|
||||||
|
@ -203,8 +203,20 @@ class String {
|
|||||||
unsigned char equalsIgnoreCase(const String &s) const;
|
unsigned char equalsIgnoreCase(const String &s) const;
|
||||||
unsigned char equalsConstantTime(const String &s) const;
|
unsigned char equalsConstantTime(const String &s) const;
|
||||||
unsigned char startsWith(const String &prefix) const;
|
unsigned char startsWith(const String &prefix) const;
|
||||||
|
unsigned char startsWith(const char *prefix) const {
|
||||||
|
return this->startsWith(String(prefix));
|
||||||
|
}
|
||||||
|
unsigned char startsWith(const __FlashStringHelper *prefix) const {
|
||||||
|
return this->startsWith(String(prefix));
|
||||||
|
}
|
||||||
unsigned char startsWith(const String &prefix, unsigned int offset) const;
|
unsigned char startsWith(const String &prefix, unsigned int offset) const;
|
||||||
unsigned char endsWith(const String &suffix) const;
|
unsigned char endsWith(const String &suffix) const;
|
||||||
|
unsigned char endsWith(const char *suffix) const {
|
||||||
|
return this->endsWith(String(suffix));
|
||||||
|
}
|
||||||
|
unsigned char endsWith(const __FlashStringHelper * suffix) const {
|
||||||
|
return this->endsWith(String(suffix));
|
||||||
|
}
|
||||||
|
|
||||||
// character access
|
// character access
|
||||||
char charAt(unsigned int index) const;
|
char charAt(unsigned int index) const;
|
||||||
@ -239,6 +251,21 @@ class String {
|
|||||||
// modification
|
// modification
|
||||||
void replace(char find, char replace);
|
void replace(char find, char replace);
|
||||||
void replace(const String &find, const String &replace);
|
void replace(const String &find, const String &replace);
|
||||||
|
void replace(const char *find, const String &replace) {
|
||||||
|
this->replace(String(find), replace);
|
||||||
|
}
|
||||||
|
void replace(const __FlashStringHelper *find, const String &replace) {
|
||||||
|
this->replace(String(find), replace);
|
||||||
|
}
|
||||||
|
void replace(const char *find, const char *replace) {
|
||||||
|
this->replace(String(find), String(replace));
|
||||||
|
}
|
||||||
|
void replace(const __FlashStringHelper *find, const char *replace) {
|
||||||
|
this->replace(String(find), String(replace));
|
||||||
|
}
|
||||||
|
void replace(const __FlashStringHelper *find, const __FlashStringHelper *replace) {
|
||||||
|
this->replace(String(find), String(replace));
|
||||||
|
}
|
||||||
void remove(unsigned int index);
|
void remove(unsigned int index);
|
||||||
void remove(unsigned int index, unsigned int count);
|
void remove(unsigned int index, unsigned int count);
|
||||||
void toLowerCase(void);
|
void toLowerCase(void);
|
||||||
|
@ -15,21 +15,34 @@
|
|||||||
#include "esp32-hal-adc.h"
|
#include "esp32-hal-adc.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "rom/ets_sys.h"
|
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_intr.h"
|
|
||||||
#include "soc/rtc_io_reg.h"
|
#include "soc/rtc_io_reg.h"
|
||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
#include "soc/sens_reg.h"
|
#include "soc/sens_reg.h"
|
||||||
|
|
||||||
|
#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
|
static uint8_t __analogAttenuation = 3;//11db
|
||||||
static uint8_t __analogWidth = 3;//12 bits
|
static uint8_t __analogWidth = 3;//12 bits
|
||||||
static uint8_t __analogCycles = 8;
|
|
||||||
static uint8_t __analogSamples = 0;//1 sample
|
|
||||||
static uint8_t __analogClockDiv = 1;
|
static uint8_t __analogClockDiv = 1;
|
||||||
|
static uint16_t __analogVRef = 0;
|
||||||
// Width of returned answer ()
|
static uint8_t __analogVRefPin = 0;
|
||||||
static uint8_t __analogReturnedWidth = 12;
|
|
||||||
|
|
||||||
void __analogSetWidth(uint8_t bits){
|
void __analogSetWidth(uint8_t bits){
|
||||||
if(bits < 9){
|
if(bits < 9){
|
||||||
@ -37,81 +50,31 @@ void __analogSetWidth(uint8_t bits){
|
|||||||
} else if(bits > 12){
|
} else if(bits > 12){
|
||||||
bits = 12;
|
bits = 12;
|
||||||
}
|
}
|
||||||
__analogReturnedWidth = bits;
|
|
||||||
__analogWidth = bits - 9;
|
__analogWidth = bits - 9;
|
||||||
SET_PERI_REG_BITS(SENS_SAR_START_FORCE_REG, SENS_SAR1_BIT_WIDTH, __analogWidth, SENS_SAR1_BIT_WIDTH_S);
|
adc1_config_width(__analogWidth);
|
||||||
SET_PERI_REG_BITS(SENS_SAR_READ_CTRL_REG, SENS_SAR1_SAMPLE_BIT, __analogWidth, SENS_SAR1_SAMPLE_BIT_S);
|
|
||||||
|
|
||||||
SET_PERI_REG_BITS(SENS_SAR_START_FORCE_REG, SENS_SAR2_BIT_WIDTH, __analogWidth, SENS_SAR2_BIT_WIDTH_S);
|
|
||||||
SET_PERI_REG_BITS(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_SAMPLE_BIT, __analogWidth, SENS_SAR2_SAMPLE_BIT_S);
|
|
||||||
}
|
|
||||||
|
|
||||||
void __analogSetCycles(uint8_t cycles){
|
|
||||||
__analogCycles = cycles;
|
|
||||||
SET_PERI_REG_BITS(SENS_SAR_READ_CTRL_REG, SENS_SAR1_SAMPLE_CYCLE, __analogCycles, SENS_SAR1_SAMPLE_CYCLE_S);
|
|
||||||
SET_PERI_REG_BITS(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_SAMPLE_CYCLE, __analogCycles, SENS_SAR2_SAMPLE_CYCLE_S);
|
|
||||||
}
|
|
||||||
|
|
||||||
void __analogSetSamples(uint8_t samples){
|
|
||||||
if(!samples){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
__analogSamples = samples - 1;
|
|
||||||
SET_PERI_REG_BITS(SENS_SAR_READ_CTRL_REG, SENS_SAR1_SAMPLE_NUM, __analogSamples, SENS_SAR1_SAMPLE_NUM_S);
|
|
||||||
SET_PERI_REG_BITS(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_SAMPLE_NUM, __analogSamples, SENS_SAR2_SAMPLE_NUM_S);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __analogSetClockDiv(uint8_t clockDiv){
|
void __analogSetClockDiv(uint8_t clockDiv){
|
||||||
if(!clockDiv){
|
if(!clockDiv){
|
||||||
return;
|
clockDiv = 1;
|
||||||
}
|
}
|
||||||
__analogClockDiv = clockDiv;
|
__analogClockDiv = clockDiv;
|
||||||
SET_PERI_REG_BITS(SENS_SAR_READ_CTRL_REG, SENS_SAR1_CLK_DIV, __analogClockDiv, SENS_SAR1_CLK_DIV_S);
|
adc_set_clk_div(__analogClockDiv);
|
||||||
SET_PERI_REG_BITS(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_CLK_DIV, __analogClockDiv, SENS_SAR2_CLK_DIV_S);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __analogSetAttenuation(adc_attenuation_t attenuation)
|
void __analogSetAttenuation(adc_attenuation_t attenuation)
|
||||||
{
|
{
|
||||||
__analogAttenuation = attenuation & 3;
|
__analogAttenuation = attenuation & 3;
|
||||||
uint32_t att_data = 0;
|
|
||||||
int i = 10;
|
|
||||||
while(i--){
|
|
||||||
att_data |= __analogAttenuation << (i * 2);
|
|
||||||
}
|
|
||||||
WRITE_PERI_REG(SENS_SAR_ATTEN1_REG, att_data & 0xFFFF);//ADC1 has 8 channels
|
|
||||||
WRITE_PERI_REG(SENS_SAR_ATTEN2_REG, att_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR __analogInit(){
|
void __analogInit(){
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
if(initialized){
|
if(initialized){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
initialized = true;
|
||||||
__analogSetAttenuation(__analogAttenuation);
|
|
||||||
__analogSetCycles(__analogCycles);
|
|
||||||
__analogSetSamples(__analogSamples + 1);//in samples
|
|
||||||
__analogSetClockDiv(__analogClockDiv);
|
__analogSetClockDiv(__analogClockDiv);
|
||||||
__analogSetWidth(__analogWidth + 9);//in bits
|
__analogSetWidth(__analogWidth + 9);//in bits
|
||||||
|
|
||||||
SET_PERI_REG_MASK(SENS_SAR_READ_CTRL_REG, SENS_SAR1_DATA_INV);
|
|
||||||
SET_PERI_REG_MASK(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_DATA_INV);
|
|
||||||
|
|
||||||
SET_PERI_REG_MASK(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_START_FORCE_M); //SAR ADC1 controller (in RTC) is started by SW
|
|
||||||
SET_PERI_REG_MASK(SENS_SAR_MEAS_START1_REG, SENS_SAR1_EN_PAD_FORCE_M); //SAR ADC1 pad enable bitmap is controlled by SW
|
|
||||||
SET_PERI_REG_MASK(SENS_SAR_MEAS_START2_REG, SENS_MEAS2_START_FORCE_M); //SAR ADC2 controller (in RTC) is started by SW
|
|
||||||
SET_PERI_REG_MASK(SENS_SAR_MEAS_START2_REG, SENS_SAR2_EN_PAD_FORCE_M); //SAR ADC2 pad enable bitmap is controlled by SW
|
|
||||||
|
|
||||||
CLEAR_PERI_REG_MASK(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR_M); //force XPD_SAR=0, use XPD_FSM
|
|
||||||
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_AMP, 0x2, SENS_FORCE_XPD_AMP_S); //force XPD_AMP=0
|
|
||||||
|
|
||||||
CLEAR_PERI_REG_MASK(SENS_SAR_MEAS_CTRL_REG, 0xfff << SENS_AMP_RST_FB_FSM_S); //clear FSM
|
|
||||||
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT1_REG, SENS_SAR_AMP_WAIT1, 0x1, SENS_SAR_AMP_WAIT1_S);
|
|
||||||
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT1_REG, SENS_SAR_AMP_WAIT2, 0x1, SENS_SAR_AMP_WAIT2_S);
|
|
||||||
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_SAR_AMP_WAIT3, 0x1, SENS_SAR_AMP_WAIT3_S);
|
|
||||||
while (GET_PERI_REG_BITS2(SENS_SAR_SLAVE_ADDR1_REG, 0x7, SENS_MEAS_STATUS_S) != 0); //wait det_fsm==
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation)
|
void __analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation)
|
||||||
@ -120,21 +83,20 @@ void __analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation)
|
|||||||
if(channel < 0 || attenuation > 3){
|
if(channel < 0 || attenuation > 3){
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
__analogInit();
|
if(channel > 9){
|
||||||
if(channel > 7){
|
adc2_config_channel_atten(channel - 10, attenuation);
|
||||||
SET_PERI_REG_BITS(SENS_SAR_ATTEN2_REG, 3, attenuation, ((channel - 10) * 2));
|
|
||||||
} else {
|
} else {
|
||||||
SET_PERI_REG_BITS(SENS_SAR_ATTEN1_REG, 3, attenuation, (channel * 2));
|
adc1_config_channel_atten(channel, attenuation);
|
||||||
}
|
}
|
||||||
|
__analogInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IRAM_ATTR __adcAttachPin(uint8_t pin){
|
bool __adcAttachPin(uint8_t pin){
|
||||||
|
|
||||||
int8_t channel = digitalPinToAnalogChannel(pin);
|
int8_t channel = digitalPinToAnalogChannel(pin);
|
||||||
if(channel < 0){
|
if(channel < 0){
|
||||||
return false;//not adc pin
|
log_e("Pin %u is not ADC pin!", pin);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t pad = digitalPinToTouchChannel(pin);
|
int8_t pad = digitalPinToTouchChannel(pin);
|
||||||
if(pad >= 0){
|
if(pad >= 0){
|
||||||
uint32_t touch = READ_PERI_REG(SENS_SAR_TOUCH_ENABLE_REG);
|
uint32_t touch = READ_PERI_REG(SENS_SAR_TOUCH_ENABLE_REG);
|
||||||
@ -151,86 +113,103 @@ bool IRAM_ATTR __adcAttachPin(uint8_t pin){
|
|||||||
}
|
}
|
||||||
|
|
||||||
pinMode(pin, ANALOG);
|
pinMode(pin, ANALOG);
|
||||||
|
__analogSetPinAttenuation(pin, __analogAttenuation);
|
||||||
__analogInit();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IRAM_ATTR __adcStart(uint8_t pin){
|
|
||||||
|
|
||||||
int8_t channel = digitalPinToAnalogChannel(pin);
|
|
||||||
if(channel < 0){
|
|
||||||
return false;//not adc pin
|
|
||||||
}
|
|
||||||
|
|
||||||
if(channel > 9){
|
|
||||||
channel -= 10;
|
|
||||||
CLEAR_PERI_REG_MASK(SENS_SAR_MEAS_START2_REG, SENS_MEAS2_START_SAR_M);
|
|
||||||
SET_PERI_REG_BITS(SENS_SAR_MEAS_START2_REG, SENS_SAR2_EN_PAD, (1 << channel), SENS_SAR2_EN_PAD_S);
|
|
||||||
SET_PERI_REG_MASK(SENS_SAR_MEAS_START2_REG, SENS_MEAS2_START_SAR_M);
|
|
||||||
} else {
|
|
||||||
CLEAR_PERI_REG_MASK(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_START_SAR_M);
|
|
||||||
SET_PERI_REG_BITS(SENS_SAR_MEAS_START1_REG, SENS_SAR1_EN_PAD, (1 << channel), SENS_SAR1_EN_PAD_S);
|
|
||||||
SET_PERI_REG_MASK(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_START_SAR_M);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IRAM_ATTR __adcBusy(uint8_t pin){
|
|
||||||
|
|
||||||
int8_t channel = digitalPinToAnalogChannel(pin);
|
|
||||||
if(channel < 0){
|
|
||||||
return false;//not adc pin
|
|
||||||
}
|
|
||||||
|
|
||||||
if(channel > 7){
|
|
||||||
return (GET_PERI_REG_MASK(SENS_SAR_MEAS_START2_REG, SENS_MEAS2_DONE_SAR) == 0);
|
|
||||||
}
|
|
||||||
return (GET_PERI_REG_MASK(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_DONE_SAR) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t IRAM_ATTR __adcEnd(uint8_t pin)
|
|
||||||
{
|
|
||||||
|
|
||||||
uint16_t value = 0;
|
|
||||||
int8_t channel = digitalPinToAnalogChannel(pin);
|
|
||||||
if(channel < 0){
|
|
||||||
return 0;//not adc pin
|
|
||||||
}
|
|
||||||
if(channel > 7){
|
|
||||||
while (GET_PERI_REG_MASK(SENS_SAR_MEAS_START2_REG, SENS_MEAS2_DONE_SAR) == 0); //wait for conversion
|
|
||||||
value = GET_PERI_REG_BITS2(SENS_SAR_MEAS_START2_REG, SENS_MEAS2_DATA_SAR, SENS_MEAS2_DATA_SAR_S);
|
|
||||||
} else {
|
|
||||||
while (GET_PERI_REG_MASK(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_DONE_SAR) == 0); //wait for conversion
|
|
||||||
value = GET_PERI_REG_BITS2(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_DATA_SAR, SENS_MEAS1_DATA_SAR_S);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shift result if necessary
|
|
||||||
uint8_t from = __analogWidth + 9;
|
|
||||||
if (from == __analogReturnedWidth) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
if (from > __analogReturnedWidth) {
|
|
||||||
return value >> (from - __analogReturnedWidth);
|
|
||||||
}
|
|
||||||
return value << (__analogReturnedWidth - from);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t IRAM_ATTR __analogRead(uint8_t pin)
|
|
||||||
{
|
|
||||||
if(!__adcAttachPin(pin) || !__adcStart(pin)){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return __adcEnd(pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
void __analogReadResolution(uint8_t bits)
|
void __analogReadResolution(uint8_t bits)
|
||||||
{
|
{
|
||||||
if(!bits || bits > 16){
|
if(!bits || bits > 16){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
__analogSetWidth(bits); // hadware from 9 to 12
|
__analogSetWidth(bits); // hadware from 9 to 12
|
||||||
__analogReturnedWidth = bits; // software from 1 to 16
|
}
|
||||||
|
|
||||||
|
uint16_t __analogRead(uint8_t pin)
|
||||||
|
{
|
||||||
|
int8_t channel = digitalPinToAnalogChannel(pin);
|
||||||
|
int value = 0;
|
||||||
|
esp_err_t r = ESP_OK;
|
||||||
|
if(channel < 0){
|
||||||
|
log_e("Pin %u is not ADC pin!", pin);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
__adcAttachPin(pin);
|
||||||
|
if(channel > 9){
|
||||||
|
channel -= 10;
|
||||||
|
r = adc2_get_raw( channel, __analogWidth, &value);
|
||||||
|
if ( r == ESP_OK ) {
|
||||||
|
return value;
|
||||||
|
} else if ( r == ESP_ERR_INVALID_STATE ) {
|
||||||
|
log_e("GPIO%u: %s: ADC2 not initialized yet.", pin, esp_err_to_name(r));
|
||||||
|
} else if ( r == ESP_ERR_TIMEOUT ) {
|
||||||
|
log_e("GPIO%u: %s: ADC2 is in use by Wi-Fi.", pin, esp_err_to_name(r));
|
||||||
|
} else {
|
||||||
|
log_e("GPIO%u: %s", pin, esp_err_to_name(r));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return adc1_get_raw(channel);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __analogSetVRefPin(uint8_t pin){
|
||||||
|
if(pin <25 || pin > 27){
|
||||||
|
pin = 0;
|
||||||
|
}
|
||||||
|
__analogVRefPin = pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t __analogReadMilliVolts(uint8_t pin){
|
||||||
|
int8_t channel = digitalPinToAnalogChannel(pin);
|
||||||
|
if(channel < 0){
|
||||||
|
log_e("Pin %u is not ADC pin!", pin);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(!__analogVRef){
|
||||||
|
if (esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP) == ESP_OK) {
|
||||||
|
log_d("eFuse Two Point: Supported");
|
||||||
|
__analogVRef = DEFAULT_VREF;
|
||||||
|
}
|
||||||
|
if (esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_VREF) == ESP_OK) {
|
||||||
|
log_d("eFuse Vref: Supported");
|
||||||
|
__analogVRef = DEFAULT_VREF;
|
||||||
|
}
|
||||||
|
if(!__analogVRef){
|
||||||
|
__analogVRef = DEFAULT_VREF;
|
||||||
|
if(__analogVRefPin){
|
||||||
|
esp_adc_cal_characteristics_t chars;
|
||||||
|
if(adc2_vref_to_gpio(__analogVRefPin) == ESP_OK){
|
||||||
|
__analogVRef = __analogRead(__analogVRefPin);
|
||||||
|
esp_adc_cal_characterize(1, __analogAttenuation, __analogWidth, DEFAULT_VREF, &chars);
|
||||||
|
__analogVRef = esp_adc_cal_raw_to_voltage(__analogVRef, &chars);
|
||||||
|
log_d("Vref to GPIO%u: %u", __analogVRefPin, __analogVRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint8_t unit = 1;
|
||||||
|
if(channel > 9){
|
||||||
|
unit = 2;
|
||||||
|
}
|
||||||
|
uint16_t adc_reading = __analogRead(pin);
|
||||||
|
if(__analogCharacteristics[unit - 1] == NULL){
|
||||||
|
__analogCharacteristics[unit - 1] = calloc(1, sizeof(esp_adc_cal_characteristics_t));
|
||||||
|
if(__analogCharacteristics[unit - 1] == NULL){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
esp_adc_cal_value_t val_type = esp_adc_cal_characterize(unit, __analogAttenuation, __analogWidth, __analogVRef, __analogCharacteristics[unit - 1]);
|
||||||
|
if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP) {
|
||||||
|
log_i("ADC%u: Characterized using Two Point Value: %u\n", unit, __analogCharacteristics[unit - 1]->vref);
|
||||||
|
} else if (val_type == ESP_ADC_CAL_VAL_EFUSE_VREF) {
|
||||||
|
log_i("ADC%u: Characterized using eFuse Vref: %u\n", unit, __analogCharacteristics[unit - 1]->vref);
|
||||||
|
} else if(__analogVRef != DEFAULT_VREF){
|
||||||
|
log_i("ADC%u: Characterized using Vref to GPIO%u: %u\n", unit, __analogVRefPin, __analogCharacteristics[unit - 1]->vref);
|
||||||
|
} else {
|
||||||
|
log_i("ADC%u: Characterized using Default Vref: %u\n", unit, __analogCharacteristics[unit - 1]->vref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return esp_adc_cal_raw_to_voltage(adc_reading, __analogCharacteristics[unit - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int __hallRead() //hall sensor without LNA
|
int __hallRead() //hall sensor without LNA
|
||||||
@ -260,14 +239,12 @@ int __hallRead() //hall sensor without LNA
|
|||||||
extern uint16_t analogRead(uint8_t pin) __attribute__ ((weak, alias("__analogRead")));
|
extern uint16_t analogRead(uint8_t pin) __attribute__ ((weak, alias("__analogRead")));
|
||||||
extern void analogReadResolution(uint8_t bits) __attribute__ ((weak, alias("__analogReadResolution")));
|
extern void analogReadResolution(uint8_t bits) __attribute__ ((weak, alias("__analogReadResolution")));
|
||||||
extern void analogSetWidth(uint8_t bits) __attribute__ ((weak, alias("__analogSetWidth")));
|
extern void analogSetWidth(uint8_t bits) __attribute__ ((weak, alias("__analogSetWidth")));
|
||||||
extern void analogSetCycles(uint8_t cycles) __attribute__ ((weak, alias("__analogSetCycles")));
|
|
||||||
extern void analogSetSamples(uint8_t samples) __attribute__ ((weak, alias("__analogSetSamples")));
|
|
||||||
extern void analogSetClockDiv(uint8_t clockDiv) __attribute__ ((weak, alias("__analogSetClockDiv")));
|
extern void analogSetClockDiv(uint8_t clockDiv) __attribute__ ((weak, alias("__analogSetClockDiv")));
|
||||||
extern void analogSetAttenuation(adc_attenuation_t attenuation) __attribute__ ((weak, alias("__analogSetAttenuation")));
|
extern void analogSetAttenuation(adc_attenuation_t attenuation) __attribute__ ((weak, alias("__analogSetAttenuation")));
|
||||||
extern void analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation) __attribute__ ((weak, alias("__analogSetPinAttenuation")));
|
extern void analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation) __attribute__ ((weak, alias("__analogSetPinAttenuation")));
|
||||||
extern int hallRead() __attribute__ ((weak, alias("__hallRead")));
|
extern int hallRead() __attribute__ ((weak, alias("__hallRead")));
|
||||||
|
|
||||||
extern bool adcAttachPin(uint8_t pin) __attribute__ ((weak, alias("__adcAttachPin")));
|
extern bool adcAttachPin(uint8_t pin) __attribute__ ((weak, alias("__adcAttachPin")));
|
||||||
extern bool adcStart(uint8_t pin) __attribute__ ((weak, alias("__adcStart")));
|
|
||||||
extern bool adcBusy(uint8_t pin) __attribute__ ((weak, alias("__adcBusy")));
|
extern void analogSetVRefPin(uint8_t pin) __attribute__ ((weak, alias("__analogSetVRefPin")));
|
||||||
extern uint16_t adcEnd(uint8_t pin) __attribute__ ((weak, alias("__adcEnd")));
|
extern uint32_t analogReadMilliVolts(uint8_t pin) __attribute__ ((weak, alias("__analogReadMilliVolts")));
|
||||||
|
@ -54,24 +54,6 @@ void analogReadResolution(uint8_t bits);
|
|||||||
* */
|
* */
|
||||||
void analogSetWidth(uint8_t bits);
|
void analogSetWidth(uint8_t bits);
|
||||||
|
|
||||||
/*
|
|
||||||
* Set number of cycles per sample
|
|
||||||
* Default is 8 and seems to do well
|
|
||||||
* Range is 1 - 255
|
|
||||||
* */
|
|
||||||
void analogSetCycles(uint8_t cycles);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set number of samples in the range.
|
|
||||||
* Default is 1
|
|
||||||
* Range is 1 - 255
|
|
||||||
* This setting splits the range into
|
|
||||||
* "samples" pieces, which could look
|
|
||||||
* like the sensitivity has been multiplied
|
|
||||||
* that many times
|
|
||||||
* */
|
|
||||||
void analogSetSamples(uint8_t samples);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the divider for the ADC clock.
|
* Set the divider for the ADC clock.
|
||||||
* Default is 1
|
* Default is 1
|
||||||
@ -97,34 +79,20 @@ void analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation);
|
|||||||
* */
|
* */
|
||||||
int hallRead();
|
int hallRead();
|
||||||
|
|
||||||
/*
|
|
||||||
* Non-Blocking API (almost)
|
|
||||||
*
|
|
||||||
* Note: ADC conversion can run only for single pin at a time.
|
|
||||||
* That means that if you want to run ADC on two pins on the same bus,
|
|
||||||
* you need to run them one after another. Probably the best use would be
|
|
||||||
* to start conversion on both buses in parallel.
|
|
||||||
* */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attach pin to ADC (will also clear any other analog mode that could be on)
|
* Attach pin to ADC (will also clear any other analog mode that could be on)
|
||||||
* */
|
* */
|
||||||
bool adcAttachPin(uint8_t pin);
|
bool adcAttachPin(uint8_t pin);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start ADC conversion on attached pin's bus
|
* Set pin to use for ADC calibration if the esp is not already calibrated (25, 26 or 27)
|
||||||
* */
|
* */
|
||||||
bool adcStart(uint8_t pin);
|
void analogSetVRefPin(uint8_t pin);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if conversion on the pin's ADC bus is currently running
|
* Get MilliVolts value for pin
|
||||||
* */
|
* */
|
||||||
bool adcBusy(uint8_t pin);
|
uint32_t analogReadMilliVolts(uint8_t pin);
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the result of the conversion (will wait if it have not finished)
|
|
||||||
* */
|
|
||||||
uint16_t adcEnd(uint8_t pin);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,14 @@ bool btStop(){
|
|||||||
while(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_ENABLED);
|
while(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_ENABLED);
|
||||||
}
|
}
|
||||||
if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_INITED){
|
if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_INITED){
|
||||||
|
if (esp_bt_controller_deinit()) {
|
||||||
|
log_e("BT deint failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
vTaskDelay(1);
|
||||||
|
if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
log_e("BT Stop failed");
|
log_e("BT Stop failed");
|
||||||
|
@ -21,13 +21,24 @@
|
|||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "soc/rtc.h"
|
#include "soc/rtc.h"
|
||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
#include "rom/rtc.h"
|
|
||||||
#include "soc/apb_ctrl_reg.h"
|
#include "soc/apb_ctrl_reg.h"
|
||||||
#include "soc/efuse_reg.h"
|
#include "soc/efuse_reg.h"
|
||||||
#include "esp32-hal.h"
|
#include "esp32-hal.h"
|
||||||
#include "esp32-hal-cpu.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 {
|
typedef struct apb_change_cb_s {
|
||||||
|
struct apb_change_cb_s * prev;
|
||||||
struct apb_change_cb_s * next;
|
struct apb_change_cb_s * next;
|
||||||
void * arg;
|
void * arg;
|
||||||
apb_change_cb_t cb;
|
apb_change_cb_t cb;
|
||||||
@ -53,10 +64,20 @@ static void triggerApbChangeCallback(apb_change_ev_t ev_type, uint32_t old_apb,
|
|||||||
initApbChangeCallback();
|
initApbChangeCallback();
|
||||||
xSemaphoreTake(apb_change_lock, portMAX_DELAY);
|
xSemaphoreTake(apb_change_lock, portMAX_DELAY);
|
||||||
apb_change_t * r = apb_change_callbacks;
|
apb_change_t * r = apb_change_callbacks;
|
||||||
|
if( r != NULL ){
|
||||||
|
if(ev_type == APB_BEFORE_CHANGE )
|
||||||
while(r != NULL){
|
while(r != NULL){
|
||||||
r->cb(r->arg, ev_type, old_apb, new_apb);
|
r->cb(r->arg, ev_type, old_apb, new_apb);
|
||||||
r=r->next;
|
r=r->next;
|
||||||
}
|
}
|
||||||
|
else { // run backwards through chain
|
||||||
|
while(r->next != NULL) r = r->next; // find first added
|
||||||
|
while( r != NULL){
|
||||||
|
r->cb(r->arg, ev_type, old_apb, new_apb);
|
||||||
|
r=r->prev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
xSemaphoreGive(apb_change_lock);
|
xSemaphoreGive(apb_change_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +89,7 @@ bool addApbChangeCallback(void * arg, apb_change_cb_t cb){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
c->next = NULL;
|
c->next = NULL;
|
||||||
|
c->prev = NULL;
|
||||||
c->arg = arg;
|
c->arg = arg;
|
||||||
c->cb = cb;
|
c->cb = cb;
|
||||||
xSemaphoreTake(apb_change_lock, portMAX_DELAY);
|
xSemaphoreTake(apb_change_lock, portMAX_DELAY);
|
||||||
@ -75,18 +97,20 @@ bool addApbChangeCallback(void * arg, apb_change_cb_t cb){
|
|||||||
apb_change_callbacks = c;
|
apb_change_callbacks = c;
|
||||||
} else {
|
} else {
|
||||||
apb_change_t * r = apb_change_callbacks;
|
apb_change_t * r = apb_change_callbacks;
|
||||||
if(r->cb != cb || r->arg != arg){
|
// look for duplicate callbacks
|
||||||
while(r->next){
|
while( (r != NULL ) && !((r->cb == cb) && ( r->arg == arg))) r = r->next;
|
||||||
r = r->next;
|
if (r) {
|
||||||
if(r->cb == cb && r->arg == arg){
|
log_e("duplicate func=%08X arg=%08X",c->cb,c->arg);
|
||||||
free(c);
|
free(c);
|
||||||
goto unlock_and_exit;
|
xSemaphoreGive(apb_change_lock);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
c->next = apb_change_callbacks;
|
||||||
|
apb_change_callbacks-> prev = c;
|
||||||
|
apb_change_callbacks = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r->next = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unlock_and_exit:
|
|
||||||
xSemaphoreGive(apb_change_lock);
|
xSemaphoreGive(apb_change_lock);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -95,24 +119,21 @@ bool removeApbChangeCallback(void * arg, apb_change_cb_t cb){
|
|||||||
initApbChangeCallback();
|
initApbChangeCallback();
|
||||||
xSemaphoreTake(apb_change_lock, portMAX_DELAY);
|
xSemaphoreTake(apb_change_lock, portMAX_DELAY);
|
||||||
apb_change_t * r = apb_change_callbacks;
|
apb_change_t * r = apb_change_callbacks;
|
||||||
|
// look for matching callback
|
||||||
|
while( (r != NULL ) && !((r->cb == cb) && ( r->arg == arg))) r = r->next;
|
||||||
if ( r == NULL ) {
|
if ( r == NULL ) {
|
||||||
|
log_e("not found func=%08X arg=%08X",cb,arg);
|
||||||
xSemaphoreGive(apb_change_lock);
|
xSemaphoreGive(apb_change_lock);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(r->cb == cb && r->arg == arg){
|
else {
|
||||||
|
// patch links
|
||||||
|
if(r->prev) r->prev->next = r->next;
|
||||||
|
else { // this is first link
|
||||||
apb_change_callbacks = r->next;
|
apb_change_callbacks = r->next;
|
||||||
|
}
|
||||||
|
if(r->next) r->next->prev = r->prev;
|
||||||
free(r);
|
free(r);
|
||||||
} else {
|
|
||||||
while(r->next && (r->next->cb != cb || r->next->arg != arg)){
|
|
||||||
r = r->next;
|
|
||||||
}
|
|
||||||
if(r->next == NULL || r->next->cb != cb || r->next->arg != arg){
|
|
||||||
xSemaphoreGive(apb_change_lock);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
apb_change_t * c = r->next;
|
|
||||||
r->next = c->next;
|
|
||||||
free(c);
|
|
||||||
}
|
}
|
||||||
xSemaphoreGive(apb_change_lock);
|
xSemaphoreGive(apb_change_lock);
|
||||||
return true;
|
return true;
|
||||||
|
@ -15,13 +15,24 @@
|
|||||||
#include "esp32-hal-dac.h"
|
#include "esp32-hal-dac.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "rom/ets_sys.h"
|
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_intr.h"
|
|
||||||
#include "soc/rtc_io_reg.h"
|
#include "soc/rtc_io_reg.h"
|
||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
#include "soc/sens_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)
|
void IRAM_ATTR __dacWrite(uint8_t pin, uint8_t value)
|
||||||
{
|
{
|
||||||
if(pin < 25 || pin > 26){
|
if(pin < 25 || pin > 26){
|
||||||
|
@ -15,15 +15,27 @@
|
|||||||
#include "esp32-hal-gpio.h"
|
#include "esp32-hal-gpio.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "rom/ets_sys.h"
|
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_intr.h"
|
|
||||||
#include "rom/gpio.h"
|
|
||||||
#include "soc/gpio_reg.h"
|
#include "soc/gpio_reg.h"
|
||||||
#include "soc/io_mux_reg.h"
|
#include "soc/io_mux_reg.h"
|
||||||
#include "soc/gpio_struct.h"
|
#include "soc/gpio_struct.h"
|
||||||
#include "soc/rtc_io_reg.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 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]={
|
const DRAM_ATTR esp32_gpioMux_t esp32_gpioMux[GPIO_PIN_COUNT]={
|
||||||
@ -59,8 +71,8 @@ const DRAM_ATTR esp32_gpioMux_t esp32_gpioMux[GPIO_PIN_COUNT]={
|
|||||||
{0, -1, -1, -1},
|
{0, -1, -1, -1},
|
||||||
{0, -1, -1, -1},
|
{0, -1, -1, -1},
|
||||||
{0, -1, -1, -1},
|
{0, -1, -1, -1},
|
||||||
{0x1c, 9, 4, 9},
|
{0x1c, 9, 4, 8},
|
||||||
{0x20, 8, 5, 8},
|
{0x20, 8, 5, 9},
|
||||||
{0x14, 4, 6, -1},
|
{0x14, 4, 6, -1},
|
||||||
{0x18, 5, 7, -1},
|
{0x18, 5, 7, -1},
|
||||||
{0x04, 0, 0, -1},
|
{0x04, 0, 0, -1},
|
||||||
|
@ -18,13 +18,25 @@
|
|||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "freertos/event_groups.h"
|
#include "freertos/event_groups.h"
|
||||||
#include "rom/ets_sys.h"
|
|
||||||
#include "driver/periph_ctrl.h"
|
#include "driver/periph_ctrl.h"
|
||||||
#include "soc/i2c_reg.h"
|
#include "soc/i2c_reg.h"
|
||||||
#include "soc/i2c_struct.h"
|
#include "soc/i2c_struct.h"
|
||||||
#include "soc/dport_reg.h"
|
#include "soc/dport_reg.h"
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp32-hal-cpu.h" // cpu clock change support 31DEC2018
|
#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) (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_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))
|
#define I2C_SCL_IDX(p) ((p==0)?I2CEXT0_SCL_OUT_IDX:((p==1)?I2CEXT1_SCL_OUT_IDX:0))
|
||||||
|
@ -16,19 +16,29 @@
|
|||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "rom/ets_sys.h"
|
|
||||||
#include "esp32-hal-matrix.h"
|
#include "esp32-hal-matrix.h"
|
||||||
#include "soc/dport_reg.h"
|
#include "soc/dport_reg.h"
|
||||||
#include "soc/ledc_reg.h"
|
#include "soc/ledc_reg.h"
|
||||||
#include "soc/ledc_struct.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
|
#if CONFIG_DISABLE_HAL_LOCKS
|
||||||
#define LEDC_MUTEX_LOCK()
|
#define LEDC_MUTEX_LOCK()
|
||||||
#define LEDC_MUTEX_UNLOCK()
|
#define LEDC_MUTEX_UNLOCK()
|
||||||
#else
|
#else
|
||||||
#define LEDC_MUTEX_LOCK() do {} while (xSemaphoreTake(_ledc_sys_lock, portMAX_DELAY) != pdPASS)
|
#define LEDC_MUTEX_LOCK() do {} while (xSemaphoreTake(_ledc_sys_lock, portMAX_DELAY) != pdPASS)
|
||||||
#define LEDC_MUTEX_UNLOCK() xSemaphoreGive(_ledc_sys_lock)
|
#define LEDC_MUTEX_UNLOCK() xSemaphoreGive(_ledc_sys_lock)
|
||||||
xSemaphoreHandle _ledc_sys_lock;
|
xSemaphoreHandle _ledc_sys_lock = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -55,18 +65,19 @@ xSemaphoreHandle _ledc_sys_lock;
|
|||||||
|
|
||||||
static void _on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old_apb, uint32_t new_apb){
|
static void _on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old_apb, uint32_t new_apb){
|
||||||
if(ev_type == APB_AFTER_CHANGE && old_apb != new_apb){
|
if(ev_type == APB_AFTER_CHANGE && old_apb != new_apb){
|
||||||
uint32_t iarg = (uint32_t)arg;
|
uint16_t iarg = *(uint16_t*)arg;
|
||||||
uint8_t chan = iarg;
|
uint8_t chan = 0;
|
||||||
uint8_t group=(chan/8), timer=((chan/2)%4);
|
|
||||||
old_apb /= 1000000;
|
old_apb /= 1000000;
|
||||||
new_apb /= 1000000;
|
new_apb /= 1000000;
|
||||||
|
while(iarg){ // run though all active channels, adjusting timing configurations
|
||||||
|
if(iarg & 1) {// this channel is active
|
||||||
|
uint8_t group=(chan/8), timer=((chan/2)%4);
|
||||||
if(LEDC_TIMER(group, timer).conf.tick_sel){
|
if(LEDC_TIMER(group, timer).conf.tick_sel){
|
||||||
LEDC_MUTEX_LOCK();
|
LEDC_MUTEX_LOCK();
|
||||||
uint32_t old_div = LEDC_TIMER(group, timer).conf.clock_divider;
|
uint32_t old_div = LEDC_TIMER(group, timer).conf.clock_divider;
|
||||||
uint32_t div_num = (new_apb * old_div) / old_apb;
|
uint32_t div_num = (new_apb * old_div) / old_apb;
|
||||||
if(div_num > LEDC_DIV_NUM_HSTIMER0_V){
|
if(div_num > LEDC_DIV_NUM_HSTIMER0_V){
|
||||||
new_apb = REF_CLK_FREQ / 1000000;
|
div_num = ((REF_CLK_FREQ /1000000) * old_div) / old_apb;
|
||||||
div_num = (new_apb * old_div) / old_apb;
|
|
||||||
if(div_num > LEDC_DIV_NUM_HSTIMER0_V) {
|
if(div_num > LEDC_DIV_NUM_HSTIMER0_V) {
|
||||||
div_num = LEDC_DIV_NUM_HSTIMER0_V;//lowest clock possible
|
div_num = LEDC_DIV_NUM_HSTIMER0_V;//lowest clock possible
|
||||||
}
|
}
|
||||||
@ -77,6 +88,13 @@ static void _on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old_apb
|
|||||||
LEDC_TIMER(group, timer).conf.clock_divider = div_num;
|
LEDC_TIMER(group, timer).conf.clock_divider = div_num;
|
||||||
LEDC_MUTEX_UNLOCK();
|
LEDC_MUTEX_UNLOCK();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
log_d("using REF_CLK chan=%d",chan);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iarg = iarg >> 1;
|
||||||
|
chan++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,11 +103,14 @@ static void _ledcSetupTimer(uint8_t chan, uint32_t div_num, uint8_t bit_num, boo
|
|||||||
{
|
{
|
||||||
uint8_t group=(chan/8), timer=((chan/2)%4);
|
uint8_t group=(chan/8), timer=((chan/2)%4);
|
||||||
static bool tHasStarted = false;
|
static bool tHasStarted = false;
|
||||||
|
static uint16_t _activeChannels = 0;
|
||||||
if(!tHasStarted) {
|
if(!tHasStarted) {
|
||||||
tHasStarted = true;
|
tHasStarted = true;
|
||||||
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_LEDC_CLK_EN);
|
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_LEDC_CLK_EN);
|
||||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_LEDC_RST);
|
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_LEDC_RST);
|
||||||
LEDC.conf.apb_clk_sel = 1;//LS use apb clock
|
LEDC.conf.apb_clk_sel = 1;//LS use apb clock
|
||||||
|
addApbChangeCallback((void*)&_activeChannels, _on_apb_change);
|
||||||
|
|
||||||
#if !CONFIG_DISABLE_HAL_LOCKS
|
#if !CONFIG_DISABLE_HAL_LOCKS
|
||||||
_ledc_sys_lock = xSemaphoreCreateMutex();
|
_ledc_sys_lock = xSemaphoreCreateMutex();
|
||||||
#endif
|
#endif
|
||||||
@ -105,8 +126,7 @@ static void _ledcSetupTimer(uint8_t chan, uint32_t div_num, uint8_t bit_num, boo
|
|||||||
LEDC_TIMER(group, timer).conf.rst = 1;//This bit is used to reset timer the counter will be 0 after reset.
|
LEDC_TIMER(group, timer).conf.rst = 1;//This bit is used to reset timer the counter will be 0 after reset.
|
||||||
LEDC_TIMER(group, timer).conf.rst = 0;
|
LEDC_TIMER(group, timer).conf.rst = 0;
|
||||||
LEDC_MUTEX_UNLOCK();
|
LEDC_MUTEX_UNLOCK();
|
||||||
uint32_t iarg = chan;
|
_activeChannels |= (1 << chan); // mark as active for APB callback
|
||||||
addApbChangeCallback((void*)iarg, _on_apb_change);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//max div_num 0x3FFFF (262143)
|
//max div_num 0x3FFFF (262143)
|
||||||
|
@ -14,7 +14,17 @@
|
|||||||
|
|
||||||
#include "esp32-hal-matrix.h"
|
#include "esp32-hal-matrix.h"
|
||||||
#include "esp_attr.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"
|
#include "rom/gpio.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MATRIX_DETACH_OUT_SIG 0x100
|
#define MATRIX_DETACH_OUT_SIG 0x100
|
||||||
#define MATRIX_DETACH_IN_LOW_PIN 0x30
|
#define MATRIX_DETACH_IN_LOW_PIN 0x30
|
||||||
|
@ -31,10 +31,20 @@
|
|||||||
#include "soc/rtc.h"
|
#include "soc/rtc.h"
|
||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
#include "soc/apb_ctrl_reg.h"
|
#include "soc/apb_ctrl_reg.h"
|
||||||
#include "rom/rtc.h"
|
|
||||||
#include "esp_task_wdt.h"
|
#include "esp_task_wdt.h"
|
||||||
#include "esp32-hal.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
|
//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
|
//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();
|
uint8_t temprature_sens_read();
|
||||||
@ -44,11 +54,13 @@ float temperatureRead()
|
|||||||
return (temprature_sens_read() - 32) / 1.8;
|
return (temprature_sens_read() - 32) / 1.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void yield()
|
void __yield()
|
||||||
{
|
{
|
||||||
vPortYield();
|
vPortYield();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void yield() __attribute__ ((weak, alias("__yield")));
|
||||||
|
|
||||||
#if CONFIG_AUTOSTART_ARDUINO
|
#if CONFIG_AUTOSTART_ARDUINO
|
||||||
|
|
||||||
extern TaskHandle_t loopTaskHandle;
|
extern TaskHandle_t loopTaskHandle;
|
||||||
|
@ -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"
|
#include "esp32-hal.h"
|
||||||
|
|
||||||
#if CONFIG_SPIRAM_SUPPORT
|
#if CONFIG_SPIRAM_SUPPORT
|
||||||
#include "esp_spiram.h"
|
|
||||||
#include "soc/efuse_reg.h"
|
#include "soc/efuse_reg.h"
|
||||||
#include "esp_heap_caps.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 spiramDetected = false;
|
||||||
static volatile bool spiramFailed = false;
|
static volatile bool spiramFailed = false;
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ static xSemaphoreHandle g_rmt_block_lock = NULL;
|
|||||||
*/
|
*/
|
||||||
static void _initPin(int pin, int channel, bool tx_not_rx);
|
static void _initPin(int pin, int channel, bool tx_not_rx);
|
||||||
|
|
||||||
static bool _rmtSendOnce(rmt_obj_t* rmt, rmt_data_t* data, size_t size);
|
static bool _rmtSendOnce(rmt_obj_t* rmt, rmt_data_t* data, size_t size, bool continuous);
|
||||||
|
|
||||||
static void IRAM_ATTR _rmt_isr(void* arg);
|
static void IRAM_ATTR _rmt_isr(void* arg);
|
||||||
|
|
||||||
@ -234,6 +234,20 @@ bool rmtDeinit(rmt_obj_t *rmt)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool rmtLoop(rmt_obj_t* rmt, rmt_data_t* data, size_t size)
|
||||||
|
{
|
||||||
|
if (!rmt) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int allocated_size = MAX_DATA_PER_CHANNEL * rmt->buffers;
|
||||||
|
|
||||||
|
if (size > allocated_size) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return _rmtSendOnce(rmt, data, size, true);
|
||||||
|
}
|
||||||
|
|
||||||
bool rmtWrite(rmt_obj_t* rmt, rmt_data_t* data, size_t size)
|
bool rmtWrite(rmt_obj_t* rmt, rmt_data_t* data, size_t size)
|
||||||
{
|
{
|
||||||
if (!rmt) {
|
if (!rmt) {
|
||||||
@ -282,10 +296,10 @@ bool rmtWrite(rmt_obj_t* rmt, rmt_data_t* data, size_t size)
|
|||||||
RMT_MUTEX_UNLOCK(channel);
|
RMT_MUTEX_UNLOCK(channel);
|
||||||
|
|
||||||
// start the transation
|
// start the transation
|
||||||
return _rmtSendOnce(rmt, data, MAX_DATA_PER_ITTERATION);
|
return _rmtSendOnce(rmt, data, MAX_DATA_PER_ITTERATION, false);
|
||||||
} else {
|
} else {
|
||||||
// use one-go mode if data fits one buffer
|
// use one-go mode if data fits one buffer
|
||||||
return _rmtSendOnce(rmt, data, size);
|
return _rmtSendOnce(rmt, data, size, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,7 +497,7 @@ rmt_obj_t* rmtInit(int pin, bool tx_not_rx, rmt_reserve_memsize_t memsize)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == MAX_CHANNELS || i+j >= MAX_CHANNELS || j != buffers) {
|
if (i == MAX_CHANNELS || i+j > MAX_CHANNELS || j != buffers) {
|
||||||
xSemaphoreGive(g_rmt_block_lock);
|
xSemaphoreGive(g_rmt_block_lock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -553,7 +567,7 @@ rmt_obj_t* rmtInit(int pin, bool tx_not_rx, rmt_reserve_memsize_t memsize)
|
|||||||
/**
|
/**
|
||||||
* Private methods definitions
|
* Private methods definitions
|
||||||
*/
|
*/
|
||||||
bool _rmtSendOnce(rmt_obj_t* rmt, rmt_data_t* data, size_t size)
|
bool _rmtSendOnce(rmt_obj_t* rmt, rmt_data_t* data, size_t size, bool continuous)
|
||||||
{
|
{
|
||||||
if (!rmt) {
|
if (!rmt) {
|
||||||
return false;
|
return false;
|
||||||
@ -571,6 +585,7 @@ bool _rmtSendOnce(rmt_obj_t* rmt, rmt_data_t* data, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
RMT_MUTEX_LOCK(channel);
|
RMT_MUTEX_LOCK(channel);
|
||||||
|
RMT.conf_ch[channel].conf1.tx_conti_mode = continuous;
|
||||||
RMT.conf_ch[channel].conf1.mem_rd_rst = 1;
|
RMT.conf_ch[channel].conf1.mem_rd_rst = 1;
|
||||||
RMT.conf_ch[channel].conf1.tx_start = 1;
|
RMT.conf_ch[channel].conf1.tx_start = 1;
|
||||||
RMT_MUTEX_UNLOCK(channel);
|
RMT_MUTEX_UNLOCK(channel);
|
||||||
|
@ -73,6 +73,12 @@ float rmtSetTick(rmt_obj_t* rmt, float tick);
|
|||||||
*/
|
*/
|
||||||
bool rmtWrite(rmt_obj_t* rmt, rmt_data_t* data, size_t size);
|
bool rmtWrite(rmt_obj_t* rmt, rmt_data_t* data, size_t size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loop data up to the reserved memsize continuously
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bool rmtLoop(rmt_obj_t* rmt, rmt_data_t* data, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiates async receive, event flag indicates data received
|
* Initiates async receive, event flag indicates data received
|
||||||
*
|
*
|
||||||
|
@ -16,11 +16,21 @@
|
|||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "rom/ets_sys.h"
|
|
||||||
#include "esp32-hal-matrix.h"
|
#include "esp32-hal-matrix.h"
|
||||||
#include "soc/gpio_sd_reg.h"
|
#include "soc/gpio_sd_reg.h"
|
||||||
#include "soc/gpio_sd_struct.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
|
#if CONFIG_DISABLE_HAL_LOCKS
|
||||||
#define SD_MUTEX_LOCK()
|
#define SD_MUTEX_LOCK()
|
||||||
|
@ -17,10 +17,7 @@
|
|||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "rom/ets_sys.h"
|
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_intr.h"
|
|
||||||
#include "rom/gpio.h"
|
|
||||||
#include "soc/spi_reg.h"
|
#include "soc/spi_reg.h"
|
||||||
#include "soc/spi_struct.h"
|
#include "soc/spi_struct.h"
|
||||||
#include "soc/io_mux_reg.h"
|
#include "soc/io_mux_reg.h"
|
||||||
@ -28,6 +25,21 @@
|
|||||||
#include "soc/dport_reg.h"
|
#include "soc/dport_reg.h"
|
||||||
#include "soc/rtc.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_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_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))))
|
#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))))
|
||||||
@ -421,14 +433,14 @@ spi_t * spiStartBus(uint8_t spi_num, uint32_t clockDiv, uint8_t dataMode, uint8_
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(spi_num == HSPI) {
|
if(spi_num == HSPI) {
|
||||||
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI_CLK_EN);
|
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_SPI_RST);
|
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI2_RST);
|
||||||
} else if(spi_num == VSPI) {
|
} else if(spi_num == VSPI) {
|
||||||
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI_CLK_EN_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_SPI_RST_2);
|
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI3_RST);
|
||||||
} else {
|
} else {
|
||||||
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI_CLK_EN_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_SPI_RST_1);
|
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI01_RST);
|
||||||
}
|
}
|
||||||
|
|
||||||
spiStopBus(spi);
|
spiStopBus(spi);
|
||||||
@ -459,7 +471,7 @@ void spiWaitReady(spi_t * spi)
|
|||||||
while(spi->dev->cmd.usr);
|
while(spi->dev->cmd.usr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void spiWrite(spi_t * spi, uint32_t *data, uint8_t len)
|
void spiWrite(spi_t * spi, const uint32_t *data, uint8_t len)
|
||||||
{
|
{
|
||||||
if(!spi) {
|
if(!spi) {
|
||||||
return;
|
return;
|
||||||
@ -532,17 +544,7 @@ uint8_t spiTransferByte(spi_t * spi, uint8_t data)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t __spiTranslate24(uint32_t data)
|
static uint32_t __spiTranslate32(uint32_t data)
|
||||||
{
|
|
||||||
union {
|
|
||||||
uint32_t l;
|
|
||||||
uint8_t b[4];
|
|
||||||
} out;
|
|
||||||
out.l = data;
|
|
||||||
return out.b[2] | (out.b[1] << 8) | (out.b[0] << 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t __spiTranslate32(uint32_t data)
|
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
uint32_t l;
|
uint32_t l;
|
||||||
@ -630,7 +632,7 @@ uint32_t spiTransferLong(spi_t * spi, uint32_t data)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __spiTransferBytes(spi_t * spi, uint8_t * data, uint8_t * out, uint32_t bytes)
|
static void __spiTransferBytes(spi_t * spi, const uint8_t * data, uint8_t * out, uint32_t bytes)
|
||||||
{
|
{
|
||||||
if(!spi) {
|
if(!spi) {
|
||||||
return;
|
return;
|
||||||
@ -671,7 +673,7 @@ void __spiTransferBytes(spi_t * spi, uint8_t * data, uint8_t * out, uint32_t byt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void spiTransferBytes(spi_t * spi, uint8_t * data, uint8_t * out, uint32_t size)
|
void spiTransferBytes(spi_t * spi, const uint8_t * data, uint8_t * out, uint32_t size)
|
||||||
{
|
{
|
||||||
if(!spi) {
|
if(!spi) {
|
||||||
return;
|
return;
|
||||||
@ -861,7 +863,7 @@ uint32_t spiTransferLongNL(spi_t * spi, uint32_t data)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void spiWriteNL(spi_t * spi, const void * data_in, size_t len){
|
void spiWriteNL(spi_t * spi, const void * data_in, uint32_t len){
|
||||||
size_t longs = len >> 2;
|
size_t longs = len >> 2;
|
||||||
if(len & 3){
|
if(len & 3){
|
||||||
longs++;
|
longs++;
|
||||||
@ -887,7 +889,7 @@ void spiWriteNL(spi_t * spi, const void * data_in, size_t len){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void spiTransferBytesNL(spi_t * spi, const void * data_in, uint8_t * data_out, size_t len){
|
void spiTransferBytesNL(spi_t * spi, const void * data_in, uint8_t * data_out, uint32_t len){
|
||||||
if(!spi) {
|
if(!spi) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -974,7 +976,7 @@ void spiTransferBitsNL(spi_t * spi, uint32_t data, uint32_t * out, uint8_t bits)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR spiWritePixelsNL(spi_t * spi, const void * data_in, size_t len){
|
void IRAM_ATTR spiWritePixelsNL(spi_t * spi, const void * data_in, uint32_t len){
|
||||||
size_t longs = len >> 2;
|
size_t longs = len >> 2;
|
||||||
if(len & 3){
|
if(len & 3){
|
||||||
longs++;
|
longs++;
|
||||||
|
@ -96,7 +96,7 @@ void spiSetClockDiv(spi_t * spi, uint32_t clockDiv);
|
|||||||
void spiSetDataMode(spi_t * spi, uint8_t dataMode);
|
void spiSetDataMode(spi_t * spi, uint8_t dataMode);
|
||||||
void spiSetBitOrder(spi_t * spi, uint8_t bitOrder);
|
void spiSetBitOrder(spi_t * spi, uint8_t bitOrder);
|
||||||
|
|
||||||
void spiWrite(spi_t * spi, uint32_t *data, uint8_t len);
|
void spiWrite(spi_t * spi, const uint32_t *data, uint8_t len);
|
||||||
void spiWriteByte(spi_t * spi, uint8_t data);
|
void spiWriteByte(spi_t * spi, uint8_t data);
|
||||||
void spiWriteWord(spi_t * spi, uint16_t data);
|
void spiWriteWord(spi_t * spi, uint16_t data);
|
||||||
void spiWriteLong(spi_t * spi, uint32_t data);
|
void spiWriteLong(spi_t * spi, uint32_t data);
|
||||||
@ -105,7 +105,7 @@ void spiTransfer(spi_t * spi, uint32_t *out, uint8_t len);
|
|||||||
uint8_t spiTransferByte(spi_t * spi, uint8_t data);
|
uint8_t spiTransferByte(spi_t * spi, uint8_t data);
|
||||||
uint16_t spiTransferWord(spi_t * spi, uint16_t data);
|
uint16_t spiTransferWord(spi_t * spi, uint16_t data);
|
||||||
uint32_t spiTransferLong(spi_t * spi, uint32_t data);
|
uint32_t spiTransferLong(spi_t * spi, uint32_t data);
|
||||||
void spiTransferBytes(spi_t * spi, uint8_t * data, uint8_t * out, uint32_t size);
|
void spiTransferBytes(spi_t * spi, const uint8_t * data, uint8_t * out, uint32_t size);
|
||||||
void spiTransferBits(spi_t * spi, uint32_t data, uint32_t * out, uint8_t bits);
|
void spiTransferBits(spi_t * spi, uint32_t data, uint32_t * out, uint8_t bits);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -115,11 +115,11 @@ void spiTransaction(spi_t * spi, uint32_t clockDiv, uint8_t dataMode, uint8_t bi
|
|||||||
void spiSimpleTransaction(spi_t * spi);
|
void spiSimpleTransaction(spi_t * spi);
|
||||||
void spiEndTransaction(spi_t * spi);
|
void spiEndTransaction(spi_t * spi);
|
||||||
|
|
||||||
void spiWriteNL(spi_t * spi, const void * data, uint32_t len);
|
void spiWriteNL(spi_t * spi, const void * data_in, uint32_t len);
|
||||||
void spiWriteByteNL(spi_t * spi, uint8_t data);
|
void spiWriteByteNL(spi_t * spi, uint8_t data);
|
||||||
void spiWriteShortNL(spi_t * spi, uint16_t data);
|
void spiWriteShortNL(spi_t * spi, uint16_t data);
|
||||||
void spiWriteLongNL(spi_t * spi, uint32_t data);
|
void spiWriteLongNL(spi_t * spi, uint32_t data);
|
||||||
void spiWritePixelsNL(spi_t * spi, const void * data, uint32_t len);
|
void spiWritePixelsNL(spi_t * spi, const void * data_in, uint32_t len);
|
||||||
|
|
||||||
#define spiTransferNL(spi, data, len) spiTransferBytesNL(spi, data, data, len)
|
#define spiTransferNL(spi, data, len) spiTransferBytesNL(spi, data, data, len)
|
||||||
uint8_t spiTransferByteNL(spi_t * spi, uint8_t data);
|
uint8_t spiTransferByteNL(spi_t * spi, uint8_t data);
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "esp32-hal.h"
|
#include "esp32-hal.h"
|
||||||
#include "lwip/apps/sntp.h"
|
#include "lwip/apps/sntp.h"
|
||||||
|
#include "tcpip_adapter.h"
|
||||||
|
|
||||||
static void setTimeZone(long offset, int daylight)
|
static void setTimeZone(long offset, int daylight)
|
||||||
{
|
{
|
||||||
@ -45,6 +46,7 @@ static void setTimeZone(long offset, int daylight)
|
|||||||
* */
|
* */
|
||||||
void configTime(long gmtOffset_sec, int daylightOffset_sec, const char* server1, const char* server2, const char* server3)
|
void configTime(long gmtOffset_sec, int daylightOffset_sec, const char* server1, const char* server2, const char* server3)
|
||||||
{
|
{
|
||||||
|
tcpip_adapter_init(); // Should not hurt anything if already inited
|
||||||
if(sntp_enabled()){
|
if(sntp_enabled()){
|
||||||
sntp_stop();
|
sntp_stop();
|
||||||
}
|
}
|
||||||
@ -62,6 +64,7 @@ void configTime(long gmtOffset_sec, int daylightOffset_sec, const char* server1,
|
|||||||
* */
|
* */
|
||||||
void configTzTime(const char* tz, const char* server1, const char* server2, const char* server3)
|
void configTzTime(const char* tz, const char* server1, const char* server2, const char* server3)
|
||||||
{
|
{
|
||||||
|
tcpip_adapter_init(); // Should not hurt anything if already inited
|
||||||
if(sntp_enabled()){
|
if(sntp_enabled()){
|
||||||
sntp_stop();
|
sntp_stop();
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,22 @@
|
|||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/xtensa_api.h"
|
#include "freertos/xtensa_api.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "rom/ets_sys.h"
|
|
||||||
#include "soc/timer_group_struct.h"
|
#include "soc/timer_group_struct.h"
|
||||||
#include "soc/dport_reg.h"
|
#include "soc/dport_reg.h"
|
||||||
#include "esp_attr.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"
|
#include "esp_intr.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define HWTIMER_LOCK() portENTER_CRITICAL(timer->lock)
|
#define HWTIMER_LOCK() portENTER_CRITICAL(timer->lock)
|
||||||
#define HWTIMER_UNLOCK() portEXIT_CRITICAL(timer->lock)
|
#define HWTIMER_UNLOCK() portEXIT_CRITICAL(timer->lock)
|
||||||
|
@ -15,13 +15,24 @@
|
|||||||
#include "esp32-hal-touch.h"
|
#include "esp32-hal-touch.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "rom/ets_sys.h"
|
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_intr.h"
|
|
||||||
#include "soc/rtc_io_reg.h"
|
#include "soc/rtc_io_reg.h"
|
||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
#include "soc/sens_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 __touchSleepCycles = 0x1000;
|
||||||
static uint16_t __touchMeasureCycles = 0x1000;
|
static uint16_t __touchMeasureCycles = 0x1000;
|
||||||
|
|
||||||
|
@ -18,10 +18,7 @@
|
|||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/queue.h"
|
#include "freertos/queue.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "rom/ets_sys.h"
|
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_intr.h"
|
|
||||||
#include "rom/uart.h"
|
|
||||||
#include "soc/uart_reg.h"
|
#include "soc/uart_reg.h"
|
||||||
#include "soc/uart_struct.h"
|
#include "soc/uart_struct.h"
|
||||||
#include "soc/io_mux_reg.h"
|
#include "soc/io_mux_reg.h"
|
||||||
@ -30,6 +27,20 @@
|
|||||||
#include "soc/rtc.h"
|
#include "soc/rtc.h"
|
||||||
#include "esp_intr_alloc.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_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_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)))
|
#define UART_TXD_IDX(u) ((u==0)?U0TXD_OUT_IDX:( (u==1)?U1TXD_OUT_IDX:( (u==2)?U2TXD_OUT_IDX:0)))
|
||||||
@ -217,7 +228,6 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx
|
|||||||
if(txPin != -1) {
|
if(txPin != -1) {
|
||||||
uartAttachTx(uart, txPin, inverted);
|
uartAttachTx(uart, txPin, inverted);
|
||||||
}
|
}
|
||||||
|
|
||||||
addApbChangeCallback(uart, uart_on_apb_change);
|
addApbChangeCallback(uart, uart_on_apb_change);
|
||||||
return uart;
|
return uart;
|
||||||
}
|
}
|
||||||
@ -253,7 +263,7 @@ size_t uartResizeRxBuffer(uart_t * uart, size_t new_size) {
|
|||||||
vQueueDelete(uart->queue);
|
vQueueDelete(uart->queue);
|
||||||
uart->queue = xQueueCreate(new_size, sizeof(uint8_t));
|
uart->queue = xQueueCreate(new_size, sizeof(uint8_t));
|
||||||
if(uart->queue == NULL) {
|
if(uart->queue == NULL) {
|
||||||
return NULL;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UART_MUTEX_UNLOCK();
|
UART_MUTEX_UNLOCK();
|
||||||
@ -327,6 +337,11 @@ void uartWriteBuf(uart_t* uart, const uint8_t * data, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void uartFlush(uart_t* uart)
|
void uartFlush(uart_t* uart)
|
||||||
|
{
|
||||||
|
uartFlushTxOnly(uart,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uartFlushTxOnly(uart_t* uart, bool txOnly)
|
||||||
{
|
{
|
||||||
if(uart == NULL) {
|
if(uart == NULL) {
|
||||||
return;
|
return;
|
||||||
@ -335,6 +350,7 @@ void uartFlush(uart_t* uart)
|
|||||||
UART_MUTEX_LOCK();
|
UART_MUTEX_LOCK();
|
||||||
while(uart->dev->status.txfifo_cnt || uart->dev->status.st_utx_out);
|
while(uart->dev->status.txfifo_cnt || uart->dev->status.st_utx_out);
|
||||||
|
|
||||||
|
if( !txOnly ){
|
||||||
//Due to hardware issue, we can not use fifo_rst to reset uart fifo.
|
//Due to hardware issue, we can not use fifo_rst to reset uart fifo.
|
||||||
//See description about UART_TXFIFO_RST and UART_RXFIFO_RST in <<esp32_technical_reference_manual>> v2.6 or later.
|
//See description about UART_TXFIFO_RST and UART_RXFIFO_RST in <<esp32_technical_reference_manual>> v2.6 or later.
|
||||||
|
|
||||||
@ -344,6 +360,7 @@ void uartFlush(uart_t* uart)
|
|||||||
}
|
}
|
||||||
|
|
||||||
xQueueReset(uart->queue);
|
xQueueReset(uart->queue);
|
||||||
|
}
|
||||||
|
|
||||||
UART_MUTEX_UNLOCK();
|
UART_MUTEX_UNLOCK();
|
||||||
}
|
}
|
||||||
@ -370,18 +387,21 @@ static void uart_on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old
|
|||||||
uart->dev->int_clr.val = 0xffffffff;
|
uart->dev->int_clr.val = 0xffffffff;
|
||||||
// read RX fifo
|
// read RX fifo
|
||||||
uint8_t c;
|
uint8_t c;
|
||||||
BaseType_t xHigherPriorityTaskWoken;
|
// BaseType_t xHigherPriorityTaskWoken;
|
||||||
while(uart->dev->status.rxfifo_cnt != 0 || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) {
|
while(uart->dev->status.rxfifo_cnt != 0 || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) {
|
||||||
c = uart->dev->fifo.rw_byte;
|
c = uart->dev->fifo.rw_byte;
|
||||||
if(uart->queue != NULL && !xQueueIsQueueFullFromISR(uart->queue)) {
|
if(uart->queue != NULL ) {
|
||||||
xQueueSendFromISR(uart->queue, &c, &xHigherPriorityTaskWoken);
|
xQueueSend(uart->queue, &c, 1); //&xHigherPriorityTaskWoken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UART_MUTEX_UNLOCK();
|
||||||
|
|
||||||
// wait TX empty
|
// wait TX empty
|
||||||
while(uart->dev->status.txfifo_cnt || uart->dev->status.st_utx_out);
|
while(uart->dev->status.txfifo_cnt || uart->dev->status.st_utx_out);
|
||||||
} else {
|
} else {
|
||||||
//todo:
|
//todo:
|
||||||
// set baudrate
|
// set baudrate
|
||||||
|
UART_MUTEX_LOCK();
|
||||||
uint32_t clk_div = (uart->dev->clk_div.div_int << 4) | (uart->dev->clk_div.div_frag & 0x0F);
|
uint32_t clk_div = (uart->dev->clk_div.div_int << 4) | (uart->dev->clk_div.div_frag & 0x0F);
|
||||||
uint32_t baud_rate = ((old_apb<<4)/clk_div);
|
uint32_t baud_rate = ((old_apb<<4)/clk_div);
|
||||||
clk_div = ((new_apb<<4)/baud_rate);
|
clk_div = ((new_apb<<4)/baud_rate);
|
||||||
|
@ -63,6 +63,7 @@ void uartWrite(uart_t* uart, uint8_t c);
|
|||||||
void uartWriteBuf(uart_t* uart, const uint8_t * data, size_t len);
|
void uartWriteBuf(uart_t* uart, const uint8_t * data, size_t len);
|
||||||
|
|
||||||
void uartFlush(uart_t* uart);
|
void uartFlush(uart_t* uart);
|
||||||
|
void uartFlushTxOnly(uart_t* uart, bool txOnly );
|
||||||
|
|
||||||
void uartSetBaudRate(uart_t* uart, uint32_t baud_rate);
|
void uartSetBaudRate(uart_t* uart, uint32_t baud_rate);
|
||||||
uint32_t uartGetBaudRate(uart_t* uart);
|
uint32_t uartGetBaudRate(uart_t* uart);
|
||||||
|
@ -34,6 +34,7 @@ extern "C" {
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
|
#include "esp_sleep.h"
|
||||||
|
|
||||||
#ifndef F_CPU
|
#ifndef F_CPU
|
||||||
#define F_CPU (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000U)
|
#define F_CPU (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000U)
|
||||||
|
@ -17,6 +17,7 @@ void loopTask(void *pvParameters)
|
|||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
}
|
}
|
||||||
loop();
|
loop();
|
||||||
|
if (serialEventRun) serialEventRun();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
Installation instructions using Arduino IDE Boards Manager
|
## Installation instructions using Arduino IDE Boards Manager
|
||||||
==========================================================
|
### ==========================================================
|
||||||
|
|
||||||
Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32 and 64 bit).
|
- Stable release link: `https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json`
|
||||||
|
- Development release link: `https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json`
|
||||||
|
|
||||||
|
Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32, 64 bit and ARM).
|
||||||
|
|
||||||
- Install the current upstream Arduino IDE at the 1.8 level or later. The current version is at the [Arduino website](http://www.arduino.cc/en/main/software).
|
- Install the current upstream Arduino IDE at the 1.8 level or later. The current version is at the [Arduino website](http://www.arduino.cc/en/main/software).
|
||||||
- Start Arduino and open Preferences window.
|
- Start Arduino and open Preferences window.
|
||||||
- Enter ```https://dl.espressif.com/dl/package_esp32_index.json``` into *Additional Board Manager URLs* field. You can add multiple URLs, separating them with commas.
|
- Enter one of the release links above into *Additional Board Manager URLs* field. You can add multiple URLs, separating them with commas.
|
||||||
- Open Boards Manager from Tools > Board menu and install *esp32* platform (and don't forget to select your ESP32 board from Tools > Board menu after installation).
|
- Open Boards Manager from Tools > Board menu and install *esp32* platform (and don't forget to select your ESP32 board from Tools > Board menu after installation).
|
||||||
|
|
||||||
Stable release link: `https://dl.espressif.com/dl/package_esp32_index.json`
|
|
||||||
|
|
||||||
Development release link: `https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json`
|
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
To use as a component of ESP-IDF
|
To use as a component of ESP-IDF
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
## esp32-arduino-lib-builder
|
||||||
|
|
||||||
|
For a simplified method, see [lib-builder](lib_builder.md)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
- Download and install [esp-idf](https://github.com/espressif/esp-idf)
|
- Download and install [esp-idf](https://github.com/espressif/esp-idf)
|
||||||
|
14
docs/lib_builder.md
Normal file
14
docs/lib_builder.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
## Using esp32-arduino-lib-builder to compile custom libraries
|
||||||
|
|
||||||
|
Espressif has provided a [tool](https://github.com/espressif/esp32-arduino-lib-builder) to simplify building your own compiled libraries for use in Arduino IDE (or your favorite IDE).
|
||||||
|
To use it to generate custom libraries, follow these steps:
|
||||||
|
1. `git clone https://github.com/espressif/esp32-arduino-lib-builder`
|
||||||
|
2. `cd esp32-arduino-lib-builder`
|
||||||
|
3. `./tools/update-components.sh`
|
||||||
|
4. `./tools/install-esp-idf.sh` (if you already have an $IDF_PATH defined, it will use your local copy of the repository)
|
||||||
|
5. `make menuconfig` or directly edit sdkconfig.
|
||||||
|
6. `./build.sh`
|
||||||
|
|
||||||
|
The script automates the process of building [arduino as an ESP-IDF component](https://github.com/espressif/arduino-esp32/blob/master/docs/esp-idf_component.md).
|
||||||
|
Once it is complete, you can cherry pick the needed libraries from `out/tools/sdk/lib`, or run `tools/copy-to-arduino.sh` to copy the entire built system.
|
||||||
|
`tools/config.sh` contains a number of variables that control the process, particularly the $IDF_BRANCH variable. You can adjust this to try building against newer versions, but there are absolutely no guarantees that any components will work or even successfully compile against a newer IDF.
|
Submodule libraries/AzureIoT deleted from 67dfa4f31e
@ -154,7 +154,7 @@ void loop() {
|
|||||||
// Set the characteristic's value to be the array of bytes that is actually a string.
|
// Set the characteristic's value to be the array of bytes that is actually a string.
|
||||||
pRemoteCharacteristic->writeValue(newValue.c_str(), newValue.length());
|
pRemoteCharacteristic->writeValue(newValue.c_str(), newValue.length());
|
||||||
}else if(doScan){
|
}else if(doScan){
|
||||||
BLEDevice::getScan()->start(0); // this is just eample to start scan after disconnect, most likely there is better way to do it in arduino
|
BLEDevice::getScan()->start(0); // this is just example to start scan after disconnect, most likely there is better way to do it in arduino
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(1000); // Delay a second between loops.
|
delay(1000); // Delay a second between loops.
|
||||||
|
@ -65,6 +65,7 @@ void setBeacon() {
|
|||||||
|
|
||||||
pAdvertising->setAdvertisementData(oAdvertisementData);
|
pAdvertising->setAdvertisementData(oAdvertisementData);
|
||||||
pAdvertising->setScanResponseData(oScanResponseData);
|
pAdvertising->setScanResponseData(oScanResponseData);
|
||||||
|
pAdvertising->setAdvertisementType(ADV_TYPE_NONCONN_IND);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@ BLEAdvertisedDevice::BLEAdvertisedDevice() {
|
|||||||
m_manufacturerData = "";
|
m_manufacturerData = "";
|
||||||
m_name = "";
|
m_name = "";
|
||||||
m_rssi = -9999;
|
m_rssi = -9999;
|
||||||
m_serviceData = "";
|
m_serviceData = {};
|
||||||
|
m_serviceDataUUIDs = {};
|
||||||
m_txPower = 0;
|
m_txPower = 0;
|
||||||
m_pScan = nullptr;
|
m_pScan = nullptr;
|
||||||
|
|
||||||
@ -101,33 +102,66 @@ BLEScan* BLEAdvertisedDevice::getScan() {
|
|||||||
return m_pScan;
|
return m_pScan;
|
||||||
} // getScan
|
} // getScan
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the number of service data.
|
||||||
|
* @return Number of service data discovered.
|
||||||
|
*/
|
||||||
|
int BLEAdvertisedDevice::getServiceDataCount() {
|
||||||
|
if (m_haveServiceData)
|
||||||
|
return m_serviceData.size();
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
} //getServiceDataCount
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the service data.
|
* @brief Get the service data.
|
||||||
* @return The ServiceData of the advertised device.
|
* @return The ServiceData of the advertised device.
|
||||||
*/
|
*/
|
||||||
std::string BLEAdvertisedDevice::getServiceData() {
|
std::string BLEAdvertisedDevice::getServiceData() {
|
||||||
return m_serviceData;
|
return m_serviceData[0];
|
||||||
} //getServiceData
|
} //getServiceData
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the service data.
|
||||||
|
* @return The ServiceData of the advertised device.
|
||||||
|
*/
|
||||||
|
std::string BLEAdvertisedDevice::getServiceData(int i) {
|
||||||
|
return m_serviceData[i];
|
||||||
|
} //getServiceData
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the service data UUID.
|
* @brief Get the service data UUID.
|
||||||
* @return The service data UUID.
|
* @return The service data UUID.
|
||||||
*/
|
*/
|
||||||
BLEUUID BLEAdvertisedDevice::getServiceDataUUID() {
|
BLEUUID BLEAdvertisedDevice::getServiceDataUUID() {
|
||||||
return m_serviceDataUUID;
|
return m_serviceDataUUIDs[0];
|
||||||
} // getServiceDataUUID
|
} // getServiceDataUUID
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the service data UUID.
|
||||||
|
* @return The service data UUID.
|
||||||
|
*/
|
||||||
|
BLEUUID BLEAdvertisedDevice::getServiceDataUUID(int i) {
|
||||||
|
return m_serviceDataUUIDs[i];
|
||||||
|
} // getServiceDataUUID
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the Service UUID.
|
* @brief Get the Service UUID.
|
||||||
* @return The Service UUID of the advertised device.
|
* @return The Service UUID of the advertised device.
|
||||||
*/
|
*/
|
||||||
BLEUUID BLEAdvertisedDevice::getServiceUUID() { //TODO Remove it eventually, is no longer useful
|
BLEUUID BLEAdvertisedDevice::getServiceUUID() {
|
||||||
return m_serviceUUIDs[0];
|
return m_serviceUUIDs[0];
|
||||||
} // getServiceUUID
|
} // getServiceUUID
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the Service UUID.
|
||||||
|
* @return The Service UUID of the advertised device.
|
||||||
|
*/
|
||||||
|
BLEUUID BLEAdvertisedDevice::getServiceUUID(int i) {
|
||||||
|
return m_serviceUUIDs[i];
|
||||||
|
} // getServiceUUID
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check advertised serviced for existence required UUID
|
* @brief Check advertised serviced for existence required UUID
|
||||||
* @return Return true if service is advertised
|
* @return Return true if service is advertised
|
||||||
@ -454,7 +488,7 @@ void BLEAdvertisedDevice::setServiceUUID(BLEUUID serviceUUID) {
|
|||||||
*/
|
*/
|
||||||
void BLEAdvertisedDevice::setServiceData(std::string serviceData) {
|
void BLEAdvertisedDevice::setServiceData(std::string serviceData) {
|
||||||
m_haveServiceData = true; // Set the flag that indicates we have service data.
|
m_haveServiceData = true; // Set the flag that indicates we have service data.
|
||||||
m_serviceData = serviceData; // Save the service data that we received.
|
m_serviceData.push_back(serviceData); // Save the service data that we received.
|
||||||
} //setServiceData
|
} //setServiceData
|
||||||
|
|
||||||
|
|
||||||
@ -464,7 +498,8 @@ void BLEAdvertisedDevice::setServiceData(std::string serviceData) {
|
|||||||
*/
|
*/
|
||||||
void BLEAdvertisedDevice::setServiceDataUUID(BLEUUID uuid) {
|
void BLEAdvertisedDevice::setServiceDataUUID(BLEUUID uuid) {
|
||||||
m_haveServiceData = true; // Set the flag that indicates we have service data.
|
m_haveServiceData = true; // Set the flag that indicates we have service data.
|
||||||
m_serviceDataUUID = uuid;
|
m_serviceDataUUIDs.push_back(uuid);
|
||||||
|
log_d("- addServiceDataUUID(): serviceDataUUID: %s", uuid.toString().c_str());
|
||||||
} // setServiceDataUUID
|
} // setServiceDataUUID
|
||||||
|
|
||||||
|
|
||||||
@ -498,10 +533,12 @@ std::string BLEAdvertisedDevice::toString() {
|
|||||||
free(pHex);
|
free(pHex);
|
||||||
}
|
}
|
||||||
if (haveServiceUUID()) {
|
if (haveServiceUUID()) {
|
||||||
res += ", serviceUUID: " + getServiceUUID().toString();
|
for (int i=0; i < m_serviceUUIDs.size(); i++) {
|
||||||
|
res += ", serviceUUID: " + getServiceUUID(i).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (haveTXPower()) {
|
if (haveTXPower()) {
|
||||||
char val[4];
|
char val[6];
|
||||||
snprintf(val, sizeof(val), "%d", getTXPower());
|
snprintf(val, sizeof(val), "%d", getTXPower());
|
||||||
res += ", txPower: ";
|
res += ", txPower: ";
|
||||||
res += val;
|
res += val;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <esp_gattc_api.h>
|
#include <esp_gattc_api.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "BLEAddress.h"
|
#include "BLEAddress.h"
|
||||||
#include "BLEScan.h"
|
#include "BLEScan.h"
|
||||||
@ -36,8 +37,12 @@ public:
|
|||||||
int getRSSI();
|
int getRSSI();
|
||||||
BLEScan* getScan();
|
BLEScan* getScan();
|
||||||
std::string getServiceData();
|
std::string getServiceData();
|
||||||
|
std::string getServiceData(int i);
|
||||||
BLEUUID getServiceDataUUID();
|
BLEUUID getServiceDataUUID();
|
||||||
|
BLEUUID getServiceDataUUID(int i);
|
||||||
BLEUUID getServiceUUID();
|
BLEUUID getServiceUUID();
|
||||||
|
BLEUUID getServiceUUID(int i);
|
||||||
|
int getServiceDataCount();
|
||||||
int8_t getTXPower();
|
int8_t getTXPower();
|
||||||
uint8_t* getPayload();
|
uint8_t* getPayload();
|
||||||
size_t getPayloadLength();
|
size_t getPayloadLength();
|
||||||
@ -93,8 +98,8 @@ private:
|
|||||||
int m_rssi;
|
int m_rssi;
|
||||||
std::vector<BLEUUID> m_serviceUUIDs;
|
std::vector<BLEUUID> m_serviceUUIDs;
|
||||||
int8_t m_txPower;
|
int8_t m_txPower;
|
||||||
std::string m_serviceData;
|
std::vector<std::string> m_serviceData;
|
||||||
BLEUUID m_serviceDataUUID;
|
std::vector<BLEUUID> m_serviceDataUUIDs;
|
||||||
uint8_t* m_payload;
|
uint8_t* m_payload;
|
||||||
size_t m_payloadLength = 0;
|
size_t m_payloadLength = 0;
|
||||||
esp_ble_addr_type_t m_addressType;
|
esp_ble_addr_type_t m_addressType;
|
||||||
|
@ -85,6 +85,10 @@ void BLEAdvertising::setAppearance(uint16_t appearance) {
|
|||||||
m_advData.appearance = appearance;
|
m_advData.appearance = appearance;
|
||||||
} // setAppearance
|
} // setAppearance
|
||||||
|
|
||||||
|
void BLEAdvertising::setAdvertisementType(esp_ble_adv_type_t adv_type){
|
||||||
|
m_advParams.adv_type = adv_type;
|
||||||
|
} // setAdvertisementType
|
||||||
|
|
||||||
void BLEAdvertising::setMinInterval(uint16_t mininterval) {
|
void BLEAdvertising::setMinInterval(uint16_t mininterval) {
|
||||||
m_advParams.adv_int_min = mininterval;
|
m_advParams.adv_int_min = mininterval;
|
||||||
} // setMinInterval
|
} // setMinInterval
|
||||||
|
@ -52,6 +52,7 @@ public:
|
|||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
void setAppearance(uint16_t appearance);
|
void setAppearance(uint16_t appearance);
|
||||||
|
void setAdvertisementType(esp_ble_adv_type_t adv_type);
|
||||||
void setMaxInterval(uint16_t maxinterval);
|
void setMaxInterval(uint16_t maxinterval);
|
||||||
void setMinInterval(uint16_t mininterval);
|
void setMinInterval(uint16_t mininterval);
|
||||||
void setAdvertisementData(BLEAdvertisementData& advertisementData);
|
void setAdvertisementData(BLEAdvertisementData& advertisementData);
|
||||||
|
@ -441,11 +441,26 @@ gatts_event_handler BLEDevice::m_customGattsHandler = nullptr;
|
|||||||
* * ESP_PWR_LVL_P1
|
* * ESP_PWR_LVL_P1
|
||||||
* * ESP_PWR_LVL_P4
|
* * ESP_PWR_LVL_P4
|
||||||
* * ESP_PWR_LVL_P7
|
* * ESP_PWR_LVL_P7
|
||||||
|
*
|
||||||
|
* The power types can be one of:
|
||||||
|
* * ESP_BLE_PWR_TYPE_CONN_HDL0
|
||||||
|
* * ESP_BLE_PWR_TYPE_CONN_HDL1
|
||||||
|
* * ESP_BLE_PWR_TYPE_CONN_HDL2
|
||||||
|
* * ESP_BLE_PWR_TYPE_CONN_HDL3
|
||||||
|
* * ESP_BLE_PWR_TYPE_CONN_HDL4
|
||||||
|
* * ESP_BLE_PWR_TYPE_CONN_HDL5
|
||||||
|
* * ESP_BLE_PWR_TYPE_CONN_HDL6
|
||||||
|
* * ESP_BLE_PWR_TYPE_CONN_HDL7
|
||||||
|
* * ESP_BLE_PWR_TYPE_CONN_HDL8
|
||||||
|
* * ESP_BLE_PWR_TYPE_ADV
|
||||||
|
* * ESP_BLE_PWR_TYPE_SCAN
|
||||||
|
* * ESP_BLE_PWR_TYPE_DEFAULT
|
||||||
|
* @param [in] powerType.
|
||||||
* @param [in] powerLevel.
|
* @param [in] powerLevel.
|
||||||
*/
|
*/
|
||||||
/* STATIC */ void BLEDevice::setPower(esp_power_level_t powerLevel) {
|
/* STATIC */ void BLEDevice::setPower(esp_power_level_t powerLevel, esp_ble_power_type_t powerType) {
|
||||||
log_v(">> setPower: %d", powerLevel);
|
log_v(">> setPower: %d (type: %d)", powerLevel, powerType);
|
||||||
esp_err_t errRc = ::esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT, powerLevel);
|
esp_err_t errRc = ::esp_ble_tx_power_set(powerType, powerLevel);
|
||||||
if (errRc != ESP_OK) {
|
if (errRc != ESP_OK) {
|
||||||
log_e("esp_ble_tx_power_set: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
log_e("esp_ble_tx_power_set: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
||||||
};
|
};
|
||||||
@ -484,7 +499,11 @@ gatts_event_handler BLEDevice::m_customGattsHandler = nullptr;
|
|||||||
*/
|
*/
|
||||||
void BLEDevice::whiteListAdd(BLEAddress address) {
|
void BLEDevice::whiteListAdd(BLEAddress address) {
|
||||||
log_v(">> whiteListAdd: %s", address.toString().c_str());
|
log_v(">> whiteListAdd: %s", address.toString().c_str());
|
||||||
|
#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.
|
esp_err_t errRc = esp_ble_gap_update_whitelist(true, *address.getNative()); // True to add an entry.
|
||||||
|
#endif
|
||||||
if (errRc != ESP_OK) {
|
if (errRc != ESP_OK) {
|
||||||
log_e("esp_ble_gap_update_whitelist: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
log_e("esp_ble_gap_update_whitelist: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
||||||
}
|
}
|
||||||
@ -498,7 +517,11 @@ void BLEDevice::whiteListAdd(BLEAddress address) {
|
|||||||
*/
|
*/
|
||||||
void BLEDevice::whiteListRemove(BLEAddress address) {
|
void BLEDevice::whiteListRemove(BLEAddress address) {
|
||||||
log_v(">> whiteListRemove: %s", address.toString().c_str());
|
log_v(">> whiteListRemove: %s", address.toString().c_str());
|
||||||
|
#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.
|
esp_err_t errRc = esp_ble_gap_update_whitelist(false, *address.getNative()); // False to remove an entry.
|
||||||
|
#endif
|
||||||
if (errRc != ESP_OK) {
|
if (errRc != ESP_OK) {
|
||||||
log_e("esp_ble_gap_update_whitelist: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
log_e("esp_ble_gap_update_whitelist: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
||||||
}
|
}
|
||||||
@ -563,6 +586,12 @@ void BLEDevice::startAdvertising() {
|
|||||||
log_v("<< startAdvertising");
|
log_v("<< startAdvertising");
|
||||||
} // startAdvertising
|
} // startAdvertising
|
||||||
|
|
||||||
|
void BLEDevice::stopAdvertising() {
|
||||||
|
log_v(">> stopAdvertising");
|
||||||
|
getAdvertising()->stop();
|
||||||
|
log_v("<< stopAdvertising");
|
||||||
|
} // stopAdvertising
|
||||||
|
|
||||||
/* multi connect support */
|
/* multi connect support */
|
||||||
/* requires a little more work */
|
/* requires a little more work */
|
||||||
std::map<uint16_t, conn_status_t> BLEDevice::getPeerDevices(bool _client) {
|
std::map<uint16_t, conn_status_t> BLEDevice::getPeerDevices(bool _client) {
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
static BLEScan* getScan(); // Get the scan object
|
static BLEScan* getScan(); // Get the scan object
|
||||||
static std::string getValue(BLEAddress bdAddress, BLEUUID serviceUUID, BLEUUID characteristicUUID); // Get the value of a characteristic of a service on a server.
|
static std::string getValue(BLEAddress bdAddress, BLEUUID serviceUUID, BLEUUID characteristicUUID); // Get the value of a characteristic of a service on a server.
|
||||||
static void init(std::string deviceName); // Initialize the local BLE environment.
|
static void init(std::string deviceName); // Initialize the local BLE environment.
|
||||||
static void setPower(esp_power_level_t powerLevel); // Set our power level.
|
static void setPower(esp_power_level_t powerLevel, esp_ble_power_type_t powerType=ESP_BLE_PWR_TYPE_DEFAULT); // Set our power level.
|
||||||
static void setValue(BLEAddress bdAddress, BLEUUID serviceUUID, BLEUUID characteristicUUID, std::string value); // Set the value of a characteristic on a service on a server.
|
static void setValue(BLEAddress bdAddress, BLEUUID serviceUUID, BLEUUID characteristicUUID, std::string value); // Set the value of a characteristic on a service on a server.
|
||||||
static std::string toString(); // Return a string representation of our device.
|
static std::string toString(); // Return a string representation of our device.
|
||||||
static void whiteListAdd(BLEAddress address); // Add an entry to the BLE white list.
|
static void whiteListAdd(BLEAddress address); // Add an entry to the BLE white list.
|
||||||
@ -50,6 +50,7 @@ public:
|
|||||||
/* move advertising to BLEDevice for saving ram and flash in beacons */
|
/* move advertising to BLEDevice for saving ram and flash in beacons */
|
||||||
static BLEAdvertising* getAdvertising();
|
static BLEAdvertising* getAdvertising();
|
||||||
static void startAdvertising();
|
static void startAdvertising();
|
||||||
|
static void stopAdvertising();
|
||||||
static uint16_t m_appId;
|
static uint16_t m_appId;
|
||||||
/* multi connect */
|
/* multi connect */
|
||||||
static std::map<uint16_t, conn_status_t> getPeerDevices(bool client);
|
static std::map<uint16_t, conn_status_t> getPeerDevices(bool client);
|
||||||
|
@ -40,6 +40,7 @@ BLERemoteCharacteristic::BLERemoteCharacteristic(
|
|||||||
m_pRemoteService = pRemoteService;
|
m_pRemoteService = pRemoteService;
|
||||||
m_notifyCallback = nullptr;
|
m_notifyCallback = nullptr;
|
||||||
m_rawData = nullptr;
|
m_rawData = nullptr;
|
||||||
|
m_auth = ESP_GATT_AUTH_REQ_NONE;
|
||||||
|
|
||||||
retrieveDescriptors(); // Get the descriptors for this characteristic
|
retrieveDescriptors(); // Get the descriptors for this characteristic
|
||||||
log_v("<< BLERemoteCharacteristic");
|
log_v("<< BLERemoteCharacteristic");
|
||||||
@ -389,6 +390,17 @@ uint8_t BLERemoteCharacteristic::readUInt8() {
|
|||||||
return 0;
|
return 0;
|
||||||
} // readUInt8
|
} // readUInt8
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read a float value.
|
||||||
|
* @return the float value.
|
||||||
|
*/
|
||||||
|
float BLERemoteCharacteristic::readFloat() {
|
||||||
|
std::string value = readValue();
|
||||||
|
if (value.length() >= 4) {
|
||||||
|
return *(float*)(value.data());
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
|
} // readFloat
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read the value of the remote characteristic.
|
* @brief Read the value of the remote characteristic.
|
||||||
@ -412,7 +424,7 @@ std::string BLERemoteCharacteristic::readValue() {
|
|||||||
m_pRemoteService->getClient()->getGattcIf(),
|
m_pRemoteService->getClient()->getGattcIf(),
|
||||||
m_pRemoteService->getClient()->getConnId(), // The connection ID to the BLE server
|
m_pRemoteService->getClient()->getConnId(), // The connection ID to the BLE server
|
||||||
getHandle(), // The handle of this characteristic
|
getHandle(), // The handle of this characteristic
|
||||||
ESP_GATT_AUTH_REQ_NONE); // Security
|
m_auth); // Security
|
||||||
|
|
||||||
if (errRc != ESP_OK) {
|
if (errRc != ESP_OK) {
|
||||||
log_e("esp_ble_gattc_read_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
log_e("esp_ble_gattc_read_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
||||||
@ -563,7 +575,7 @@ void BLERemoteCharacteristic::writeValue(uint8_t* data, size_t length, bool resp
|
|||||||
length,
|
length,
|
||||||
data,
|
data,
|
||||||
response?ESP_GATT_WRITE_TYPE_RSP:ESP_GATT_WRITE_TYPE_NO_RSP,
|
response?ESP_GATT_WRITE_TYPE_RSP:ESP_GATT_WRITE_TYPE_NO_RSP,
|
||||||
ESP_GATT_AUTH_REQ_NONE
|
m_auth
|
||||||
);
|
);
|
||||||
|
|
||||||
if (errRc != ESP_OK) {
|
if (errRc != ESP_OK) {
|
||||||
@ -584,4 +596,12 @@ uint8_t* BLERemoteCharacteristic::readRawData() {
|
|||||||
return m_rawData;
|
return m_rawData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set authentication request type for characteristic
|
||||||
|
* @param [in] auth Authentication request type.
|
||||||
|
*/
|
||||||
|
void BLERemoteCharacteristic::setAuth(esp_gatt_auth_req_t auth) {
|
||||||
|
m_auth = auth;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_BT_ENABLED */
|
#endif /* CONFIG_BT_ENABLED */
|
||||||
|
@ -45,12 +45,14 @@ public:
|
|||||||
uint8_t readUInt8();
|
uint8_t readUInt8();
|
||||||
uint16_t readUInt16();
|
uint16_t readUInt16();
|
||||||
uint32_t readUInt32();
|
uint32_t readUInt32();
|
||||||
|
float readFloat();
|
||||||
void registerForNotify(notify_callback _callback, bool notifications = true);
|
void registerForNotify(notify_callback _callback, bool notifications = true);
|
||||||
void writeValue(uint8_t* data, size_t length, bool response = false);
|
void writeValue(uint8_t* data, size_t length, bool response = false);
|
||||||
void writeValue(std::string newValue, bool response = false);
|
void writeValue(std::string newValue, bool response = false);
|
||||||
void writeValue(uint8_t newValue, bool response = false);
|
void writeValue(uint8_t newValue, bool response = false);
|
||||||
std::string toString();
|
std::string toString();
|
||||||
uint8_t* readRawData();
|
uint8_t* readRawData();
|
||||||
|
void setAuth(esp_gatt_auth_req_t auth);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BLERemoteCharacteristic(uint16_t handle, BLEUUID uuid, esp_gatt_char_prop_t charProp, BLERemoteService* pRemoteService);
|
BLERemoteCharacteristic(uint16_t handle, BLEUUID uuid, esp_gatt_char_prop_t charProp, BLERemoteService* pRemoteService);
|
||||||
@ -68,6 +70,7 @@ private:
|
|||||||
// Private properties
|
// Private properties
|
||||||
BLEUUID m_uuid;
|
BLEUUID m_uuid;
|
||||||
esp_gatt_char_prop_t m_charProp;
|
esp_gatt_char_prop_t m_charProp;
|
||||||
|
esp_gatt_auth_req_t m_auth;
|
||||||
uint16_t m_handle;
|
uint16_t m_handle;
|
||||||
BLERemoteService* m_pRemoteService;
|
BLERemoteService* m_pRemoteService;
|
||||||
FreeRTOS::Semaphore m_semaphoreReadCharEvt = FreeRTOS::Semaphore("ReadCharEvt");
|
FreeRTOS::Semaphore m_semaphoreReadCharEvt = FreeRTOS::Semaphore("ReadCharEvt");
|
||||||
|
@ -19,6 +19,7 @@ BLERemoteDescriptor::BLERemoteDescriptor(
|
|||||||
m_handle = handle;
|
m_handle = handle;
|
||||||
m_uuid = uuid;
|
m_uuid = uuid;
|
||||||
m_pRemoteCharacteristic = pRemoteCharacteristic;
|
m_pRemoteCharacteristic = pRemoteCharacteristic;
|
||||||
|
m_auth = ESP_GATT_AUTH_REQ_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ std::string BLERemoteDescriptor::readValue() {
|
|||||||
m_pRemoteCharacteristic->getRemoteService()->getClient()->getGattcIf(),
|
m_pRemoteCharacteristic->getRemoteService()->getClient()->getGattcIf(),
|
||||||
m_pRemoteCharacteristic->getRemoteService()->getClient()->getConnId(), // The connection ID to the BLE server
|
m_pRemoteCharacteristic->getRemoteService()->getClient()->getConnId(), // The connection ID to the BLE server
|
||||||
getHandle(), // The handle of this characteristic
|
getHandle(), // The handle of this characteristic
|
||||||
ESP_GATT_AUTH_REQ_NONE); // Security
|
m_auth); // Security
|
||||||
|
|
||||||
if (errRc != ESP_OK) {
|
if (errRc != ESP_OK) {
|
||||||
log_e("esp_ble_gattc_read_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
log_e("esp_ble_gattc_read_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
|
||||||
@ -143,7 +144,7 @@ void BLERemoteDescriptor::writeValue(uint8_t* data, size_t length, bool response
|
|||||||
length, // Data length
|
length, // Data length
|
||||||
data, // Data
|
data, // Data
|
||||||
response ? ESP_GATT_WRITE_TYPE_RSP : ESP_GATT_WRITE_TYPE_NO_RSP,
|
response ? ESP_GATT_WRITE_TYPE_RSP : ESP_GATT_WRITE_TYPE_NO_RSP,
|
||||||
ESP_GATT_AUTH_REQ_NONE
|
m_auth
|
||||||
);
|
);
|
||||||
if (errRc != ESP_OK) {
|
if (errRc != ESP_OK) {
|
||||||
log_e("esp_ble_gattc_write_char_descr: %d", errRc);
|
log_e("esp_ble_gattc_write_char_descr: %d", errRc);
|
||||||
@ -171,5 +172,12 @@ void BLERemoteDescriptor::writeValue(uint8_t newValue, bool response) {
|
|||||||
writeValue(&newValue, 1, response);
|
writeValue(&newValue, 1, response);
|
||||||
} // writeValue
|
} // writeValue
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set authentication request type for characteristic
|
||||||
|
* @param [in] auth Authentication request type.
|
||||||
|
*/
|
||||||
|
void BLERemoteDescriptor::setAuth(esp_gatt_auth_req_t auth) {
|
||||||
|
m_auth = auth;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_BT_ENABLED */
|
#endif /* CONFIG_BT_ENABLED */
|
||||||
|
@ -34,6 +34,7 @@ public:
|
|||||||
void writeValue(uint8_t* data, size_t length, bool response = false);
|
void writeValue(uint8_t* data, size_t length, bool response = false);
|
||||||
void writeValue(std::string newValue, bool response = false);
|
void writeValue(std::string newValue, bool response = false);
|
||||||
void writeValue(uint8_t newValue, bool response = false);
|
void writeValue(uint8_t newValue, bool response = false);
|
||||||
|
void setAuth(esp_gatt_auth_req_t auth);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -48,6 +49,7 @@ private:
|
|||||||
std::string m_value; // Last received value of the descriptor.
|
std::string m_value; // Last received value of the descriptor.
|
||||||
BLERemoteCharacteristic* m_pRemoteCharacteristic; // Reference to the Remote characteristic of which this descriptor is associated.
|
BLERemoteCharacteristic* m_pRemoteCharacteristic; // Reference to the Remote characteristic of which this descriptor is associated.
|
||||||
FreeRTOS::Semaphore m_semaphoreReadDescrEvt = FreeRTOS::Semaphore("ReadDescrEvt");
|
FreeRTOS::Semaphore m_semaphoreReadDescrEvt = FreeRTOS::Semaphore("ReadDescrEvt");
|
||||||
|
esp_gatt_auth_req_t m_auth;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -243,8 +243,8 @@ std::map<uint16_t, BLERemoteCharacteristic*>* BLERemoteService::getCharacteristi
|
|||||||
/**
|
/**
|
||||||
* @brief This function is designed to get characteristics map when we have multiple characteristics with the same UUID
|
* @brief This function is designed to get characteristics map when we have multiple characteristics with the same UUID
|
||||||
*/
|
*/
|
||||||
void BLERemoteService::getCharacteristics(std::map<uint16_t, BLERemoteCharacteristic*>* pCharacteristicMap) {
|
void BLERemoteService::getCharacteristics(std::map<uint16_t, BLERemoteCharacteristic*>** pCharacteristicMap) {
|
||||||
pCharacteristicMap = &m_characteristicMapByHandle;
|
*pCharacteristicMap = &m_characteristicMapByHandle;
|
||||||
} // Get the characteristics map.
|
} // Get the characteristics map.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
BLERemoteCharacteristic* getCharacteristic(uint16_t uuid); // Get the specified characteristic reference.
|
BLERemoteCharacteristic* getCharacteristic(uint16_t uuid); // Get the specified characteristic reference.
|
||||||
std::map<std::string, BLERemoteCharacteristic*>* getCharacteristics();
|
std::map<std::string, BLERemoteCharacteristic*>* getCharacteristics();
|
||||||
std::map<uint16_t, BLERemoteCharacteristic*>* getCharacteristicsByHandle(); // Get the characteristics map.
|
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.
|
BLEClient* getClient(void); // Get a reference to the client associated with this service.
|
||||||
uint16_t getHandle(); // Get the handle of this service.
|
uint16_t getHandle(); // Get the handle of this service.
|
||||||
|
@ -186,7 +186,7 @@ void FreeRTOS::Semaphore::giveFromISR() {
|
|||||||
* @return True if we took the semaphore.
|
* @return True if we took the semaphore.
|
||||||
*/
|
*/
|
||||||
bool FreeRTOS::Semaphore::take(std::string owner) {
|
bool FreeRTOS::Semaphore::take(std::string owner) {
|
||||||
log_d("Semaphore taking: %s for %s", toString().c_str(), owner.c_str());
|
log_v("Semaphore taking: %s for %s", toString().c_str(), owner.c_str());
|
||||||
bool rc = false;
|
bool rc = false;
|
||||||
if (m_usePthreads) {
|
if (m_usePthreads) {
|
||||||
pthread_mutex_lock(&m_pthread_mutex);
|
pthread_mutex_lock(&m_pthread_mutex);
|
||||||
@ -195,7 +195,7 @@ bool FreeRTOS::Semaphore::take(std::string owner) {
|
|||||||
}
|
}
|
||||||
m_owner = owner;
|
m_owner = owner;
|
||||||
if (rc) {
|
if (rc) {
|
||||||
log_d("Semaphore taken: %s", toString().c_str());
|
log_v("Semaphore taken: %s", toString().c_str());
|
||||||
} else {
|
} else {
|
||||||
log_e("Semaphore NOT taken: %s", toString().c_str());
|
log_e("Semaphore NOT taken: %s", toString().c_str());
|
||||||
}
|
}
|
||||||
@ -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] 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.
|
* @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);
|
m_handle = ::xRingbufferCreate(length, type);
|
||||||
} // Ringbuffer
|
} // Ringbuffer
|
||||||
|
|
||||||
|
@ -60,7 +60,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
class Ringbuffer {
|
class Ringbuffer {
|
||||||
public:
|
public:
|
||||||
|
#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);
|
Ringbuffer(size_t length, ringbuf_type_t type = RINGBUF_TYPE_NOSPLIT);
|
||||||
|
#endif
|
||||||
~Ringbuffer();
|
~Ringbuffer();
|
||||||
|
|
||||||
void* receive(size_t* size, TickType_t wait = portMAX_DELAY);
|
void* receive(size_t* size, TickType_t wait = portMAX_DELAY);
|
||||||
|
@ -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] = {0xAA, 0xBB, 0xCC, 0x11, 0x22, 0x33};
|
||||||
//uint8_t address[6] = {0x00, 0x1D, 0xA5, 0x02, 0xC3, 0x22};
|
//uint8_t address[6] = {0x00, 0x1D, 0xA5, 0x02, 0xC3, 0x22};
|
||||||
String name = "OBDII";
|
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;
|
bool connected;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
@ -36,9 +36,7 @@
|
|||||||
#include "esp_spp_api.h"
|
#include "esp_spp_api.h"
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
|
||||||
#include "esp32-hal-log.h"
|
#include "esp32-hal-log.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
const char * _spp_server_name = "ESP32SPP";
|
const char * _spp_server_name = "ESP32SPP";
|
||||||
|
|
||||||
@ -52,6 +50,7 @@ static TaskHandle_t _spp_task_handle = NULL;
|
|||||||
static EventGroupHandle_t _spp_event_group = NULL;
|
static EventGroupHandle_t _spp_event_group = NULL;
|
||||||
static boolean secondConnectionAttempt;
|
static boolean secondConnectionAttempt;
|
||||||
static esp_spp_cb_t * custom_spp_callback = NULL;
|
static esp_spp_cb_t * custom_spp_callback = NULL;
|
||||||
|
static BluetoothSerialDataCb custom_data_callback = NULL;
|
||||||
|
|
||||||
#define INQ_LEN 0x10
|
#define INQ_LEN 0x10
|
||||||
#define INQ_NUM_RSPS 20
|
#define INQ_NUM_RSPS 20
|
||||||
@ -76,6 +75,7 @@ typedef struct {
|
|||||||
uint8_t data[];
|
uint8_t data[];
|
||||||
} spp_packet_t;
|
} spp_packet_t;
|
||||||
|
|
||||||
|
#if (ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO)
|
||||||
static char *bda2str(esp_bd_addr_t bda, char *str, size_t size)
|
static char *bda2str(esp_bd_addr_t bda, char *str, size_t size)
|
||||||
{
|
{
|
||||||
if (bda == NULL || str == NULL || size < 18) {
|
if (bda == NULL || str == NULL || size < 18) {
|
||||||
@ -87,6 +87,7 @@ static char *bda2str(esp_bd_addr_t bda, char *str, size_t size)
|
|||||||
p[0], p[1], p[2], p[3], p[4], p[5]);
|
p[0], p[1], p[2], p[3], p[4], p[5]);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool get_name_from_eir(uint8_t *eir, char *bdname, uint8_t *bdname_len)
|
static bool get_name_from_eir(uint8_t *eir, char *bdname, uint8_t *bdname_len)
|
||||||
{
|
{
|
||||||
@ -152,7 +153,7 @@ static uint8_t _spp_tx_buffer[SPP_TX_MAX];
|
|||||||
static uint16_t _spp_tx_buffer_len = 0;
|
static uint16_t _spp_tx_buffer_len = 0;
|
||||||
|
|
||||||
static bool _spp_send_buffer(){
|
static bool _spp_send_buffer(){
|
||||||
if((xEventGroupWaitBits(_spp_event_group, SPP_CONGESTED, pdFALSE, pdTRUE, portMAX_DELAY) & SPP_CONGESTED)){
|
if((xEventGroupWaitBits(_spp_event_group, SPP_CONGESTED, pdFALSE, pdTRUE, portMAX_DELAY) & SPP_CONGESTED) != 0){
|
||||||
esp_err_t err = esp_spp_write(_spp_client, _spp_tx_buffer_len, _spp_tx_buffer);
|
esp_err_t err = esp_spp_write(_spp_client, _spp_tx_buffer_len, _spp_tx_buffer);
|
||||||
if(err != ESP_OK){
|
if(err != ESP_OK){
|
||||||
log_e("SPP Write Failed! [0x%X]", err);
|
log_e("SPP Write Failed! [0x%X]", err);
|
||||||
@ -216,14 +217,17 @@ static void _spp_tx_task(void * arg){
|
|||||||
_spp_task_handle = NULL;
|
_spp_task_handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
|
static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
|
||||||
{
|
{
|
||||||
switch (event)
|
switch (event)
|
||||||
{
|
{
|
||||||
case ESP_SPP_INIT_EVT:
|
case ESP_SPP_INIT_EVT:
|
||||||
log_i("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);
|
esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
|
||||||
|
#endif
|
||||||
if (!_isMaster) {
|
if (!_isMaster) {
|
||||||
log_i("ESP_SPP_INIT_EVT: slave: start");
|
log_i("ESP_SPP_INIT_EVT: slave: start");
|
||||||
esp_spp_start_srv(ESP_SPP_SEC_NONE, ESP_SPP_ROLE_SLAVE, 0, _spp_server_name);
|
esp_spp_start_srv(ESP_SPP_SEC_NONE, ESP_SPP_ROLE_SLAVE, 0, _spp_server_name);
|
||||||
@ -276,7 +280,9 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
|
|||||||
//esp_log_buffer_hex("",param->data_ind.data,param->data_ind.len); //for low level debug
|
//esp_log_buffer_hex("",param->data_ind.data,param->data_ind.len); //for low level debug
|
||||||
//ets_printf("r:%u\n", param->data_ind.len);
|
//ets_printf("r:%u\n", param->data_ind.len);
|
||||||
|
|
||||||
if (_spp_rx_queue != NULL){
|
if(custom_data_callback){
|
||||||
|
custom_data_callback(param->data_ind.data, param->data_ind.len);
|
||||||
|
} else if (_spp_rx_queue != NULL){
|
||||||
for (int i = 0; i < param->data_ind.len; i++){
|
for (int i = 0; i < param->data_ind.len; i++){
|
||||||
if(xQueueSend(_spp_rx_queue, param->data_ind.data + i, (TickType_t)0) != pdTRUE){
|
if(xQueueSend(_spp_rx_queue, param->data_ind.data + i, (TickType_t)0) != pdTRUE){
|
||||||
log_e("RX Full! Discarding %u bytes", param->data_ind.len - i);
|
log_e("RX Full! Discarding %u bytes", param->data_ind.len - i);
|
||||||
@ -320,13 +326,19 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
|
|||||||
if(custom_spp_callback)(*custom_spp_callback)(event, param);
|
if(custom_spp_callback)(*custom_spp_callback)(event, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BluetoothSerial::onData(BluetoothSerialDataCb cb){
|
||||||
|
custom_data_callback = cb;
|
||||||
|
}
|
||||||
|
|
||||||
static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
|
static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
|
||||||
{
|
{
|
||||||
switch(event){
|
switch(event){
|
||||||
case ESP_BT_GAP_DISC_RES_EVT:
|
case ESP_BT_GAP_DISC_RES_EVT:
|
||||||
log_i("ESP_BT_GAP_DISC_RES_EVT");
|
log_i("ESP_BT_GAP_DISC_RES_EVT");
|
||||||
|
#if (ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO)
|
||||||
char bda_str[18];
|
char bda_str[18];
|
||||||
log_i("Scanned device: %s", bda2str(param->disc_res.bda, bda_str, 18));
|
log_i("Scanned device: %s", bda2str(param->disc_res.bda, bda_str, 18));
|
||||||
|
#endif
|
||||||
for (int i = 0; i < param->disc_res.num_prop; i++) {
|
for (int i = 0; i < param->disc_res.num_prop; i++) {
|
||||||
uint8_t peer_bdname_len;
|
uint8_t peer_bdname_len;
|
||||||
char peer_bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1];
|
char peer_bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1];
|
||||||
@ -361,11 +373,11 @@ static void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ESP_BT_GAP_DEV_PROP_COD:
|
case ESP_BT_GAP_DEV_PROP_COD:
|
||||||
//log_i("ESP_BT_GAP_DEV_PROP_COD");
|
log_d("ESP_BT_GAP_DEV_PROP_COD");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ESP_BT_GAP_DEV_PROP_RSSI:
|
case ESP_BT_GAP_DEV_PROP_RSSI:
|
||||||
//log_i("ESP_BT_GAP_DEV_PROP_RSSI");
|
log_d("ESP_BT_GAP_DEV_PROP_RSSI");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -465,7 +477,7 @@ static bool _init_bt(const char *deviceName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!_spp_task_handle){
|
if(!_spp_task_handle){
|
||||||
xTaskCreate(_spp_tx_task, "spp_tx", 4096, NULL, 2, &_spp_task_handle);
|
xTaskCreatePinnedToCore(_spp_tx_task, "spp_tx", 4096, NULL, 2, &_spp_task_handle, 0);
|
||||||
if(!_spp_task_handle){
|
if(!_spp_task_handle){
|
||||||
log_e("Network Event Task Start Failed!");
|
log_e("Network Event Task Start Failed!");
|
||||||
return false;
|
return false;
|
||||||
@ -507,6 +519,10 @@ static bool _init_bt(const char *deviceName)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (esp_bt_sleep_disable() != ESP_OK){
|
||||||
|
log_e("esp_bt_sleep_disable failed");
|
||||||
|
}
|
||||||
|
|
||||||
log_i("device name set");
|
log_i("device name set");
|
||||||
esp_bt_dev_set_device_name(deviceName);
|
esp_bt_dev_set_device_name(deviceName);
|
||||||
|
|
||||||
@ -574,7 +590,7 @@ static bool _stop_bt()
|
|||||||
|
|
||||||
static bool waitForConnect(int timeout) {
|
static bool waitForConnect(int timeout) {
|
||||||
TickType_t xTicksToWait = timeout / portTICK_PERIOD_MS;
|
TickType_t xTicksToWait = timeout / portTICK_PERIOD_MS;
|
||||||
return (xEventGroupWaitBits(_spp_event_group, SPP_CONNECTED, pdFALSE, pdTRUE, xTicksToWait) != 0);
|
return (xEventGroupWaitBits(_spp_event_group, SPP_CONNECTED, pdFALSE, pdTRUE, xTicksToWait) & SPP_CONNECTED) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -648,7 +664,11 @@ size_t BluetoothSerial::write(const uint8_t *buffer, size_t size)
|
|||||||
|
|
||||||
void BluetoothSerial::flush()
|
void BluetoothSerial::flush()
|
||||||
{
|
{
|
||||||
while(read() >= 0){}
|
if (_spp_tx_queue != NULL){
|
||||||
|
while(uxQueueMessagesWaiting(_spp_tx_queue) > 0){
|
||||||
|
delay(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BluetoothSerial::end()
|
void BluetoothSerial::end()
|
||||||
@ -701,7 +721,11 @@ bool BluetoothSerial::connect(String remoteName)
|
|||||||
_remote_name[ESP_BT_GAP_MAX_BDNAME_LEN] = 0;
|
_remote_name[ESP_BT_GAP_MAX_BDNAME_LEN] = 0;
|
||||||
log_i("master : remoteName");
|
log_i("master : remoteName");
|
||||||
// will first resolve name to address
|
// will first resolve name to address
|
||||||
|
#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);
|
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) {
|
if (esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, INQ_LEN, INQ_NUM_RSPS) == ESP_OK) {
|
||||||
return waitForConnect(SCAN_TIMEOUT);
|
return waitForConnect(SCAN_TIMEOUT);
|
||||||
}
|
}
|
||||||
@ -741,7 +765,11 @@ bool BluetoothSerial::connect()
|
|||||||
disconnect();
|
disconnect();
|
||||||
log_i("master : remoteName");
|
log_i("master : remoteName");
|
||||||
// will resolve name to address first - it may take a while
|
// 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);
|
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) {
|
if (esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, INQ_LEN, INQ_NUM_RSPS) == ESP_OK) {
|
||||||
return waitForConnect(SCAN_TIMEOUT);
|
return waitForConnect(SCAN_TIMEOUT);
|
||||||
}
|
}
|
||||||
@ -757,7 +785,7 @@ bool BluetoothSerial::disconnect() {
|
|||||||
log_i("disconnecting");
|
log_i("disconnecting");
|
||||||
if (esp_spp_disconnect(_spp_client) == ESP_OK) {
|
if (esp_spp_disconnect(_spp_client) == ESP_OK) {
|
||||||
TickType_t xTicksToWait = READY_TIMEOUT / portTICK_PERIOD_MS;
|
TickType_t xTicksToWait = READY_TIMEOUT / portTICK_PERIOD_MS;
|
||||||
return (xEventGroupWaitBits(_spp_event_group, SPP_DISCONNECTED, pdFALSE, pdTRUE, xTicksToWait) != 0);
|
return (xEventGroupWaitBits(_spp_event_group, SPP_DISCONNECTED, pdFALSE, pdTRUE, xTicksToWait) & SPP_DISCONNECTED) != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -785,6 +813,6 @@ bool BluetoothSerial::isReady(bool checkMaster, int timeout) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
TickType_t xTicksToWait = timeout / portTICK_PERIOD_MS;
|
TickType_t xTicksToWait = timeout / portTICK_PERIOD_MS;
|
||||||
return (xEventGroupWaitBits(_spp_event_group, SPP_RUNNING, pdFALSE, pdTRUE, xTicksToWait) != 0);
|
return (xEventGroupWaitBits(_spp_event_group, SPP_RUNNING, pdFALSE, pdTRUE, xTicksToWait) & SPP_RUNNING) != 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "Stream.h"
|
#include "Stream.h"
|
||||||
#include <esp_spp_api.h>
|
#include <esp_spp_api.h>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
typedef std::function<void(const uint8_t *buffer, size_t size)> BluetoothSerialDataCb;
|
||||||
|
|
||||||
class BluetoothSerial: public Stream
|
class BluetoothSerial: public Stream
|
||||||
{
|
{
|
||||||
@ -39,6 +42,7 @@ class BluetoothSerial: public Stream
|
|||||||
size_t write(const uint8_t *buffer, size_t size);
|
size_t write(const uint8_t *buffer, size_t size);
|
||||||
void flush();
|
void flush();
|
||||||
void end(void);
|
void end(void);
|
||||||
|
void onData(BluetoothSerialDataCb cb);
|
||||||
esp_err_t register_callback(esp_spp_cb_t * callback);
|
esp_err_t register_callback(esp_spp_cb_t * callback);
|
||||||
|
|
||||||
void enableSSP();
|
void enableSSP();
|
||||||
|
@ -12,6 +12,8 @@ String responseHTML = ""
|
|||||||
"be redirected here.</p></body></html>";
|
"be redirected here.</p></body></html>";
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
WiFi.disconnect(); //added to start with the wifi off, avoid crashing
|
||||||
|
WiFi.mode(WIFI_OFF); //added to start with the wifi off, avoid crashing
|
||||||
WiFi.mode(WIFI_AP);
|
WiFi.mode(WIFI_AP);
|
||||||
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
|
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
|
||||||
WiFi.softAP("DNSServer CaptivePortal example");
|
WiFi.softAP("DNSServer CaptivePortal example");
|
||||||
|
@ -52,10 +52,10 @@ void setup() {
|
|||||||
Serial.println("------------------------------------\n");
|
Serial.println("------------------------------------\n");
|
||||||
|
|
||||||
// Clear variables
|
// Clear variables
|
||||||
name = '\0';
|
rname[0] = '\0';
|
||||||
height = 0;
|
height = 0;
|
||||||
age = 0;
|
age = 0;
|
||||||
Serial.print("name: "); Serial.println(name);
|
Serial.print("name: "); Serial.println(rname);
|
||||||
Serial.print("height: "); Serial.println(height);
|
Serial.print("height: "); Serial.println(height);
|
||||||
Serial.print("age: "); Serial.println(age);
|
Serial.print("age: "); Serial.println(age);
|
||||||
Serial.println("------------------------------------\n");
|
Serial.println("------------------------------------\n");
|
||||||
|
@ -2,16 +2,18 @@
|
|||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// WARNING!!! Make sure that you have either selected ESP32 Wrover Module,
|
// WARNING!!! PSRAM IC required for UXGA resolution and high JPEG quality
|
||||||
// or another board which has PSRAM enabled
|
// Ensure ESP32 Wrover Module or other board with PSRAM is selected
|
||||||
|
// Partial images will be transmitted if image exceeds buffer size
|
||||||
//
|
//
|
||||||
|
|
||||||
// Select camera model
|
// Select camera model
|
||||||
#define CAMERA_MODEL_WROVER_KIT
|
#define CAMERA_MODEL_WROVER_KIT // Has PSRAM
|
||||||
//#define CAMERA_MODEL_ESP_EYE
|
//#define CAMERA_MODEL_ESP_EYE // Has PSRAM
|
||||||
//#define CAMERA_MODEL_M5STACK_PSRAM
|
//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
|
||||||
//#define CAMERA_MODEL_M5STACK_WIDE
|
//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
|
||||||
//#define CAMERA_MODEL_AI_THINKER
|
//#define CAMERA_MODEL_AI_THINKER // Has PSRAM
|
||||||
|
//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
|
||||||
|
|
||||||
#include "camera_pins.h"
|
#include "camera_pins.h"
|
||||||
|
|
||||||
@ -46,7 +48,9 @@ void setup() {
|
|||||||
config.pin_reset = RESET_GPIO_NUM;
|
config.pin_reset = RESET_GPIO_NUM;
|
||||||
config.xclk_freq_hz = 20000000;
|
config.xclk_freq_hz = 20000000;
|
||||||
config.pixel_format = PIXFORMAT_JPEG;
|
config.pixel_format = PIXFORMAT_JPEG;
|
||||||
//init with high specs to pre-allocate larger buffers
|
|
||||||
|
// if PSRAM IC present, init with UXGA resolution and higher JPEG quality
|
||||||
|
// for larger pre-allocated frame buffer.
|
||||||
if(psramFound()){
|
if(psramFound()){
|
||||||
config.frame_size = FRAMESIZE_UXGA;
|
config.frame_size = FRAMESIZE_UXGA;
|
||||||
config.jpeg_quality = 10;
|
config.jpeg_quality = 10;
|
||||||
@ -73,7 +77,7 @@ void setup() {
|
|||||||
// initial sensors are flipped vertically and colors are a bit saturated
|
// initial sensors are flipped vertically and colors are a bit saturated
|
||||||
if (s->id.PID == OV3660_PID) {
|
if (s->id.PID == OV3660_PID) {
|
||||||
s->set_vflip(s, 1); // flip it back
|
s->set_vflip(s, 1); // flip it back
|
||||||
s->set_brightness(s, 1);//up the blightness just a bit
|
s->set_brightness(s, 1); // up the brightness just a bit
|
||||||
s->set_saturation(s, -2); // lower the saturation
|
s->set_saturation(s, -2); // lower the saturation
|
||||||
}
|
}
|
||||||
// drop down frame size for higher initial frame rate
|
// drop down frame size for higher initial frame rate
|
||||||
|
@ -56,11 +56,11 @@ static ra_filter_t ra_filter;
|
|||||||
httpd_handle_t stream_httpd = NULL;
|
httpd_handle_t stream_httpd = NULL;
|
||||||
httpd_handle_t camera_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 detection_enabled = 0;
|
||||||
static int8_t recognition_enabled = 0;
|
static int8_t recognition_enabled = 0;
|
||||||
static int8_t is_enrolling = 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){
|
static ra_filter_t * ra_filter_init(ra_filter_t * filter, size_t sample_size){
|
||||||
memset(filter, 0, sizeof(ra_filter_t));
|
memset(filter, 0, sizeof(ra_filter_t));
|
||||||
|
@ -94,6 +94,25 @@
|
|||||||
#define HREF_GPIO_NUM 23
|
#define HREF_GPIO_NUM 23
|
||||||
#define PCLK_GPIO_NUM 22
|
#define PCLK_GPIO_NUM 22
|
||||||
|
|
||||||
|
#elif defined(CAMERA_MODEL_TTGO_T_JOURNAL)
|
||||||
|
#define PWDN_GPIO_NUM 0
|
||||||
|
#define RESET_GPIO_NUM 15
|
||||||
|
#define XCLK_GPIO_NUM 27
|
||||||
|
#define SIOD_GPIO_NUM 25
|
||||||
|
#define SIOC_GPIO_NUM 23
|
||||||
|
|
||||||
|
#define Y9_GPIO_NUM 19
|
||||||
|
#define Y8_GPIO_NUM 36
|
||||||
|
#define Y7_GPIO_NUM 18
|
||||||
|
#define Y6_GPIO_NUM 39
|
||||||
|
#define Y5_GPIO_NUM 5
|
||||||
|
#define Y4_GPIO_NUM 34
|
||||||
|
#define Y3_GPIO_NUM 35
|
||||||
|
#define Y2_GPIO_NUM 17
|
||||||
|
#define VSYNC_GPIO_NUM 22
|
||||||
|
#define HREF_GPIO_NUM 26
|
||||||
|
#define PCLK_GPIO_NUM 21
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "Camera model not selected"
|
#error "Camera model not selected"
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,7 +12,15 @@
|
|||||||
* Evandro Luis Copercini - 2017
|
* 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 */
|
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ void readFile(fs::FS &fs, const char * path){
|
|||||||
while(file.available()){
|
while(file.available()){
|
||||||
Serial.write(file.read());
|
Serial.write(file.read());
|
||||||
}
|
}
|
||||||
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeFile(fs::FS &fs, const char * path, const char * message){
|
void writeFile(fs::FS &fs, const char * path, const char * message){
|
||||||
@ -65,8 +66,9 @@ void writeFile(fs::FS &fs, const char * path, const char * message){
|
|||||||
if(file.print(message)){
|
if(file.print(message)){
|
||||||
Serial.println("- file written");
|
Serial.println("- file written");
|
||||||
} else {
|
} else {
|
||||||
Serial.println("- frite failed");
|
Serial.println("- write failed");
|
||||||
}
|
}
|
||||||
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void appendFile(fs::FS &fs, const char * path, const char * message){
|
void appendFile(fs::FS &fs, const char * path, const char * message){
|
||||||
@ -82,6 +84,7 @@ void appendFile(fs::FS &fs, const char * path, const char * message){
|
|||||||
} else {
|
} else {
|
||||||
Serial.println("- append failed");
|
Serial.println("- append failed");
|
||||||
}
|
}
|
||||||
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void renameFile(fs::FS &fs, const char * path1, const char * path2){
|
void renameFile(fs::FS &fs, const char * path1, const char * path2){
|
||||||
|
@ -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_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_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_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();
|
||||||
esp_wifi_sta_wpa2_ent_enable(&config); //set config settings to enable function
|
|
||||||
WiFi.begin(ssid); //connect to wifi
|
WiFi.begin(ssid); //connect to wifi
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(500);
|
delay(500);
|
||||||
|
@ -910,7 +910,7 @@ void HTTPClient::addHeader(const String& name, const String& value, bool first,
|
|||||||
|
|
||||||
if (replace) {
|
if (replace) {
|
||||||
int headerStart = _headers.indexOf(headerLine);
|
int headerStart = _headers.indexOf(headerLine);
|
||||||
if (headerStart != -1) {
|
if (headerStart != -1 && (headerStart == 0 || _headers[headerStart - 1] == '\n')) {
|
||||||
int headerEnd = _headers.indexOf('\n', headerStart);
|
int headerEnd = _headers.indexOf('\n', headerStart);
|
||||||
_headers = _headers.substring(0, headerStart) + _headers.substring(headerEnd + 1);
|
_headers = _headers.substring(0, headerStart) + _headers.substring(headerEnd + 1);
|
||||||
}
|
}
|
||||||
@ -924,7 +924,6 @@ void HTTPClient::addHeader(const String& name, const String& value, bool first,
|
|||||||
_headers += headerLine;
|
_headers += headerLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTPClient::collectHeaders(const char* headerKeys[], const size_t headerKeysCount)
|
void HTTPClient::collectHeaders(const char* headerKeys[], const size_t headerKeysCount)
|
||||||
|
95
libraries/README.md
Normal file
95
libraries/README.md
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
# ESP32 Libraries
|
||||||
|
|
||||||
|
arduino-esp32 includes libraries for Arduino compatibility along with some object wrappers around hardware specific devices. Examples are included in the examples folder under each library folder. The ESP32 includes additional examples which need no special drivers.
|
||||||
|
|
||||||
|
### ArduinoOTA
|
||||||
|
Over The Air firmware update daemon. Use espota.py to upload to the device.
|
||||||
|
|
||||||
|
### AsyncUDP
|
||||||
|
Asynchronous task driven UDP datagram client/server
|
||||||
|
|
||||||
|
### AzureIoT
|
||||||
|
Library to interact with Microsoft Azure IoT services
|
||||||
|
|
||||||
|
### BLE
|
||||||
|
Bluetooth Low Energy v4.2 client/server framework
|
||||||
|
|
||||||
|
### BluetoothSerial
|
||||||
|
Serial to Bluetooth redirection server
|
||||||
|
|
||||||
|
### DNSServer
|
||||||
|
A basic UDP DNS daemon (includes captive portal demo)
|
||||||
|
|
||||||
|
### EEPROM
|
||||||
|
Arduino compatibility for EEPROM (using flash)
|
||||||
|
|
||||||
|
### ESP32
|
||||||
|
Additional examples
|
||||||
|
* AnalogOut
|
||||||
|
* Camera
|
||||||
|
* ChipID
|
||||||
|
* DeepSleep
|
||||||
|
* ESPNow
|
||||||
|
* FreeRTOS
|
||||||
|
* GPIO
|
||||||
|
* HallSensor
|
||||||
|
* I2S
|
||||||
|
* ResetReason
|
||||||
|
* RMT
|
||||||
|
* Time
|
||||||
|
* Timer
|
||||||
|
* Touch
|
||||||
|
|
||||||
|
### ESPmDNS
|
||||||
|
mDNS service advertising
|
||||||
|
|
||||||
|
### FFat
|
||||||
|
FAT indexed filesystem on SPI flash
|
||||||
|
|
||||||
|
### FS
|
||||||
|
Filesystem virtualization framework
|
||||||
|
|
||||||
|
### HTTPClient
|
||||||
|
A simple HTTP client, compatible with WiFiClientSecure
|
||||||
|
|
||||||
|
### HTTPUpdate
|
||||||
|
Download a firmware update from HTTPd and apply it using Update
|
||||||
|
|
||||||
|
### NetBIOS
|
||||||
|
NetBIOS name advertiser
|
||||||
|
|
||||||
|
### Preferences
|
||||||
|
Flash keystore using ESP32 NVS
|
||||||
|
|
||||||
|
### SD
|
||||||
|
Secure Digital card filesystem using SPI access
|
||||||
|
|
||||||
|
### SD_MMC
|
||||||
|
Secure Digital card filesystem using 4-lane access
|
||||||
|
|
||||||
|
### SimpleBLE
|
||||||
|
Minimal BLE advertiser
|
||||||
|
|
||||||
|
### SPI
|
||||||
|
Arduino compatible Serial Peripheral Interface driver (master only)
|
||||||
|
|
||||||
|
### SPIFFS
|
||||||
|
SPI Flash Filesystem (see [spiffs-plugin](https://github.com/me-no-dev/arduino-esp32fs-plugin) to upload to device)
|
||||||
|
|
||||||
|
### Ticker
|
||||||
|
A timer to call functions on an interval
|
||||||
|
|
||||||
|
### Update
|
||||||
|
Sketch Update using ESP32 OTA functionality
|
||||||
|
|
||||||
|
### WebServer
|
||||||
|
A simple HTTP daemon
|
||||||
|
|
||||||
|
### WiFi
|
||||||
|
Arduino compatible WiFi driver (includes Ethernet driver)
|
||||||
|
|
||||||
|
### WiFiClientSecure
|
||||||
|
Arduino compatible WiFi client object using embedded encryption
|
||||||
|
|
||||||
|
### Wire
|
||||||
|
Arduino compatible I2C driver (master only)
|
@ -12,10 +12,13 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#include "sd_diskio.h"
|
#include "sd_diskio.h"
|
||||||
|
#include "esp_system.h"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "diskio.h"
|
|
||||||
#include "ffconf.h"
|
|
||||||
#include "ff.h"
|
#include "ff.h"
|
||||||
|
#include "diskio.h"
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR
|
||||||
|
#include "diskio_impl.h"
|
||||||
|
#endif
|
||||||
//#include "esp_vfs.h"
|
//#include "esp_vfs.h"
|
||||||
#include "esp_vfs_fat.h"
|
#include "esp_vfs_fat.h"
|
||||||
char CRC7(const char* data, int length);
|
char CRC7(const char* data, int length);
|
||||||
|
@ -15,6 +15,30 @@
|
|||||||
*/
|
*/
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
|
// Define ALTERNATE_PINS to use non-standard GPIO pins for SPI bus
|
||||||
|
|
||||||
|
#ifdef ALTERNATE_PINS
|
||||||
|
#define VSPI_MISO 2
|
||||||
|
#define VSPI_MOSI 4
|
||||||
|
#define VSPI_SCLK 0
|
||||||
|
#define VSPI_SS 33
|
||||||
|
|
||||||
|
#define HSPI_MISO 26
|
||||||
|
#define HSPI_MOSI 27
|
||||||
|
#define HSPI_SCLK 25
|
||||||
|
#define HSPI_SS 32
|
||||||
|
#else
|
||||||
|
#define VSPI_MISO MISO
|
||||||
|
#define VSPI_MOSI MOSI
|
||||||
|
#define VSPI_SCLK SCK
|
||||||
|
#define VSPI_SS SS
|
||||||
|
|
||||||
|
#define HSPI_MISO 12
|
||||||
|
#define HSPI_MOSI 13
|
||||||
|
#define HSPI_SCLK 14
|
||||||
|
#define HSPI_SS 15
|
||||||
|
#endif
|
||||||
|
|
||||||
static const int spiClk = 1000000; // 1 MHz
|
static const int spiClk = 1000000; // 1 MHz
|
||||||
|
|
||||||
//uninitalised pointers to SPI objects
|
//uninitalised pointers to SPI objects
|
||||||
@ -28,22 +52,28 @@ void setup() {
|
|||||||
|
|
||||||
//clock miso mosi ss
|
//clock miso mosi ss
|
||||||
|
|
||||||
|
#ifndef ALTERNATE_PINS
|
||||||
//initialise vspi with default pins
|
//initialise vspi with default pins
|
||||||
//SCLK = 18, MISO = 19, MOSI = 23, SS = 5
|
//SCLK = 18, MISO = 19, MOSI = 23, SS = 5
|
||||||
vspi->begin();
|
vspi->begin();
|
||||||
|
#else
|
||||||
//alternatively route through GPIO pins of your choice
|
//alternatively route through GPIO pins of your choice
|
||||||
//hspi->begin(0, 2, 4, 33); //SCLK, MISO, MOSI, SS
|
vspi->begin(VSPI_SCLK, VSPI_MISO, VSPI_MOSI, VSPI_SS); //SCLK, MISO, MOSI, SS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ALTERNATE_PINS
|
||||||
//initialise hspi with default pins
|
//initialise hspi with default pins
|
||||||
//SCLK = 14, MISO = 12, MOSI = 13, SS = 15
|
//SCLK = 14, MISO = 12, MOSI = 13, SS = 15
|
||||||
hspi->begin();
|
hspi->begin();
|
||||||
|
#else
|
||||||
//alternatively route through GPIO pins
|
//alternatively route through GPIO pins
|
||||||
//hspi->begin(25, 26, 27, 32); //SCLK, MISO, MOSI, SS
|
hspi->begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI, HSPI_SS); //SCLK, MISO, MOSI, SS
|
||||||
|
#endif
|
||||||
|
|
||||||
//set up slave select pins as outputs as the Arduino API
|
//set up slave select pins as outputs as the Arduino API
|
||||||
//doesn't handle automatically pulling SS low
|
//doesn't handle automatically pulling SS low
|
||||||
pinMode(5, OUTPUT); //VSPI SS
|
pinMode(VSPI_SS, OUTPUT); //VSPI SS
|
||||||
pinMode(15, OUTPUT); //HSPI SS
|
pinMode(HSPI_SS, OUTPUT); //HSPI SS
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,9 +90,9 @@ void vspiCommand() {
|
|||||||
|
|
||||||
//use it as you would the regular arduino SPI API
|
//use it as you would the regular arduino SPI API
|
||||||
vspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
|
vspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
|
||||||
digitalWrite(5, LOW); //pull SS slow to prep other end for transfer
|
digitalWrite(VSPI_SS, LOW); //pull SS slow to prep other end for transfer
|
||||||
vspi->transfer(data);
|
vspi->transfer(data);
|
||||||
digitalWrite(5, HIGH); //pull ss high to signify end of data transfer
|
digitalWrite(VSPI_SS, HIGH); //pull ss high to signify end of data transfer
|
||||||
vspi->endTransaction();
|
vspi->endTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,8 +100,8 @@ void hspiCommand() {
|
|||||||
byte stuff = 0b11001100;
|
byte stuff = 0b11001100;
|
||||||
|
|
||||||
hspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
|
hspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
|
||||||
digitalWrite(15, LOW);
|
digitalWrite(HSPI_SS, LOW);
|
||||||
hspi->transfer(stuff);
|
hspi->transfer(stuff);
|
||||||
digitalWrite(15, HIGH);
|
digitalWrite(HSPI_SS, HIGH);
|
||||||
hspi->endTransaction();
|
hspi->endTransaction();
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ void SPIClass::writePixels(const void * data, uint32_t size)
|
|||||||
* @param out uint8_t * output buffer. can be NULL for Write Only operation
|
* @param out uint8_t * output buffer. can be NULL for Write Only operation
|
||||||
* @param size uint32_t
|
* @param size uint32_t
|
||||||
*/
|
*/
|
||||||
void SPIClass::transferBytes(uint8_t * data, uint8_t * out, uint32_t size)
|
void SPIClass::transferBytes(const uint8_t * data, uint8_t * out, uint32_t size)
|
||||||
{
|
{
|
||||||
if(_inTransaction){
|
if(_inTransaction){
|
||||||
return spiTransferBytesNL(_spi, data, out, size);
|
return spiTransferBytesNL(_spi, data, out, size);
|
||||||
@ -251,7 +251,7 @@ void SPIClass::transferBytes(uint8_t * data, uint8_t * out, uint32_t size)
|
|||||||
* @param size uint8_t max for size is 64Byte
|
* @param size uint8_t max for size is 64Byte
|
||||||
* @param repeat uint32_t
|
* @param repeat uint32_t
|
||||||
*/
|
*/
|
||||||
void SPIClass::writePattern(uint8_t * data, uint8_t size, uint32_t repeat)
|
void SPIClass::writePattern(const uint8_t * data, uint8_t size, uint32_t repeat)
|
||||||
{
|
{
|
||||||
if(size > 64) {
|
if(size > 64) {
|
||||||
return; //max Hardware FIFO
|
return; //max Hardware FIFO
|
||||||
@ -272,12 +272,12 @@ void SPIClass::writePattern(uint8_t * data, uint8_t size, uint32_t repeat)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPIClass::writePattern_(uint8_t * data, uint8_t size, uint8_t repeat)
|
void SPIClass::writePattern_(const uint8_t * data, uint8_t size, uint8_t repeat)
|
||||||
{
|
{
|
||||||
uint8_t bytes = (size * repeat);
|
uint8_t bytes = (size * repeat);
|
||||||
uint8_t buffer[64];
|
uint8_t buffer[64];
|
||||||
uint8_t * bufferPtr = &buffer[0];
|
uint8_t * bufferPtr = &buffer[0];
|
||||||
uint8_t * dataPtr;
|
const uint8_t * dataPtr;
|
||||||
uint8_t dataSize = bytes;
|
uint8_t dataSize = bytes;
|
||||||
for(uint8_t i = 0; i < repeat; i++) {
|
for(uint8_t i = 0; i < repeat; i++) {
|
||||||
dataSize = size;
|
dataSize = size;
|
||||||
|
@ -48,7 +48,7 @@ private:
|
|||||||
uint32_t _div;
|
uint32_t _div;
|
||||||
uint32_t _freq;
|
uint32_t _freq;
|
||||||
bool _inTransaction;
|
bool _inTransaction;
|
||||||
void writePattern_(uint8_t * data, uint8_t size, uint8_t repeat);
|
void writePattern_(const uint8_t * data, uint8_t size, uint8_t repeat);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SPIClass(uint8_t spi_bus=HSPI);
|
SPIClass(uint8_t spi_bus=HSPI);
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
uint16_t transfer16(uint16_t data);
|
uint16_t transfer16(uint16_t data);
|
||||||
uint32_t transfer32(uint32_t data);
|
uint32_t transfer32(uint32_t data);
|
||||||
|
|
||||||
void transferBytes(uint8_t * data, uint8_t * out, uint32_t size);
|
void transferBytes(const uint8_t * data, uint8_t * out, uint32_t size);
|
||||||
void transferBits(uint32_t data, uint32_t * out, uint8_t bits);
|
void transferBits(uint32_t data, uint32_t * out, uint8_t bits);
|
||||||
|
|
||||||
void write(uint8_t data);
|
void write(uint8_t data);
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
void write32(uint32_t data);
|
void write32(uint32_t data);
|
||||||
void writeBytes(const uint8_t * data, uint32_t size);
|
void writeBytes(const uint8_t * data, uint32_t size);
|
||||||
void writePixels(const void * data, uint32_t size);//ili9341 compatible
|
void writePixels(const void * data, uint32_t size);//ili9341 compatible
|
||||||
void writePattern(uint8_t * data, uint8_t size, uint32_t repeat);
|
void writePattern(const uint8_t * data, uint8_t size, uint32_t repeat);
|
||||||
|
|
||||||
spi_t * bus(){ return _spi; }
|
spi_t * bus(){ return _spi; }
|
||||||
};
|
};
|
||||||
|
@ -50,6 +50,7 @@ void readFile(fs::FS &fs, const char * path){
|
|||||||
while(file.available()){
|
while(file.available()){
|
||||||
Serial.write(file.read());
|
Serial.write(file.read());
|
||||||
}
|
}
|
||||||
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeFile(fs::FS &fs, const char * path, const char * message){
|
void writeFile(fs::FS &fs, const char * path, const char * message){
|
||||||
@ -63,8 +64,9 @@ void writeFile(fs::FS &fs, const char * path, const char * message){
|
|||||||
if(file.print(message)){
|
if(file.print(message)){
|
||||||
Serial.println("- file written");
|
Serial.println("- file written");
|
||||||
} else {
|
} else {
|
||||||
Serial.println("- frite failed");
|
Serial.println("- write failed");
|
||||||
}
|
}
|
||||||
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void appendFile(fs::FS &fs, const char * path, const char * message){
|
void appendFile(fs::FS &fs, const char * path, const char * message){
|
||||||
@ -80,6 +82,7 @@ void appendFile(fs::FS &fs, const char * path, const char * message){
|
|||||||
} else {
|
} else {
|
||||||
Serial.println("- append failed");
|
Serial.println("- append failed");
|
||||||
}
|
}
|
||||||
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void renameFile(fs::FS &fs, const char * path1, const char * path2){
|
void renameFile(fs::FS &fs, const char * path1, const char * path2){
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
#include <WebServer.h>
|
#include <WebServer.h>
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
|
|
||||||
|
#include <uri/UriBraces.h>
|
||||||
|
#include <uri/UriRegex.h>
|
||||||
|
|
||||||
const char *ssid = "........";
|
const char *ssid = "........";
|
||||||
const char *password = "........";
|
const char *password = "........";
|
||||||
|
|
||||||
@ -33,12 +36,12 @@ void setup(void) {
|
|||||||
server.send(200, "text/plain", "hello from esp32!");
|
server.send(200, "text/plain", "hello from esp32!");
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/users/{}", []() {
|
server.on(UriBraces("/users/{}"), []() {
|
||||||
String user = server.pathArg(0);
|
String user = server.pathArg(0);
|
||||||
server.send(200, "text/plain", "User: '" + user + "'");
|
server.send(200, "text/plain", "User: '" + user + "'");
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/users/{}/devices/{}", []() {
|
server.on(UriRegex("^\\/users\\/([0-9]+)\\/devices\\/([0-9]+)$"), []() {
|
||||||
String user = server.pathArg(0);
|
String user = server.pathArg(0);
|
||||||
String device = server.pathArg(1);
|
String device = server.pathArg(1);
|
||||||
server.send(200, "text/plain", "User: '" + user + "' and Device: '" + device + "'");
|
server.send(200, "text/plain", "User: '" + user + "' and Device: '" + device + "'");
|
||||||
|
28
libraries/WebServer/src/Uri.h
Normal file
28
libraries/WebServer/src/Uri.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#ifndef URI_H
|
||||||
|
#define URI_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class Uri {
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const String _uri;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Uri(const char *uri) : _uri(uri) {}
|
||||||
|
Uri(const String &uri) : _uri(uri) {}
|
||||||
|
virtual ~Uri() {}
|
||||||
|
|
||||||
|
virtual Uri* clone() const {
|
||||||
|
return new Uri(_uri);
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void initPathArgs(__attribute__((unused)) std::vector<String> &pathArgs) {}
|
||||||
|
|
||||||
|
virtual bool canHandle(const String &requestUri, __attribute__((unused)) std::vector<String> &pathArgs) {
|
||||||
|
return _uri == requestUri;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
|
|
||||||
static const char AUTHORIZATION_HEADER[] = "Authorization";
|
static const char AUTHORIZATION_HEADER[] = "Authorization";
|
||||||
static const char qop_auth[] = "qop=auth";
|
static const char qop_auth[] = "qop=\"auth\"";
|
||||||
static const char WWW_Authenticate[] = "WWW-Authenticate";
|
static const char WWW_Authenticate[] = "WWW-Authenticate";
|
||||||
static const char Content_Length[] = "Content-Length";
|
static const char Content_Length[] = "Content-Length";
|
||||||
|
|
||||||
@ -161,17 +161,17 @@ bool WebServer::authenticate(const char * username, const char * password){
|
|||||||
} else if(authReq.startsWith(F("Digest"))) {
|
} else if(authReq.startsWith(F("Digest"))) {
|
||||||
authReq = authReq.substring(7);
|
authReq = authReq.substring(7);
|
||||||
log_v("%s", authReq.c_str());
|
log_v("%s", authReq.c_str());
|
||||||
String _username = _extractParam(authReq,F("username=\""));
|
String _username = _extractParam(authReq,F("username=\""),'\"');
|
||||||
if(!_username.length() || _username != String(username)) {
|
if(!_username.length() || _username != String(username)) {
|
||||||
authReq = "";
|
authReq = "";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// extracting required parameters for RFC 2069 simpler Digest
|
// extracting required parameters for RFC 2069 simpler Digest
|
||||||
String _realm = _extractParam(authReq, F("realm=\""));
|
String _realm = _extractParam(authReq, F("realm=\""),'\"');
|
||||||
String _nonce = _extractParam(authReq, F("nonce=\""));
|
String _nonce = _extractParam(authReq, F("nonce=\""),'\"');
|
||||||
String _uri = _extractParam(authReq, F("uri=\""));
|
String _uri = _extractParam(authReq, F("uri=\""),'\"');
|
||||||
String _response = _extractParam(authReq, F("response=\""));
|
String _response = _extractParam(authReq, F("response=\""),'\"');
|
||||||
String _opaque = _extractParam(authReq, F("opaque=\""));
|
String _opaque = _extractParam(authReq, F("opaque=\""),'\"');
|
||||||
|
|
||||||
if((!_realm.length()) || (!_nonce.length()) || (!_uri.length()) || (!_response.length()) || (!_opaque.length())) {
|
if((!_realm.length()) || (!_nonce.length()) || (!_uri.length()) || (!_response.length()) || (!_opaque.length())) {
|
||||||
authReq = "";
|
authReq = "";
|
||||||
@ -185,7 +185,7 @@ bool WebServer::authenticate(const char * username, const char * password){
|
|||||||
String _nc,_cnonce;
|
String _nc,_cnonce;
|
||||||
if(authReq.indexOf(FPSTR(qop_auth)) != -1) {
|
if(authReq.indexOf(FPSTR(qop_auth)) != -1) {
|
||||||
_nc = _extractParam(authReq, F("nc="), ',');
|
_nc = _extractParam(authReq, F("nc="), ',');
|
||||||
_cnonce = _extractParam(authReq, F("cnonce=\""));
|
_cnonce = _extractParam(authReq, F("cnonce=\""),'\"');
|
||||||
}
|
}
|
||||||
String _H1 = md5str(String(username) + ':' + _realm + ':' + String(password));
|
String _H1 = md5str(String(username) + ':' + _realm + ':' + String(password));
|
||||||
log_v("Hash of user:realm:pass=%s", _H1.c_str());
|
log_v("Hash of user:realm:pass=%s", _H1.c_str());
|
||||||
@ -245,15 +245,15 @@ void WebServer::requestAuthentication(HTTPAuthMethod mode, const char* realm, co
|
|||||||
send(401, String(FPSTR(mimeTable[html].mimeType)), authFailMsg);
|
send(401, String(FPSTR(mimeTable[html].mimeType)), authFailMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebServer::on(const String &uri, WebServer::THandlerFunction handler) {
|
void WebServer::on(const Uri &uri, WebServer::THandlerFunction handler) {
|
||||||
on(uri, HTTP_ANY, handler);
|
on(uri, HTTP_ANY, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebServer::on(const String &uri, HTTPMethod method, WebServer::THandlerFunction fn) {
|
void WebServer::on(const Uri &uri, HTTPMethod method, WebServer::THandlerFunction fn) {
|
||||||
on(uri, method, fn, _fileUploadHandler);
|
on(uri, method, fn, _fileUploadHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebServer::on(const String &uri, HTTPMethod method, WebServer::THandlerFunction fn, WebServer::THandlerFunction ufn) {
|
void WebServer::on(const Uri &uri, HTTPMethod method, WebServer::THandlerFunction fn, WebServer::THandlerFunction ufn) {
|
||||||
_addRequestHandler(new FunctionRequestHandler(fn, ufn, uri, method));
|
_addRequestHandler(new FunctionRequestHandler(fn, ufn, uri, method));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include "HTTP_Method.h"
|
#include "HTTP_Method.h"
|
||||||
|
#include "Uri.h"
|
||||||
|
|
||||||
enum HTTPUploadStatus { UPLOAD_FILE_START, UPLOAD_FILE_WRITE, UPLOAD_FILE_END,
|
enum HTTPUploadStatus { UPLOAD_FILE_START, UPLOAD_FILE_WRITE, UPLOAD_FILE_END,
|
||||||
UPLOAD_FILE_ABORTED };
|
UPLOAD_FILE_ABORTED };
|
||||||
@ -84,9 +85,9 @@ public:
|
|||||||
void requestAuthentication(HTTPAuthMethod mode = BASIC_AUTH, const char* realm = NULL, const String& authFailMsg = String("") );
|
void requestAuthentication(HTTPAuthMethod mode = BASIC_AUTH, const char* realm = NULL, const String& authFailMsg = String("") );
|
||||||
|
|
||||||
typedef std::function<void(void)> THandlerFunction;
|
typedef std::function<void(void)> THandlerFunction;
|
||||||
void on(const String &uri, THandlerFunction handler);
|
void on(const Uri &uri, THandlerFunction handler);
|
||||||
void on(const String &uri, HTTPMethod method, THandlerFunction fn);
|
void on(const Uri &uri, HTTPMethod method, THandlerFunction fn);
|
||||||
void on(const String &uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn);
|
void on(const Uri &uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn);
|
||||||
void addHandler(RequestHandler* handler);
|
void addHandler(RequestHandler* handler);
|
||||||
void serveStatic(const char* uri, fs::FS& fs, const char* path, const char* cache_header = NULL );
|
void serveStatic(const char* uri, fs::FS& fs, const char* path, const char* cache_header = NULL );
|
||||||
void onNotFound(THandlerFunction fn); //called when handler is not assigned
|
void onNotFound(THandlerFunction fn); //called when handler is not assigned
|
||||||
|
@ -4,66 +4,30 @@
|
|||||||
#include "RequestHandler.h"
|
#include "RequestHandler.h"
|
||||||
#include "mimetable.h"
|
#include "mimetable.h"
|
||||||
#include "WString.h"
|
#include "WString.h"
|
||||||
|
#include "Uri.h"
|
||||||
|
|
||||||
using namespace mime;
|
using namespace mime;
|
||||||
|
|
||||||
class FunctionRequestHandler : public RequestHandler {
|
class FunctionRequestHandler : public RequestHandler {
|
||||||
public:
|
public:
|
||||||
FunctionRequestHandler(WebServer::THandlerFunction fn, WebServer::THandlerFunction ufn, const String &uri, HTTPMethod method)
|
FunctionRequestHandler(WebServer::THandlerFunction fn, WebServer::THandlerFunction ufn, const Uri &uri, HTTPMethod method)
|
||||||
: _fn(fn)
|
: _fn(fn)
|
||||||
, _ufn(ufn)
|
, _ufn(ufn)
|
||||||
, _uri(uri)
|
, _uri(uri.clone())
|
||||||
, _method(method)
|
, _method(method)
|
||||||
{
|
{
|
||||||
int numParams = 0, start = 0;
|
_uri->initPathArgs(pathArgs);
|
||||||
do {
|
|
||||||
start = _uri.indexOf("{}", start);
|
|
||||||
if (start > 0) {
|
|
||||||
numParams++;
|
|
||||||
start += 2;
|
|
||||||
}
|
}
|
||||||
} while (start > 0);
|
|
||||||
pathArgs.resize(numParams);
|
~FunctionRequestHandler() {
|
||||||
|
delete _uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canHandle(HTTPMethod requestMethod, String requestUri) override {
|
bool canHandle(HTTPMethod requestMethod, String requestUri) override {
|
||||||
if (_method != HTTP_ANY && _method != requestMethod)
|
if (_method != HTTP_ANY && _method != requestMethod)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_uri == requestUri)
|
return _uri->canHandle(requestUri, pathArgs);
|
||||||
return true;
|
|
||||||
|
|
||||||
size_t uriLength = _uri.length();
|
|
||||||
unsigned int pathArgIndex = 0;
|
|
||||||
unsigned int requestUriIndex = 0;
|
|
||||||
for (unsigned int i = 0; i < uriLength; i++, requestUriIndex++) {
|
|
||||||
char uriChar = _uri[i];
|
|
||||||
char requestUriChar = requestUri[requestUriIndex];
|
|
||||||
|
|
||||||
if (uriChar == requestUriChar)
|
|
||||||
continue;
|
|
||||||
if (uriChar != '{')
|
|
||||||
return false;
|
|
||||||
|
|
||||||
i += 2; // index of char after '}'
|
|
||||||
if (i >= uriLength) {
|
|
||||||
// there is no char after '}'
|
|
||||||
pathArgs[pathArgIndex] = requestUri.substring(requestUriIndex);
|
|
||||||
return pathArgs[pathArgIndex].indexOf("/") == -1; // path argument may not contain a '/'
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char charEnd = _uri[i];
|
|
||||||
int uriIndex = requestUri.indexOf(charEnd, requestUriIndex);
|
|
||||||
if (uriIndex < 0)
|
|
||||||
return false;
|
|
||||||
pathArgs[pathArgIndex] = requestUri.substring(requestUriIndex, uriIndex);
|
|
||||||
requestUriIndex = (unsigned int) uriIndex;
|
|
||||||
}
|
|
||||||
pathArgIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return requestUriIndex >= requestUri.length();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canUpload(String requestUri) override {
|
bool canUpload(String requestUri) override {
|
||||||
@ -92,7 +56,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
WebServer::THandlerFunction _fn;
|
WebServer::THandlerFunction _fn;
|
||||||
WebServer::THandlerFunction _ufn;
|
WebServer::THandlerFunction _ufn;
|
||||||
String _uri;
|
Uri *_uri;
|
||||||
HTTPMethod _method;
|
HTTPMethod _method;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
66
libraries/WebServer/src/uri/UriBraces.h
Normal file
66
libraries/WebServer/src/uri/UriBraces.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#ifndef URI_BRACES_H
|
||||||
|
#define URI_BRACES_H
|
||||||
|
|
||||||
|
#include "Uri.h"
|
||||||
|
|
||||||
|
class UriBraces : public Uri {
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit UriBraces(const char *uri) : Uri(uri) {};
|
||||||
|
explicit UriBraces(const String &uri) : Uri(uri) {};
|
||||||
|
|
||||||
|
Uri* clone() const override final {
|
||||||
|
return new UriBraces(_uri);
|
||||||
|
};
|
||||||
|
|
||||||
|
void initPathArgs(std::vector<String> &pathArgs) override final {
|
||||||
|
int numParams = 0, start = 0;
|
||||||
|
do {
|
||||||
|
start = _uri.indexOf("{}", start);
|
||||||
|
if (start > 0) {
|
||||||
|
numParams++;
|
||||||
|
start += 2;
|
||||||
|
}
|
||||||
|
} while (start > 0);
|
||||||
|
pathArgs.resize(numParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool canHandle(const String &requestUri, std::vector<String> &pathArgs) override final {
|
||||||
|
if (Uri::canHandle(requestUri, pathArgs))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
size_t uriLength = _uri.length();
|
||||||
|
unsigned int pathArgIndex = 0;
|
||||||
|
unsigned int requestUriIndex = 0;
|
||||||
|
for (unsigned int i = 0; i < uriLength; i++, requestUriIndex++) {
|
||||||
|
char uriChar = _uri[i];
|
||||||
|
char requestUriChar = requestUri[requestUriIndex];
|
||||||
|
|
||||||
|
if (uriChar == requestUriChar)
|
||||||
|
continue;
|
||||||
|
if (uriChar != '{')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
i += 2; // index of char after '}'
|
||||||
|
if (i >= uriLength) {
|
||||||
|
// there is no char after '}'
|
||||||
|
pathArgs[pathArgIndex] = requestUri.substring(requestUriIndex);
|
||||||
|
return pathArgs[pathArgIndex].indexOf("/") == -1; // path argument may not contain a '/'
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char charEnd = _uri[i];
|
||||||
|
int uriIndex = requestUri.indexOf(charEnd, requestUriIndex);
|
||||||
|
if (uriIndex < 0)
|
||||||
|
return false;
|
||||||
|
pathArgs[pathArgIndex] = requestUri.substring(requestUriIndex, uriIndex);
|
||||||
|
requestUriIndex = (unsigned int) uriIndex;
|
||||||
|
}
|
||||||
|
pathArgIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestUriIndex >= requestUri.length();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
22
libraries/WebServer/src/uri/UriGlob.h
Normal file
22
libraries/WebServer/src/uri/UriGlob.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef URI_GLOB_H
|
||||||
|
#define URI_GLOB_H
|
||||||
|
|
||||||
|
#include "Uri.h"
|
||||||
|
#include <fnmatch.h>
|
||||||
|
|
||||||
|
class UriGlob : public Uri {
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit UriGlob(const char *uri) : Uri(uri) {};
|
||||||
|
explicit UriGlob(const String &uri) : Uri(uri) {};
|
||||||
|
|
||||||
|
Uri* clone() const override final {
|
||||||
|
return new UriGlob(_uri);
|
||||||
|
};
|
||||||
|
|
||||||
|
bool canHandle(const String &requestUri, __attribute__((unused)) std::vector<String> &pathArgs) override final {
|
||||||
|
return fnmatch(_uri.c_str(), requestUri.c_str(), 0) == 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
44
libraries/WebServer/src/uri/UriRegex.h
Normal file
44
libraries/WebServer/src/uri/UriRegex.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#ifndef URI_REGEX_H
|
||||||
|
#define URI_REGEX_H
|
||||||
|
|
||||||
|
#include "Uri.h"
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
class UriRegex : public Uri {
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit UriRegex(const char *uri) : Uri(uri) {};
|
||||||
|
explicit UriRegex(const String &uri) : Uri(uri) {};
|
||||||
|
|
||||||
|
Uri* clone() const override final {
|
||||||
|
return new UriRegex(_uri);
|
||||||
|
};
|
||||||
|
|
||||||
|
void initPathArgs(std::vector<String> &pathArgs) override final {
|
||||||
|
std::regex rgx((_uri + "|").c_str());
|
||||||
|
std::smatch matches;
|
||||||
|
std::string s{""};
|
||||||
|
std::regex_search(s, matches, rgx);
|
||||||
|
pathArgs.resize(matches.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool canHandle(const String &requestUri, std::vector<String> &pathArgs) override final {
|
||||||
|
if (Uri::canHandle(requestUri, pathArgs))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
unsigned int pathArgIndex = 0;
|
||||||
|
std::regex rgx(_uri.c_str());
|
||||||
|
std::smatch matches;
|
||||||
|
std::string s(requestUri.c_str());
|
||||||
|
if (std::regex_search(s, matches, rgx)) {
|
||||||
|
for (size_t i = 1; i < matches.size(); ++i) { // skip first
|
||||||
|
pathArgs[pathArgIndex] = String(matches[i].str().c_str());
|
||||||
|
pathArgIndex++;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -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);
|
|
||||||
}
|
|
@ -31,7 +31,6 @@ WPS
|
|||||||
static esp_wps_config_t config;
|
static esp_wps_config_t config;
|
||||||
|
|
||||||
void wpsInitConfig(){
|
void wpsInitConfig(){
|
||||||
config.crypto_funcs = &g_wifi_default_wps_crypto_funcs;
|
|
||||||
config.wps_type = ESP_WPS_MODE;
|
config.wps_type = ESP_WPS_MODE;
|
||||||
strcpy(config.factory_info.manufacturer, ESP_MANUFACTURER);
|
strcpy(config.factory_info.manufacturer, ESP_MANUFACTURER);
|
||||||
strcpy(config.factory_info.model_number, ESP_MODEL_NUMBER);
|
strcpy(config.factory_info.model_number, ESP_MODEL_NUMBER);
|
||||||
|
@ -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_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_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_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();
|
||||||
esp_wifi_sta_wpa2_ent_enable(&config); //set config settings to enable function
|
|
||||||
WiFi.begin(ssid); //connect to wifi
|
WiFi.begin(ssid); //connect to wifi
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(500);
|
delay(500);
|
||||||
|
@ -19,14 +19,86 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ETH.h"
|
#include "ETH.h"
|
||||||
|
#include "esp_system.h"
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR
|
||||||
|
#include "esp_event.h"
|
||||||
|
#include "esp_eth.h"
|
||||||
|
#include "esp_eth_phy.h"
|
||||||
|
#include "esp_eth_mac.h"
|
||||||
|
#include "esp_eth_com.h"
|
||||||
|
#else
|
||||||
#include "eth_phy/phy.h"
|
#include "eth_phy/phy.h"
|
||||||
#include "eth_phy/phy_tlk110.h"
|
#include "eth_phy/phy_tlk110.h"
|
||||||
#include "eth_phy/phy_lan8720.h"
|
#include "eth_phy/phy_lan8720.h"
|
||||||
|
#endif
|
||||||
#include "lwip/err.h"
|
#include "lwip/err.h"
|
||||||
#include "lwip/dns.h"
|
#include "lwip/dns.h"
|
||||||
|
|
||||||
extern void tcpipInit();
|
extern void tcpipInit();
|
||||||
|
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Callback function invoked when lowlevel initialization is finished
|
||||||
|
*
|
||||||
|
* @param[in] eth_handle: handle of Ethernet driver
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - ESP_OK: process extra lowlevel initialization successfully
|
||||||
|
* - ESP_FAIL: error occurred when processing extra lowlevel initialization
|
||||||
|
*/
|
||||||
|
//static esp_err_t on_lowlevel_init_done(esp_eth_handle_t eth_handle){
|
||||||
|
//#define PIN_PHY_POWER 2
|
||||||
|
// pinMode(PIN_PHY_POWER, OUTPUT);
|
||||||
|
// digitalWrite(PIN_PHY_POWER, HIGH);
|
||||||
|
// delay(100);
|
||||||
|
// return ESP_OK;
|
||||||
|
//}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Callback function invoked when lowlevel deinitialization is finished
|
||||||
|
*
|
||||||
|
* @param[in] eth_handle: handle of Ethernet driver
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - ESP_OK: process extra lowlevel deinitialization successfully
|
||||||
|
* - ESP_FAIL: error occurred when processing extra lowlevel deinitialization
|
||||||
|
*/
|
||||||
|
//static esp_err_t on_lowlevel_deinit_done(esp_eth_handle_t eth_handle){
|
||||||
|
// return ESP_OK;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Event handler for Ethernet
|
||||||
|
void ETHClass::eth_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
|
||||||
|
{
|
||||||
|
system_event_t event;
|
||||||
|
switch (event_id) {
|
||||||
|
case ETHERNET_EVENT_CONNECTED:
|
||||||
|
event.event_id = SYSTEM_EVENT_ETH_CONNECTED;
|
||||||
|
((ETHClass*)(arg))->eth_link = ETH_LINK_UP;
|
||||||
|
break;
|
||||||
|
case ETHERNET_EVENT_DISCONNECTED:
|
||||||
|
event.event_id = SYSTEM_EVENT_ETH_DISCONNECTED;
|
||||||
|
((ETHClass*)(arg))->eth_link = ETH_LINK_DOWN;
|
||||||
|
break;
|
||||||
|
case ETHERNET_EVENT_START:
|
||||||
|
event.event_id = SYSTEM_EVENT_ETH_START;
|
||||||
|
((ETHClass*)(arg))->started = true;
|
||||||
|
break;
|
||||||
|
case ETHERNET_EVENT_STOP:
|
||||||
|
event.event_id = SYSTEM_EVENT_ETH_STOP;
|
||||||
|
((ETHClass*)(arg))->started = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
WiFi._eventCallback(arg, &event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
static int _eth_phy_mdc_pin = -1;
|
static int _eth_phy_mdc_pin = -1;
|
||||||
static int _eth_phy_mdio_pin = -1;
|
static int _eth_phy_mdio_pin = -1;
|
||||||
static int _eth_phy_power_pin = -1;
|
static int _eth_phy_power_pin = -1;
|
||||||
@ -48,14 +120,100 @@ static void _eth_phy_power_enable(bool enable)
|
|||||||
digitalWrite(_eth_phy_power_pin, enable);
|
digitalWrite(_eth_phy_power_pin, enable);
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ETHClass::ETHClass():initialized(false),started(false),staticIP(false)
|
ETHClass::ETHClass()
|
||||||
|
:initialized(false)
|
||||||
|
,staticIP(false)
|
||||||
|
#if ESP_IDF_VERSION_MAJOR > 3
|
||||||
|
,eth_handle(NULL)
|
||||||
|
#endif
|
||||||
|
,started(false)
|
||||||
|
#if ESP_IDF_VERSION_MAJOR > 3
|
||||||
|
,eth_link(ETH_LINK_DOWN)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ETHClass::~ETHClass()
|
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){
|
||||||
|
|
||||||
|
tcpipInit();
|
||||||
|
|
||||||
|
tcpip_adapter_set_default_eth_handlers();
|
||||||
|
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
|
||||||
|
eth_mac = esp_eth_mac_new_esp32(&mac_config);
|
||||||
|
#if CONFIG_ETH_SPI_ETHERNET_DM9051
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(eth_mac == NULL){
|
||||||
|
log_e("esp_eth_mac_new_esp32 failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
||||||
|
phy_config.phy_addr = phy_addr;
|
||||||
|
phy_config.reset_gpio_num = power;
|
||||||
|
esp_eth_phy_t *eth_phy = NULL;
|
||||||
|
switch(type){
|
||||||
|
case ETH_PHY_LAN8720:
|
||||||
|
eth_phy = esp_eth_phy_new_lan8720(&phy_config);
|
||||||
|
break;
|
||||||
|
case ETH_PHY_TLK110:
|
||||||
|
eth_phy = esp_eth_phy_new_ip101(&phy_config);
|
||||||
|
break;
|
||||||
|
case ETH_PHY_RTL8201:
|
||||||
|
eth_phy = esp_eth_phy_new_rtl8201(&phy_config);
|
||||||
|
break;
|
||||||
|
case ETH_PHY_DP83848:
|
||||||
|
eth_phy = esp_eth_phy_new_dp83848(&phy_config);
|
||||||
|
break;
|
||||||
|
#if CONFIG_ETH_SPI_ETHERNET_DM9051
|
||||||
|
case ETH_PHY_DM9051:
|
||||||
|
eth_phy = esp_eth_phy_new_dm9051(&phy_config);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(eth_phy == NULL){
|
||||||
|
log_e("esp_eth_phy_new failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
eth_handle = NULL;
|
||||||
|
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(eth_mac, eth_phy);
|
||||||
|
//eth_config.on_lowlevel_init_done = on_lowlevel_init_done;
|
||||||
|
//eth_config.on_lowlevel_deinit_done = on_lowlevel_deinit_done;
|
||||||
|
if(esp_eth_driver_install(ð_config, ð_handle) != ESP_OK || eth_handle == NULL){
|
||||||
|
log_e("esp_eth_driver_install failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(esp_eth_start(eth_handle) != ESP_OK){
|
||||||
|
log_e("esp_eth_start failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#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)
|
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;
|
esp_err_t err;
|
||||||
@ -108,6 +266,7 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2)
|
bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2)
|
||||||
{
|
{
|
||||||
@ -193,8 +352,8 @@ IPAddress ETHClass::gatewayIP()
|
|||||||
|
|
||||||
IPAddress ETHClass::dnsIP(uint8_t dns_no)
|
IPAddress ETHClass::dnsIP(uint8_t dns_no)
|
||||||
{
|
{
|
||||||
ip_addr_t dns_ip = dns_getserver(dns_no);
|
const ip_addr_t * dns_ip = dns_getserver(dns_no);
|
||||||
return IPAddress(dns_ip.u_addr.ip4.addr);
|
return IPAddress(dns_ip->u_addr.ip4.addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress ETHClass::broadcastIP()
|
IPAddress ETHClass::broadcastIP()
|
||||||
@ -240,17 +399,31 @@ bool ETHClass::setHostname(const char * hostname)
|
|||||||
|
|
||||||
bool ETHClass::fullDuplex()
|
bool ETHClass::fullDuplex()
|
||||||
{
|
{
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR
|
||||||
|
return true;//todo: do not see an API for this
|
||||||
|
#else
|
||||||
return eth_config.phy_get_duplex_mode();
|
return eth_config.phy_get_duplex_mode();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ETHClass::linkUp()
|
bool ETHClass::linkUp()
|
||||||
{
|
{
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR
|
||||||
|
return eth_link == ETH_LINK_UP;
|
||||||
|
#else
|
||||||
return eth_config.phy_check_link();
|
return eth_config.phy_check_link();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ETHClass::linkSpeed()
|
uint8_t ETHClass::linkSpeed()
|
||||||
{
|
{
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR
|
||||||
|
eth_speed_t link_speed;
|
||||||
|
esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &link_speed);
|
||||||
|
return (link_speed == ETH_SPEED_10M)?10:100;
|
||||||
|
#else
|
||||||
return eth_config.phy_get_speed_mode()?100:10;
|
return eth_config.phy_get_speed_mode()?100:10;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ETHClass::enableIpV6()
|
bool ETHClass::enableIpV6()
|
||||||
@ -267,20 +440,24 @@ IPv6Address ETHClass::localIPv6()
|
|||||||
return IPv6Address(addr.addr);
|
return IPv6Address(addr.addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t * macAddress(uint8_t* mac)
|
uint8_t * ETHClass::macAddress(uint8_t* mac)
|
||||||
{
|
{
|
||||||
if(!mac){
|
if(!mac){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR
|
||||||
|
esp_eth_ioctl(eth_handle, ETH_CMD_G_MAC_ADDR, mac);
|
||||||
|
#else
|
||||||
esp_eth_get_mac(mac);
|
esp_eth_get_mac(mac);
|
||||||
|
#endif
|
||||||
return mac;
|
return mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ETHClass::macAddress(void)
|
String ETHClass::macAddress(void)
|
||||||
{
|
{
|
||||||
uint8_t mac[6];
|
uint8_t mac[6] = {0,0,0,0,0,0};
|
||||||
char macStr[18] = { 0 };
|
char macStr[18] = { 0 };
|
||||||
esp_eth_get_mac(mac);
|
macAddress(mac);
|
||||||
sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||||
return String(macStr);
|
return String(macStr);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#define _ETH_H_
|
#define _ETH_H_
|
||||||
|
|
||||||
#include "WiFi.h"
|
#include "WiFi.h"
|
||||||
|
#include "esp_system.h"
|
||||||
#include "esp_eth.h"
|
#include "esp_eth.h"
|
||||||
|
|
||||||
#ifndef ETH_PHY_ADDR
|
#ifndef ETH_PHY_ADDR
|
||||||
@ -44,23 +45,38 @@
|
|||||||
#define ETH_PHY_MDIO 18
|
#define ETH_PHY_MDIO 18
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ESP_IDF_VERSION_MAJOR < 4
|
||||||
#ifndef ETH_CLK_MODE
|
#ifndef ETH_CLK_MODE
|
||||||
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_IN
|
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_IN
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum { ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_MAX } eth_phy_type_t;
|
typedef enum { ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_RTL8201, ETH_PHY_DP83848, ETH_PHY_DM9051, ETH_PHY_MAX } eth_phy_type_t;
|
||||||
|
|
||||||
class ETHClass {
|
class ETHClass {
|
||||||
private:
|
private:
|
||||||
bool initialized;
|
bool initialized;
|
||||||
bool started;
|
|
||||||
bool staticIP;
|
bool staticIP;
|
||||||
|
#if ESP_IDF_VERSION_MAJOR > 3
|
||||||
|
esp_eth_handle_t eth_handle;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool started;
|
||||||
|
eth_link_t eth_link;
|
||||||
|
static void eth_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
|
||||||
|
#else
|
||||||
|
bool started;
|
||||||
eth_config_t eth_config;
|
eth_config_t eth_config;
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
ETHClass();
|
ETHClass();
|
||||||
~ETHClass();
|
~ETHClass();
|
||||||
|
|
||||||
|
#if ESP_IDF_VERSION_MAJOR > 3
|
||||||
|
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);
|
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);
|
bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
|
||||||
|
|
||||||
|
@ -46,7 +46,11 @@ private:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int count;
|
int count;
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR
|
||||||
|
int res = lwip_ioctl(_fd, FIONREAD, &count);
|
||||||
|
#else
|
||||||
int res = lwip_ioctl_r(_fd, FIONREAD, &count);
|
int res = lwip_ioctl_r(_fd, FIONREAD, &count);
|
||||||
|
#endif
|
||||||
if(res < 0) {
|
if(res < 0) {
|
||||||
_failed = true;
|
_failed = true;
|
||||||
return 0;
|
return 0;
|
||||||
@ -227,7 +231,11 @@ int WiFiClient::connect(IPAddress ip, uint16_t port, int32_t timeout)
|
|||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = timeout * 1000;
|
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));
|
int res = lwip_connect_r(sockfd, (struct sockaddr*)&serveraddr, sizeof(serveraddr));
|
||||||
|
#endif
|
||||||
if (res < 0 && errno != EINPROGRESS) {
|
if (res < 0 && errno != EINPROGRESS) {
|
||||||
log_e("connect on fd %d, errno: %d, \"%s\"", sockfd, errno, strerror(errno));
|
log_e("connect on fd %d, errno: %d, \"%s\"", sockfd, errno, strerror(errno));
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
@ -495,6 +503,8 @@ uint8_t WiFiClient::connected()
|
|||||||
int res = recv(fd(), &dummy, 0, MSG_DONTWAIT);
|
int res = recv(fd(), &dummy, 0, MSG_DONTWAIT);
|
||||||
// avoid unused var warning by gcc
|
// avoid unused var warning by gcc
|
||||||
(void)res;
|
(void)res;
|
||||||
|
// recv only sets errno if res is <= 0
|
||||||
|
if (res <= 0){
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
case EWOULDBLOCK:
|
case EWOULDBLOCK:
|
||||||
case ENOENT: //caused by vfs
|
case ENOENT: //caused by vfs
|
||||||
@ -513,6 +523,9 @@ uint8_t WiFiClient::connected()
|
|||||||
_connected = true;
|
_connected = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_connected = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return _connected;
|
return _connected;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,6 @@ extern "C" {
|
|||||||
|
|
||||||
#include "esp32-hal-log.h"
|
#include "esp32-hal-log.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
static xQueueHandle _network_event_queue;
|
static xQueueHandle _network_event_queue;
|
||||||
@ -55,10 +54,10 @@ static TaskHandle_t _network_event_task_handle = NULL;
|
|||||||
static EventGroupHandle_t _network_event_group = NULL;
|
static EventGroupHandle_t _network_event_group = NULL;
|
||||||
|
|
||||||
static void _network_event_task(void * arg){
|
static void _network_event_task(void * arg){
|
||||||
system_event_t *event = NULL;
|
system_event_t event;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if(xQueueReceive(_network_event_queue, &event, portMAX_DELAY) == pdTRUE){
|
if(xQueueReceive(_network_event_queue, &event, portMAX_DELAY) == pdTRUE){
|
||||||
WiFiGenericClass::_eventCallback(arg, event);
|
WiFiGenericClass::_eventCallback(arg, &event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
@ -66,7 +65,7 @@ static void _network_event_task(void * arg){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static esp_err_t _network_event_cb(void *arg, system_event_t *event){
|
static esp_err_t _network_event_cb(void *arg, system_event_t *event){
|
||||||
if (xQueueSend(_network_event_queue, &event, portMAX_DELAY) != pdPASS) {
|
if (xQueueSend(_network_event_queue, event, portMAX_DELAY) != pdPASS) {
|
||||||
log_w("Network Event Queue Send Failed!");
|
log_w("Network Event Queue Send Failed!");
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
@ -83,7 +82,7 @@ static bool _start_network_event_task(){
|
|||||||
xEventGroupSetBits(_network_event_group, WIFI_DNS_IDLE_BIT);
|
xEventGroupSetBits(_network_event_group, WIFI_DNS_IDLE_BIT);
|
||||||
}
|
}
|
||||||
if(!_network_event_queue){
|
if(!_network_event_queue){
|
||||||
_network_event_queue = xQueueCreate(32, sizeof(system_event_t *));
|
_network_event_queue = xQueueCreate(32, sizeof(system_event_t));
|
||||||
if(!_network_event_queue){
|
if(!_network_event_queue){
|
||||||
log_e("Network Event Queue Create Failed!");
|
log_e("Network Event Queue Create Failed!");
|
||||||
return false;
|
return false;
|
||||||
@ -103,6 +102,13 @@ void tcpipInit(){
|
|||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
if(!initialized && _start_network_event_task()){
|
if(!initialized && _start_network_event_task()){
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR
|
||||||
|
uint8_t mac[8];
|
||||||
|
if(esp_efuse_mac_get_default(mac) == ESP_OK){
|
||||||
|
esp_base_mac_addr_set(mac);
|
||||||
|
}
|
||||||
|
esp_event_loop_create_default();
|
||||||
|
#endif
|
||||||
tcpip_adapter_init();
|
tcpip_adapter_init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,24 +139,19 @@ static bool wifiLowLevelDeinit(){
|
|||||||
|
|
||||||
static bool _esp_wifi_started = false;
|
static bool _esp_wifi_started = false;
|
||||||
|
|
||||||
static bool espWiFiStart(bool persistent){
|
static bool espWiFiStart(){
|
||||||
if(_esp_wifi_started){
|
if(_esp_wifi_started){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!wifiLowLevelInit(persistent)){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
esp_err_t err = esp_wifi_start();
|
esp_err_t err = esp_wifi_start();
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
log_e("esp_wifi_start %d", err);
|
log_e("esp_wifi_start %d", err);
|
||||||
wifiLowLevelDeinit();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_esp_wifi_started = true;
|
_esp_wifi_started = true;
|
||||||
system_event_t event;
|
system_event_t event;
|
||||||
event.event_id = SYSTEM_EVENT_WIFI_READY;
|
event.event_id = SYSTEM_EVENT_WIFI_READY;
|
||||||
WiFiGenericClass::_eventCallback(nullptr, &event);
|
WiFiGenericClass::_eventCallback(nullptr, &event);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,6 +191,7 @@ wifi_event_id_t WiFiEventCbList::current_id = 1;
|
|||||||
static std::vector<WiFiEventCbList_t> cbEventList;
|
static std::vector<WiFiEventCbList_t> cbEventList;
|
||||||
|
|
||||||
bool WiFiGenericClass::_persistent = true;
|
bool WiFiGenericClass::_persistent = true;
|
||||||
|
bool WiFiGenericClass::_long_range = false;
|
||||||
wifi_mode_t WiFiGenericClass::_forceSleepLastMode = WIFI_MODE_NULL;
|
wifi_mode_t WiFiGenericClass::_forceSleepLastMode = WIFI_MODE_NULL;
|
||||||
|
|
||||||
WiFiGenericClass::WiFiGenericClass()
|
WiFiGenericClass::WiFiGenericClass()
|
||||||
@ -325,10 +327,10 @@ void WiFiGenericClass::removeEvent(wifi_event_id_t id)
|
|||||||
* @param arg
|
* @param arg
|
||||||
*/
|
*/
|
||||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
||||||
const char * system_event_names[] = { "WIFI_READY", "SCAN_DONE", "STA_START", "STA_STOP", "STA_CONNECTED", "STA_DISCONNECTED", "STA_AUTHMODE_CHANGE", "STA_GOT_IP", "STA_LOST_IP", "STA_WPS_ER_SUCCESS", "STA_WPS_ER_FAILED", "STA_WPS_ER_TIMEOUT", "STA_WPS_ER_PIN", "AP_START", "AP_STOP", "AP_STACONNECTED", "AP_STADISCONNECTED", "AP_STAIPASSIGNED", "AP_PROBEREQRECVED", "GOT_IP6", "ETH_START", "ETH_STOP", "ETH_CONNECTED", "ETH_DISCONNECTED", "ETH_GOT_IP", "MAX"};
|
const char * system_event_names[] = { "WIFI_READY", "SCAN_DONE", "STA_START", "STA_STOP", "STA_CONNECTED", "STA_DISCONNECTED", "STA_AUTHMODE_CHANGE", "STA_GOT_IP", "STA_LOST_IP", "STA_WPS_ER_SUCCESS", "STA_WPS_ER_FAILED", "STA_WPS_ER_TIMEOUT", "STA_WPS_ER_PIN", "STA_WPS_ER_PBC_OVERLAP", "AP_START", "AP_STOP", "AP_STACONNECTED", "AP_STADISCONNECTED", "AP_STAIPASSIGNED", "AP_PROBEREQRECVED", "GOT_IP6", "ETH_START", "ETH_STOP", "ETH_CONNECTED", "ETH_DISCONNECTED", "ETH_GOT_IP", "MAX"};
|
||||||
#endif
|
#endif
|
||||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_WARN
|
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_WARN
|
||||||
const char * system_event_reasons[] = { "UNSPECIFIED", "AUTH_EXPIRE", "AUTH_LEAVE", "ASSOC_EXPIRE", "ASSOC_TOOMANY", "NOT_AUTHED", "NOT_ASSOCED", "ASSOC_LEAVE", "ASSOC_NOT_AUTHED", "DISASSOC_PWRCAP_BAD", "DISASSOC_SUPCHAN_BAD", "UNSPECIFIED", "IE_INVALID", "MIC_FAILURE", "4WAY_HANDSHAKE_TIMEOUT", "GROUP_KEY_UPDATE_TIMEOUT", "IE_IN_4WAY_DIFFERS", "GROUP_CIPHER_INVALID", "PAIRWISE_CIPHER_INVALID", "AKMP_INVALID", "UNSUPP_RSN_IE_VERSION", "INVALID_RSN_IE_CAP", "802_1X_AUTH_FAILED", "CIPHER_SUITE_REJECTED", "BEACON_TIMEOUT", "NO_AP_FOUND", "AUTH_FAIL", "ASSOC_FAIL", "HANDSHAKE_TIMEOUT" };
|
const char * system_event_reasons[] = { "UNSPECIFIED", "AUTH_EXPIRE", "AUTH_LEAVE", "ASSOC_EXPIRE", "ASSOC_TOOMANY", "NOT_AUTHED", "NOT_ASSOCED", "ASSOC_LEAVE", "ASSOC_NOT_AUTHED", "DISASSOC_PWRCAP_BAD", "DISASSOC_SUPCHAN_BAD", "UNSPECIFIED", "IE_INVALID", "MIC_FAILURE", "4WAY_HANDSHAKE_TIMEOUT", "GROUP_KEY_UPDATE_TIMEOUT", "IE_IN_4WAY_DIFFERS", "GROUP_CIPHER_INVALID", "PAIRWISE_CIPHER_INVALID", "AKMP_INVALID", "UNSUPP_RSN_IE_VERSION", "INVALID_RSN_IE_CAP", "802_1X_AUTH_FAILED", "CIPHER_SUITE_REJECTED", "BEACON_TIMEOUT", "NO_AP_FOUND", "AUTH_FAIL", "ASSOC_FAIL", "HANDSHAKE_TIMEOUT", "CONNECTION_FAIL" };
|
||||||
#define reason2str(r) ((r>176)?system_event_reasons[r-176]:system_event_reasons[r-1])
|
#define reason2str(r) ((r>176)?system_event_reasons[r-176]:system_event_reasons[r-1])
|
||||||
#endif
|
#endif
|
||||||
esp_err_t WiFiGenericClass::_eventCallback(void *arg, system_event_t *event)
|
esp_err_t WiFiGenericClass::_eventCallback(void *arg, system_event_t *event)
|
||||||
@ -471,6 +473,16 @@ void WiFiGenericClass::persistent(bool persistent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enable WiFi long range mode
|
||||||
|
* @param enable
|
||||||
|
*/
|
||||||
|
void WiFiGenericClass::enableLongRange(bool enable)
|
||||||
|
{
|
||||||
|
_long_range = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set new mode
|
* set new mode
|
||||||
* @param m WiFiMode_t
|
* @param m WiFiMode_t
|
||||||
@ -482,7 +494,7 @@ bool WiFiGenericClass::mode(wifi_mode_t m)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!cm && m){
|
if(!cm && m){
|
||||||
if(!espWiFiStart(_persistent)){
|
if(!wifiLowLevelInit(_persistent)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if(cm && !m){
|
} else if(cm && !m){
|
||||||
@ -495,6 +507,25 @@ bool WiFiGenericClass::mode(wifi_mode_t m)
|
|||||||
log_e("Could not set mode! %d", err);
|
log_e("Could not set mode! %d", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(_long_range){
|
||||||
|
if(m & WIFI_MODE_STA){
|
||||||
|
err = esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_LR);
|
||||||
|
if(err != ESP_OK){
|
||||||
|
log_e("Could not enable long range on STA! %d", err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(m & WIFI_MODE_AP){
|
||||||
|
err = esp_wifi_set_protocol(WIFI_IF_AP, WIFI_PROTOCOL_LR);
|
||||||
|
if(err != ESP_OK){
|
||||||
|
log_e("Could not enable long range on AP! %d", err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!espWiFiStart()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,7 +535,7 @@ bool WiFiGenericClass::mode(wifi_mode_t m)
|
|||||||
*/
|
*/
|
||||||
wifi_mode_t WiFiGenericClass::getMode()
|
wifi_mode_t WiFiGenericClass::getMode()
|
||||||
{
|
{
|
||||||
if(!_esp_wifi_started){
|
if(!lowLevelInitDone){
|
||||||
return WIFI_MODE_NULL;
|
return WIFI_MODE_NULL;
|
||||||
}
|
}
|
||||||
wifi_mode_t mode;
|
wifi_mode_t mode;
|
||||||
|
@ -83,6 +83,7 @@ class WiFiGenericClass
|
|||||||
int32_t channel(void);
|
int32_t channel(void);
|
||||||
|
|
||||||
void persistent(bool persistent);
|
void persistent(bool persistent);
|
||||||
|
void enableLongRange(bool enable);
|
||||||
|
|
||||||
static bool mode(wifi_mode_t);
|
static bool mode(wifi_mode_t);
|
||||||
static wifi_mode_t getMode();
|
static wifi_mode_t getMode();
|
||||||
@ -100,6 +101,7 @@ class WiFiGenericClass
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static bool _persistent;
|
static bool _persistent;
|
||||||
|
static bool _long_range;
|
||||||
static wifi_mode_t _forceSleepLastMode;
|
static wifi_mode_t _forceSleepLastMode;
|
||||||
|
|
||||||
static int setStatusBits(int bits);
|
static int setStatusBits(int bits);
|
||||||
|
@ -488,8 +488,8 @@ IPAddress WiFiSTAClass::dnsIP(uint8_t dns_no)
|
|||||||
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
|
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
|
||||||
return IPAddress();
|
return IPAddress();
|
||||||
}
|
}
|
||||||
ip_addr_t dns_ip = dns_getserver(dns_no);
|
const ip_addr_t * dns_ip = dns_getserver(dns_no);
|
||||||
return IPAddress(dns_ip.u_addr.ip4.addr);
|
return IPAddress(dns_ip->u_addr.ip4.addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -687,7 +687,13 @@ bool WiFiSTAClass::beginSmartConfig() {
|
|||||||
esp_wifi_disconnect();
|
esp_wifi_disconnect();
|
||||||
|
|
||||||
esp_err_t err;
|
esp_err_t err;
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR
|
||||||
|
esp_event_handler_register(SC_EVENT, ESP_EVENT_ANY_ID, _smartConfigCallback, this);
|
||||||
|
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);
|
err = esp_smartconfig_start(reinterpret_cast<sc_callback_t>(&WiFiSTAClass::_smartConfigCallback), 1);
|
||||||
|
#endif
|
||||||
if (err == ESP_OK) {
|
if (err == ESP_OK) {
|
||||||
_smartConfigStarted = true;
|
_smartConfigStarted = true;
|
||||||
_smartConfigDone = false;
|
_smartConfigDone = false;
|
||||||
@ -717,6 +723,45 @@ bool WiFiSTAClass::smartConfigDone() {
|
|||||||
return _smartConfigDone;
|
return _smartConfigDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
||||||
|
const char * sc_type_strings[] = {
|
||||||
|
"ESPTOUCH",
|
||||||
|
"AIRKISS",
|
||||||
|
"ESPTOUCH_AIRKISS"
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR //todo
|
||||||
|
void WiFiSTAClass::_smartConfigCallback(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data){
|
||||||
|
smartconfig_event_t event = (smartconfig_event_t)event_id;
|
||||||
|
switch(event){
|
||||||
|
case SC_EVENT_SCAN_DONE:
|
||||||
|
log_d("smartconfig has finished to scan for APs");
|
||||||
|
break;
|
||||||
|
case SC_EVENT_FOUND_CHANNEL:
|
||||||
|
log_d("smartconfig has found the channel of the target AP");
|
||||||
|
break;
|
||||||
|
case SC_EVENT_GOT_SSID_PSWD:
|
||||||
|
{
|
||||||
|
log_d("smartconfig got the SSID and password");
|
||||||
|
smartconfig_event_got_ssid_pswd_t * data = (smartconfig_event_got_ssid_pswd_t*)event_data;
|
||||||
|
log_d("Type: %s", sc_type_strings[data->type]);
|
||||||
|
log_d("SSID: %s", (const char *)data->ssid);
|
||||||
|
log_d("Password: %s", (const char *)data->password);
|
||||||
|
log_d("Sender IP: " IPSTR, data->cellphone_ip[3], data->cellphone_ip[2], data->cellphone_ip[1], data->cellphone_ip[0]);
|
||||||
|
WiFi.begin((const char *)data->ssid, (const char *)data->password);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SC_EVENT_SEND_ACK_DONE:
|
||||||
|
log_d("smartconfig has sent ACK to the sender");
|
||||||
|
WiFi.stopSmartConfig();
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
||||||
const char * sc_status_strings[] = {
|
const char * sc_status_strings[] = {
|
||||||
"WAIT",
|
"WAIT",
|
||||||
@ -725,12 +770,6 @@ const char * sc_status_strings[] = {
|
|||||||
"LINK",
|
"LINK",
|
||||||
"LINK_OVER"
|
"LINK_OVER"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char * sc_type_strings[] = {
|
|
||||||
"ESPTOUCH",
|
|
||||||
"AIRKISS",
|
|
||||||
"ESPTOUCH_AIRKISS"
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void WiFiSTAClass::_smartConfigCallback(uint32_t st, void* result) {
|
void WiFiSTAClass::_smartConfigCallback(uint32_t st, void* result) {
|
||||||
@ -758,3 +797,4 @@ void WiFiSTAClass::_smartConfigCallback(uint32_t st, void* result) {
|
|||||||
WiFi.stopSmartConfig();
|
WiFi.stopSmartConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
|
|
||||||
#include "WiFiType.h"
|
#include "WiFiType.h"
|
||||||
#include "WiFiGeneric.h"
|
#include "WiFiGeneric.h"
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR
|
||||||
|
#include "esp_event.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class WiFiSTAClass
|
class WiFiSTAClass
|
||||||
@ -98,7 +101,11 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
static bool _smartConfigStarted;
|
static bool _smartConfigStarted;
|
||||||
static bool _smartConfigDone;
|
static bool _smartConfigDone;
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR //todo
|
||||||
|
static void _smartConfigCallback(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
|
||||||
|
#else
|
||||||
static void _smartConfigCallback(uint32_t status, void* result);
|
static void _smartConfigCallback(uint32_t status, void* result);
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ void* WiFiScanClass::_scanResult = 0;
|
|||||||
* @param show_hidden show hidden networks
|
* @param show_hidden show hidden networks
|
||||||
* @return Number of discovered networks
|
* @return Number of discovered networks
|
||||||
*/
|
*/
|
||||||
int16_t WiFiScanClass::scanNetworks(bool async, bool show_hidden, bool passive, uint32_t max_ms_per_chan)
|
int16_t WiFiScanClass::scanNetworks(bool async, bool show_hidden, bool passive, uint32_t max_ms_per_chan, uint8_t channel)
|
||||||
{
|
{
|
||||||
if(WiFiGenericClass::getStatusBits() & WIFI_SCANNING_BIT) {
|
if(WiFiGenericClass::getStatusBits() & WIFI_SCANNING_BIT) {
|
||||||
return WIFI_SCAN_RUNNING;
|
return WIFI_SCAN_RUNNING;
|
||||||
@ -70,7 +70,7 @@ int16_t WiFiScanClass::scanNetworks(bool async, bool show_hidden, bool passive,
|
|||||||
wifi_scan_config_t config;
|
wifi_scan_config_t config;
|
||||||
config.ssid = 0;
|
config.ssid = 0;
|
||||||
config.bssid = 0;
|
config.bssid = 0;
|
||||||
config.channel = 0;
|
config.channel = channel;
|
||||||
config.show_hidden = show_hidden;
|
config.show_hidden = show_hidden;
|
||||||
if(passive){
|
if(passive){
|
||||||
config.scan_type = WIFI_SCAN_TYPE_PASSIVE;
|
config.scan_type = WIFI_SCAN_TYPE_PASSIVE;
|
||||||
|
@ -31,7 +31,7 @@ class WiFiScanClass
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int16_t scanNetworks(bool async = false, bool show_hidden = false, bool passive = false, uint32_t max_ms_per_chan = 300);
|
int16_t scanNetworks(bool async = false, bool show_hidden = false, bool passive = false, uint32_t max_ms_per_chan = 300, uint8_t channel = 0);
|
||||||
|
|
||||||
int16_t scanComplete();
|
int16_t scanComplete();
|
||||||
void scanDelete();
|
void scanDelete();
|
||||||
|
@ -49,7 +49,11 @@ WiFiClient WiFiServer::available(){
|
|||||||
else {
|
else {
|
||||||
struct sockaddr_in _client;
|
struct sockaddr_in _client;
|
||||||
int cs = sizeof(struct sockaddr_in);
|
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);
|
client_sock = lwip_accept_r(sockfd, (struct sockaddr *)&_client, (socklen_t*)&cs);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if(client_sock >= 0){
|
if(client_sock >= 0){
|
||||||
int val = 1;
|
int val = 1;
|
||||||
@ -99,7 +103,11 @@ bool WiFiServer::hasClient() {
|
|||||||
}
|
}
|
||||||
struct sockaddr_in _client;
|
struct sockaddr_in _client;
|
||||||
int cs = sizeof(struct sockaddr_in);
|
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);
|
_accepted_sockfd = lwip_accept_r(sockfd, (struct sockaddr *)&_client, (socklen_t*)&cs);
|
||||||
|
#endif
|
||||||
if (_accepted_sockfd >= 0) {
|
if (_accepted_sockfd >= 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -107,7 +115,11 @@ bool WiFiServer::hasClient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WiFiServer::end(){
|
void WiFiServer::end(){
|
||||||
|
#ifdef ESP_IDF_VERSION_MAJOR
|
||||||
|
lwip_close(sockfd);
|
||||||
|
#else
|
||||||
lwip_close_r(sockfd);
|
lwip_close_r(sockfd);
|
||||||
|
#endif
|
||||||
sockfd = -1;
|
sockfd = -1;
|
||||||
_listening = false;
|
_listening = false;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ It is the same functionality as implemented in your web browser when you connect
|
|||||||
If you are accessing your own server:
|
If you are accessing your own server:
|
||||||
- Generate a root certificate for your own certificate authority
|
- Generate a root certificate for your own certificate authority
|
||||||
- Generate a cert & private key using your root certificate ("self-signed cert") for your server
|
- Generate a cert & private key using your root certificate ("self-signed cert") for your server
|
||||||
|
|
||||||
If you are accessing a public server:
|
If you are accessing a public server:
|
||||||
- Obtain the cert of the public CA that signed that server's cert
|
- Obtain the cert of the public CA that signed that server's cert
|
||||||
Then:
|
Then:
|
||||||
|
@ -1,39 +1,50 @@
|
|||||||
/*|----------------------------------------------------------|*/
|
/*|-----------------------------------------------------------|*/
|
||||||
/*|WORKING EXAMPLE FOR HTTPS CONNECTION |*/
|
/*|WORKING EXAMPLE FOR HTTPS CONNECTION |*/
|
||||||
|
/*|Author: Bc. Martin Chlebovec |*/
|
||||||
|
/*|Technical University of Košice |*/
|
||||||
/*|TESTED BOARDS: Devkit v1 DOIT, Devkitc v4 |*/
|
/*|TESTED BOARDS: Devkit v1 DOIT, Devkitc v4 |*/
|
||||||
/*|CORE: June 2018 |*/
|
/*|CORE: 0.9x, 1.0.0, 1.0.1 tested, working (newer not tested)|*/
|
||||||
/*|----------------------------------------------------------|*/
|
/*|Supported methods: PEAP + MsCHAPv2, EAP-TTLS + MsCHAPv2 |*/
|
||||||
|
/*|-----------------------------------------------------------|*/
|
||||||
|
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
#include "esp_wpa2.h"
|
#include "esp_wpa2.h"
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#define EAP_IDENTITY "identity" //if connecting from another corporation, use identity@organisation.domain in Eduroam
|
#define EAP_ANONYMOUS_IDENTITY "anonymous@example.com" //anonymous identity
|
||||||
#define EAP_PASSWORD "password" //your Eduroam password
|
#define EAP_IDENTITY "id@example.com" //user identity
|
||||||
const char* ssid = "eduroam"; // Eduroam SSID
|
#define EAP_PASSWORD "password" //eduroam user password
|
||||||
const char* host = "arduino.php5.sk"; //external server domain for HTTP connection after authentification
|
const char* ssid = "eduroam"; // eduroam SSID
|
||||||
|
const char* host = "arduino.php5.sk"; //external server domain for HTTPS connection
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
const char* test_root_ca = \
|
const char* test_root_ca = \
|
||||||
"-----BEGIN CERTIFICATE-----\n" \
|
"-----BEGIN CERTIFICATE-----\n" \
|
||||||
"MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n" \
|
"MIIEsTCCA5mgAwIBAgIQCKWiRs1LXIyD1wK0u6tTSTANBgkqhkiG9w0BAQsFADBh\n" \
|
||||||
"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" \
|
"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" \
|
||||||
"d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" \
|
"d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" \
|
||||||
"QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\n" \
|
"QTAeFw0xNzExMDYxMjIzMzNaFw0yNzExMDYxMjIzMzNaMF4xCzAJBgNVBAYTAlVT\n" \
|
||||||
"MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" \
|
"MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" \
|
||||||
"b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\n" \
|
"b20xHTAbBgNVBAMTFFJhcGlkU1NMIFJTQSBDQSAyMDE4MIIBIjANBgkqhkiG9w0B\n" \
|
||||||
"9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\n" \
|
"AQEFAAOCAQ8AMIIBCgKCAQEA5S2oihEo9nnpezoziDtx4WWLLCll/e0t1EYemE5n\n" \
|
||||||
"CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\n" \
|
"+MgP5viaHLy+VpHP+ndX5D18INIuuAV8wFq26KF5U0WNIZiQp6mLtIWjUeWDPA28\n" \
|
||||||
"nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\n" \
|
"OeyhTlj9TLk2beytbtFU6ypbpWUltmvY5V8ngspC7nFRNCjpfnDED2kRyJzO8yoK\n" \
|
||||||
"43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\n" \
|
"MFz4J4JE8N7NA1uJwUEFMUvHLs0scLoPZkKcewIRm1RV2AxmFQxJkdf7YN9Pckki\n" \
|
||||||
"T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\n" \
|
"f2Xgm3b48BZn0zf0qXsSeGu84ua9gwzjzI7tbTBjayTpT+/XpWuBVv6fvarI6bik\n" \
|
||||||
"gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\n" \
|
"KB859OSGQuw73XXgeuFwEPHTIRoUtkzu3/EQ+LtwznkkdQIDAQABo4IBZjCCAWIw\n" \
|
||||||
"BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\n" \
|
"HQYDVR0OBBYEFFPKF1n8a8ADIS8aruSqqByCVtp1MB8GA1UdIwQYMBaAFAPeUDVW\n" \
|
||||||
"TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\n" \
|
"0Uy7ZvCj4hsbw5eyPdFVMA4GA1UdDwEB/wQEAwIBhjAdBgNVHSUEFjAUBggrBgEF\n" \
|
||||||
"DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\n" \
|
"BQcDAQYIKwYBBQUHAwIwEgYDVR0TAQH/BAgwBgEB/wIBADA0BggrBgEFBQcBAQQo\n" \
|
||||||
"hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\n" \
|
"MCYwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLmRpZ2ljZXJ0LmNvbTBCBgNVHR8E\n" \
|
||||||
"06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\n" \
|
"OzA5MDegNaAzhjFodHRwOi8vY3JsMy5kaWdpY2VydC5jb20vRGlnaUNlcnRHbG9i\n" \
|
||||||
"PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n" \
|
"YWxSb290Q0EuY3JsMGMGA1UdIARcMFowNwYJYIZIAYb9bAECMCowKAYIKwYBBQUH\n" \
|
||||||
"YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n" \
|
"AgEWHGh0dHBzOi8vd3d3LmRpZ2ljZXJ0LmNvbS9DUFMwCwYJYIZIAYb9bAEBMAgG\n" \
|
||||||
"CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n" \
|
"BmeBDAECATAIBgZngQwBAgIwDQYJKoZIhvcNAQELBQADggEBAH4jx/LKNW5ZklFc\n" \
|
||||||
|
"YWs8Ejbm0nyzKeZC2KOVYR7P8gevKyslWm4Xo4BSzKr235FsJ4aFt6yAiv1eY0tZ\n" \
|
||||||
|
"/ZN18bOGSGStoEc/JE4ocIzr8P5Mg11kRYHbmgYnr1Rxeki5mSeb39DGxTpJD4kG\n" \
|
||||||
|
"hs5lXNoo4conUiiJwKaqH7vh2baryd8pMISag83JUqyVGc2tWPpO0329/CWq2kry\n" \
|
||||||
|
"qv66OSMjwulUz0dXf4OHQasR7CNfIr+4KScc6ABlQ5RDF86PGeE6kdwSQkFiB/cQ\n" \
|
||||||
|
"ysNyq0jEDQTkfa2pjmuWtMCNbBnhFXBYejfubIhaUbEv2FOQB3dCav+FPg5eEveX\n" \
|
||||||
|
"TVyMnGo=\n" \
|
||||||
"-----END CERTIFICATE-----\n";
|
"-----END CERTIFICATE-----\n";
|
||||||
// You can use x.509 client certificates if you want
|
// You can use x.509 client certificates if you want
|
||||||
//const char* test_client_key = ""; //to verify the client
|
//const char* test_client_key = ""; //to verify the client
|
||||||
@ -47,30 +58,29 @@ void setup() {
|
|||||||
Serial.println(ssid);
|
Serial.println(ssid);
|
||||||
WiFi.disconnect(true); //disconnect form wifi to set new wifi connection
|
WiFi.disconnect(true); //disconnect form wifi to set new wifi connection
|
||||||
WiFi.mode(WIFI_STA); //init wifi mode
|
WiFi.mode(WIFI_STA); //init wifi mode
|
||||||
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide identity
|
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 --> identity and username is same
|
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_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();
|
||||||
esp_wifi_sta_wpa2_ent_enable(&config); //set config settings to enable function
|
|
||||||
WiFi.begin(ssid); //connect to wifi
|
WiFi.begin(ssid); //connect to wifi
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(500);
|
delay(500);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
counter++;
|
counter++;
|
||||||
if(counter>=60){ //after 30 seconds timeout - reset board
|
if (counter >= 60) { //after 30 seconds timeout - reset board (on unsucessful connection)
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client.setCACert(test_root_ca);
|
client.setCACert(test_root_ca);
|
||||||
//client.setCertificate(test_client_key); // for client verification
|
//client.setCertificate(test_client_key); // for client verification - certificate
|
||||||
//client.setPrivateKey(test_client_cert); // for client verification
|
//client.setPrivateKey(test_client_cert); // for client verification - private key
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
Serial.println("WiFi connected");
|
Serial.println("WiFi connected");
|
||||||
Serial.println("IP address set: ");
|
Serial.println("IP address set: ");
|
||||||
Serial.println(WiFi.localIP()); //print LAN IP
|
Serial.println(WiFi.localIP()); //print LAN IP
|
||||||
}
|
}
|
||||||
void loop() {
|
void loop() {
|
||||||
if (WiFi.status() == WL_CONNECTED) { //if we are connected to Eduroam network
|
if (WiFi.status() == WL_CONNECTED) { //if we are connected to eduroam network
|
||||||
counter = 0; //reset counter
|
counter = 0; //reset counter
|
||||||
Serial.println("Wifi is still connected with IP: ");
|
Serial.println("Wifi is still connected with IP: ");
|
||||||
Serial.println(WiFi.localIP()); //inform user about his IP address
|
Serial.println(WiFi.localIP()); //inform user about his IP address
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
#include "ssl_client.h"
|
#include "ssl_client.h"
|
||||||
#include "WiFi.h"
|
#include "WiFi.h"
|
||||||
|
|
||||||
|
#ifndef MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED
|
||||||
|
# error "Please configure IDF framework to include mbedTLS -> Enable pre-shared-key ciphersuites and activate at least one cipher"
|
||||||
|
#endif
|
||||||
|
|
||||||
const char *pers = "esp32-tls";
|
const char *pers = "esp32-tls";
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user