diff --git a/boards.txt b/boards.txt index e52e6dc2e93..f3ea5e1cc5b 100644 --- a/boards.txt +++ b/boards.txt @@ -7479,8 +7479,8 @@ dfrobot_firebeetle2_esp32e.menu.EraseFlash.all.upload.erase_cmd=-e dfrobot_firebeetle2_esp32s3.name=DFRobot Firebeetle 2 ESP32-S3 #dfrobot_firebeetle2_esp32s3.vid.0=0x3343 #dfrobot_firebeetle2_esp32s3.pid.0=0x83CF -dfrobot_firebeetle2_esp32s3.vid.0=0x303a -dfrobot_firebeetle2_esp32s3.pid.0=0x1001 +dfrobot_beetle_esp32c3.vid.0=0x303a +dfrobot_beetle_esp32c3.pid.0=0x1001 dfrobot_firebeetle2_esp32s3.bootloader.tool=esptool_py dfrobot_firebeetle2_esp32s3.bootloader.tool.default=esptool_py @@ -7691,198 +7691,6 @@ dfrobot_firebeetle2_esp32s3.menu.EraseFlash.none.upload.erase_cmd= dfrobot_firebeetle2_esp32s3.menu.EraseFlash.all=Enabled dfrobot_firebeetle2_esp32s3.menu.EraseFlash.all.upload.erase_cmd=-e -############################################################## -# dfrobot Romeo ESP32-S3 -dfrobot_romeo_esp32s3.name=DFRobot Romeo ESP32-S3 -dfrobot_romeo_esp32s3.vid.0=0x303a -dfrobot_romeo_esp32s3.pid.0=0x1001 - -dfrobot_romeo_esp32s3.bootloader.tool=esptool_py -dfrobot_romeo_esp32s3.bootloader.tool.default=esptool_py - -dfrobot_romeo_esp32s3.upload.tool=esptool_py -dfrobot_romeo_esp32s3.upload.tool.default=esptool_py -dfrobot_romeo_esp32s3.upload.tool.network=esp_ota - -dfrobot_romeo_esp32s3.upload.maximum_size=1310720 -dfrobot_romeo_esp32s3.upload.maximum_data_size=327680 -dfrobot_romeo_esp32s3.upload.flags= -dfrobot_romeo_esp32s3.upload.extra_flags= -dfrobot_romeo_esp32s3.upload.use_1200bps_touch=false -dfrobot_romeo_esp32s3.upload.wait_for_upload_port=false - -dfrobot_romeo_esp32s3.serial.disableDTR=false -dfrobot_romeo_esp32s3.serial.disableRTS=false - -dfrobot_romeo_esp32s3.build.tarch=xtensa -dfrobot_romeo_esp32s3.build.bootloader_addr=0x0 -dfrobot_romeo_esp32s3.build.target=esp32s3 -dfrobot_romeo_esp32s3.build.mcu=esp32s3 -dfrobot_romeo_esp32s3.build.core=esp32 -dfrobot_romeo_esp32s3.build.variant=dfrobot_romeo_esp32s3 -dfrobot_romeo_esp32s3.build.board=DFROBOT_ROMEO_ESP32S3 - - -dfrobot_romeo_esp32s3.build.usb_mode=1 -dfrobot_romeo_esp32s3.build.cdc_on_boot=0 -dfrobot_romeo_esp32s3.build.msc_on_boot=0 -dfrobot_romeo_esp32s3.build.dfu_on_boot=0 -dfrobot_romeo_esp32s3.build.f_cpu=240000000L -dfrobot_romeo_esp32s3.build.flash_size=16MB -dfrobot_romeo_esp32s3.build.flash_freq=80m -dfrobot_romeo_esp32s3.build.flash_mode=qio -dfrobot_romeo_esp32s3.build.boot=qio -dfrobot_romeo_esp32s3.build.boot_freq=80m -dfrobot_romeo_esp32s3.build.partitions=default -dfrobot_romeo_esp32s3.build.defines= -dfrobot_romeo_esp32s3.build.loop_core= -dfrobot_romeo_esp32s3.build.event_core= -dfrobot_romeo_esp32s3.build.flash_type=qio -dfrobot_romeo_esp32s3.build.psram_type=qspi -dfrobot_romeo_esp32s3.build.memory_type={build.flash_type}_{build.psram_type} - -dfrobot_romeo_esp32s3.menu.PSRAM.opi=OPI PSRAM -dfrobot_romeo_esp32s3.menu.PSRAM.opi.build.defines=-DBOARD_HAS_PSRAM -dfrobot_romeo_esp32s3.menu.PSRAM.opi.build.psram_type=opi -dfrobot_romeo_esp32s3.menu.PSRAM.disabled=Disabled -dfrobot_romeo_esp32s3.menu.PSRAM.disabled.build.defines= -dfrobot_romeo_esp32s3.menu.PSRAM.disabled.build.psram_type=qspi -dfrobot_romeo_esp32s3.menu.PSRAM.enabled=QSPI PSRAM -dfrobot_romeo_esp32s3.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -dfrobot_romeo_esp32s3.menu.PSRAM.enabled.build.psram_type=qspi - - -dfrobot_romeo_esp32s3.menu.FlashMode.qio=QIO 80MHz -dfrobot_romeo_esp32s3.menu.FlashMode.qio.build.flash_mode=dio -dfrobot_romeo_esp32s3.menu.FlashMode.qio.build.boot=qio -dfrobot_romeo_esp32s3.menu.FlashMode.qio.build.boot_freq=80m -dfrobot_romeo_esp32s3.menu.FlashMode.qio.build.flash_freq=80m -dfrobot_romeo_esp32s3.menu.FlashMode.qio.build.flash_type=qio -dfrobot_romeo_esp32s3.menu.FlashMode.qio120=QIO 120MHz -dfrobot_romeo_esp32s3.menu.FlashMode.qio120.build.flash_mode=dio -dfrobot_romeo_esp32s3.menu.FlashMode.qio120.build.boot=qio -dfrobot_romeo_esp32s3.menu.FlashMode.qio120.build.boot_freq=120m -dfrobot_romeo_esp32s3.menu.FlashMode.qio120.build.flash_freq=80m -dfrobot_romeo_esp32s3.menu.FlashMode.qio120.build.flash_type=qio -dfrobot_romeo_esp32s3.menu.FlashMode.dio=DIO 80MHz -dfrobot_romeo_esp32s3.menu.FlashMode.dio.build.flash_mode=dio -dfrobot_romeo_esp32s3.menu.FlashMode.dio.build.boot=dio -dfrobot_romeo_esp32s3.menu.FlashMode.dio.build.boot_freq=80m -dfrobot_romeo_esp32s3.menu.FlashMode.dio.build.flash_freq=80m -dfrobot_romeo_esp32s3.menu.FlashMode.dio.build.flash_type=qio -dfrobot_romeo_esp32s3.menu.FlashMode.opi=OPI 80MHz -dfrobot_romeo_esp32s3.menu.FlashMode.opi.build.flash_mode=dout -dfrobot_romeo_esp32s3.menu.FlashMode.opi.build.boot=opi -dfrobot_romeo_esp32s3.menu.FlashMode.opi.build.boot_freq=80m -dfrobot_romeo_esp32s3.menu.FlashMode.opi.build.flash_freq=80m -dfrobot_romeo_esp32s3.menu.FlashMode.opi.build.flash_type=opi - -dfrobot_romeo_esp32s3.menu.FlashSize.16M=16MB (128Mb) -dfrobot_romeo_esp32s3.menu.FlashSize.16M.build.flash_size=16MB - - -dfrobot_romeo_esp32s3.menu.LoopCore.1=Core 1 -dfrobot_romeo_esp32s3.menu.LoopCore.1.build.loop_core=-DARDUINO_RUNNING_CORE=1 -dfrobot_romeo_esp32s3.menu.LoopCore.0=Core 0 -dfrobot_romeo_esp32s3.menu.LoopCore.0.build.loop_core=-DARDUINO_RUNNING_CORE=0 - -dfrobot_romeo_esp32s3.menu.EventsCore.1=Core 1 -dfrobot_romeo_esp32s3.menu.EventsCore.1.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1 -dfrobot_romeo_esp32s3.menu.EventsCore.0=Core 0 -dfrobot_romeo_esp32s3.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0 - -dfrobot_romeo_esp32s3.menu.USBMode.hwcdc=Hardware CDC and JTAG -dfrobot_romeo_esp32s3.menu.USBMode.hwcdc.build.usb_mode=1 -dfrobot_romeo_esp32s3.menu.USBMode.default=USB-OTG (TinyUSB) -dfrobot_romeo_esp32s3.menu.USBMode.default.build.usb_mode=0 - -dfrobot_romeo_esp32s3.menu.CDCOnBoot.cdc=Enabled -dfrobot_romeo_esp32s3.menu.CDCOnBoot.cdc.build.cdc_on_boot=1 -dfrobot_romeo_esp32s3.menu.CDCOnBoot.default=Disabled -dfrobot_romeo_esp32s3.menu.CDCOnBoot.default.build.cdc_on_boot=0 - - -dfrobot_romeo_esp32s3.menu.MSCOnBoot.default=Disabled -dfrobot_romeo_esp32s3.menu.MSCOnBoot.default.build.msc_on_boot=0 -dfrobot_romeo_esp32s3.menu.MSCOnBoot.msc=Enabled (Requires USB-OTG Mode) -dfrobot_romeo_esp32s3.menu.MSCOnBoot.msc.build.msc_on_boot=1 - -dfrobot_romeo_esp32s3.menu.DFUOnBoot.default=Disabled -dfrobot_romeo_esp32s3.menu.DFUOnBoot.default.build.dfu_on_boot=0 -dfrobot_romeo_esp32s3.menu.DFUOnBoot.dfu=Enabled (Requires USB-OTG Mode) -dfrobot_romeo_esp32s3.menu.DFUOnBoot.dfu.build.dfu_on_boot=1 - -dfrobot_romeo_esp32s3.menu.UploadMode.default=UART0 / Hardware CDC -dfrobot_romeo_esp32s3.menu.UploadMode.default.upload.use_1200bps_touch=false -dfrobot_romeo_esp32s3.menu.UploadMode.default.upload.wait_for_upload_port=false -dfrobot_romeo_esp32s3.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB) -dfrobot_romeo_esp32s3.menu.UploadMode.cdc.upload.use_1200bps_touch=true -dfrobot_romeo_esp32s3.menu.UploadMode.cdc.upload.wait_for_upload_port=true - -dfrobot_romeo_esp32s3.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9.9MB FATFS) -dfrobot_romeo_esp32s3.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB -dfrobot_romeo_esp32s3.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728 -dfrobot_romeo_esp32s3.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FATFS) -dfrobot_romeo_esp32s3.menu.PartitionScheme.fatflash.build.partitions=ffat -dfrobot_romeo_esp32s3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152 -dfrobot_romeo_esp32s3.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS) -dfrobot_romeo_esp32s3.menu.PartitionScheme.minimal.build.partitions=minimal -dfrobot_romeo_esp32s3.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS) -dfrobot_romeo_esp32s3.menu.PartitionScheme.huge_app.build.partitions=huge_app -dfrobot_romeo_esp32s3.menu.PartitionScheme.huge_app.upload.maximum_size=3145728 -dfrobot_romeo_esp32s3.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS) -dfrobot_romeo_esp32s3.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs -dfrobot_romeo_esp32s3.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 -dfrobot_romeo_esp32s3.menu.PartitionScheme.rainmaker=RainMaker -dfrobot_romeo_esp32s3.menu.PartitionScheme.rainmaker.build.partitions=rainmaker -dfrobot_romeo_esp32s3.menu.PartitionScheme.rainmaker.upload.maximum_size=3145728 - -dfrobot_romeo_esp32s3.menu.CPUFreq.240=240MHz (WiFi) -dfrobot_romeo_esp32s3.menu.CPUFreq.240.build.f_cpu=240000000L -dfrobot_romeo_esp32s3.menu.CPUFreq.160=160MHz (WiFi) -dfrobot_romeo_esp32s3.menu.CPUFreq.160.build.f_cpu=160000000L -dfrobot_romeo_esp32s3.menu.CPUFreq.80=80MHz (WiFi) -dfrobot_romeo_esp32s3.menu.CPUFreq.80.build.f_cpu=80000000L -dfrobot_romeo_esp32s3.menu.CPUFreq.40=40MHz -dfrobot_romeo_esp32s3.menu.CPUFreq.40.build.f_cpu=40000000L -dfrobot_romeo_esp32s3.menu.CPUFreq.20=20MHz -dfrobot_romeo_esp32s3.menu.CPUFreq.20.build.f_cpu=20000000L -dfrobot_romeo_esp32s3.menu.CPUFreq.10=10MHz -dfrobot_romeo_esp32s3.menu.CPUFreq.10.build.f_cpu=10000000L - -dfrobot_romeo_esp32s3.menu.UploadSpeed.921600=921600 -dfrobot_romeo_esp32s3.menu.UploadSpeed.921600.upload.speed=921600 -dfrobot_romeo_esp32s3.menu.UploadSpeed.115200=115200 -dfrobot_romeo_esp32s3.menu.UploadSpeed.115200.upload.speed=115200 -dfrobot_romeo_esp32s3.menu.UploadSpeed.256000.windows=256000 -dfrobot_romeo_esp32s3.menu.UploadSpeed.256000.upload.speed=256000 -dfrobot_romeo_esp32s3.menu.UploadSpeed.230400.windows.upload.speed=256000 -dfrobot_romeo_esp32s3.menu.UploadSpeed.230400=230400 -dfrobot_romeo_esp32s3.menu.UploadSpeed.230400.upload.speed=230400 -dfrobot_romeo_esp32s3.menu.UploadSpeed.460800.linux=460800 -dfrobot_romeo_esp32s3.menu.UploadSpeed.460800.macosx=460800 -dfrobot_romeo_esp32s3.menu.UploadSpeed.460800.upload.speed=460800 -dfrobot_romeo_esp32s3.menu.UploadSpeed.512000.windows=512000 -dfrobot_romeo_esp32s3.menu.UploadSpeed.512000.upload.speed=512000 - -dfrobot_romeo_esp32s3.menu.DebugLevel.none=None -dfrobot_romeo_esp32s3.menu.DebugLevel.none.build.code_debug=0 -dfrobot_romeo_esp32s3.menu.DebugLevel.error=Error -dfrobot_romeo_esp32s3.menu.DebugLevel.error.build.code_debug=1 -dfrobot_romeo_esp32s3.menu.DebugLevel.warn=Warn -dfrobot_romeo_esp32s3.menu.DebugLevel.warn.build.code_debug=2 -dfrobot_romeo_esp32s3.menu.DebugLevel.info=Info -dfrobot_romeo_esp32s3.menu.DebugLevel.info.build.code_debug=3 -dfrobot_romeo_esp32s3.menu.DebugLevel.debug=Debug -dfrobot_romeo_esp32s3.menu.DebugLevel.debug.build.code_debug=4 -dfrobot_romeo_esp32s3.menu.DebugLevel.verbose=Verbose -dfrobot_romeo_esp32s3.menu.DebugLevel.verbose.build.code_debug=5 - -dfrobot_romeo_esp32s3.menu.EraseFlash.none=Disabled -dfrobot_romeo_esp32s3.menu.EraseFlash.none.upload.erase_cmd= -dfrobot_romeo_esp32s3.menu.EraseFlash.all=Enabled -dfrobot_romeo_esp32s3.menu.EraseFlash.all.upload.erase_cmd=-e - ############################################################## firebeetle32.name=FireBeetle-ESP32 @@ -10830,185 +10638,6 @@ adafruit_itsybitsy_esp32.menu.EraseFlash.none.upload.erase_cmd= adafruit_itsybitsy_esp32.menu.EraseFlash.all=Enabled adafruit_itsybitsy_esp32.menu.EraseFlash.all.upload.erase_cmd=-e -############################################################## -# Adafruit MatrixPortal ESP32-S3 - -adafruit_matrixportal_esp32s3.name=Adafruit MatrixPortal ESP32-S3 -adafruit_matrixportal_esp32s3.vid.0=0x239A -adafruit_matrixportal_esp32s3.pid.0=0x8125 -adafruit_matrixportal_esp32s3.vid.1=0x239A -adafruit_matrixportal_esp32s3.pid.1=0x0125 -adafruit_matrixportal_esp32s3.vid.2=0x239A -adafruit_matrixportal_esp32s3.pid.2=0x8126 - -adafruit_matrixportal_esp32s3.bootloader.tool=esptool_py -adafruit_matrixportal_esp32s3.bootloader.tool.default=esptool_py - -adafruit_matrixportal_esp32s3.upload.tool=esptool_py -adafruit_matrixportal_esp32s3.upload.tool.default=esptool_py -adafruit_matrixportal_esp32s3.upload.tool.network=esp_ota - -adafruit_matrixportal_esp32s3.upload.maximum_size=1310720 -adafruit_matrixportal_esp32s3.upload.maximum_data_size=327680 -adafruit_matrixportal_esp32s3.upload.flags= -adafruit_matrixportal_esp32s3.upload.extra_flags= -adafruit_matrixportal_esp32s3.upload.use_1200bps_touch=true -adafruit_matrixportal_esp32s3.upload.wait_for_upload_port=true - -adafruit_matrixportal_esp32s3.serial.disableDTR=false -adafruit_matrixportal_esp32s3.serial.disableRTS=false - -adafruit_matrixportal_esp32s3.build.tarch=xtensa -adafruit_matrixportal_esp32s3.build.bootloader_addr=0x0 -adafruit_matrixportal_esp32s3.build.target=esp32s3 -adafruit_matrixportal_esp32s3.build.mcu=esp32s3 -adafruit_matrixportal_esp32s3.build.core=esp32 -adafruit_matrixportal_esp32s3.build.variant=adafruit_matrixportal_esp32s3 -adafruit_matrixportal_esp32s3.build.board=ADAFRUIT_MATRIXPORTAL_ESP32S3 - -adafruit_matrixportal_esp32s3.build.usb_mode=0 -adafruit_matrixportal_esp32s3.build.cdc_on_boot=1 -adafruit_matrixportal_esp32s3.build.msc_on_boot=0 -adafruit_matrixportal_esp32s3.build.dfu_on_boot=0 -adafruit_matrixportal_esp32s3.build.f_cpu=240000000L -adafruit_matrixportal_esp32s3.build.flash_size=8MB -adafruit_matrixportal_esp32s3.build.flash_freq=80m -adafruit_matrixportal_esp32s3.build.flash_mode=dio -adafruit_matrixportal_esp32s3.build.boot=qio -adafruit_matrixportal_esp32s3.build.partitions=default -adafruit_matrixportal_esp32s3.build.defines= -adafruit_matrixportal_esp32s3.build.loop_core= -adafruit_matrixportal_esp32s3.build.event_core= -adafruit_matrixportal_esp32s3.build.flash_type=qio -adafruit_matrixportal_esp32s3.build.psram_type=qspi -adafruit_matrixportal_esp32s3.build.memory_type={build.flash_type}_{build.psram_type} - -adafruit_matrixportal_esp32s3.menu.LoopCore.1=Core 1 -adafruit_matrixportal_esp32s3.menu.LoopCore.1.build.loop_core=-DARDUINO_RUNNING_CORE=1 -adafruit_matrixportal_esp32s3.menu.LoopCore.0=Core 0 -adafruit_matrixportal_esp32s3.menu.LoopCore.0.build.loop_core=-DARDUINO_RUNNING_CORE=0 - -adafruit_matrixportal_esp32s3.menu.EventsCore.1=Core 1 -adafruit_matrixportal_esp32s3.menu.EventsCore.1.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1 -adafruit_matrixportal_esp32s3.menu.EventsCore.0=Core 0 -adafruit_matrixportal_esp32s3.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0 - -adafruit_matrixportal_esp32s3.menu.USBMode.default=USB-OTG (TinyUSB) -adafruit_matrixportal_esp32s3.menu.USBMode.default.build.usb_mode=0 -adafruit_matrixportal_esp32s3.menu.USBMode.hwcdc=Hardware CDC and JTAG -adafruit_matrixportal_esp32s3.menu.USBMode.hwcdc.build.usb_mode=1 - -adafruit_matrixportal_esp32s3.menu.CDCOnBoot.cdc=Enabled -adafruit_matrixportal_esp32s3.menu.CDCOnBoot.cdc.build.cdc_on_boot=1 -adafruit_matrixportal_esp32s3.menu.CDCOnBoot.default=Disabled -adafruit_matrixportal_esp32s3.menu.CDCOnBoot.default.build.cdc_on_boot=0 - -adafruit_matrixportal_esp32s3.menu.MSCOnBoot.default=Disabled -adafruit_matrixportal_esp32s3.menu.MSCOnBoot.default.build.msc_on_boot=0 -adafruit_matrixportal_esp32s3.menu.MSCOnBoot.msc=Enabled (Requires USB-OTG Mode) -adafruit_matrixportal_esp32s3.menu.MSCOnBoot.msc.build.msc_on_boot=1 - -adafruit_matrixportal_esp32s3.menu.DFUOnBoot.default=Disabled -adafruit_matrixportal_esp32s3.menu.DFUOnBoot.default.build.dfu_on_boot=0 -adafruit_matrixportal_esp32s3.menu.DFUOnBoot.dfu=Enabled (Requires USB-OTG Mode) -adafruit_matrixportal_esp32s3.menu.DFUOnBoot.dfu.build.dfu_on_boot=1 - -adafruit_matrixportal_esp32s3.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB) -adafruit_matrixportal_esp32s3.menu.UploadMode.cdc.upload.use_1200bps_touch=true -adafruit_matrixportal_esp32s3.menu.UploadMode.cdc.upload.wait_for_upload_port=true -adafruit_matrixportal_esp32s3.menu.UploadMode.default=UART0 / Hardware CDC -adafruit_matrixportal_esp32s3.menu.UploadMode.default.upload.use_1200bps_touch=false -adafruit_matrixportal_esp32s3.menu.UploadMode.default.upload.wait_for_upload_port=false - -adafruit_matrixportal_esp32s3.menu.PSRAM.enabled=QSPI PSRAM -adafruit_matrixportal_esp32s3.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -adafruit_matrixportal_esp32s3.menu.PSRAM.enabled.build.psram_type=qspi -adafruit_matrixportal_esp32s3.menu.PSRAM.disabled=Disabled -adafruit_matrixportal_esp32s3.menu.PSRAM.disabled.build.defines= -adafruit_matrixportal_esp32s3.menu.PSRAM.disabled.build.psram_type=qspi -adafruit_matrixportal_esp32s3.menu.PSRAM.opi=OPI PSRAM -adafruit_matrixportal_esp32s3.menu.PSRAM.opi.build.defines=-DBOARD_HAS_PSRAM -adafruit_matrixportal_esp32s3.menu.PSRAM.opi.build.psram_type=opi - -adafruit_matrixportal_esp32s3.menu.PartitionScheme.tinyuf2=TinyUF2 8MB (2MB APP/3.7MB FFAT) -adafruit_matrixportal_esp32s3.menu.PartitionScheme.tinyuf2.build.custom_bootloader=bootloader-tinyuf2 -adafruit_matrixportal_esp32s3.menu.PartitionScheme.tinyuf2.build.custom_partitions=partitions-8MB-tinyuf2 -adafruit_matrixportal_esp32s3.menu.PartitionScheme.tinyuf2.upload.maximum_size=2097152 -adafruit_matrixportal_esp32s3.menu.PartitionScheme.tinyuf2.upload.extra_flags=0x410000 "{runtime.platform.path}/variants/{build.variant}/tinyuf2.bin" -adafruit_matrixportal_esp32s3.menu.PartitionScheme.default_8MB=Default (3MB APP/1.5MB SPIFFS) -adafruit_matrixportal_esp32s3.menu.PartitionScheme.default_8MB.build.partitions=default_8MB -adafruit_matrixportal_esp32s3.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336 - -adafruit_matrixportal_esp32s3.menu.CPUFreq.240=240MHz (WiFi) -adafruit_matrixportal_esp32s3.menu.CPUFreq.240.build.f_cpu=240000000L -adafruit_matrixportal_esp32s3.menu.CPUFreq.160=160MHz (WiFi) -adafruit_matrixportal_esp32s3.menu.CPUFreq.160.build.f_cpu=160000000L -adafruit_matrixportal_esp32s3.menu.CPUFreq.80=80MHz (WiFi) -adafruit_matrixportal_esp32s3.menu.CPUFreq.80.build.f_cpu=80000000L -adafruit_matrixportal_esp32s3.menu.CPUFreq.40=40MHz -adafruit_matrixportal_esp32s3.menu.CPUFreq.40.build.f_cpu=40000000L -adafruit_matrixportal_esp32s3.menu.CPUFreq.20=20MHz -adafruit_matrixportal_esp32s3.menu.CPUFreq.20.build.f_cpu=20000000L -adafruit_matrixportal_esp32s3.menu.CPUFreq.10=10MHz -adafruit_matrixportal_esp32s3.menu.CPUFreq.10.build.f_cpu=10000000L - -adafruit_matrixportal_esp32s3.menu.FlashMode.qio=QIO 80MHz -adafruit_matrixportal_esp32s3.menu.FlashMode.qio.build.flash_mode=dio -adafruit_matrixportal_esp32s3.menu.FlashMode.qio.build.boot=qio -adafruit_matrixportal_esp32s3.menu.FlashMode.qio.build.boot_freq=80m -adafruit_matrixportal_esp32s3.menu.FlashMode.qio.build.flash_freq=80m -adafruit_matrixportal_esp32s3.menu.FlashMode.qio120=QIO 120MHz -adafruit_matrixportal_esp32s3.menu.FlashMode.qio120.build.flash_mode=dio -adafruit_matrixportal_esp32s3.menu.FlashMode.qio120.build.boot=qio -adafruit_matrixportal_esp32s3.menu.FlashMode.qio120.build.boot_freq=120m -adafruit_matrixportal_esp32s3.menu.FlashMode.qio120.build.flash_freq=80m -adafruit_matrixportal_esp32s3.menu.FlashMode.dio=DIO 80MHz -adafruit_matrixportal_esp32s3.menu.FlashMode.dio.build.flash_mode=dio -adafruit_matrixportal_esp32s3.menu.FlashMode.dio.build.boot=dio -adafruit_matrixportal_esp32s3.menu.FlashMode.dio.build.boot_freq=80m -adafruit_matrixportal_esp32s3.menu.FlashMode.dio.build.flash_freq=80m -adafruit_matrixportal_esp32s3.menu.FlashMode.opi=OPI 80MHz -adafruit_matrixportal_esp32s3.menu.FlashMode.opi.build.flash_mode=dout -adafruit_matrixportal_esp32s3.menu.FlashMode.opi.build.boot=opi -adafruit_matrixportal_esp32s3.menu.FlashMode.opi.build.boot_freq=80m -adafruit_matrixportal_esp32s3.menu.FlashMode.opi.build.flash_freq=80m - -adafruit_matrixportal_esp32s3.menu.FlashSize.8M=8MB (64Mb) -adafruit_matrixportal_esp32s3.menu.FlashSize.8M.build.flash_size=8MB - -adafruit_matrixportal_esp32s3.menu.UploadSpeed.921600=921600 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.921600.upload.speed=921600 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.115200=115200 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.115200.upload.speed=115200 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.256000.windows=256000 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.256000.upload.speed=256000 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.230400.windows.upload.speed=256000 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.230400=230400 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.230400.upload.speed=230400 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.460800.linux=460800 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.460800.macosx=460800 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.460800.upload.speed=460800 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.512000.windows=512000 -adafruit_matrixportal_esp32s3.menu.UploadSpeed.512000.upload.speed=512000 - -adafruit_matrixportal_esp32s3.menu.DebugLevel.none=None -adafruit_matrixportal_esp32s3.menu.DebugLevel.none.build.code_debug=0 -adafruit_matrixportal_esp32s3.menu.DebugLevel.error=Error -adafruit_matrixportal_esp32s3.menu.DebugLevel.error.build.code_debug=1 -adafruit_matrixportal_esp32s3.menu.DebugLevel.warn=Warn -adafruit_matrixportal_esp32s3.menu.DebugLevel.warn.build.code_debug=2 -adafruit_matrixportal_esp32s3.menu.DebugLevel.info=Info -adafruit_matrixportal_esp32s3.menu.DebugLevel.info.build.code_debug=3 -adafruit_matrixportal_esp32s3.menu.DebugLevel.debug=Debug -adafruit_matrixportal_esp32s3.menu.DebugLevel.debug.build.code_debug=4 -adafruit_matrixportal_esp32s3.menu.DebugLevel.verbose=Verbose -adafruit_matrixportal_esp32s3.menu.DebugLevel.verbose.build.code_debug=5 - -adafruit_matrixportal_esp32s3.menu.EraseFlash.none=Disabled -adafruit_matrixportal_esp32s3.menu.EraseFlash.none.upload.erase_cmd= -adafruit_matrixportal_esp32s3.menu.EraseFlash.all=Enabled -adafruit_matrixportal_esp32s3.menu.EraseFlash.all.upload.erase_cmd=-e - ############################################################## @@ -12636,198 +12265,6 @@ m5stack-core2.menu.EraseFlash.all.upload.erase_cmd=-e ############################################################## -m5stack-cores3.name=M5Stack-CoreS3 -m5stack-cores3.vid.0=0x303a -m5stack-cores3.pid.0=0x1001 - -m5stack-cores3.bootloader.tool=esptool_py -m5stack-cores3.bootloader.tool.default=esptool_py - -m5stack-cores3.upload.tool=esptool_py -m5stack-cores3.upload.tool.default=esptool_py -m5stack-cores3.upload.tool.network=esp_ota - -m5stack-cores3.upload.maximum_size=1310720 -m5stack-cores3.upload.maximum_data_size=327680 -m5stack-cores3.upload.flags= -m5stack-cores3.upload.extra_flags= -m5stack-cores3.upload.use_1200bps_touch=false -m5stack-cores3.upload.wait_for_upload_port=false - -m5stack-cores3.serial.disableDTR=false -m5stack-cores3.serial.disableRTS=false - -m5stack-cores3.build.tarch=xtensa -m5stack-cores3.build.bootloader_addr=0x0 -m5stack-cores3.build.target=esp32s3 -m5stack-cores3.build.mcu=esp32s3 -m5stack-cores3.build.core=esp32 -m5stack-cores3.build.variant=m5stack_cores3 -m5stack-cores3.build.board=M5STACK_CORES3 - -m5stack-cores3.build.usb_mode=1 -m5stack-cores3.build.cdc_on_boot=0 -m5stack-cores3.build.msc_on_boot=0 -m5stack-cores3.build.dfu_on_boot=0 -m5stack-cores3.build.f_cpu=240000000L -m5stack-cores3.build.flash_size=4MB -m5stack-cores3.build.flash_freq=80m -m5stack-cores3.build.flash_mode=dio -m5stack-cores3.build.boot=qio -m5stack-cores3.build.boot_freq=80m -m5stack-cores3.build.partitions=default -m5stack-cores3.build.defines= -m5stack-cores3.build.loop_core= -m5stack-cores3.build.event_core= -m5stack-cores3.build.psram_type=qspi -m5stack-cores3.build.memory_type={build.boot}_{build.psram_type} - -m5stack-cores3.menu.JTAGAdapter.default=Disabled -m5stack-cores3.menu.JTAGAdapter.default.build.copy_jtag_files=0 -m5stack-cores3.menu.JTAGAdapter.builtin=Integrated USB JTAG -m5stack-cores3.menu.JTAGAdapter.builtin.build.openocdscript=esp32s3-builtin.cfg -m5stack-cores3.menu.JTAGAdapter.builtin.build.copy_jtag_files=1 -m5stack-cores3.menu.JTAGAdapter.external=FTDI Adapter -m5stack-cores3.menu.JTAGAdapter.external.build.openocdscript=esp32s3-ftdi.cfg -m5stack-cores3.menu.JTAGAdapter.external.build.copy_jtag_files=1 -m5stack-cores3.menu.JTAGAdapter.bridge=ESP USB Bridge -m5stack-cores3.menu.JTAGAdapter.bridge.build.openocdscript=esp32s3-bridge.cfg -m5stack-cores3.menu.JTAGAdapter.bridge.build.copy_jtag_files=1 - -m5stack-cores3.menu.PSRAM.disabled=Disabled -m5stack-cores3.menu.PSRAM.disabled.build.defines= -m5stack-cores3.menu.PSRAM.disabled.build.psram_type=qspi -m5stack-cores3.menu.PSRAM.enabled=QSPI PSRAM -m5stack-cores3.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -m5stack-cores3.menu.PSRAM.enabled.build.psram_type=qspi -m5stack-cores3.menu.PSRAM.opi=OPI PSRAM -m5stack-cores3.menu.PSRAM.opi.build.defines=-DBOARD_HAS_PSRAM -m5stack-cores3.menu.PSRAM.opi.build.psram_type=opi - -m5stack-cores3.menu.FlashMode.qio=QIO 80MHz -m5stack-cores3.menu.FlashMode.qio.build.flash_mode=dio -m5stack-cores3.menu.FlashMode.qio.build.boot=qio -m5stack-cores3.menu.FlashMode.qio.build.boot_freq=80m -m5stack-cores3.menu.FlashMode.qio.build.flash_freq=80m -m5stack-cores3.menu.FlashMode.qio120=QIO 120MHz -m5stack-cores3.menu.FlashMode.qio120.build.flash_mode=dio -m5stack-cores3.menu.FlashMode.qio120.build.boot=qio -m5stack-cores3.menu.FlashMode.qio120.build.boot_freq=120m -m5stack-cores3.menu.FlashMode.qio120.build.flash_freq=80m -m5stack-cores3.menu.FlashMode.dio=DIO 80MHz -m5stack-cores3.menu.FlashMode.dio.build.flash_mode=dio -m5stack-cores3.menu.FlashMode.dio.build.boot=dio -m5stack-cores3.menu.FlashMode.dio.build.boot_freq=80m -m5stack-cores3.menu.FlashMode.dio.build.flash_freq=80m -m5stack-cores3.menu.FlashMode.opi=OPI 80MHz -m5stack-cores3.menu.FlashMode.opi.build.flash_mode=dout -m5stack-cores3.menu.FlashMode.opi.build.boot=opi -m5stack-cores3.menu.FlashMode.opi.build.boot_freq=80m -m5stack-cores3.menu.FlashMode.opi.build.flash_freq=80m - -m5stack-cores3.menu.FlashSize.4M=4MB (32Mb) -m5stack-cores3.menu.FlashSize.4M.build.flash_size=4MB -m5stack-cores3.menu.FlashSize.8M=8MB (64Mb) -m5stack-cores3.menu.FlashSize.8M.build.flash_size=8MB -m5stack-cores3.menu.FlashSize.8M.build.partitions=default_8MB -m5stack-cores3.menu.FlashSize.16M=16MB (128Mb) -m5stack-cores3.menu.FlashSize.16M.build.flash_size=16MB -#m5stack-cores3.menu.FlashSize.32M=32MB (256Mb) -#m5stack-cores3.menu.FlashSize.32M.build.flash_size=32MB - -m5stack-cores3.menu.LoopCore.1=Core 1 -m5stack-cores3.menu.LoopCore.1.build.loop_core=-DARDUINO_RUNNING_CORE=1 -m5stack-cores3.menu.LoopCore.0=Core 0 -m5stack-cores3.menu.LoopCore.0.build.loop_core=-DARDUINO_RUNNING_CORE=0 - -m5stack-cores3.menu.EventsCore.1=Core 1 -m5stack-cores3.menu.EventsCore.1.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1 -m5stack-cores3.menu.EventsCore.0=Core 0 -m5stack-cores3.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0 - -m5stack-cores3.menu.USBMode.hwcdc=Hardware CDC and JTAG -m5stack-cores3.menu.USBMode.hwcdc.build.usb_mode=1 -m5stack-cores3.menu.USBMode.default=USB-OTG (TinyUSB) -m5stack-cores3.menu.USBMode.default.build.usb_mode=0 - -m5stack-cores3.menu.CDCOnBoot.default=Disabled -m5stack-cores3.menu.CDCOnBoot.default.build.cdc_on_boot=0 -m5stack-cores3.menu.CDCOnBoot.cdc=Enabled -m5stack-cores3.menu.CDCOnBoot.cdc.build.cdc_on_boot=1 - -m5stack-cores3.menu.MSCOnBoot.default=Disabled -m5stack-cores3.menu.MSCOnBoot.default.build.msc_on_boot=0 -m5stack-cores3.menu.MSCOnBoot.msc=Enabled (Requires USB-OTG Mode) -m5stack-cores3.menu.MSCOnBoot.msc.build.msc_on_boot=1 - -m5stack-cores3.menu.DFUOnBoot.default=Disabled -m5stack-cores3.menu.DFUOnBoot.default.build.dfu_on_boot=0 -m5stack-cores3.menu.DFUOnBoot.dfu=Enabled (Requires USB-OTG Mode) -m5stack-cores3.menu.DFUOnBoot.dfu.build.dfu_on_boot=1 - -m5stack-cores3.menu.UploadMode.default=UART0 / Hardware CDC -m5stack-cores3.menu.UploadMode.default.upload.use_1200bps_touch=false -m5stack-cores3.menu.UploadMode.default.upload.wait_for_upload_port=false -m5stack-cores3.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB) -m5stack-cores3.menu.UploadMode.cdc.upload.use_1200bps_touch=true -m5stack-cores3.menu.UploadMode.cdc.upload.wait_for_upload_port=true - -m5stack-cores3.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) -m5stack-cores3.menu.PartitionScheme.default.build.partitions=default -m5stack-cores3.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS) -m5stack-cores3.menu.PartitionScheme.defaultffat.build.partitions=default_ffat -m5stack-cores3.menu.PartitionScheme.default_8MB=8M with spiffs (3MB APP/1.5MB SPIFFS) -m5stack-cores3.menu.PartitionScheme.default_8MB.build.partitions=default_8MB -m5stack-cores3.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336 - -m5stack-cores3.menu.CPUFreq.240=240MHz (WiFi) -m5stack-cores3.menu.CPUFreq.240.build.f_cpu=240000000L -m5stack-cores3.menu.CPUFreq.160=160MHz (WiFi) -m5stack-cores3.menu.CPUFreq.160.build.f_cpu=160000000L -m5stack-cores3.menu.CPUFreq.80=80MHz (WiFi) -m5stack-cores3.menu.CPUFreq.80.build.f_cpu=80000000L -m5stack-cores3.menu.CPUFreq.40=40MHz -m5stack-cores3.menu.CPUFreq.40.build.f_cpu=40000000L -m5stack-cores3.menu.CPUFreq.20=20MHz -m5stack-cores3.menu.CPUFreq.20.build.f_cpu=20000000L -m5stack-cores3.menu.CPUFreq.10=10MHz -m5stack-cores3.menu.CPUFreq.10.build.f_cpu=10000000L - -m5stack-cores3.menu.UploadSpeed.921600=921600 -m5stack-cores3.menu.UploadSpeed.921600.upload.speed=921600 -m5stack-cores3.menu.UploadSpeed.115200=115200 -m5stack-cores3.menu.UploadSpeed.115200.upload.speed=115200 -m5stack-cores3.menu.UploadSpeed.256000.windows=256000 -m5stack-cores3.menu.UploadSpeed.256000.upload.speed=256000 -m5stack-cores3.menu.UploadSpeed.230400.windows.upload.speed=256000 -m5stack-cores3.menu.UploadSpeed.230400=230400 -m5stack-cores3.menu.UploadSpeed.230400.upload.speed=230400 -m5stack-cores3.menu.UploadSpeed.460800.linux=460800 -m5stack-cores3.menu.UploadSpeed.460800.macosx=460800 -m5stack-cores3.menu.UploadSpeed.460800.upload.speed=460800 -m5stack-cores3.menu.UploadSpeed.512000.windows=512000 -m5stack-cores3.menu.UploadSpeed.512000.upload.speed=512000 - -m5stack-cores3.menu.DebugLevel.none=None -m5stack-cores3.menu.DebugLevel.none.build.code_debug=0 -m5stack-cores3.menu.DebugLevel.error=Error -m5stack-cores3.menu.DebugLevel.error.build.code_debug=1 -m5stack-cores3.menu.DebugLevel.warn=Warn -m5stack-cores3.menu.DebugLevel.warn.build.code_debug=2 -m5stack-cores3.menu.DebugLevel.info=Info -m5stack-cores3.menu.DebugLevel.info.build.code_debug=3 -m5stack-cores3.menu.DebugLevel.debug=Debug -m5stack-cores3.menu.DebugLevel.debug.build.code_debug=4 -m5stack-cores3.menu.DebugLevel.verbose=Verbose -m5stack-cores3.menu.DebugLevel.verbose.build.code_debug=5 - -m5stack-cores3.menu.EraseFlash.none=Disabled -m5stack-cores3.menu.EraseFlash.none.upload.erase_cmd= -m5stack-cores3.menu.EraseFlash.all=Enabled -m5stack-cores3.menu.EraseFlash.all.upload.erase_cmd=-e - -############################################################## - m5stack-timer-cam.name=M5Stack-Timer-CAM m5stack-timer-cam.bootloader.tool=esptool_py @@ -23614,224 +23051,3 @@ crabik_slot_esp32_s3.menu.EraseFlash.all=Enabled crabik_slot_esp32_s3.menu.EraseFlash.all.upload.erase_cmd=-e ############################################################## - - -nebulas3.name=Nebula S3 -nebulas3.vid.0=0x303a -nebulas3.pid.0=0x1001 - -nebulas3.bootloader.tool=esptool_py -nebulas3.bootloader.tool.default=esptool_py - -nebulas3.upload.tool=esptool_py -nebulas3.upload.tool.default=esptool_py -nebulas3.upload.tool.network=esp_ota - -nebulas3.upload.maximum_size=1310720 -nebulas3.upload.maximum_data_size=327680 -nebulas3.upload.flags= -nebulas3.upload.extra_flags= -nebulas3.upload.use_1200bps_touch=false -nebulas3.upload.wait_for_upload_port=false - -nebulas3.serial.disableDTR=false -nebulas3.serial.disableRTS=false - -nebulas3.build.tarch=xtensa -nebulas3.build.bootloader_addr=0x0 -nebulas3.build.target=esp32s3 -nebulas3.build.mcu=esp32s3 -nebulas3.build.core=esp32 -nebulas3.build.variant=Nebula_S3 -nebulas3.build.board=NEBULAS3 - -nebulas3.build.usb_mode=1 -nebulas3.build.cdc_on_boot=0 -nebulas3.build.msc_on_boot=0 -nebulas3.build.dfu_on_boot=0 -nebulas3.build.f_cpu=240000000L -nebulas3.build.flash_size=4MB -nebulas3.build.flash_freq=80m -nebulas3.build.flash_mode=dio -nebulas3.build.boot=qio -nebulas3.build.boot_freq=80m -nebulas3.build.partitions=default -nebulas3.build.defines= -nebulas3.build.loop_core= -nebulas3.build.event_core= -nebulas3.build.psram_type=qspi -nebulas3.build.memory_type={build.boot}_{build.psram_type} - -## IDE 2.0 Seems to not update the value -nebulas3.menu.JTAGAdapter.default=Disabled -nebulas3.menu.JTAGAdapter.default.build.copy_jtag_files=0 -nebulas3.menu.JTAGAdapter.builtin=Integrated USB JTAG -nebulas3.menu.JTAGAdapter.builtin.build.openocdscript=esp32s3-builtin.cfg -nebulas3.menu.JTAGAdapter.builtin.build.copy_jtag_files=1 -nebulas3.menu.JTAGAdapter.external=FTDI Adapter -nebulas3.menu.JTAGAdapter.external.build.openocdscript=esp32s3-ftdi.cfg -nebulas3.menu.JTAGAdapter.external.build.copy_jtag_files=1 -nebulas3.menu.JTAGAdapter.bridge=ESP USB Bridge -nebulas3.menu.JTAGAdapter.bridge.build.openocdscript=esp32s3-bridge.cfg -nebulas3.menu.JTAGAdapter.bridge.build.copy_jtag_files=1 - -nebulas3.menu.PSRAM.disabled=Disabled -nebulas3.menu.PSRAM.disabled.build.defines= -nebulas3.menu.PSRAM.disabled.build.psram_type=qspi -nebulas3.menu.PSRAM.enabled=QSPI PSRAM -nebulas3.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -nebulas3.menu.PSRAM.enabled.build.psram_type=qspi -nebulas3.menu.PSRAM.opi=OPI PSRAM -nebulas3.menu.PSRAM.opi.build.defines=-DBOARD_HAS_PSRAM -nebulas3.menu.PSRAM.opi.build.psram_type=opi - -nebulas3.menu.FlashMode.qio=QIO 80MHz -nebulas3.menu.FlashMode.qio.build.flash_mode=dio -nebulas3.menu.FlashMode.qio.build.boot=qio -nebulas3.menu.FlashMode.qio.build.boot_freq=80m -nebulas3.menu.FlashMode.qio.build.flash_freq=80m -nebulas3.menu.FlashMode.qio120=QIO 120MHz -nebulas3.menu.FlashMode.qio120.build.flash_mode=dio -nebulas3.menu.FlashMode.qio120.build.boot=qio -nebulas3.menu.FlashMode.qio120.build.boot_freq=120m -nebulas3.menu.FlashMode.qio120.build.flash_freq=80m -nebulas3.menu.FlashMode.dio=DIO 80MHz -nebulas3.menu.FlashMode.dio.build.flash_mode=dio -nebulas3.menu.FlashMode.dio.build.boot=dio -nebulas3.menu.FlashMode.dio.build.boot_freq=80m -nebulas3.menu.FlashMode.dio.build.flash_freq=80m -nebulas3.menu.FlashMode.opi=OPI 80MHz -nebulas3.menu.FlashMode.opi.build.flash_mode=dout -nebulas3.menu.FlashMode.opi.build.boot=opi -nebulas3.menu.FlashMode.opi.build.boot_freq=80m -nebulas3.menu.FlashMode.opi.build.flash_freq=80m - -nebulas3.menu.FlashSize.4M=4MB (32Mb) -nebulas3.menu.FlashSize.4M.build.flash_size=4MB -nebulas3.menu.FlashSize.8M=8MB (64Mb) -nebulas3.menu.FlashSize.8M.build.flash_size=8MB -nebulas3.menu.FlashSize.8M.build.partitions=default_8MB -nebulas3.menu.FlashSize.16M=16MB (128Mb) -nebulas3.menu.FlashSize.16M.build.flash_size=16MB - -nebulas3.menu.LoopCore.1=Core 1 -nebulas3.menu.LoopCore.1.build.loop_core=-DARDUINO_RUNNING_CORE=1 -nebulas3.menu.LoopCore.0=Core 0 -nebulas3.menu.LoopCore.0.build.loop_core=-DARDUINO_RUNNING_CORE=0 - -nebulas3.menu.EventsCore.1=Core 1 -nebulas3.menu.EventsCore.1.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1 -nebulas3.menu.EventsCore.0=Core 0 -nebulas3.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0 - -nebulas3.menu.USBMode.hwcdc=Hardware CDC and JTAG -nebulas3.menu.USBMode.hwcdc.build.usb_mode=1 -nebulas3.menu.USBMode.default=USB-OTG (TinyUSB) -nebulas3.menu.USBMode.default.build.usb_mode=0 - -nebulas3.menu.CDCOnBoot.default= Enabled -nebulas3.menu.CDCOnBoot.default.build.cdc_on_boot=1 -nebulas3.menu.CDCOnBoot.cdc=Disabled -nebulas3.menu.CDCOnBoot.cdc.build.cdc_on_boot=0 - -nebulas3.menu.MSCOnBoot.default=Disabled -nebulas3.menu.MSCOnBoot.default.build.msc_on_boot=0 -nebulas3.menu.MSCOnBoot.msc=Enabled (Requires USB-OTG Mode) -nebulas3.menu.MSCOnBoot.msc.build.msc_on_boot=1 - -nebulas3.menu.DFUOnBoot.default=Disabled -nebulas3.menu.DFUOnBoot.default.build.dfu_on_boot=0 -nebulas3.menu.DFUOnBoot.dfu=Enabled (Requires USB-OTG Mode) -nebulas3.menu.DFUOnBoot.dfu.build.dfu_on_boot=1 - -nebulas3.menu.UploadMode.default=UART0 / Hardware CDC -nebulas3.menu.UploadMode.default.upload.use_1200bps_touch=false -nebulas3.menu.UploadMode.default.upload.wait_for_upload_port=false -nebulas3.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB) -nebulas3.menu.UploadMode.cdc.upload.use_1200bps_touch=true -nebulas3.menu.UploadMode.cdc.upload.wait_for_upload_port=true - -nebulas3.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) -nebulas3.menu.PartitionScheme.default.build.partitions=default -nebulas3.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS) -nebulas3.menu.PartitionScheme.defaultffat.build.partitions=default_ffat -nebulas3.menu.PartitionScheme.default_8MB=8M with spiffs (3MB APP/1.5MB SPIFFS) -nebulas3.menu.PartitionScheme.default_8MB.build.partitions=default_8MB -nebulas3.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336 -nebulas3.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS) -nebulas3.menu.PartitionScheme.minimal.build.partitions=minimal -nebulas3.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS) -nebulas3.menu.PartitionScheme.no_ota.build.partitions=no_ota -nebulas3.menu.PartitionScheme.no_ota.upload.maximum_size=2097152 -nebulas3.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS) -nebulas3.menu.PartitionScheme.noota_3g.build.partitions=noota_3g -nebulas3.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576 -nebulas3.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS) -nebulas3.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat -nebulas3.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152 -nebulas3.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS) -nebulas3.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat -nebulas3.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576 -nebulas3.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS) -nebulas3.menu.PartitionScheme.huge_app.build.partitions=huge_app -nebulas3.menu.PartitionScheme.huge_app.upload.maximum_size=3145728 -nebulas3.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS) -nebulas3.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs -nebulas3.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 -nebulas3.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FATFS) -nebulas3.menu.PartitionScheme.fatflash.build.partitions=ffat -nebulas3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152 -nebulas3.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9.9MB FATFS) -nebulas3.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB -nebulas3.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728 -nebulas3.menu.PartitionScheme.rainmaker=RainMaker -nebulas3.menu.PartitionScheme.rainmaker.build.partitions=rainmaker -nebulas3.menu.PartitionScheme.rainmaker.upload.maximum_size=3145728 - -nebulas3.menu.CPUFreq.240=240MHz (WiFi) -nebulas3.menu.CPUFreq.240.build.f_cpu=240000000L -nebulas3.menu.CPUFreq.160=160MHz (WiFi) -nebulas3.menu.CPUFreq.160.build.f_cpu=160000000L -nebulas3.menu.CPUFreq.80=80MHz (WiFi) -nebulas3.menu.CPUFreq.80.build.f_cpu=80000000L -nebulas3.menu.CPUFreq.40=40MHz -nebulas3.menu.CPUFreq.40.build.f_cpu=40000000L -nebulas3.menu.CPUFreq.20=20MHz -nebulas3.menu.CPUFreq.20.build.f_cpu=20000000L -nebulas3.menu.CPUFreq.10=10MHz -nebulas3.menu.CPUFreq.10.build.f_cpu=10000000L - -nebulas3.menu.UploadSpeed.921600=921600 -nebulas3.menu.UploadSpeed.921600.upload.speed=921600 -nebulas3.menu.UploadSpeed.115200=115200 -nebulas3.menu.UploadSpeed.115200.upload.speed=115200 -nebulas3.menu.UploadSpeed.256000.windows=256000 -nebulas3.menu.UploadSpeed.256000.upload.speed=256000 -nebulas3.menu.UploadSpeed.230400.windows.upload.speed=256000 -nebulas3.menu.UploadSpeed.230400=230400 -nebulas3.menu.UploadSpeed.230400.upload.speed=230400 -nebulas3.menu.UploadSpeed.460800.linux=460800 -nebulas3.menu.UploadSpeed.460800.macosx=460800 -nebulas3.menu.UploadSpeed.460800.upload.speed=460800 -nebulas3.menu.UploadSpeed.512000.windows=512000 -nebulas3.menu.UploadSpeed.512000.upload.speed=512000 - -nebulas3.menu.DebugLevel.none=None -nebulas3.menu.DebugLevel.none.build.code_debug=0 -nebulas3.menu.DebugLevel.error=Error -nebulas3.menu.DebugLevel.error.build.code_debug=1 -nebulas3.menu.DebugLevel.warn=Warn -nebulas3.menu.DebugLevel.warn.build.code_debug=2 -nebulas3.menu.DebugLevel.info=Info -nebulas3.menu.DebugLevel.info.build.code_debug=3 -nebulas3.menu.DebugLevel.debug=Debug -nebulas3.menu.DebugLevel.debug.build.code_debug=4 -nebulas3.menu.DebugLevel.verbose=Verbose -nebulas3.menu.DebugLevel.verbose.build.code_debug=5 - -nebulas3.menu.EraseFlash.none=Disabled -nebulas3.menu.EraseFlash.none.upload.erase_cmd= -nebulas3.menu.EraseFlash.all=Enabled -nebulas3.menu.EraseFlash.all.upload.erase_cmd=-e - -############################################################## \ No newline at end of file diff --git a/cores/esp32/HWCDC.cpp b/cores/esp32/HWCDC.cpp index 6ec8625cff9..25744f0b0a3 100644 --- a/cores/esp32/HWCDC.cpp +++ b/cores/esp32/HWCDC.cpp @@ -28,7 +28,7 @@ ESP_EVENT_DEFINE_BASE(ARDUINO_HW_CDC_EVENTS); static RingbufHandle_t tx_ring_buf = NULL; static xQueueHandle rx_queue = NULL; -static uint8_t rx_data_buf[64] = {0}; +static uint8_t rx_data_buf[64]; static intr_handle_t intr_handle = NULL; static volatile bool initial_empty = false; static xSemaphoreHandle tx_lock = NULL; @@ -195,7 +195,6 @@ void HWCDC::end() intr_handle = NULL; if(tx_lock != NULL) { vSemaphoreDelete(tx_lock); - tx_lock = NULL; } setRxBufferSize(0); setTxBufferSize(0); diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index e2b12bda3f4..e60588f931e 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -365,6 +365,9 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in } break; #endif + default: + log_e("Bad UART Number"); + return; } } diff --git a/cores/esp32/IPAddress.cpp b/cores/esp32/IPAddress.cpp index 0575363f254..b8f7b7aae1b 100644 --- a/cores/esp32/IPAddress.cpp +++ b/cores/esp32/IPAddress.cpp @@ -20,68 +20,93 @@ #include #include #include +#include -IPAddress::IPAddress() -{ - _address.dword = 0; +IPAddress::IPAddress() { +#if LWIP_IPV6 + _ip = *IP6_ADDR_ANY; +#else + _ip = *IP_ADDR_ANY; +#endif + // _ip = *IP_ANY_TYPE; // lwIP's v4-or-v6 generic address } -IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) +IPAddress::IPAddress(const IPAddress& from) { - _address.bytes[0] = first_octet; - _address.bytes[1] = second_octet; - _address.bytes[2] = third_octet; - _address.bytes[3] = fourth_octet; + ip_addr_copy(_ip, from._ip); } -IPAddress::IPAddress(uint32_t address) -{ - _address.dword = address; +IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) { + setV4(); + (*this)[0] = first_octet; + (*this)[1] = second_octet; + (*this)[2] = third_octet; + (*this)[3] = fourth_octet; } -IPAddress::IPAddress(const uint8_t *address) -{ - memcpy(_address.bytes, address, sizeof(_address.bytes)); +IPAddress::IPAddress(uint8_t o1, uint8_t o2, uint8_t o3, uint8_t o4, uint8_t o5, uint8_t o6, uint8_t o7, uint8_t o8, uint8_t o9, uint8_t o10, uint8_t o11, uint8_t o12, uint8_t o13, uint8_t o14, uint8_t o15, uint8_t o16) { + setV6(); + (*this)[0] = o1; + (*this)[1] = o2; + (*this)[2] = o3; + (*this)[3] = o4; + (*this)[4] = o5; + (*this)[5] = o6; + (*this)[6] = o7; + (*this)[7] = o8; + (*this)[8] = o9; + (*this)[9] = o10; + (*this)[10] = o11; + (*this)[11] = o12; + (*this)[12] = o13; + (*this)[13] = o14; + (*this)[14] = o15; + (*this)[15] = o16; } -IPAddress& IPAddress::operator=(const uint8_t *address) -{ - memcpy(_address.bytes, address, sizeof(_address.bytes)); - return *this; +IPAddress::IPAddress(IPType type, const uint8_t *address) { + if (type == IPv4) { + setV4(); + memcpy(&this->_ip.u_addr.ip4, address, 4); + } else if (type == IPv6) { + setV6(); + memcpy(&this->_ip.u_addr.ip6.addr[0], address, 16); + } else { +#if LWIP_IPV6 + _ip = *IP6_ADDR_ANY; +#else + _ip = *IP_ADDR_ANY; +#endif + } + } -IPAddress& IPAddress::operator=(uint32_t address) -{ - _address.dword = address; - return *this; +void IPAddress::ctor32(uint32_t address) { + setV4(); + v4() = address; } -bool IPAddress::operator==(const uint8_t* addr) const -{ - return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0; +IPAddress::IPAddress(const uint8_t *address) { + setV4(); + (*this)[0] = address[0]; + (*this)[1] = address[1]; + (*this)[2] = address[2]; + (*this)[3] = address[3]; } -size_t IPAddress::printTo(Print& p) const -{ - size_t n = 0; - for(int i = 0; i < 3; i++) { - n += p.print(_address.bytes[i], DEC); - n += p.print('.'); +bool IPAddress::fromString(const char *address) { + if (!fromString4(address)) { +#if LWIP_IPV6 + return fromString6(address); +#else + return false; +#endif } - n += p.print(_address.bytes[3], DEC); - return n; + return true; } -String IPAddress::toString() const -{ - char szRet[16]; - sprintf(szRet,"%u.%u.%u.%u", _address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3]); - return String(szRet); -} - -bool IPAddress::fromString(const char *address) -{ - // TODO: add support for "a", "a.b", "a.b.c" formats +bool IPAddress::fromString4(const char *address) { + // TODO: (IPv4) add support for "a", "a.b", "a.b.c" formats uint16_t acc = 0; // Accumulator uint8_t dots = 0; @@ -103,7 +128,7 @@ bool IPAddress::fromString(const char *address) // Too much dots (there must be 3 dots) return false; } - _address.bytes[dots++] = acc; + (*this)[dots++] = acc; acc = 0; } else @@ -117,9 +142,146 @@ bool IPAddress::fromString(const char *address) // Too few dots (there must be 3 dots) return false; } - _address.bytes[3] = acc; + (*this)[3] = acc; + + setV4(); + return true; +} + +IPAddress& IPAddress::operator=(const uint8_t *address) { + setV4(); + v4() = *reinterpret_cast(address); + return *this; +} + +IPAddress& IPAddress::operator=(uint32_t address) { + setV4(); + v4() = address; + return *this; +} + +bool IPAddress::operator==(const uint8_t* addr) const { + return isV4() && v4() == *reinterpret_cast(addr); +} + +size_t IPAddress::printTo(Print& p) const { + size_t n = 0; + + // if (!isSet()) + // return p.print(F("(IP unset)")); + +#if LWIP_IPV6 + if (isV6()) { + int count0 = 0; + for (int i = 0; i < 8; i++) { + uint16_t bit = PP_NTOHS(raw6()[i]); + if (bit || count0 < 0) { + n += p.printf("%x", bit); + if (count0 > 0) + // no more hiding 0 + count0 = -8; + } else + count0++; + if ((i != 7 && count0 < 2) || count0 == 7) + n += p.print(':'); + } + return n; + } +#endif + + for(int i = 0; i < 4; i++) { + n += p.print((*this)[i], DEC); + if (i != 3) + n += p.print('.'); + } + return n; +} + +String IPAddress::toString() const +{ + StreamString sstr; +#if LWIP_IPV6 + if (isV6()) + sstr.reserve(40); // 8 shorts x 4 chars each + 7 colons + nullterm + else +#endif + sstr.reserve(16); // 4 bytes with 3 chars max + 3 dots + nullterm, or '(IP unset)' + printTo(sstr); + return sstr; +} + +bool IPAddress::isValid(const String& arg) { + return IPAddress().fromString(arg); +} + +bool IPAddress::isValid(const char* arg) { + return IPAddress().fromString(arg); +} + +const IPAddress INADDR46_ANY; // generic "0.0.0.0" for IPv4 & IPv6 +const IPAddress INADDR46_NONE(255,255,255,255); + +void IPAddress::clear() { + (*this) = INADDR46_ANY; +} + +/**************************************/ + +#if LWIP_IPV6 + +bool IPAddress::fromString6(const char *address) { + // TODO: test test test + + uint32_t acc = 0; // Accumulator + int dots = 0, doubledots = -1; + + while (*address) + { + char c = tolower(*address++); + if (isalnum(c)) { + if (c >= 'a') + c -= 'a' - '0' - 10; + acc = acc * 16 + (c - '0'); + if (acc > 0xffff) + // Value out of range + return false; + } + else if (c == ':') { + if (*address == ':') { + if (doubledots >= 0) + // :: allowed once + return false; + // remember location + doubledots = dots + !!acc; + address++; + } + if (dots == 7) + // too many separators + return false; + raw6()[dots++] = PP_HTONS(acc); + acc = 0; + } + else + // Invalid char + return false; + } + + if (doubledots == -1 && dots != 7) + // Too few separators + return false; + raw6()[dots++] = PP_HTONS(acc); + + if (doubledots != -1) { + for (int i = dots - doubledots - 1; i >= 0; i--) + raw6()[8 - dots + doubledots + i] = raw6()[doubledots + i]; + for (int i = doubledots; i < 8 - dots + doubledots; i++) + raw6()[i] = 0; + } + + setV6(); return true; } +#endif // LWIP_IPV6 // declared one time - as external in IPAddress.h -IPAddress INADDR_NONE(0, 0, 0, 0); +IPAddress INADDR_NONE(0, 0, 0, 0); // TODO diff --git a/cores/esp32/IPAddress.h b/cores/esp32/IPAddress.h index 3bedd4f8749..d6d2e947f67 100644 --- a/cores/esp32/IPAddress.h +++ b/cores/esp32/IPAddress.h @@ -20,77 +20,174 @@ #ifndef IPAddress_h #define IPAddress_h -#include #include #include +#include -// A class to make it easier to handle and pass around IP addresses +enum IPType +{ + IPv4 = IPADDR_TYPE_V4, + IPv6 = IPADDR_TYPE_V6 +}; class IPAddress: public Printable { private: - union { - uint8_t bytes[4]; // IPv4 address - uint32_t dword; - } _address; + ip_addr_t _ip; // Access the raw byte array containing the address. Because this returns a pointer // to the internal structure rather than a copy of the address this function should only // be used when you know that the usage of the returned uint8_t* will be transient and not // stored. - uint8_t* raw_address() - { - return _address.bytes; + uint8_t* raw_address() { + return reinterpret_cast(&v4()); } + const uint8_t* raw_address() const { + return reinterpret_cast(&v4()); + } + + void ctor32 (uint32_t); public: // Constructors IPAddress(); + IPAddress(const IPAddress& from); IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); - IPAddress(uint32_t address); - IPAddress(const uint8_t *address); - virtual ~IPAddress() {} + IPAddress(uint8_t o1, uint8_t o2, uint8_t o3, uint8_t o4, uint8_t o5, uint8_t o6, uint8_t o7, uint8_t o8, uint8_t o9, uint8_t o10, uint8_t o11, uint8_t o12, uint8_t o13, uint8_t o14, uint8_t o15, uint8_t o16); + IPAddress(uint32_t address) { ctor32(address); } + IPAddress(const uint8_t *address); // v4 only + IPAddress(IPType type, const uint8_t *address); bool fromString(const char *address); bool fromString(const String &address) { return fromString(address.c_str()); } // Overloaded cast operator to allow IPAddress objects to be used where a pointer // to a four-byte uint8_t array is expected - operator uint32_t() const - { - return _address.dword; + operator uint32_t() const { return isV4()? v4(): (uint32_t)0; } + operator uint32_t() { return isV4()? v4(): (uint32_t)0; } + + // generic IPv4 wrapper to uint32-view like arduino loves to see it + const uint32_t& v4() const { return ip_2_ip4(&_ip)->addr; } // for raw_address(const) + uint32_t& v4() { return ip_2_ip4(&_ip)->addr; } + + bool operator==(const IPAddress& addr) const { + return ip_addr_cmp(&_ip, &addr._ip); } - bool operator==(const IPAddress& addr) const - { - return _address.dword == addr._address.dword; + bool operator!=(const IPAddress& addr) const { + return !ip_addr_cmp(&_ip, &addr._ip); + } + bool operator==(uint32_t addr) const { + return isV4() && v4() == addr; } + // bool operator==(unsigned long addr) const { + // return isV4() && v4() == (uint32_t)addr; + // } + bool operator!=(uint32_t addr) const { + return !(isV4() && v4() == addr); + } + // bool operator!=(unsigned long addr) const { + // return isV4() && v4() != (uint32_t)addr; + // } bool operator==(const uint8_t* addr) const; + int operator>>(int n) const { + return isV4()? v4() >> n: 0; + } + // Overloaded index operator to allow getting and setting individual octets of the address - uint8_t operator[](int index) const - { - return _address.bytes[index]; + uint8_t operator[](int index) const { + return isV4()? *(raw_address() + index): 0; } - uint8_t& operator[](int index) - { - return _address.bytes[index]; + uint8_t& operator[](int index) { + setV4(); + return *(raw_address() + index); } // Overloaded copy operators to allow initialisation of IPAddress objects from other types IPAddress& operator=(const uint8_t *address); IPAddress& operator=(uint32_t address); + IPAddress& operator=(const IPAddress&) = default; + + IPType type() const { return (IPType)_ip.type; } virtual size_t printTo(Print& p) const; String toString() const; + void clear(); + + /* + check if input string(arg) is a valid IPV4 address or not. + return true on valid. + return false on invalid. + */ + static bool isValid(const String& arg); + static bool isValid(const char* arg); + friend class EthernetClass; friend class UDP; friend class Client; friend class Server; friend class DhcpClass; friend class DNSClient; + + operator ip_addr_t () const { return _ip; } + operator const ip_addr_t*() const { return &_ip; } + operator ip_addr_t*() { return &_ip; } + + bool isV4() const { return IP_IS_V4_VAL(_ip); } + void setV4() { IP_SET_TYPE_VAL(_ip, IPADDR_TYPE_V4); } + + bool isLocal() const { return ip_addr_islinklocal(&_ip); } + bool isAny() const { return ip_addr_isany_val(_ip); } + +#if LWIP_IPV6 + IPAddress(const ip_addr_t& lwip_addr) { ip_addr_copy(_ip, lwip_addr); } + IPAddress(const ip_addr_t* lwip_addr) { ip_addr_copy(_ip, *lwip_addr); } + + IPAddress& operator=(const ip_addr_t& lwip_addr) { ip_addr_copy(_ip, lwip_addr); return *this; } + IPAddress& operator=(const ip_addr_t* lwip_addr) { ip_addr_copy(_ip, *lwip_addr); return *this; } + + uint16_t* raw6() + { + setV6(); + return reinterpret_cast(ip_2_ip6(&_ip)); + } + + const uint16_t* raw6() const + { + return isV6()? reinterpret_cast(ip_2_ip6(&_ip)): nullptr; + } + + // when not IPv6, ip_addr_t == ip4_addr_t so this one would be ambiguous + // required otherwise + operator const ip4_addr_t*() const { return isV4()? ip_2_ip4(&_ip): nullptr; } + + bool isV6() const { return IP_IS_V6_VAL(_ip); } + void setV6() { + IP_SET_TYPE_VAL(_ip, IPADDR_TYPE_V6); + ip6_addr_clear_zone(ip_2_ip6(&_ip)); + } + +protected: + bool fromString6(const char *address); + +#else + + // allow portable code when IPv6 is not enabled + + uint16_t* raw6() { return nullptr; } + const uint16_t* raw6() const { return nullptr; } + bool isV6() const { return false; } + void setV6() { } + +#endif + +protected: + bool fromString4(const char *address); }; // changed to extern because const declaration creates copies in BSS of INADDR_NONE for each CPP unit that includes it extern IPAddress INADDR_NONE; +extern IPAddress IN6ADDR_ANY; + #endif diff --git a/cores/esp32/esp32-hal-bt.c b/cores/esp32/esp32-hal-bt.c index 7b6a54e1ad4..d17a761bebd 100644 --- a/cores/esp32/esp32-hal-bt.c +++ b/cores/esp32/esp32-hal-bt.c @@ -16,8 +16,7 @@ #ifdef CONFIG_BT_ENABLED -// user may want to change it to free resources -__attribute__((weak)) bool btInUse(){ return true; } +bool btInUse(){ return true; } #include "esp_bt.h" diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index 9bc1b3a3a8e..1a71b0e86f9 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -209,8 +209,9 @@ bool verifyRollbackLater() { return false; } #endif #ifdef CONFIG_BT_ENABLED -//from esp32-hal-bt.c -extern bool btInUse(); +//overwritten in esp32-hal-bt.c +bool btInUse() __attribute__((weak)); +bool btInUse(){ return false; } #endif void initArduino() diff --git a/docs/source/api/ledc.rst b/docs/source/api/ledc.rst index efc66c86324..d3ee885a474 100644 --- a/docs/source/api/ledc.rst +++ b/docs/source/api/ledc.rst @@ -90,7 +90,7 @@ This function is used to setup the LEDC channel to 50 % PWM tone on selected fre * ``freq`` select frequency of pwm signal. This function will return ``frequency`` set for channel. -If ``0`` is returned, error occurs and ledc channel was not configured. +If ``0`` is returned, error occurs and ledc cahnnel was not configured. ledcWriteNote ************* diff --git a/docs/source/faq.rst b/docs/source/faq.rst index 6af19fc804f..97520b35673 100644 --- a/docs/source/faq.rst +++ b/docs/source/faq.rst @@ -15,20 +15,3 @@ How to compile libs with different debug level? ----------------------------------------------- The short answer is ``esp32-arduino-lib-builder/configs/defconfig.common:44``. A guide explaining the process can be found here - -SPIFFS mount failed -------------------- -When you come across and error like this: - -.. code-block:: shell - - E (588) SPIFFS: mount failed, -10025 - [E][SPIFFS.cpp:47] begin(): Mounting SPIFFS failed! Error: -1 - -Try enforcing format on fail in your code by adding ``true`` in the ``begin`` method such as this: - -.. code-block:: c++ - - SPIFFS.begin(true); - -See the method prototype for reference: ``bool begin(bool formatOnFail=false, const char * basePath="/spiffs", uint8_t maxOpenFiles=10, const char * partitionLabel=NULL);`` \ No newline at end of file diff --git a/docs/source/tutorials/preferences.rst b/docs/source/tutorials/preferences.rst index 3cb54f1928c..eb0397af543 100644 --- a/docs/source/tutorials/preferences.rst +++ b/docs/source/tutorials/preferences.rst @@ -233,9 +233,9 @@ Like so: .. code-block:: arduino - float myFloat = myPreferences.getFloat("pi"); + String myString = myPreferences.getString("myStringKey"); -This will retrieve the float value from the namespace key ``"pi"`` and assign it to the float type variable ``myFloat``. +This will retrieve the String value from the namespace key ``"myStringKey"`` and assign it to the String type variable ``myString``. Summary @@ -277,10 +277,9 @@ When started, the system has no way of knowing which of the above conditions is // not the complete setup(), but in setup(), include this... stcPrefs.begin("STCPrefs", RO_MODE); // Open our namespace (or create it - // if it doesn't exist) in RO mode. + // if it doesn't exist) in in RO mode. - bool tpInit = stcPrefs.isKey("nvsInit"); // Test for the existence - // of the "already initialized" key. + bool tpInit = stcPrefs.isKey("nvsInit"); // Test for the existence of the "already initialized" key. if (tpInit == false) { // If tpInit is 'false', the key "nvsInit" does not yet exist therefore this @@ -290,15 +289,13 @@ When started, the system has no way of knowing which of the above conditions is // The .begin() method created the "STCPrefs" namespace and since this is our - // first-time run we will create - // our keys and store the initial "factory default" values. + // first-time run we will create our keys and store the initial "factory default" values. stcPrefs.putUChar("curBright", 10); stcPrefs.putString("talChan", "one"); stcPrefs.putLong("talMax", -220226); stcPrefs.putBool("ctMde", true); - stcPrefs.putBool("nvsInit", true); // Create the "already initialized" - // key and store a value. + stcPrefs.putBool("nvsInit", true); // Create the "already initialized" key and store a value. // The "factory defaults" are created and stored so... stcPrefs.end(); // Close the namespace in RW mode and... @@ -459,12 +456,10 @@ This is best explained with an example. Here the ``Bytes`` methods are used to s Serial.begin(115200); delay(250); - mySketchPrefs.begin("myPrefs", RW_MODE); // open (or create) the namespace - // "myPrefs" in RW mode + mySketchPrefs.begin("myPrefs", RW_MODE); // open (or create) the namespace "myPrefs" in RW mode mySketchPrefs.clear(); // delete any previous keys in this namespace - // Create an array of test values. We're using hex numbers - // throughout to better show how the bytes move around. + // Create an array of test values. We're using hex numbers throughout to better show how the bytes move around. int16_t myArray[] = { 0x1112, 0x2122, 0x3132, 0x4142, 0x5152, 0x6162, 0x7172 }; Serial.println("Printing myArray..."); @@ -473,28 +468,22 @@ This is best explained with an example. Here the ``Bytes`` methods are used to s } Serial.println("\r\n"); - // In the next statement, the second sizeof() needs - // to match the data type of the elements of myArray - Serial.print("The number of elements in myArray is: "); - Serial.println( sizeof(myArray) / sizeof(int16_t) ); - Serial.print("But the size of myArray in bytes is: "); - Serial.println( sizeof(myArray) ); + // In the next statement, the second sizeof() needs to match the data type of the elements of myArray + Serial.print("The number of elements in myArray is: "); Serial.println( sizeof(myArray) / sizeof(int16_t) ); + Serial.print("But the size of myArray in bytes is: "); Serial.println( sizeof(myArray) ); Serial.println(""); - Serial.println( - "Storing myArray into the Preferences namespace \"myPrefs\" against the key \"myPrefsBytes\"."); + Serial.println("Storing myArray into the Preferences namespace \"myPrefs\" against the key \"myPrefsBytes\"."); // Note: in the next statement, to store the entire array, we must use the // size of the arrray in bytes, not the number of elements in the array. mySketchPrefs.putBytes( "myPrefsBytes", myArray, sizeof(myArray) ); - Serial.print("The size of \"myPrefsBytes\" is (in bytes): "); - Serial.println( mySketchPrefs.getBytesLength("myPrefsBytes") ); + Serial.print("The size of \"myPrefsBytes\" is (in bytes): "); Serial.println( mySketchPrefs.getBytesLength("myPrefsBytes") ); Serial.println(""); - int16_t myIntBuffer[20] = {}; // No magic about 20. Just making a buffer (array) big enough. + int16_t myIntBuffer[20] = {}; // No magic about 20. Just making a buffer (array) big enough. Serial.println("Retrieving the value of myPrefsBytes into myIntBuffer."); Serial.println(" - Note the data type of myIntBuffer matches that of myArray"); - mySketchPrefs.getBytes("myPrefsBytes", myIntBuffer, - mySketchPrefs.getBytesLength("myPrefsBytes")); + mySketchPrefs.getBytes( "myPrefsBytes", myIntBuffer, mySketchPrefs.getBytesLength("myPrefsBytes") ); Serial.println("Printing myIntBuffer..."); // In the next statement, sizeof() needs to match the data type of the elements of myArray @@ -503,11 +492,9 @@ This is best explained with an example. Here the ``Bytes`` methods are used to s } Serial.println("\r\n"); - Serial.println( - "We can see how the data from myArray is actually stored in the namespace as follows."); - uint8_t myByteBuffer[40] = {}; // No magic about 40. Just making a buffer (array) big enough. - mySketchPrefs.getBytes("myPrefsBytes", myByteBuffer, - mySketchPrefs.getBytesLength("myPrefsBytes")); + Serial.println("We can see how the data from myArray is actually stored in the namespace as follows."); + uint8_t myByteBuffer[40] = {}; // No magic about 40. Just making a buffer (array) big enough. + mySketchPrefs.getBytes( "myPrefsBytes", myByteBuffer, mySketchPrefs.getBytesLength("myPrefsBytes") ); Serial.println("Printing myByteBuffer..."); for (int i = 0; i < mySketchPrefs.getBytesLength("myPrefsBytes"); i++) { diff --git a/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino b/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino index 354ae68c0c7..17491588d86 100644 --- a/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino +++ b/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino @@ -28,8 +28,7 @@ //#define CAMERA_MODEL_ESP32_CAM_BOARD //#define CAMERA_MODEL_ESP32S2_CAM_BOARD //#define CAMERA_MODEL_ESP32S3_CAM_LCD -//#define CAMERA_MODEL_DFRobot_FireBeetle2_ESP32S3 // Has PSRAM -//#define CAMERA_MODEL_DFRobot_Romeo_ESP32S3 // Has PSRAM + #include "camera_pins.h" // =========================== diff --git a/libraries/ESP32/examples/Camera/CameraWebServer/camera_pins.h b/libraries/ESP32/examples/Camera/CameraWebServer/camera_pins.h index caa97bed606..ec9663602db 100644 --- a/libraries/ESP32/examples/Camera/CameraWebServer/camera_pins.h +++ b/libraries/ESP32/examples/Camera/CameraWebServer/camera_pins.h @@ -293,25 +293,6 @@ #define HREF_GPIO_NUM 7 #define PCLK_GPIO_NUM 13 -#elif defined(CAMERA_MODEL_DFRobot_FireBeetle2_ESP32S3) || defined(CAMERA_MODEL_DFRobot_Romeo_ESP32S3) -#define PWDN_GPIO_NUM -1 -#define RESET_GPIO_NUM -1 -#define XCLK_GPIO_NUM 45 -#define SIOD_GPIO_NUM 1 -#define SIOC_GPIO_NUM 2 - -#define Y9_GPIO_NUM 48 -#define Y8_GPIO_NUM 46 -#define Y7_GPIO_NUM 8 -#define Y6_GPIO_NUM 7 -#define Y5_GPIO_NUM 4 -#define Y4_GPIO_NUM 41 -#define Y3_GPIO_NUM 40 -#define Y2_GPIO_NUM 39 -#define VSYNC_GPIO_NUM 6 -#define HREF_GPIO_NUM 42 -#define PCLK_GPIO_NUM 5 - #else #error "Camera model not selected" #endif diff --git a/libraries/ESP32/examples/GPIO/FunctionalInterrupt/FunctionalInterrupt.ino b/libraries/ESP32/examples/GPIO/FunctionalInterrupt/FunctionalInterrupt.ino index d028f4ea036..844a14dabd1 100644 --- a/libraries/ESP32/examples/GPIO/FunctionalInterrupt/FunctionalInterrupt.ino +++ b/libraries/ESP32/examples/GPIO/FunctionalInterrupt/FunctionalInterrupt.ino @@ -1,45 +1,26 @@ -/* - * This example demonstrates usage of interrupt by detecting a button press. - * - * Setup: Connect first button between pin defined in BUTTON1 and GND - * Similarly connect second button between pin defined in BUTTON2 and GND. - * If you do not have a button simply connect a wire to those buttons - * - touching GND pin with other end of the wire will behave same as pressing the connected button. - * Wen using the bare wire be careful not to touch any other pin by accident. - * - * Note: There is no de-bounce implemented and the physical connection will normally - * trigger many more button presses than actually happened. - * This is completely normal and is not to be considered a fault. - */ - - #include #include #define BUTTON1 16 #define BUTTON2 17 -class Button{ +class Button +{ public: Button(uint8_t reqPin) : PIN(reqPin){ pinMode(PIN, INPUT_PULLUP); - }; - - void begin(){ attachInterrupt(PIN, std::bind(&Button::isr,this), FALLING); - Serial.printf("Started button interrupt on pin %d\n", PIN); - } - - ~Button(){ + }; + ~Button() { detachInterrupt(PIN); } - void ARDUINO_ISR_ATTR isr(){ + void ARDUINO_ISR_ATTR isr() { numberKeyPresses += 1; pressed = true; } - void checkPressed(){ + void checkPressed() { if (pressed) { Serial.printf("Button on pin %u has been pressed %u times\n", PIN, numberKeyPresses); pressed = false; @@ -47,7 +28,7 @@ public: } private: - const uint8_t PIN; + const uint8_t PIN; volatile uint32_t numberKeyPresses; volatile bool pressed; }; @@ -55,13 +36,9 @@ private: Button button1(BUTTON1); Button button2(BUTTON2); + void setup() { Serial.begin(115200); - while(!Serial) delay(10); - Serial.println("Starting Functional Interrupt example."); - button1.begin(); - button2.begin(); - Serial.println("Setup done."); } void loop() { diff --git a/libraries/RainMaker/src/RMakerDevice.cpp b/libraries/RainMaker/src/RMakerDevice.cpp index c042e0d22b7..e0dca8810c0 100644 --- a/libraries/RainMaker/src/RMakerDevice.cpp +++ b/libraries/RainMaker/src/RMakerDevice.cpp @@ -5,31 +5,27 @@ static esp_err_t err; typedef void (*deviceWriteCb)(Device*, Param*, const param_val_t val, void *priv_data, write_ctx_t *ctx); typedef void (*deviceReadCb)(Device*, Param*, void *priv_data, read_ctx_t *ctx); -typedef struct { - void *priv_data; - deviceWriteCb write_cb; - deviceReadCb read_cb; -} RMakerDevicePrivT; + +void (*write_cb)(Device*, Param*, param_val_t, void*, write_ctx_t*); +void (*read_cb)(Device*, Param*, void*, read_ctx_t*); +Device device; +Param param; static esp_err_t write_callback(const device_handle_t *dev_handle, const param_handle_t *par_handle, const param_val_t val, void *priv_data, write_ctx_t *ctx) { - Device device; - Param param; device.setDeviceHandle(dev_handle); param.setParamHandle(par_handle); - deviceWriteCb cb = ((RMakerDevicePrivT *)priv_data)->write_cb; - cb(&device, ¶m, val, ((RMakerDevicePrivT *)priv_data)->priv_data, ctx); + + write_cb(&device, ¶m, val, priv_data, ctx); return ESP_OK; } static esp_err_t read_callback(const device_handle_t *dev_handle, const param_handle_t *par_handle, void *priv_data, read_ctx_t *ctx) { - Device device; - Param param; device.setDeviceHandle(dev_handle); param.setParamHandle(par_handle); - deviceReadCb cb = ((RMakerDevicePrivT *)priv_data)->read_cb; - cb(&device, ¶m, ((RMakerDevicePrivT *)priv_data)->priv_data, ctx); + + read_cb(&device, ¶m, priv_data, ctx); return ESP_OK; } @@ -45,8 +41,8 @@ esp_err_t Device::deleteDevice() void Device::addCb(deviceWriteCb writeCb, deviceReadCb readCb) { - this->private_data.write_cb = writeCb; - this->private_data.read_cb = readCb; + write_cb = writeCb; + read_cb = readCb; err = esp_rmaker_device_add_cb(getDeviceHandle(), write_callback, read_callback); if(err != ESP_OK) { log_e("Failed to register callback"); diff --git a/libraries/RainMaker/src/RMakerDevice.h b/libraries/RainMaker/src/RMakerDevice.h index cba498c2cb8..0c92f79c57f 100644 --- a/libraries/RainMaker/src/RMakerDevice.h +++ b/libraries/RainMaker/src/RMakerDevice.h @@ -21,42 +21,17 @@ class Device { - public: - typedef void (*deviceWriteCb)(Device*, Param*, const param_val_t val, void *priv_data, write_ctx_t *ctx); - typedef void (*deviceReadCb)(Device*, Param*, void *priv_data, read_ctx_t *ctx); - typedef struct { - void *priv_data; - deviceWriteCb write_cb; - deviceReadCb read_cb; - } RMakerDevicePrivT; private: const device_handle_t *device_handle; - RMakerDevicePrivT private_data; - protected: - void setPrivateData(void *priv_data) { - this->private_data.priv_data = priv_data; - } - - const RMakerDevicePrivT* getDevicePrivateData() - { - return &this->private_data; - } public: Device() { device_handle = NULL; - this->private_data.priv_data = NULL; - this->private_data.write_cb = NULL; - this->private_data.read_cb = NULL; - } - + } Device(const char *dev_name, const char *dev_type = NULL, void *priv_data = NULL) { - this->private_data.priv_data = priv_data; - this->private_data.write_cb = NULL; - this->private_data.read_cb = NULL; - device_handle = esp_rmaker_device_create(dev_name, dev_type, &this->private_data); + device_handle = esp_rmaker_device_create(dev_name, dev_type, priv_data); if(device_handle == NULL){ log_e("Device create error"); } @@ -73,6 +48,9 @@ class Device { return device_handle; } + + typedef void (*deviceWriteCb)(Device*, Param*, const param_val_t val, void *priv_data, write_ctx_t *ctx); + typedef void (*deviceReadCb)(Device*, Param*, void *priv_data, read_ctx_t *ctx); esp_err_t deleteDevice(); void addCb(deviceWriteCb write_cb, deviceReadCb read_cb = NULL); @@ -116,8 +94,7 @@ class Switch : public Device } void standardSwitchDevice(const char *dev_name, void *priv_data, bool power) { - this->setPrivateData(priv_data); - esp_rmaker_device_t *dev_handle = esp_rmaker_switch_device_create(dev_name, (void *)this->getDevicePrivateData(), power); + esp_rmaker_device_t *dev_handle = esp_rmaker_switch_device_create(dev_name, priv_data, power); setDeviceHandle(dev_handle); if(dev_handle == NULL){ log_e("Switch device not created"); @@ -138,8 +115,7 @@ class LightBulb : public Device } void standardLightBulbDevice(const char *dev_name, void *priv_data, bool power) { - this->setPrivateData(priv_data); - esp_rmaker_device_t *dev_handle = esp_rmaker_lightbulb_device_create(dev_name, (void *)this->getDevicePrivateData(), power); + esp_rmaker_device_t *dev_handle = esp_rmaker_lightbulb_device_create(dev_name, priv_data, power); setDeviceHandle(dev_handle); if(dev_handle == NULL){ log_e("Light device not created"); @@ -181,8 +157,7 @@ class TemperatureSensor : public Device } void standardTemperatureSensorDevice(const char *dev_name, void *priv_data, float temp) { - this->setPrivateData(priv_data); - esp_rmaker_device_t *dev_handle = esp_rmaker_temp_sensor_device_create(dev_name, (void *)this->getDevicePrivateData(), temp); + esp_rmaker_device_t *dev_handle = esp_rmaker_temp_sensor_device_create(dev_name, priv_data, temp); setDeviceHandle(dev_handle); if(dev_handle == NULL){ log_e("Temperature Sensor device not created"); diff --git a/libraries/WiFi/examples/WiFiTelnetToSerialIPv6/WiFiTelnetToSerialIPv6.ino b/libraries/WiFi/examples/WiFiTelnetToSerialIPv6/WiFiTelnetToSerialIPv6.ino new file mode 100644 index 00000000000..05e02771dae --- /dev/null +++ b/libraries/WiFi/examples/WiFiTelnetToSerialIPv6/WiFiTelnetToSerialIPv6.ino @@ -0,0 +1,132 @@ +/* + WiFiTelnetToSerial - Example Transparent UART to Telnet Server for ESP32 + + Copyright (c) 2017 Hristo Gochkov. All rights reserved. + This file is part of the ESP32 WiFi library for Arduino environment. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#include +#include + +WiFiMulti wifiMulti; + +//Even this example state IPv6, it is dual stack and compatible with IPv4 too + +//how many clients should be able to telnet to this ESP32 +#define MAX_SRV_CLIENTS 1 +const char* ssid = "**********"; +const char* password = "**********"; + +WiFiServer server(23); +WiFiClient serverClients[MAX_SRV_CLIENTS]; + +void setup() { + Serial.begin(115200); + Serial.println("\nConnecting"); + + wifiMulti.IPv6(true); + wifiMulti.addAP(ssid, password); + wifiMulti.addAP("ssid_from_AP_2", "your_password_for_AP_2"); + wifiMulti.addAP("ssid_from_AP_3", "your_password_for_AP_3"); + + Serial.println("Connecting Wifi "); + for (int loops = 10; loops > 0; loops--) { + if (wifiMulti.run() == WL_CONNECTED) { + Serial.println(""); + Serial.print("WiFi connected "); + Serial.print("IP address: "); + Serial.println(WiFi.localIP()); + break; + } + else { + Serial.println(loops); + delay(1000); + } + } + if (wifiMulti.run() != WL_CONNECTED) { + Serial.println("WiFi connect failed"); + delay(1000); + ESP.restart(); + } + + //start UART and the server + Serial1.begin(9600); + server.begin(); + server.setNoDelay(true); + + Serial.print("Ready! Use 'telnet "); + Serial.print(WiFi.localIP()); + Serial.println(" 23' to connect"); +} + +void loop() { + uint8_t i; + if (wifiMulti.run() == WL_CONNECTED) { + //check if there are any new clients + if (server.hasClient()){ + for(i = 0; i < MAX_SRV_CLIENTS; i++){ + //find free/disconnected spot + if (!serverClients[i] || !serverClients[i].connected()){ + if(serverClients[i]) serverClients[i].stop(); + serverClients[i] = server.available(); + if (!serverClients[i]) Serial.println("available broken"); + Serial.print("New client: "); + Serial.print(i); Serial.print(' '); + Serial.println(serverClients[i].remoteIP()); + break; + } + } + if (i >= MAX_SRV_CLIENTS) { + //no free/disconnected spot so reject + server.available().stop(); + } + } + //check clients for data + for(i = 0; i < MAX_SRV_CLIENTS; i++){ + 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()); + } + } + else { + if (serverClients[i]) { + serverClients[i].stop(); + } + } + } + //check UART for data + if(Serial1.available()){ + size_t len = Serial1.available(); + uint8_t sbuf[len]; + Serial1.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()){ + serverClients[i].write(sbuf, len); + delay(1); + } + } + } + } + else { + Serial.println("WiFi not connected!"); + for(i = 0; i < MAX_SRV_CLIENTS; i++) { + if (serverClients[i]) serverClients[i].stop(); + } + delay(1000); + } +} diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp index 9e2a85f5dea..ee704c2dbca 100644 --- a/libraries/WiFi/src/WiFiClient.cpp +++ b/libraries/WiFi/src/WiFiClient.cpp @@ -23,6 +23,11 @@ #include #include +#define IN6_IS_ADDR_V4MAPPED(a) \ + ((((__const uint32_t *) (a))[0] == 0) \ + && (((__const uint32_t *) (a))[1] == 0) \ + && (((__const uint32_t *) (a))[2] == htonl (0xffff))) + #define WIFI_CLIENT_DEF_CONN_TIMEOUT_MS (3000) #define WIFI_CLIENT_MAX_WRITE_RETRY (10) #define WIFI_CLIENT_SELECT_TIMEOUT_US (1000000) @@ -210,22 +215,32 @@ int WiFiClient::connect(IPAddress ip, uint16_t port) { return connect(ip,port,_timeout); } + int WiFiClient::connect(IPAddress ip, uint16_t port, int32_t timeout_ms) { + struct sockaddr_storage serveraddr = {}; _timeout = timeout_ms; - int sockfd = socket(AF_INET, SOCK_STREAM, 0); + int sockfd = -1; + + if (ip.type() == IPv6) { + struct sockaddr_in6 *tmpaddr = (struct sockaddr_in6 *)&serveraddr; + sockfd = socket(AF_INET6, SOCK_STREAM, 0); + tmpaddr->sin6_family = AF_INET6; + memcpy(tmpaddr->sin6_addr.un.u8_addr, &ip[0], 16); + tmpaddr->sin6_port = htons(port); + } else { + struct sockaddr_in *tmpaddr = (struct sockaddr_in *)&serveraddr; + sockfd = socket(AF_INET, SOCK_STREAM, 0); + tmpaddr->sin_family = AF_INET; + tmpaddr->sin_addr.s_addr = ip; + tmpaddr->sin_port = htons(port); + } if (sockfd < 0) { log_e("socket: %d", errno); return 0; } fcntl( sockfd, F_SETFL, fcntl( sockfd, F_GETFL, 0 ) | O_NONBLOCK ); - uint32_t ip_addr = ip; - struct sockaddr_in serveraddr; - memset((char *) &serveraddr, 0, sizeof(serveraddr)); - serveraddr.sin_family = AF_INET; - memcpy((void *)&serveraddr.sin_addr.s_addr, (const void *)(&ip_addr), 4); - serveraddr.sin_port = htons(port); fd_set fdset; struct timeval tv; FD_ZERO(&fdset); @@ -294,6 +309,19 @@ int WiFiClient::connect(const char *host, uint16_t port) int WiFiClient::connect(const char *host, uint16_t port, int32_t timeout_ms) { + if (WiFiGenericClass::getStatusBits() & WIFI_WANT_IP6_BIT) { + ip_addr_t srv6; + if(!WiFiGenericClass::hostByName6(host, srv6)){ + return 0; + } + if (srv6.type == IPADDR_TYPE_V4) { + IPAddress ip(srv6.u_addr.ip4.addr); + return connect(ip, port, timeout_ms); + } else { + IPAddress ip(IPv6, (uint8_t*)&srv6.u_addr.ip6.addr[0]); + return connect(ip, port, timeout_ms); + } + } IPAddress srv((uint32_t)0); if(!WiFiGenericClass::hostByName(host, srv)){ return 0; @@ -562,8 +590,24 @@ IPAddress WiFiClient::remoteIP(int fd) const struct sockaddr_storage addr; socklen_t len = sizeof addr; getpeername(fd, (struct sockaddr*)&addr, &len); - struct sockaddr_in *s = (struct sockaddr_in *)&addr; - return IPAddress((uint32_t)(s->sin_addr.s_addr)); + + // IPv4 socket, old way + if (((struct sockaddr*)&addr)->sa_family == AF_INET) { + struct sockaddr_in *s = (struct sockaddr_in *)&addr; + return IPAddress((uint32_t)(s->sin_addr.s_addr)); + } + + // IPv6, but it might be IPv4 mapped address + if (((struct sockaddr*)&addr)->sa_family == AF_INET6) { + struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *)&addr; + if (IN6_IS_ADDR_V4MAPPED(saddr6->sin6_addr.un.u32_addr)) { + return IPAddress(IPv4, (uint8_t*)saddr6->sin6_addr.s6_addr+12); + } else { + return IPAddress(IPv6, (uint8_t*)(saddr6->sin6_addr.s6_addr)); + } + } + log_e("WiFiClient::remoteIP Not AF_INET or AF_INET6?"); + return (IPAddress(0,0,0,0)); } uint16_t WiFiClient::remotePort(int fd) const diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp index 1b74d322739..bf015ab05f8 100644 --- a/libraries/WiFi/src/WiFiGeneric.cpp +++ b/libraries/WiFi/src/WiFiGeneric.cpp @@ -768,6 +768,126 @@ WiFiGenericClass::WiFiGenericClass() { } +/** + * @brief Convert wifi_err_reason_t to a string. + * @param [in] reason The reason to be converted. + * @return A string representation of the error code. + * @note: wifi_err_reason_t values as of Mar 2023 (arduino-esp32 r2.0.7) are: (1-39, 46-51, 67-68, 200-208) and are defined in /tools/sdk/esp32/include/esp_wifi/include/esp_wifi_types.h. + */ +const char * WiFiGenericClass::disconnectReasonName(wifi_err_reason_t reason) { + switch(reason) { + //ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2,0,7) + case WIFI_REASON_UNSPECIFIED: return "UNSPECIFIED"; + case WIFI_REASON_AUTH_EXPIRE: return "AUTH_EXPIRE"; + case WIFI_REASON_AUTH_LEAVE: return "AUTH_LEAVE"; + case WIFI_REASON_ASSOC_EXPIRE: return "ASSOC_EXPIRE"; + case WIFI_REASON_ASSOC_TOOMANY: return "ASSOC_TOOMANY"; + case WIFI_REASON_NOT_AUTHED: return "NOT_AUTHED"; + case WIFI_REASON_NOT_ASSOCED: return "NOT_ASSOCED"; + case WIFI_REASON_ASSOC_LEAVE: return "ASSOC_LEAVE"; + case WIFI_REASON_ASSOC_NOT_AUTHED: return "ASSOC_NOT_AUTHED"; + case WIFI_REASON_DISASSOC_PWRCAP_BAD: return "DISASSOC_PWRCAP_BAD"; + case WIFI_REASON_DISASSOC_SUPCHAN_BAD: return "DISASSOC_SUPCHAN_BAD"; + case WIFI_REASON_BSS_TRANSITION_DISASSOC: return "BSS_TRANSITION_DISASSOC"; + case WIFI_REASON_IE_INVALID: return "IE_INVALID"; + case WIFI_REASON_MIC_FAILURE: return "MIC_FAILURE"; + case WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT: return "4WAY_HANDSHAKE_TIMEOUT"; + case WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT: return "GROUP_KEY_UPDATE_TIMEOUT"; + case WIFI_REASON_IE_IN_4WAY_DIFFERS: return "IE_IN_4WAY_DIFFERS"; + case WIFI_REASON_GROUP_CIPHER_INVALID: return "GROUP_CIPHER_INVALID"; + case WIFI_REASON_PAIRWISE_CIPHER_INVALID: return "PAIRWISE_CIPHER_INVALID"; + case WIFI_REASON_AKMP_INVALID: return "AKMP_INVALID"; + case WIFI_REASON_UNSUPP_RSN_IE_VERSION: return "UNSUPP_RSN_IE_VERSION"; + case WIFI_REASON_INVALID_RSN_IE_CAP: return "INVALID_RSN_IE_CAP"; + case WIFI_REASON_802_1X_AUTH_FAILED: return "802_1X_AUTH_FAILED"; + case WIFI_REASON_CIPHER_SUITE_REJECTED: return "CIPHER_SUITE_REJECTED"; + case WIFI_REASON_TDLS_PEER_UNREACHABLE: return "TDLS_PEER_UNREACHABLE"; + case WIFI_REASON_TDLS_UNSPECIFIED: return "TDLS_UNSPECIFIED"; + case WIFI_REASON_SSP_REQUESTED_DISASSOC: return "SSP_REQUESTED_DISASSOC"; + case WIFI_REASON_NO_SSP_ROAMING_AGREEMENT: return "NO_SSP_ROAMING_AGREEMENT"; + case WIFI_REASON_BAD_CIPHER_OR_AKM: return "BAD_CIPHER_OR_AKM"; + case WIFI_REASON_NOT_AUTHORIZED_THIS_LOCATION: return "NOT_AUTHORIZED_THIS_LOCATION"; + case WIFI_REASON_SERVICE_CHANGE_PERCLUDES_TS: return "SERVICE_CHANGE_PERCLUDES_TS"; + case WIFI_REASON_UNSPECIFIED_QOS: return "UNSPECIFIED_QOS"; + case WIFI_REASON_NOT_ENOUGH_BANDWIDTH: return "NOT_ENOUGH_BANDWIDTH"; + case WIFI_REASON_MISSING_ACKS: return "MISSING_ACKS"; + case WIFI_REASON_EXCEEDED_TXOP: return "EXCEEDED_TXOP"; + case WIFI_REASON_STA_LEAVING: return "STA_LEAVING"; + case WIFI_REASON_END_BA: return "END_BA"; + case WIFI_REASON_UNKNOWN_BA: return "UNKNOWN_BA"; + case WIFI_REASON_TIMEOUT: return "TIMEOUT"; + case WIFI_REASON_PEER_INITIATED: return "PEER_INITIATED"; + case WIFI_REASON_AP_INITIATED: return "AP_INITIATED"; + case WIFI_REASON_INVALID_FT_ACTION_FRAME_COUNT: return "INVALID_FT_ACTION_FRAME_COUNT"; + case WIFI_REASON_INVALID_PMKID: return "INVALID_PMKID"; + case WIFI_REASON_INVALID_MDE: return "INVALID_MDE"; + case WIFI_REASON_INVALID_FTE: return "INVALID_FTE"; + case WIFI_REASON_TRANSMISSION_LINK_ESTABLISH_FAILED: return "TRANSMISSION_LINK_ESTABLISH_FAILED"; + case WIFI_REASON_ALTERATIVE_CHANNEL_OCCUPIED: return "ALTERATIVE_CHANNEL_OCCUPIED"; + case WIFI_REASON_BEACON_TIMEOUT: return "BEACON_TIMEOUT"; + case WIFI_REASON_NO_AP_FOUND: return "NO_AP_FOUND"; + case WIFI_REASON_AUTH_FAIL: return "AUTH_FAIL"; + case WIFI_REASON_ASSOC_FAIL: return "ASSOC_FAIL"; + case WIFI_REASON_HANDSHAKE_TIMEOUT: return "HANDSHAKE_TIMEOUT"; + case WIFI_REASON_CONNECTION_FAIL: return "CONNECTION_FAIL"; + case WIFI_REASON_AP_TSF_RESET: return "AP_TSF_RESET"; + case WIFI_REASON_ROAMING: return "ROAMING"; + default: return ""; + } +} + +/** + * @brief Convert arduino_event_id_t to a C string. + * @param [in] id The event id to be converted. + * @return A string representation of the event id. + * @note: arduino_event_id_t values as of Mar 2023 (arduino-esp32 r2.0.7) are: 0-39 (ARDUINO_EVENT_MAX=40) and are defined in WiFiGeneric.h. + */ +const char * WiFiGenericClass::eventName(arduino_event_id_t id) { + switch(id) { + case ARDUINO_EVENT_WIFI_READY: return "WIFI_READY"; + case ARDUINO_EVENT_WIFI_SCAN_DONE: return "SCAN_DONE"; + case ARDUINO_EVENT_WIFI_STA_START: return "STA_START"; + case ARDUINO_EVENT_WIFI_STA_STOP: return "STA_STOP"; + case ARDUINO_EVENT_WIFI_STA_CONNECTED: return "STA_CONNECTED"; + case ARDUINO_EVENT_WIFI_STA_DISCONNECTED: return "STA_DISCONNECTED"; + case ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE: return "STA_AUTHMODE_CHANGE"; + case ARDUINO_EVENT_WIFI_STA_GOT_IP: return "STA_GOT_IP"; + case ARDUINO_EVENT_WIFI_STA_GOT_IP6: return "STA_GOT_IP6"; + case ARDUINO_EVENT_WIFI_STA_LOST_IP: return "STA_LOST_IP"; + case ARDUINO_EVENT_WIFI_AP_START: return "AP_START"; + case ARDUINO_EVENT_WIFI_AP_STOP: return "AP_STOP"; + case ARDUINO_EVENT_WIFI_AP_STACONNECTED: return "AP_STACONNECTED"; + case ARDUINO_EVENT_WIFI_AP_STADISCONNECTED: return "AP_STADISCONNECTED"; + case ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED: return "AP_STAIPASSIGNED"; + case ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED: return "AP_PROBEREQRECVED"; + case ARDUINO_EVENT_WIFI_AP_GOT_IP6: return "AP_GOT_IP6"; + case ARDUINO_EVENT_WIFI_FTM_REPORT: return "FTM_REPORT"; + case ARDUINO_EVENT_ETH_START: return "ETH_START"; + case ARDUINO_EVENT_ETH_STOP: return "ETH_STOP"; + case ARDUINO_EVENT_ETH_CONNECTED: return "ETH_CONNECTED"; + case ARDUINO_EVENT_ETH_DISCONNECTED: return "ETH_DISCONNECTED"; + case ARDUINO_EVENT_ETH_GOT_IP: return "ETH_GOT_IP"; + case ARDUINO_EVENT_ETH_GOT_IP6: return "ETH_GOT_IP6"; + case ARDUINO_EVENT_WPS_ER_SUCCESS: return "WPS_ER_SUCCESS"; + case ARDUINO_EVENT_WPS_ER_FAILED: return "WPS_ER_FAILED"; + case ARDUINO_EVENT_WPS_ER_TIMEOUT: return "WPS_ER_TIMEOUT"; + case ARDUINO_EVENT_WPS_ER_PIN: return "WPS_ER_PIN"; + case ARDUINO_EVENT_WPS_ER_PBC_OVERLAP: return "WPS_ER_PBC_OVERLAP"; + case ARDUINO_EVENT_SC_SCAN_DONE: return "SC_SCAN_DONE"; + case ARDUINO_EVENT_SC_FOUND_CHANNEL: return "SC_FOUND_CHANNEL"; + case ARDUINO_EVENT_SC_GOT_SSID_PSWD: return "SC_GOT_SSID_PSWD"; + case ARDUINO_EVENT_SC_SEND_ACK_DONE: return "SC_SEND_ACK_DONE"; + case ARDUINO_EVENT_PROV_INIT: return "PROV_INIT"; + case ARDUINO_EVENT_PROV_DEINIT: return "PROV_DEINIT"; + case ARDUINO_EVENT_PROV_START: return "PROV_START"; + case ARDUINO_EVENT_PROV_END: return "PROV_END"; + case ARDUINO_EVENT_PROV_CRED_RECV: return "PROV_CRED_RECV"; + case ARDUINO_EVENT_PROV_CRED_FAIL: return "PROV_CRED_FAIL"; + case ARDUINO_EVENT_PROV_CRED_SUCCESS: return "PROV_CRED_SUCCESS"; + default: return ""; + } +} + const char * WiFiGenericClass::getHostname() { return get_esp_netif_hostname(); @@ -906,33 +1026,15 @@ void WiFiGenericClass::removeEvent(wifi_event_id_t id) * callback for WiFi events * @param arg */ -#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG -const char * arduino_event_names[] = { - "WIFI_READY", - "SCAN_DONE", - "STA_START", "STA_STOP", "STA_CONNECTED", "STA_DISCONNECTED", "STA_AUTHMODE_CHANGE", "STA_GOT_IP", "STA_GOT_IP6", "STA_LOST_IP", - "AP_START", "AP_STOP", "AP_STACONNECTED", "AP_STADISCONNECTED", "AP_STAIPASSIGNED", "AP_PROBEREQRECVED", "AP_GOT_IP6", - "FTM_REPORT", - "ETH_START", "ETH_STOP", "ETH_CONNECTED", "ETH_DISCONNECTED", "ETH_GOT_IP", "ETH_GOT_IP6", - "WPS_ER_SUCCESS", "WPS_ER_FAILED", "WPS_ER_TIMEOUT", "WPS_ER_PIN", "WPS_ER_PBC_OVERLAP", - "SC_SCAN_DONE", "SC_FOUND_CHANNEL", "SC_GOT_SSID_PSWD", "SC_SEND_ACK_DONE", - "PROV_INIT", "PROV_DEINIT", "PROV_START", "PROV_END", "PROV_CRED_RECV", "PROV_CRED_FAIL", "PROV_CRED_SUCCESS" -}; -#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", "CONNECTION_FAIL" }; -#define reason2str(r) ((r>176)?system_event_reasons[r-176]:system_event_reasons[r-1]) -#endif esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event) { static bool first_connect = true; - if(event->event_id < ARDUINO_EVENT_MAX) { - log_d("Arduino Event: %d - %s", event->event_id, arduino_event_names[event->event_id]); - } + if(!event) return ESP_OK; //Null would crash this function + + log_d("Arduino Event: %d - %s", event->event_id, WiFi.eventName(event->event_id)); if(event->event_id == ARDUINO_EVENT_WIFI_SCAN_DONE) { WiFiScanClass::_scanDone(); - } else if(event->event_id == ARDUINO_EVENT_WIFI_STA_START) { WiFiSTAClass::_setStatus(WL_DISCONNECTED); setStatusBits(STA_STARTED_BIT); @@ -945,14 +1047,14 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event) } else if(event->event_id == ARDUINO_EVENT_WIFI_STA_CONNECTED) { WiFiSTAClass::_setStatus(WL_IDLE_STATUS); setStatusBits(STA_CONNECTED_BIT); - - //esp_netif_create_ip6_linklocal(esp_netifs[ESP_IF_WIFI_STA]); + if (getStatusBits() & WIFI_WANT_IP6_BIT) + esp_netif_create_ip6_linklocal(esp_netifs[ESP_IF_WIFI_STA]); } else if(event->event_id == ARDUINO_EVENT_WIFI_STA_DISCONNECTED) { uint8_t reason = event->event_info.wifi_sta_disconnected.reason; // Reason 0 causes crash, use reason 1 (UNSPECIFIED) instead if(!reason) reason = WIFI_REASON_UNSPECIFIED; - log_w("Reason: %u - %s", reason, reason2str(reason)); + log_w("Reason: %u - %s", reason, WiFi.disconnectReasonName((wifi_err_reason_t)reason)); if(reason == WIFI_REASON_NO_AP_FOUND) { WiFiSTAClass::_setStatus(WL_NO_SSID_AVAIL); } else if((reason == WIFI_REASON_AUTH_FAIL) && !first_connect){ @@ -1450,35 +1552,82 @@ static void wifi_dns_found_callback(const char *name, const ip_addr_t *ipaddr, v } /** - * Resolve the given hostname to an IP address. If passed hostname is an IP address, it will be parsed into IPAddress structure. - * @param aHostname Name to be resolved or string containing IP address + * IPv6 compatible DNS callback + * @param name + * @param ipaddr + * @param callback_arg + */ +static void wifi_dns6_found_callback(const char *name, const ip_addr_t *ipaddr, void *callback_arg) +{ + struct dns_api_msg *msg = (struct dns_api_msg *)callback_arg; + + if(ipaddr && !msg->result) { + msg->ip_addr = *ipaddr; + msg->result = 1; + } else { + msg->result = -1; + } + xEventGroupSetBits(_arduino_event_group, WIFI_DNS_DONE_BIT); +} + +/** + * Resolve the given hostname to an IP address. + * @param aHostname Name to be resolved * @param aResult IPAddress structure to store the returned IP address * @return 1 if aIPAddrString was successfully converted to an IP address, * else error code */ int WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResult) { - if (!aResult.fromString(aHostname)) - { - ip_addr_t addr; - aResult = static_cast(0); - waitStatusBits(WIFI_DNS_IDLE_BIT, 16000); - clearStatusBits(WIFI_DNS_IDLE_BIT | WIFI_DNS_DONE_BIT); - err_t err = dns_gethostbyname(aHostname, &addr, &wifi_dns_found_callback, &aResult); - if(err == ERR_OK && addr.u_addr.ip4.addr) { - aResult = addr.u_addr.ip4.addr; - } else if(err == ERR_INPROGRESS) { - waitStatusBits(WIFI_DNS_DONE_BIT, 15000); //real internal timeout in lwip library is 14[s] - clearStatusBits(WIFI_DNS_DONE_BIT); - } - setStatusBits(WIFI_DNS_IDLE_BIT); - if((uint32_t)aResult == 0){ - log_e("DNS Failed for %s", aHostname); - } + ip_addr_t addr; + aResult = static_cast(0); + waitStatusBits(WIFI_DNS_IDLE_BIT, 16000); + clearStatusBits(WIFI_DNS_IDLE_BIT | WIFI_DNS_DONE_BIT); + err_t err = dns_gethostbyname(aHostname, &addr, &wifi_dns_found_callback, &aResult); + if(err == ERR_OK && addr.u_addr.ip4.addr) { + aResult = addr.u_addr.ip4.addr; + } else if(err == ERR_INPROGRESS) { + waitStatusBits(WIFI_DNS_DONE_BIT, 15000); //real internal timeout in lwip library is 14[s] + clearStatusBits(WIFI_DNS_DONE_BIT); + } + setStatusBits(WIFI_DNS_IDLE_BIT); + if((uint32_t)aResult == 0){ + log_e("DNS Failed for %s", aHostname); } return (uint32_t)aResult != 0; } +/** + * Resolve the given hostname to an IP6 address. + * @param aHostname Name to be resolved + * @param aResult IPv6Address structure to store the returned IP address + * @return 1 if aHostname was successfully converted to an IP address, + * else error code + */ +int WiFiGenericClass::hostByName6(const char* aHostname, ip_addr_t& aResult) +{ + ip_addr_t addr; + struct dns_api_msg arg; + + memset(&arg, 0x0, sizeof(arg)); + waitStatusBits(WIFI_DNS_IDLE_BIT, 16000); + clearStatusBits(WIFI_DNS_IDLE_BIT | WIFI_DNS_DONE_BIT); + + err_t err = dns_gethostbyname_addrtype(aHostname, &addr, &wifi_dns6_found_callback, + &arg, LWIP_DNS_ADDRTYPE_IPV6_IPV4); + if(err == ERR_OK) { + aResult = addr; + } else if(err == ERR_INPROGRESS) { + waitStatusBits(WIFI_DNS_DONE_BIT, 15000); //real internal timeout in lwip library is 14[s] + clearStatusBits(WIFI_DNS_DONE_BIT); + if (arg.result == 1) { + aResult = arg.ip_addr; + } + } + setStatusBits(WIFI_DNS_IDLE_BIT); + return (uint32_t)err == ERR_OK || (err == ERR_INPROGRESS && arg.result == 1); +} + IPAddress WiFiGenericClass::calculateNetworkID(IPAddress ip, IPAddress subnet) { IPAddress networkID; diff --git a/libraries/WiFi/src/WiFiGeneric.h b/libraries/WiFi/src/WiFiGeneric.h index 2f670a34d05..236f07b4289 100644 --- a/libraries/WiFi/src/WiFiGeneric.h +++ b/libraries/WiFi/src/WiFiGeneric.h @@ -138,6 +138,7 @@ static const int WIFI_SCANNING_BIT = BIT11; static const int WIFI_SCAN_DONE_BIT= BIT12; static const int WIFI_DNS_IDLE_BIT = BIT13; static const int WIFI_DNS_DONE_BIT = BIT14; +static const int WIFI_WANT_IP6_BIT = BIT15; typedef enum { WIFI_RX_ANT0 = 0, @@ -151,6 +152,11 @@ typedef enum { WIFI_TX_ANT_AUTO } wifi_tx_ant_t; +struct dns_api_msg { + ip_addr_t ip_addr; + int result; +}; + class WiFiGenericClass { public: @@ -188,12 +194,14 @@ class WiFiGenericClass static bool setDualAntennaConfig(uint8_t gpio_ant1, uint8_t gpio_ant2, wifi_rx_ant_t rx_mode, wifi_tx_ant_t tx_mode); + const char * disconnectReasonName(wifi_err_reason_t reason); + const char * eventName(arduino_event_id_t id); static const char * getHostname(); static bool setHostname(const char * hostname); static bool hostname(const String& aHostname) { return setHostname(aHostname.c_str()); } static esp_err_t _eventCallback(arduino_event_t *event); - + static void useStaticBuffers(bool bufferMode); static bool useStaticBuffers(); @@ -212,6 +220,7 @@ class WiFiGenericClass public: static int hostByName(const char *aHostname, IPAddress &aResult); + static int hostByName6(const char *aHostname, ip_addr_t& aResult); static IPAddress calculateNetworkID(IPAddress ip, IPAddress subnet); static IPAddress calculateBroadcast(IPAddress ip, IPAddress subnet); diff --git a/libraries/WiFi/src/WiFiMulti.cpp b/libraries/WiFi/src/WiFiMulti.cpp index 3d69e481293..9e7f03c6531 100644 --- a/libraries/WiFi/src/WiFiMulti.cpp +++ b/libraries/WiFi/src/WiFiMulti.cpp @@ -30,6 +30,7 @@ WiFiMulti::WiFiMulti() { + ipv6_support = false; } WiFiMulti::~WiFiMulti() @@ -160,6 +161,8 @@ uint8_t WiFiMulti::run(uint32_t connectTimeout) log_i("[WIFI] Connecting BSSID: %02X:%02X:%02X:%02X:%02X:%02X SSID: %s Channel: %d (%d)", bestBSSID[0], bestBSSID[1], bestBSSID[2], bestBSSID[3], bestBSSID[4], bestBSSID[5], bestNetwork.ssid, bestChannel, bestNetworkDb); WiFi.begin(bestNetwork.ssid, bestNetwork.passphrase, bestChannel, bestBSSID); + if (ipv6_support == true) + WiFi.IPv6(true); status = WiFi.status(); auto startTime = millis(); @@ -202,3 +205,7 @@ uint8_t WiFiMulti::run(uint32_t connectTimeout) return status; } + +void WiFiMulti::IPv6(bool state) { + ipv6_support = state; +} diff --git a/libraries/WiFi/src/WiFiMulti.h b/libraries/WiFi/src/WiFiMulti.h index 38ddb5d9f95..bbeb78dc860 100644 --- a/libraries/WiFi/src/WiFiMulti.h +++ b/libraries/WiFi/src/WiFiMulti.h @@ -42,10 +42,12 @@ class WiFiMulti bool addAP(const char* ssid, const char *passphrase = NULL); + void IPv6(bool state); uint8_t run(uint32_t connectTimeout=5000); private: std::vector APlist; + bool ipv6_support; }; #endif /* WIFICLIENTMULTI_H_ */ diff --git a/libraries/WiFi/src/WiFiSTA.cpp b/libraries/WiFi/src/WiFiSTA.cpp index 185aaa84503..625d7cc55de 100644 --- a/libraries/WiFi/src/WiFiSTA.cpp +++ b/libraries/WiFi/src/WiFiSTA.cpp @@ -748,6 +748,19 @@ bool WiFiSTAClass::enableIpV6() return esp_netif_create_ip6_linklocal(get_esp_interface_netif(ESP_IF_WIFI_STA)) == ESP_OK; } +/** + * Enable IPv6 support on the station interface. + * @return true on success + */ +bool WiFiSTAClass::IPv6(bool state) +{ + if (state) + WiFiGenericClass::setStatusBits(WIFI_WANT_IP6_BIT); + else + WiFiGenericClass::clearStatusBits(WIFI_WANT_IP6_BIT); + return true; +} + /** * Get the station interface IPv6 address. * @return IPv6Address diff --git a/libraries/WiFi/src/WiFiSTA.h b/libraries/WiFi/src/WiFiSTA.h index 0b8f9daf053..98172ae24fc 100644 --- a/libraries/WiFi/src/WiFiSTA.h +++ b/libraries/WiFi/src/WiFiSTA.h @@ -91,6 +91,7 @@ class WiFiSTAClass uint8_t subnetCIDR(); bool enableIpV6(); + bool IPv6(bool state); IPv6Address localIPv6(); // STA WiFi info diff --git a/libraries/WiFi/src/WiFiServer.cpp b/libraries/WiFi/src/WiFiServer.cpp index db21858125b..ad2cb7fb364 100644 --- a/libraries/WiFi/src/WiFiServer.cpp +++ b/libraries/WiFi/src/WiFiServer.cpp @@ -47,8 +47,8 @@ WiFiClient WiFiServer::available(){ _accepted_sockfd = -1; } else { - struct sockaddr_in _client; - int cs = sizeof(struct sockaddr_in); + struct sockaddr_in6 _client; + int cs = sizeof(struct sockaddr_in6); #ifdef ESP_IDF_VERSION_MAJOR client_sock = lwip_accept(sockfd, (struct sockaddr *)&_client, (socklen_t*)&cs); #else @@ -76,14 +76,23 @@ void WiFiServer::begin(uint16_t port, int enable){ if(port){ _port = port; } - struct sockaddr_in server; - sockfd = socket(AF_INET , SOCK_STREAM, 0); + struct sockaddr_in6 server; + sockfd = socket(AF_INET6 , SOCK_STREAM, 0); if (sockfd < 0) return; setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)); - server.sin_family = AF_INET; - server.sin_addr.s_addr = _addr; - server.sin_port = htons(_port); + server.sin6_family = AF_INET6; + if (_addr.type() == IPv4) { + log_e("---------------- IPv4"); + memcpy(server.sin6_addr.s6_addr+11, (uint8_t*)&_addr[0], 4); + server.sin6_addr.s6_addr[10] = 0xFF; + server.sin6_addr.s6_addr[11] = 0xFF; + } else { + log_e("---------------- IPv6"); + memcpy(server.sin6_addr.s6_addr, (uint8_t*)&_addr[0], 16); + } + memset(server.sin6_addr.s6_addr, 0x0, 16); + server.sin6_port = htons(_port); if(bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0) return; if(listen(sockfd , _max_clients) < 0) @@ -106,8 +115,8 @@ bool WiFiServer::hasClient() { if (_accepted_sockfd >= 0) { return true; } - struct sockaddr_in _client; - int cs = sizeof(struct sockaddr_in); + struct sockaddr_in6 _client; + int cs = sizeof(struct sockaddr_in6); #ifdef ESP_IDF_VERSION_MAJOR _accepted_sockfd = lwip_accept(sockfd, (struct sockaddr *)&_client, (socklen_t*)&cs); #else diff --git a/libraries/WiFi/src/WiFiServer.h b/libraries/WiFi/src/WiFiServer.h index 346986abad5..d933231bdbb 100644 --- a/libraries/WiFi/src/WiFiServer.h +++ b/libraries/WiFi/src/WiFiServer.h @@ -37,7 +37,6 @@ class WiFiServer : public Server { public: void listenOnLocalhost(){} - // _addr(INADDR_ANY) is the same as _addr() ==> 0.0.0.0 WiFiServer(uint16_t port=80, uint8_t max_clients=4):sockfd(-1),_accepted_sockfd(-1),_addr(),_port(port),_max_clients(max_clients),_listening(false),_noDelay(false) { log_v("WiFiServer::WiFiServer(port=%d, ...)", port); } diff --git a/libraries/WiFi/src/WiFiUdp.cpp b/libraries/WiFi/src/WiFiUdp.cpp index 556f9a8afcc..0226dcdb2cf 100644 --- a/libraries/WiFi/src/WiFiUdp.cpp +++ b/libraries/WiFi/src/WiFiUdp.cpp @@ -44,13 +44,17 @@ uint8_t WiFiUDP::begin(IPAddress address, uint16_t port){ server_port = port; - tx_buffer = new char[1460]; + tx_buffer = (char *)malloc(1460); if(!tx_buffer){ log_e("could not create tx buffer: %d", errno); return 0; } +#if LWIP_IPV6 + if ((udp_server=socket(address.isV6() ? AF_INET6 : AF_INET, SOCK_DGRAM, 0)) == -1){ +#else if ((udp_server=socket(AF_INET, SOCK_DGRAM, 0)) == -1){ +#endif log_e("could not create socket: %d", errno); return 0; } @@ -62,45 +66,87 @@ uint8_t WiFiUDP::begin(IPAddress address, uint16_t port){ return 0; } - struct sockaddr_in addr; - memset((char *) &addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_port = htons(server_port); - addr.sin_addr.s_addr = (in_addr_t)address; - if(bind(udp_server , (struct sockaddr*)&addr, sizeof(addr)) == -1){ + struct sockaddr_storage serveraddr = {}; + size_t sock_size = 0; +#if LWIP_IPV6 + if (address.isV6()) { + struct sockaddr_in6 *tmpaddr = (struct sockaddr_in6 *)&serveraddr; + ip_addr_t * ip_addr = (ip_addr_t*) address; + memset((char *) tmpaddr, 0, sizeof(struct sockaddr_in)); + tmpaddr->sin6_family = AF_INET6; + tmpaddr->sin6_port = htons(server_port); + inet6_addr_from_ip6addr(&tmpaddr->sin6_addr, ip_2_ip6(ip_addr)); + tmpaddr->sin6_flowinfo = 0; + sock_size = sizeof(sockaddr_in6); + } else +#endif + if (1) { + struct sockaddr_in *tmpaddr = (struct sockaddr_in *)&serveraddr; + memset((char *) tmpaddr, 0, sizeof(struct sockaddr_in)); + tmpaddr->sin_family = AF_INET; + tmpaddr->sin_port = htons(server_port); + tmpaddr->sin_addr.s_addr = (in_addr_t)address; + sock_size = sizeof(sockaddr_in); + } + if(bind(udp_server , (sockaddr*)&serveraddr, sock_size) == -1){ log_e("could not bind socket: %d", errno); stop(); return 0; } + fcntl(udp_server, F_SETFL, O_NONBLOCK); return 1; } uint8_t WiFiUDP::begin(uint16_t p){ - return begin(IPAddress(INADDR_ANY), p); + return begin(IPAddress(), p); } uint8_t WiFiUDP::beginMulticast(IPAddress a, uint16_t p){ - if(begin(IPAddress(INADDR_ANY), p)){ - if(a != 0){ - struct ip_mreq mreq; - mreq.imr_multiaddr.s_addr = (in_addr_t)a; - mreq.imr_interface.s_addr = INADDR_ANY; - if (setsockopt(udp_server, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) { + if(begin(IPAddress(), p)){ + ip_addr_t * ip_addr = (ip_addr_t*) a; + if (ip_addr_ismulticast(ip_addr)) { +#if LWIP_IPV6 + if (IP_IS_V6_VAL(*ip_addr)) { + struct ipv6_mreq mreq; + bool joined = false; + inet6_addr_from_ip6addr(&mreq.ipv6mr_multiaddr, ip_2_ip6(ip_addr)); + + // iterate on each interface + for (netif* intf = netif_list; intf != nullptr; intf = intf->next) { + mreq.ipv6mr_interface = intf->num + 1; + if (intf->name[0] != 'l' || intf->name[1] != 'o') { // skip 'lo' local interface + int ret = setsockopt(udp_server, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, sizeof(mreq)); + if (ret >= 0) { joined = true; } + } + } + if (!joined) { log_e("could not join igmp: %d", errno); stop(); return 0; + } + } else +#endif + if (1) { + struct ip_mreq mreq; + mreq.imr_multiaddr.s_addr = (in_addr_t)a; + mreq.imr_interface.s_addr = INADDR_ANY; + if (setsockopt(udp_server, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) { + log_e("could not join igmp: %d", errno); + stop(); + return 0; + } } multicast_ip = a; + return 1; } - return 1; } return 0; } void WiFiUDP::stop(){ if(tx_buffer){ - delete[] tx_buffer; + free(tx_buffer); tx_buffer = NULL; } tx_buffer_len = 0; @@ -111,19 +157,37 @@ void WiFiUDP::stop(){ } if(udp_server == -1) return; - if(multicast_ip != 0){ - struct ip_mreq mreq; - mreq.imr_multiaddr.s_addr = (in_addr_t)multicast_ip; - mreq.imr_interface.s_addr = (in_addr_t)0; - setsockopt(udp_server, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)); - multicast_ip = IPAddress(INADDR_ANY); + ip_addr_t * mcast_addr = (ip_addr_t*) multicast_ip; + if (!ip_addr_isany(mcast_addr)) { +#if LWIP_IPV6 + if (IP_IS_V6(mcast_addr)) { + struct ipv6_mreq mreq; + inet6_addr_from_ip6addr(&mreq.ipv6mr_multiaddr, ip_2_ip6(mcast_addr)); + + // iterate on each interface + for (netif* intf = netif_list; intf != nullptr; intf = intf->next) { + mreq.ipv6mr_interface = intf->num + 1; + if (intf->name[0] != 'l' || intf->name[1] != 'o') { // skip 'lo' local interface + int ret = setsockopt(udp_server, IPPROTO_IPV6, IPV6_LEAVE_GROUP, &mreq, sizeof(mreq)); + } + } + } else +#endif + if (1) { + struct ip_mreq mreq; + mreq.imr_multiaddr.s_addr = (in_addr_t)multicast_ip; + mreq.imr_interface.s_addr = (in_addr_t)0; + setsockopt(udp_server, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)); + } + // now common code for v4/v6 + multicast_ip = IPAddress(); } close(udp_server); udp_server = -1; } int WiFiUDP::beginMulticastPacket(){ - if(!server_port || multicast_ip == IPAddress(INADDR_ANY)) + if(!server_port || multicast_ip == IPAddress()) return 0; remote_ip = multicast_ip; remote_port = server_port; @@ -136,7 +200,7 @@ int WiFiUDP::beginPacket(){ // allocate tx_buffer if is necessary if(!tx_buffer){ - tx_buffer = new char[1460]; + tx_buffer = (char *)malloc(1460); if(!tx_buffer){ log_e("could not create tx buffer: %d", errno); return 0; @@ -176,14 +240,29 @@ int WiFiUDP::beginPacket(const char *host, uint16_t port){ } int WiFiUDP::endPacket(){ - struct sockaddr_in recipient; - recipient.sin_addr.s_addr = (uint32_t)remote_ip; - recipient.sin_family = AF_INET; - recipient.sin_port = htons(remote_port); - int sent = sendto(udp_server, tx_buffer, tx_buffer_len, 0, (struct sockaddr*) &recipient, sizeof(recipient)); - if(sent < 0){ - log_e("could not send data: %d", errno); - return 0; + + if (remote_ip.isV4()) { + struct sockaddr_in recipient; + recipient.sin_addr.s_addr = (uint32_t)remote_ip; + recipient.sin_family = AF_INET; + recipient.sin_port = htons(remote_port); + int sent = sendto(udp_server, tx_buffer, tx_buffer_len, 0, (struct sockaddr*) &recipient, sizeof(recipient)); + if(sent < 0){ + log_e("could not send data: %d", errno); + return 0; + } + } else { + struct sockaddr_in6 recipient; + recipient.sin6_flowinfo = 0; + recipient.sin6_addr = *(in6_addr*)(ip_addr_t*)remote_ip; + recipient.sin6_family = AF_INET6; + recipient.sin6_port = htons(remote_port); + recipient.sin6_scope_id = 0; + int sent = sendto(udp_server, tx_buffer, tx_buffer_len, 0, (struct sockaddr*) &recipient, sizeof(recipient)); + if(sent < 0){ + log_e("could not send data: %d", errno); + return 0; + } } return 1; } @@ -207,13 +286,14 @@ size_t WiFiUDP::write(const uint8_t *buffer, size_t size){ int WiFiUDP::parsePacket(){ if(rx_buffer) return 0; - struct sockaddr_in si_other; - int slen = sizeof(si_other) , len; + struct sockaddr_storage si_other_storage; // enough storage for v4 and v6 + socklen_t slen = sizeof(sockaddr_storage); + int len; char *buf = (char *)malloc(1460); if(!buf) { return 0; } - if ((len = recvfrom(udp_server, buf, 1460, MSG_DONTWAIT, (struct sockaddr *) &si_other, (socklen_t *)&slen)) == -1){ + if ((len = recvfrom(udp_server, buf, 1460, MSG_DONTWAIT, (struct sockaddr *) &si_other_storage, (socklen_t *)&slen)) == -1){ free(buf); if(errno == EWOULDBLOCK){ return 0; @@ -221,8 +301,28 @@ int WiFiUDP::parsePacket(){ log_e("could not receive data: %d", errno); return 0; } - remote_ip = IPAddress(si_other.sin_addr.s_addr); - remote_port = ntohs(si_other.sin_port); + if (si_other_storage.ss_family == AF_INET) { + struct sockaddr_in &si_other = (sockaddr_in&) si_other_storage; + remote_ip = IPAddress(si_other.sin_addr.s_addr); + remote_port = ntohs(si_other.sin_port); + } +#if LWIP_IPV6 + else if (si_other_storage.ss_family == AF_INET6) { + struct sockaddr_in6 &si_other = (sockaddr_in6&) si_other_storage; + remote_ip = IPAddress(IPv6, (uint8_t*)&si_other.sin6_addr); // force IPv6 + ip_addr_t *ip_addr = (ip_addr_t*) remote_ip; + /* Dual-stack: Unmap IPv4 mapped IPv6 addresses */ + if (IP_IS_V6_VAL(*ip_addr) && ip6_addr_isipv4mappedipv6(ip_2_ip6(ip_addr))) { + unmap_ipv4_mapped_ipv6(ip_2_ip4(ip_addr), ip_2_ip6(ip_addr)); + IP_SET_TYPE_VAL(*ip_addr, IPADDR_TYPE_V4); + } + remote_port = ntohs(si_other.sin6_port); + } +#endif // LWIP_IPV6=1 + else { + remote_ip = *IP_ADDR_ANY; + remote_port = 0; + } if (len > 0) { rx_buffer = new(std::nothrow) cbuf(len); rx_buffer->write(buf, len); diff --git a/libraries/WiFiProv/examples/WiFiProv/README.md b/libraries/WiFiProv/examples/WiFiProv/README.md index 70da0052c3d..bae3eadf297 100644 --- a/libraries/WiFiProv/examples/WiFiProv/README.md +++ b/libraries/WiFiProv/examples/WiFiProv/README.md @@ -1,120 +1,116 @@ # Provisioning for Arduino -This sketch implements provisioning using various IDF components. +This sketch implements provisioning using various IDF components -## Description +# Description -This example allows Arduino users to choose either BLE or SOFTAP as the mode of transport for provisioning-related communication between the device (to be provisioned) and the client (owner of the device). +This example allows Arduino user to choose either BLE or SOFTAP as a mode of transport, over which the provisioning related communication is to take place, between the device (to be provisioned) and the client (owner of the device). -## APIs introduced for provisioning +# APIs introduced for provisioning -### WiFi.onEvent() +## WiFi.onEvent() -Using this API, users can register to receive WiFi Events and Provisioning Events. +Using this API user can register to receive WiFi Events and Provisioning Events -### WiFi.beginProvision() +## WiFi.beginProvision() -``` -WiFi.beginProvision(void (*scheme_cb)(), wifi_prov_scheme_event_handler_t scheme_event_handler, wifi_prov_security_t security, char *pop, char *service_name, char *service_key, uint8_t *uuid); -``` +WiFi.beginProvision(void ( * scheme_cb)(), wifi_prov_scheme_event_handler_t scheme_event_handler, wifi_prov_security_t security, char * pop, char * service_name, char * service_key, uint8_t * uuid); #### Parameters passed -- Function pointer: Choose the mode of transfer - - `provSchemeBLE` - Using BLE - - `provSchemeSoftAP` - Using SoftAP - -- `security`: Choose the security type - - `WIFI_PROV_SECURITY_1` - Enables secure communication with a secure handshake using key exchange and proof of possession (pop), and encryption/decryption of messages. - - `WIFI_PROV_SECURITY_0` - Does not provide application-level security, allowing plain text communication. +* function pointer : choose the mode of transfer + * provSchemeBLE - Using BLE + * provSchemeSoftAP - Using SoftAP + +* security : choose security type + * WIFI_PROV_SECURITY_1 - It allows secure communication which consists of secure handshake using key exchange and proof of possession (pop) and encryption/decryption of messages. -- `scheme_event_handler`: Specify the handlers according to the chosen mode - - BLE: - - `WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM` - Used when the application doesn't need BT and BLE after provisioning is finished. - - `WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BLE` - Used when the application doesn't need BLE to be active after provisioning is finished. - - `WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BT` - Used when the application doesn't need BT to be active after provisioning is finished. + * WIFI_PROV_SECURITY_0 - It do not provide application level security, it involve simply plain text communication. - - SoftAP: - - `WIFI_PROV_EVENT_HANDLER_NONE` +* scheme_event_handler : specify the handlers according to the mode chosen + * BLE : + - WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM - This scheme event handler is used when application doesn't need BT and BLE after provisioning is finised + - WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BLE - This scheme event handler is used when application doesn't need BLE to be active after provisioning is finised + - WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BT - This scheme event handler is used when application doesn't need BT to be active after provisioning is finised -- `pop`: String used for authentication. + * SoftAp : + - WIFI_PROV_EVENT_HANDLER_NONE -- `service_name`: Specify the service name for the device. If not specified, the default chosen name is `PROV_XXX`, where XXX represents the last 3 bytes of the MAC address. +* pop : It is the string that is used to provide the authentication. -- `service_key`: Specify the service key. If the chosen mode of provisioning is BLE, the `service_key` is always NULL. +* service_name : Specify service name for the device, if it is not specified then default chosen name is PROV_XXX where XXX are the last 3 bytes of the MAC address. -- `uuid`: Users can specify their own 128-bit UUID while provisioning using BLE. If not specified, the default value is: +* service_key : Specify service key, if chosen mode of provisioning is BLE then service_key is always NULL -``` -{ 0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, 0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02 } -``` +* uuid : user can specify there own 128 bit UUID while provisioning using BLE, if not specified then default value taken is + - { 0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, + 0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02, } -- `reset_provisioned`: Resets previously provisioned data before initializing. Using this prevents problem when the device automatically connects to previously connected WiFi and therefore cannot be found. +# NOTE -**NOTE:** If none of the parameters are specified in `beginProvision`, default provisioning takes place using SoftAP with the following settings: -- `scheme = WIFI_PROV_SCHEME_SOFTAP` -- `scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE` -- `security = WIFI_PROV_SECURITY_1` -- `pop = "abcd1234"` -- `service_name = "PROV_XXX"` -- `service_key = NULL` -- `uuid = NULL` -- `reset_provisioned = false` +* If none of the parameters are specified in beginProvision then default provisioning takes place using SoftAP with + * scheme = WIFI_PROV_SCHEME_SOFTAP + * scheme_event_handler = WIFI_PROV_EVENT_HANDLER_NONE + * security = WIFI_PROV_SECURITY_1 + * pop = "abcd1234" + * service_name = "PROV_XXX" + * service_key = NULL + * uuid = NULL -## Flashing -This sketch takes up a lot of space for the app and may not be able to flash with default setting on some chips. -If you see Error like this: "Sketch too big" -In Arduino IDE go to: Tools > Partition scheme > chose anything that has more than 1.4MB APP for example `No OTA (2MB APP/2MB SPIFFS)` +# Log Output +* Enable debuger : [ Tools -> Core Debug Level -> Info ] -## Log Output -- To enable debugging: Go to Tools -> Core Debug Level -> Info. +# Provisioning Tools +https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/provisioning/wifi_provisioning.html#provisioning-tools -## Provisioning Tools -[Provisioning Tools](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/provisioning/wifi_provisioning.html#provisioning-tools) +# Example output -## Example Output +## Provisioning using SoftAP -### Provisioning using SoftAP ``` [I][WiFiProv.cpp:117] beginProvision(): Starting AP using SOFTAP - service_name: PROV_XXX - password: 123456789 - pop: abcd1234 + service_name : PROV_XXX + password : 123456789 + pop : abcd1234 Provisioning started -Give Credentials of your access point using "Android app" +Give Credentials of your access point using " Android app " Received Wi-Fi credentials - SSID: GIONEE M2 - Password: 123456789 + SSID : GIONEE M2 + Password : 123456789 -Connected IP address: 192.168.43.120 +Connected IP address : 192.168.43.120 Provisioning Successful Provisioning Ends + ``` -### Provisioning using BLE +## Provisioning using BLE + ``` [I][WiFiProv.cpp:115] beginProvision(): Starting AP using BLE - service_name: PROV_XXX - pop: abcd1234 + service_name : PROV_XXX + pop : abcd1234 Provisioning started -Give Credentials of your access point using "Android app" +Give Credentials of your access point using " Android app " Received Wi-Fi credentials - SSID: GIONEE M2 - Password: 123456789 + SSID : GIONEE M2 + Password : 123456789 -Connected IP address: 192.168.43.120 +Connected IP address : 192.168.43.120 Provisioning Successful Provisioning Ends + ``` -### Credentials are available on the device +## Credentials are available on device + +``` +[I][WiFiProv.cpp:146] beginProvision(): Aleardy Provisioned, starting Wi-Fi STA +[I][WiFiProv.cpp:150] beginProvision(): SSID : Wce***** +[I][WiFiProv.cpp:152] beginProvision(): CONNECTING TO THE ACCESS POINT : +Connected IP address : 192.168.43.120 ``` -[I][WiFiProv.cpp:146] beginProvision(): Already Provisioned, starting Wi-Fi STA -[I][WiFiProv.cpp:150] beginProvision(): SSID: Wce***** -[I][WiFiProv.cpp:152] beginProvision(): CONNECTING TO THE ACCESS POINT: -Connected IP address: 192.168.43.120 -``` \ No newline at end of file diff --git a/libraries/WiFiProv/examples/WiFiProv/WiFiProv.ino b/libraries/WiFiProv/examples/WiFiProv/WiFiProv.ino index 28c470f7241..9d6de5f00f3 100644 --- a/libraries/WiFiProv/examples/WiFiProv/WiFiProv.ino +++ b/libraries/WiFiProv/examples/WiFiProv/WiFiProv.ino @@ -1,23 +1,5 @@ -/* -Please read README.md file in this folder, or on the web: -https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFiProv/examples/WiFiProv - -Note: This sketch takes up a lot of space for the app and may not be able to flash with default setting on some chips. - If you see Error like this: "Sketch too big" - In Arduino IDE go to: Tools > Partition scheme > chose anything that has more than 1.4MB APP - - for example "No OTA (2MB APP/2MB SPIFFS)" -*/ - #include "WiFiProv.h" #include "WiFi.h" - -// #define USE_SOFT_AP // Uncomment if you want to enforce using Soft AP method instead of BLE - -const char * pop = "abcd1234"; // Proof of possession - otherwise called a PIN - string provided by the device, entered by user in the phone app -const char * service_name = "PROV_123"; // Name of your device (the Espressif apps expects by default device name starting with "Prov_") -const char * service_key = NULL; // Password used for SofAP method (NULL = no password needed) -bool reset_provisioned = true; // When true the library will automatically delete previously provisioned data. - void SysProvEvent(arduino_event_t *sys_event) { switch (sys_event->event_id) { @@ -29,9 +11,9 @@ void SysProvEvent(arduino_event_t *sys_event) Serial.println("\nDisconnected. Connecting to the AP again... "); break; case ARDUINO_EVENT_PROV_START: - Serial.println("\nProvisioning started\nGive Credentials of your access point using smartphone app"); + Serial.println("\nProvisioning started\nGive Credentials of your access point using \" Android app \""); break; - case ARDUINO_EVENT_PROV_CRED_RECV: { + case ARDUINO_EVENT_PROV_CRED_RECV: { Serial.println("\nReceived Wi-Fi credentials"); Serial.print("\tSSID : "); Serial.println((const char *) sys_event->event_info.prov_cred_recv.ssid); @@ -39,12 +21,12 @@ void SysProvEvent(arduino_event_t *sys_event) Serial.println((char const *) sys_event->event_info.prov_cred_recv.password); break; } - case ARDUINO_EVENT_PROV_CRED_FAIL: { + case ARDUINO_EVENT_PROV_CRED_FAIL: { Serial.println("\nProvisioning failed!\nPlease reset to factory and retry provisioning\n"); - if(sys_event->event_info.prov_fail_reason == WIFI_PROV_STA_AUTH_ERROR) + if(sys_event->event_info.prov_fail_reason == WIFI_PROV_STA_AUTH_ERROR) Serial.println("\nWi-Fi AP password incorrect"); else - Serial.println("\nWi-Fi AP not found....Add API \" nvs_flash_erase() \" before beginProvision()"); + Serial.println("\nWi-Fi AP not found....Add API \" nvs_flash_erase() \" before beginProvision()"); break; } case ARDUINO_EVENT_PROV_CRED_SUCCESS: @@ -60,26 +42,15 @@ void SysProvEvent(arduino_event_t *sys_event) void setup() { Serial.begin(115200); + //Sample uuid that user can pass during provisioning using BLE + /* uint8_t uuid[16] = {0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, + 0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02 };*/ WiFi.onEvent(SysProvEvent); - -#if CONFIG_IDF_TARGET_ESP32 && CONFIG_BLUEDROID_ENABLED && not USE_SOFT_AP - Serial.println("Begin Provisioning using BLE"); - // Sample uuid that user can pass during provisioning using BLE - uint8_t uuid[16] = {0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, - 0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02 }; - WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name, service_key, uuid, reset_provisioned); +#if CONFIG_IDF_TARGET_ESP32 && CONFIG_BLUEDROID_ENABLED + WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123"); #else - Serial.println("Begin Provisioning using Soft AP"); - WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, pop, service_name, service_key); + WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123"); #endif - - #if CONFIG_BLUEDROID_ENABLED && not USE_SOFT_AP - log_d("ble qr"); - WiFiProv.printQR(service_name, pop, "ble"); - #else - log_d("wifi qr"); - WiFiProv.printQR(service_name, pop, "softap"); - #endif } void loop() { diff --git a/libraries/WiFiProv/src/WiFiProv.cpp b/libraries/WiFiProv/src/WiFiProv.cpp index 8acb684993b..d5a2cb0e4c3 100644 --- a/libraries/WiFiProv/src/WiFiProv.cpp +++ b/libraries/WiFiProv/src/WiFiProv.cpp @@ -26,9 +26,6 @@ #include #include #include -#if __has_include("qrcode.h") - #include "qrcode.h" -#endif #include #if CONFIG_BLUEDROID_ENABLED @@ -69,7 +66,7 @@ static void get_device_service_name(prov_scheme_t prov_scheme, char *service_nam #endif } -void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t scheme_handler, wifi_prov_security_t security, const char * pop, const char *service_name, const char *service_key, uint8_t * uuid, bool reset_provisioned) +void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t scheme_handler, wifi_prov_security_t security, const char * pop, const char *service_name, const char *service_key, uint8_t * uuid) { bool provisioned = false; static char service_name_temp[32]; @@ -110,13 +107,10 @@ void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t log_e("wifi_prov_mgr_init failed!"); return; } - if(reset_provisioned){ - log_i("Resetting provisioned data."); - wifi_prov_mgr_reset_provisioning(); - }else if(wifi_prov_mgr_is_provisioned(&provisioned) != ESP_OK){ - log_e("wifi_prov_mgr_is_provisioned failed!"); - wifi_prov_mgr_deinit(); - return; + if(wifi_prov_mgr_is_provisioned(&provisioned) != ESP_OK){ + log_e("wifi_prov_mgr_is_provisioned failed!"); + wifi_prov_mgr_deinit(); + return; } if(provisioned == false) { #if CONFIG_BLUEDROID_ENABLED @@ -164,30 +158,4 @@ void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t } } -// Copied from IDF example -void WiFiProvClass :: printQR(const char *name, const char *pop, const char *transport){ - if (!name || !transport) { - log_w("Cannot generate QR code payload. Data missing."); - return; - } - char payload[150] = {0}; - if (pop) { - snprintf(payload, sizeof(payload), "{\"ver\":\"%s\",\"name\":\"%s\"" \ - ",\"pop\":\"%s\",\"transport\":\"%s\"}", - "v1", name, pop, transport); - } else { - snprintf(payload, sizeof(payload), "{\"ver\":\"%s\",\"name\":\"%s\"" \ - ",\"transport\":\"%s\"}", - "v1", name, transport); - } -#if __has_include("qrcode.h") - log_i("Scan this QR code from the provisioning application for Provisioning."); - esp_qrcode_config_t cfg = ESP_QRCODE_CONFIG_DEFAULT(); - esp_qrcode_generate(&cfg, payload); -#else - log_i("If QR code is not visible, copy paste the below URL in a browser.\n%s?data=%s", "https://espressif.github.io/esp-jumpstart/qrcode.html", payload); - log_i("If you are using Arduino as IDF component, install ESP Rainmaker:\nhttps://github.com/espressif/esp-rainmaker"); -#endif -} - WiFiProvClass WiFiProv; diff --git a/libraries/WiFiProv/src/WiFiProv.h b/libraries/WiFiProv/src/WiFiProv.h index 57342668770..bbcab41a6f8 100644 --- a/libraries/WiFiProv/src/WiFiProv.h +++ b/libraries/WiFiProv/src/WiFiProv.h @@ -47,9 +47,7 @@ class WiFiProvClass public: void beginProvision(prov_scheme_t prov_scheme = WIFI_PROV_SCHEME_SOFTAP, scheme_handler_t scheme_handler = WIFI_PROV_SCHEME_HANDLER_NONE, - wifi_prov_security_t security = WIFI_PROV_SECURITY_1, const char * pop = "abcd1234", const char * service_name = NULL, - const char * service_key = NULL, uint8_t *uuid = NULL, bool reset_provisioned = false); - void printQR(const char *name, const char *pop, const char *transport); + wifi_prov_security_t security = WIFI_PROV_SECURITY_1, const char * pop = "abcd1234", const char * service_name = NULL, const char * service_key = NULL, uint8_t *uuid = NULL); }; extern WiFiProvClass WiFiProv; diff --git a/variants/Nebula_S3/pins_arduino.h b/variants/Nebula_S3/pins_arduino.h deleted file mode 100644 index 513aef8409e..00000000000 --- a/variants/Nebula_S3/pins_arduino.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef Pins_Arduino_h -#define Pins_Arduino_h - -#include - -#define USB_VID 0x303a -#define USB_PID 0x1001 - -#define EXTERNAL_NUM_INTERRUPTS 20 -#define NUM_DIGITAL_PINS 20 -#define NUM_ANALOG_INPUTS 6 - -#define analogInputToDigitalPin(p) (((p)<6)?(analogChannelToDigitalPin(p)):-1) -#define digitalPinToInterrupt(p) (((p)<20)?(p):-1) -#define digitalPinHasPWM(p) (p < 20) - - -static const uint8_t LED_BUILTIN = 45; -#define BUILTIN_LED LED_BUILTIN // backward compatibility -#define LED_BUILTIN LED_BUILTIN -#define RGB_BUILTIN LED_BUILTIN -#define RGB_BRIGHTNESS 64 - -static const uint8_t TX = 43; -static const uint8_t RX = 44; - -static const uint8_t SDA = 12; -static const uint8_t SCL = 13; - -static const uint8_t SDA1 = 2; -static const uint8_t SCL1 = 1; - -static const uint8_t SS = 41; -static const uint8_t MOSI = 40; -static const uint8_t MISO = 39; -static const uint8_t SCK = 38; - -static const uint8_t D0 = 1; -static const uint8_t D1 = 2; -static const uint8_t D2 = 44; -static const uint8_t D3 = 43; -static const uint8_t D4 = 42; -static const uint8_t D5 = 41; -static const uint8_t D6 = 40; -static const uint8_t D7 = 39; -static const uint8_t D8 = 38; -static const uint8_t D9 = 27; -static const uint8_t D10 = 45; -static const uint8_t D11 = 4; -static const uint8_t D12 = 5; -static const uint8_t D13 = 6; -static const uint8_t D14 = 7; -static const uint8_t D15 = 15; -static const uint8_t D16 = 16; -static const uint8_t D17 = 17; -static const uint8_t D18 = 18; - -static const uint8_t A0 = 4; -static const uint8_t A1 = 5; -static const uint8_t A2 = 6; -static const uint8_t A3 = 7; -static const uint8_t A4 = 1; -static const uint8_t A5 = 2; - - -#endif /* Pins_Arduino_h */ diff --git a/variants/adafruit_matrixportal_esp32s3/bootloader-tinyuf2.bin b/variants/adafruit_matrixportal_esp32s3/bootloader-tinyuf2.bin deleted file mode 100644 index dc5dc9e6e28..00000000000 Binary files a/variants/adafruit_matrixportal_esp32s3/bootloader-tinyuf2.bin and /dev/null differ diff --git a/variants/adafruit_matrixportal_esp32s3/partitions-8MB-tinyuf2.csv b/variants/adafruit_matrixportal_esp32s3/partitions-8MB-tinyuf2.csv deleted file mode 100644 index a68b39e9fa7..00000000000 --- a/variants/adafruit_matrixportal_esp32s3/partitions-8MB-tinyuf2.csv +++ /dev/null @@ -1,10 +0,0 @@ -# ESP-IDF Partition Table -# Name, Type, SubType, Offset, Size, Flags -# bootloader.bin,, 0x1000, 32K -# partition table,, 0x8000, 4K -nvs, data, nvs, 0x9000, 20K, -otadata, data, ota, 0xe000, 8K, -ota_0, app, ota_0, 0x10000, 2048K, -ota_1, app, ota_1, 0x210000, 2048K, -uf2, app, factory,0x410000, 256K, -ffat, data, fat, 0x450000, 3776K, diff --git a/variants/adafruit_matrixportal_esp32s3/pins_arduino.h b/variants/adafruit_matrixportal_esp32s3/pins_arduino.h deleted file mode 100644 index c239edcd9fa..00000000000 --- a/variants/adafruit_matrixportal_esp32s3/pins_arduino.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef Pins_Arduino_h -#define Pins_Arduino_h - -#include - -#define USB_VID 0x239A -#define USB_PID 0x8125 -#define USB_MANUFACTURER "Adafruit" -#define USB_PRODUCT "MatrixPortal ESP32-S3" -#define USB_SERIAL "" // Empty string for MAC adddress - -#define EXTERNAL_NUM_INTERRUPTS 46 -#define NUM_DIGITAL_PINS 48 -#define NUM_ANALOG_INPUTS 6 - -#define analogInputToDigitalPin(p) (((p) - - - -#define EXTERNAL_NUM_INTERRUPTS 46 -#define NUM_DIGITAL_PINS 48 -#define NUM_ANALOG_INPUTS 20 - -#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1) -#define digitalPinToInterrupt(p) (((p)<48)?(p):-1) -#define digitalPinHasPWM(p) (p < 46) - - -static const uint8_t TX = 43; -static const uint8_t RX = 44; - -static const uint8_t SDA = 1; -static const uint8_t SCL = 2; - - -static const uint8_t MOSI = 15; -static const uint8_t MISO = 16; -static const uint8_t SCK = 17; -static const uint8_t SS = 18; - -#define GDI_DISPLAY_FPC_INTERFACE -#ifdef GDI_DISPLAY_FPC_INTERFACE - -#define GDI_BLK 21 -#define GDI_SPI_SCLK SCK -#define GDI_SPI_MOSI MOSI -#define GDI_SPI_MISO MISO -#define GDI_DC 3 -#define GDI_RES 38 -#define GDI_CS 18 -#define GDI_SDCS 0 -#define GDI_FCS 7 -#define GDI_TCS 12 -#define GDI_SCL SCL -#define GDI_SDA SDA -#define GDI_INT 13 -#define GDI_BUSY_TE 14 - -#endif /* GDI_DISPLAY_FPC_INTERFACE */ - -// CAM -#define CAM_DVP_INTERFACE -#ifdef CAM_DVP_INTERFACE - -#define CAM_D5 4 -#define CAM_PCLK 5 -#define CAM_VSYNC 6 -#define CAM_D6 7 -#define CAM_D7 8 -#define CAM_D8 46 -#define CAM_D9 48 -#define CAM_XMCLK 45 -#define CAM_D2 39 -#define CAM_D3 40 -#define CAM_D4 41 -#define CAM_HREF 42 -#define CAM_SCL SCL -#define CAM_SDA SDA - -#endif /* CAM_DVP_INTERFACE */ - -// Motor -#define MOTOR_INTERFACE -#ifdef MOTOR_INTERFACE - -#define M1_EN 12 -#define M1_PH 13 -#define M2_EN 14 -#define M2_PH 21 -#define M3_EN 9 -#define M3_PH 10 -#define M4_EN 47 -#define M4_PH 11 - -#endif - -#endif /* Pins_Arduino_h */ diff --git a/variants/m5stack_cores3/pins_arduino.h b/variants/m5stack_cores3/pins_arduino.h deleted file mode 100644 index c8c979abe69..00000000000 --- a/variants/m5stack_cores3/pins_arduino.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef Pins_Arduino_h -#define Pins_Arduino_h - -#include -#include "soc/soc_caps.h" - -#define USB_VID 0x303a -#define USB_PID 0x1001 - -#define EXTERNAL_NUM_INTERRUPTS 46 -#define NUM_DIGITAL_PINS 48 -#define NUM_ANALOG_INPUTS 20 - -// Some boards have too low voltage on this pin (board design bug) -// Use different pin with 3V and connect with 48 -// and change this setup for the chosen pin (for example 38) -static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT + 48; -#define BUILTIN_LED LED_BUILTIN // backward compatibility -#define LED_BUILTIN LED_BUILTIN -#define RGB_BUILTIN LED_BUILTIN -#define RGB_BRIGHTNESS 64 - -#define analogInputToDigitalPin(p) \ - (((p) < 20) ? (analogChannelToDigitalPin(p)) : -1) -#define digitalPinToInterrupt(p) (((p) < 48) ? (p) : -1) -#define digitalPinHasPWM(p) (p < 46) - -static const uint8_t TX = 43; -static const uint8_t RX = 44; - -static const uint8_t TXD2 = 17; -static const uint8_t RXD2 = 18; - -static const uint8_t SDA = 12; -static const uint8_t SCL = 11; - -static const uint8_t SS = 15; -static const uint8_t MOSI = 37; -static const uint8_t MISO = 35; -static const uint8_t SCK = 36; - -static const uint8_t G0 = 0; -static const uint8_t G1 = 1; -static const uint8_t G2 = 2; -static const uint8_t G3 = 3; -static const uint8_t G4 = 4; -static const uint8_t G5 = 5; -static const uint8_t G6 = 6; -static const uint8_t G7 = 7; -static const uint8_t G8 = 8; -static const uint8_t G9 = 9; -static const uint8_t G11 = 11; -static const uint8_t G12 = 12; -static const uint8_t G13 = 13; -static const uint8_t G14 = 14; -static const uint8_t G17 = 17; -static const uint8_t G18 = 18; -static const uint8_t G19 = 19; -static const uint8_t G20 = 20; -static const uint8_t G21 = 21; -static const uint8_t G33 = 33; -static const uint8_t G34 = 34; -static const uint8_t G35 = 35; -static const uint8_t G36 = 36; -static const uint8_t G37 = 37; -static const uint8_t G38 = 38; -static const uint8_t G45 = 45; -static const uint8_t G46 = 46; - -static const uint8_t ADC = 10; - -#endif /* Pins_Arduino_h */