diff --git a/Makefile.projbuild b/Makefile.projbuild index e21d4c77b93..324f282902e 100644 --- a/Makefile.projbuild +++ b/Makefile.projbuild @@ -9,7 +9,7 @@ endif BOOT_APP_BIN_FLASH_CMD = $(ESPTOOLPY_SERIAL) write_flash $(BOOT_APP_BIN_OFFSET) $(BOOT_APP_BIN_PATH) ESPTOOL_ALL_FLASH_ARGS += $(BOOT_APP_BIN_OFFSET) $(BOOT_APP_BIN_PATH) -CPPFLAGS += -DARDUINO=10800 -DESP32=1 -DARDUINO_ARCH_ESP32=1 +CPPFLAGS += -DARDUINO=10800 -DESP32=1 -DARDUINO_ARCH_ESP32=1 -DBOARD_HAS_PSRAM boot-app0: @echo "Rebooting to APP0" diff --git a/README.md b/README.md index 4c0c046e5a8..4b3c14a4bff 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Most of the framework is implemented. Most noticable is the missing analogWrite. - [Using PlatformIO](docs/platformio.md) - [Building with make](docs/make.md) - [Using as ESP-IDF component](docs/esp-idf_component.md) +- [Using OTAWebUpdater](docs/OTAWebUpdate/OTAWebUpdate.md) #### Decoding exceptions diff --git a/boards.txt b/boards.txt index 599a39fd653..b5f44fac431 100644 --- a/boards.txt +++ b/boards.txt @@ -4,6 +4,7 @@ menu.FlashMode=Flash Mode menu.FlashSize=Flash Size menu.PartitionScheme=Partition Scheme menu.DebugLevel=Core Debug Level +menu.PSRAM=PSRAM ############################################################## @@ -28,6 +29,12 @@ esp32.build.flash_freq=40m esp32.build.flash_mode=dio esp32.build.boot=dio esp32.build.partitions=default +esp32.build.defines= + +esp32.menu.PSRAM.disabled=Disabled +esp32.menu.PSRAM.disabled.build.defines= +esp32.menu.PSRAM.enabled=Enabled +esp32.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue esp32.menu.PartitionScheme.default=Default esp32.menu.PartitionScheme.default.build.partitions=default @@ -94,6 +101,164 @@ esp32.menu.DebugLevel.verbose.build.code_debug=5 ############################################################## +cw02.name=XinaBox CW02 + +cw02.upload.tool=esptool +cw02.upload.maximum_size=1310720 +cw02.upload.maximum_data_size=294912 +cw02.upload.wait_for_upload_port=true + +cw02.serial.disableDTR=true +cw02.serial.disableRTS=true + +cw02.build.mcu=esp32 +cw02.build.core=esp32 +cw02.build.variant=xinabox +cw02.build.board=ESP32_DEV + +cw02.build.f_cpu=240000000L +cw02.build.flash_size=4MB +cw02.build.flash_freq=40m +cw02.build.flash_mode=dio +cw02.build.boot=dio +cw02.build.partitions=default + +cw02.menu.FlashMode.qio=QIO +cw02.menu.FlashMode.qio.build.flash_mode=dio +cw02.menu.FlashMode.qio.build.boot=qio +cw02.menu.FlashMode.dio=DIO +cw02.menu.FlashMode.dio.build.flash_mode=dio +cw02.menu.FlashMode.dio.build.boot=dio +cw02.menu.FlashMode.qout=QOUT +cw02.menu.FlashMode.qout.build.flash_mode=dout +cw02.menu.FlashMode.qout.build.boot=qout +cw02.menu.FlashMode.dout=DOUT +cw02.menu.FlashMode.dout.build.flash_mode=dout +cw02.menu.FlashMode.dout.build.boot=dout + +cw02.menu.FlashFreq.80=80MHz +cw02.menu.FlashFreq.80.build.flash_freq=80m +cw02.menu.FlashFreq.40=40MHz +cw02.menu.FlashFreq.40.build.flash_freq=40m + +cw02.menu.FlashSize.4M=4MB (32Mb) +cw02.menu.FlashSize.4M.build.flash_size=4MB +cw02.menu.FlashSize.2M=2MB (16Mb) +cw02.menu.FlashSize.2M.build.flash_size=2MB +cw02.menu.FlashSize.2M.build.partitions=minimal + +cw02.menu.UploadSpeed.921600=921600 +cw02.menu.UploadSpeed.921600.upload.speed=921600 +cw02.menu.UploadSpeed.115200=115200 +cw02.menu.UploadSpeed.115200.upload.speed=115200 +cw02.menu.UploadSpeed.256000.windows=256000 +cw02.menu.UploadSpeed.256000.upload.speed=256000 +cw02.menu.UploadSpeed.230400.windows.upload.speed=256000 +cw02.menu.UploadSpeed.230400=230400 +cw02.menu.UploadSpeed.230400.upload.speed=230400 +cw02.menu.UploadSpeed.460800.linux=460800 +cw02.menu.UploadSpeed.460800.macosx=460800 +cw02.menu.UploadSpeed.460800.upload.speed=460800 +cw02.menu.UploadSpeed.512000.windows=512000 +cw02.menu.UploadSpeed.512000.upload.speed=512000 + +cw02.menu.DebugLevel.none=None +cw02.menu.DebugLevel.none.build.code_debug=0 +cw02.menu.DebugLevel.error=Error +cw02.menu.DebugLevel.error.build.code_debug=1 +cw02.menu.DebugLevel.warn=Warn +cw02.menu.DebugLevel.warn.build.code_debug=2 +cw02.menu.DebugLevel.info=Info +cw02.menu.DebugLevel.info.build.code_debug=3 +cw02.menu.DebugLevel.debug=Debug +cw02.menu.DebugLevel.debug.build.code_debug=4 +cw02.menu.DebugLevel.verbose=Verbose +cw02.menu.DebugLevel.verbose.build.code_debug=5 + +############################################################## + +esp32wrover.name=ESP32 Wrover Module + +esp32wrover.upload.tool=esptool +esp32wrover.upload.maximum_size=1310720 +esp32wrover.upload.maximum_data_size=327680 +esp32wrover.upload.wait_for_upload_port=true + +esp32wrover.serial.disableDTR=true +esp32wrover.serial.disableRTS=true + +esp32wrover.build.mcu=esp32 +esp32wrover.build.core=esp32 +esp32wrover.build.variant=esp32 +esp32wrover.build.board=ESP32_DEV + +esp32wrover.build.f_cpu=240000000L +esp32wrover.build.flash_size=4MB +esp32wrover.build.flash_freq=40m +esp32wrover.build.flash_mode=dio +esp32wrover.build.boot=dio +esp32wrover.build.partitions=default +esp32wrover.build.defines=-DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue + +esp32wrover.menu.PartitionScheme.default=Default +esp32wrover.menu.PartitionScheme.default.build.partitions=default +esp32wrover.menu.PartitionScheme.minimal=Minimal (2MB FLASH) +esp32wrover.menu.PartitionScheme.minimal.build.partitions=minimal +esp32wrover.menu.PartitionScheme.no_ota=No OTA (Large APP) +esp32wrover.menu.PartitionScheme.no_ota.build.partitions=no_ota +esp32wrover.menu.PartitionScheme.no_ota.upload.maximum_size=2097152 +esp32wrover.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA) +esp32wrover.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs +esp32wrover.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 + +esp32wrover.menu.FlashMode.qio=QIO +esp32wrover.menu.FlashMode.qio.build.flash_mode=dio +esp32wrover.menu.FlashMode.qio.build.boot=qio +esp32wrover.menu.FlashMode.dio=DIO +esp32wrover.menu.FlashMode.dio.build.flash_mode=dio +esp32wrover.menu.FlashMode.dio.build.boot=dio +esp32wrover.menu.FlashMode.qout=QOUT +esp32wrover.menu.FlashMode.qout.build.flash_mode=dout +esp32wrover.menu.FlashMode.qout.build.boot=qout +esp32wrover.menu.FlashMode.dout=DOUT +esp32wrover.menu.FlashMode.dout.build.flash_mode=dout +esp32wrover.menu.FlashMode.dout.build.boot=dout + +esp32wrover.menu.FlashFreq.80=80MHz +esp32wrover.menu.FlashFreq.80.build.flash_freq=80m +esp32wrover.menu.FlashFreq.40=40MHz +esp32wrover.menu.FlashFreq.40.build.flash_freq=40m + +esp32wrover.menu.UploadSpeed.921600=921600 +esp32wrover.menu.UploadSpeed.921600.upload.speed=921600 +esp32wrover.menu.UploadSpeed.115200=115200 +esp32wrover.menu.UploadSpeed.115200.upload.speed=115200 +esp32wrover.menu.UploadSpeed.256000.windows=256000 +esp32wrover.menu.UploadSpeed.256000.upload.speed=256000 +esp32wrover.menu.UploadSpeed.230400.windows.upload.speed=256000 +esp32wrover.menu.UploadSpeed.230400=230400 +esp32wrover.menu.UploadSpeed.230400.upload.speed=230400 +esp32wrover.menu.UploadSpeed.460800.linux=460800 +esp32wrover.menu.UploadSpeed.460800.macosx=460800 +esp32wrover.menu.UploadSpeed.460800.upload.speed=460800 +esp32wrover.menu.UploadSpeed.512000.windows=512000 +esp32wrover.menu.UploadSpeed.512000.upload.speed=512000 + +esp32wrover.menu.DebugLevel.none=None +esp32wrover.menu.DebugLevel.none.build.code_debug=0 +esp32wrover.menu.DebugLevel.error=Error +esp32wrover.menu.DebugLevel.error.build.code_debug=1 +esp32wrover.menu.DebugLevel.warn=Warn +esp32wrover.menu.DebugLevel.warn.build.code_debug=2 +esp32wrover.menu.DebugLevel.info=Info +esp32wrover.menu.DebugLevel.info.build.code_debug=3 +esp32wrover.menu.DebugLevel.debug=Debug +esp32wrover.menu.DebugLevel.debug.build.code_debug=4 +esp32wrover.menu.DebugLevel.verbose=Verbose +esp32wrover.menu.DebugLevel.verbose.build.code_debug=5 + +############################################################## + pico32.name=ESP32 Pico Kit pico32.upload.tool=esptool @@ -115,6 +280,7 @@ pico32.build.flash_freq=80m pico32.build.flash_mode=dio pico32.build.boot=dio pico32.build.partitions=default +pico32.build.defines= pico32.menu.UploadSpeed.921600=921600 pico32.menu.UploadSpeed.921600.upload.speed=921600 @@ -166,6 +332,7 @@ esp32thing.build.flash_mode=dio esp32thing.build.flash_size=4MB esp32thing.build.boot=dio esp32thing.build.partitions=default +esp32thing.build.defines= esp32thing.menu.FlashFreq.80=80MHz esp32thing.menu.FlashFreq.80.build.flash_freq=80m @@ -209,6 +376,7 @@ nina_w10.build.partitions=minimal nina_w10.build.flash_mode=dio nina_w10.build.flash_size=2MB nina_w10.build.flash_freq=40m +nina_w10.build.defines= nina_w10.menu.UploadSpeed.921600=921600 nina_w10.menu.UploadSpeed.921600.upload.speed=921600 @@ -247,6 +415,7 @@ widora-air.build.flash_mode=dio widora-air.build.flash_size=16MB widora-air.build.boot=dio widora-air.build.partitions=default +widora-air.build.defines= widora-air.menu.FlashFreq.80=80MHz widora-air.menu.FlashFreq.80.build.flash_freq=80m @@ -290,6 +459,7 @@ esp320.build.flash_mode=qio esp320.build.flash_size=4MB esp320.build.boot=dio esp320.build.partitions=default +esp320.build.defines= esp320.menu.FlashFreq.80=80MHz esp320.menu.FlashFreq.80.build.flash_freq=80m @@ -333,6 +503,7 @@ nano32.build.flash_mode=dio nano32.build.flash_size=4MB nano32.build.boot=dio nano32.build.partitions=default +nano32.build.defines= nano32.menu.FlashFreq.80=80MHz nano32.menu.FlashFreq.80.build.flash_freq=80m @@ -376,6 +547,7 @@ lolin32.build.flash_mode=dio lolin32.build.flash_size=4MB lolin32.build.boot=dio lolin32.build.partitions=default +lolin32.build.defines= lolin32.menu.FlashFreq.80=80MHz lolin32.menu.FlashFreq.80.build.flash_freq=80m @@ -428,6 +600,7 @@ pocket_32.build.flash_mode=dio pocket_32.build.flash_size=4MB pocket_32.build.boot=dio pocket_32.build.partitions=default +pocket_32.build.defines= pocket_32.menu.FlashFreq.80=80MHz pocket_32.menu.FlashFreq.80.build.flash_freq=80m @@ -471,6 +644,7 @@ WeMosBat.build.flash_mode=dio WeMosBat.build.flash_size=4MB WeMosBat.build.boot=dio WeMosBat.build.partitions=default +WeMosBat.build.defines= WeMosBat.menu.FlashFreq.80=80MHz WeMosBat.menu.FlashFreq.80.build.flash_freq=80m @@ -527,6 +701,7 @@ espea32.build.flash_mode=dio espea32.build.flash_size=4MB espea32.build.boot=dio espea32.build.partitions=default +espea32.build.defines= espea32.menu.FlashFreq.80=80MHz espea32.menu.FlashFreq.80.build.flash_freq=80m @@ -570,6 +745,7 @@ quantum.build.flash_mode=qio quantum.build.flash_size=16MB quantum.build.boot=dio quantum.build.partitions=default +quantum.build.defines= quantum.menu.FlashFreq.80=80MHz quantum.menu.FlashFreq.80.build.flash_freq=80m @@ -613,6 +789,7 @@ node32s.build.flash_mode=dio node32s.build.flash_size=4MB node32s.build.boot=dio node32s.build.partitions=default +node32s.build.defines= node32s.menu.FlashFreq.80=80MHz node32s.menu.FlashFreq.80.build.flash_freq=80m @@ -656,6 +833,7 @@ hornbill32dev.build.flash_mode=dio hornbill32dev.build.flash_size=4MB hornbill32dev.build.boot=dio hornbill32dev.build.partitions=default +hornbill32dev.build.defines= hornbill32dev.menu.FlashFreq.80=80MHz hornbill32dev.menu.FlashFreq.80.build.flash_freq=80m @@ -698,6 +876,7 @@ hornbill32minima.build.flash_mode=dio hornbill32minima.build.flash_size=4MB hornbill32minima.build.boot=dio hornbill32minima.build.partitions=default +hornbill32minima.build.defines= hornbill32minima.menu.FlashFreq.80=80MHz hornbill32minima.menu.FlashFreq.80.build.flash_freq=80m @@ -741,6 +920,7 @@ firebeetle32.build.flash_mode=dio firebeetle32.build.flash_size=4MB firebeetle32.build.boot=dio firebeetle32.build.partitions=default +firebeetle32.build.defines= firebeetle32.menu.FlashFreq.80=80MHz firebeetle32.menu.FlashFreq.80.build.flash_freq=80m @@ -784,6 +964,7 @@ intorobot-fig.build.flash_mode=dio intorobot-fig.build.flash_size=4MB intorobot-fig.build.boot=dio intorobot-fig.build.partitions=default +intorobot-fig.build.defines= intorobot-fig.menu.FlashFreq.80=80MHz intorobot-fig.menu.FlashFreq.80.build.flash_freq=80m @@ -827,6 +1008,7 @@ onehorse32dev.build.flash_mode=dout onehorse32dev.build.flash_size=4MB onehorse32dev.build.boot=dio onehorse32dev.build.partitions=default +onehorse32dev.build.defines= onehorse32dev.menu.FlashFreq.80=80MHz onehorse32dev.menu.FlashFreq.80.build.flash_freq=80m @@ -870,6 +1052,7 @@ featheresp32.build.flash_mode=dio featheresp32.build.flash_size=4MB featheresp32.build.boot=dio featheresp32.build.partitions=default +featheresp32.build.defines= featheresp32.menu.FlashFreq.80=80MHz featheresp32.menu.FlashFreq.80.build.flash_freq=80m @@ -926,6 +1109,7 @@ nodemcu-32s.build.flash_mode=dio nodemcu-32s.build.flash_size=4MB nodemcu-32s.build.boot=dio nodemcu-32s.build.partitions=default +nodemcu-32s.build.defines= nodemcu-32s.menu.FlashFreq.80=80MHz nodemcu-32s.menu.FlashFreq.80.build.flash_freq=80m @@ -969,6 +1153,7 @@ mhetesp32devkit.build.flash_mode=dio mhetesp32devkit.build.flash_size=4MB mhetesp32devkit.build.boot=dio mhetesp32devkit.build.partitions=default +mhetesp32devkit.build.defines= mhetesp32devkit.menu.FlashFreq.80=80MHz mhetesp32devkit.menu.FlashFreq.80.build.flash_freq=80m @@ -1034,6 +1219,7 @@ mhetesp32minikit.build.flash_mode=dio mhetesp32minikit.build.flash_size=4MB mhetesp32minikit.build.boot=dio mhetesp32minikit.build.partitions=default +mhetesp32minikit.build.defines= mhetesp32minikit.menu.FlashFreq.80=80MHz mhetesp32minikit.menu.FlashFreq.80.build.flash_freq=80m @@ -1099,6 +1285,7 @@ esp32vn-iot-uno.build.flash_mode=dio esp32vn-iot-uno.build.flash_size=4MB esp32vn-iot-uno.build.boot=dio esp32vn-iot-uno.build.partitions=default +esp32vn-iot-uno.build.defines= esp32vn-iot-uno.menu.FlashFreq.80=80MHz esp32vn-iot-uno.menu.FlashFreq.80.build.flash_freq=80m @@ -1142,6 +1329,7 @@ esp32doit-devkit-v1.build.flash_mode=dio esp32doit-devkit-v1.build.flash_size=4MB esp32doit-devkit-v1.build.boot=dio esp32doit-devkit-v1.build.partitions=default +esp32doit-devkit-v1.build.defines= esp32doit-devkit-v1.menu.FlashFreq.80=80MHz esp32doit-devkit-v1.menu.FlashFreq.80.build.flash_freq=80m @@ -1196,6 +1384,7 @@ esp32-evb.build.flash_mode=dio esp32-evb.build.flash_size=4MB esp32-evb.build.boot=dio esp32-evb.build.partitions=default +esp32-evb.build.defines= esp32-evb.menu.FlashFreq.80=80MHz esp32-evb.menu.FlashFreq.80.build.flash_freq=80m @@ -1228,6 +1417,7 @@ esp32-gateway.build.flash_mode=dio esp32-gateway.build.flash_size=4MB esp32-gateway.build.boot=dio esp32-gateway.build.partitions=default +esp32-gateway.build.defines= esp32-gateway.menu.FlashFreq.80=80MHz esp32-gateway.menu.FlashFreq.80.build.flash_freq=80m @@ -1260,6 +1450,7 @@ espino32.build.flash_mode=dio espino32.build.flash_size=4MB espino32.build.boot=dio espino32.build.partitions=default +espino32.build.defines= espino32.menu.FlashFreq.80=80MHz espino32.menu.FlashFreq.80.build.flash_freq=80m @@ -1303,6 +1494,7 @@ m5stack-core-esp32.build.flash_size=4MB m5stack-core-esp32.build.flash_mode=dio m5stack-core-esp32.build.boot=dio m5stack-core-esp32.build.partitions=default +m5stack-core-esp32.build.defines= m5stack-core-esp32.menu.FlashMode.qio=QIO m5stack-core-esp32.menu.FlashMode.qio.build.flash_mode=dio @@ -1381,6 +1573,7 @@ odroid_esp32.build.flash_size=16MB odroid_esp32.build.flash_mode=dio odroid_esp32.build.boot=dio odroid_esp32.build.partitions=default +odroid_esp32.build.defines= odroid_esp32.menu.FlashMode.qio=QIO odroid_esp32.menu.FlashMode.qio.build.flash_mode=dio @@ -1459,6 +1652,7 @@ heltec_wifi_kit_32.build.flash_mode=dio heltec_wifi_kit_32.build.flash_size=4MB heltec_wifi_kit_32.build.boot=dio heltec_wifi_kit_32.build.partitions=default +heltec_wifi_kit_32.build.defines= heltec_wifi_kit_32.menu.FlashFreq.80=80MHz heltec_wifi_kit_32.menu.FlashFreq.80.build.flash_freq=80m @@ -1502,6 +1696,7 @@ heltec_wifi_lora_32.build.flash_mode=dio heltec_wifi_lora_32.build.flash_size=4MB heltec_wifi_lora_32.build.boot=dio heltec_wifi_lora_32.build.partitions=default +heltec_wifi_lora_32.build.defines= heltec_wifi_lora_32.menu.FlashFreq.80=80MHz heltec_wifi_lora_32.menu.FlashFreq.80.build.flash_freq=80m @@ -1545,6 +1740,7 @@ espectro32.build.flash_size=4MB espectro32.build.flash_mode=dio espectro32.build.boot=dio espectro32.build.partitions=default +espectro32.build.defines= espectro32.menu.FlashMode.qio=QIO espectro32.menu.FlashMode.qio.build.flash_mode=dio @@ -1620,6 +1816,7 @@ CoreESP32.build.flash_mode=dio CoreESP32.build.flash_size=4MB CoreESP32.build.boot=dio CoreESP32.build.partitions=default +CoreESP32.build.defines= CoreESP32.menu.FlashFreq.80=80MHz CoreESP32.menu.FlashFreq.80.build.flash_freq=80m @@ -1643,6 +1840,96 @@ CoreESP32.menu.UploadSpeed.512000.upload.speed=512000 ############################################################## + +alksesp32.name=ALKS ESP32 + +alksesp32.upload.tool=esptool +alksesp32.upload.maximum_size=1310720 +alksesp32.upload.maximum_data_size=327680 +alksesp32.upload.wait_for_upload_port=true + +alksesp32.serial.disableDTR=true +alksesp32.serial.disableRTS=true + +alksesp32.build.mcu=esp32 +alksesp32.build.core=esp32 +alksesp32.build.variant=alksesp32 +alksesp32.build.board=ALKS + +alksesp32.build.f_cpu=240000000L +alksesp32.build.flash_size=4MB +alksesp32.build.flash_freq=40m +alksesp32.build.flash_mode=dio +alksesp32.build.boot=dio +alksesp32.build.partitions=default +alksesp32.build.defines= + +alksesp32.menu.PartitionScheme.default=Default +alksesp32.menu.PartitionScheme.default.build.partitions=default +alksesp32.menu.PartitionScheme.minimal=Minimal (2MB FLASH) +alksesp32.menu.PartitionScheme.minimal.build.partitions=minimal +alksesp32.menu.PartitionScheme.no_ota=No OTA (Large APP) +alksesp32.menu.PartitionScheme.no_ota.build.partitions=no_ota +alksesp32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152 +alksesp32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA) +alksesp32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs +alksesp32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 + +alksesp32.menu.FlashMode.qio=QIO +alksesp32.menu.FlashMode.qio.build.flash_mode=dio +alksesp32.menu.FlashMode.qio.build.boot=qio +alksesp32.menu.FlashMode.dio=DIO +alksesp32.menu.FlashMode.dio.build.flash_mode=dio +alksesp32.menu.FlashMode.dio.build.boot=dio +alksesp32.menu.FlashMode.qout=QOUT +alksesp32.menu.FlashMode.qout.build.flash_mode=dout +alksesp32.menu.FlashMode.qout.build.boot=qout +alksesp32.menu.FlashMode.dout=DOUT +alksesp32.menu.FlashMode.dout.build.flash_mode=dout +alksesp32.menu.FlashMode.dout.build.boot=dout + +alksesp32.menu.FlashFreq.80=80MHz +alksesp32.menu.FlashFreq.80.build.flash_freq=80m +alksesp32.menu.FlashFreq.40=40MHz +alksesp32.menu.FlashFreq.40.build.flash_freq=40m + +alksesp32.menu.FlashSize.4M=4MB (32Mb) +alksesp32.menu.FlashSize.4M.build.flash_size=4MB +alksesp32.menu.FlashSize.2M=2MB (16Mb) +alksesp32.menu.FlashSize.2M.build.flash_size=2MB +alksesp32.menu.FlashSize.2M.build.partitions=minimal + +alksesp32.menu.UploadSpeed.921600=921600 +alksesp32.menu.UploadSpeed.921600.upload.speed=921600 +alksesp32.menu.UploadSpeed.115200=115200 +alksesp32.menu.UploadSpeed.115200.upload.speed=115200 +alksesp32.menu.UploadSpeed.256000.windows=256000 +alksesp32.menu.UploadSpeed.256000.upload.speed=256000 +alksesp32.menu.UploadSpeed.230400.windows.upload.speed=256000 +alksesp32.menu.UploadSpeed.230400=230400 +alksesp32.menu.UploadSpeed.230400.upload.speed=230400 +alksesp32.menu.UploadSpeed.460800.linux=460800 +alksesp32.menu.UploadSpeed.460800.macosx=460800 +alksesp32.menu.UploadSpeed.460800.upload.speed=460800 +alksesp32.menu.UploadSpeed.512000.windows=512000 +alksesp32.menu.UploadSpeed.512000.upload.speed=512000 + +alksesp32.menu.DebugLevel.none=None +alksesp32.menu.DebugLevel.none.build.code_debug=0 +alksesp32.menu.DebugLevel.error=Error +alksesp32.menu.DebugLevel.error.build.code_debug=1 +alksesp32.menu.DebugLevel.warn=Warn +alksesp32.menu.DebugLevel.warn.build.code_debug=2 +alksesp32.menu.DebugLevel.info=Info +alksesp32.menu.DebugLevel.info.build.code_debug=3 +alksesp32.menu.DebugLevel.debug=Debug +alksesp32.menu.DebugLevel.debug.build.code_debug=4 +alksesp32.menu.DebugLevel.verbose=Verbose +alksesp32.menu.DebugLevel.verbose.build.code_debug=5 + +############################################################## + + wipy3.name=WiPy 3.0 wipy3.upload.tool=esptool @@ -1663,6 +1950,7 @@ wipy3.build.flash_mode=dio wipy3.build.flash_size=8MB wipy3.build.boot=dio wipy3.build.partitions=default +wipy3.build.defines= wipy3.menu.FlashFreq.80=80MHz wipy3.menu.FlashFreq.80.build.flash_freq=80m @@ -1695,5 +1983,4 @@ wipy3.menu.DebugLevel.info.build.code_debug=3 wipy3.menu.DebugLevel.debug=Debug wipy3.menu.DebugLevel.debug.build.code_debug=4 wipy3.menu.DebugLevel.verbose=Verbose -wipy3.menu.DebugLevel.verbose.build.code_debug=5 - +wipy3.menu.DebugLevel.verbose.build.code_debug=5 \ No newline at end of file diff --git a/component.mk b/component.mk index 15d50c00626..ba79873ebef 100644 --- a/component.mk +++ b/component.mk @@ -1,4 +1,4 @@ -ARDUINO_CORE_LIBS := $(patsubst $(COMPONENT_PATH)/%,%,$(sort $(dir $(wildcard $(COMPONENT_PATH)/libraries/*/*/)))) +ARDUINO_CORE_LIBS := $(patsubst $(COMPONENT_PATH)/%,%,$(sort $(dir $(wildcard $(COMPONENT_PATH)/libraries/*/*/)) $(dir $(wildcard $(COMPONENT_PATH)/libraries/*/*/*/)))) COMPONENT_ADD_INCLUDEDIRS := cores/esp32 variants/esp32 $(ARDUINO_CORE_LIBS) COMPONENT_PRIV_INCLUDEDIRS := cores/esp32/libb64 diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index 1f1a52900f5..e46c7a02cf2 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -7,6 +7,8 @@ #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) HardwareSerial Serial(0); +HardwareSerial Serial1(1); +HardwareSerial Serial2(2); #endif HardwareSerial::HardwareSerial(int uart_nr) : _uart_nr(uart_nr), _uart(NULL) {} diff --git a/cores/esp32/HardwareSerial.h b/cores/esp32/HardwareSerial.h index c0e00ec2e23..f1e04e90bf2 100644 --- a/cores/esp32/HardwareSerial.h +++ b/cores/esp32/HardwareSerial.h @@ -79,6 +79,8 @@ class HardwareSerial: public Stream #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) extern HardwareSerial Serial; +extern HardwareSerial Serial1; +extern HardwareSerial Serial2; #endif #endif diff --git a/cores/esp32/esp32-hal-gpio.c b/cores/esp32/esp32-hal-gpio.c index 7c5e02bd47f..795dba2b7ab 100644 --- a/cores/esp32/esp32-hal-gpio.c +++ b/cores/esp32/esp32-hal-gpio.c @@ -70,7 +70,12 @@ const DRAM_ATTR esp32_gpioMux_t esp32_gpioMux[GPIO_PIN_COUNT]={ }; typedef void (*voidFuncPtr)(void); -static voidFuncPtr __pinInterruptHandlers[GPIO_PIN_COUNT] = {0,}; +typedef void (*voidFuncPtrArg)(void*); +typedef struct { + voidFuncPtr fn; + void* arg; +} InterruptHandle_t; +static InterruptHandle_t __pinInterruptHandlers[GPIO_PIN_COUNT] = {0,}; #include "driver/rtc_io.h" @@ -193,7 +198,7 @@ extern int IRAM_ATTR __digitalRead(uint8_t pin) static intr_handle_t gpio_intr_handle = NULL; -static void IRAM_ATTR __onPinInterrupt(void *arg) +static void IRAM_ATTR __onPinInterrupt() { uint32_t gpio_intr_status_l=0; uint32_t gpio_intr_status_h=0; @@ -207,8 +212,12 @@ static void IRAM_ATTR __onPinInterrupt(void *arg) if(gpio_intr_status_l) { do { if(gpio_intr_status_l & ((uint32_t)1 << pin)) { - if(__pinInterruptHandlers[pin]) { - __pinInterruptHandlers[pin](); + if(__pinInterruptHandlers[pin].fn) { + if(__pinInterruptHandlers[pin].arg){ + ((voidFuncPtrArg)__pinInterruptHandlers[pin].fn)(__pinInterruptHandlers[pin].arg); + } else { + __pinInterruptHandlers[pin].fn(); + } } } } while(++pin<32); @@ -217,15 +226,19 @@ static void IRAM_ATTR __onPinInterrupt(void *arg) pin=32; do { if(gpio_intr_status_h & ((uint32_t)1 << (pin - 32))) { - if(__pinInterruptHandlers[pin]) { - __pinInterruptHandlers[pin](); + if(__pinInterruptHandlers[pin].fn) { + if(__pinInterruptHandlers[pin].arg){ + ((voidFuncPtrArg)__pinInterruptHandlers[pin].fn)(__pinInterruptHandlers[pin].arg); + } else { + __pinInterruptHandlers[pin].fn(); + } } } } while(++pin= i2c->queueCount)) { // disable IRQ, the next dq will re-enable it i2c->dev->int_ena.tx_fifo_empty=0; + + if(!full) { // add a byte to keep spurious tx_empty int + uint8_t filler=i2c->dev->fifo_conf.tx_fifo_empty_thrhd; + if(filler >( 31 - i2c->dev->status_reg.tx_fifo_cnt)){ + filler = ( 31 - i2c->dev->status_reg.tx_fifo_cnt); + } + + while(filler > 0){ + i2c->dev->fifo_data.val = 0xFE; // Just a dummy byte + filler--; + } + } } i2c->dev->int_clr.tx_fifo_empty=1; @@ -563,9 +575,9 @@ static void IRAM_ATTR i2cIsrExit(i2c_t * i2c,const uint32_t eventCode,bool Fatal if(i2c->dq[i2c->queuePos].ctrl.mode == 1) { emptyRxFifo(i2c); // grab last few characters } - +// log_d("raw=0x%05x status=0x%05x",i2c->dev->int_raw.val,i2c->dev->int_status.val); i2c->dev->int_ena.val = 0; // shutdown interrupts - i2c->dev->int_clr.val = 0x1FFFF; + i2c->dev->int_clr.val = 0x1FFF; i2c->stage = I2C_DONE; i2c->exitCode = exitCode; //true eventcode @@ -586,12 +598,16 @@ static void IRAM_ATTR i2cIsrExit(i2c_t * i2c,const uint32_t eventCode,bool Fatal static void IRAM_ATTR i2c_isr_handler_default(void* arg) { i2c_t* p_i2c = (i2c_t*) arg; // recover data - uint32_t activeInt = p_i2c->dev->int_status.val&0x1FFF; - - //portBASE_TYPE HPTaskAwoken = pdFALSE,xResult; + uint32_t activeInt = p_i2c->dev->int_status.val&0x7FF; - if(p_i2c->stage==I2C_DONE) { //get Out - log_e("eject int=%p, ena=%p",activeInt,p_i2c->dev->int_ena.val); + if(!activeInt){ //spurious interrupt, possibly bus relate 20180711 + log_d("raw=0x%05x status=0x%05x",p_i2c->dev->int_raw.val,p_i2c->dev->int_status.val); + } + if(p_i2c->stage==I2C_DONE) { //get Out, can't service, not configured + // this error is some kind of a race condition at high clock >400khz + // see #1588. it does not compromise i2c communications though, just + // a poke in the eye + log_d("eject raw=%p, int=%p",p_i2c->dev->int_raw.val,activeInt); p_i2c->dev->int_ena.val = 0; p_i2c->dev->int_clr.val = activeInt; //0x1FFF; return; @@ -610,8 +626,7 @@ static void IRAM_ATTR i2c_isr_handler_default(void* arg) intBuff[intPos[p_i2c->num]][2][p_i2c->num] = xTaskGetTickCountFromISR(); // when IRQ fired #endif - //uint32_t oldInt =activeInt; - + if (activeInt & I2C_TRANS_START_INT_ST_M) { // p_i2c->byteCnt=0; if(p_i2c->stage==I2C_STARTUP) { @@ -871,18 +886,21 @@ i2c_err_t i2cProcQueue(i2c_t * i2c, uint32_t *readCount, uint16_t timeOutMillis) f.rx_fifo_rst = 1; // fifo in reset f.tx_fifo_rst = 1; // fifo in reset f.nonfifo_en = 0; // use fifo mode + f.nonfifo_tx_thres =63; // need to adjust threshold based on I2C clock rate, at 100k, 30 usually works, // sometimes the emptyRx() actually moves 31 bytes // it hasn't overflowed yet, I cannot tell if the new byte is added while // emptyRX() is executing or before? - f.rx_fifo_full_thrhd = 30; // 30 bytes before INT is issued + // let i2cSetFrequency() set thrhds + // f.rx_fifo_full_thrhd = 30; // 30 bytes before INT is issued + // f.tx_fifo_empty_thrhd = 0; f.fifo_addr_cfg_en = 0; // no directed access i2c->dev->fifo_conf.val = f.val; // post them all f.rx_fifo_rst = 0; // release fifo f.tx_fifo_rst = 0; i2c->dev->fifo_conf.val = f.val; // post them all - + i2c->dev->int_clr.val = 0xFFFFFFFF; // kill them All! i2c->dev->ctr.ms_mode = 1; // master! i2c->queuePos=0; @@ -936,9 +954,9 @@ i2c_err_t i2cProcQueue(i2c_t * i2c, uint32_t *readCount, uint16_t timeOutMillis) ESP_INTR_FLAG_LOWMED; //< Low and medium prio interrupts. These can be handled in C. if(i2c->num) { - ret = esp_intr_alloc_intrstatus(ETS_I2C_EXT1_INTR_SOURCE, flags, (uint32_t)&i2c->dev->int_status.val, 0x1FFF, &i2c_isr_handler_default,i2c, &i2c->intr_handle); + ret = esp_intr_alloc_intrstatus(ETS_I2C_EXT1_INTR_SOURCE, flags, (uint32_t)&i2c->dev->int_status.val, 0x7FF, &i2c_isr_handler_default,i2c, &i2c->intr_handle); } else { - ret = esp_intr_alloc_intrstatus(ETS_I2C_EXT0_INTR_SOURCE, flags, (uint32_t)&i2c->dev->int_status.val, 0x1FFF, &i2c_isr_handler_default,i2c, &i2c->intr_handle); + ret = esp_intr_alloc_intrstatus(ETS_I2C_EXT0_INTR_SOURCE, flags, (uint32_t)&i2c->dev->int_status.val, 0x7FF, &i2c_isr_handler_default,i2c, &i2c->intr_handle); } if(ret!=ESP_OK) { @@ -1326,12 +1344,23 @@ i2c_err_t i2cSetFrequency(i2c_t * i2c, uint32_t clk_speed) if(i2c == NULL) { return I2C_ERROR_DEV; } - + I2C_FIFO_CONF_t f; + uint32_t period = (APB_CLK_FREQ/clk_speed) / 2; uint32_t halfPeriod = period/2; uint32_t quarterPeriod = period/4; I2C_MUTEX_LOCK(); + + // Adjust Fifo thresholds based on frequency + f.val = i2c->dev->fifo_conf.val; + uint32_t a = (clk_speed / 50000L )+1; + if (a > 24) a=24; + f.rx_fifo_full_thrhd = 32 - a; + f.tx_fifo_empty_thrhd = a; + i2c->dev->fifo_conf.val = f.val; // set thresholds + log_v("threshold=%d",a); + //the clock num during SCL is low level i2c->dev->scl_low_period.period = period; //the clock num during SCL is high level diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index a2c4420820b..5e6ea13df9e 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "esp32-hal.h" #include "sdkconfig.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -24,6 +23,7 @@ #include "esp_timer.h" #include "esp_bt.h" #include +#include "esp32-hal.h" //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 diff --git a/cores/esp32/esp32-hal-psram.c b/cores/esp32/esp32-hal-psram.c index 38479211c33..9a1fd8cd37d 100644 --- a/cores/esp32/esp32-hal-psram.c +++ b/cores/esp32/esp32-hal-psram.c @@ -1,6 +1,5 @@ #include "esp32-hal.h" -#include "sdkconfig.h" #if CONFIG_SPIRAM_SUPPORT #include "esp_spiram.h" diff --git a/cores/esp32/esp32-hal-psram.h b/cores/esp32/esp32-hal-psram.h index f5bde289cf2..36acc0a03de 100644 --- a/cores/esp32/esp32-hal-psram.h +++ b/cores/esp32/esp32-hal-psram.h @@ -15,6 +15,10 @@ #ifndef _ESP32_HAL_PSRAM_H_ #define _ESP32_HAL_PSRAM_H_ +#ifdef __cplusplus +extern "C" { +#endif + bool psramInit(); bool psramFound(); @@ -22,4 +26,8 @@ void *ps_malloc(size_t size); void *ps_calloc(size_t n, size_t size); void *ps_realloc(void *ptr, size_t size); +#ifdef __cplusplus +} +#endif + #endif /* _ESP32_HAL_PSRAM_H_ */ diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index bcf9d045093..d8d132950bb 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -315,11 +315,14 @@ void uartFlush(uart_t* uart) UART_MUTEX_LOCK(); while(uart->dev->status.txfifo_cnt); - uart->dev->conf0.txfifo_rst = 1; - uart->dev->conf0.txfifo_rst = 0; + //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 <> v2.6 or later. + + // we read the data out and make `fifo_len == 0 && rd_addr == wr_addr`. + while(uart->dev->status.rxfifo_cnt != 0 || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) { + READ_PERI_REG(UART_FIFO_REG(uart->num)); + } - uart->dev->conf0.rxfifo_rst = 1; - uart->dev->conf0.rxfifo_rst = 0; UART_MUTEX_UNLOCK(); } diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index 3b19b052fbb..3de30950e22 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -33,6 +33,7 @@ extern "C" { #include #include #include "sdkconfig.h" +#include "esp_system.h" #ifndef F_CPU #define F_CPU (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000U) @@ -60,7 +61,12 @@ void yield(void); #include "esp32-hal-timer.h" #include "esp32-hal-bt.h" #include "esp32-hal-psram.h" -#include "esp_system.h" + +#ifndef BOARD_HAS_PSRAM +#ifdef CONFIG_SPIRAM_SUPPORT +#undef CONFIG_SPIRAM_SUPPORT +#endif +#endif //returns chip temperature in Celsius float temperatureRead(); diff --git a/docs/OTAWebUpdate/OTAWebUpdate.md b/docs/OTAWebUpdate/OTAWebUpdate.md new file mode 100644 index 00000000000..383f6214433 --- /dev/null +++ b/docs/OTAWebUpdate/OTAWebUpdate.md @@ -0,0 +1,59 @@ +# Over the Air through Web browser +OTAWebUpdate is done with a web browser that can be useful in the following typical scenarios: +- Once the application developed and loading directly from Arduino IDE is inconvenient or not possible +- after deployment if user is unable to expose Firmware for OTA from external update server +- provide updates after deployment to small quantity of modules when setting an update server is not practicable + +## Requirements +- The ESP and the computer must be connected to the same network + +## Implementation +The sample implementation has been done using: +- example sketch OTAWebUpdater.ino +- ESP32 (Dev Module) + +You can use another module also if it meets Flash chip size of the sketch + +1-Before you begin, please make sure that you have the following software installed: + - Arduino IDE + - Host software depending on O/S you use: + - Avahi http://avahi.org/ for Linux + - Bonjour http://www.apple.com/support/bonjour/ for Windows + - Mac OSX and iOS - support is already built in / no any extra s/w is required + +Prepare the sketch and configuration for initial upload with a serial port +- Start Arduino IDE and load sketch OTAWebUpdater.ino available under File > Examples > OTAWebUpdater.ino +- Update ssid and pass in the sketch so the module can join your Wi-Fi network +- Open File > Preferences, look for “Show verbose output during:” and check out “compilation” option + +![verbrose](esp32verbose.PNG) + +- Upload sketch (Ctrl+U) +- Now open web browser and enter the url, i.e. http://esp32.local. Once entered, browser should display a form + +![login](esp32login.PNG) + +> username= admin + +> password= admin + +**Note**-*If entering “http://ESP32.local” does not work, try replacing “ESP32” with module’s IP address.This workaround is useful in case the host software installed does not work*. + +Now click on Login button and browser will display a upload form + +![upload](esp32upload.PNG) + +For Uploading the New Firmware you need to provide the Binary File of your Code. + +Exporting Binary file of the Firmware (Code) +- Open up the Arduino IDE +- Open up the Code, for Exporting up Binary file +- Now go to Sketch > export compiled Binary +![export](exportTobinary.PNG) + +- Binary file is exported to the same Directory where your code is present + +Once you are comfortable with this procedure go ahead and modify OTAWebUpdater.ino sketch to print some additional messages, compile it, Export new binary file and upload it using web browser to see entered changes on a Serial Monitor + + + diff --git a/docs/OTAWebUpdate/esp32login.PNG b/docs/OTAWebUpdate/esp32login.PNG new file mode 100644 index 00000000000..48c90c7f452 Binary files /dev/null and b/docs/OTAWebUpdate/esp32login.PNG differ diff --git a/docs/OTAWebUpdate/esp32upload.PNG b/docs/OTAWebUpdate/esp32upload.PNG new file mode 100644 index 00000000000..81f2eaba79d Binary files /dev/null and b/docs/OTAWebUpdate/esp32upload.PNG differ diff --git a/docs/OTAWebUpdate/esp32verbose.PNG b/docs/OTAWebUpdate/esp32verbose.PNG new file mode 100644 index 00000000000..bd9c3fc41fe Binary files /dev/null and b/docs/OTAWebUpdate/esp32verbose.PNG differ diff --git a/docs/OTAWebUpdate/exportTobinary.PNG b/docs/OTAWebUpdate/exportTobinary.PNG new file mode 100644 index 00000000000..62d85831724 Binary files /dev/null and b/docs/OTAWebUpdate/exportTobinary.PNG differ diff --git a/libraries/ArduinoOTA/examples/OTAWebUpdater/OTAWebUpdater.ino b/libraries/ArduinoOTA/examples/OTAWebUpdater/OTAWebUpdater.ino index aa8aaf03f4b..ed93c59f975 100644 --- a/libraries/ArduinoOTA/examples/OTAWebUpdater/OTAWebUpdater.ino +++ b/libraries/ArduinoOTA/examples/OTAWebUpdater/OTAWebUpdater.ino @@ -4,93 +4,101 @@ #include #include -const char* host = "ESP32"; +const char* host = "esp32"; const char* ssid = "xxx"; const char* password = "xxxx"; WebServer server(80); -const char* loginIndex = "
" - "" - "" - "" - "
" - "
" - "" - "" - "" - "" - "
" - "
" - "" - "" - "" - "
" - "
" - "" +const char* loginIndex = + "" + "
ESP32 Login Page
" - "
" +/* + * Login page + */ - "
Username:
Password:
" + "" + "" + "
" + "
" + "" + "" + "" + "" + "
" + "
" + "" + "" + "" + "
" + "
" + "" + "" + "" + "" + "
" + "
ESP32 Login Page
" + "
" + "
Username:
Password:
" +"
" +""; + +/* + * Server Index Page + */ + +const char* serverIndex = +"" +"
" + "" + "" + "
" + "
progress: 0%
" + ""; - "" - "" - "" - "" - "" - ""; - - - - - -const char* serverIndex = "" - "
" - "" - "" - "
" - "
progress: 0%
" - ""; +/* + * setup function + */ void setup(void) { Serial.begin(115200); @@ -110,7 +118,7 @@ void setup(void) { Serial.println(WiFi.localIP()); /*use mdns for host name resolution*/ - if (!MDNS.begin(host)) { //http://esp32.local + if (!MDNS.begin(host)) { //http://esp32.local Serial.println("Error setting up MDNS responder!"); while (1) { delay(1000); diff --git a/libraries/AsyncUDP/src/AsyncUDP.cpp b/libraries/AsyncUDP/src/AsyncUDP.cpp index eb4b9621722..6fff201a9bd 100644 --- a/libraries/AsyncUDP/src/AsyncUDP.cpp +++ b/libraries/AsyncUDP/src/AsyncUDP.cpp @@ -286,6 +286,8 @@ AsyncUDPPacket::AsyncUDPPacket(AsyncUDP *udp, pbuf *pb, const ip_addr_t *raddr, _len = pb->len; _index = 0; + pbuf_ref(_pb); + //memcpy(&_remoteIp, raddr, sizeof(ip_addr_t)); _remoteIp.type = raddr->type; _localIp.type = _remoteIp.type; diff --git a/libraries/BluetoothSerial/src/BluetoothSerial.cpp b/libraries/BluetoothSerial/src/BluetoothSerial.cpp index c0b4d5e61d9..a71bd294dd6 100644 --- a/libraries/BluetoothSerial/src/BluetoothSerial.cpp +++ b/libraries/BluetoothSerial/src/BluetoothSerial.cpp @@ -136,6 +136,16 @@ static bool _init_bt(const char *deviceName) } esp_bt_dev_set_device_name(deviceName); + // the default BTA_DM_COD_LOUDSPEAKER does not work with the macOS BT stack + esp_bt_cod_t cod; + cod.major = 0b00001; + cod.minor = 0b000100; + cod.service = 0b00000010110; + if (esp_bt_gap_set_cod(cod, ESP_BT_INIT_COD) != ESP_OK) { + log_e("%s set cod failed\n", __func__); + return false; + } + return true; } diff --git a/libraries/EEPROM/EEPROM.cpp b/libraries/EEPROM/EEPROM.cpp index bc83dbcbd20..0e91f987c4b 100644 --- a/libraries/EEPROM/EEPROM.cpp +++ b/libraries/EEPROM/EEPROM.cpp @@ -24,7 +24,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "Arduino.h" #include "EEPROM.h" #include @@ -296,9 +295,9 @@ String EEPROMClass::readString (int address) if (address + len > _size) return String(0); - char value[len + 1]; + char value[len]; memcpy((uint8_t*) value, _data + address, len); - value[len + 1] = 0; + value[len] = 0; return String(value); } diff --git a/libraries/EEPROM/EEPROM.h b/libraries/EEPROM/EEPROM.h index 2e4383c9bd2..3a9165e3185 100644 --- a/libraries/EEPROM/EEPROM.h +++ b/libraries/EEPROM/EEPROM.h @@ -29,6 +29,7 @@ #ifndef EEPROM_FLASH_PARTITION_NAME #define EEPROM_FLASH_PARTITION_NAME "eeprom" #endif +#include extern "C" { #include diff --git a/libraries/ESP32/examples/GPIOInterrupt/GPIOInterrupt.ino b/libraries/ESP32/examples/GPIOInterrupt/GPIOInterrupt.ino new file mode 100644 index 00000000000..c3d1245fa0c --- /dev/null +++ b/libraries/ESP32/examples/GPIOInterrupt/GPIOInterrupt.ino @@ -0,0 +1,45 @@ +#include + +struct Button { + const uint8_t PIN; + uint32_t numberKeyPresses; + bool pressed; +}; + +Button button1 = {23, 0, false}; +Button button2 = {18, 0, false}; + +void IRAM_ATTR isr(void* arg) { + Button* s = static_cast(arg); + s->numberKeyPresses += 1; + s->pressed = true; +} + +void IRAM_ATTR isr() { + button2.numberKeyPresses += 1; + button2.pressed = true; +} + +void setup() { + Serial.begin(115200); + pinMode(button1.PIN, INPUT_PULLUP); + attachInterruptArg(button1.PIN, isr, &button1, FALLING); + pinMode(button2.PIN, INPUT_PULLUP); + attachInterrupt(button2.PIN, isr, FALLING); +} + +void loop() { + if (button1.pressed) { + Serial.printf("Button 1 has been pressed %u times\n", button1.numberKeyPresses); + button1.pressed = false; + } + if (button2.pressed) { + Serial.printf("Button 2 has been pressed %u times\n", button2.numberKeyPresses); + button2.pressed = false; + } + static uint32_t lastMillis = 0; + if (millis() - lastMillis > 10000) { + lastMillis = millis(); + detachInterrupt(button1.PIN); + } +} diff --git a/libraries/FS/src/FS.h b/libraries/FS/src/FS.h index c27e3a64b89..d63fc5da305 100644 --- a/libraries/FS/src/FS.h +++ b/libraries/FS/src/FS.h @@ -47,7 +47,9 @@ enum SeekMode { class File : public Stream { public: - File(FileImplPtr p = FileImplPtr()) : _p(p) {} + File(FileImplPtr p = FileImplPtr()) : _p(p) { + _timeout = 0; + } size_t write(uint8_t) override; size_t write(const uint8_t *buf, size_t size) override; diff --git a/libraries/HTTPClient/src/HTTPClient.cpp b/libraries/HTTPClient/src/HTTPClient.cpp index d39e89ce7c7..e77c2445218 100644 --- a/libraries/HTTPClient/src/HTTPClient.cpp +++ b/libraries/HTTPClient/src/HTTPClient.cpp @@ -252,7 +252,7 @@ void HTTPClient::end(void) bool HTTPClient::connected() { if(_tcp) { - return (_tcp->connected() || (_tcp->available() > 0)); + return ((_tcp->available() > 0) || _tcp->connected()); } return false; } diff --git a/libraries/WebServer/src/Parsing.cpp b/libraries/WebServer/src/Parsing.cpp index ce206cf0115..119c27bb280 100644 --- a/libraries/WebServer/src/Parsing.cpp +++ b/libraries/WebServer/src/Parsing.cpp @@ -32,6 +32,10 @@ #define DEBUG_OUTPUT Serial #endif +#ifndef WEBSERVER_MAX_POST_ARGS +#define WEBSERVER_MAX_POST_ARGS 32 +#endif + static const char Content_Type[] PROGMEM = "Content-Type"; static const char filename[] PROGMEM = "filename"; @@ -359,7 +363,7 @@ uint8_t WebServer::_uploadReadByte(WiFiClient& client){ int res = client.read(); if(res == -1){ while(!client.available() && client.connected()) - yield(); + delay(2); res = client.read(); } return (uint8_t)res; @@ -383,8 +387,9 @@ bool WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t len){ client.readStringUntil('\n'); //start reading the form if (line == ("--"+boundary)){ - RequestArgument* postArgs = new RequestArgument[32]; - int postArgsLen = 0; + if(_postArgs) delete[] _postArgs; + _postArgs = new RequestArgument[WEBSERVER_MAX_POST_ARGS]; + _postArgsLen = 0; while(1){ String argName; String argValue; @@ -445,7 +450,7 @@ bool WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t len){ DEBUG_OUTPUT.println(); #endif - RequestArgument& arg = postArgs[postArgsLen++]; + RequestArgument& arg = _postArgs[_postArgsLen++]; arg.key = argName; arg.value = argValue; @@ -552,22 +557,25 @@ bool WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t len){ } int iarg; - int totalArgs = ((32 - postArgsLen) < _currentArgCount)?(32 - postArgsLen):_currentArgCount; + int totalArgs = ((WEBSERVER_MAX_POST_ARGS - _postArgsLen) < _currentArgCount)?(WEBSERVER_MAX_POST_ARGS - _postArgsLen):_currentArgCount; for (iarg = 0; iarg < totalArgs; iarg++){ - RequestArgument& arg = postArgs[postArgsLen++]; + RequestArgument& arg = _postArgs[_postArgsLen++]; arg.key = _currentArgs[iarg].key; arg.value = _currentArgs[iarg].value; } if (_currentArgs) delete[] _currentArgs; - _currentArgs = new RequestArgument[postArgsLen]; - for (iarg = 0; iarg < postArgsLen; iarg++){ + _currentArgs = new RequestArgument[_postArgsLen]; + for (iarg = 0; iarg < _postArgsLen; iarg++){ RequestArgument& arg = _currentArgs[iarg]; - arg.key = postArgs[iarg].key; - arg.value = postArgs[iarg].value; + arg.key = _postArgs[iarg].key; + arg.value = _postArgs[iarg].value; } _currentArgCount = iarg; - if (postArgs) - delete[] postArgs; + if (_postArgs) { + delete[] _postArgs; + _postArgs=nullptr; + _postArgsLen = 0; + } return true; } #ifdef DEBUG_ESP_HTTP_SERVER diff --git a/libraries/WebServer/src/WebServer.cpp b/libraries/WebServer/src/WebServer.cpp index 1c966981143..049b412a31f 100644 --- a/libraries/WebServer/src/WebServer.cpp +++ b/libraries/WebServer/src/WebServer.cpp @@ -54,6 +54,8 @@ WebServer::WebServer(IPAddress addr, int port) , _lastHandler(nullptr) , _currentArgCount(0) , _currentArgs(nullptr) +, _postArgsLen(0) +, _postArgs(nullptr) , _headerKeysCount(0) , _currentHeaders(nullptr) , _contentLength(0) @@ -72,6 +74,8 @@ WebServer::WebServer(int port) , _lastHandler(nullptr) , _currentArgCount(0) , _currentArgs(nullptr) +, _postArgsLen(0) +, _postArgs(nullptr) , _headerKeysCount(0) , _currentHeaders(nullptr) , _contentLength(0) @@ -94,11 +98,13 @@ WebServer::~WebServer() { void WebServer::begin() { close(); _server.begin(); + _server.setNoDelay(true); } void WebServer::begin(uint16_t port) { close(); _server.begin(port); + _server.setNoDelay(true); } String WebServer::_extractParam(String& authReq,const String& param,const char delimit){ @@ -505,6 +511,10 @@ void WebServer::_streamFileCore(const size_t fileSize, const String & fileName, String WebServer::arg(String name) { + for (int j = 0; j < _postArgsLen; ++j) { + if ( _postArgs[j].key == name ) + return _postArgs[j].value; + } for (int i = 0; i < _currentArgCount; ++i) { if ( _currentArgs[i].key == name ) return _currentArgs[i].value; @@ -529,6 +539,10 @@ int WebServer::args() { } bool WebServer::hasArg(String name) { + for (int j = 0; j < _postArgsLen; ++j) { + if (_postArgs[j].key == name) + return true; + } for (int i = 0; i < _currentArgCount; ++i) { if (_currentArgs[i].key == name) return true; diff --git a/libraries/WebServer/src/WebServer.h b/libraries/WebServer/src/WebServer.h index 11564c0dc0c..adc754f8bd3 100644 --- a/libraries/WebServer/src/WebServer.h +++ b/libraries/WebServer/src/WebServer.h @@ -34,10 +34,10 @@ enum HTTPUploadStatus { UPLOAD_FILE_START, UPLOAD_FILE_WRITE, UPLOAD_FILE_END, enum HTTPClientStatus { HC_NONE, HC_WAIT_READ, HC_WAIT_CLOSE }; enum HTTPAuthMethod { BASIC_AUTH, DIGEST_AUTH }; -#define HTTP_DOWNLOAD_UNIT_SIZE 1460 +#define HTTP_DOWNLOAD_UNIT_SIZE 1436 #ifndef HTTP_UPLOAD_BUFLEN -#define HTTP_UPLOAD_BUFLEN 2048 +#define HTTP_UPLOAD_BUFLEN 1436 #endif #define HTTP_MAX_DATA_WAIT 5000 //ms to wait for the client to send the request @@ -179,6 +179,9 @@ class WebServer int _currentArgCount; RequestArgument* _currentArgs; + int _postArgsLen; + RequestArgument* _postArgs; + std::unique_ptr _currentUpload; int _headerKeysCount; diff --git a/libraries/WiFi/examples/WiFiTelnetToSerial/WiFiTelnetToSerial.ino b/libraries/WiFi/examples/WiFiTelnetToSerial/WiFiTelnetToSerial.ino index 6821b057853..63bdf6c13b6 100644 --- a/libraries/WiFi/examples/WiFiTelnetToSerial/WiFiTelnetToSerial.ino +++ b/libraries/WiFi/examples/WiFiTelnetToSerial/WiFiTelnetToSerial.ino @@ -31,8 +31,6 @@ const char* password = "**********"; WiFiServer server(23); WiFiClient serverClients[MAX_SRV_CLIENTS]; -HardwareSerial Serial1(2); // UART1/Serial1 pins 16,17 - void setup() { Serial.begin(115200); Serial.println("\nConnecting"); @@ -62,7 +60,7 @@ void setup() { } //start UART and the server - Serial1.begin(9600); + Serial2.begin(9600); server.begin(); server.setNoDelay(true); @@ -98,7 +96,7 @@ void loop() { if (serverClients[i] && serverClients[i].connected()){ if(serverClients[i].available()){ //get data from the telnet client and push it to the UART - while(serverClients[i].available()) Serial1.write(serverClients[i].read()); + while(serverClients[i].available()) Serial2.write(serverClients[i].read()); } } else { @@ -108,10 +106,10 @@ void loop() { } } //check UART for data - if(Serial1.available()){ - size_t len = Serial1.available(); + if(Serial2.available()){ + size_t len = Serial2.available(); uint8_t sbuf[len]; - Serial1.readBytes(sbuf, len); + Serial2.readBytes(sbuf, len); //push UART data to all connected telnet clients for(i = 0; i < MAX_SRV_CLIENTS; i++){ if (serverClients[i] && serverClients[i].connected()){ diff --git a/libraries/WiFi/src/WiFiAP.cpp b/libraries/WiFi/src/WiFiAP.cpp index c0c8402856e..f4a2fa54493 100644 --- a/libraries/WiFi/src/WiFiAP.cpp +++ b/libraries/WiFi/src/WiFiAP.cpp @@ -184,6 +184,11 @@ bool WiFiAPClass::softAPdisconnect(bool wifioff) { bool ret; wifi_config_t conf; + + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return ESP_ERR_INVALID_STATE; + } + *conf.ap.ssid = 0; *conf.ap.password = 0; conf.ap.authmode = WIFI_AUTH_OPEN; // auth must be open if pass=0 @@ -204,6 +209,9 @@ bool WiFiAPClass::softAPdisconnect(bool wifioff) uint8_t WiFiAPClass::softAPgetStationNum() { wifi_sta_list_t clients; + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return 0; + } if(esp_wifi_ap_get_sta_list(&clients) == ESP_OK) { return clients.num; } @@ -217,6 +225,9 @@ uint8_t WiFiAPClass::softAPgetStationNum() IPAddress WiFiAPClass::softAPIP() { tcpip_adapter_ip_info_t ip; + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return IPAddress(); + } tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_AP, &ip); return IPAddress(ip.ip.addr); } @@ -229,7 +240,9 @@ IPAddress WiFiAPClass::softAPIP() */ uint8_t* WiFiAPClass::softAPmacAddress(uint8_t* mac) { - esp_wifi_get_mac(WIFI_IF_AP, mac); + if(WiFiGenericClass::getMode() != WIFI_MODE_NULL){ + esp_wifi_get_mac(WIFI_IF_AP, mac); + } return mac; } @@ -241,6 +254,9 @@ String WiFiAPClass::softAPmacAddress(void) { uint8_t mac[6]; char macStr[18] = { 0 }; + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return String(); + } esp_wifi_get_mac(WIFI_IF_AP, mac); sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); @@ -253,9 +269,12 @@ String WiFiAPClass::softAPmacAddress(void) */ const char * WiFiAPClass::softAPgetHostname() { - const char * hostname; + const char * hostname = NULL; + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return hostname; + } if(tcpip_adapter_get_hostname(TCPIP_ADAPTER_IF_AP, &hostname)) { - return NULL; + return hostname; } return hostname; } @@ -267,6 +286,9 @@ const char * WiFiAPClass::softAPgetHostname() */ bool WiFiAPClass::softAPsetHostname(const char * hostname) { + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return false; + } return tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_AP, hostname) == ESP_OK; } @@ -276,6 +298,9 @@ bool WiFiAPClass::softAPsetHostname(const char * hostname) */ bool WiFiAPClass::softAPenableIpV6() { + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return false; + } return tcpip_adapter_create_ip6_linklocal(TCPIP_ADAPTER_IF_AP) == ESP_OK; } @@ -286,6 +311,9 @@ bool WiFiAPClass::softAPenableIpV6() IPv6Address WiFiAPClass::softAPIPv6() { static ip6_addr_t addr; + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return IPv6Address(); + } if(tcpip_adapter_get_ip6_linklocal(TCPIP_ADAPTER_IF_AP, &addr)) { return IPv6Address(); } diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp index e496160fc86..845f2b4d5cb 100644 --- a/libraries/WiFi/src/WiFiClient.cpp +++ b/libraries/WiFi/src/WiFiClient.cpp @@ -31,6 +31,118 @@ #undef write #undef read +class WiFiClientRxBuffer { +private: + size_t _size; + uint8_t *_buffer; + size_t _pos; + size_t _fill; + int _fd; + bool _failed; + + size_t r_available() + { + if(_fd < 0){ + return 0; + } + int count; + int res = lwip_ioctl_r(_fd, FIONREAD, &count); + if(res < 0) { + _failed = true; + return 0; + } + return count; + } + + size_t fillBuffer() + { + if(!_buffer){ + _buffer = (uint8_t *)malloc(_size); + } + if(_fill && _pos == _fill){ + _fill = 0; + _pos = 0; + } + if(!_buffer || _size <= _fill || !r_available()) { + return 0; + } + int res = recv(_fd, _buffer + _fill, _size - _fill, MSG_DONTWAIT); + if(res < 0 && errno != EWOULDBLOCK) { + _failed = true; + return 0; + } + _fill += res; + return res; + } + +public: + WiFiClientRxBuffer(int fd, size_t size=1436) + :_size(size) + ,_buffer(NULL) + ,_pos(0) + ,_fill(0) + ,_fd(fd) + ,_failed(false) + { + //_buffer = (uint8_t *)malloc(_size); + } + + ~WiFiClientRxBuffer() + { + free(_buffer); + } + + bool failed(){ + return _failed; + } + + int read(uint8_t * dst, size_t len){ + if(!dst || !len || (_pos == _fill && !fillBuffer())){ + return -1; + } + size_t a = _fill - _pos; + if(len <= a || ((len - a) <= (_size - _fill) && fillBuffer() >= (len - a))){ + if(len == 1){ + *dst = _buffer[_pos]; + } else { + memcpy(dst, _buffer + _pos, len); + } + _pos += len; + return len; + } + size_t left = len; + size_t toRead = a; + uint8_t * buf = dst; + memcpy(buf, _buffer + _pos, toRead); + _pos += toRead; + left -= toRead; + buf += toRead; + while(left){ + if(!fillBuffer()){ + return len - left; + } + a = _fill - _pos; + toRead = (a > left)?left:a; + memcpy(buf, _buffer + _pos, toRead); + _pos += toRead; + left -= toRead; + buf += toRead; + } + return len; + } + + int peek(){ + if(_pos == _fill && !fillBuffer()){ + return -1; + } + return _buffer[_pos]; + } + + size_t available(){ + return _fill - _pos + r_available(); + } +}; + class WiFiClientSocketHandle { private: int sockfd; @@ -58,6 +170,7 @@ WiFiClient::WiFiClient():_connected(false),next(NULL) WiFiClient::WiFiClient(int fd):_connected(true),next(NULL) { clientSocketHandle.reset(new WiFiClientSocketHandle(fd)); + _rxBuffer.reset(new WiFiClientRxBuffer(fd)); } WiFiClient::~WiFiClient() @@ -69,6 +182,7 @@ WiFiClient & WiFiClient::operator=(const WiFiClient &other) { stop(); clientSocketHandle = other.clientSocketHandle; + _rxBuffer = other._rxBuffer; _connected = other._connected; return *this; } @@ -76,6 +190,7 @@ WiFiClient & WiFiClient::operator=(const WiFiClient &other) void WiFiClient::stop() { clientSocketHandle = NULL; + _rxBuffer = NULL; _connected = false; } @@ -100,6 +215,7 @@ int WiFiClient::connect(IPAddress ip, uint16_t port) return 0; } clientSocketHandle.reset(new WiFiClientSocketHandle(sockfd)); + _rxBuffer.reset(new WiFiClientRxBuffer(sockfd)); _connected = true; return 1; } @@ -260,11 +376,9 @@ size_t WiFiClient::write(Stream &stream) int WiFiClient::read(uint8_t *buf, size_t size) { - if(!available()) { - return -1; - } - int res = recv(fd(), buf, size, MSG_DONTWAIT); - if(res < 0 && errno != EWOULDBLOCK) { + int res = -1; + res = _rxBuffer->read(buf, size); + if(_rxBuffer->failed()) { log_e("%d", errno); stop(); } @@ -273,16 +387,12 @@ int WiFiClient::read(uint8_t *buf, size_t size) int WiFiClient::peek() { - if(!available()) { - return -1; - } - uint8_t data = 0; - int res = recv(fd(), &data, 1, MSG_PEEK); - if(res < 0 && errno != EWOULDBLOCK) { + int res = _rxBuffer->peek(); + if(_rxBuffer->failed()) { log_e("%d", errno); stop(); } - return data; + return res; } int WiFiClient::available() @@ -290,14 +400,12 @@ int WiFiClient::available() if(!_connected) { return 0; } - int count; - int res = lwip_ioctl_r(fd(), FIONREAD, &count); - if(res < 0) { + int res = _rxBuffer->available(); + if(_rxBuffer->failed()) { log_e("%d", errno); stop(); - return 0; } - return count; + return res; } // Though flushing means to send all pending data, @@ -330,22 +438,23 @@ uint8_t WiFiClient::connected() if (_connected) { uint8_t dummy; int res = recv(fd(), &dummy, 0, MSG_DONTWAIT); - if (res < 0) { - switch (errno) { - case ENOTCONN: - case EPIPE: - case ECONNRESET: - case ECONNREFUSED: - case ECONNABORTED: - _connected = false; - break; - default: - _connected = true; - break; - } - } - else { - _connected = true; + switch (errno) { + case EWOULDBLOCK: + case ENOENT: //caused by vfs + _connected = true; + break; + case ENOTCONN: + case EPIPE: + case ECONNRESET: + case ECONNREFUSED: + case ECONNABORTED: + _connected = false; + log_d("Disconnected: RES: %d, ERR: %d", res, errno); + break; + default: + log_i("Unexpected: RES: %d, ERR: %d", res, errno); + _connected = true; + break; } } return _connected; diff --git a/libraries/WiFi/src/WiFiClient.h b/libraries/WiFi/src/WiFiClient.h index 7f6cd2744ee..78f3fd94772 100644 --- a/libraries/WiFi/src/WiFiClient.h +++ b/libraries/WiFi/src/WiFiClient.h @@ -28,11 +28,13 @@ #include class WiFiClientSocketHandle; +class WiFiClientRxBuffer; class WiFiClient : public Client { protected: std::shared_ptr clientSocketHandle; + std::shared_ptr _rxBuffer; bool _connected; public: diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp index b09e2d74a04..f4d86875804 100644 --- a/libraries/WiFi/src/WiFiGeneric.cpp +++ b/libraries/WiFi/src/WiFiGeneric.cpp @@ -334,7 +334,7 @@ void WiFiGenericClass::removeEvent(wifi_event_id_t id) * @param arg */ #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_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", "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 #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" }; @@ -365,17 +365,29 @@ esp_err_t WiFiGenericClass::_eventCallback(void *arg, system_event_t *event) } else if(reason == WIFI_REASON_BEACON_TIMEOUT || reason == WIFI_REASON_HANDSHAKE_TIMEOUT) { WiFiSTAClass::_setStatus(WL_CONNECTION_LOST); } else if(reason == WIFI_REASON_AUTH_EXPIRE) { - if(WiFi.getAutoReconnect()){ - WiFi.begin(); - } + } else { WiFiSTAClass::_setStatus(WL_DISCONNECTED); } clearStatusBits(STA_CONNECTED_BIT | STA_HAS_IP_BIT | STA_HAS_IP6_BIT); - if(reason >= WIFI_REASON_BEACON_TIMEOUT && reason != WIFI_REASON_AUTH_FAIL && WiFi.getAutoReconnect()){ + if(((reason == WIFI_REASON_AUTH_EXPIRE) || + (reason >= WIFI_REASON_BEACON_TIMEOUT && reason != WIFI_REASON_AUTH_FAIL)) && + WiFi.getAutoReconnect()) + { + WiFi.enableSTA(false); + WiFi.enableSTA(true); WiFi.begin(); } } else if(event->event_id == SYSTEM_EVENT_STA_GOT_IP) { +#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG + uint8_t * ip = (uint8_t *)&(event->event_info.got_ip.ip_info.ip.addr); + uint8_t * mask = (uint8_t *)&(event->event_info.got_ip.ip_info.netmask.addr); + uint8_t * gw = (uint8_t *)&(event->event_info.got_ip.ip_info.gw.addr); + log_d("STA IP: %u.%u.%u.%u, MASK: %u.%u.%u.%u, GW: %u.%u.%u.%u", + ip[0], ip[1], ip[2], ip[3], + mask[0], mask[1], mask[2], mask[3], + gw[0], gw[1], gw[2], gw[3]); +#endif WiFiSTAClass::_setStatus(WL_CONNECTED); setStatusBits(STA_HAS_IP_BIT | STA_CONNECTED_BIT); } else if(event->event_id == SYSTEM_EVENT_STA_LOST_IP) { @@ -403,6 +415,15 @@ esp_err_t WiFiGenericClass::_eventCallback(void *arg, system_event_t *event) } else if(event->event_id == SYSTEM_EVENT_ETH_DISCONNECTED) { clearStatusBits(ETH_CONNECTED_BIT | ETH_HAS_IP_BIT | ETH_HAS_IP6_BIT); } else if(event->event_id == SYSTEM_EVENT_ETH_GOT_IP) { +#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG + uint8_t * ip = (uint8_t *)&(event->event_info.got_ip.ip_info.ip.addr); + uint8_t * mask = (uint8_t *)&(event->event_info.got_ip.ip_info.netmask.addr); + uint8_t * gw = (uint8_t *)&(event->event_info.got_ip.ip_info.gw.addr); + log_d("ETH IP: %u.%u.%u.%u, MASK: %u.%u.%u.%u, GW: %u.%u.%u.%u", + ip[0], ip[1], ip[2], ip[3], + mask[0], mask[1], mask[2], mask[3], + gw[0], gw[1], gw[2], gw[3]); +#endif setStatusBits(ETH_CONNECTED_BIT | ETH_HAS_IP_BIT); } else if(event->event_id == SYSTEM_EVENT_GOT_IP6) { diff --git a/libraries/WiFi/src/WiFiSTA.cpp b/libraries/WiFi/src/WiFiSTA.cpp index 99024e106d8..f1ffa1f1f4f 100644 --- a/libraries/WiFi/src/WiFiSTA.cpp +++ b/libraries/WiFi/src/WiFiSTA.cpp @@ -399,6 +399,9 @@ uint8_t WiFiSTAClass::waitForConnectResult() */ IPAddress WiFiSTAClass::localIP() { + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return IPAddress(); + } tcpip_adapter_ip_info_t ip; tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip); return IPAddress(ip.ip.addr); @@ -412,7 +415,9 @@ IPAddress WiFiSTAClass::localIP() */ uint8_t* WiFiSTAClass::macAddress(uint8_t* mac) { - esp_wifi_get_mac(WIFI_IF_STA, mac); + if(WiFiGenericClass::getMode() != WIFI_MODE_NULL){ + esp_wifi_get_mac(WIFI_IF_STA, mac); + } return mac; } @@ -424,6 +429,9 @@ String WiFiSTAClass::macAddress(void) { uint8_t mac[6]; char macStr[18] = { 0 }; + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return String(); + } esp_wifi_get_mac(WIFI_IF_STA, mac); sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); @@ -436,6 +444,9 @@ String WiFiSTAClass::macAddress(void) */ IPAddress WiFiSTAClass::subnetMask() { + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return IPAddress(); + } tcpip_adapter_ip_info_t ip; tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip); return IPAddress(ip.netmask.addr); @@ -447,6 +458,9 @@ IPAddress WiFiSTAClass::subnetMask() */ IPAddress WiFiSTAClass::gatewayIP() { + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return IPAddress(); + } tcpip_adapter_ip_info_t ip; tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip); return IPAddress(ip.gw.addr); @@ -459,6 +473,9 @@ IPAddress WiFiSTAClass::gatewayIP() */ IPAddress WiFiSTAClass::dnsIP(uint8_t dns_no) { + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return IPAddress(); + } ip_addr_t dns_ip = dns_getserver(dns_no); return IPAddress(dns_ip.u_addr.ip4.addr); } @@ -469,6 +486,9 @@ IPAddress WiFiSTAClass::dnsIP(uint8_t dns_no) */ String WiFiSTAClass::SSID() const { + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return String(); + } wifi_ap_record_t info; if(!esp_wifi_sta_get_ap_info(&info)) { return String(reinterpret_cast(info.ssid)); @@ -482,6 +502,9 @@ String WiFiSTAClass::SSID() const */ String WiFiSTAClass::psk() const { + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return String(); + } wifi_config_t conf; esp_wifi_get_config(WIFI_IF_STA, &conf); return String(reinterpret_cast(conf.sta.password)); @@ -495,6 +518,9 @@ uint8_t* WiFiSTAClass::BSSID(void) { static uint8_t bssid[6]; wifi_ap_record_t info; + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return NULL; + } if(!esp_wifi_sta_get_ap_info(&info)) { memcpy(bssid, info.bssid, 6); return reinterpret_cast(bssid); @@ -523,6 +549,9 @@ String WiFiSTAClass::BSSIDstr(void) */ int8_t WiFiSTAClass::RSSI(void) { + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return 0; + } wifi_ap_record_t info; if(!esp_wifi_sta_get_ap_info(&info)) { return info.rssi; @@ -536,7 +565,10 @@ int8_t WiFiSTAClass::RSSI(void) */ const char * WiFiSTAClass::getHostname() { - const char * hostname; + const char * hostname = NULL; + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return hostname; + } if(tcpip_adapter_get_hostname(TCPIP_ADAPTER_IF_STA, &hostname)){ return NULL; } @@ -550,6 +582,9 @@ const char * WiFiSTAClass::getHostname() */ bool WiFiSTAClass::setHostname(const char * hostname) { + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return false; + } return tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, hostname) == 0; } @@ -559,6 +594,9 @@ bool WiFiSTAClass::setHostname(const char * hostname) */ bool WiFiSTAClass::enableIpV6() { + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return false; + } return tcpip_adapter_create_ip6_linklocal(TCPIP_ADAPTER_IF_STA) == 0; } @@ -569,6 +607,9 @@ bool WiFiSTAClass::enableIpV6() IPv6Address WiFiSTAClass::localIPv6() { static ip6_addr_t addr; + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return IPv6Address(); + } if(tcpip_adapter_get_ip6_linklocal(TCPIP_ADAPTER_IF_STA, &addr)){ return IPv6Address(); } diff --git a/libraries/Wire/src/Wire.cpp b/libraries/Wire/src/Wire.cpp index d3197e95f19..7109835dcbf 100644 --- a/libraries/Wire/src/Wire.cpp +++ b/libraries/Wire/src/Wire.cpp @@ -364,3 +364,4 @@ void TwoWire::dumpI2C() } TwoWire Wire = TwoWire(0); +TwoWire Wire1 = TwoWire(1); diff --git a/libraries/Wire/src/Wire.h b/libraries/Wire/src/Wire.h index cdf50fd5e67..755c815045c 100644 --- a/libraries/Wire/src/Wire.h +++ b/libraries/Wire/src/Wire.h @@ -134,6 +134,7 @@ class TwoWire: public Stream }; extern TwoWire Wire; +extern TwoWire Wire1; /* diff --git a/package/package_esp32_index.template.json b/package/package_esp32_index.template.json index 4bbe6da664f..a03f263984a 100644 --- a/package/package_esp32_index.template.json +++ b/package/package_esp32_index.template.json @@ -38,7 +38,7 @@ { "packager": "esp32", "name": "esptool", - "version": "da31d9d2" + "version": "2.3.1" }, { "packager": "esp32", @@ -85,41 +85,41 @@ }, { "name": "esptool", - "version": "da31d9d2", + "version": "2.3.1", "systems": [ { "host": "i686-mingw32", - "url": "https://dl.espressif.com/dl/esptool-da31d9d2-windows.zip", - "archiveFileName": "esptool-da31d9d2-windows.zip", - "checksum": "SHA-256:5e3b5154b9adaf38aeb580222b434bf6e9381a8b989e227f3ad6b2cecc56a57b", + "url": "https://dl.espressif.com/dl/esptool-2.3.1-windows.zip", + "archiveFileName": "esptool-2.3.1-windows.zip", + "checksum": "SHA-256:c187763d0faac7da7c30a292a23c759bbc256fcd084dc8846ed284000cb0fe29", "size": "3396085" }, { "host": "x86_64-apple-darwin", - "url": "https://dl.espressif.com/dl/esptool-da31d9d2-macos.tar.gz", - "archiveFileName": "esptool-da31d9d2-macos.tar.gz", - "checksum": "SHA-256:00f2c16e3b44064596e883fcb20392c9e52ebf74484672170fbeb4c6641e37cc", - "size": "3810936" + "url": "https://dl.espressif.com/dl/esptool-2.3.1-macos.tar.gz", + "archiveFileName": "esptool-2.3.1-macos.tar.gz", + "checksum": "SHA-256:cd922418f02e0ca11dc066b36a22646a1b441da00d762b4464ca598c902c5ecb", + "size": "3810932" }, { "host": "x86_64-pc-linux-gnu", - "url": "https://dl.espressif.com/dl/esptool-da31d9d2-linux.tar.gz", - "archiveFileName": "esptool-da31d9d2-linux.tar.gz", - "checksum": "SHA-256:a8a23028bde25b25fae39554b4e6138592ef18e099bfeb239b4a003a2ae3f55c", + "url": "https://dl.espressif.com/dl/esptool-2.3.1-linux.tar.gz", + "archiveFileName": "esptool-2.3.1-linux.tar.gz", + "checksum": "SHA-256:cff30841dad80ed5d7d2d58a31843b63afa57528979a9c839806568167691d8e", "size": "39563" }, { "host": "i686-pc-linux-gnu", - "url": "https://dl.espressif.com/dl/esptool-da31d9d2-linux.tar.gz", - "archiveFileName": "esptool-da31d9d2-linux.tar.gz", - "checksum": "SHA-256:a8a23028bde25b25fae39554b4e6138592ef18e099bfeb239b4a003a2ae3f55c", + "url": "https://dl.espressif.com/dl/esptool-2.3.1-linux.tar.gz", + "archiveFileName": "esptool-2.3.1-linux.tar.gz", + "checksum": "SHA-256:cff30841dad80ed5d7d2d58a31843b63afa57528979a9c839806568167691d8e", "size": "39563" }, { "host": "arm-linux-gnueabihf", - "url": "https://dl.espressif.com/dl/esptool-da31d9d2-linux.tar.gz", - "archiveFileName": "esptool-da31d9d2-linux.tar.gz", - "checksum": "SHA-256:a8a23028bde25b25fae39554b4e6138592ef18e099bfeb239b4a003a2ae3f55c", + "url": "https://dl.espressif.com/dl/esptool-2.3.1-linux.tar.gz", + "archiveFileName": "esptool-2.3.1-linux.tar.gz", + "checksum": "SHA-256:cff30841dad80ed5d7d2d58a31843b63afa57528979a9c839806568167691d8e", "size": "39563" } ] diff --git a/platform.txt b/platform.txt index b7764fe1f39..cd6078df584 100644 --- a/platform.txt +++ b/platform.txt @@ -49,7 +49,8 @@ build.flash_size=4MB build.flash_mode=dio build.boot=bootloader build.code_debug=0 -build.extra_flags=-DESP32 -DCORE_DEBUG_LEVEL={build.code_debug} +build.defines= +build.extra_flags=-DESP32 -DCORE_DEBUG_LEVEL={build.code_debug} {build.defines} # These can be overridden in platform.local.txt compiler.c.extra_flags= diff --git a/tools/build-release.sh b/tools/build-release.sh index d53e5389989..03667177c6e 100755 --- a/tools/build-release.sh +++ b/tools/build-release.sh @@ -36,6 +36,8 @@ function downloadAndMergePackageJSON() #curl --verbose -sH "Authorization: token $curlAuthToken" -L -o "$old_json" "$jsonLink" curl -L -o "$old_json" "$jsonLink?access_token=$curlAuthToken" + if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi + #curl -L -o "$old_json" "$jsonLink" @@ -227,6 +229,7 @@ find $outdir -name '*.DS_Store' -exec rm -f {} \; # handles tool paths differently when package is installed in hardware folder echo " - updating platform.txt..." cat $srcdir/platform.txt | \ +sed "s/version=.*/version=$ver$extent/g" | \ sed 's/runtime.tools.xtensa-esp32-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32-elf//g' | \ sed 's/tools.esptool.path={runtime.platform.path}\/tools\/esptool/tools.esptool.path=\{runtime.tools.esptool.path\}/g' \ > $outdir/platform.txt @@ -255,10 +258,7 @@ echo " - creating package ZIP archive (${package_name_zip})..." pushd $releaseDir >/dev/null zip -qr $package_name_zip $package_name -if [ $? -ne 0 ]; then - echo " !error: failed to create ${package_name_zip} (ZIP errno: $?) => aborting" - exit 1 -fi +if [ $? -ne 0 ]; then echo " !error: failed to create ${package_name_zip} (ZIP errno: $?) => aborting"; exit 1; fi # Calculate SHA sum and size of ZIP archive sha=`shasum -a 256 $package_name_zip | cut -f 1 -d ' '` @@ -296,6 +296,7 @@ set +e releasesJson=$releaseDir/releases.json curl -sH "Authorization: token $curlAuth" https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases > $releasesJson +if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi prev_release=$(jq -e -r '. | map(select(.draft == false and .prerelease == false)) | sort_by(.created_at | - fromdateiso8601) | .[0].tag_name' ${releasesJson}) prev_any_release=$(jq -e -r '. | map(select(.draft == false)) | sort_by(.created_at | - fromdateiso8601) | .[0].tag_name' ${releasesJson}) @@ -314,8 +315,8 @@ set -e rm -f "$releasesJson" echo " previous Release: $prev_release" -echo " previous (?Pre-)release: $prev_any_release" echo " previous Pre-release: $prev_pre_release" +echo " previous (any)release: $prev_any_release" # add generated items to JSON package-definition contents jq_arg=".packages[0].platforms[0].version = \"$ver\" | \ diff --git a/tools/deploy.sh b/tools/deploy.sh index f4e1969a491..3b008767599 100644 --- a/tools/deploy.sh +++ b/tools/deploy.sh @@ -1,5 +1,11 @@ #!/bin/bash + +json_escape () { + printf '%s' "$1" | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))' + #printf '%s' "$1" | php -r 'echo json_encode(file_get_contents("php://stdin"));' +} + set -e #Cmdline options @@ -77,6 +83,11 @@ shopt -u nocasematch # other lines: converted to bullets # empty lines ignored # if '* ' found as a first char pair, it's converted to '- ' to keep bulleting unified +echo +echo Preparing release notes +echo ----------------------- +echo "Tag's message:" + relNotesRaw=`git show -s --format=%b $varTagName` readarray -t msgArray <<<"$relNotesRaw" @@ -85,58 +96,124 @@ if [ $arrLen > 3 ]; then ind=3 while [ $ind -lt $arrLen ]; do if [ $ind -eq 3 ]; then - releaseNotes="#### ${msgArray[ind]}\\n" + releaseNotes="#### ${msgArray[ind]}" + releaseNotes+=$'\r\n' else oneLine="$(echo -e "${msgArray[ind]}" | sed -e 's/^[[:space:]]*//')" if [ ${#oneLine} -gt 0 ]; then if [ "${oneLine:0:2}" == "* " ]; then oneLine=$(echo ${oneLine/\*/-}); fi if [ "${oneLine:0:2}" != "- " ]; then releaseNotes+="- "; fi - releaseNotes+="$oneLine\\n" + releaseNotes+="$oneLine" + releaseNotes+=$'\r\n' + + #debug output + echo " ${oneLine}" fi fi let ind=$ind+1 done else - releaseNotes="#### Release of $varTagName\\n" + releaseNotes="#### Release of $varTagName" + releaseNotes+=$'\r\n' + + #debug output + echo " Release of $varTagName" fi # - list of commits (commits.txt must exit in the output dir) commitFile=$varAssetsDir/commits.txt -if [ -e "$commitFile" ]; then +if [ -s "$commitFile" ]; then - releaseNotes+="\\n##### Commits\\n" + releaseNotes+=$'\r\n##### Commits\r\n' + echo + echo "Commits:" + IFS=$'\n' for next in `cat $commitFile` do IFS=' ' read -r commitId commitMsg <<< "$next" - releaseNotes+="- [$commitId](https://github.com/$varRepoSlug/commit/$commitId) $commitMsg\\n" + commitLine="- [$commitId](https://github.com/$varRepoSlug/commit/$commitId) $commitMsg" + echo " $commitLine" + + releaseNotes+="$commitLine" + releaseNotes+=$'\r\n' done rm -f $commitFile fi -releaseNotes=$(perl -pe 's/\r?\n/\\n/' <<< ${releaseNotes}) - # Check possibly existing release for current tag -echo "Checking for possible releases of current tag $varTagName..." -# (eg build invoked by Create New Release GHUI button -> GH default release pack created immediatelly including default assests) +echo +echo "Processing GitHub release record for $varTagName:" +echo "-------------------------------------------------" + +echo " - check $varTagName possible existence..." + +# (eg build invoked by Create New Release GHUI button -> GH default release pack created immediately including default assests) HTTP_RESPONSE=$(curl -L --silent --write-out "HTTPSTATUS:%{http_code}" https://api.github.com/repos/$varRepoSlug/releases/tags/$varTagName?access_token=$varAccessToken) +if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi + HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g') HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') - -echo " HTTP server response code: $HTTP_STATUS" +echo " ---> GitHub server HTTP response: $HTTP_STATUS" # if the release exists, append/update recent files to its assets vector if [ $HTTP_STATUS -eq 200 ]; then releaseId=$(echo $HTTP_BODY | jq -r '.id') echo " - $varTagName release found (id $releaseId)" + + #Merge release notes and overwrite pre-release flag. all other attributes remain unchanged: + + # 1. take existing notes from server (added by release creator) + releaseNotesGH=$(echo $HTTP_BODY | jq -r '.body') + + # - strip possibly trailing CR + if [ "${releaseNotesGH: -1}" == $'\r' ]; then + releaseNotesTemp="${releaseNotesGH:0:-1}" + else + releaseNotesTemp="$releaseNotesGH" + fi + # - add CRLF to make relnotes consistent for JSON encoding + releaseNotesTemp+=$'\r\n' + + # 2. #append generated relnotes (usually commit oneliners) + releaseNotes="$releaseNotesTemp$releaseNotes" + + # 3. JSON-encode whole string for GH API transfer + releaseNotes=$(json_escape "$releaseNotes") + + # 4. remove extra quotes returned by python (dummy but whatever) + releaseNotes=${releaseNotes:1:-1} + + #Update current GH release record + echo " - updating release notes and pre-release flag:" + + curlData="{\"body\": \"$releaseNotes\",\"prerelease\": $varPrerelease}" + echo " $curlData" + echo + #echo "DEBUG: curl --data \"$curlData\" https://api.github.com/repos/$varRepoSlug/releases/$releaseId?access_token=$varAccessToken" + + curl --data "$curlData" https://api.github.com/repos/$varRepoSlug/releases/$releaseId?access_token=$varAccessToken + if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi + + echo " - $varTagName release record successfully updated" + #... or create a new release record else + releaseNotes=$(json_escape "$releaseNotes") + releaseNotes=${releaseNotes:1:-1} + + echo " - release $varTagName not found, creating a new record:" + curlData="{\"tag_name\": \"$varTagName\",\"target_commitish\": \"master\",\"name\": \"v$varTagName\",\"body\": \"$releaseNotes\",\"draft\": false,\"prerelease\": $varPrerelease}" + echo " $curlData" + #echo "DEBUG: curl --data \"${curlData}\" https://api.github.com/repos/${varRepoSlug}/releases?access_token=$varAccessToken | jq -r '.id'" releaseId=$(curl --data "$curlData" https://api.github.com/repos/$varRepoSlug/releases?access_token=$varAccessToken | jq -r '.id') - echo " - new release created for $varTagName (id $releaseId)" + if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi + + echo " - $varTagName release record successfully created (id $releaseId)" fi # Assets defined by dir contents @@ -149,22 +226,26 @@ if [ ! -z $varAssetsDir ]; then done fi -echo -echo varAssets: $varAssets - #Upload additional assets if [ ! -z $varAssets ]; then + echo + echo "Uploading assets:" + echo "-----------------" + echo " Files to upload:" + echo " $varAssets" + echo + curlAuth="Authorization: token $varAccessToken" for filename in $(echo $varAssets | tr ";" "\n") do + echo " - ${filename}:" + curl -X POST -sH "$curlAuth" -H "Content-Type: application/octet-stream" --data-binary @"$filename" https://uploads.github.com/repos/$varRepoSlug/releases/$releaseId/assets?name=$(basename $filename) + + if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi + + echo + echo "OK" echo - echo Uploading $filename... - curl -X POST -sH "$curlAuth" -H "Content-Type: application/octet-stream" --data-binary @"$filename" https://uploads.github.com/repos/$varRepoSlug/releases/$releaseId/assets?name=$(basename $filename) done fi - -echo -echo - - diff --git a/variants/alksesp32/pins_arduino.h b/variants/alksesp32/pins_arduino.h new file mode 100644 index 00000000000..540669eca73 --- /dev/null +++ b/variants/alksesp32/pins_arduino.h @@ -0,0 +1,82 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define EXTERNAL_NUM_INTERRUPTS 16 +#define NUM_DIGITAL_PINS 40 +#define NUM_ANALOG_INPUTS 16 + +#define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1) +#define digitalPinToInterrupt(p) (((p)<40)?(p):-1) +#define digitalPinHasPWM(p) (p < 34) + +#define ALKSESP32 // tell library to not map pins again + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t D0 = 40; +static const uint8_t D1 = 41; +static const uint8_t D2 = 15; +static const uint8_t D3 = 2; +static const uint8_t D4 = 0; +static const uint8_t D5 = 4; +static const uint8_t D6 = 16; +static const uint8_t D7 = 17; +static const uint8_t D8 = 5; +static const uint8_t D9 = 18; +static const uint8_t D10 = 19; +static const uint8_t D11 = 21; +static const uint8_t D12 = 22; +static const uint8_t D13 = 23; + +static const uint8_t A0 = 32; +static const uint8_t A1 = 33; +static const uint8_t A2 = 25; +static const uint8_t A3 = 26; +static const uint8_t A4 = 27; +static const uint8_t A5 = 14; +static const uint8_t A6 = 12; +static const uint8_t A7 = 15; + +static const uint8_t L_R = 22; +static const uint8_t L_G = 17; +static const uint8_t L_Y = 23; +static const uint8_t L_B = 5; +static const uint8_t L_RGB_R = 4; +static const uint8_t L_RGB_G = 21; +static const uint8_t L_RGB_B = 16; + +static const uint8_t SW1 = 15; +static const uint8_t SW2 = 2; +static const uint8_t SW3 = 0; + +static const uint8_t POT1 = 32; +static const uint8_t POT2 = 33; + +static const uint8_t PIEZO1 = 19; +static const uint8_t PIEZO2 = 18; + +static const uint8_t PHOTO = 25; + +static const uint8_t DHT_PIN = 26; + +static const uint8_t S1 = 4; +static const uint8_t S2 = 16; +static const uint8_t S3 = 18; +static const uint8_t S4 = 19; +static const uint8_t S5 = 21; + +static const uint8_t SDA = 27; +static const uint8_t SCL = 14; + +static const uint8_t SS = 19; +static const uint8_t MOSI = 21; +static const uint8_t MISO = 22; +static const uint8_t SCK = 23; + +static const uint8_t DAC1 = 25; +static const uint8_t DAC2 = 26; + +#endif /* Pins_Arduino_h */ diff --git a/variants/xinabox/pins_arduino.h b/variants/xinabox/pins_arduino.h new file mode 100644 index 00000000000..2cb41b91eb3 --- /dev/null +++ b/variants/xinabox/pins_arduino.h @@ -0,0 +1,28 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define EXTERNAL_NUM_INTERRUPTS 16 +#define NUM_DIGITAL_PINS 40 +#define NUM_ANALOG_INPUTS 16 + +#define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1) +#define digitalPinToInterrupt(p) (((p)<40)?(p):-1) +#define digitalPinHasPWM(p) (p < 34) + +static const uint8_t LED_BUILTIN = 27; +#define BUILTIN_LED LED_BUILTIN // backward compatibility + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t SDA = 21; +static const uint8_t SCL = 22; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 23; +static const uint8_t MISO = 19; +static const uint8_t SCK = 18; + +#endif /* Pins_Arduino_h */