diff --git a/boards.txt b/boards.txt index fe5f3b853e0..7d9b9359688 100755 --- a/boards.txt +++ b/boards.txt @@ -127,7 +127,7 @@ esp32s3.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0 esp32s3.menu.USBMode.hwcdc=Hardware CDC and JTAG esp32s3.menu.USBMode.hwcdc.build.usb_mode=1 -esp32s3.menu.USBMode.default=USB-OTG +esp32s3.menu.USBMode.default=USB-OTG (TinyUSB) esp32s3.menu.USBMode.default.build.usb_mode=0 esp32s3.menu.CDCOnBoot.default=Disabled @@ -145,10 +145,10 @@ esp32s3.menu.DFUOnBoot.default.build.dfu_on_boot=0 esp32s3.menu.DFUOnBoot.dfu=Enabled (Requires USB-OTG Mode) esp32s3.menu.DFUOnBoot.dfu.build.dfu_on_boot=1 -esp32s3.menu.UploadMode.default=UART0 +esp32s3.menu.UploadMode.default=UART0 / Hardware CDC esp32s3.menu.UploadMode.default.upload.use_1200bps_touch=false esp32s3.menu.UploadMode.default.upload.wait_for_upload_port=false -esp32s3.menu.UploadMode.cdc=Internal USB +esp32s3.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB) esp32s3.menu.UploadMode.cdc.upload.use_1200bps_touch=true esp32s3.menu.UploadMode.cdc.upload.wait_for_upload_port=true @@ -1121,6 +1121,106 @@ esp32s3box.menu.DebugLevel.verbose.build.code_debug=5 ############################################################## +esp32s3usbotg.name=ESP32-S3-USB-OTG +esp32s3usbotg.vid.0=0x303a +esp32s3usbotg.pid.0=0x1001 + +esp32s3usbotg.upload.tool=esptool_py +esp32s3usbotg.upload.maximum_size=1310720 +esp32s3usbotg.upload.maximum_data_size=327680 +esp32s3usbotg.upload.speed=921600 +esp32s3usbotg.upload.flags= +esp32s3usbotg.upload.extra_flags= +esp32s3usbotg.upload.use_1200bps_touch=false +esp32s3usbotg.upload.wait_for_upload_port=false + +esp32s3usbotg.serial.disableDTR=false +esp32s3usbotg.serial.disableRTS=false + +esp32s3usbotg.build.tarch=xtensa +esp32s3usbotg.build.bootloader_addr=0x0 +esp32s3usbotg.build.target=esp32s3 +esp32s3usbotg.build.mcu=esp32s3 +esp32s3usbotg.build.core=esp32 +esp32s3usbotg.build.variant=esp32s3usbotg +esp32s3usbotg.build.board=ESP32_S3_USB_OTG + +esp32s3usbotg.build.usb_mode=0 +esp32s3usbotg.build.cdc_on_boot=0 +esp32s3usbotg.build.msc_on_boot=0 +esp32s3usbotg.build.dfu_on_boot=0 +esp32s3usbotg.build.f_cpu=240000000L +esp32s3usbotg.build.flash_size=8MB +esp32s3usbotg.build.flash_freq=80m +esp32s3usbotg.build.flash_mode=dio +esp32s3usbotg.build.boot=qio +esp32s3usbotg.build.partitions=default +esp32s3usbotg.build.defines= +esp32s3usbotg.build.memory_type=qspi_qspi +esp32s3usbotg.build.loop_core=-DARDUINO_RUNNING_CORE=1 +esp32s3usbotg.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1 + +esp32s3usbotg.menu.USBMode.default=USB-OTG +esp32s3usbotg.menu.USBMode.default.build.usb_mode=0 +esp32s3usbotg.menu.USBMode.default.build.cdc_on_boot=0 +esp32s3usbotg.menu.USBMode.hwcdc=Hardware CDC and JTAG +esp32s3usbotg.menu.USBMode.hwcdc.build.usb_mode=1 +esp32s3usbotg.menu.USBMode.hwcdc.build.cdc_on_boot=1 + +esp32s3usbotg.menu.UploadMode.default=UART0 / Hardware CDC +esp32s3usbotg.menu.UploadMode.default.upload.use_1200bps_touch=false +esp32s3usbotg.menu.UploadMode.default.upload.wait_for_upload_port=false +esp32s3usbotg.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB) +esp32s3usbotg.menu.UploadMode.cdc.upload.use_1200bps_touch=true +esp32s3usbotg.menu.UploadMode.cdc.upload.wait_for_upload_port=true + +esp32s3usbotg.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) +esp32s3usbotg.menu.PartitionScheme.default.build.partitions=default +esp32s3usbotg.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS) +esp32s3usbotg.menu.PartitionScheme.defaultffat.build.partitions=default_ffat +esp32s3usbotg.menu.PartitionScheme.default_8MB=8M Flash (3MB APP/1.5MB FAT) +esp32s3usbotg.menu.PartitionScheme.default_8MB.build.partitions=default_8MB +esp32s3usbotg.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336 +esp32s3usbotg.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS) +esp32s3usbotg.menu.PartitionScheme.no_ota.build.partitions=no_ota +esp32s3usbotg.menu.PartitionScheme.no_ota.upload.maximum_size=2097152 +esp32s3usbotg.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS) +esp32s3usbotg.menu.PartitionScheme.noota_3g.build.partitions=noota_3g +esp32s3usbotg.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576 +esp32s3usbotg.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS) +esp32s3usbotg.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat +esp32s3usbotg.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152 +esp32s3usbotg.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS) +esp32s3usbotg.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat +esp32s3usbotg.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576 +esp32s3usbotg.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS) +esp32s3usbotg.menu.PartitionScheme.huge_app.build.partitions=huge_app +esp32s3usbotg.menu.PartitionScheme.huge_app.upload.maximum_size=3145728 +esp32s3usbotg.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS) +esp32s3usbotg.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs +esp32s3usbotg.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 +esp32s3usbotg.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT) +esp32s3usbotg.menu.PartitionScheme.fatflash.build.partitions=ffat +esp32s3usbotg.menu.PartitionScheme.fatflash.upload.maximum_size=2097152 +esp32s3usbotg.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS) +esp32s3usbotg.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB +esp32s3usbotg.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728 + +esp32s3usbotg.menu.DebugLevel.none=None +esp32s3usbotg.menu.DebugLevel.none.build.code_debug=0 +esp32s3usbotg.menu.DebugLevel.error=Error +esp32s3usbotg.menu.DebugLevel.error.build.code_debug=1 +esp32s3usbotg.menu.DebugLevel.warn=Warn +esp32s3usbotg.menu.DebugLevel.warn.build.code_debug=2 +esp32s3usbotg.menu.DebugLevel.info=Info +esp32s3usbotg.menu.DebugLevel.info.build.code_debug=3 +esp32s3usbotg.menu.DebugLevel.debug=Debug +esp32s3usbotg.menu.DebugLevel.debug.build.code_debug=4 +esp32s3usbotg.menu.DebugLevel.verbose=Verbose +esp32s3usbotg.menu.DebugLevel.verbose.build.code_debug=5 + +############################################################## + esp32s3camlcd.name=ESP32S3 CAM LCD esp32s3camlcd.vid.0=0x303a esp32s3camlcd.pid.0=0x1001 @@ -4890,6 +4990,43 @@ WeMosBat.build.boot=dio WeMosBat.build.partitions=default WeMosBat.build.defines= +WeMosBat.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) +WeMosBat.menu.PartitionScheme.default.build.partitions=default +WeMosBat.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS) +WeMosBat.menu.PartitionScheme.defaultffat.build.partitions=default_ffat +WeMosBat.menu.PartitionScheme.default_8MB=8M Flash (3MB APP/1.5MB FAT) +WeMosBat.menu.PartitionScheme.default_8MB.build.partitions=default_8MB +WeMosBat.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336 +WeMosBat.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS) +WeMosBat.menu.PartitionScheme.minimal.build.partitions=minimal +WeMosBat.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS) +WeMosBat.menu.PartitionScheme.no_ota.build.partitions=no_ota +WeMosBat.menu.PartitionScheme.no_ota.upload.maximum_size=2097152 +WeMosBat.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS) +WeMosBat.menu.PartitionScheme.noota_3g.build.partitions=noota_3g +WeMosBat.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576 +WeMosBat.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS) +WeMosBat.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat +WeMosBat.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152 +WeMosBat.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS) +WeMosBat.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat +WeMosBat.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576 +WeMosBat.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS) +WeMosBat.menu.PartitionScheme.huge_app.build.partitions=huge_app +WeMosBat.menu.PartitionScheme.huge_app.upload.maximum_size=3145728 +WeMosBat.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS) +WeMosBat.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs +WeMosBat.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 +WeMosBat.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT) +WeMosBat.menu.PartitionScheme.fatflash.build.partitions=ffat +WeMosBat.menu.PartitionScheme.fatflash.upload.maximum_size=2097152 +WeMosBat.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS) +WeMosBat.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB +WeMosBat.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728 +WeMosBat.menu.PartitionScheme.rainmaker=RainMaker +WeMosBat.menu.PartitionScheme.rainmaker.build.partitions=rainmaker +WeMosBat.menu.PartitionScheme.rainmaker.upload.maximum_size=3145728 + WeMosBat.menu.FlashFreq.80=80MHz WeMosBat.menu.FlashFreq.80.build.flash_freq=80m WeMosBat.menu.FlashFreq.40=40MHz @@ -6778,6 +6915,288 @@ adafruit_feather_esp32_v2.menu.DebugLevel.verbose=Verbose adafruit_feather_esp32_v2.menu.DebugLevel.verbose.build.code_debug=5 +############################################################## + +adafruit_feather_esp32s3.name=Adafruit Feather ESP32-S3 No PSRAM +adafruit_feather_esp32s3.vid.0=0x239A +adafruit_feather_esp32s3.pid.0=0x8113 +adafruit_feather_esp32s3.vid.1=0x239A +adafruit_feather_esp32s3.pid.1=0x0113 +adafruit_feather_esp32s3.vid.1=0x239A +adafruit_feather_esp32s3.pid.1=0x8114 + +adafruit_feather_esp32s3.upload.tool=esptool_py +adafruit_feather_esp32s3.upload.maximum_size=1310720 +adafruit_feather_esp32s3.upload.maximum_data_size=327680 +adafruit_feather_esp32s3.upload.flags= +adafruit_feather_esp32s3.upload.extra_flags=0x410000 "{runtime.platform.path}/variants/{build.variant}/tinyuf2.bin" +adafruit_feather_esp32s3.upload.use_1200bps_touch=true +adafruit_feather_esp32s3.upload.wait_for_upload_port=true + +adafruit_feather_esp32s3.serial.disableDTR=false +adafruit_feather_esp32s3.serial.disableRTS=false + +adafruit_feather_esp32s3.build.tarch=xtensa +adafruit_feather_esp32s3.build.bootloader_addr=0x0 +adafruit_feather_esp32s3.build.target=esp32s3 +adafruit_feather_esp32s3.build.mcu=esp32s3 +adafruit_feather_esp32s3.build.core=esp32 +adafruit_feather_esp32s3.build.variant=adafruit_feather_esp32s3_nopsram +adafruit_feather_esp32s3.build.board=ADAFRUIT_FEATHER_ESP32S3_NOPSRAM + +adafruit_feather_esp32s3.build.usb_mode=1 +adafruit_feather_esp32s3.build.cdc_on_boot=1 +adafruit_feather_esp32s3.build.msc_on_boot=0 +adafruit_feather_esp32s3.build.dfu_on_boot=0 +adafruit_feather_esp32s3.build.f_cpu=240000000L +adafruit_feather_esp32s3.build.flash_size=8MB +adafruit_feather_esp32s3.build.flash_freq=80m +adafruit_feather_esp32s3.build.flash_mode=dio +adafruit_feather_esp32s3.build.boot=qio +adafruit_feather_esp32s3.build.partitions=default +adafruit_feather_esp32s3.build.defines= +adafruit_feather_esp32s3.build.loop_core=-DARDUINO_RUNNING_CORE=1 +adafruit_feather_esp32s3.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1 + +adafruit_feather_esp32s3.menu.USBMode.default=USB-OTG +adafruit_feather_esp32s3.menu.USBMode.default.build.usb_mode=0 +adafruit_feather_esp32s3.menu.USBMode.default.upload.use_1200bps_touch=true +adafruit_feather_esp32s3.menu.USBMode.default.upload.wait_for_upload_port=true +adafruit_feather_esp32s3.menu.USBMode.hwcdc=Hardware CDC and JTAG +adafruit_feather_esp32s3.menu.USBMode.hwcdc.build.usb_mode=1 +adafruit_feather_esp32s3.menu.USBMode.hwcdc.upload.use_1200bps_touch=false +adafruit_feather_esp32s3.menu.USBMode.hwcdc.upload.wait_for_upload_port=false + +adafruit_feather_esp32s3.menu.CDCOnBoot.cdc=Enabled +adafruit_feather_esp32s3.menu.CDCOnBoot.cdc.build.cdc_on_boot=1 +adafruit_feather_esp32s3.menu.CDCOnBoot.default=Disabled +adafruit_feather_esp32s3.menu.CDCOnBoot.default.build.cdc_on_boot=0 + +adafruit_feather_esp32s3.menu.MSCOnBoot.default=Disabled +adafruit_feather_esp32s3.menu.MSCOnBoot.default.build.msc_on_boot=0 +adafruit_feather_esp32s3.menu.MSCOnBoot.msc=Enabled +adafruit_feather_esp32s3.menu.MSCOnBoot.msc.build.msc_on_boot=1 + +adafruit_feather_esp32s3.menu.DFUOnBoot.default=Disabled +adafruit_feather_esp32s3.menu.DFUOnBoot.default.build.dfu_on_boot=0 +adafruit_feather_esp32s3.menu.DFUOnBoot.dfu=Enabled +adafruit_feather_esp32s3.menu.DFUOnBoot.dfu.build.dfu_on_boot=1 + +adafruit_feather_esp32s3.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) +adafruit_feather_esp32s3.menu.PartitionScheme.default.build.partitions=default +adafruit_feather_esp32s3.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS) +adafruit_feather_esp32s3.menu.PartitionScheme.defaultffat.build.partitions=default_ffat +adafruit_feather_esp32s3.menu.PartitionScheme.default_8MB=8M Flash (3MB APP/1.5MB FAT) +adafruit_feather_esp32s3.menu.PartitionScheme.default_8MB.build.partitions=default_8MB +adafruit_feather_esp32s3.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336 +adafruit_feather_esp32s3.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS) +adafruit_feather_esp32s3.menu.PartitionScheme.minimal.build.partitions=minimal +adafruit_feather_esp32s3.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS) +adafruit_feather_esp32s3.menu.PartitionScheme.no_ota.build.partitions=no_ota +adafruit_feather_esp32s3.menu.PartitionScheme.no_ota.upload.maximum_size=2097152 +adafruit_feather_esp32s3.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS) +adafruit_feather_esp32s3.menu.PartitionScheme.noota_3g.build.partitions=noota_3g +adafruit_feather_esp32s3.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576 +adafruit_feather_esp32s3.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS) +adafruit_feather_esp32s3.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat +adafruit_feather_esp32s3.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152 +adafruit_feather_esp32s3.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS) +adafruit_feather_esp32s3.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat +adafruit_feather_esp32s3.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576 +adafruit_feather_esp32s3.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS) +adafruit_feather_esp32s3.menu.PartitionScheme.huge_app.build.partitions=huge_app +adafruit_feather_esp32s3.menu.PartitionScheme.huge_app.upload.maximum_size=3145728 +adafruit_feather_esp32s3.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS) +adafruit_feather_esp32s3.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs +adafruit_feather_esp32s3.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 +adafruit_feather_esp32s3.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT) +adafruit_feather_esp32s3.menu.PartitionScheme.fatflash.build.partitions=ffat +adafruit_feather_esp32s3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152 +adafruit_feather_esp32s3.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS) +adafruit_feather_esp32s3.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB +adafruit_feather_esp32s3.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728 + +adafruit_feather_esp32s3.menu.CPUFreq.240=240MHz (WiFi) +adafruit_feather_esp32s3.menu.CPUFreq.240.build.f_cpu=240000000L +adafruit_feather_esp32s3.menu.CPUFreq.160=160MHz (WiFi) +adafruit_feather_esp32s3.menu.CPUFreq.160.build.f_cpu=160000000L +adafruit_feather_esp32s3.menu.CPUFreq.80=80MHz (WiFi) +adafruit_feather_esp32s3.menu.CPUFreq.80.build.f_cpu=80000000L +adafruit_feather_esp32s3.menu.CPUFreq.40=40MHz +adafruit_feather_esp32s3.menu.CPUFreq.40.build.f_cpu=40000000L +adafruit_feather_esp32s3.menu.CPUFreq.20=20MHz +adafruit_feather_esp32s3.menu.CPUFreq.20.build.f_cpu=20000000L +adafruit_feather_esp32s3.menu.CPUFreq.10=10MHz +adafruit_feather_esp32s3.menu.CPUFreq.10.build.f_cpu=10000000L + +adafruit_feather_esp32s3.menu.FlashFreq.80=80MHz +adafruit_feather_esp32s3.menu.FlashFreq.80.build.flash_freq=80m +adafruit_feather_esp32s3.menu.FlashFreq.40=40MHz +adafruit_feather_esp32s3.menu.FlashFreq.40.build.flash_freq=40m + +adafruit_feather_esp32s3.menu.UploadSpeed.921600=921600 +adafruit_feather_esp32s3.menu.UploadSpeed.921600.upload.speed=921600 +adafruit_feather_esp32s3.menu.UploadSpeed.115200=115200 +adafruit_feather_esp32s3.menu.UploadSpeed.115200.upload.speed=115200 +adafruit_feather_esp32s3.menu.UploadSpeed.256000.windows=256000 +adafruit_feather_esp32s3.menu.UploadSpeed.256000.upload.speed=256000 +adafruit_feather_esp32s3.menu.UploadSpeed.230400.windows.upload.speed=256000 +adafruit_feather_esp32s3.menu.UploadSpeed.230400=230400 +adafruit_feather_esp32s3.menu.UploadSpeed.230400.upload.speed=230400 +adafruit_feather_esp32s3.menu.UploadSpeed.460800.linux=460800 +adafruit_feather_esp32s3.menu.UploadSpeed.460800.macosx=460800 +adafruit_feather_esp32s3.menu.UploadSpeed.460800.upload.speed=460800 +adafruit_feather_esp32s3.menu.UploadSpeed.512000.windows=512000 +adafruit_feather_esp32s3.menu.UploadSpeed.512000.upload.speed=512000 + +adafruit_feather_esp32s3.menu.DebugLevel.none=None +adafruit_feather_esp32s3.menu.DebugLevel.none.build.code_debug=0 +adafruit_feather_esp32s3.menu.DebugLevel.error=Error +adafruit_feather_esp32s3.menu.DebugLevel.error.build.code_debug=1 +adafruit_feather_esp32s3.menu.DebugLevel.warn=Warn +adafruit_feather_esp32s3.menu.DebugLevel.warn.build.code_debug=2 +adafruit_feather_esp32s3.menu.DebugLevel.info=Info +adafruit_feather_esp32s3.menu.DebugLevel.info.build.code_debug=3 +adafruit_feather_esp32s3.menu.DebugLevel.debug=Debug +adafruit_feather_esp32s3.menu.DebugLevel.debug.build.code_debug=4 +adafruit_feather_esp32s3.menu.DebugLevel.verbose=Verbose +adafruit_feather_esp32s3.menu.DebugLevel.verbose.build.code_debug=5 + + +############################################################## + +adafruit_qtpy_esp32s3.name=Adafruit QT Py ESP32-S3 No PSRAM +adafruit_qtpy_esp32s3.vid.0=0x239A +adafruit_qtpy_esp32s3.pid.0=0x8119 +adafruit_qtpy_esp32s3.vid.1=0x239A +adafruit_qtpy_esp32s3.pid.1=0x0119 +adafruit_qtpy_esp32s3.vid.1=0x239A +adafruit_qtpy_esp32s3.pid.1=0x811A + +adafruit_qtpy_esp32s3.upload.tool=esptool_py +adafruit_qtpy_esp32s3.upload.maximum_size=1310720 +adafruit_qtpy_esp32s3.upload.maximum_data_size=327680 +adafruit_qtpy_esp32s3.upload.flags= +adafruit_qtpy_esp32s3.upload.extra_flags=0x410000 "{runtime.platform.path}/variants/{build.variant}/tinyuf2.bin" +adafruit_qtpy_esp32s3.upload.use_1200bps_touch=true +adafruit_qtpy_esp32s3.upload.wait_for_upload_port=true +adafruit_qtpy_esp32s3.upload.speed=921600 + +adafruit_qtpy_esp32s3.serial.disableDTR=false +adafruit_qtpy_esp32s3.serial.disableRTS=false + +adafruit_qtpy_esp32s3.build.tarch=xtensa +adafruit_qtpy_esp32s3.build.bootloader_addr=0x0 +adafruit_qtpy_esp32s3.build.target=esp32s3 +adafruit_qtpy_esp32s3.build.mcu=esp32s3 +adafruit_qtpy_esp32s3.build.core=esp32 +adafruit_qtpy_esp32s3.build.variant=adafruit_qtpy_esp32s3_nopsram +adafruit_qtpy_esp32s3.build.board=ADAFRUIT_QTPY_ESP32S3_NOPSRAM + +adafruit_qtpy_esp32s3.build.usb_mode=1 +adafruit_qtpy_esp32s3.build.cdc_on_boot=1 +adafruit_qtpy_esp32s3.build.msc_on_boot=0 +adafruit_qtpy_esp32s3.build.dfu_on_boot=0 +adafruit_qtpy_esp32s3.build.f_cpu=240000000L +adafruit_qtpy_esp32s3.build.flash_size=8MB +adafruit_qtpy_esp32s3.build.flash_freq=80m +adafruit_qtpy_esp32s3.build.flash_mode=dio +adafruit_qtpy_esp32s3.build.boot=qio +adafruit_qtpy_esp32s3.build.partitions=default_8MB +adafruit_qtpy_esp32s3.build.defines= +adafruit_qtpy_esp32s3.build.loop_core=-DARDUINO_RUNNING_CORE=1 +adafruit_qtpy_esp32s3.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1 + +adafruit_qtpy_esp32s3.menu.USBMode.default=USB-OTG +adafruit_qtpy_esp32s3.menu.USBMode.default.build.usb_mode=0 +adafruit_qtpy_esp32s3.menu.USBMode.default.upload.use_1200bps_touch=true +adafruit_qtpy_esp32s3.menu.USBMode.default.upload.wait_for_upload_port=true +adafruit_qtpy_esp32s3.menu.USBMode.hwcdc=Hardware CDC and JTAG +adafruit_qtpy_esp32s3.menu.USBMode.hwcdc.build.usb_mode=1 +adafruit_qtpy_esp32s3.menu.USBMode.hwcdc.upload.use_1200bps_touch=false +adafruit_qtpy_esp32s3.menu.USBMode.hwcdc.upload.wait_for_upload_port=false + +adafruit_qtpy_esp32s3.menu.CDCOnBoot.cdc=Enabled +adafruit_qtpy_esp32s3.menu.CDCOnBoot.cdc.build.cdc_on_boot=1 +adafruit_qtpy_esp32s3.menu.CDCOnBoot.default=Disabled +adafruit_qtpy_esp32s3.menu.CDCOnBoot.default.build.cdc_on_boot=0 + +adafruit_qtpy_esp32s3.menu.MSCOnBoot.default=Disabled +adafruit_qtpy_esp32s3.menu.MSCOnBoot.default.build.msc_on_boot=0 +adafruit_qtpy_esp32s3.menu.MSCOnBoot.msc=Enabled +adafruit_qtpy_esp32s3.menu.MSCOnBoot.msc.build.msc_on_boot=1 + +adafruit_qtpy_esp32s3.menu.DFUOnBoot.default=Disabled +adafruit_qtpy_esp32s3.menu.DFUOnBoot.default.build.dfu_on_boot=0 +adafruit_qtpy_esp32s3.menu.DFUOnBoot.dfu=Enabled +adafruit_qtpy_esp32s3.menu.DFUOnBoot.dfu.build.dfu_on_boot=1 + +adafruit_qtpy_esp32s3.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) +adafruit_qtpy_esp32s3.menu.PartitionScheme.default.build.partitions=default +adafruit_qtpy_esp32s3.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS) +adafruit_qtpy_esp32s3.menu.PartitionScheme.defaultffat.build.partitions=default_ffat +adafruit_qtpy_esp32s3.menu.PartitionScheme.default_8MB=8M Flash (3MB APP/1.5MB FAT) +adafruit_qtpy_esp32s3.menu.PartitionScheme.default_8MB.build.partitions=default_8MB +adafruit_qtpy_esp32s3.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336 +adafruit_qtpy_esp32s3.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS) +adafruit_qtpy_esp32s3.menu.PartitionScheme.minimal.build.partitions=minimal +adafruit_qtpy_esp32s3.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS) +adafruit_qtpy_esp32s3.menu.PartitionScheme.no_ota.build.partitions=no_ota +adafruit_qtpy_esp32s3.menu.PartitionScheme.no_ota.upload.maximum_size=2097152 +adafruit_qtpy_esp32s3.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS) +adafruit_qtpy_esp32s3.menu.PartitionScheme.noota_3g.build.partitions=noota_3g +adafruit_qtpy_esp32s3.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576 +adafruit_qtpy_esp32s3.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS) +adafruit_qtpy_esp32s3.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat +adafruit_qtpy_esp32s3.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152 +adafruit_qtpy_esp32s3.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS) +adafruit_qtpy_esp32s3.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat +adafruit_qtpy_esp32s3.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576 +adafruit_qtpy_esp32s3.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS) +adafruit_qtpy_esp32s3.menu.PartitionScheme.huge_app.build.partitions=huge_app +adafruit_qtpy_esp32s3.menu.PartitionScheme.huge_app.upload.maximum_size=3145728 +adafruit_qtpy_esp32s3.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS) +adafruit_qtpy_esp32s3.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs +adafruit_qtpy_esp32s3.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 +adafruit_qtpy_esp32s3.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT) +adafruit_qtpy_esp32s3.menu.PartitionScheme.fatflash.build.partitions=ffat +adafruit_qtpy_esp32s3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152 +adafruit_qtpy_esp32s3.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS) +adafruit_qtpy_esp32s3.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB +adafruit_qtpy_esp32s3.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728 + +adafruit_qtpy_esp32s3.menu.CPUFreq.240=240MHz (WiFi) +adafruit_qtpy_esp32s3.menu.CPUFreq.240.build.f_cpu=240000000L +adafruit_qtpy_esp32s3.menu.CPUFreq.160=160MHz (WiFi) +adafruit_qtpy_esp32s3.menu.CPUFreq.160.build.f_cpu=160000000L +adafruit_qtpy_esp32s3.menu.CPUFreq.80=80MHz (WiFi) +adafruit_qtpy_esp32s3.menu.CPUFreq.80.build.f_cpu=80000000L +adafruit_qtpy_esp32s3.menu.CPUFreq.40=40MHz +adafruit_qtpy_esp32s3.menu.CPUFreq.40.build.f_cpu=40000000L +adafruit_qtpy_esp32s3.menu.CPUFreq.20=20MHz +adafruit_qtpy_esp32s3.menu.CPUFreq.20.build.f_cpu=20000000L +adafruit_qtpy_esp32s3.menu.CPUFreq.10=10MHz +adafruit_qtpy_esp32s3.menu.CPUFreq.10.build.f_cpu=10000000L + +adafruit_qtpy_esp32s3.menu.FlashFreq.80=80MHz +adafruit_qtpy_esp32s3.menu.FlashFreq.80.build.flash_freq=80m +adafruit_qtpy_esp32s3.menu.FlashFreq.40=40MHz +adafruit_qtpy_esp32s3.menu.FlashFreq.40.build.flash_freq=40m + +adafruit_qtpy_esp32s3.menu.DebugLevel.none=None +adafruit_qtpy_esp32s3.menu.DebugLevel.none.build.code_debug=0 +adafruit_qtpy_esp32s3.menu.DebugLevel.error=Error +adafruit_qtpy_esp32s3.menu.DebugLevel.error.build.code_debug=1 +adafruit_qtpy_esp32s3.menu.DebugLevel.warn=Warn +adafruit_qtpy_esp32s3.menu.DebugLevel.warn.build.code_debug=2 +adafruit_qtpy_esp32s3.menu.DebugLevel.info=Info +adafruit_qtpy_esp32s3.menu.DebugLevel.info.build.code_debug=3 +adafruit_qtpy_esp32s3.menu.DebugLevel.debug=Debug +adafruit_qtpy_esp32s3.menu.DebugLevel.debug.build.code_debug=4 +adafruit_qtpy_esp32s3.menu.DebugLevel.verbose=Verbose +adafruit_qtpy_esp32s3.menu.DebugLevel.verbose.build.code_debug=5 + + ############################################################## diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index 7a10fe161a1..ba8429a5dac 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -37,7 +37,7 @@ void serialEvent(void) {} #ifndef RX1 #if CONFIG_IDF_TARGET_ESP32 #define RX1 9 -#elif CONFIG_IDF_TARGET_ESP32S2 +#elif CONFIG_IDF_TARGET_ESP32S2 #define RX1 18 #elif CONFIG_IDF_TARGET_ESP32C3 #define RX1 18 @@ -86,8 +86,6 @@ void serialEvent2(void) {} #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) #if ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC HardwareSerial Serial0(0); -#elif ARDUINO_HW_CDC_ON_BOOT -HardwareSerial Serial0(0); #else HardwareSerial Serial(0); #endif @@ -102,8 +100,6 @@ void serialEventRun(void) { #if ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC if(Serial0.available()) serialEvent(); -#elif ARDUINO_HW_CDC_ON_BOOT - if(Serial0.available()) serialEvent(); #else if(Serial.available()) serialEvent(); #endif @@ -127,7 +123,8 @@ void serialEventRun(void) HardwareSerial::HardwareSerial(int uart_nr) : _uart_nr(uart_nr), _uart(NULL), -_rxBufferSize(256), +_rxBufferSize(256), +_txBufferSize(0), _onReceiveCB(NULL), _onReceiveErrorCB(NULL), _eventTask(NULL) @@ -295,7 +292,7 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in } // IDF UART driver keeps Pin setting on restarting. Negative Pin number will keep it unmodified. - _uart = uartBegin(_uart_nr, baud ? baud : 9600, config, rxPin, txPin, _rxBufferSize, invert, rxfifo_full_thrhd); + _uart = uartBegin(_uart_nr, baud ? baud : 9600, config, rxPin, txPin, _rxBufferSize, _txBufferSize, invert, rxfifo_full_thrhd); if (!baud) { // using baud rate as zero, forces it to try to detect the current baud rate in place uartStartDetectBaudrate(_uart); @@ -309,7 +306,7 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in if(detectedBaudRate) { delay(100); // Give some time... - _uart = uartBegin(_uart_nr, detectedBaudRate, config, rxPin, txPin, _rxBufferSize, invert, rxfifo_full_thrhd); + _uart = uartBegin(_uart_nr, detectedBaudRate, config, rxPin, txPin, _rxBufferSize, _txBufferSize, invert, rxfifo_full_thrhd); } else { log_e("Could not detect baudrate. Serial data at the port must be present within the timeout for detection to be possible"); _uart = NULL; @@ -458,10 +455,26 @@ size_t HardwareSerial::setRxBufferSize(size_t new_size) { } if (new_size <= SOC_UART_FIFO_LEN) { - log_e("RX Buffer must be higher than %d.\n", SOC_UART_FIFO_LEN); + log_e("RX Buffer must be higher than %d.\n", SOC_UART_FIFO_LEN); // ESP32, S2, S3 and C3 means higher than 128 return 0; } _rxBufferSize = new_size; return _rxBufferSize; } + +size_t HardwareSerial::setTxBufferSize(size_t new_size) { + + if (_uart) { + log_e("TX Buffer can't be resized when Serial is already running.\n"); + return 0; + } + + if (new_size <= SOC_UART_FIFO_LEN) { + log_e("TX Buffer must be higher than %d.\n", SOC_UART_FIFO_LEN); // ESP32, S2, S3 and C3 means higher than 128 + return 0; + } + + _txBufferSize = new_size; + return _txBufferSize; +} diff --git a/cores/esp32/HardwareSerial.h b/cores/esp32/HardwareSerial.h index 7a25b64e37f..4291c046b86 100644 --- a/cores/esp32/HardwareSerial.h +++ b/cores/esp32/HardwareSerial.h @@ -132,11 +132,13 @@ class HardwareSerial: public Stream void setHwFlowCtrlMode(uint8_t mode = HW_FLOWCTRL_CTS_RTS, uint8_t threshold = 64); // 64 is half FIFO Length size_t setRxBufferSize(size_t new_size); + size_t setTxBufferSize(size_t new_size); protected: int _uart_nr; uart_t* _uart; size_t _rxBufferSize; + size_t _txBufferSize; OnReceiveCb _onReceiveCB; OnReceiveErrorCb _onReceiveErrorCB; TaskHandle_t _eventTask; @@ -156,10 +158,10 @@ extern void serialEventRun(void) __attribute__((weak)); #define ARDUINO_USB_CDC_ON_BOOT 0 #endif #if ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC +#if !ARDUINO_USB_MODE #include "USB.h" #include "USBCDC.h" -extern HardwareSerial Serial0; -#elif ARDUINO_HW_CDC_ON_BOOT +#endif extern HardwareSerial Serial0; #else extern HardwareSerial Serial; diff --git a/cores/esp32/USBCDC.cpp b/cores/esp32/USBCDC.cpp index a48a7548094..ccf5180d7c7 100644 --- a/cores/esp32/USBCDC.cpp +++ b/cores/esp32/USBCDC.cpp @@ -117,16 +117,39 @@ size_t USBCDC::setRxBufferSize(size_t rx_queue_len){ size_t currentQueueSize = rx_queue ? uxQueueSpacesAvailable(rx_queue) + uxQueueMessagesWaiting(rx_queue) : 0; - if (rx_queue && (!rx_queue_len || rx_queue_len != currentQueueSize)) { - vQueueDelete(rx_queue); - rx_queue = NULL; - } - if(!rx_queue_len || rx_queue_len == currentQueueSize){ - return 0; - } - rx_queue = xQueueCreate(rx_queue_len, sizeof(uint8_t)); - if(!rx_queue){ - return 0; + if (rx_queue_len != currentQueueSize) { + xQueueHandle new_rx_queue = NULL; + if (rx_queue_len) { + new_rx_queue = xQueueCreate(rx_queue_len, sizeof(uint8_t)); + if(!new_rx_queue){ + log_e("CDC Queue creation failed."); + return 0; + } + if (rx_queue) { + size_t copySize = uxQueueMessagesWaiting(rx_queue); + if (copySize > 0) { + for(size_t i = 0; i < copySize; i++) { + uint8_t ch = 0; + xQueueReceive(rx_queue, &ch, 0); + if (!xQueueSend(new_rx_queue, &ch, 0)) { + arduino_usb_cdc_event_data_t p; + p.rx_overflow.dropped_bytes = copySize - i; + arduino_usb_event_post(ARDUINO_USB_CDC_EVENTS, ARDUINO_USB_CDC_RX_OVERFLOW_EVENT, &p, sizeof(arduino_usb_cdc_event_data_t), portMAX_DELAY); + log_e("CDC RX Overflow."); + break; + } + } + } + vQueueDelete(rx_queue); + } + rx_queue = new_rx_queue; + return rx_queue_len; + } else { + if (rx_queue) { + vQueueDelete(rx_queue); + rx_queue = NULL; + } + } } return rx_queue_len; } @@ -249,26 +272,19 @@ void USBCDC::_onLineCoding(uint32_t _bit_rate, uint8_t _stop_bits, uint8_t _pari } void USBCDC::_onRX(){ + arduino_usb_cdc_event_data_t p; uint8_t buf[CONFIG_TINYUSB_CDC_RX_BUFSIZE+1]; uint32_t count = tud_cdc_n_read(itf, buf, CONFIG_TINYUSB_CDC_RX_BUFSIZE); - - if(rx_queue == NULL) { - return; - } - if (uxQueueSpacesAvailable(rx_queue) < count) { - //this VTaskDelay gives, to Arduino's task, time to the CPU do its processing - //without it, data may be lost when the number of bytes received is higher than CDC buffer size - vTaskDelay(10); - } for(uint32_t i=0; i= SOC_UART_NUM) { return NULL; @@ -163,7 +163,7 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx uart_config.source_clk = UART_SCLK_APB; - ESP_ERROR_CHECK(uart_driver_install(uart_nr, 2*queueLen, 0, 20, &(uart->uart_event_queue), 0)); + ESP_ERROR_CHECK(uart_driver_install(uart_nr, rx_buffer_size, tx_buffer_size, 20, &(uart->uart_event_queue), 0)); ESP_ERROR_CHECK(uart_param_config(uart_nr, &uart_config)); ESP_ERROR_CHECK(uart_set_pin(uart_nr, txPin, rxPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE)); diff --git a/cores/esp32/esp32-hal-uart.h b/cores/esp32/esp32-hal-uart.h index 25c17ea6ab6..ec7912c3d7a 100644 --- a/cores/esp32/esp32-hal-uart.h +++ b/cores/esp32/esp32-hal-uart.h @@ -61,7 +61,7 @@ extern "C" { struct uart_struct_t; typedef struct uart_struct_t uart_t; -uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rxPin, int8_t txPin, uint16_t queueLen, bool inverted, uint8_t rxfifo_full_thrhd); +uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rxPin, int8_t txPin, uint16_t rx_buffer_size, uint16_t tx_buffer_size, bool inverted, uint8_t rxfifo_full_thrhd); void uartEnd(uart_t* uart); // This is used to retrieve the Event Queue pointer from a UART IDF Driver in order to allow user to deal with its events diff --git a/docs/source/api/preferences.rst b/docs/source/api/preferences.rst new file mode 100644 index 00000000000..86268cfc507 --- /dev/null +++ b/docs/source/api/preferences.rst @@ -0,0 +1,701 @@ +########### +Preferences +########### + +About +----- + +The Preferences library is unique to arduino-esp32. It should be considered as the replacement for the Arduino EEPROM library. + +It uses a portion of the on-board non-volatile memory (NVS) of the ESP32 to store data. This data is retained across restarts and loss of power events to the system. + +Preferences works best for storing many small values, rather than a few large values. If large amounts of data are to be stored, consider using a file system library such as LitteFS. + +The Preferences library is usable by all ESP32 variants. + + +Header File +----------- + +.. code-block:: arduino + + #include +.. + + +Overview +-------- + +Library methods are provided to: + - create a namespace; + - open and close a namespace; + - store and retrieve data within a namespace for supported data types; + - determine if a key value has been initialized; + - delete a ``key-value`` pair; + - delete all ``key-value`` pairs in a namespace; + - determine data types stored against a key; + - determine the number of key entries in the namespace. + +Preferences directly supports the following data types: + +.. table:: **Table 1 — Preferences Data Types** + :align: center + + +-------------------+-------------------+---------------+ + | Preferences Type | Data Type | Size (bytes) | + +===================+===================+===============+ + | Bool | bool | 1 | + +-------------------+-------------------+---------------+ + | Char | int8_t | 1 | + +-------------------+-------------------+---------------+ + | UChar | uint8_t | 1 | + +-------------------+-------------------+---------------+ + | Short | int16_t | 2 | + +-------------------+-------------------+---------------+ + | UShort | uint16_t | 2 | + +-------------------+-------------------+---------------+ + | Int | int32_t | 4 | + +-------------------+-------------------+---------------+ + | UInt | uint32_t | 4 | + +-------------------+-------------------+---------------+ + | Long | int32_t | 4 | + +-------------------+-------------------+---------------+ + | ULong | uint32_t | 4 | + +-------------------+-------------------+---------------+ + | Long64 | int64_t | 8 | + +-------------------+-------------------+---------------+ + | ULong64 | uint64_t | 8 | + +-------------------+-------------------+---------------+ + | Float | float_t | 8 | + +-------------------+-------------------+---------------+ + | Double | double_t | 8 | + +-------------------+-------------------+---------------+ + | | const char* | variable | + | String +-------------------+ | + | | String | | + +-------------------+-------------------+---------------+ + | Bytes | uint8_t | variable | + +-------------------+-------------------+---------------+ + +String values can be stored and retrieved either as an Arduino String or as a null terminated ``char`` array (c-string). + +Bytes type is used for storing and retrieving an arbitrary number of bytes in a namespace. + + +Arduino-esp32 Preferences API +----------------------------- + +``begin`` +********** + + Open non-volatile storage with a given namespace name from an NVS partition. + + .. code-block:: arduino + + bool begin(const char * name, bool readOnly=false, const char* partition_label=NULL) + .. + + **Parameters** + * ``name`` (Required) + - Namespace name. Maximum length is 15 characters. + + * ``readOnly`` (Optional) + - ``false`` will open the namespace in read-write mode. + - ``true`` will open the namespace in read-only mode. + - if omitted, the namespace is opened in read-write mode. + + * ``partition_label`` (Optional) + - name of the NVS partition in which to open the namespace. + - if omitted, the namespace is opened in the "``nvs``" partition. + + **Returns** + * ``true`` if the namespace was opened successfully; ``false`` otherwise. + + **Notes** + * If the namespace does not exist within the partition, it is first created. + * Attempting to write a key value to a namespace open in read-only mode will fail. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``end`` +********* + + Close the currently opened namespace. + + .. code-block:: arduino + + void end() + .. + + **Parameters** + * None + + **Returns** + * Nothing + + **Note** + * After closing a namespace, methods used to access it will fail. + + +``clear`` +********** + + Delete all keys and values from the currently opened namespace. + + .. code-block:: arduino + + bool clear() + .. + + **Parameters** + * None + + **Returns** + * ``true`` if all keys and values were deleted; ``false`` otherwise. + + **Note** + * the namespace name still exists afterward. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``remove`` +************* + + Delete a key-value pair from the currently open namespace. + + .. code-block:: arduino + + bool remove(const char * key) + .. + + **Parameters** + * ``key`` (Required) + - the name of the key to be deleted. + + **Returns** + * ``true`` if key-value pair was deleted; ``false`` otherwise. + + **Note** + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``putChar, putUChar`` +********************** + + Store a value against a given key in the currently open namespace. + + .. code-block:: arduino + + size_t putChar(const char* key, int8_t value) + size_t putUChar(const char* key, uint8_t value) + + .. + + **Parameters** + * ``key`` (Required) + - if the key does not exist in the currently opened namespace it is first created. + + * ``value`` (Required) + - must match the data type of the method. + + **Returns** + * ``1`` (the number of bytes stored for these data types) if the call is successful; ``0`` otherwise. + + **Notes** + * Attempting to store a value without a namespace being open in read-write mode will fail. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``putShort, putUShort`` +************************ + + Store a value against a given key in the currently open namespace. + + .. code-block:: arduino + + size_t putShort(const char* key, int16_t value) + size_t putUShort(const char* key, uint16_t value) + + .. + + **Parameters** + * ``key`` (Required) + - if the key does not exist in the currently opened namespace it is first created. + + * ``value`` (Required) + - must match the data type of the method. + + **Returns** + * ``2`` (the number of bytes stored for these data types) if the call is successful; ``0`` otherwise. + + **Notes** + * Attempting to store a value without a namespace being open in read-write mode will fail. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + + +``putInt, putUInt`` +******************** +``putLong, putULong`` +********************** + + Store a value against a given key in the currently open namespace. + + .. code-block:: arduino + + size_t putInt(const char* key, int32_t value) + size_t putUInt(const char* key, uint32_t value) + size_t putLong(const char* key, int32_t value) + size_t putULong(const char* key, uint32_t value) + + .. + + **Parameters** + * ``key`` (Required) + - if the key does not exist in the currently opened namespace it is first created. + + * ``value`` (Required) + - must match the data type of the method. + + **Returns** + * ``4`` (the number of bytes stored for these data types) if the call is successful; ``0`` otherwise. + + **Notes** + * Attempting to store a value without a namespace being open in read-write mode will fail. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``putLong64, putULong64`` +************************* +``putFloat, putDouble`` +*********************** + + Store a value against a given key in the currently open namespace. + + .. code-block:: arduino + + size_t putLong64(const char* key, int64_t value) + size_t putULong64(const char* key, uint64_t value) + size_t putFloat(const char* key, float_t value) + size_t putDouble(const char* key, double_t value) + + .. + + **Parameters** + * ``key`` (Required) + - if the key does not exist in the currently opened namespace it is first created. + + * ``value`` (Required) + - must match the data type of the method. + + **Returns** + * ``8`` (the number of bytes stored for these data types) if the call is successful; ``0`` otherwise. + + **Notes** + * Attempting to store a value without a namespace being open in read-write mode will fail. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``putBool`` +*********** + + Store a value against a given key in the currently open namespace. + + .. code-block:: arduino + + size_t putBool(const char* key, bool value) + + .. + + **Parameters** + * ``key`` (Required) + - if the key does not exist in the currently opened namespace it is first created. + + * ``value`` (Required) + - must match the data type of the method. + + **Returns** + * ``true`` if successful; ``false`` otherwise. + + **Notes** + * Attempting to store a value without a namespace being open in read-write mode will fail. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``putString`` +************** + + Store a variable length value against a given key in the currently open namespace. + + .. code-block:: arduino + + size_t putString(const char* key, const char* value); + size_t putString(const char* key, String value); + + .. + + **Parameters** + * ``key`` (Required) + - if the key does not exist in the currently opened namespace it is first created. + + * ``value`` (Required) + - if ``const char*``, a null-terminated (c-string) character array. + - if ``String``, a valid Arduino String type. + + **Returns** + * if successful: the number of bytes stored; ``0`` otherwise. + + **Notes** + * Attempting to store a value without a namespace being open in read-write mode will fail. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``putBytes`` +************ + + Store a variable number of bytes against a given key in the currently open namespace. + + .. code-block:: arduino + + size_t putBytes(const char* key, const void* value, size_t len); + + .. + + **Parameters** + * ``key`` (Required) + - if the key does not exist in the currently opened namespace it is first created. + + * ``value`` (Required) + - pointer to an array or buffer containing the bytes to be stored. + + * ``len`` (Required) + - the number of bytes from ``value`` to be stored. + + **Returns** + * if successful: the number of bytes stored; ``0`` otherwise. + + **Notes** + * Attempting to store a value without a namespace being open in read-write mode will fail. + * This method operates on the bytes used by the underlying data type, not the number of elements of a given data type. The data type of ``value`` is not retained by the Preferences library afterward. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``getChar, getUChar`` +********************* + + Retrieve a value stored against a given key in the currently open namespace. + + .. code-block:: arduino + + int8_t getChar(const char* key, int8_t defaultValue = 0) + uint8_t getUChar(const char* key, uint8_t defaultValue = 0) + + .. + + **Parameters** + * ``key`` (Required) + + * ``defaultValue`` (Optional) + - must match the data type of the method if provided. + + **Returns** + * the value stored against ``key`` if the call is successful. + * ``defaultValue``, if it is provided; ``0`` otherwise. + + **Notes** + * Attempting to retrieve a key without a namespace being available will fail. + * Attempting to retrieve value from a non existant key will fail. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``getShort, getUShort`` +**************************** + + Retrieve a value stored against a given key in the currently open namespace. + + .. code-block:: arduino + + int16_t getShort(const char* key, int16_t defaultValue = 0) + uint16_t getUShort(const char* key, uint16_t defaultValue = 0) + .. + + Except for the data type returned, behaves exactly like ``getChar``. + + + +``getInt, getUInt`` +******************* + + Retrieve a value stored against a given key in the currently open namespace. + + .. code-block:: arduino + + int32_t getInt(const char* key, int32_t defaultValue = 0) + uint32_t getUInt(const char* key, uint32_t defaultValue = 0) + + .. + + Except for the data type returned, behaves exactly like ``getChar``. + + +``getLong, getULong`` +********************* + + Retrieve a value stored against a given key in the currently open namespace. + + .. code-block:: arduino + + int32_t getLong(const char* key, int32_t defaultValue = 0) + uint32_t getULong(const char* key, uint32_t defaultValue = 0) + + .. + + Except for the data type returned, behaves exactly like ``getChar``. + + +``getLong64, getULong64`` +************************* + + Retrieve a value stored against a given key in the currently open namespace. + + .. code-block:: arduino + + int64_t getLong64(const char* key, int64_t defaultValue = 0) + uint64_t getULong64(const char* key, uint64_t defaultValue = 0) + + .. + + Except for the data type returned, behaves exactly like ``getChar``. + + +``getFloat`` +************* + + Retrieve a value stored against a given key in the currently open namespace. + + .. code-block:: arduino + + float_t getFloat(const char* key, float_t defaultValue = NAN) + + .. + + Except for the data type returned and the value of ``defaultValue``, behaves exactly like ``getChar``. + + +``getDouble`` +************* + + Retrieve a value stored against a given key in the currently open namespace. + + .. code-block:: arduino + + double_t getDouble(const char* key, double_t defaultValue = NAN) + + .. + + Except for the data type returned and the value of ``defaultValue``, behaves exactly like ``getChar``. + + +``getBool`` +************ + + Retrieve a value stored against a given key in the currently open namespace. + + .. code-block:: arduino + + uint8_t getUChar(const char* key, uint8_t defaultValue = 0); + + .. + + Except for the data type returned, behaves exactly like ``getChar``. + + +``getString`` +************* + + Copy a string of ``char`` stored against a given key in the currently open namespace to a buffer. + +.. code-block:: arduino + + size_t getString(const char* key, char* value, size_t len); +.. + + **Parameters** + * ``key`` (Required) + * ``value`` (Required) + - a buffer of a size large enough to hold ``len`` bytes + * ``len`` (Required) + - the number of type ``char``` to be written to the buffer pointed to by ``value`` + + **Returns** + * if successful; the number of bytes equal to ``len`` is written to the buffer pointed to by ``value``, and the method returns ``1``. + * if the method fails, nothing is written to the buffer pointed to by ``value`` and the method returns ``0``. + + **Notes** + * ``len`` must equal the number of bytes stored against the key or the call will fail. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``getString`` +************* + + Retrieve an Arduino String value stored against a given key in the currently open namespace. + +.. code-block:: arduino + + String getString(const char* key, String defaultValue = String()); + +.. + + **Parameters** + * ``key`` (Required) + * ``defaultValue`` (Optional) + + **Returns** + * the value stored against ``key`` if the call if successful + * if the method fails: it returns ``defaultValue``, if provided; ``""`` (an empty String) otherwise. + + **Notes** + * ``defaultValue`` must be of type ``String``. + + +``getBytes`` +************* + +Copy a series of bytes stored against a given key in the currently open namespace to a buffer. + +.. code-block:: arduino + + size_t getBytes(const char* key, void * buf, size_t len); + +.. + + **Parameters** + * ``key`` (Required) + * ``buf`` (Required) + - a buffer of a size large enough to hold ``len`` bytes. + * ``len`` (Required) + - the number of bytes to be written to the buffer pointed to by ``buf`` + + **Returns** + * if successful, the number of bytes equal to ``len`` is written to buffer ``buf``, and the method returns ``1``. + * if the method fails, nothing is written to the buffer and the method returns ``0``. + + **Notes** + * ``len`` must equal the number of bytes stored against the key or the call will fail. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``getBytesLength`` +****************** + +Get the number of bytes stored in the value against a key of type ``Bytes`` in the currently open namespace. + +.. code-block:: arduino + + size_t getBytesLength(const char* key) + +.. + + **Parameters** + * ``key`` (Required) + + **Returns** + * if successful: the number of bytes in the value stored against ``key``; ``0`` otherwise. + + **Notes** + * This method will fail if ``key`` is not of type ``Bytes``. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +``getType`` +*********** + +Get the Preferences data type of a given key within the currently open namespace. + +.. code-block:: arduino + + PreferenceType getType(const char* key) + +.. + + **Parameters** + * ``key`` (Required) + + **Returns** + * an ``int`` value as per Table 2 below. + * a value of ``10`` (PT_INVALID) if the call fails. + + **Notes** + * The return values are enumerated in ``Preferences.h``. Table 2 includes the enumerated values for information. + * A return value can map to more than one Prefs Type. + * The method will fail if: the namespace is not open; the key does not exist; the provided key exceeds 15 characters. + +.. table:: **Table 2 — getType Return Values** + :align: center + + +---------------+---------------+-------------------+-----------------------+ + | Return value | Prefs Type | Data Type | Enumerated Value | + +===============+===============+===================+=======================+ + | 0 | Char | int8_t | PT_I8 | + +---------------+---------------+-------------------+-----------------------+ + | 1 | UChar | uint8_t | PT_U8 | + | +---------------+-------------------+ | + | | Bool | bool | | + +---------------+---------------+-------------------+-----------------------+ + | 2 | Short | int16_t | PT_I16 | + +---------------+---------------+-------------------+-----------------------+ + | 3 | UShort | uint16_t | PT_U16 | + +---------------+---------------+-------------------+-----------------------+ + | 4 | Int | int32_t | PT_I32 | + | +---------------+ | | + | | Long | | | + +---------------+---------------+-------------------+-----------------------+ + | 5 | UInt | uint32_t | PT_U32 | + | +---------------+ | | + | | ULong | | | + +---------------+---------------+-------------------+-----------------------+ + | 6 | Long64 | int64_t | PT_I64 | + +---------------+---------------+-------------------+-----------------------+ + | 7 | ULong64 | uint64_t | PT_U64 | + +---------------+---------------+-------------------+-----------------------+ + | 8 | String | String | PT_STR | + | | +-------------------+ | + | | | \*char | | + +---------------+---------------+-------------------+-----------------------+ + | 9 | Double | double_t | PT_BLOB | + | +---------------+-------------------+ | + | | Float | float_t | | + | +---------------+-------------------+ | + | | Bytes | uint8_t | | + +---------------+---------------+-------------------+-----------------------+ + | 10 | \- | \- | PT_INVALID | + +---------------+---------------+-------------------+-----------------------+ + + +``freeEntries`` +*************** + +Get the number of free entries available in the key table of the currently open namespace. + +.. code-block:: arduino + + size_t freeEntries() + +.. + + **Parameters** + * none + + **Returns** + * if successful: the number of free entries available in the key table of the currently open namespace; ``0`` otherwise. + + **Notes** + * keys storing values of type ``Bool``, ``Char``, ``UChar``, ``Short``, ``UShort``, ``Int``, ``UInt``, ``Long``, ``ULong``, ``Long64``, ``ULong64`` use one entry in the key table. + * keys storing values of type ``Float`` and ``Double`` use three entries in the key table. + * Arduino or c-string ``String`` types use a minimum of two key table entries with the number of entries increasing with the length of the string. + * keys storing values of type ``Bytes`` use a minimum of three key table entries with the number of entries increasing with the number of bytes stored. + * A message providing the reason for a failed call is sent to the arduino-esp32 ``log_e`` facility. + + +.. --- EOF ---- \ No newline at end of file diff --git a/docs/source/api/usb_cdc.rst b/docs/source/api/usb_cdc.rst index 1c0b04f2f3c..7d700b955a8 100644 --- a/docs/source/api/usb_cdc.rst +++ b/docs/source/api/usb_cdc.rst @@ -34,6 +34,7 @@ Where ``event`` can be: * ARDUINO_USB_CDC_LINE_CODING_EVENT * ARDUINO_USB_CDC_RX_EVENT * ARDUINO_USB_CDC_TX_EVENT +* ARDUINO_USB_CDC_RX_OVERFLOW_EVENT * ARDUINO_USB_CDC_MAX_EVENT setRxBufferSize diff --git a/docs/source/guides/docs_contributing.rst b/docs/source/guides/docs_contributing.rst new file mode 100644 index 00000000000..be5a54e4b37 --- /dev/null +++ b/docs/source/guides/docs_contributing.rst @@ -0,0 +1,334 @@ +##################################### +Documentation Contribution Guidelines +##################################### + +Introduction +------------ + +This is a guideline for the Arduino ESP32 project documentation. The idea for this guideline is to show how to start collaborating on the project. + +The guideline works to give you the directions and to keep the documentation more concise, helping users to better understand the structure. + +About Documentation +------------------- + +We all know how important documentation is. This project is no different. + +This documentation was created in a collaborative and open way, letting everyone contribute, from a small typo fix to a new chapter writing. We try to motivate our community by giving all the support needed through this guide. + +The documentation is in **English only**. Future translations can be added when we finish the essential content in English first. + +How to Collaborate +------------------ + +Everyone with some knowledge to share is welcome to collaborate. + +One thing you need to consider is the fact that your contribution must be concise and assertive since it will be used by people developing projects. The information is very important for everyone, be sure you are not making the developer's life harder! + +Documentation Guide +------------------- + +This documentation is based on the `Sphinx`_ with `reStructuredText`_ and hosted by `ReadTheDocs`_. + +If you want to get started with `Sphinx`_, see the official documentation: + +* `Documentation Index `_ +* `Basics `_ +* `Directives `_ + +First Steps +*********** + +Before starting your collaboration, you need to get the documentation source code from the Arduino-ESP32 project. + +* **Step 1** - Fork the `Arduino-ESP32`_ to your GitHub account. +* **Step 2** - Check out the recently created fork. +* **Step 3** - Create a new branch for the changes/addition to the docs. +* **Step 4** - Write! + +Requirements +************ + +To properly work with the documentation, you need to install some packages in your system. + +.. code-block:: + + pip install -U Sphinx + pip install -r requirements.txt + +The requirements file is under the ``docs`` folder. + +Using Visual Studio Code +************************ + +If you are using the Visual Studio Code, you can install some extensions to help you while writing documentation. + +`reStructuredText Pack `_ + +We also recommend you install to grammar check extension to help you to review English grammar. + +`Grammarly `_ + +Building +******** + +To build the documentation and generate the HTLM files, you can use the following command inside the ``docs`` folder. After a successful build, you can check the files inside the `build/html` folder. + +.. code-block:: + + make html + +This step is essential to ensure that there are no syntax errors and also to see the final result. + +If everything is ok, you will see some output logs similar to this one: + +.. code-block:: + + Running Sphinx v2.3.1 + loading pickled environment... done + building [mo]: targets for 0 po files that are out of date + building [html]: targets for 35 source files that are out of date + updating environment: [extensions changed ('sphinx_tabs.tabs')] 41 added, 3 changed, 0 removed + reading sources... [100%] tutorials/tutorials + looking for now-outdated files... none found + pickling environment... done + checking consistency... done + preparing documents... done + writing output... [100%] tutorials/tutorials + generating indices... genindexdone + writing additional pages... searchdone + copying images... [100%] tutorials/../_static/tutorials/peripherals/tutorial_peripheral_diagram.png + copying static files... ... done + copying extra files... done + dumping search index in English (code: en)... done + dumping object inventory... done + build succeeded. + +The HTML pages are in build/html. + +Sections +-------- + +The Arduino ESP32 is structured in some sections to make it easier to maintain. Here is a brief description of this structure. + +API +*** + +In this section, you will include all the documentation about drivers, libraries, and any other related to the core. + +In this section, we do not add general information. For more general information, we have sections for other related parts, like the FAQ, library builder, troubleshooting, etc. + +Boards +****** + +Here is the place to add any special guide on the development boards, pin layout, schematics, and any other relevant content. + +Common +****** + +In this folder, you can add all common information used in several different places. This helps to make documentation easily maintainable. + + +Guides +****** + +This is the place to add the guides for common applications, IDEs configuration, and any other information that can be used as a guideline. + +Tutorials +********* + +If you want to add a specific tutorial related to the Arduino core for ESP32, this is the place. The intention is not to create a blog or a demo area, but this can be used to add some complex description or to add some more information about APIs. + +Images and Assets +***************** + +All the files used on the documentation must be stored in the ``_static`` folder. Be sure that the content used is not with any copyright restriction. + +Documentation Rules +------------------- + +Here are some guidelines to help you. We also recommend copying a sample file from the same category you are creating. + +This will help you to follow the structure as well as to get inspired. + +Basic Structure +*************** + +To help you create a new section from scratch, we recommend you include this structure in your content if it applies. + +* **About** - Brief description of the document. + * Description of the peripheral, driver, protocol, including all different modes and configurations. +* **API** - Description of each public function, macros, and structs. +* **Basic Usage** +* **Example Application** + +About Section +^^^^^^^^^^^^^ + +In this section, you need to add a brief description of the API. If you are describing a peripheral API, you should explain a little bit about the peripheral and the working modes, if it's applicable. + +API Functions +^^^^^^^^^^^^^ + +To add a new function description, you must know that the users only have access to the public functions. + + +Here is an example of how to add the function description from `I2C API `_: + +.. code-block:: + + setPins + ^^^^^^^ + + This function is used to define the ``SDA`` and ``SCL`` pins. + + .. note:: Call this function before ``begin`` to change the pins from the default ones. + + .. code-block:: arduino + + bool setPins(int sdaPin, int sclPin); + + * ``sdaPin`` sets the GPIO to be used as the I2C peripheral data line. + + * ``sclPin`` sets the GPIO to be used as the I2C peripheral clock line. + + The default pins may vary from board to board. On the *Generic ESP32* the default I2C pins are: + + * ``sdaPin`` **GPIO21** + + * ``sclPin`` **GPIO22** + + This function will return ``true`` if the peripheral was configured correctly. + +Be sure to include a very comprehensive description, add all the parameters in and out, and describe the desired output. + +If the function uses a specific structure, you can also describe the structure in the same function block or add a specific section if the structure is shared with other functions. + +Basic Usage +^^^^^^^^^^^ + +Some APIs are more complex to use or require more steps in order to configure or initialize. If the API is not straightforward in terms of usability, please consider adding a how-to-use section describing all the steps to get the API configured. + +Here is an example: + +.. code-block:: + + Basic Usage + ^^^^^^^^^^^ + + To start using I2C as slave mode on the Arduino, the first step is to include the ``Wire.h`` header to the sketch. + + .. code-block:: arduino + + #include "Wire.h" + + Before calling ``begin``, you must create two callback functions to handle the communication with the master device. + + .. code-block:: arduino + + Wire.onReceive(onReceive); + + and + + .. code-block:: arduino + + Wire.onRequest(onRequest); + + The ``onReceive`` will handle the request from the ``master`` device upon a slave read request and the ``onRequest`` will handle the answer to the master. + + Now, we can start the peripheral configuration by calling ``begin`` function with the device address. + + .. code-block:: arduino + + Wire.begin((uint8_t)I2C_DEV_ADDR); + + By using ``begin`` without any arguments, all the settings will be done by using the default values. To set the values on your own, see the function description. This function is described here: `i2c begin`_ + + + +Example Application +^^^^^^^^^^^^^^^^^^^ +It is very important to include at least one application example or a code snippet to help people using the API. + +If the API does not have any application example, you can embed the code directly. However, if the example is available, you must include it as a literal block. + +.. code-block:: + + .. literalinclude:: ../../../libraries/WiFi/examples/WiFiAccessPoint/WiFiAccessPoint.ino + :language: arduino + + +Sphinx Basics +------------- + +Heading Levels +************** + +The heading levels used on this documentation are: + +* **H1**: - (Dash) +* **H2**: * (Asterisk) +* **H3**: ^ (Circumflex) +* **H4**: # (Sharp) + +Code Block +********** + +To add a code block, you can use the following structure: + +.. code-block:: + + .. code-block:: arduino + bool begin(); //Code example + +Links +***** + +To include links to external content, you can use two ways. + +* First option: + +.. code-block:: + + `Arduino Wire Library`_ + + _Arduino Wire Library: https://www.arduino.cc/en/reference/wire + +* Second option: + +.. code-block:: + + `Arduino Wire Library `_ + +Images +****** + +To include images in the docs, first, add all the files into the ``_static`` folder with a filename that makes sense for the topic. + +After that, you can use the following structure to include the image in the docs. + +.. code-block:: + + .. figure:: ../_static/arduino_i2c_master.png + :align: center + :width: 720 + :figclass: align-center + +You can adjust the ``width`` according to the image size. + +Be sure the file size does not exceed 600kB. + +Support +******* + +If you need support on the documentation, you can ask a question in the discussion `here `_. + +Additional Guidelines +--------------------- + +If you want to contribute with code on the Arduino ESP32 core, be sure to follow the `ESP-IDF Documenting Code `_ as a reference. + +.. _Arduino-ESP32: https://github.com/espressif/arduino-esp32 +.. _Sphinx: https://www.sphinx-doc.org/en/master/ +.. _ReadTheDocs: https://readthedocs.org/ +.. _reStructuredText: https://docutils.sourceforge.io/rst.html diff --git a/docs/source/tutorials/preferences.rst b/docs/source/tutorials/preferences.rst new file mode 100644 index 00000000000..eb0397af543 --- /dev/null +++ b/docs/source/tutorials/preferences.rst @@ -0,0 +1,697 @@ +########### +Preferences +########### + + +Introduction +------------ + +The Preferences library is unique to arduino-esp32. It should be considered as the replacement for the Arduino EEPROM library. + +It uses a portion of the on-board non-volatile memory (NVS) of the ESP32 to store data. This data is retained across restarts and loss of power events to the system. + +Preferences works best for storing many small values, rather than a few large values. If you need to store large amounts of data, consider using a file system library such as LitteFS. + +The Preferences library is usable by all ESP32 variants. + + +Preferences Attributes +---------------------- + +Preferences data is stored in NVS in sections called a "``namespace``". Within each namespace are a set of ``key-value`` pairs. The "``key``" is the name of the data item and the "``value``" is, well, the value of that piece of data. Kind of like variables. The key is the name of the variable and the value is its value. Like variables, a ``key-value`` pair has a data type. + +Multiple namespaces are permitted within NVS. The name of each namespace must be unique. The keys within that namespace are unique to that namespace. Meaning the same key name can be used in multiple namespaces without conflict. + +Namespace and key names are case sensitive. + +Each key name must be unique within a namespace. + +Namespace and key names are character strings and are limited to a maximum of 15 characters. + +Only one namespace can be open (in use) at a time. + + +Library Overview +---------------- + +Library methods are provided to: + - create a namespace; + - open and close a namespace; + - store and retrieve data within a namespace for supported data types; + - determine if a key value has been initialized; + - delete a ``key-value`` pair; + - delete all ``key-value`` pairs in a namespace; + - determine data types stored against a key; + - determine the number of key entries available in the namespace. + +Preferences directly suports the following data types: + +.. table:: **Table 1 — Preferences Types** + :align: center + + +-------------------+-------------------+---------------+ + | Preferences Type | Data Type | Size (bytes) | + +===================+===================+===============+ + | Bool | bool | 1 | + +-------------------+-------------------+---------------+ + | Char | int8_t | 1 | + +-------------------+-------------------+---------------+ + | UChar | uint8_t | 1 | + +-------------------+-------------------+---------------+ + | Short | int16_t | 2 | + +-------------------+-------------------+---------------+ + | UShort | uint16_t | 2 | + +-------------------+-------------------+---------------+ + | Int | int32_t | 4 | + +-------------------+-------------------+---------------+ + | UInt | uint32_t | 4 | + +-------------------+-------------------+---------------+ + | Long | int32_t | 4 | + +-------------------+-------------------+---------------+ + | ULong | uint32_t | 4 | + +-------------------+-------------------+---------------+ + | Long64 | int64_t | 8 | + +-------------------+-------------------+---------------+ + | ULong64 | uint64_t | 8 | + +-------------------+-------------------+---------------+ + | Float | float_t | 8 | + +-------------------+-------------------+---------------+ + | Double | double_t | 8 | + +-------------------+-------------------+---------------+ + | | const char* | | + | String +-------------------+ variable | + | | String | | + +-------------------+-------------------+---------------+ + | Bytes | uint8_t | variable | + +-------------------+-------------------+---------------+ + +String values can be stored and retrieved either as an Arduino String or as a null terminated ``char`` array (C-string). + +Bytes type is used for storing and retrieving an arbitrary number of bytes in a namespace. + + +Workflow +-------- + +Preferences workflow, once everything is initialized, is pretty simple. + +To store a value: + - Open the namespace in read-write mode. + - Put the value into the key. + - Close the namespace. + +To retrieve a value: + - Open the namespace in read-only mode. + - Use the key to get the value. + - Close the namespace. + +*(Technically, you can retrieve a value if the namespace is open in either read-only or read-write mode but it's good practice to open the namespace in read-only mode if you are only retrieving values.)* + +When storing information, a "``put[PreferencesType]``" method referenced to its key is used. + +When retrieving information a "``get[PreferencesType]``" method referenced to its key is used. + +Ensuring that the data types of your “``get``'s” and “``put``'s” all match, you’re good to go. + +The nuance is in initializing everything at the start. + +Before you can store or retrieve anything using Preferences, both the namespace and the key within that namespace need to exist. So the workflow is: + +#. Create or open the namespace. +#. Test for the existence of a key that should exist if the namespace has been initialized. +#. If that key does not exist, create the key(s). +#. Carry on with the rest of your sketch where data can now be stored and retrieved from the namespace. + +Each step is discussed below. + +.. note:: + + From here on when referring in general to a method used to store or retrieve data we'll use the shorthand "``putX``" and "``getX``" where the "``X``" is understood to be a Preferences Type; Bool, UInt, Char, and so on from the Preferences Types table above. + +.. + + +Create or Open the Namespace +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In your sketch, first insert a declaration of a ``Preferences`` object by including a line like; + +.. code-block:: arduino + + Preferences mySketchPrefs; // "mySketchPrefs" is the name of the Preferences object. + // Can be whatever you want. + +This object is used with the Preferences methods to access the namespace and the key-value pairs it contains. + +A namespace is made available for use with the ``.begin`` method: + +.. code-block:: arduino + + mySketchPrefs.begin("myPrefs", false) + +If the namespace does not yet exist, this will create and then open the namespace ``myPrefs``. + +If the namespace already exists, this will open the namespace ``myPrefs``. + +If the second argument is ``false`` the namespace is opened in read-write (RW) mode — values can be stored in to and retrieved from the namespace. If it is ``true`` the namespace is opened in read-only (RO) mode — values can be retrieved from the namespace but nothing can be stored. + + +Test for Initial Existence of Your Key(s) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +When the ESP32 boots, there is no inherent way to know if this is the very first time it has ever powered on or if it is a subsequent launch and it has run its sketch before. We can use Preferences to store information that is retained across reboots that we can read, and based on that, decide if this is a first-time run and take the required actions if so. + +We do this by testing for the existence of a certain key within a namespace. If that key exists, it is safe to assume the key was created during the first-time run of the sketch and so the namespace has already been initialized. + +To determine if a key exists, use: + +.. code-block:: arduino + + isKey("myTestKey") + +This returns ``true`` if ``"myTestKey"`` exists in the namespace, and ``false`` if it does not. + +By example, consider this code segment: + +.. code-block:: arduino + + Preferences mySketchPrefs; + String doesExist; + + mySketchPrefs.begin("myPrefs", false); // open (or create and then open if it does not + // yet exist) the namespace "myPrefs" in RW mode. + + bool doesExist = mySketchPrefs.isKey("myTestKey"); + + if (doesExist == false) { + /* + If doesExist is false, we will need to create our + namespace key(s) and store a value into them. + */ + + // Insert your "first time run" code to create your keys & assign their values below here. + } + else { + /* + If doesExist is true, the key(s) we need have been created before + and so we can access their values as needed during startup. + */ + + // Insert your "we've been here before" startup code below here. + } + + + +Creating Namespace Keys and Storing Values +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To create a key, we use one of the ``.putX`` methods, matching ``"X"`` to the Preferences Type of the data we wish to store: + +.. code-block:: arduino + + myPreferences.putX("myKeyName", value) + +If ``"myKeyName"`` does not exist in the namespace, it is first created and then ``value`` is stored against that keyname. The namespace must be open in RW mode to do this. Note that ``value`` is not optional and must be provided with every "``.putX``" statement. Thus every key within a namespace will always hold a valid value. + +An example is: + +.. code-block:: arduino + + myPreferences.putFloat("pi", 3.14159265359); // stores an float_t data type + // against the key "pi". + +Reading Values From a Namespace +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Once a key exists in a namespace and the namespace is open, its value is retrieved using one of the ``getX`` methods, matching ``"X"`` to the type of data stored against that key. + +.. code-block:: arduino + + myPreferences.getX("myKeyName") + +Like so: + +.. code-block:: arduino + + String myString = myPreferences.getString("myStringKey"); + +This will retrieve the String value from the namespace key ``"myStringKey"`` and assign it to the String type variable ``myString``. + + +Summary +~~~~~~~ + +So the basics of using Preferences are: + + #. You cannot store into or retrieve from a ``key-value`` pair until a namespace is created and opened and the key exists in that namespace. + + #. If the key already exists, it was created the first time the sketch was run. + + #. A key value can be retrieved regardless of the mode in which the namespace was opened, but a value can only be stored if the namespace is open in read-write mode. + + #. Data types of the “``get``'s” and “``put``'s” must match. + + #. Remember the 15 character limit for namespace and key names. + + +Real World Example +------------------ + +Here is part of a ``setup()`` function that uses Preferences. + +Its purpose is to set either a factory default configuration if the system has never run before, or use the last configuration if it has. + +When started, the system has no way of knowing which of the above conditions is true. So the first thing it does after opening the namespace is check for the existence of a key that we have predetermined can only exist if we have previously run the sketch. Based on its existence we decide if a factory default set of operating parameters should be used (and in so doing create the namespace keys and populate the values with defaults) or if we should use operating parameters from the last time the system was running. + +.. code-block:: arduino + + #include + + #define RW_MODE false + #define RO_MODE true + + Preferences stcPrefs; + + void setup() { + + // 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 in RO mode. + + 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 + // must be our first-time run. We need to set up our Preferences namespace keys. So... + stcPrefs.end(); // close the namespace in RO mode and... + stcPrefs.begin("STCPrefs", RW_MODE); // reopen it in RW mode. + + + // 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. + 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. + + // The "factory defaults" are created and stored so... + stcPrefs.end(); // Close the namespace in RW mode and... + stcPrefs.begin("STCPrefs", RO_MODE); // reopen it in RO mode so the setup code + // outside this first-time run 'if' block + // can retrieve the run-time values + // from the "STCPrefs" namespace. + } + + // Retrieve the operational parameters from the namespace + // and save them into their run-time variables. + currentBrightness = stcPrefs.getUChar("curBright"); // + tChannel = stcPrefs.getString("talChan"); // The LHS variables were defined + tChanMax = stcPrefs.getLong("talMax"); // earlier in the sketch. + ctMode = stcPrefs.getBool("ctMde"); // + + // All done. Last run state (or the factory default) is now restored. + stcPrefs.end(); // Close our preferences namespace. + + // Carry on with the rest of your setup code... + + // When the sketch is running, it updates any changes to an operational parameter + // to the appropriate key-value pair in the namespace. + + } + + +Utility Functions +----------------- + +There are a few other functions useful when working with namespaces. + +Deleting key-value Pairs +~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: arduino + + preferences.clear(); + +.. + + - Deletes *all* the key-value pairs in the currently opened namespace. + + - The namespace still exists. + + - The namespace must be open in read-write mode for this to work. + +.. code-block:: arduino + + preferences.remove("keyname"); + +.. + + - Deletes the "keyname" and value associated with it from the currently opened namespace. + + - The namespace must be open in read-write mode for this to work. + - Tip: use this to remove the "test key" to force a "factory reset" during the next reboot (see the *Real World Example* above). + +If either of the above are used, the ``key-value`` pair will need to be recreated before using it again. + + +Determining the Number of Available Keys +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +For each namespace, Preferences keeps track of the keys in a key table. There must be an open entry in the table before a key can be created. This method will return the number of entires available in the table. + +.. code-block:: arduino + + freeEntries() + +.. + +To send to the serial monitor the number of available entries the following could be used. + +.. code-block:: arduino + + Preferences mySketchPrefs; + + mySketchPrefs.begin("myPrefs", true); + size_t whatsLeft = freeEntries(); // this method works regardless of the mode in which the namespace is opened. + Serial.printf("There are: %u entries available in the namespace table.\n, whatsLeft); + mySketchPrefs.end(); + +.. + +The number of available entries in the key table changes depending on the number of keys in the namespace and also the dynamic size of certain types of data stored in the namespace. Details are in the `Preferences API Reference`_. + +Do note that the number of entries in the key table does not guarantee that there is room in the opened NVS namespace for all the data to be stored in that namespace. Refer to the espressif `Non-volatile storage library`_ documentation for full details. + + +Determining the Type of a key-value Pair +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Keeping track of the data types stored against a key-value pair is one of the bookkeeping tasks left to you. Should you want to discover the Preferences data type stored against a given key, use this method: + +.. code-block:: arduino + + getType("myKey") + +.. + +As in: + +.. code-block:: arduino + + PreferenceType whatType = getType("myKey"); + +.. + +The value returned is a ``PreferenceType`` value that maps to a Preferences Type. Refer to the description in the `Preferences API Reference`_ for details. + + + +Working with Large Data +----------------------- + +Recall that the Preferences library works best for storing many small values, rather than a few large values. Regardless, it may be desirable to store larger amounts of arbitrary data than what is provided by the basic types in the Preferences Types table above. + +The library provides the following methods to facilitate this. + +.. code-block:: arduino + + putBytes("myBytesKey", value, valueLen) + getBytes("myBytesKey", buffer, valueLen) + getBytesLength("myBytesKey") + +.. + +The ``put`` and ``get`` ``Bytes`` methods store and retrieve the data. The ``getBytesLength`` method is used to find the size of the data stored against the key (which is needed to retrieve ``Bytes`` data). + +As the names of the methods imply, they operate on variable length bytes of data (often referred to as a "blob") and not on individual elements of a certain data type. + +Meaning if you store for example an array of type ``int16_t`` against a ``Bytes`` type key, the value of that key becomes a series of bytes with no associated data type. Or if you like, all data stored as a blob gets converted to a series of ``uint8_t`` type bytes. + +As a result, when using the ``getBytes`` method to retrieve the value of the key, what is returned to the buffer is a series of ``uint8_t`` bytes. It is up to you to manage the data types and size of the arrays and buffers when retrieving ``Bytes`` data. + +Fortunately this is not as difficult as it may sound as the ``getBytesLength`` method and the ``sizeof`` operator help with keeping track of it all. + +This is best explained with an example. Here the ``Bytes`` methods are used to store and retrieve an array, while ensuring the data type is preserved. + +.. code-block:: arduino + + /* + * An example sketch using the Preferences "Bytes" methods + * to store and retrieve an arbitrary number of bytes in + * a namespace. + */ + + #include + + #define RO_MODE true + #define RW_MODE false + + void setup() { + + Preferences mySketchPrefs; + + Serial.begin(115200); + delay(250); + + 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. + int16_t myArray[] = { 0x1112, 0x2122, 0x3132, 0x4142, 0x5152, 0x6162, 0x7172 }; + + Serial.println("Printing myArray..."); + for (int i = 0; i < sizeof(myArray) / sizeof(int16_t); i++) { + Serial.print(myArray[i], HEX); Serial.print(", "); + } + 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) ); + Serial.println(""); + + 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.println(""); + + 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") ); + + Serial.println("Printing myIntBuffer..."); + // In the next statement, sizeof() needs to match the data type of the elements of myArray + for (int i = 0; i < mySketchPrefs.getBytesLength("myPrefsBytes") / sizeof(int16_t); i++) { + Serial.print(myIntBuffer[i], HEX); Serial.print(", "); + } + 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("Printing myByteBuffer..."); + for (int i = 0; i < mySketchPrefs.getBytesLength("myPrefsBytes"); i++) { + Serial.print(myByteBuffer[i], HEX); Serial.print(", "); + } + Serial.println(""); + + } + + void loop() { + ; + } + +.. + +The resulting output is: +:: + + Printing myArray... + 1112, 2122, 3132, 4142, 5152, 6162, 7172, + + The number of elements in myArray is: 7 + But the size of myArray in bytes is: 14 + + Storing myArray into the Preferences namespace "myPrefs" against the key "myPrefsBytes". + The size of "myPrefsBytes" is (in bytes): 14 + + Retrieving the value of myPrefsBytes into myIntBuffer. + - Note the data type of myIntBuffer matches that of myArray + Printing myIntBuffer... + 1112, 2122, 3132, 4142, 5152, 6162, 7172, + + We can see how the data from myArray is actually stored in the namespace as follows. + Printing myByteBuffer... + 12, 11, 22, 21, 32, 31, 42, 41, 52, 51, 62, 61, 72, 71, + +You can copy the sketch and change the data type and values in ``myArray`` and follow along with the code and output to see how the ``Bytes`` methods work. The data type of ``myIntBuffer`` should be changed to match that of ``myArray`` (and check the "``sizeof()``'s" where indicated in the comments). + +The main takeaway is to remember you're working with bytes and so attention needs to be paid to store all the data based on the size of its type and to manage the buffer size and data type for the value retrieved. + + +Multiple Namespaces +------------------- + +As stated earlier, multiple namespaces can exist in the Preferences NVS partition. However, only one namespace at a time can be open (in use). + +If you need to access a different namespace, close the one before opening the other. For example: + +.. code-block:: arduino + + Preferences currentNamespace; + + currentNamespace.begin("myNamespace", false); + // do stuff... + + currentNamespace.end(); // closes 'myNamespace' + + currentNamespace.begin("myOtherNamespace", false); // opens a different Preferences namesspace. + // do other stuff... + + currentNamespace.end(); // closes 'myOtherNamespace' + +Here the "``currentNamespace``" object is reused, but different Preferences objects can be declared and used. Just remember to keep it all straight as all "``putX``'s" and "``getX``'s", etc. will only operate on the single currently opened namespace. + + +A Closer Look at ``getX`` +-------------------------- + +Methods in the Preferences library return a status code that can be used to determine if the method completed successfully. This is described in the `Preferences API Reference`_. + +Assume we have a key named "``favourites``" that contains a value of a ``String`` data type. + +After executing the statement: + +.. code-block:: arduino + + dessert = mySketchPrefs.getString("favourites"); + +.. + +the variable ``dessert`` will contain the value of the string stored against the key ``"favourites"``. + +But what if something went wrong and the ``getString`` call failed to retrieve the key value? How would we be able to detect the error? + +With Preferences, the ``getX`` methods listed in Table 2 below will return a default value if an error is encountered. + +.. table:: **Table 2 — getX Methods Defaults** + :align: center + + +------------------+-----------------+ + | Preferences | Default Return | + | Type | Value | + +==================+=================+ + | Char, UChar, | 0 | + | | | + | Short, UShort, | | + | | | + | Int, UInt, | | + | | | + | Long, ULong, | | + | | | + | Long64, ULong64 | | + +------------------+-----------------+ + | Bool | false | + +------------------+-----------------+ + | Float | NAN | + | | | + | Double | | + +------------------+-----------------+ + | String (String) | "" | + +------------------+-----------------+ + | String (* buf) | \\0 | + +------------------+-----------------+ + +Thus to detect an error we could compare the value returned against its default return value and if they are equal assume an error occurred and take the appropriate action. + +But what if a method default return value is also a potential legitimate value? How can we then know if an error occurred? + +As it turns out, the complete form of the ``getX`` methods for each of the Preferences Types in Table 2 is: + +.. code-block:: arduino + + preferences.getX("myKey", myDefault) + +.. + +In this form the method will return either the value associated with "``myKey``" or, if an error occurred, return the value ``myDefault``, where ``myDefault`` must be the same data type as the ``getX``. + +Returning to the example above: + +.. code-block:: arduino + + dessert = mySketchPrefs.getString("favourites", "gravel"); + +.. + +will assign to the variable ``dessert`` the String ``gravel`` if an error occurred, or the value stored against the key ``favourites`` if not. + +If we predetermine a default value that is outside all legitimate values, we now have a way to test if an error actually occurred. + +In summary, if you need to confirm that a value was retrieved without error from a namespace, use the complete form of the ``getX`` method with a predetermined default "this can only happen if an error" value and compare that against the value returned by the call. Otherwise, you can omit the default value as the call will return the default for that particular ``getX`` method. + +Additional detail is given in the `Preferences API Reference`_. + + +Advanced Item +------------- + +In the arduino-esp32 implementation of Preferences there is no method to completely remove a namespace. As a result, over the course of a number of projects, it is possible that the ESP32 NVS Preferences partition becomes cluttered or full. + +To completely erase and reformat the NVS memory used by Preferences, create and run a sketch that contains: + +.. code-block:: arduino + + #include + + void setup() { + + nvs_flash_erase(); // erase the NVS partition and... + nvs_flash_init(); // initialize the NVS partition. + while (true); + + } + + void loop() { + ; + } + +.. + +.. warning:: + **You should download a new sketch to your board immediately after running the above or else it will reformat the NVS partition every time it is powered up or restarted!** + + +Resources +--------- + +* `Preferences API Reference <../api/preferences.html>`_ +* `Non-volatile storage library`_ (espressif-IDF API Reference) +* `Official ESP-IDF documentation`_ (espressif-IDF Reference) + + +.. _Non-volatile storage library: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/storage/nvs_flash.html +.. _Official ESP-IDF documentation: https://docs.espressif.com/projects/esp-idf/en/stable + + +Contribute +---------- + +.. ==*Do not change! Keep as is.*== + +To contribute to this project, see `How to contribute`_. + +If you have any **feedback** or **issue** to report on this tutorial, please open an issue or fix it by creating a new PR. Contributions are more than welcome! + +Before creating a new issue, be sure to try the Troubleshooting and to check if the same issue was already created by someone else. + +.. _How to Contribute: https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst + +.. ---- EOF ---- diff --git a/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino b/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino index d779c6d349e..86cbe168a14 100644 --- a/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino +++ b/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino @@ -10,6 +10,10 @@ #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it #endif +#if !defined(CONFIG_BT_SPP_ENABLED) +#error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip. +#endif + BluetoothSerial SerialBT; void setup() { diff --git a/libraries/BluetoothSerial/examples/SerialToSerialBTM/SerialToSerialBTM.ino b/libraries/BluetoothSerial/examples/SerialToSerialBTM/SerialToSerialBTM.ino index 3d17fb9005a..fc650059fb7 100644 --- a/libraries/BluetoothSerial/examples/SerialToSerialBTM/SerialToSerialBTM.ino +++ b/libraries/BluetoothSerial/examples/SerialToSerialBTM/SerialToSerialBTM.ino @@ -8,6 +8,10 @@ #include "BluetoothSerial.h" +#if !defined(CONFIG_BT_SPP_ENABLED) +#error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip. +#endif + BluetoothSerial SerialBT; String MACadd = "AA:BB:CC:11:22:33"; diff --git a/libraries/BluetoothSerial/examples/SerialToSerialBT_SSP_pairing/SerialToSerialBT_SSP_pairing.ino b/libraries/BluetoothSerial/examples/SerialToSerialBT_SSP_pairing/SerialToSerialBT_SSP_pairing.ino index 8791b6c7a02..c440545fcf3 100644 --- a/libraries/BluetoothSerial/examples/SerialToSerialBT_SSP_pairing/SerialToSerialBT_SSP_pairing.ino +++ b/libraries/BluetoothSerial/examples/SerialToSerialBT_SSP_pairing/SerialToSerialBT_SSP_pairing.ino @@ -10,6 +10,10 @@ #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it #endif +#if !defined(CONFIG_BT_SPP_ENABLED) +#error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip. +#endif + BluetoothSerial SerialBT; boolean confirmRequestPending = true; diff --git a/libraries/BluetoothSerial/examples/bt_classic_device_discovery/bt_classic_device_discovery.ino b/libraries/BluetoothSerial/examples/bt_classic_device_discovery/bt_classic_device_discovery.ino index b3ec78ccf2a..8d44f262174 100644 --- a/libraries/BluetoothSerial/examples/bt_classic_device_discovery/bt_classic_device_discovery.ino +++ b/libraries/BluetoothSerial/examples/bt_classic_device_discovery/bt_classic_device_discovery.ino @@ -4,6 +4,10 @@ #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it #endif +#if !defined(CONFIG_BT_SPP_ENABLED) +#error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip. +#endif + BluetoothSerial SerialBT; diff --git a/libraries/BluetoothSerial/examples/bt_remove_paired_devices/bt_remove_paired_devices.ino b/libraries/BluetoothSerial/examples/bt_remove_paired_devices/bt_remove_paired_devices.ino index c316a73b2bc..0d49fe46414 100755 --- a/libraries/BluetoothSerial/examples/bt_remove_paired_devices/bt_remove_paired_devices.ino +++ b/libraries/BluetoothSerial/examples/bt_remove_paired_devices/bt_remove_paired_devices.ino @@ -15,6 +15,10 @@ #include"esp_gap_bt_api.h" #include "esp_err.h" +#if !defined(CONFIG_BT_SPP_ENABLED) +#error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip. +#endif + #define REMOVE_BONDED_DEVICES 0 // <- Set to 0 to view all bonded devices addresses, set to 1 to remove #define PAIR_MAX_DEVICES 20 diff --git a/libraries/FS/src/vfs_api.cpp b/libraries/FS/src/vfs_api.cpp index e43b4397452..9e200a1500b 100644 --- a/libraries/FS/src/vfs_api.cpp +++ b/libraries/FS/src/vfs_api.cpp @@ -13,9 +13,12 @@ // limitations under the License. #include "vfs_api.h" +#include using namespace fs; +#define READ_SIZE_SWITCH 128 //swithc to read func when read size > 128bytes + FileImplPtr VFSImpl::open(const char* fpath, const char* mode, const bool create) { if(!_mountpoint) { @@ -374,7 +377,28 @@ size_t VFSFileImpl::read(uint8_t* buf, size_t size) return 0; } - return fread(buf, 1, size, _f); + //ERASE BYTEBUFFER and use read when size > READ_SIZE_SWITCH always + if(size > READ_SIZE_SWITCH) + { + //check some data in buffer exists –> clear buffer and move pointer to deleted data + size_t bytesinbuf = __fpending(_f); + if (bytesinbuf && (bytesinbuf != 128)) //buffer lenght is 128 bytes + { + fpurge(_f); + lseek(fileno(_f),(-128+bytesinbuf),SEEK_CUR); + } + + int res = ::read(fileno(_f), buf, size); + if (res < 0) { + // an error occurred + return 0; + } + return res; + } + else + { + return fread(buf, 1, size, _f); + } } void VFSFileImpl::flush() diff --git a/libraries/README.md b/libraries/README.md index d7e0e8fbd29..23a4d376e18 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -12,7 +12,9 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec Bluetooth Low Energy v4.2 client/server framework ### BluetoothSerial - Serial to Bluetooth redirection server + Serial to Bluetooth redirection server\ + Note: This library depends on Bluetooth Classic which is only available for ESP32\ + (Bluetoothserial is **not available** for ESP32-S2, ESP32-C3, ESP32-S3). ### DNSServer A basic UDP DNS daemon (includes captive portal demo) diff --git a/libraries/SD/src/SD.cpp b/libraries/SD/src/SD.cpp index 8e2b6d234e5..b1731f155ba 100644 --- a/libraries/SD/src/SD.cpp +++ b/libraries/SD/src/SD.cpp @@ -75,6 +75,22 @@ uint64_t SDFS::cardSize() return (uint64_t)sectors * sectorSize; } +size_t SDFS::numSectors() +{ + if(_pdrv == 0xFF) { + return 0; + } + return sdcard_num_sectors(_pdrv); +} + +size_t SDFS::sectorSize() +{ + if(_pdrv == 0xFF) { + return 0; + } + return sdcard_sector_size(_pdrv); +} + uint64_t SDFS::totalBytes() { FATFS* fsinfo; diff --git a/libraries/SD/src/SD.h b/libraries/SD/src/SD.h index 665b33370e4..a5548579bd7 100644 --- a/libraries/SD/src/SD.h +++ b/libraries/SD/src/SD.h @@ -32,6 +32,8 @@ class SDFS : public FS void end(); sdcard_type_t cardType(); uint64_t cardSize(); + size_t numSectors(); + size_t sectorSize(); uint64_t totalBytes(); uint64_t usedBytes(); bool readRAW(uint8_t* buffer, uint32_t sector); diff --git a/libraries/USB/examples/CompositeDevice/CompositeDevice.ino b/libraries/USB/examples/CompositeDevice/CompositeDevice.ino index 754ff90a26a..4c1021bc57b 100644 --- a/libraries/USB/examples/CompositeDevice/CompositeDevice.ino +++ b/libraries/USB/examples/CompositeDevice/CompositeDevice.ino @@ -78,7 +78,10 @@ static void usbEventCallback(void* arg, esp_event_base_t event_base, int32_t eve } HWSerial.println(); break; - + case ARDUINO_USB_CDC_RX_OVERFLOW_EVENT: + HWSerial.printf("CDC RX Overflow of %d bytes", data->rx_overflow.dropped_bytes); + break; + default: break; } diff --git a/libraries/USB/examples/USBSerial/USBSerial.ino b/libraries/USB/examples/USBSerial/USBSerial.ino index 1766d81bcb3..0f57e2b1b1d 100644 --- a/libraries/USB/examples/USBSerial/USBSerial.ino +++ b/libraries/USB/examples/USBSerial/USBSerial.ino @@ -57,7 +57,10 @@ static void usbEventCallback(void* arg, esp_event_base_t event_base, int32_t eve } HWSerial.println(); break; - + case ARDUINO_USB_CDC_RX_OVERFLOW_EVENT: + HWSerial.printf("CDC RX Overflow of %d bytes", data->rx_overflow.dropped_bytes); + break; + default: break; } diff --git a/libraries/WiFi/examples/WiFiClientEnterprise/WiFiClientEnterprise.ino b/libraries/WiFi/examples/WiFiClientEnterprise/WiFiClientEnterprise.ino index d7a2d0ad3cf..caaa2139170 100644 --- a/libraries/WiFi/examples/WiFiClientEnterprise/WiFiClientEnterprise.ino +++ b/libraries/WiFi/examples/WiFiClientEnterprise/WiFiClientEnterprise.ino @@ -1,10 +1,22 @@ #include //Wifi library #include "esp_wpa2.h" //wpa2 library for connections to Enterprise networks #define EAP_IDENTITY "login" //if connecting from another corporation, use identity@organisation.domain in Eduroam +#define EAP_USERNAME "login" //oftentimes just a repeat of the identity #define EAP_PASSWORD "password" //your Eduroam password const char* ssid = "eduroam"; // Eduroam SSID const char* host = "arduino.php5.sk"; //external server domain for HTTP connection after authentification int counter = 0; + +// NOTE: For some systems, various certification keys are required to connect to the wifi system. +// Usually you are provided these by the IT department of your organization when certs are required +// and you can't connect with just an identity and password. +// Most eduroam setups we have seen do not require this level of authentication, but you should contact +// your IT department to verify. +// You should uncomment these and populate with the contents of the files if this is required for your scenario (See Example 2 and Example 3 below). +//const char *ca_pem = "insert your CA cert from your .pem file here"; +//const char *client_cert = "insert your client cert from your .crt file here"; +//const char *client_key = "insert your client key from your .key file here"; + void setup() { Serial.begin(115200); delay(10); @@ -13,11 +25,17 @@ void setup() { Serial.println(ssid); WiFi.disconnect(true); //disconnect form wifi to set new wifi connection WiFi.mode(WIFI_STA); //init wifi mode - esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide identity - esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY)); //provide username --> identity and username is same - esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)); //provide password - esp_wifi_sta_wpa2_ent_enable(); - WiFi.begin(ssid); //connect to wifi + + // Example1 (most common): a cert-file-free eduroam with PEAP (or TTLS) + WiFi.begin(ssid, WPA2_AUTH_PEAP, EAP_IDENTITY, EAP_USERNAME, EAP_PASSWORD); + + // Example 2: a cert-file WPA2 Enterprise with PEAP + //WiFi.begin(ssid, WPA2_AUTH_PEAP, EAP_IDENTITY, EAP_USERNAME, EAP_PASSWORD, ca_pem, client_cert, client_key); + + // Example 3: TLS with cert-files and no password + //WiFi.begin(ssid, WPA2_AUTH_TLS, EAP_IDENTITY, NULL, NULL, ca_pem, client_cert, client_key); + + while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); diff --git a/libraries/WiFi/src/WiFiSTA.cpp b/libraries/WiFi/src/WiFiSTA.cpp index c75405bb4f3..02e7185cd7e 100644 --- a/libraries/WiFi/src/WiFiSTA.cpp +++ b/libraries/WiFi/src/WiFiSTA.cpp @@ -42,6 +42,7 @@ extern "C" { #include "lwip/dns.h" #include #include +#include "esp_wpa2.h" } // ----------------------------------------------------------------------------------------------------------------------- @@ -145,6 +146,67 @@ wl_status_t WiFiSTAClass::status() return (wl_status_t)xEventGroupClearBits(_sta_status_group, 0); } +/** + * Start Wifi connection with a WPA2 Enterprise AP + * if passphrase is set the most secure supported mode will be automatically selected + * @param ssid const char* Pointer to the SSID string. + * @param method wpa2_method_t The authentication method of WPA2 (WPA2_AUTH_TLS, WPA2_AUTH_PEAP, WPA2_AUTH_TTLS) + * @param wpa2_identity const char* Pointer to the entity + * @param wpa2_username const char* Pointer to the username + * @param password const char * Pointer to the password. + * @param ca_pem const char* Pointer to a string with the contents of a .pem file with CA cert + * @param client_crt const char* Pointer to a string with the contents of a .crt file with client cert + * @param client_key const char* Pointer to a string with the contants of a .key file with client key + * @param bssid uint8_t[6] Optional. BSSID / MAC of AP + * @param channel Optional. Channel of AP + * @param connect Optional. call connect + * @return + */ +wl_status_t WiFiSTAClass::begin(const char* wpa2_ssid, wpa2_auth_method_t method, const char* wpa2_identity, const char* wpa2_username, const char *wpa2_password, const char* ca_pem, const char* client_crt, const char* client_key, int32_t channel, const uint8_t* bssid, bool connect) +{ + if(!WiFi.enableSTA(true)) { + log_e("STA enable failed!"); + return WL_CONNECT_FAILED; + } + + if(!wpa2_ssid || *wpa2_ssid == 0x00 || strlen(wpa2_ssid) > 32) { + log_e("SSID too long or missing!"); + return WL_CONNECT_FAILED; + } + + if(wpa2_identity && strlen(wpa2_identity) > 64) { + log_e("identity too long!"); + return WL_CONNECT_FAILED; + } + + if(wpa2_username && strlen(wpa2_username) > 64) { + log_e("username too long!"); + return WL_CONNECT_FAILED; + } + + if(wpa2_password && strlen(wpa2_password) > 64) { + log_e("password too long!"); + } + + if(ca_pem) { + esp_wifi_sta_wpa2_ent_set_ca_cert((uint8_t *)ca_pem, strlen(ca_pem)); + } + + if(client_crt) { + esp_wifi_sta_wpa2_ent_set_cert_key((uint8_t *)client_crt, strlen(client_crt), (uint8_t *)client_key, strlen(client_key), NULL, 0); + } + + esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)wpa2_identity, strlen(wpa2_identity)); + if(method == WPA2_AUTH_PEAP || method == WPA2_AUTH_TTLS) { + esp_wifi_sta_wpa2_ent_set_username((uint8_t *)wpa2_username, strlen(wpa2_username)); + esp_wifi_sta_wpa2_ent_set_password((uint8_t *)wpa2_password, strlen(wpa2_password)); + } + esp_wifi_sta_wpa2_ent_enable(); //set config settings to enable function + WiFi.begin(wpa2_ssid); //connect to wifi + + return status(); +} + /** * Start Wifi connection * if passphrase is set the most secure supported mode will be automatically selected diff --git a/libraries/WiFi/src/WiFiSTA.h b/libraries/WiFi/src/WiFiSTA.h index e49273f0176..613c37682b8 100644 --- a/libraries/WiFi/src/WiFiSTA.h +++ b/libraries/WiFi/src/WiFiSTA.h @@ -30,6 +30,11 @@ #include "esp_event.h" #endif +typedef enum { + WPA2_AUTH_TLS = 0, + WPA2_AUTH_PEAP = 1, + WPA2_AUTH_TTLS = 2 +} wpa2_auth_method_t; class WiFiSTAClass { @@ -39,6 +44,7 @@ class WiFiSTAClass public: + wl_status_t begin(const char* wpa2_ssid, wpa2_auth_method_t method, const char* wpa2_identity=NULL, const char* wpa2_username=NULL, const char *wpa2_password=NULL, const char* ca_pem=NULL, const char* client_crt=NULL, const char* client_key=NULL, int32_t channel=0, const uint8_t* bssid=0, bool connect=true); wl_status_t begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true); wl_status_t begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true); wl_status_t begin(); diff --git a/tools/esptool.py b/tools/esptool.py index aaec1854581..beb06a3098d 100755 --- a/tools/esptool.py +++ b/tools/esptool.py @@ -374,6 +374,10 @@ def detect_chip(port=DEFAULT_PORT, baud=ESP_ROM_BAUD, connect_mode='default_rese if chip_id == cls.IMAGE_CHIP_ID: inst = cls(detect_port._port, baud, trace_enabled=trace_enabled) inst._post_connect() + try: + inst.read_reg(ESPLoader.CHIP_DETECT_MAGIC_REG_ADDR) # Dummy read to check Secure Download mode + except UnsupportedCommandError: + inst.secure_download_mode = True except (UnsupportedCommandError, struct.error, FatalError) as e: # UnsupportedCmdErr: ESP8266/ESP32 ROM | struct.err: ESP32-S2 | FatalErr: ESP8266/ESP32 STUB print(" Unsupported detection protocol, switching and trying again...") @@ -2376,6 +2380,11 @@ class ESP32C2ROM(ESP32C3ROM): CHIP_NAME = "ESP32-C2" IMAGE_CHIP_ID = 12 + IROM_MAP_START = 0x42000000 + IROM_MAP_END = 0x42400000 + DROM_MAP_START = 0x3c000000 + DROM_MAP_END = 0x3c400000 + CHIP_DETECT_MAGIC_VALUE = [0x6f51306f] EFUSE_BASE = 0x60008800 @@ -4730,16 +4739,21 @@ def flash_xmc_startup(): print("XMC flash chip boot-up fix successful!") # Check flash chip connection - try: - flash_id = esp.flash_id() - if flash_id in (0xffffff, 0x000000): - print('WARNING: Failed to communicate with the flash chip, read/write operations will fail. ' - 'Try checking the chip connections or removing any other hardware connected to IOs.') - except Exception as e: - esp.trace('Unable to verify flash chip connection ({}).'.format(e)) + if not esp.secure_download_mode: + try: + flash_id = esp.flash_id() + if flash_id in (0xffffff, 0x000000): + print('WARNING: Failed to communicate with the flash chip, read/write operations will fail. ' + 'Try checking the chip connections or removing any other hardware connected to IOs.') + except Exception as e: + esp.trace('Unable to verify flash chip connection ({}).'.format(e)) # Check if XMC SPI flash chip booted-up successfully, fix if not - flash_xmc_startup() + if not esp.secure_download_mode: + try: + flash_xmc_startup() + except Exception as e: + esp.trace('Unable to perform XMC flash chip startup sequence ({}).'.format(e)) if hasattr(args, "flash_size"): print("Configuring flash size...") diff --git a/tools/platformio-build-esp32.py b/tools/platformio-build-esp32.py index 1a63d35f755..d3b90aa608d 100644 --- a/tools/platformio-build-esp32.py +++ b/tools/platformio-build-esp32.py @@ -112,7 +112,7 @@ "-u", "newlib_include_pthread_impl", "-u", "newlib_include_assert_impl", "-u", "__cxa_guard_dummy", - '-Wl,-Map="%s"' % join("$BUILD_DIR", basename(env.subst("${PROJECT_DIR}.map"))) + '-Wl,-Map="%s"' % join("${BUILD_DIR}", "${PROGNAME}.map") ], CPPPATH=[ diff --git a/tools/platformio-build-esp32c3.py b/tools/platformio-build-esp32c3.py index 590b173dfb0..76f1f55575f 100644 --- a/tools/platformio-build-esp32c3.py +++ b/tools/platformio-build-esp32c3.py @@ -111,7 +111,7 @@ "-u", "newlib_include_pthread_impl", "-u", "newlib_include_assert_impl", "-u", "__cxa_guard_dummy", - '-Wl,-Map="%s"' % join("$BUILD_DIR", basename(env.subst("${PROJECT_DIR}.map"))) + '-Wl,-Map="%s"' % join("${BUILD_DIR}", "${PROGNAME}.map") ], CPPPATH=[ diff --git a/tools/platformio-build-esp32s2.py b/tools/platformio-build-esp32s2.py index b55dcf4af2f..e4925249b75 100644 --- a/tools/platformio-build-esp32s2.py +++ b/tools/platformio-build-esp32s2.py @@ -108,7 +108,7 @@ "-u", "newlib_include_pthread_impl", "-u", "newlib_include_assert_impl", "-u", "__cxa_guard_dummy", - '-Wl,-Map="%s"' % join("$BUILD_DIR", basename(env.subst("${PROJECT_DIR}.map"))) + '-Wl,-Map="%s"' % join("${BUILD_DIR}", "${PROGNAME}.map") ], CPPPATH=[ diff --git a/tools/platformio-build-esp32s3.py b/tools/platformio-build-esp32s3.py index 5d0c598b7f3..30e13591fbb 100644 --- a/tools/platformio-build-esp32s3.py +++ b/tools/platformio-build-esp32s3.py @@ -108,7 +108,7 @@ "-u", "newlib_include_pthread_impl", "-u", "newlib_include_assert_impl", "-u", "__cxa_guard_dummy", - '-Wl,-Map="%s"' % join("$BUILD_DIR", basename(env.subst("${PROJECT_DIR}.map"))) + '-Wl,-Map="%s"' % join("${BUILD_DIR}", "${PROGNAME}.map") ], CPPPATH=[ diff --git a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_hf_client_api.h b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_hf_client_api.h index 3c5c05b178c..55569bc5c84 100644 --- a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_hf_client_api.h +++ b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_hf_client_api.h @@ -60,6 +60,9 @@ typedef enum { #define ESP_HF_CLIENT_PEER_FEAT_ECC 0x80 /* Enhanced Call Control */ #define ESP_HF_CLIENT_PEER_FEAT_EXTERR 0x100 /* Extended error codes */ #define ESP_HF_CLIENT_PEER_FEAT_CODEC 0x200 /* Codec Negotiation */ +/* HFP 1.7+ */ +#define ESP_HF_CLIENT_PEER_FEAT_HF_IND 0x400 /* HF Indicators */ +#define ESP_HF_CLIENT_PEER_FEAT_ESCO_S4 0x800 /* eSCO S4 Setting Supported */ /* CHLD feature masks of AG */ #define ESP_HF_CLIENT_CHLD_FEAT_REL 0x01 /* 0 Release waiting call or held calls */ diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_console.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_console.h deleted file mode 100644 index 70c02ffeae0..00000000000 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_console.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Initialize console - * - * Initializes serial console and adds basic commands. - * - * @return ESP_OK on success. - * @return error in case of failures. - */ -esp_err_t esp_rmaker_console_init(void); - -/* Reference for adding custom console commands: -#include - -static int command_console_handler(int argc, char *argv[]) -{ - // Command code here -} - -static void register_console_command() -{ - const esp_console_cmd_t cmd = { - .command = "", - .help = "", - .func = &command_console_handler, - }; - ESP_ERROR_CHECK(esp_console_cmd_register(&cmd)); -} -*/ - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_core.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_core.h deleted file mode 100644 index 6ddb0fbe912..00000000000 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_core.h +++ /dev/null @@ -1,891 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#pragma once -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define ESP_RMAKER_CONFIG_VERSION "2020-03-20" - -/* Maximum length of the alert message that can be passed to esp_rmaker_raise_alert() */ -#define ESP_RMAKER_MAX_ALERT_LEN 100 - -/** @cond **/ -/** ESP RainMaker Event Base */ -ESP_EVENT_DECLARE_BASE(RMAKER_EVENT); -/** @endcond **/ - -/** ESP RainMaker Events */ -typedef enum { - /** RainMaker Core Initialisation Done */ - RMAKER_EVENT_INIT_DONE = 1, - /** Self Claiming Started */ - RMAKER_EVENT_CLAIM_STARTED, - /** Self Claiming was Successful */ - RMAKER_EVENT_CLAIM_SUCCESSFUL, - /** Self Claiming Failed */ - RMAKER_EVENT_CLAIM_FAILED, - /** Node side communication for User-Node mapping done. - * Actual mapping state will be managed by the ESP RainMaker cloud based on the user side communication. - * Associated data is the NULL terminated user id. - */ - RMAKER_EVENT_USER_NODE_MAPPING_DONE, - /** Local control started. Associated data is the NULL terminated Service Name */ - RMAKER_EVENT_LOCAL_CTRL_STARTED, -} esp_rmaker_event_t; - -/** ESP RainMaker Node information */ -typedef struct { - /** Name of the Node */ - char *name; - /** Type of the Node */ - char *type; - /** Firmware Version (Optional). If not set, PROJECT_VER is used as default (recommended)*/ - char *fw_version; - /** Model (Optional). If not set, PROJECT_NAME is used as default (recommended)*/ - char *model; -} esp_rmaker_node_info_t; - -/** ESP RainMaker Configuration */ -typedef struct { - /** Enable Time Sync - * Setting this true will enable SNTP and fetch the current time before - * attempting to connect to the ESP RainMaker service - */ - bool enable_time_sync; -} esp_rmaker_config_t; - -/** ESP RainMaker Parameter Value type */ -typedef enum { - /** Invalid */ - RMAKER_VAL_TYPE_INVALID = 0, - /** Boolean */ - RMAKER_VAL_TYPE_BOOLEAN, - /** Integer. Mapped to a 32 bit signed integer */ - RMAKER_VAL_TYPE_INTEGER, - /** Floating point number */ - RMAKER_VAL_TYPE_FLOAT, - /** NULL terminated string */ - RMAKER_VAL_TYPE_STRING, - /** NULL terminated JSON Object string Eg. {"name":"value"} */ - RMAKER_VAL_TYPE_OBJECT, - /** NULL terminated JSON Array string Eg. [1,2,3] */ - RMAKER_VAL_TYPE_ARRAY, -} esp_rmaker_val_type_t; - -/** ESP RainMaker Value */ -typedef union { - /** Boolean */ - bool b; - /** Integer */ - int i; - /** Float */ - float f; - /** NULL terminated string */ - char *s; -} esp_rmaker_val_t; - -/** ESP RainMaker Parameter Value */ -typedef struct { - /** Type of Value */ - esp_rmaker_val_type_t type; - /** Actual value. Depends on the type */ - esp_rmaker_val_t val; -} esp_rmaker_param_val_t; - -/** Param property flags */ -typedef enum { - PROP_FLAG_WRITE = (1 << 0), - PROP_FLAG_READ = (1 << 1), - PROP_FLAG_TIME_SERIES = (1 << 2), - PROP_FLAG_PERSIST = (1 << 3) -} esp_param_property_flags_t; - -/** System Service Reboot Flag */ -#define SYSTEM_SERV_FLAG_REBOOT (1 << 0) - -/** System Service Factory Reset Flag */ -#define SYSTEM_SERV_FLAG_FACTORY_RESET (1 << 1) - -/** System Service Wi-Fi Reset Flag */ -#define SYSTEM_SERV_FLAG_WIFI_RESET (1 << 2) - -/** System Service All Flags */ -#define SYSTEM_SERV_FLAGS_ALL (SYSTEM_SERV_FLAG_REBOOT | SYSTEM_SERV_FLAG_FACTORY_RESET | SYSTEM_SERV_FLAG_WIFI_RESET) - -/** Generic ESP RainMaker handle */ -typedef size_t esp_rmaker_handle_t; - -/** ESP RainMaker Node Handle */ -typedef esp_rmaker_handle_t esp_rmaker_node_t; - -/** ESP RainMaker Device Handle */ -typedef esp_rmaker_handle_t esp_rmaker_device_t; - -/** ESP RainMaker Parameter Handle */ -typedef esp_rmaker_handle_t esp_rmaker_param_t; - -/** Parameter read/write request source */ -typedef enum { - /** Request triggered in the init sequence i.e. when a value is found - * in persistent memory for parameters with PROP_FLAG_PERSIST. - */ - ESP_RMAKER_REQ_SRC_INIT, - /** Request received from cloud */ - ESP_RMAKER_REQ_SRC_CLOUD, - /** Request received when a schedule has triggered */ - ESP_RMAKER_REQ_SRC_SCHEDULE, - /** Request received from a local controller */ - ESP_RMAKER_REQ_SRC_LOCAL, - /** This will always be the last value. Any value equal to or - * greater than this should be considered invalid. - */ - ESP_RMAKER_REQ_SRC_MAX, -} esp_rmaker_req_src_t; - -/** Write request Context */ -typedef struct { - /** Source of request */ - esp_rmaker_req_src_t src; -} esp_rmaker_write_ctx_t; - -/** Read request context */ -typedef struct { - /** Source of request */ - esp_rmaker_req_src_t src; -} esp_rmaker_read_ctx_t; - -/** System service configuration */ -typedef struct { - /** Logical OR of system service flags (SYSTEM_SERV_FLAG_REBOOT, - * SYSTEM_SERV_FLAG_FACTORY_RESET, SYSTEM_SERV_FLAG_WIFI_RESET) as required - * or SYSTEM_SERV_FLAGS_ALL. - */ - uint16_t flags; - /** Time in seconds after which the device should reboot. - * Value of zero would trigger an immediate reboot if a write is received for - * the Reboot parameter. - * Recommended value: 2 - */ - int8_t reboot_seconds; - /** Time in seconds after which the device should reset (Wi-Fi or factory). - * Value of zero would trigger an immediate action if a write is received for - * the Wi-Fi reset or Factory reset parameter. - * Recommended value: 2 - */ - int8_t reset_seconds; - /** Time in seconds after which the device should reboot after it has been reset. - * Value of zero would mean that there won't be any reboot after the reset. - * Recommended value: 2 - */ - int8_t reset_reboot_seconds; -} esp_rmaker_system_serv_config_t; - -/** Callback for parameter value write requests. - * - * The callback should call the esp_rmaker_param_update_and_report() API if the new value is to be set - * and reported back. - * - * @param[in] device Device handle. - * @param[in] param Parameter handle. - * @param[in] param Pointer to \ref esp_rmaker_param_val_t. Use appropriate elements as per the value type. - * @param[in] priv_data Pointer to the private data paassed while creating the device. - * @param[in] ctx Context associated with the request. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -typedef esp_err_t (*esp_rmaker_device_write_cb_t)(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param, - const esp_rmaker_param_val_t val, void *priv_data, esp_rmaker_write_ctx_t *ctx); - -/** Callback for parameter value changes - * - * The callback should call the esp_rmaker_param_update_and_report() API if the new value is to be set - * and reported back. - * - * @note Currently, the read callback never gets invoked as the communication between clients (mobile phones, CLI, etc.) - * and node is asynchronous. So, the read request does not reach the node. This callback will however be used in future. - * - * @param[in] device Device handle. - * @param[in] param Parameter handle. - * @param[in] priv_data Pointer to the private data passed while creating the device. - * @param[in] ctx Context associated with the request. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -typedef esp_err_t (*esp_rmaker_device_read_cb_t)(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param, - void *priv_data, esp_rmaker_read_ctx_t *ctx); - -/** Convert device callback source to string - * - * Device read/write callback can be via different sources. This is a helper API - * to give the source in string format for printing. - * - * Example Usage: - * @code{c} - * static esp_err_t write_cb(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param, - * const esp_rmaker_param_val_t val, void *priv_data, esp_rmaker_write_ctx_t *ctx) -{ - if (ctx) { - ESP_LOGI(TAG, "Received write request via : %s", esp_rmaker_device_cb_src_to_str(ctx->src)); - } - * @endcode - * - * @param[in] src The src field as received in the callback context. - * - * @return NULL terminated source string on success - * @return NULL on failure - */ -const char *esp_rmaker_device_cb_src_to_str(esp_rmaker_req_src_t src); - -/** - * Initialise a Boolean value - * - * @param[in] bval Initialising value. - * - * @return Value structure. - */ -esp_rmaker_param_val_t esp_rmaker_bool(bool bval); - -/** - * Initialise an Integer value - * - * @param[in] ival Initialising value. - * - * @return Value structure. - */ -esp_rmaker_param_val_t esp_rmaker_int(int ival); - -/** - * Initialise a Float value - * - * @param[in] fval Initialising value. - * - * @return Value structure. - */ -esp_rmaker_param_val_t esp_rmaker_float(float fval); - -/** - * Initialise a String value - * - * @param[in] sval Initialising value. - * - * @return Value structure. - */ -esp_rmaker_param_val_t esp_rmaker_str(const char *sval); - -/** - * Initialise a json object value - * - * @note the object will not be validated internally. it is the application's - * responsibility to ensure that the object is a valid json object. - * eg. esp_rmaker_obj("{\"name\":\"value\"}"); - * - * param[in] val initialising value - * - * return value structure - */ -esp_rmaker_param_val_t esp_rmaker_obj(const char *val); - -/** - * Initialise a json array value - * - * @note the array will not be validated internally. it is the application's - * responsibility to ensure that the array is a valid json array. - * eg. esp_rmaker_array("[1,2,3]"); - * - * param[in] val initialising value - * - * return value structure - */ -esp_rmaker_param_val_t esp_rmaker_array(const char *val); - - -/** Initialize ESP RainMaker Node - * - * This initializes the ESP RainMaker agent and creates the node. - * The model and firmware version for the node are set internally as per - * the project name and version. These can be overridden (but not recommended) using the - * esp_rmaker_node_add_fw_version() and esp_rmaker_node_add_model() APIs. - * - * @note This should be the first call before using any other ESP RainMaker API. - * - * @param[in] config Configuration to be used by the ESP RainMaker. - * @param[in] name Name of the node. - * @param[in] type Type of the node. - * - * @return Node handle on success. - * @return NULL in case of failure. - */ -esp_rmaker_node_t *esp_rmaker_node_init(const esp_rmaker_config_t *config, const char *name, const char *type); - -/** Start ESP RainMaker Agent - * - * This call starts the actual ESP RainMaker thread. This should preferably be called after a - * successful Wi-Fi connection in order to avoid unnecessary failures. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_start(void); - -/** Stop ESP RainMaker Agent - * - * This call stops the ESP RainMaker Agent instance started earlier by esp_rmaker_start(). - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_stop(void); - -/** Deinitialize ESP RainMaker Node - * - * This API deinitializes the ESP RainMaker agent and the node created using esp_rmaker_node_init(). - * - * @note This should be called after rainmaker has stopped. - * - * @param[in] node Node Handle returned by esp_rmaker_node_init(). - * - * @retur ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_node_deinit(const esp_rmaker_node_t *node); - -/** Get a handle to the Node - * - * This API returns handle to a node created using esp_rmaker_node_init(). - * - * @return Node handle on success. - * @return NULL in case of failure. - */ -const esp_rmaker_node_t *esp_rmaker_get_node(void); - -/** Get Node Id - * - * Returns pointer to the NULL terminated Node ID string. - * - * @return Pointer to a NULL terminated Node ID string. - */ -char *esp_rmaker_get_node_id(void); - -/** Get Node Info - * - * Returns pointer to the node info as configured during initialisation. - * - * @param node Node handle. - * - * @return Pointer to the node info on success. - * @return NULL in case of failure. - */ -esp_rmaker_node_info_t *esp_rmaker_node_get_info(const esp_rmaker_node_t *node); - -/** Add Node attribute - * - * Adds a new attribute as the metadata for the node. For the sake of simplicity, - * only string values are allowed. - * - * @param node Node handle. - * @param[in] attr_name Name of the attribute. - * @param[in] val Value for the attribute. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_node_add_attribute(const esp_rmaker_node_t *node, const char *attr_name, const char *val); - -/** Add FW version for a node (Not recommended) - * - * FW version is set internally to the project version. This API can be used to - * override that version. - * - * @param node Node handle. - * @param[in] fw_version New firmware version. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_node_add_fw_version(const esp_rmaker_node_t *node, const char *fw_version); - -/** Add model for a node (Not recommended) - * - * Model is set internally to the project name. This API can be used to - * override that name. - * - * @param node Node handle. - * @param[in] model New model string. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_node_add_model(const esp_rmaker_node_t *node, const char *model); - -/** - * Create a Device - * - * This API will create a virtual "Device". - * This could be something like a Switch, Lightbulb, etc. - * - * @note The device created needs to be added to a node using esp_rmaker_node_add_device(). - * - * @param[in] dev_name The unique device name. - * @param[in] type Optional device type. Can be kept NULL. - * @param[in] priv_data (Optional) Private data associated with the device. This will be passed to callbacks. - * It should stay allocated throughout the lifetime of the device. - * - * @return Device handle on success. - * @return NULL in case of any error. - */ -esp_rmaker_device_t *esp_rmaker_device_create(const char *dev_name, const char *type, void *priv_data); - -/** - * Create a Service - * - * This API will create a "Service". It is exactly same like a device in terms of structure and so, all - * APIs for device are also valid for a service. - * A service could be something like OTA, diagnostics, etc. - * - * @note Name of a service should not clash with name of a device. - * @note The service created needs to be added to a node using esp_rmaker_node_add_device(). - * - * @param[in] serv_name The unique service name. - * @param[in] type Optional service type. Can be kept NULL. - * @param[in] priv_data (Optional) Private data associated with the service. This will be passed to callbacks. - * It should stay allocated throughout the lifetime of the device. - * - * @return Device handle on success. - * @return NULL in case of any error. - */ -esp_rmaker_device_t *esp_rmaker_service_create(const char *serv_name, const char *type, void *priv_data); - -/** - * Delete a Device/Service - * - * This API will delete a device created using esp_rmaker_device_create(). - * - * @note The device should first be removed from the node using esp_rmaker_node_remove_device() before deleting. - * - * @param[in] device Device handle. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_device_delete(const esp_rmaker_device_t *device); - -/** - * Add callbacks for a device/service - * - * Add read/write callbacks for a device that will be invoked as per requests received from the cloud (or other paths - * as may be added in future). - * - * @param[in] device Device handle. - * @param[in] write_cb Write callback. - * @param[in] read_cb Read callback. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_device_add_cb(const esp_rmaker_device_t *device, esp_rmaker_device_write_cb_t write_cb, esp_rmaker_device_read_cb_t read_cb); - -/** - * Add a device to a node - * - * @param[in] node Node handle. - * @param[in] device Device handle. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_node_add_device(const esp_rmaker_node_t *node, const esp_rmaker_device_t *device); - -/** - * Remove a device from a node - * - * @param[in] node Node handle. - * @param[in] device Device handle. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_node_remove_device(const esp_rmaker_node_t *node, const esp_rmaker_device_t *device); - -/** Get device by name - * - * Get handle for a device based on the name. - * - * @param[in] node Node handle. - * @param[in] device_name Device name to search. - * - * @return Device handle on success. - * @return NULL in case of failure. - */ -esp_rmaker_device_t *esp_rmaker_node_get_device_by_name(const esp_rmaker_node_t *node, const char *device_name); - -/** Add a Device attribute - * - * @note Device attributes are reported only once after a boot-up as part of the node - * configuration. - * Eg. Serial Number - * - * @param[in] device Device handle. - * @param[in] attr_name Name of the attribute. - * @param[in] val Value of the attribute. - * - * @return ESP_OK if the attribute was added successfully. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_device_add_attribute(const esp_rmaker_device_t *device, const char *attr_name, const char *val); - -/** Add a Device subtype - * - * This can be something like esp.subtype.rgb-light for a device of type esp.device.lightbulb. - * This would primarily be used by the phone apps to render different icons for the same device type. - * - * @param[in] device Device handle. - * @param[in] subtype String describing the sub type. - * - * @return ESP_OK if the subtype was added successfully. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_device_add_subtype(const esp_rmaker_device_t *device, const char *subtype); - -/** Get device name from handle - * - * @param[in] device Device handle. - * - * @return NULL terminated device name string on success. - * @return NULL in case of failure. - */ -char *esp_rmaker_device_get_name(const esp_rmaker_device_t *device); - -/** Get device type from handle - * - * @param[in] device Device handle. - * - * @return NULL terminated device type string on success. - * @return NULL in case of failure, or if the type wasn't provided while creating the device. - */ -char *esp_rmaker_device_get_type(const esp_rmaker_device_t *device); - -/** - * Add a parameter to a device/service - * - * @param[in] device Device handle. - * @param[in] param Parameter handle. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_device_add_param(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param); - - -/** Get parameter by type - * - * Get handle for a parameter based on the type. - * - * @note If there are multiple parameters with the same type, this will return the first one. The API - * esp_rmaker_device_get_param_by_name() can be used to get a specific parameter, because the parameter - * names in a device are unique. - * - * @param[in] device Device handle. - * @param[in] param_type Parameter type to search. - * - * @return Parameter handle on success. - * @return NULL in case of failure. - */ -esp_rmaker_param_t *esp_rmaker_device_get_param_by_type(const esp_rmaker_device_t *device, const char *param_type); - -/** Get parameter by name - * - * Get handle for a parameter based on the name. - * - * @param[in] device Device handle. - * @param[in] param_name Parameter name to search. - * - * @return Parameter handle on success. - * @return NULL in case of failure. - */ -esp_rmaker_param_t *esp_rmaker_device_get_param_by_name(const esp_rmaker_device_t *device, const char *param_name); - -/** Assign a primary parameter - * - * Assign a parameter (already added using esp_rmaker_device_add_param()) as a primary parameter, - * which can be used by clients (phone apps specifically) to give prominence to it. - * - * @param[in] device Device handle. - * @param[in] param Parameter handle. - * - * @return ESP_OK if the parameter was assigned as the primary successfully. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_device_assign_primary_param(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param); - -/** - * Create a Parameter - * - * Parameter can be something like Temperature, Outlet state, Lightbulb brightness, etc. - * - * Any changes should be reported using the esp_rmaker_param_update_and_report() API. - * Any remote changes will be reported to the application via the device callback, if registered. - * - * @note The parameter created needs to be added to a device using esp_rmaker_device_add_param(). - * Parameter name should be unique in a given device. - * - * @param[in] param_name Name of the parameter. - a* @param[in] type Optional parameter type. Can be kept NULL. - * @param[in] val Value of the parameter. This also specifies the type that will be assigned - * to this parameter. You can use esp_rmaker_bool(), esp_rmaker_int(), esp_rmaker_float() - * or esp_rmaker_str() functions as the argument here. Eg, esp_rmaker_bool(true). - * @param[in] properties Properties of the parameter, which will be a logical OR of flags in - * \ref esp_param_property_flags_t. - * - * @return Parameter handle on success. - * @return NULL in case of failure. - */ -esp_rmaker_param_t *esp_rmaker_param_create(const char *param_name, const char *type, - esp_rmaker_param_val_t val, uint8_t properties); - -/** - * Add a UI Type to a parameter - * - * This will be used by the Phone apps (or other clients) to render appropriate UI for the given - * parameter. Please refer the RainMaker documetation for supported UI Types. - * - * @param[in] param Parameter handle. - * @param[in] ui_type String describing the UI Type. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_param_add_ui_type(const esp_rmaker_param_t *param, const char *ui_type); - -/** - * Add bounds for an integer/float parameter - * - * This can be used to add bounds (min/max values) for a given integer parameter. Eg. brightness - * will have bounds as 0 and 100 if it is a percentage. - * Eg. esp_rmaker_param_add_bounds(brightness_param, esp_rmaker_int(0), esp_rmaker_int(100), esp_rmaker_int(5)); - * - * @note The RainMaker core does not check the bounds. It is upto the application to handle it. - * - * @param[in] param Parameter handle. - * @param[in] min Minimum allowed value. - * @param[in] max Maximum allowed value. - * @param[in] step Minimum stepping (set to 0 if no specific value is desired). - * - * @return ESP_OK on success. - * return error in case of failure. - */ -esp_err_t esp_rmaker_param_add_bounds(const esp_rmaker_param_t *param, - esp_rmaker_param_val_t min, esp_rmaker_param_val_t max, esp_rmaker_param_val_t step); - -/** - * Add a list of valid strings for a string parameter - * - * This can be used to add a list of valid strings for a given string parameter. - * - * Eg. - * static const char *valid_strs[] = {"None","Yes","No","Can't Say"}; - * esp_rmaker_param_add_valid_str_list(param, valid_strs, 4); - * - * @note The RainMaker core does not check the values. It is upto the application to handle it. - * - * @param[in] param Parameter handle. - * @param[in] strs Pointer to an array of strings. Note that this memory should stay allocated - * throughout the lifetime of this parameter. - * @param[in] count Number of strings in the above array. - * - * @return ESP_OK on success. - * return error in case of failure. - */ -esp_err_t esp_rmaker_param_add_valid_str_list(const esp_rmaker_param_t *param, const char *strs[], uint8_t count); - -/** Add max count for an array parameter - * - * This can be used to put a limit on the maximum number of elements in an array. - * - * @note The RainMaker core does not check the values. It is upto the application to handle it. - * - * @param[in] param Parameter handle. - * @param[in] count Max number of elements allowed in the array. - * - * @return ESP_OK on success. - * return error in case of failure. - */ -esp_err_t esp_rmaker_param_add_array_max_count(const esp_rmaker_param_t *param, int count); - - -/* Update a parameter - * - * This will just update the value of a parameter with esp rainmaker core, without actually reporting - * it. This can be used when multiple parameters need to be reported together. - * Eg. If x parameters are to be reported, this API can be used for the first x -1 parameters - * and the last one can be updated using esp_rmaker_param_update_and_report(). - * This will report all parameters which were updated prior to this call. - * - * Sample: - * - * esp_rmaker_param_update(param1, esp_rmaker_float(10.2)); - * esp_rmaker_param_update(param2, esp_rmaker_int(55)); - * esp_rmaker_param_update(param3, esp_rmaker_int(95)); - * esp_rmaker_param_update_and_report(param1, esp_rmaker_bool(true)); - * - * @param[in] param Parameter handle. - * @param[in] val New value of the parameter. - * - * @return ESP_OK if the parameter was updated successfully. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_param_update(const esp_rmaker_param_t *param, esp_rmaker_param_val_t val); - -/** Update and report a parameter - * - * Calling this API will update the parameter and report it to ESP RainMaker cloud. - * This should be used whenever there is any local change. - * - * @param[in] param Parameter handle. - * @param[in] val New value of the parameter. - * - * @return ESP_OK if the parameter was updated successfully. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_param_update_and_report(const esp_rmaker_param_t *param, esp_rmaker_param_val_t val); - -/** Update and notify a parameter - * - * Calling this API will update the parameter and report it to ESP RainMaker cloud similar to - * esp_rmaker_param_update_and_report(). However, additionally, it will also trigger a notification - * on the phone apps (if enabled). - * - * @note This should be used only when some local change requires explicit notification even when the - * phone app is in background, not otherwise. - * Eg. Alarm got triggered, temperature exceeded some threshold, etc. - * - * Alternatively, the esp_rmaker_raise_alert() API can also be used to trigger notification - * on the phone apps with pre-formatted text. - * - * @param[in] param Parameter handle. - * @param[in] val New value of the parameter. - * - * @return ESP_OK if the parameter was updated successfully. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_param_update_and_notify(const esp_rmaker_param_t *param, esp_rmaker_param_val_t val); - -/** Trigger an alert on the phone app - * - * This API will trigger a notification alert on the phone apps (if enabled) using the formatted text - * provided. Note that this does not send a notification directly to the phone, but reports the alert - * to the ESP RainMaker cloud which then uses the Notification framework to send notifications to the - * phone apps. The value does not get stored anywhere, nor is it linked to any node parameters. - * - * @note This should be used only if some event requires explicitly alerting the user even when the - * phone app is in background, not otherwise. - * Eg. "Motion Detected", "Fire alarm triggered" - * - * @param[in] alert_str NULL terminated pre-formatted alert string. - * Maximum length can be ESP_RMAKER_MAX_ALERT_LEN, excluding NULL character. - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_raise_alert(const char *alert_str); - -/** Get parameter name from handle - * - * @param[in] param Parameter handle. - * - * @return NULL terminated parameter name string on success. - * @return NULL in case of failure. - */ -char *esp_rmaker_param_get_name(const esp_rmaker_param_t *param); - -/** Get parameter type from handle - * - * @param[in] param Parameter handle. - * - * @return NULL terminated parameter type string on success. - * @return NULL in case of failure, or if the type wasn't provided while creating the parameter. - */ -char *esp_rmaker_param_get_type(const esp_rmaker_param_t *param); - -/** Get parameter value - * - * This gives the parameter value that is stored in the RainMaker core. - * - * @note This does not call any explicit functions to read value from hardware/driver. - * - * @param[in] param Parameter handle - * - * @return Pointer to parameter value on success. - * @return NULL in case of failure. - */ -esp_rmaker_param_val_t *esp_rmaker_param_get_val(esp_rmaker_param_t *param); - -/** Report the node details to the cloud - * - * This API reports node details i.e. the node configuration and values of all the parameters to the ESP RainMaker cloud. - * Eg. If a new device is created (with some parameters and attributes), then this API should be called after that - * to send the node details to the cloud again and the changes to be reflected in the clients (like phone apps). - * - * @note Please use this API only if you need to create or delete devices after esp_rmaker_start() has already - * been called, for use cases like bridges or hubs. - * - * @return ESP_OK if the node details are successfully queued to be published. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_report_node_details(void); - -/** Enable Timezone Service - * - * This enables the ESP RainMaker standard timezone service which can be used to set - * timezone, either in POSIX or location string format. Please refer the specifications - * for additional details. - * - * @return ESP_OK on success - * @return error on failure - */ -esp_err_t esp_rmaker_timezone_service_enable(void); - -/** Enable System Service - * - * This enables the ESP RainMaker standard system service which can be - * used for operations like reboot, factory reset and Wi-Fi reset. - * - * Please refer the specifications for additional details. - * - * @param[in] config Configuration for the system service. - * - * @return ESP_OK on success - * @return error on failure - */ -esp_err_t esp_rmaker_system_service_enable(esp_rmaker_system_serv_config_t *config); - -/** - * Check if local_ctrl service has started - * - * @return true if service has started - * @return false if the service has not started - */ -bool esp_rmaker_local_ctrl_service_started(void); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_mqtt.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_mqtt.h deleted file mode 100644 index 1cc6cd5156e..00000000000 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_mqtt.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#pragma once -#include -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -esp_rmaker_mqtt_conn_params_t *esp_rmaker_mqtt_get_conn_params(void); - -/** Initialize ESP RainMaker MQTT - * - * @param[in] config The MQTT configuration data - * - * @return ESP_OK on success. - * @return error in case of any error. - */ -esp_err_t esp_rmaker_mqtt_init(esp_rmaker_mqtt_conn_params_t *conn_params); - -/** MQTT Connect - * - * Starts the connection attempts to the MQTT broker as per the configuration - * provided during initializing. - * This should ideally be called after successful network connection. - * - * @return ESP_OK on success. - * @return error in case of any error. - */ -esp_err_t esp_rmaker_mqtt_connect(void); - -/** MQTT Disconnect - * - * Disconnects from the MQTT broker. - * - * @return ESP_OK on success. - * @return error in case of any error. - */ -esp_err_t esp_rmaker_mqtt_disconnect(void); - -/** Publish MQTT Message - * - * @param[in] topic The MQTT topic on which the message should be published. - * @param[in] data Data to be published - * @param[in] data_len Length of the data - * @param[in] qos Quality of Service for the Publish. Can be 0, 1 or 2. Also depends on what the MQTT broker supports. - * - * @return ESP_OK on success. - * @return error in case of any error. - */ -esp_err_t esp_rmaker_mqtt_publish(const char *topic, void *data, size_t data_len, uint8_t qos, int *msg_id); - -/** Subscribe to MQTT topic - * - * @param[in] topic The topic to be subscribed to. - * @param[in] cb The callback to be invoked when a message is received on the given topic. - * @param[in] priv_data Optional private data to be passed to the callback - * @param[in] qos Quality of Service for the Subscription. Can be 0, 1 or 2. Also depends on what the MQTT broker supports. - * - * @return ESP_OK on success. - * @return error in case of any error. - */ -esp_err_t esp_rmaker_mqtt_subscribe(const char *topic, esp_rmaker_mqtt_subscribe_cb_t cb, uint8_t qos, void *priv_data); - -/** Unsubscribe from MQTT topic - * - * @param[in] topic Topic from which to unsubscribe. - * - * @return ESP_OK on success. - * @return error in case of any error. - */ -esp_err_t esp_rmaker_mqtt_unsubscribe(const char *topic); -esp_err_t esp_rmaker_mqtt_setup(esp_rmaker_mqtt_config_t mqtt_config); -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_ota.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_ota.h deleted file mode 100644 index e66b95705bc..00000000000 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_ota.h +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#pragma once -#include -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Default ESP RainMaker OTA Server Certificate */ -extern const char *ESP_RMAKER_OTA_DEFAULT_SERVER_CERT; - -/** OTA Status to be reported to ESP RainMaker Cloud */ -typedef enum { - /** OTA is in Progress. This can be reported multiple times as the OTA progresses. */ - OTA_STATUS_IN_PROGRESS = 1, - /** OTA Succeeded. This should be reported only once, at the end of OTA. */ - OTA_STATUS_SUCCESS, - /** OTA Failed. This should be reported only once, at the end of OTA. */ - OTA_STATUS_FAILED, - /** OTA was delayed by the application */ - OTA_STATUS_DELAYED, -} ota_status_t; - -/** OTA Workflow type */ -typedef enum { - /** OTA will be performed using services and parameters. */ - OTA_USING_PARAMS = 1, - /** OTA will be performed using pre-defined MQTT topics. */ - OTA_USING_TOPICS -} esp_rmaker_ota_type_t; - -/** The OTA Handle to be used by the OTA callback */ -typedef void *esp_rmaker_ota_handle_t; - -/** OTA Data */ -typedef struct { - /** The OTA URL received from ESP RainMaker Cloud */ - char *url; - /** Size of the OTA File. Can be 0 if the file size isn't received from - * the ESP RainMaker Cloud */ - int filesize; - /** The server certificate passed in esp_rmaker_enable_ota() */ - const char *server_cert; - /** The private data passed in esp_rmaker_enable_ota() */ - char *priv; -} esp_rmaker_ota_data_t; - -/** Function prototype for OTA Callback - * - * This function will be invoked by the ESP RainMaker core whenever an OTA is available. - * The esp_rmaker_report_ota_status() API should be used to indicate the progress and - * success/fail status. - * - * @param[in] handle An OTA handle assigned by the ESP RainMaker Core - * @param[in] ota_data The data to be used for the OTA - * - * @return ESP_OK if the OTA was successful - * @return ESP_FAIL if the OTA failed. - */ -typedef esp_err_t (*esp_rmaker_ota_cb_t) (esp_rmaker_ota_handle_t handle, - esp_rmaker_ota_data_t *ota_data); - -/** Function Prototype for Post OTA Diagnostics - * - * If the Application rollback feature is enabled, this callback will be invoked - * as soon as you call esp_rmaker_ota_enable(), if it is the first - * boot after an OTA. You may perform some application specific diagnostics and - * report the status which will decide whether to roll back or not. - * - * @return true if diagnostics are successful, meaning that the new firmware is fine. - * @return false if diagnostics fail and a roolback to previous firmware is required. - */ -typedef bool (*esp_rmaker_post_ota_diag_t)(void); - -/** ESP RainMaker OTA Configuration */ -typedef struct { - /** OTA Callback. - * The callback to be invoked when an OTA Job is available. - * If kept NULL, the internal default callback will be used (Recommended). - */ - esp_rmaker_ota_cb_t ota_cb; - /** OTA Diagnostics Callback. - * A post OTA diagnostic handler to be invoked if app rollback feature is enabled. - * If kept NULL, the new firmware will be assumed to be fine, - * and no rollback will be performed. - */ - esp_rmaker_post_ota_diag_t ota_diag; - /** Server Certificate. - * The certificate to be passed to the OTA callback for server authentication. - * This is mandatory, unless you have disabled it in ESP HTTPS OTA config option. - * If you are using the ESP RainMaker OTA Service, you can just set this to - * `ESP_RMAKER_OTA_DEFAULT_SERVER_CERT`. - */ - const char *server_cert; - /** Private Data. - * Optional private data to be passed to the OTA callback. - */ - void *priv; -} esp_rmaker_ota_config_t; - -/** Enable OTA - * - * Calling this API enables OTA as per the ESP RainMaker specification. - * Please check the various ESP RainMaker configuration options to - * use the different variants of OTA. Refer the documentation for - * additional details. - * - * @param[in] ota_config Pointer to an OTA configuration structure - * @param[in] type The OTA workflow type - * - * @return ESP_OK on success - * @return error on failure - */ -esp_err_t esp_rmaker_ota_enable(esp_rmaker_ota_config_t *ota_config, esp_rmaker_ota_type_t type); - -/** Report OTA Status - * - * This API must be called from the OTA Callback to indicate the status of the OTA. The OTA_STATUS_IN_PROGRESS - * can be reported multiple times with appropriate additional information. The final success/failure should - * be reported only once, at the end. - * - * This can be ignored if you are using the default internal OTA callback. - * - * @param[in] ota_handle The OTA handle received by the callback - * @param[in] status Status to be reported - * @param[in] additional_info NULL terminated string indicating additional information for the status - * - * @return ESP_OK on success - * @return error on failure - */ -esp_err_t esp_rmaker_ota_report_status(esp_rmaker_ota_handle_t ota_handle, ota_status_t status, char *additional_info); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_schedule.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_schedule.h deleted file mode 100644 index 383c0949188..00000000000 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_schedule.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Enable Schedules - * - * This API enables the scheduling service for the node. For more information, - * check [here](https://rainmaker.espressif.com/docs/scheduling.html) - * - * It is recommended to set the timezone while using schedules. Check [here](https://rainmaker.espressif.com/docs/time-service.html#time-zone) for more information on timezones - * - * @note This API should be called after esp_rmaker_node_init() but before esp_rmaker_start(). - * - * @return ESP_OK on success. - * @return error in case of failure. - */ -esp_err_t esp_rmaker_schedule_enable(void); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_devices.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_devices.h deleted file mode 100644 index db9480672ba..00000000000 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_devices.h +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Create a standard Switch device - * - * This creates a Switch device with the mandatory parameters and also assigns - * the primary parameter. The default parameter names will be used. - * Refer \ref esp_rmaker_standard_params.h for default names. - * - * @param[in] dev_name The unique device name - * @param[in] priv_data (Optional) Private data associated with the device. This should stay - * allocated throughout the lifetime of the device - * #@param[in] power Default value of the mandatory parameter "power" - * - * @return Device handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_device_t *esp_rmaker_switch_device_create(const char *dev_name, - void *priv_data, bool power); - -/** Create a standard Lightbulb device - * - * This creates a Lightbulb device with the mandatory parameters and also assigns - * the primary parameter. The default parameter names will be used. - * Refer \ref esp_rmaker_standard_params.h for default names. - * - * @param[in] dev_name The unique device name - * @param[in] priv_data (Optional) Private data associated with the device. This should stay - * allocated throughout the lifetime of the device - * @param[in] power Default value of the mandatory parameter "power" - * - * @return Device handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_device_t *esp_rmaker_lightbulb_device_create(const char *dev_name, - void *priv_data, bool power); - -/** Create a standard Fan device - * - * This creates a Fan device with the mandatory parameters and also assigns - * the primary parameter. The default parameter names will be used. - * Refer \ref esp_rmaker_standard_params.h for default names. - * - * @param[in] dev_name The unique device name - * @param[in] priv_data (Optional) Private data associated with the device. This should stay - * allocated throughout the lifetime of the device - * @param[in] power Default value of the mandatory parameter "power" - * - * @return Device handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_device_t *esp_rmaker_fan_device_create(const char *dev_name, - void *priv_data, bool power); - -/** Create a standard Temperature Sensor device - * - * This creates a Temperature Sensor device with the mandatory parameters and also assigns - * the primary parameter. The default parameter names will be used. - * Refer \ref esp_rmaker_standard_params.h for default names. - * - * @param[in] dev_name The unique device name - * @param[in] priv_data (Optional) Private data associated with the device. This should stay - * allocated throughout the lifetime of the device - * @param[in] temperature Default value of the mandatory parameter "temperature" - * - * @return Device handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_device_t *esp_rmaker_temp_sensor_device_create(const char *dev_name, - void *priv_data, float temperature); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_params.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_params.h deleted file mode 100644 index 6cde69a2935..00000000000 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_params.h +++ /dev/null @@ -1,335 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#pragma once -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Suggested default names for the parameters. - * These will also be used by default if you use any standard device helper APIs. - * - * @note These names are not mandatory. You can use the ESP RainMaker Core APIs - * to create your own parameters with custom names, if required. - */ - -#define ESP_RMAKER_DEF_NAME_PARAM "Name" -#define ESP_RMAKER_DEF_POWER_NAME "Power" -#define ESP_RMAKER_DEF_BRIGHTNESS_NAME "Brightness" -#define ESP_RMAKER_DEF_HUE_NAME "Hue" -#define ESP_RMAKER_DEF_SATURATION_NAME "Saturation" -#define ESP_RMAKER_DEF_INTENSITY_NAME "Intensity" -#define ESP_RMAKER_DEF_CCT_NAME "CCT" -#define ESP_RMAKER_DEF_DIRECTION_NAME "Direction" -#define ESP_RMAKER_DEF_SPEED_NAME "Speed" -#define ESP_RMAKER_DEF_TEMPERATURE_NAME "Temperature" -#define ESP_RMAKER_DEF_OTA_STATUS_NAME "Status" -#define ESP_RMAKER_DEF_OTA_INFO_NAME "Info" -#define ESP_RMAKER_DEF_OTA_URL_NAME "URL" -#define ESP_RMAKER_DEF_TIMEZONE_NAME "TZ" -#define ESP_RMAKER_DEF_TIMEZONE_POSIX_NAME "TZ-POSIX" -#define ESP_RMAKER_DEF_SCHEDULE_NAME "Schedules" -#define ESP_RMAKER_DEF_REBOOT_NAME "Reboot" -#define ESP_RMAKER_DEF_FACTORY_RESET_NAME "Factory-Reset" -#define ESP_RMAKER_DEF_WIFI_RESET_NAME "Wi-Fi-Reset" -#define ESP_RMAKER_DEF_LOCAL_CONTROL_POP "POP" -#define ESP_RMAKER_DEF_LOCAL_CONTROL_TYPE "Type" - -/** - * Create standard name param - * - * This will create the standard name parameter. - * This should be added to all devices for which you want a user customisable name. - * The value should be same as the device name. - * - * All standard device creation APIs will add this internally. - * No application registered callback will be called for this parameter, - * and changes will be managed internally. - * - * @param[in] param_name Name of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_name_param_create(const char *param_name, const char *val); - -/** - * Create standard Power param - * - * This will create the standard power parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_power_param_create(const char *param_name, bool val); - -/** - * Create standard Brightness param - * - * This will create the standard brightness parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_brightness_param_create(const char *param_name, int val); - -/** - * Create standard Hue param - * - * This will create the standard hue parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_hue_param_create(const char *param_name, int val); - -/** - * Create standard Saturation param - * - * This will create the standard saturation parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_saturation_param_create(const char *param_name, int val); - -/** - * Create standard Intensity param - * - * This will create the standard intensity parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_intensity_param_create(const char *param_name, int val); - -/** - * Create standard CCT param - * - * This will create the standard cct parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_cct_param_create(const char *param_name, int val); - -/** - * Create standard Direction param - * - * This will create the standard direction parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_direction_param_create(const char *param_name, int val); - -/** - * Create standard Speed param - * - * This will create the standard speed parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_speed_param_create(const char *param_name, int val); - -/** - * Create standard Temperature param - * - * This will create the standard temperature parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_temperature_param_create(const char *param_name, float val); - -/** - * Create standard OTA Status param - * - * This will create the standard ota status parameter. Default value - * is set internally. - * - * @param[in] param_name Name of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_ota_status_param_create(const char *param_name); - -/** - * Create standard OTA Info param - * - * This will create the standard ota info parameter. Default value - * is set internally. - * - * @param[in] param_name Name of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_ota_info_param_create(const char *param_name); - -/** - * Create standard OTA URL param - * - * This will create the standard ota url parameter. Default value - * is set internally. - * - * @param[in] param_name Name of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_ota_url_param_create(const char *param_name); - -/** - * Create standard Timezone param - * - * This will create the standard timezone parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter (Eg. "Asia/Shanghai"). Can be kept NULL. - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_timezone_param_create(const char *param_name, const char *val); - -/** - * Create standard POSIX Timezone param - * - * This will create the standard posix timezone parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter (Eg. "CST-8"). Can be kept NULL. - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_timezone_posix_param_create(const char *param_name, const char *val); - -/** - * Create standard Schedules param - * - * This will create the standard schedules parameter. Default value - * is set internally. - * - * @param[in] param_name Name of the parameter - * @param[in] max_schedules Maximum number of schedules allowed - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_schedules_param_create(const char *param_name, int max_schedules); - -/** - * Create standard Reboot param - * - * This will create the standard reboot parameter. - * Set value to true (via write param) for the action to trigger. - * - * @param[in] param_name Name of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_reboot_param_create(const char *param_name); - -/** - * Create standard Factory Reset param - * - * This will create the standard factory reset parameter. - * Set value to true (via write param) for the action to trigger. - * - * @param[in] param_name Name of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_factory_reset_param_create(const char *param_name); - -/** - * Create standard Wi-Fi Reset param - * - * This will create the standard Wi-Fi Reset parameter. - * Set value to true (via write param) for the action to trigger. - * - * @param[in] param_name Name of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_wifi_reset_param_create(const char *param_name); - -/** - * Create standard Local Control POP param - * - * This will create the standard Local Control POP parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter (Eg. "abcd1234"). Can be kept NULL. - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_local_control_pop_param_create(const char *param_name, const char *val); - -/** - * Create standard Local Control Type param - * - * This will create the standard Local Control security type parameter. - * - * @param[in] param_name Name of the parameter - * @param[in] val Default Value of the parameter - * - * @return Parameter handle on success. - * @return NULL in case of failures. - */ -esp_rmaker_param_t *esp_rmaker_local_control_type_param_create(const char *param_name, int val); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_services.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_services.h deleted file mode 100644 index 7dc6dfbad80..00000000000 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_services.h +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Create a standard OTA service - * - * This creates an OTA service with the mandatory parameters. The default parameter names will be used. - * Refer \ref esp_rmaker_standard_params.h for default names. - * - * @param[in] serv_name The unique service name - * @param[in] priv_data (Optional) Private data associated with the service. This should stay - * allocated throughout the lifetime of the service. - * - * @return service_handle on success. - * @return NULL in case of any error. - */ -esp_rmaker_device_t *esp_rmaker_ota_service_create(const char *serv_name, void *priv_data); - -/** Create a standard OTA service - * - * This creates an OTA service with the mandatory parameters. The default parameter names will be used. - * Refer \ref esp_rmaker_standard_params.h for default names. - * - * @param[in] serv_name The unique service name - * @param[in] timezone Default value of timezone string (Eg. "Asia/Shanghai"). Can be kept NULL. - * @param[in] timezone_posix Default value of posix timezone string (Eg. "CST-8"). Can be kept NULL. - * @param[in] priv_data (Optional) Private data associated with the service. This should stay - * allocated throughout the lifetime of the service. - * - * @return service_handle on success. - * @return NULL in case of any error. - */ -esp_rmaker_device_t *esp_rmaker_time_service_create(const char *serv_name, const char *timezone, - const char *timezone_posix, void *priv_data); - -/** Create a standard Schedule service - * - * This creates a Schedule service with the mandatory parameters. The default parameter names will be used. - * Refer \ref esp_rmaker_standard_params.h for default names. - * - * @param[in] serv_name The unique service name - * @param[in] write_cb Write callback. - * @param[in] read_cb Read callback. - * @param[in] max_schedules Maximum number of schedules supported. - * @param[in] priv_data (Optional) Private data associated with the service. This should stay - * allocated throughout the lifetime of the service. - * - * @return service_handle on success. - * @return NULL in case of any error. - */ -esp_rmaker_device_t *esp_rmaker_create_schedule_service(const char *serv_name, esp_rmaker_device_write_cb_t write_cb, esp_rmaker_device_read_cb_t read_cb, int max_schedules, void *priv_data); - -/** Create a standard System service - * - * This creates an empty System service. Appropriate parameters should be added by the caller. - * - * @param[in] serv_name The unique service name - * @param[in] priv_data (Optional) Private data associated with the service. This should stay - * allocated throughout the lifetime of the service. - * - * @return service_handle on success. - * @return NULL in case of any error. - */ - -esp_rmaker_device_t *esp_rmaker_create_system_service(const char *serv_name, void *priv_data); - -/** Create a standard Local Control service - * - * This creates a Local Control service with the mandatory parameters. The default parameter names will be used. - * Refer \ref esp_rmaker_standard_params.h for default names. - * - * @param[in] serv_name The unique service name - * @param[in] pop Proof of possession - * @param[in] sec_type Security type - * @param[in] priv_data (Optional) Private data associated with the service. This should stay - * allocated throughout the lifetime of the service. - * - * @return service_handle on success. - * @return NULL in case of any error. - */ -esp_rmaker_device_t *esp_rmaker_create_local_control_service(const char *serv_name, const char *pop, int sec_type, void *priv_data); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_types.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_types.h deleted file mode 100644 index 11eecebcb1c..00000000000 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_types.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif - -/********** STANDARD UI TYPES **********/ - -#define ESP_RMAKER_UI_TOGGLE "esp.ui.toggle" -#define ESP_RMAKER_UI_SLIDER "esp.ui.slider" -#define ESP_RMAKER_UI_DROPDOWN "esp.ui.dropdown" -#define ESP_RMAKER_UI_TEXT "esp.ui.text" -#define ESP_RMAKER_UI_HUE_SLIDER "esp.ui.hue-slider" - -/********** STANDARD PARAM TYPES **********/ - -#define ESP_RMAKER_PARAM_NAME "esp.param.name" -#define ESP_RMAKER_PARAM_POWER "esp.param.power" -#define ESP_RMAKER_PARAM_BRIGHTNESS "esp.param.brightness" -#define ESP_RMAKER_PARAM_HUE "esp.param.hue" -#define ESP_RMAKER_PARAM_SATURATION "esp.param.saturation" -#define ESP_RMAKER_PARAM_INTENSITY "esp.param.intensity" -#define ESP_RMAKER_PARAM_CCT "esp.param.cct" -#define ESP_RMAKER_PARAM_SPEED "esp.param.speed" -#define ESP_RMAKER_PARAM_DIRECTION "esp.param.direction" -#define ESP_RMAKER_PARAM_TEMPERATURE "esp.param.temperature" -#define ESP_RMAKER_PARAM_OTA_STATUS "esp.param.ota_status" -#define ESP_RMAKER_PARAM_OTA_INFO "esp.param.ota_info" -#define ESP_RMAKER_PARAM_OTA_URL "esp.param.ota_url" -#define ESP_RMAKER_PARAM_TIMEZONE "esp.param.tz" -#define ESP_RMAKER_PARAM_TIMEZONE_POSIX "esp.param.tz_posix" -#define ESP_RMAKER_PARAM_SCHEDULES "esp.param.schedules" -#define ESP_RMAKER_PARAM_REBOOT "esp.param.reboot" -#define ESP_RMAKER_PARAM_FACTORY_RESET "esp.param.factory-reset" -#define ESP_RMAKER_PARAM_WIFI_RESET "esp.param.wifi-reset" -#define ESP_RMAKER_PARAM_LOCAL_CONTROL_POP "esp.param.local_control_pop" -#define ESP_RMAKER_PARAM_LOCAL_CONTROL_TYPE "esp.param.local_control_type" - - -/********** STANDARD DEVICE TYPES **********/ - -#define ESP_RMAKER_DEVICE_SWITCH "esp.device.switch" -#define ESP_RMAKER_DEVICE_LIGHTBULB "esp.device.lightbulb" -#define ESP_RMAKER_DEVICE_FAN "esp.device.fan" -#define ESP_RMAKER_DEVICE_TEMP_SENSOR "esp.device.temperature-sensor" - - -/********** STANDARD SERVICE TYPES **********/ -#define ESP_RMAKER_SERVICE_OTA "esp.service.ota" -#define ESP_RMAKER_SERVICE_TIME "esp.service.time" -#define ESP_RMAKER_SERVICE_SCHEDULE "esp.service.schedule" -#define ESP_RMAKER_SERVICE_SYSTEM "esp.service.system" -#define ESP_RMAKER_SERVICE_LOCAL_CONTROL "esp.service.local_control" - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_user_mapping.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_user_mapping.h deleted file mode 100644 index a763561f3c2..00000000000 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_user_mapping.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#pragma once -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * Create User Mapping Endpoint - * - * This will create a custom provisioning endpoint for user-node mapping. - * This should be called after wifi_prov_mgr_init() but before - * wifi_prov_mgr_start_provisioning() - * - * @return ESP_OK on success - * @return error on failure - */ -esp_err_t esp_rmaker_user_mapping_endpoint_create(void); - -/** - * Register User Mapping Endpoint - * - * This will register the callback for the custom provisioning endpoint - * for user-node mapping which was created with esp_rmaker_user_mapping_endpoint_create(). - * This should be called immediately after wifi_prov_mgr_start_provisioning(). - * - * @return ESP_OK on success - * @return error on failure - */ -esp_err_t esp_rmaker_user_mapping_endpoint_register(void); - -/** Add User-Node mapping - * - * This call will start the user-node mapping workflow on the node. - * This is automatically called if you have used esp_rmaker_user_mapping_endpoint_register(). - * Use this API only if you want to trigger the user-node mapping after the Wi-Fi provisioning - * has already been done. - * - * @param[in] user_id The User identifier received from the client (Phone app/CLI) - * @param[in] secret_key The Secret key received from the client (Phone app/CLI) - * - * @return ESP_OK if the workflow was successfully triggered. This does not guarantee success - * of the actual mapping. The mapping status needs to be checked separately by the clients. - * @return error on failure. - */ -esp_err_t esp_rmaker_start_user_node_mapping(char *user_id, char *secret_key); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/portmacro.h b/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/portmacro.h index 934f056816c..2ee4c12c2b8 100644 --- a/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/portmacro.h +++ b/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/portmacro.h @@ -558,14 +558,14 @@ static inline void __attribute__((always_inline)) uxPortCompareSetExtram(volatil // --------------------- Interrupts ------------------------ -static inline UBaseType_t xPortSetInterruptMaskFromISR(void) +static inline UBaseType_t __attribute__((always_inline)) xPortSetInterruptMaskFromISR(void) { UBaseType_t prev_int_level = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); portbenchmarkINTERRUPT_DISABLE(); return prev_int_level; } -static inline void vPortClearInterruptMaskFromISR(UBaseType_t prev_level) +static inline void __attribute__((always_inline)) vPortClearInterruptMaskFromISR(UBaseType_t prev_level) { portbenchmarkINTERRUPT_RESTORE(prev_level); XTOS_RESTORE_JUST_INTLEVEL(prev_level); diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/emac_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/emac_ll.h index bea18961bc4..cd341b1c5f8 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/emac_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/emac_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -342,6 +342,11 @@ static inline uint32_t emac_ll_transmit_frame_ctrl_status(emac_mac_dev_t *mac_re return mac_regs->emacdebug.mactfcs; } +static inline uint32_t emac_ll_receive_read_ctrl_state(emac_mac_dev_t *mac_regs) +{ + return mac_regs->emacdebug.mtlrfrcs; +} + /* emacmiidata */ static inline void emac_ll_set_phy_data(emac_mac_dev_t *mac_regs, uint32_t data) { diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/gpio_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/gpio_ll.h index 59a2858ce91..fcff6a22bd6 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/gpio_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/gpio_ll.h @@ -567,7 +567,7 @@ static inline void gpio_ll_iomux_in(gpio_dev_t *hw, uint32_t gpio, uint32_t sign * @param pin_name Pin name to configure * @param func Function to assign to the pin */ -static inline void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func) +static inline __attribute__((always_inline)) void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func) { PIN_FUNC_SELECT(pin_name, func); } diff --git a/tools/sdk/esp32/include/hal/include/hal/emac_hal.h b/tools/sdk/esp32/include/hal/include/hal/emac_hal.h index 4f332811aba..27cd38456dc 100644 --- a/tools/sdk/esp32/include/hal/include/hal/emac_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/emac_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -225,7 +225,7 @@ void emac_hal_start(emac_hal_context_t *hal); * @param hal EMAC HAL context infostructure * @return * - ESP_OK: succeed - * - ESP_ERR_INVALID_STATE: previous frame transmission is not completed. When this error occurs, + * - ESP_ERR_INVALID_STATE: previous frame transmission/reception is not completed. When this error occurs, * wait and reapeat the EMAC stop again. */ esp_err_t emac_hal_stop(emac_hal_context_t *hal); diff --git a/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_common_events.h b/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_common_events.h index 62c4b208759..b77f8a3d142 100644 --- a/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_common_events.h +++ b/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_common_events.h @@ -35,9 +35,26 @@ typedef enum { RMAKER_MQTT_EVENT_CONNECTED, /** Disconnected from MQTT Broker */ RMAKER_MQTT_EVENT_DISCONNECTED, - /** MQTT message published successfully */ + /** MQTT message published successfully. + * Event data will contain the message ID (integer) of published message. + */ RMAKER_MQTT_EVENT_PUBLISHED, -} esp_rmaker_mqtt_event_t; + /** POSIX Timezone Changed. Associated data would be NULL terminated POSIX Timezone + * Eg. "PST8PDT,M3.2.0,M11.1.0" */ + RMAKER_EVENT_TZ_POSIX_CHANGED, + /** Timezone Changed. Associated data would be NULL terminated Timezone. + * Eg. "America/Los_Angeles" + * Note that whenever this event is received, the RMAKER_EVENT_TZ_POSIX_CHANGED event + * will also be received, but not necessarily vice versa. + */ + RMAKER_EVENT_TZ_CHANGED, + /** + * MQTT message deleted from the outbox if the message couldn't have been sent and acknowledged. + * Event data will contain the message ID (integer) of deleted message. + * Valid only if CONFIG_MQTT_REPORT_DELETED_MESSAGES is enabled. + */ + RMAKER_MQTT_EVENT_MSG_DELETED, +} esp_rmaker_common_event_t; #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_mqtt_glue.h b/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_mqtt_glue.h index 8a9e1ae649d..95744bdf58c 100644 --- a/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_mqtt_glue.h +++ b/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_mqtt_glue.h @@ -52,7 +52,7 @@ typedef esp_rmaker_mqtt_conn_params_t *(*esp_rmaker_mqtt_get_conn_params_t)(void * @param[in] priv_data The private data passed during subscription */ typedef void (*esp_rmaker_mqtt_subscribe_cb_t)(const char *topic, void *payload, size_t payload_len, void *priv_data); - + /** MQTT Init function prototype * * @param[in] conn_params The MQTT connection parameters. If NULL is passed, it should internally use the @@ -63,6 +63,12 @@ typedef void (*esp_rmaker_mqtt_subscribe_cb_t)(const char *topic, void *payload, */ typedef esp_err_t (*esp_rmaker_mqtt_init_t)(esp_rmaker_mqtt_conn_params_t *conn_params); +/** MQTT Deinit function prototype + * + * Call this function after MQTT has disconnected. + */ +typedef void (*esp_rmaker_mqtt_deinit_t)(void); + /** MQTT Connect function prototype * * Starts the connection attempts to the MQTT broker. @@ -124,6 +130,8 @@ typedef struct { esp_rmaker_mqtt_get_conn_params_t get_conn_params; /** Pointer to MQTT Init function. */ esp_rmaker_mqtt_init_t init; + /** Pointer to MQTT Deinit function. */ + esp_rmaker_mqtt_deinit_t deinit; /** Pointer to MQTT Connect function. */ esp_rmaker_mqtt_connect_t connect; /** Pointer to MQTQ Disconnect function */ diff --git a/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_utils.h b/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_utils.h index 9a5ba16f0aa..86ab691d492 100644 --- a/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_utils.h +++ b/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_utils.h @@ -15,12 +15,24 @@ #include #include #include +#include +#include #ifdef __cplusplus extern "C" { #endif +#ifdef CONFIG_SPIRAM +#define MEM_ALLOC_EXTRAM(size) heap_caps_malloc(size, MALLOC_CAP_SPIRAM) +#define MEM_CALLOC_EXTRAM(num, size) heap_caps_calloc(num, size, MALLOC_CAP_SPIRAM) +#define MEM_REALLOC_EXTRAM(ptr, size) heap_caps_realloc(ptr, size, MALLOC_CAP_SPIRAM) +#else +#define MEM_ALLOC_EXTRAM(size) malloc(size) +#define MEM_CALLOC_EXTRAM(num, size) calloc(num, size) +#define MEM_REALLOC_EXTRAM(ptr, size) realloc(ptr, size) +#endif + typedef struct esp_rmaker_time_config { /** If not specified, then 'CONFIG_ESP_RMAKER_SNTP_SERVER_NAME' is used as the SNTP server. */ char *sntp_server_name; diff --git a/tools/sdk/esp32/lib/libapp_trace.a b/tools/sdk/esp32/lib/libapp_trace.a index 8cf628938e2..defe4c47233 100644 Binary files a/tools/sdk/esp32/lib/libapp_trace.a and b/tools/sdk/esp32/lib/libapp_trace.a differ diff --git a/tools/sdk/esp32/lib/libapp_update.a b/tools/sdk/esp32/lib/libapp_update.a index 23ac4fe8093..00242fe58d7 100644 Binary files a/tools/sdk/esp32/lib/libapp_update.a and b/tools/sdk/esp32/lib/libapp_update.a differ diff --git a/tools/sdk/esp32/lib/libbt.a b/tools/sdk/esp32/lib/libbt.a index 87ccb4239a7..fe0e8d2e82d 100644 Binary files a/tools/sdk/esp32/lib/libbt.a and b/tools/sdk/esp32/lib/libbt.a differ diff --git a/tools/sdk/esp32/lib/libbutton.a b/tools/sdk/esp32/lib/libbutton.a index c39c2a162a0..0664c986ef0 100644 Binary files a/tools/sdk/esp32/lib/libbutton.a and b/tools/sdk/esp32/lib/libbutton.a differ diff --git a/tools/sdk/esp32/lib/libcoap.a b/tools/sdk/esp32/lib/libcoap.a index 1fbf8163abc..8aba1a10cf3 100644 Binary files a/tools/sdk/esp32/lib/libcoap.a and b/tools/sdk/esp32/lib/libcoap.a differ diff --git a/tools/sdk/esp32/lib/libdriver.a b/tools/sdk/esp32/lib/libdriver.a index 186cd096317..c677662b039 100644 Binary files a/tools/sdk/esp32/lib/libdriver.a and b/tools/sdk/esp32/lib/libdriver.a differ diff --git a/tools/sdk/esp32/lib/libesp-tls.a b/tools/sdk/esp32/lib/libesp-tls.a index 170540c41f9..c811ef37174 100644 Binary files a/tools/sdk/esp32/lib/libesp-tls.a and b/tools/sdk/esp32/lib/libesp-tls.a differ diff --git a/tools/sdk/esp32/lib/libesp_eth.a b/tools/sdk/esp32/lib/libesp_eth.a index 4fbfc3ad1f1..1bbead08d7f 100644 Binary files a/tools/sdk/esp32/lib/libesp_eth.a and b/tools/sdk/esp32/lib/libesp_eth.a differ diff --git a/tools/sdk/esp32/lib/libesp_http_client.a b/tools/sdk/esp32/lib/libesp_http_client.a index 46dcdb139a9..8d365c67190 100644 Binary files a/tools/sdk/esp32/lib/libesp_http_client.a and b/tools/sdk/esp32/lib/libesp_http_client.a differ diff --git a/tools/sdk/esp32/lib/libesp_http_server.a b/tools/sdk/esp32/lib/libesp_http_server.a index 5eb1a006b73..bc9fbe8d112 100644 Binary files a/tools/sdk/esp32/lib/libesp_http_server.a and b/tools/sdk/esp32/lib/libesp_http_server.a differ diff --git a/tools/sdk/esp32/lib/libesp_ipc.a b/tools/sdk/esp32/lib/libesp_ipc.a index 7196bc05990..e3cca647d42 100644 Binary files a/tools/sdk/esp32/lib/libesp_ipc.a and b/tools/sdk/esp32/lib/libesp_ipc.a differ diff --git a/tools/sdk/esp32/lib/libesp_lcd.a b/tools/sdk/esp32/lib/libesp_lcd.a index 9bfd4135dbe..8883b038593 100644 Binary files a/tools/sdk/esp32/lib/libesp_lcd.a and b/tools/sdk/esp32/lib/libesp_lcd.a differ diff --git a/tools/sdk/esp32/lib/libesp_pm.a b/tools/sdk/esp32/lib/libesp_pm.a index 19d6b95dc44..ebf040b2bc3 100644 Binary files a/tools/sdk/esp32/lib/libesp_pm.a and b/tools/sdk/esp32/lib/libesp_pm.a differ diff --git a/tools/sdk/esp32/lib/libesp_rainmaker.a b/tools/sdk/esp32/lib/libesp_rainmaker.a index 922a157141d..c45e14e231a 100644 Binary files a/tools/sdk/esp32/lib/libesp_rainmaker.a and b/tools/sdk/esp32/lib/libesp_rainmaker.a differ diff --git a/tools/sdk/esp32/lib/libesp_websocket_client.a b/tools/sdk/esp32/lib/libesp_websocket_client.a index f22dcbf423a..e979b6a0d3a 100644 Binary files a/tools/sdk/esp32/lib/libesp_websocket_client.a and b/tools/sdk/esp32/lib/libesp_websocket_client.a differ diff --git a/tools/sdk/esp32/lib/libfreemodbus.a b/tools/sdk/esp32/lib/libfreemodbus.a index a0e1946e5cd..19f3dfd0794 100644 Binary files a/tools/sdk/esp32/lib/libfreemodbus.a and b/tools/sdk/esp32/lib/libfreemodbus.a differ diff --git a/tools/sdk/esp32/lib/libhal.a b/tools/sdk/esp32/lib/libhal.a index c977c9a1080..dd9d6aeb386 100644 Binary files a/tools/sdk/esp32/lib/libhal.a and b/tools/sdk/esp32/lib/libhal.a differ diff --git a/tools/sdk/esp32/lib/liblibsodium.a b/tools/sdk/esp32/lib/liblibsodium.a index df7ec00a4d6..8558a5bb2af 100644 Binary files a/tools/sdk/esp32/lib/liblibsodium.a and b/tools/sdk/esp32/lib/liblibsodium.a differ diff --git a/tools/sdk/esp32/lib/libmbedcrypto.a b/tools/sdk/esp32/lib/libmbedcrypto.a index 3ceed1e5423..f453fd3ed9f 100644 Binary files a/tools/sdk/esp32/lib/libmbedcrypto.a and b/tools/sdk/esp32/lib/libmbedcrypto.a differ diff --git a/tools/sdk/esp32/lib/libmbedtls.a b/tools/sdk/esp32/lib/libmbedtls.a index e7aeff5576d..8f73985511f 100644 Binary files a/tools/sdk/esp32/lib/libmbedtls.a and b/tools/sdk/esp32/lib/libmbedtls.a differ diff --git a/tools/sdk/esp32/lib/libmbedx509.a b/tools/sdk/esp32/lib/libmbedx509.a index 1df3448c5d3..20759c1ca35 100644 Binary files a/tools/sdk/esp32/lib/libmbedx509.a and b/tools/sdk/esp32/lib/libmbedx509.a differ diff --git a/tools/sdk/esp32/lib/libmqtt.a b/tools/sdk/esp32/lib/libmqtt.a index 2656bde3c65..95ac2710f88 100644 Binary files a/tools/sdk/esp32/lib/libmqtt.a and b/tools/sdk/esp32/lib/libmqtt.a differ diff --git a/tools/sdk/esp32/lib/libopenssl.a b/tools/sdk/esp32/lib/libopenssl.a index 2e8ee4973bf..6649f415101 100644 Binary files a/tools/sdk/esp32/lib/libopenssl.a and b/tools/sdk/esp32/lib/libopenssl.a differ diff --git a/tools/sdk/esp32/lib/libprotocomm.a b/tools/sdk/esp32/lib/libprotocomm.a index 79380351c34..170f1e89ffb 100644 Binary files a/tools/sdk/esp32/lib/libprotocomm.a and b/tools/sdk/esp32/lib/libprotocomm.a differ diff --git a/tools/sdk/esp32/lib/librmaker_common.a b/tools/sdk/esp32/lib/librmaker_common.a index 29ac8b00306..ffa57cc8898 100644 Binary files a/tools/sdk/esp32/lib/librmaker_common.a and b/tools/sdk/esp32/lib/librmaker_common.a differ diff --git a/tools/sdk/esp32/lib/libtcp_transport.a b/tools/sdk/esp32/lib/libtcp_transport.a index 39bd05bb700..d691977906a 100644 Binary files a/tools/sdk/esp32/lib/libtcp_transport.a and b/tools/sdk/esp32/lib/libtcp_transport.a differ diff --git a/tools/sdk/esp32/lib/libwpa_supplicant.a b/tools/sdk/esp32/lib/libwpa_supplicant.a index 01c4db485c4..9f045212079 100644 Binary files a/tools/sdk/esp32/lib/libwpa_supplicant.a and b/tools/sdk/esp32/lib/libwpa_supplicant.a differ diff --git a/tools/sdk/esp32/qspi_qspi/include/sdkconfig.h b/tools/sdk/esp32/qspi_qspi/include/sdkconfig.h index 68f0593603b..d923bc8fe95 100644 --- a/tools/sdk/esp32/qspi_qspi/include/sdkconfig.h +++ b/tools/sdk/esp32/qspi_qspi/include/sdkconfig.h @@ -48,6 +48,7 @@ #define CONFIG_LIB_BUILDER_FLASHMODE "dio" #define CONFIG_LIB_BUILDER_FLASHFREQ "40m" #define CONFIG_ESP_RMAKER_ASSISTED_CLAIM 1 +#define CONFIG_ESP_RMAKER_CLAIM_TYPE 2 #define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" #define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024 #define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0 1 @@ -348,7 +349,6 @@ #define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2 #define CONFIG_HEAP_POISONING_LIGHT 1 #define CONFIG_HEAP_TRACING_OFF 1 -#define CONFIG_LIBSODIUM_USE_MBEDTLS_SHA 1 #define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1 #define CONFIG_LOG_DEFAULT_LEVEL 1 #define CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT 1 @@ -417,6 +417,7 @@ #define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL 1 #define CONFIG_MBEDTLS_HARDWARE_AES 1 #define CONFIG_MBEDTLS_HARDWARE_MPI 1 +#define CONFIG_MBEDTLS_HARDWARE_SHA 1 #define CONFIG_MBEDTLS_ROM_MD5 1 #define CONFIG_MBEDTLS_HAVE_TIME 1 #define CONFIG_MBEDTLS_ECDSA_DETERMINISTIC 1 diff --git a/tools/sdk/esp32/qspi_qspi/libbootloader_support.a b/tools/sdk/esp32/qspi_qspi/libbootloader_support.a index 59516186cfb..2c1a283c79b 100644 Binary files a/tools/sdk/esp32/qspi_qspi/libbootloader_support.a and b/tools/sdk/esp32/qspi_qspi/libbootloader_support.a differ diff --git a/tools/sdk/esp32/qspi_qspi/libesp_hw_support.a b/tools/sdk/esp32/qspi_qspi/libesp_hw_support.a index c1a28586968..edc264e0237 100644 Binary files a/tools/sdk/esp32/qspi_qspi/libesp_hw_support.a and b/tools/sdk/esp32/qspi_qspi/libesp_hw_support.a differ diff --git a/tools/sdk/esp32/qspi_qspi/libesp_system.a b/tools/sdk/esp32/qspi_qspi/libesp_system.a index 0c97e03e446..5a9fc71d912 100644 Binary files a/tools/sdk/esp32/qspi_qspi/libesp_system.a and b/tools/sdk/esp32/qspi_qspi/libesp_system.a differ diff --git a/tools/sdk/esp32/qspi_qspi/libfreertos.a b/tools/sdk/esp32/qspi_qspi/libfreertos.a index 387ab2ba035..ac0ba416c17 100644 Binary files a/tools/sdk/esp32/qspi_qspi/libfreertos.a and b/tools/sdk/esp32/qspi_qspi/libfreertos.a differ diff --git a/tools/sdk/esp32/qspi_qspi/libspi_flash.a b/tools/sdk/esp32/qspi_qspi/libspi_flash.a index c9217310008..1f827011210 100644 Binary files a/tools/sdk/esp32/qspi_qspi/libspi_flash.a and b/tools/sdk/esp32/qspi_qspi/libspi_flash.a differ diff --git a/tools/sdk/esp32/qspi_qspi/sections.ld b/tools/sdk/esp32/qspi_qspi/sections.ld index a757898d2e1..e595c454b92 100644 --- a/tools/sdk/esp32/qspi_qspi/sections.ld +++ b/tools/sdk/esp32/qspi_qspi/sections.ld @@ -605,8 +605,8 @@ SECTIONS _bss_start = ABSOLUTE(.); *(.bss .bss.*) - *(.ext_ram.bss .ext_ram.bss.*) *(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb .gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2 .sbss2.* .scommon .share.mem) + *(.ext_ram.bss .ext_ram.bss.*) *(COMMON) _bt_bss_start = ABSOLUTE(.); *libbt.a:(.bss .bss.* COMMON) diff --git a/tools/sdk/esp32/sdkconfig b/tools/sdk/esp32/sdkconfig index 7318079de73..5f56097ba67 100644 --- a/tools/sdk/esp32/sdkconfig +++ b/tools/sdk/esp32/sdkconfig @@ -134,7 +134,9 @@ CONFIG_LIB_BUILDER_FLASHFREQ="40m" # # ESP RainMaker Config # +# CONFIG_ESP_RMAKER_NO_CLAIM is not set CONFIG_ESP_RMAKER_ASSISTED_CLAIM=y +CONFIG_ESP_RMAKER_CLAIM_TYPE=2 CONFIG_ESP_RMAKER_MQTT_HOST="a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE=1024 # CONFIG_ESP_RMAKER_DISABLE_USER_MAPPING_PROV is not set @@ -996,7 +998,6 @@ CONFIG_HEAP_TRACING_OFF=y # # libsodium # -CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y # end of libsodium # @@ -1205,7 +1206,7 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y # CONFIG_MBEDTLS_CMAC_C is not set CONFIG_MBEDTLS_HARDWARE_AES=y CONFIG_MBEDTLS_HARDWARE_MPI=y -# CONFIG_MBEDTLS_HARDWARE_SHA is not set +CONFIG_MBEDTLS_HARDWARE_SHA=y CONFIG_MBEDTLS_ROM_MD5=y # CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set # CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set diff --git a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_hf_client_api.h b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_hf_client_api.h index 3c5c05b178c..55569bc5c84 100644 --- a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_hf_client_api.h +++ b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_hf_client_api.h @@ -60,6 +60,9 @@ typedef enum { #define ESP_HF_CLIENT_PEER_FEAT_ECC 0x80 /* Enhanced Call Control */ #define ESP_HF_CLIENT_PEER_FEAT_EXTERR 0x100 /* Extended error codes */ #define ESP_HF_CLIENT_PEER_FEAT_CODEC 0x200 /* Codec Negotiation */ +/* HFP 1.7+ */ +#define ESP_HF_CLIENT_PEER_FEAT_HF_IND 0x400 /* HF Indicators */ +#define ESP_HF_CLIENT_PEER_FEAT_ESCO_S4 0x800 /* eSCO S4 Setting Supported */ /* CHLD feature masks of AG */ #define ESP_HF_CLIENT_CHLD_FEAT_REL 0x01 /* 0 Release waiting call or held calls */ diff --git a/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_core.h b/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_core.h index 6ddb0fbe912..f9d96be4ee6 100644 --- a/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_core.h +++ b/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_core.h @@ -49,6 +49,8 @@ typedef enum { RMAKER_EVENT_USER_NODE_MAPPING_DONE, /** Local control started. Associated data is the NULL terminated Service Name */ RMAKER_EVENT_LOCAL_CTRL_STARTED, + /* User reset request successfully sent to ESP RainMaker Cloud */ + RMAKER_EVENT_USER_NODE_MAPPING_RESET, } esp_rmaker_event_t; /** ESP RainMaker Node information */ diff --git a/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h b/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h index a763561f3c2..77a153b02f2 100644 --- a/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h +++ b/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h @@ -19,6 +19,25 @@ extern "C" { #endif +/** User-Node Mapping states */ +typedef enum { + /** Mapping does not exist or is not initialized */ + ESP_RMAKER_USER_MAPPING_RESET = 0, + /** Mapping has started */ + ESP_RMAKER_USER_MAPPING_STARTED, + /** Mapping is done */ + ESP_RMAKER_USER_MAPPING_DONE, +} esp_rmaker_user_mapping_state_t; + +/** + * Get User-Node mapping state + * + * This returns the current user-node mapping state. + * + * @return user mapping state + */ +esp_rmaker_user_mapping_state_t esp_rmaker_user_node_mapping_get_state(void); + /** * Create User Mapping Endpoint * diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/gpio_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/gpio_ll.h index 804e94a7b43..91343f84776 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/gpio_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/gpio_ll.h @@ -380,7 +380,7 @@ static inline void gpio_ll_iomux_in(gpio_dev_t *hw, uint32_t gpio, uint32_t sign * @param pin_name Pin name to configure * @param func Function to assign to the pin */ -static inline void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func) +static inline __attribute__((always_inline)) void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func) { // Disable USB Serial JTAG if pins 18 or pins 19 needs to select an IOMUX function if (pin_name == IO_MUX_GPIO18_REG || pin_name == IO_MUX_GPIO19_REG) { diff --git a/tools/sdk/esp32c3/include/hal/include/hal/emac_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/emac_hal.h index 4f332811aba..27cd38456dc 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/emac_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/emac_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -225,7 +225,7 @@ void emac_hal_start(emac_hal_context_t *hal); * @param hal EMAC HAL context infostructure * @return * - ESP_OK: succeed - * - ESP_ERR_INVALID_STATE: previous frame transmission is not completed. When this error occurs, + * - ESP_ERR_INVALID_STATE: previous frame transmission/reception is not completed. When this error occurs, * wait and reapeat the EMAC stop again. */ esp_err_t emac_hal_stop(emac_hal_context_t *hal); diff --git a/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_common_events.h b/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_common_events.h index 62c4b208759..b77f8a3d142 100644 --- a/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_common_events.h +++ b/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_common_events.h @@ -35,9 +35,26 @@ typedef enum { RMAKER_MQTT_EVENT_CONNECTED, /** Disconnected from MQTT Broker */ RMAKER_MQTT_EVENT_DISCONNECTED, - /** MQTT message published successfully */ + /** MQTT message published successfully. + * Event data will contain the message ID (integer) of published message. + */ RMAKER_MQTT_EVENT_PUBLISHED, -} esp_rmaker_mqtt_event_t; + /** POSIX Timezone Changed. Associated data would be NULL terminated POSIX Timezone + * Eg. "PST8PDT,M3.2.0,M11.1.0" */ + RMAKER_EVENT_TZ_POSIX_CHANGED, + /** Timezone Changed. Associated data would be NULL terminated Timezone. + * Eg. "America/Los_Angeles" + * Note that whenever this event is received, the RMAKER_EVENT_TZ_POSIX_CHANGED event + * will also be received, but not necessarily vice versa. + */ + RMAKER_EVENT_TZ_CHANGED, + /** + * MQTT message deleted from the outbox if the message couldn't have been sent and acknowledged. + * Event data will contain the message ID (integer) of deleted message. + * Valid only if CONFIG_MQTT_REPORT_DELETED_MESSAGES is enabled. + */ + RMAKER_MQTT_EVENT_MSG_DELETED, +} esp_rmaker_common_event_t; #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h b/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h index 8a9e1ae649d..95744bdf58c 100644 --- a/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h +++ b/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h @@ -52,7 +52,7 @@ typedef esp_rmaker_mqtt_conn_params_t *(*esp_rmaker_mqtt_get_conn_params_t)(void * @param[in] priv_data The private data passed during subscription */ typedef void (*esp_rmaker_mqtt_subscribe_cb_t)(const char *topic, void *payload, size_t payload_len, void *priv_data); - + /** MQTT Init function prototype * * @param[in] conn_params The MQTT connection parameters. If NULL is passed, it should internally use the @@ -63,6 +63,12 @@ typedef void (*esp_rmaker_mqtt_subscribe_cb_t)(const char *topic, void *payload, */ typedef esp_err_t (*esp_rmaker_mqtt_init_t)(esp_rmaker_mqtt_conn_params_t *conn_params); +/** MQTT Deinit function prototype + * + * Call this function after MQTT has disconnected. + */ +typedef void (*esp_rmaker_mqtt_deinit_t)(void); + /** MQTT Connect function prototype * * Starts the connection attempts to the MQTT broker. @@ -124,6 +130,8 @@ typedef struct { esp_rmaker_mqtt_get_conn_params_t get_conn_params; /** Pointer to MQTT Init function. */ esp_rmaker_mqtt_init_t init; + /** Pointer to MQTT Deinit function. */ + esp_rmaker_mqtt_deinit_t deinit; /** Pointer to MQTT Connect function. */ esp_rmaker_mqtt_connect_t connect; /** Pointer to MQTQ Disconnect function */ diff --git a/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_utils.h b/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_utils.h index 9a5ba16f0aa..86ab691d492 100644 --- a/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_utils.h +++ b/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_utils.h @@ -15,12 +15,24 @@ #include #include #include +#include +#include #ifdef __cplusplus extern "C" { #endif +#ifdef CONFIG_SPIRAM +#define MEM_ALLOC_EXTRAM(size) heap_caps_malloc(size, MALLOC_CAP_SPIRAM) +#define MEM_CALLOC_EXTRAM(num, size) heap_caps_calloc(num, size, MALLOC_CAP_SPIRAM) +#define MEM_REALLOC_EXTRAM(ptr, size) heap_caps_realloc(ptr, size, MALLOC_CAP_SPIRAM) +#else +#define MEM_ALLOC_EXTRAM(size) malloc(size) +#define MEM_CALLOC_EXTRAM(num, size) calloc(num, size) +#define MEM_REALLOC_EXTRAM(ptr, size) realloc(ptr, size) +#endif + typedef struct esp_rmaker_time_config { /** If not specified, then 'CONFIG_ESP_RMAKER_SNTP_SERVER_NAME' is used as the SNTP server. */ char *sntp_server_name; diff --git a/tools/sdk/esp32c3/ld/esp32c3.rom.ld b/tools/sdk/esp32c3/ld/esp32c3.rom.ld index 471fc1c1a9f..db1a6ac02c9 100644 --- a/tools/sdk/esp32c3/ld/esp32c3.rom.ld +++ b/tools/sdk/esp32c3/ld/esp32c3.rom.ld @@ -1067,7 +1067,6 @@ r_lld_con_tx_prog = 0x40001140; r_lld_conn_dynamic_pti_process = 0x40001144; r_lld_continue_scan_rx_isr_end_process = 0x40001148; r_lld_ext_scan_dynamic_pti_process = 0x4000114c; -r_lld_ext_adv_dynamic_aux_pti_process = 0x40001b44; r_lld_hw_cca_end_isr = 0x40001150; r_lld_hw_cca_evt_handler = 0x40001154; r_lld_hw_cca_isr = 0x40001158; @@ -1897,7 +1896,7 @@ rom_read_sar2_code = 0x40001aa4; rom_get_sar2_vol = 0x40001aa8; rom_get_pll_vol = 0x40001aac; rom_get_phy_target_power = 0x40001ab0; -rom_temp_to_power = 0x40001ab4; +/* rom_temp_to_power = 0x40001ab4; */ rom_phy_track_pll_cap = 0x40001ab8; rom_phy_pwdet_always_en = 0x40001abc; rom_phy_pwdet_onetime_en = 0x40001ac0; diff --git a/tools/sdk/esp32c3/lib/libapp_update.a b/tools/sdk/esp32c3/lib/libapp_update.a index 4e25d3037e0..7fb803199d2 100644 Binary files a/tools/sdk/esp32c3/lib/libapp_update.a and b/tools/sdk/esp32c3/lib/libapp_update.a differ diff --git a/tools/sdk/esp32c3/lib/libbutton.a b/tools/sdk/esp32c3/lib/libbutton.a index 225ac7b6586..ad32dd76ab8 100644 Binary files a/tools/sdk/esp32c3/lib/libbutton.a and b/tools/sdk/esp32c3/lib/libbutton.a differ diff --git a/tools/sdk/esp32c3/lib/libdriver.a b/tools/sdk/esp32c3/lib/libdriver.a index 165c7c18a7d..9b8151c272d 100644 Binary files a/tools/sdk/esp32c3/lib/libdriver.a and b/tools/sdk/esp32c3/lib/libdriver.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_eth.a b/tools/sdk/esp32c3/lib/libesp_eth.a index 98d719a1bb1..d9c1f390555 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_eth.a and b/tools/sdk/esp32c3/lib/libesp_eth.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_rainmaker.a b/tools/sdk/esp32c3/lib/libesp_rainmaker.a index 25659a32808..a8f80eda7dc 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_rainmaker.a and b/tools/sdk/esp32c3/lib/libesp_rainmaker.a differ diff --git a/tools/sdk/esp32c3/lib/libfreemodbus.a b/tools/sdk/esp32c3/lib/libfreemodbus.a index 791b5d5c1eb..7f90d8d9fd9 100644 Binary files a/tools/sdk/esp32c3/lib/libfreemodbus.a and b/tools/sdk/esp32c3/lib/libfreemodbus.a differ diff --git a/tools/sdk/esp32c3/lib/librmaker_common.a b/tools/sdk/esp32c3/lib/librmaker_common.a index ac6ebf458a9..efe9d2e3bbb 100644 Binary files a/tools/sdk/esp32c3/lib/librmaker_common.a and b/tools/sdk/esp32c3/lib/librmaker_common.a differ diff --git a/tools/sdk/esp32c3/qspi_qspi/include/sdkconfig.h b/tools/sdk/esp32c3/qspi_qspi/include/sdkconfig.h index c16b030b987..55dbbf92865 100644 --- a/tools/sdk/esp32c3/qspi_qspi/include/sdkconfig.h +++ b/tools/sdk/esp32c3/qspi_qspi/include/sdkconfig.h @@ -51,6 +51,7 @@ #define CONFIG_LIB_BUILDER_FLASHMODE "qio" #define CONFIG_LIB_BUILDER_FLASHFREQ "80m" #define CONFIG_ESP_RMAKER_ASSISTED_CLAIM 1 +#define CONFIG_ESP_RMAKER_CLAIM_TYPE 2 #define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" #define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024 #define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0 1 diff --git a/tools/sdk/esp32c3/qspi_qspi/libesp_system.a b/tools/sdk/esp32c3/qspi_qspi/libesp_system.a index 0a0b1876d45..7dbf89db362 100644 Binary files a/tools/sdk/esp32c3/qspi_qspi/libesp_system.a and b/tools/sdk/esp32c3/qspi_qspi/libesp_system.a differ diff --git a/tools/sdk/esp32c3/qspi_qspi/libspi_flash.a b/tools/sdk/esp32c3/qspi_qspi/libspi_flash.a index fc470eb4ae0..84f84dd3764 100644 Binary files a/tools/sdk/esp32c3/qspi_qspi/libspi_flash.a and b/tools/sdk/esp32c3/qspi_qspi/libspi_flash.a differ diff --git a/tools/sdk/esp32c3/sdkconfig b/tools/sdk/esp32c3/sdkconfig index 0939b43f914..f16fd8c1041 100644 --- a/tools/sdk/esp32c3/sdkconfig +++ b/tools/sdk/esp32c3/sdkconfig @@ -144,7 +144,10 @@ CONFIG_LIB_BUILDER_FLASHFREQ="80m" # # ESP RainMaker Config # +# CONFIG_ESP_RMAKER_NO_CLAIM is not set +# CONFIG_ESP_RMAKER_SELF_CLAIM is not set CONFIG_ESP_RMAKER_ASSISTED_CLAIM=y +CONFIG_ESP_RMAKER_CLAIM_TYPE=2 CONFIG_ESP_RMAKER_MQTT_HOST="a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE=1024 # CONFIG_ESP_RMAKER_DISABLE_USER_MAPPING_PROV is not set diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_host.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_host.h index 0d435138b8a..67162a0ca28 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_host.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_host.h @@ -42,14 +42,14 @@ * \defgroup CDC_Serial_Host Host * @{ */ -bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_control_complete_cb_t complete_cb); +bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_control_xfer_cb_t complete_cb); -static inline bool tuh_cdc_connect(uint8_t dev_addr, tuh_control_complete_cb_t complete_cb) +static inline bool tuh_cdc_connect(uint8_t dev_addr, tuh_control_xfer_cb_t complete_cb) { return tuh_cdc_set_control_line_state(dev_addr, true, true, complete_cb); } -static inline bool tuh_cdc_disconnect(uint8_t dev_addr, tuh_control_complete_cb_t complete_cb) +static inline bool tuh_cdc_disconnect(uint8_t dev_addr, tuh_control_xfer_cb_t complete_cb) { return tuh_cdc_set_control_line_state(dev_addr, false, false, complete_cb); } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_rndis_host.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_rndis_host.h index 170cb3b0ece..447cc4e97f2 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_rndis_host.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_rndis_host.h @@ -50,7 +50,7 @@ typedef struct { }rndish_data_t; void rndish_init(void); -tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc); +bool rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc); void rndish_xfer_isr(cdch_data_t *p_cdc, pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes); void rndish_close(uint8_t dev_addr); diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/vendor/vendor_host.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/vendor/vendor_host.h index 07fa56c61b0..65223fbca07 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/vendor/vendor_host.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/vendor/vendor_host.h @@ -49,16 +49,16 @@ static inline bool tusbh_custom_is_mounted(uint8_t dev_addr, uint16_t vendor_id, return false; } -tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length); -tusb_error_t tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void const * p_data, uint16_t length); +bool tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length); +bool tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void const * p_data, uint16_t length); //--------------------------------------------------------------------+ // Internal Class Driver API //--------------------------------------------------------------------+ -void cush_init(void); -tusb_error_t cush_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length); -void cush_isr(pipe_handle_t pipe_hdl, xfer_result_t event); -void cush_close(uint8_t dev_addr); +void cush_init(void); +bool cush_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length); +void cush_isr(pipe_handle_t pipe_hdl, xfer_result_t event); +void cush_close(uint8_t dev_addr); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h index 26865805e70..58591f0bea0 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h @@ -71,23 +71,10 @@ #include "tusb_compiler.h" #include "tusb_verify.h" #include "tusb_types.h" +#include "tusb_debug.h" -#include "tusb_error.h" // TODO remove #include "tusb_timeout.h" // TODO remove -//--------------------------------------------------------------------+ -// Internal Helper used by Host and Device Stack -//--------------------------------------------------------------------+ - -// Check if endpoint descriptor is valid per USB specs -bool tu_edpt_validate(tusb_desc_endpoint_t const * desc_ep, tusb_speed_t speed); - -// Bind all endpoint of a interface descriptor to class driver -void tu_edpt_bind_driver(uint8_t ep2drv[][2], tusb_desc_interface_t const* p_desc, uint16_t desc_len, uint8_t driver_id); - -// Calculate total length of n interfaces (depending on IAD) -uint16_t tu_desc_get_interface_total_len(tusb_desc_interface_t const* desc_itf, uint8_t itf_count, uint16_t max_len); - //--------------------------------------------------------------------+ // Internal Inline Functions //--------------------------------------------------------------------+ @@ -268,138 +255,6 @@ TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write16 (void* mem, ui + TU_BIN8(dlsb)) #endif -//--------------------------------------------------------------------+ -// Debug Function -//--------------------------------------------------------------------+ - -// CFG_TUSB_DEBUG for debugging -// 0 : no debug -// 1 : print error -// 2 : print warning -// 3 : print info -#if CFG_TUSB_DEBUG - -void tu_print_mem(void const *buf, uint32_t count, uint8_t indent); - -#ifdef CFG_TUSB_DEBUG_PRINTF - extern int CFG_TUSB_DEBUG_PRINTF(const char *format, ...); - #define tu_printf CFG_TUSB_DEBUG_PRINTF -#else - #define tu_printf printf -#endif - -static inline -void tu_print_var(uint8_t const* buf, uint32_t bufsize) -{ - for(uint32_t i=0; i= 2 - #define TU_LOG2 TU_LOG1 - #define TU_LOG2_MEM TU_LOG1_MEM - #define TU_LOG2_VAR TU_LOG1_VAR - #define TU_LOG2_INT TU_LOG1_INT - #define TU_LOG2_HEX TU_LOG1_HEX -#endif - -// Log Level 3: Info -#if CFG_TUSB_DEBUG >= 3 - #define TU_LOG3 TU_LOG1 - #define TU_LOG3_MEM TU_LOG1_MEM - #define TU_LOG3_VAR TU_LOG1_VAR - #define TU_LOG3_INT TU_LOG1_INT - #define TU_LOG3_HEX TU_LOG1_HEX -#endif - -typedef struct -{ - uint32_t key; - const char* data; -} tu_lookup_entry_t; - -typedef struct -{ - uint16_t count; - tu_lookup_entry_t const* items; -} tu_lookup_table_t; - -static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint32_t key) -{ - static char not_found[11]; - - for(uint16_t i=0; icount; i++) - { - if (p_table->items[i].key == key) return p_table->items[i].data; - } - - // not found return the key value in hex - snprintf(not_found, sizeof(not_found), "0x%08lX", (unsigned long) key); - - return not_found; -} - -#endif // CFG_TUSB_DEBUG - -#ifndef TU_LOG -#define TU_LOG(n, ...) -#define TU_LOG_MEM(n, ...) -#define TU_LOG_VAR(n, ...) -#define TU_LOG_INT(n, ...) -#define TU_LOG_HEX(n, ...) -#define TU_LOG_LOCATION() -#define TU_LOG_FAILED() -#endif - -// TODO replace all TU_LOGn with TU_LOG(n) - -#define TU_LOG0(...) -#define TU_LOG0_MEM(...) -#define TU_LOG0_VAR(...) -#define TU_LOG0_INT(...) -#define TU_LOG0_HEX(...) - - -#ifndef TU_LOG1 - #define TU_LOG1(...) - #define TU_LOG1_MEM(...) - #define TU_LOG1_VAR(...) - #define TU_LOG1_INT(...) - #define TU_LOG1_HEX(...) -#endif - -#ifndef TU_LOG2 - #define TU_LOG2(...) - #define TU_LOG2_MEM(...) - #define TU_LOG2_VAR(...) - #define TU_LOG2_INT(...) - #define TU_LOG2_HEX(...) -#endif - -#ifndef TU_LOG3 - #define TU_LOG3(...) - #define TU_LOG3_MEM(...) - #define TU_LOG3_VAR(...) - #define TU_LOG3_INT(...) - #define TU_LOG3_HEX(...) -#endif - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h new file mode 100644 index 00000000000..647e8a8db5d --- /dev/null +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h @@ -0,0 +1,174 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2022, Ha Thach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * This file is part of the TinyUSB stack. + */ + +#ifndef _TUSB_DEBUG_H_ +#define _TUSB_DEBUG_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +//--------------------------------------------------------------------+ +// Debug +//--------------------------------------------------------------------+ + +// CFG_TUSB_DEBUG for debugging +// 0 : no debug +// 1 : print error +// 2 : print warning +// 3 : print info +#if CFG_TUSB_DEBUG + +// Enum to String for debugging purposes +#if CFG_TUSB_DEBUG >= 2 +extern char const* const tu_str_speed[]; +extern char const* const tu_str_std_request[]; +#endif + +void tu_print_mem(void const *buf, uint32_t count, uint8_t indent); + +#ifdef CFG_TUSB_DEBUG_PRINTF + extern int CFG_TUSB_DEBUG_PRINTF(const char *format, ...); + #define tu_printf CFG_TUSB_DEBUG_PRINTF +#else + #define tu_printf printf +#endif + +static inline void tu_print_var(uint8_t const* buf, uint32_t bufsize) +{ + for(uint32_t i=0; i= 2 + #define TU_LOG2 TU_LOG1 + #define TU_LOG2_MEM TU_LOG1_MEM + #define TU_LOG2_VAR TU_LOG1_VAR + #define TU_LOG2_INT TU_LOG1_INT + #define TU_LOG2_HEX TU_LOG1_HEX +#endif + +// Log Level 3: Info +#if CFG_TUSB_DEBUG >= 3 + #define TU_LOG3 TU_LOG1 + #define TU_LOG3_MEM TU_LOG1_MEM + #define TU_LOG3_VAR TU_LOG1_VAR + #define TU_LOG3_INT TU_LOG1_INT + #define TU_LOG3_HEX TU_LOG1_HEX +#endif + +typedef struct +{ + uint32_t key; + const char* data; +} tu_lookup_entry_t; + +typedef struct +{ + uint16_t count; + tu_lookup_entry_t const* items; +} tu_lookup_table_t; + +static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint32_t key) +{ + static char not_found[11]; + + for(uint16_t i=0; icount; i++) + { + if (p_table->items[i].key == key) return p_table->items[i].data; + } + + // not found return the key value in hex + snprintf(not_found, sizeof(not_found), "0x%08lX", (unsigned long) key); + + return not_found; +} + +#endif // CFG_TUSB_DEBUG + +#ifndef TU_LOG + #define TU_LOG(n, ...) + #define TU_LOG_MEM(n, ...) + #define TU_LOG_VAR(n, ...) + #define TU_LOG_INT(n, ...) + #define TU_LOG_HEX(n, ...) + #define TU_LOG_LOCATION() + #define TU_LOG_FAILED() +#endif + +// TODO replace all TU_LOGn with TU_LOG(n) + +#define TU_LOG0(...) +#define TU_LOG0_MEM(...) +#define TU_LOG0_VAR(...) +#define TU_LOG0_INT(...) +#define TU_LOG0_HEX(...) + +#ifndef TU_LOG1 + #define TU_LOG1(...) + #define TU_LOG1_MEM(...) + #define TU_LOG1_VAR(...) + #define TU_LOG1_INT(...) + #define TU_LOG1_HEX(...) +#endif + +#ifndef TU_LOG2 + #define TU_LOG2(...) + #define TU_LOG2_MEM(...) + #define TU_LOG2_VAR(...) + #define TU_LOG2_INT(...) + #define TU_LOG2_HEX(...) +#endif + +#ifndef TU_LOG3 + #define TU_LOG3(...) + #define TU_LOG3_MEM(...) + #define TU_LOG3_VAR(...) + #define TU_LOG3_INT(...) + #define TU_LOG3_HEX(...) +#endif + +#ifdef __cplusplus + } +#endif + +#endif /* _TUSB_DEBUG_H_ */ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_error.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_error.h deleted file mode 100644 index 42541acd678..00000000000 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_error.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -/** \ingroup Group_Common - * \defgroup Group_Error Error Codes - * @{ */ - -#ifndef _TUSB_ERRORS_H_ -#define _TUSB_ERRORS_H_ - -#include "tusb_option.h" - -#ifdef __cplusplus - extern "C" { -#endif - -#define ERROR_ENUM(x) x, -#define ERROR_STRING(x) #x, - -#define ERROR_TABLE(ENTRY) \ - ENTRY(TUSB_ERROR_NONE )\ - ENTRY(TUSB_ERROR_INVALID_PARA )\ - ENTRY(TUSB_ERROR_DEVICE_NOT_READY )\ - ENTRY(TUSB_ERROR_INTERFACE_IS_BUSY )\ - ENTRY(TUSB_ERROR_HCD_OPEN_PIPE_FAILED )\ - ENTRY(TUSB_ERROR_OSAL_TIMEOUT )\ - ENTRY(TUSB_ERROR_CDCH_DEVICE_NOT_MOUNTED )\ - ENTRY(TUSB_ERROR_MSCH_DEVICE_NOT_MOUNTED )\ - ENTRY(TUSB_ERROR_NOT_SUPPORTED )\ - ENTRY(TUSB_ERROR_NOT_ENOUGH_MEMORY )\ - ENTRY(TUSB_ERROR_FAILED )\ - -/// \brief Error Code returned -/// TODO obsolete and to be remove -typedef enum -{ - ERROR_TABLE(ERROR_ENUM) - TUSB_ERROR_COUNT -}tusb_error_t; - -#if CFG_TUSB_DEBUG -/// Enum to String for debugging purposes. Only available if \ref CFG_TUSB_DEBUG > 0 -extern char const* const tusb_strerr[TUSB_ERROR_COUNT]; -extern char const* const tusb_speed_str[]; - -#endif - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_ERRORS_H_ */ - -/** @} */ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_private.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_private.h new file mode 100644 index 00000000000..b34506f6500 --- /dev/null +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_private.h @@ -0,0 +1,65 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2022, Ha Thach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * This file is part of the TinyUSB stack. + */ + + +#ifndef _TUSB_PRIVATE_H_ +#define _TUSB_PRIVATE_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +typedef struct TU_ATTR_PACKED +{ + volatile uint8_t busy : 1; + volatile uint8_t stalled : 1; + volatile uint8_t claimed : 1; +}tu_edpt_state_t; + +//--------------------------------------------------------------------+ +// Internal Helper used by Host and Device Stack +//--------------------------------------------------------------------+ + +// Check if endpoint descriptor is valid per USB specs +bool tu_edpt_validate(tusb_desc_endpoint_t const * desc_ep, tusb_speed_t speed); + +// Bind all endpoint of a interface descriptor to class driver +void tu_edpt_bind_driver(uint8_t ep2drv[][2], tusb_desc_interface_t const* p_desc, uint16_t desc_len, uint8_t driver_id); + +// Calculate total length of n interfaces (depending on IAD) +uint16_t tu_desc_get_interface_total_len(tusb_desc_interface_t const* desc_itf, uint8_t itf_count, uint16_t max_len); + +// Claim an endpoint with provided mutex +bool tu_edpt_claim(tu_edpt_state_t* ep_state, osal_mutex_t mutex); + +// Release an endpoint with provided mutex +bool tu_edpt_release(tu_edpt_state_t* ep_state, osal_mutex_t mutex); + +#ifdef __cplusplus + } +#endif + +#endif /* _TUSB_PRIVATE_H_ */ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h index 5b26f5aece2..e2fa175327f 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h @@ -223,19 +223,13 @@ enum { #define TUSB_DESC_CONFIG_POWER_MA(x) ((x)/2) -/// Device State TODO remove -typedef enum -{ - TUSB_DEVICE_STATE_UNPLUG = 0 , - TUSB_DEVICE_STATE_CONFIGURED , - TUSB_DEVICE_STATE_SUSPENDED , -}tusb_device_state_t; - typedef enum { XFER_RESULT_SUCCESS, XFER_RESULT_FAILED, XFER_RESULT_STALLED, + XFER_RESULT_TIMEOUT, + XFER_RESULT_INVALID }xfer_result_t; enum // TODO remove @@ -265,6 +259,7 @@ typedef enum enum { + CONTROL_STAGE_IDLE, CONTROL_STAGE_SETUP, CONTROL_STAGE_DATA, CONTROL_STAGE_ACK diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h index 8fef11dc720..f4a08ce2f91 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h @@ -74,10 +74,8 @@ #if CFG_TUSB_DEBUG #include - #define _MESS_ERR(_err) tu_printf("%s %d: failed, error = %s\r\n", __func__, __LINE__, tusb_strerr[_err]) #define _MESS_FAILED() tu_printf("%s %d: ASSERT FAILED\r\n", __func__, __LINE__) #else - #define _MESS_ERR(_err) do {} while (0) #define _MESS_FAILED() do {} while (0) #endif @@ -144,32 +142,6 @@ #define TU_ASSERT(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_2ARGS, ASSERT_1ARGS,UNUSED)(__VA_ARGS__) #endif -// TODO remove TU_ASSERT_ERR() later - -/*------------- Generator for TU_VERIFY_ERR and TU_VERIFY_ERR_HDLR -------------*/ -#define TU_VERIFY_ERR_DEF2(_error, _handler) do \ -{ \ - uint32_t _err = (uint32_t)(_error); \ - if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _err; } \ -} while(0) - -#define TU_VERIFY_ERR_DEF3(_error, _handler, _ret) do \ -{ \ - uint32_t _err = (uint32_t)(_error); \ - if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _ret; } \ -} while(0) - -/*------------------------------------------------------------------*/ -/* ASSERT Error - * basically TU_VERIFY Error with TU_BREAKPOINT() as handler - *------------------------------------------------------------------*/ -#define ASSERT_ERR_1ARGS(_error) TU_VERIFY_ERR_DEF2(_error, TU_BREAKPOINT()) -#define ASSERT_ERR_2ARGS(_error, _ret) TU_VERIFY_ERR_DEF3(_error, TU_BREAKPOINT(), _ret) - -#ifndef TU_ASSERT_ERR -#define TU_ASSERT_ERR(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_ERR_2ARGS, ASSERT_ERR_1ARGS,UNUSED)(__VA_ARGS__) -#endif - /*------------------------------------------------------------------*/ /* ASSERT HDLR *------------------------------------------------------------------*/ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h index dae95cebbe5..29753451ebc 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h @@ -80,7 +80,7 @@ bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16 // If caller does not make any transfer, it must release endpoint for others. bool usbd_edpt_claim(uint8_t rhport, uint8_t ep_addr); -// Release an endpoint without submitting a transfer +// Release claimed endpoint without submitting a transfer bool usbd_edpt_release(uint8_t rhport, uint8_t ep_addr); // Check if endpoint is busy transferring diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd.h index 9819f5f2a8c..c40bea64cec 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd.h @@ -94,7 +94,8 @@ typedef struct } hcd_event_t; -typedef struct { +typedef struct +{ uint8_t rhport; uint8_t hub_addr; uint8_t hub_port; diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hub.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hub.h index c4d5441933e..30cf3dd1c33 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hub.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hub.h @@ -171,12 +171,35 @@ typedef struct { TU_VERIFY_STATIC( sizeof(hub_port_status_response_t) == 4, "size is not correct"); -bool hub_port_clear_feature(uint8_t hub_addr, uint8_t hub_port, uint8_t feature, tuh_control_complete_cb_t complete_cb); -bool hub_port_set_feature(uint8_t hub_addr, uint8_t hub_port, uint8_t feature, tuh_control_complete_cb_t complete_cb); +// Clear feature +bool hub_port_clear_feature (uint8_t hub_addr, uint8_t hub_port, uint8_t feature, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Set feature +bool hub_port_set_feature (uint8_t hub_addr, uint8_t hub_port, uint8_t feature, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get port status +bool hub_port_get_status (uint8_t hub_addr, uint8_t hub_port, void* resp, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get status from Interrupt endpoint +bool hub_edpt_status_xfer(uint8_t dev_addr); + +// Reset a port +static inline bool hub_port_reset(uint8_t hub_addr, uint8_t hub_port, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg) +{ + return hub_port_set_feature(hub_addr, hub_port, HUB_FEATURE_PORT_RESET, complete_cb, user_arg); +} + +// Clear Reset Change +static inline bool hub_port_clear_reset_change(uint8_t hub_addr, uint8_t hub_port, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg) +{ + return hub_port_clear_feature(hub_addr, hub_port, HUB_FEATURE_PORT_RESET_CHANGE, complete_cb, user_arg); +} -bool hub_port_reset(uint8_t hub_addr, uint8_t hub_port, tuh_control_complete_cb_t complete_cb); -bool hub_port_get_status(uint8_t hub_addr, uint8_t hub_port, void* resp, tuh_control_complete_cb_t complete_cb); -bool hub_status_pipe_queue(uint8_t dev_addr); //--------------------------------------------------------------------+ // Internal Class Driver API diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh.h index 9465d1d1bc7..3bd40c50d67 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh.h @@ -38,7 +38,31 @@ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ -typedef bool (*tuh_control_complete_cb_t)(uint8_t daddr, tusb_control_request_t const * request, xfer_result_t result); +// forward declaration +struct tuh_control_xfer_s; +typedef struct tuh_control_xfer_s tuh_control_xfer_t; + +typedef bool (*tuh_control_xfer_cb_t)(uint8_t daddr, tuh_control_xfer_t const * xfer, xfer_result_t result); + +struct tuh_control_xfer_s +{ + tusb_control_request_t request TU_ATTR_ALIGNED(4); + uint8_t* buffer; + tuh_control_xfer_cb_t complete_cb; + uintptr_t user_arg; +}; + +//--------------------------------------------------------------------+ +// APPLICATION CALLBACK +//--------------------------------------------------------------------+ + +//TU_ATTR_WEAK uint8_t tuh_attach_cb (tusb_desc_device_t const *desc_device); + +// Invoked when device is mounted (configured) +TU_ATTR_WEAK void tuh_mount_cb (uint8_t daddr); + +/// Invoked when device is unmounted (bus reset/unplugged) +TU_ATTR_WEAK void tuh_umount_cb(uint8_t daddr); //--------------------------------------------------------------------+ // APPLICATION API @@ -80,48 +104,102 @@ static inline bool tuh_ready(uint8_t daddr) return tuh_mounted(daddr) && !tuh_suspended(daddr); } -// Carry out control transfer -bool tuh_control_xfer (uint8_t daddr, tusb_control_request_t const* request, void* buffer, tuh_control_complete_cb_t complete_cb); +// Carry out a control transfer +// true on success, false if there is on-going control transfer or incorrect parameters +// Blocking if complete callback is NULL, in this case 'user_arg' must contain xfer_result_t variable +bool tuh_control_xfer (uint8_t daddr, tuh_control_xfer_t const* xfer); + +// Sync (blocking) version of tuh_control_xfer() +// return transfer result +uint8_t tuh_control_xfer_sync(uint8_t daddr, tuh_control_xfer_t const* xfer, uint32_t timeout_ms); -// Set Configuration +// Set Configuration (control transfer) // config_num = 0 will un-configure device. Note: config_num = config_descriptor_index + 1 -bool tuh_configuration_set(uint8_t daddr, uint8_t config_num, tuh_control_complete_cb_t complete_cb); +// true on success, false if there is on-going control transfer or incorrect parameters +// Blocking if complete callback is NULL, in this case 'user_arg' must contain xfer_result_t variable +bool tuh_configuration_set(uint8_t daddr, uint8_t config_num, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); -//------------- descriptors -------------// +//--------------------------------------------------------------------+ +// Descriptors Asynchronous (non-blocking) +//--------------------------------------------------------------------+ -// Get an descriptor -bool tuh_descriptor_get(uint8_t daddr, uint8_t type, uint8_t index, - void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +// Get an descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get(uint8_t daddr, uint8_t type, uint8_t index, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get device descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get_device(uint8_t daddr, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get configuration descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get_configuration(uint8_t daddr, uint8_t index, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get HID report descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get_hid_report(uint8_t daddr, uint8_t itf_num, uint8_t desc_type, uint8_t index, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get string descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +// Blocking if complete callback is NULL, in this case 'user_arg' must contain xfer_result_t variable +bool tuh_descriptor_get_string(uint8_t daddr, uint8_t index, uint16_t language_id, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get manufacturer string descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get_manufacturer_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get product string descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get_product_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get serial string descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get_serial_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); -// Get device descriptor -bool tuh_descriptor_device_get(uint8_t daddr, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +//--------------------------------------------------------------------+ +// Descriptors Synchronous (blocking) +//--------------------------------------------------------------------+ -// Get configuration descriptor -bool tuh_descriptor_configuration_get(uint8_t daddr, uint8_t index, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +// Sync (blocking) version of tuh_descriptor_get() +// return transfer result +uint8_t tuh_descriptor_get_sync(uint8_t daddr, uint8_t type, uint8_t index, void* buffer, uint16_t len, uint8_t timeout_ms); -// Get string descriptor -bool tuh_descriptor_string_get(uint8_t daddr, uint16_t language_id, uint8_t index, - void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +// Sync (blocking) version of tuh_descriptor_get_device() +// return transfer result +uint8_t tuh_descriptor_get_device_sync(uint8_t daddr, void* buffer, uint16_t len, uint8_t timeout_ms); -// Get manufacturer string descriptor -bool tuh_descriptor_string_manufacturer_get(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +// Sync (blocking) version of tuh_descriptor_get_configuration() +// return transfer result +uint8_t tuh_descriptor_get_configuration_sync(uint8_t daddr, uint8_t index, void* buffer, uint16_t len, uint8_t timeout_ms); -// Get product string descriptor -bool tuh_descriptor_string_product_get(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +// Sync (blocking) version of tuh_descriptor_get_hid_report() +// return transfer result +uint8_t tuh_descriptor_get_hid_report_sync(uint8_t daddr, uint8_t itf_num, uint8_t desc_type, uint8_t index, void* buffer, uint16_t len, uint8_t timeout_ms); -// Get serial string descriptor -bool tuh_descriptor_string_serial_get(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +// Sync (blocking) version of tuh_descriptor_get_string() +// return transfer result +uint8_t tuh_descriptor_get_string_sync(uint8_t daddr, uint8_t index, uint16_t language_id, void* buffer, uint16_t len, uint8_t timeout_ms); -//--------------------------------------------------------------------+ -// APPLICATION CALLBACK -//--------------------------------------------------------------------+ -//TU_ATTR_WEAK uint8_t tuh_attach_cb (tusb_desc_device_t const *desc_device); +// Sync (blocking) version of tuh_descriptor_get_manufacturer_string() +// return transfer result +uint8_t tuh_descriptor_get_manufacturer_string_sync(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, uint8_t timeout_ms); -// Invoked when device is mounted (configured) -TU_ATTR_WEAK void tuh_mount_cb (uint8_t daddr); +// Sync (blocking) version of tuh_descriptor_get_product_string() +// return transfer result +uint8_t tuh_descriptor_get_product_string_sync(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, uint8_t timeout_ms); -/// Invoked when device is unmounted (bus reset/unplugged) -TU_ATTR_WEAK void tuh_umount_cb(uint8_t daddr); +// Sync (blocking) version of tuh_descriptor_get_serial_string() +// return transfer result +uint8_t tuh_descriptor_get_serial_string_sync(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, uint8_t timeout_ms); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh_classdriver.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh_classdriver.h index 2f9957cc65a..0435eae701b 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh_classdriver.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh_classdriver.h @@ -73,6 +73,7 @@ bool usbh_edpt_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_ // If caller does not make any transfer, it must release endpoint for others. bool usbh_edpt_claim(uint8_t dev_addr, uint8_t ep_addr); +// Release claimed endpoint without submitting a transfer bool usbh_edpt_release(uint8_t dev_addr, uint8_t ep_addr); // Check if endpoint transferring is complete diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h index e1dd95c3400..4217f042225 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h @@ -111,7 +111,7 @@ typedef struct typedef osal_queue_def_t* osal_queue_t; -// role device/host is used by OS NONE for mutex (disable usb isr) only +// _int_set is used as mutex in OS NONE (disable/enable USB ISR) #define OSAL_QUEUE_DEF(_int_set, _name, _depth, _type) \ uint8_t _name##_buf[_depth*sizeof(_type)]; \ osal_queue_def_t _name = { \ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb.h index 549f00b4320..222855fcb6b 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb.h @@ -117,8 +117,6 @@ //--------------------------------------------------------------------+ // APPLICATION API //--------------------------------------------------------------------+ -/** \ingroup group_application_api - * @{ */ // Initialize device/host stack // Note: when using with RTOS, this should be called after scheduler/kernel is started. @@ -131,8 +129,6 @@ bool tusb_inited(void); // TODO // bool tusb_teardown(void); -/** @} */ - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h index afd69c38bfc..0352faaed6e 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h @@ -285,6 +285,9 @@ #define CFG_TUSB_OS_INC_PATH #endif +// mutex is only needed for RTOS TODO also required with multiple core MCUs +#define TUSB_OPT_MUTEX (CFG_TUSB_OS != OPT_OS_NONE) + //-------------------------------------------------------------------- // DEVICE OPTIONS //-------------------------------------------------------------------- diff --git a/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_core.h b/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_core.h index 6ddb0fbe912..f9d96be4ee6 100644 --- a/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_core.h +++ b/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_core.h @@ -49,6 +49,8 @@ typedef enum { RMAKER_EVENT_USER_NODE_MAPPING_DONE, /** Local control started. Associated data is the NULL terminated Service Name */ RMAKER_EVENT_LOCAL_CTRL_STARTED, + /* User reset request successfully sent to ESP RainMaker Cloud */ + RMAKER_EVENT_USER_NODE_MAPPING_RESET, } esp_rmaker_event_t; /** ESP RainMaker Node information */ diff --git a/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_user_mapping.h b/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_user_mapping.h index a763561f3c2..77a153b02f2 100644 --- a/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_user_mapping.h +++ b/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_user_mapping.h @@ -19,6 +19,25 @@ extern "C" { #endif +/** User-Node Mapping states */ +typedef enum { + /** Mapping does not exist or is not initialized */ + ESP_RMAKER_USER_MAPPING_RESET = 0, + /** Mapping has started */ + ESP_RMAKER_USER_MAPPING_STARTED, + /** Mapping is done */ + ESP_RMAKER_USER_MAPPING_DONE, +} esp_rmaker_user_mapping_state_t; + +/** + * Get User-Node mapping state + * + * This returns the current user-node mapping state. + * + * @return user mapping state + */ +esp_rmaker_user_mapping_state_t esp_rmaker_user_node_mapping_get_state(void); + /** * Create User Mapping Endpoint * diff --git a/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/portmacro.h b/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/portmacro.h index 934f056816c..2ee4c12c2b8 100644 --- a/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/portmacro.h +++ b/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/portmacro.h @@ -558,14 +558,14 @@ static inline void __attribute__((always_inline)) uxPortCompareSetExtram(volatil // --------------------- Interrupts ------------------------ -static inline UBaseType_t xPortSetInterruptMaskFromISR(void) +static inline UBaseType_t __attribute__((always_inline)) xPortSetInterruptMaskFromISR(void) { UBaseType_t prev_int_level = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); portbenchmarkINTERRUPT_DISABLE(); return prev_int_level; } -static inline void vPortClearInterruptMaskFromISR(UBaseType_t prev_level) +static inline void __attribute__((always_inline)) vPortClearInterruptMaskFromISR(UBaseType_t prev_level) { portbenchmarkINTERRUPT_RESTORE(prev_level); XTOS_RESTORE_JUST_INTLEVEL(prev_level); diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/gpio_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/gpio_ll.h index 572e4bc3262..1056230604a 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/gpio_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/gpio_ll.h @@ -390,7 +390,7 @@ static inline void gpio_ll_iomux_in(gpio_dev_t *hw, uint32_t gpio, uint32_t sign * @param pin_name Pin name to configure * @param func Function to assign to the pin */ -static inline void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func) +static inline __attribute__((always_inline)) void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func) { PIN_FUNC_SELECT(pin_name, func); } diff --git a/tools/sdk/esp32s2/include/hal/include/hal/emac_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/emac_hal.h index 4f332811aba..27cd38456dc 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/emac_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/emac_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -225,7 +225,7 @@ void emac_hal_start(emac_hal_context_t *hal); * @param hal EMAC HAL context infostructure * @return * - ESP_OK: succeed - * - ESP_ERR_INVALID_STATE: previous frame transmission is not completed. When this error occurs, + * - ESP_ERR_INVALID_STATE: previous frame transmission/reception is not completed. When this error occurs, * wait and reapeat the EMAC stop again. */ esp_err_t emac_hal_stop(emac_hal_context_t *hal); diff --git a/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_common_events.h b/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_common_events.h index 62c4b208759..b77f8a3d142 100644 --- a/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_common_events.h +++ b/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_common_events.h @@ -35,9 +35,26 @@ typedef enum { RMAKER_MQTT_EVENT_CONNECTED, /** Disconnected from MQTT Broker */ RMAKER_MQTT_EVENT_DISCONNECTED, - /** MQTT message published successfully */ + /** MQTT message published successfully. + * Event data will contain the message ID (integer) of published message. + */ RMAKER_MQTT_EVENT_PUBLISHED, -} esp_rmaker_mqtt_event_t; + /** POSIX Timezone Changed. Associated data would be NULL terminated POSIX Timezone + * Eg. "PST8PDT,M3.2.0,M11.1.0" */ + RMAKER_EVENT_TZ_POSIX_CHANGED, + /** Timezone Changed. Associated data would be NULL terminated Timezone. + * Eg. "America/Los_Angeles" + * Note that whenever this event is received, the RMAKER_EVENT_TZ_POSIX_CHANGED event + * will also be received, but not necessarily vice versa. + */ + RMAKER_EVENT_TZ_CHANGED, + /** + * MQTT message deleted from the outbox if the message couldn't have been sent and acknowledged. + * Event data will contain the message ID (integer) of deleted message. + * Valid only if CONFIG_MQTT_REPORT_DELETED_MESSAGES is enabled. + */ + RMAKER_MQTT_EVENT_MSG_DELETED, +} esp_rmaker_common_event_t; #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_mqtt_glue.h b/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_mqtt_glue.h index 8a9e1ae649d..95744bdf58c 100644 --- a/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_mqtt_glue.h +++ b/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_mqtt_glue.h @@ -52,7 +52,7 @@ typedef esp_rmaker_mqtt_conn_params_t *(*esp_rmaker_mqtt_get_conn_params_t)(void * @param[in] priv_data The private data passed during subscription */ typedef void (*esp_rmaker_mqtt_subscribe_cb_t)(const char *topic, void *payload, size_t payload_len, void *priv_data); - + /** MQTT Init function prototype * * @param[in] conn_params The MQTT connection parameters. If NULL is passed, it should internally use the @@ -63,6 +63,12 @@ typedef void (*esp_rmaker_mqtt_subscribe_cb_t)(const char *topic, void *payload, */ typedef esp_err_t (*esp_rmaker_mqtt_init_t)(esp_rmaker_mqtt_conn_params_t *conn_params); +/** MQTT Deinit function prototype + * + * Call this function after MQTT has disconnected. + */ +typedef void (*esp_rmaker_mqtt_deinit_t)(void); + /** MQTT Connect function prototype * * Starts the connection attempts to the MQTT broker. @@ -124,6 +130,8 @@ typedef struct { esp_rmaker_mqtt_get_conn_params_t get_conn_params; /** Pointer to MQTT Init function. */ esp_rmaker_mqtt_init_t init; + /** Pointer to MQTT Deinit function. */ + esp_rmaker_mqtt_deinit_t deinit; /** Pointer to MQTT Connect function. */ esp_rmaker_mqtt_connect_t connect; /** Pointer to MQTQ Disconnect function */ diff --git a/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_utils.h b/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_utils.h index 9a5ba16f0aa..86ab691d492 100644 --- a/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_utils.h +++ b/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_utils.h @@ -15,12 +15,24 @@ #include #include #include +#include +#include #ifdef __cplusplus extern "C" { #endif +#ifdef CONFIG_SPIRAM +#define MEM_ALLOC_EXTRAM(size) heap_caps_malloc(size, MALLOC_CAP_SPIRAM) +#define MEM_CALLOC_EXTRAM(num, size) heap_caps_calloc(num, size, MALLOC_CAP_SPIRAM) +#define MEM_REALLOC_EXTRAM(ptr, size) heap_caps_realloc(ptr, size, MALLOC_CAP_SPIRAM) +#else +#define MEM_ALLOC_EXTRAM(size) malloc(size) +#define MEM_CALLOC_EXTRAM(num, size) calloc(num, size) +#define MEM_REALLOC_EXTRAM(ptr, size) realloc(ptr, size) +#endif + typedef struct esp_rmaker_time_config { /** If not specified, then 'CONFIG_ESP_RMAKER_SNTP_SERVER_NAME' is used as the SNTP server. */ char *sntp_server_name; diff --git a/tools/sdk/esp32s2/lib/libapp_trace.a b/tools/sdk/esp32s2/lib/libapp_trace.a index 577f81bbf8e..43038ca105b 100644 Binary files a/tools/sdk/esp32s2/lib/libapp_trace.a and b/tools/sdk/esp32s2/lib/libapp_trace.a differ diff --git a/tools/sdk/esp32s2/lib/libapp_update.a b/tools/sdk/esp32s2/lib/libapp_update.a index 648914b6a33..a468af8a72e 100644 Binary files a/tools/sdk/esp32s2/lib/libapp_update.a and b/tools/sdk/esp32s2/lib/libapp_update.a differ diff --git a/tools/sdk/esp32s2/lib/libarduino_tinyusb.a b/tools/sdk/esp32s2/lib/libarduino_tinyusb.a index dbffee69cdf..1bbc5337dd0 100644 Binary files a/tools/sdk/esp32s2/lib/libarduino_tinyusb.a and b/tools/sdk/esp32s2/lib/libarduino_tinyusb.a differ diff --git a/tools/sdk/esp32s2/lib/libbutton.a b/tools/sdk/esp32s2/lib/libbutton.a index 529c16c89d0..f047ab99477 100644 Binary files a/tools/sdk/esp32s2/lib/libbutton.a and b/tools/sdk/esp32s2/lib/libbutton.a differ diff --git a/tools/sdk/esp32s2/lib/libcoap.a b/tools/sdk/esp32s2/lib/libcoap.a index 0cceba865a8..23dd2586d65 100644 Binary files a/tools/sdk/esp32s2/lib/libcoap.a and b/tools/sdk/esp32s2/lib/libcoap.a differ diff --git a/tools/sdk/esp32s2/lib/libdriver.a b/tools/sdk/esp32s2/lib/libdriver.a index 5f8b0f23131..0c1ba43f71e 100644 Binary files a/tools/sdk/esp32s2/lib/libdriver.a and b/tools/sdk/esp32s2/lib/libdriver.a differ diff --git a/tools/sdk/esp32s2/lib/libesp-tls.a b/tools/sdk/esp32s2/lib/libesp-tls.a index b7c2b87c784..461ea572fc9 100644 Binary files a/tools/sdk/esp32s2/lib/libesp-tls.a and b/tools/sdk/esp32s2/lib/libesp-tls.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_eth.a b/tools/sdk/esp32s2/lib/libesp_eth.a index 47a1d13f576..6c3bca706b4 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_eth.a and b/tools/sdk/esp32s2/lib/libesp_eth.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_http_client.a b/tools/sdk/esp32s2/lib/libesp_http_client.a index 7373d1b575a..b5c14b722f2 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_http_client.a and b/tools/sdk/esp32s2/lib/libesp_http_client.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_http_server.a b/tools/sdk/esp32s2/lib/libesp_http_server.a index b60ab0ecaf4..21f6fe1ba5a 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_http_server.a and b/tools/sdk/esp32s2/lib/libesp_http_server.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_https_server.a b/tools/sdk/esp32s2/lib/libesp_https_server.a index 611e644d0b1..29f87457fcd 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_https_server.a and b/tools/sdk/esp32s2/lib/libesp_https_server.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_lcd.a b/tools/sdk/esp32s2/lib/libesp_lcd.a index 420ab94fe4d..7d6696694fe 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_lcd.a and b/tools/sdk/esp32s2/lib/libesp_lcd.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_local_ctrl.a b/tools/sdk/esp32s2/lib/libesp_local_ctrl.a index 248d389c492..cca01502157 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_local_ctrl.a and b/tools/sdk/esp32s2/lib/libesp_local_ctrl.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_pm.a b/tools/sdk/esp32s2/lib/libesp_pm.a index 518ada5213d..64d6c97b5cb 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_pm.a and b/tools/sdk/esp32s2/lib/libesp_pm.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_rainmaker.a b/tools/sdk/esp32s2/lib/libesp_rainmaker.a index 2e28e4627bb..02849c43f80 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_rainmaker.a and b/tools/sdk/esp32s2/lib/libesp_rainmaker.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_websocket_client.a b/tools/sdk/esp32s2/lib/libesp_websocket_client.a index 008c1581216..8f508a3ef8c 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_websocket_client.a and b/tools/sdk/esp32s2/lib/libesp_websocket_client.a differ diff --git a/tools/sdk/esp32s2/lib/libfreemodbus.a b/tools/sdk/esp32s2/lib/libfreemodbus.a index c1d3a96419b..1263fb7b2c6 100644 Binary files a/tools/sdk/esp32s2/lib/libfreemodbus.a and b/tools/sdk/esp32s2/lib/libfreemodbus.a differ diff --git a/tools/sdk/esp32s2/lib/liblibsodium.a b/tools/sdk/esp32s2/lib/liblibsodium.a index 5e0a9407d81..542d53566b4 100644 Binary files a/tools/sdk/esp32s2/lib/liblibsodium.a and b/tools/sdk/esp32s2/lib/liblibsodium.a differ diff --git a/tools/sdk/esp32s2/lib/libmbedcrypto.a b/tools/sdk/esp32s2/lib/libmbedcrypto.a index f5a635bb161..ec46a1ac08a 100644 Binary files a/tools/sdk/esp32s2/lib/libmbedcrypto.a and b/tools/sdk/esp32s2/lib/libmbedcrypto.a differ diff --git a/tools/sdk/esp32s2/lib/libmbedtls.a b/tools/sdk/esp32s2/lib/libmbedtls.a index 5c57d3eb8ca..7097ba509bd 100644 Binary files a/tools/sdk/esp32s2/lib/libmbedtls.a and b/tools/sdk/esp32s2/lib/libmbedtls.a differ diff --git a/tools/sdk/esp32s2/lib/libmbedx509.a b/tools/sdk/esp32s2/lib/libmbedx509.a index 896fc5c104b..64671495b3a 100644 Binary files a/tools/sdk/esp32s2/lib/libmbedx509.a and b/tools/sdk/esp32s2/lib/libmbedx509.a differ diff --git a/tools/sdk/esp32s2/lib/libmqtt.a b/tools/sdk/esp32s2/lib/libmqtt.a index 3b0df3b9977..1a64dff84fa 100644 Binary files a/tools/sdk/esp32s2/lib/libmqtt.a and b/tools/sdk/esp32s2/lib/libmqtt.a differ diff --git a/tools/sdk/esp32s2/lib/libnewlib.a b/tools/sdk/esp32s2/lib/libnewlib.a index f089d1582d7..38654df0e66 100644 Binary files a/tools/sdk/esp32s2/lib/libnewlib.a and b/tools/sdk/esp32s2/lib/libnewlib.a differ diff --git a/tools/sdk/esp32s2/lib/libopenssl.a b/tools/sdk/esp32s2/lib/libopenssl.a index 6725f2c6093..67a3dade2c9 100644 Binary files a/tools/sdk/esp32s2/lib/libopenssl.a and b/tools/sdk/esp32s2/lib/libopenssl.a differ diff --git a/tools/sdk/esp32s2/lib/libprotocomm.a b/tools/sdk/esp32s2/lib/libprotocomm.a index e8c5c9531bf..53ea6aa572e 100644 Binary files a/tools/sdk/esp32s2/lib/libprotocomm.a and b/tools/sdk/esp32s2/lib/libprotocomm.a differ diff --git a/tools/sdk/esp32s2/lib/librmaker_common.a b/tools/sdk/esp32s2/lib/librmaker_common.a index 468c202d49f..7a5571a06d8 100644 Binary files a/tools/sdk/esp32s2/lib/librmaker_common.a and b/tools/sdk/esp32s2/lib/librmaker_common.a differ diff --git a/tools/sdk/esp32s2/lib/libtcp_transport.a b/tools/sdk/esp32s2/lib/libtcp_transport.a index f7921caedba..5f1fdff06ba 100644 Binary files a/tools/sdk/esp32s2/lib/libtcp_transport.a and b/tools/sdk/esp32s2/lib/libtcp_transport.a differ diff --git a/tools/sdk/esp32s2/lib/libwpa_supplicant.a b/tools/sdk/esp32s2/lib/libwpa_supplicant.a index e8afafd2bc4..a6462b70aa1 100644 Binary files a/tools/sdk/esp32s2/lib/libwpa_supplicant.a and b/tools/sdk/esp32s2/lib/libwpa_supplicant.a differ diff --git a/tools/sdk/esp32s2/qspi_qspi/include/sdkconfig.h b/tools/sdk/esp32s2/qspi_qspi/include/sdkconfig.h index 942482f8038..7018c51532b 100644 --- a/tools/sdk/esp32s2/qspi_qspi/include/sdkconfig.h +++ b/tools/sdk/esp32s2/qspi_qspi/include/sdkconfig.h @@ -52,6 +52,7 @@ #define CONFIG_LIB_BUILDER_FLASHMODE "qio" #define CONFIG_LIB_BUILDER_FLASHFREQ "80m" #define CONFIG_ESP_RMAKER_SELF_CLAIM 1 +#define CONFIG_ESP_RMAKER_CLAIM_TYPE 1 #define CONFIG_ESP_RMAKER_CLAIM_SERVICE_BASE_URL "https://esp-claiming.rainmaker.espressif.com" #define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" #define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024 @@ -287,7 +288,6 @@ #define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2 #define CONFIG_HEAP_POISONING_LIGHT 1 #define CONFIG_HEAP_TRACING_OFF 1 -#define CONFIG_LIBSODIUM_USE_MBEDTLS_SHA 1 #define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1 #define CONFIG_LOG_DEFAULT_LEVEL 1 #define CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT 1 @@ -357,6 +357,8 @@ #define CONFIG_MBEDTLS_HARDWARE_AES 1 #define CONFIG_MBEDTLS_AES_USE_INTERRUPT 1 #define CONFIG_MBEDTLS_HARDWARE_GCM 1 +#define CONFIG_MBEDTLS_HARDWARE_MPI 1 +#define CONFIG_MBEDTLS_HARDWARE_SHA 1 #define CONFIG_MBEDTLS_ROM_MD5 1 #define CONFIG_MBEDTLS_HAVE_TIME 1 #define CONFIG_MBEDTLS_ECDSA_DETERMINISTIC 1 diff --git a/tools/sdk/esp32s2/qspi_qspi/libbootloader_support.a b/tools/sdk/esp32s2/qspi_qspi/libbootloader_support.a index 85a29722d63..f5e705a2157 100644 Binary files a/tools/sdk/esp32s2/qspi_qspi/libbootloader_support.a and b/tools/sdk/esp32s2/qspi_qspi/libbootloader_support.a differ diff --git a/tools/sdk/esp32s2/qspi_qspi/libesp_system.a b/tools/sdk/esp32s2/qspi_qspi/libesp_system.a index 03891e7729e..0c1b0c74f26 100644 Binary files a/tools/sdk/esp32s2/qspi_qspi/libesp_system.a and b/tools/sdk/esp32s2/qspi_qspi/libesp_system.a differ diff --git a/tools/sdk/esp32s2/qspi_qspi/libfreertos.a b/tools/sdk/esp32s2/qspi_qspi/libfreertos.a index 3d89b7421bd..2c1ddde0e49 100644 Binary files a/tools/sdk/esp32s2/qspi_qspi/libfreertos.a and b/tools/sdk/esp32s2/qspi_qspi/libfreertos.a differ diff --git a/tools/sdk/esp32s2/qspi_qspi/libspi_flash.a b/tools/sdk/esp32s2/qspi_qspi/libspi_flash.a index 8a3f7e84b0b..2ce9db81b77 100644 Binary files a/tools/sdk/esp32s2/qspi_qspi/libspi_flash.a and b/tools/sdk/esp32s2/qspi_qspi/libspi_flash.a differ diff --git a/tools/sdk/esp32s2/qspi_qspi/sections.ld b/tools/sdk/esp32s2/qspi_qspi/sections.ld index 71601754293..3d57be82afb 100644 --- a/tools/sdk/esp32s2/qspi_qspi/sections.ld +++ b/tools/sdk/esp32s2/qspi_qspi/sections.ld @@ -374,8 +374,8 @@ SECTIONS *(.ext_ram.bss*) *(.bss .bss.*) - *(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb .gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2 .sbss2.* .scommon .share.mem) *(.ext_ram.bss .ext_ram.bss.*) + *(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb .gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2 .sbss2.* .scommon .share.mem) *(COMMON) _bt_bss_start = ABSOLUTE(.); *libbt.a:(.bss .bss.* COMMON) diff --git a/tools/sdk/esp32s2/sdkconfig b/tools/sdk/esp32s2/sdkconfig index 95826e06010..4aa42bee716 100644 --- a/tools/sdk/esp32s2/sdkconfig +++ b/tools/sdk/esp32s2/sdkconfig @@ -144,7 +144,9 @@ CONFIG_LIB_BUILDER_FLASHFREQ="80m" # # ESP RainMaker Config # +# CONFIG_ESP_RMAKER_NO_CLAIM is not set CONFIG_ESP_RMAKER_SELF_CLAIM=y +CONFIG_ESP_RMAKER_CLAIM_TYPE=1 CONFIG_ESP_RMAKER_CLAIM_SERVICE_BASE_URL="https://esp-claiming.rainmaker.espressif.com" CONFIG_ESP_RMAKER_MQTT_HOST="a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE=1024 @@ -886,7 +888,6 @@ CONFIG_HEAP_TRACING_OFF=y # # libsodium # -CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y # end of libsodium # @@ -1095,8 +1096,8 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y CONFIG_MBEDTLS_HARDWARE_AES=y CONFIG_MBEDTLS_AES_USE_INTERRUPT=y CONFIG_MBEDTLS_HARDWARE_GCM=y -# CONFIG_MBEDTLS_HARDWARE_MPI is not set -# CONFIG_MBEDTLS_HARDWARE_SHA is not set +CONFIG_MBEDTLS_HARDWARE_MPI=y +CONFIG_MBEDTLS_HARDWARE_SHA=y CONFIG_MBEDTLS_ROM_MD5=y # CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set # CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set @@ -1190,6 +1191,7 @@ CONFIG_MBEDTLS_ECP_NIST_OPTIM=y # CONFIG_MBEDTLS_CHACHA20_C is not set # CONFIG_MBEDTLS_HKDF_C is not set # CONFIG_MBEDTLS_THREADING_C is not set +# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set # CONFIG_MBEDTLS_SECURITY_RISKS is not set # end of mbedTLS diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_host.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_host.h index 0d435138b8a..67162a0ca28 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_host.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_host.h @@ -42,14 +42,14 @@ * \defgroup CDC_Serial_Host Host * @{ */ -bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_control_complete_cb_t complete_cb); +bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_control_xfer_cb_t complete_cb); -static inline bool tuh_cdc_connect(uint8_t dev_addr, tuh_control_complete_cb_t complete_cb) +static inline bool tuh_cdc_connect(uint8_t dev_addr, tuh_control_xfer_cb_t complete_cb) { return tuh_cdc_set_control_line_state(dev_addr, true, true, complete_cb); } -static inline bool tuh_cdc_disconnect(uint8_t dev_addr, tuh_control_complete_cb_t complete_cb) +static inline bool tuh_cdc_disconnect(uint8_t dev_addr, tuh_control_xfer_cb_t complete_cb) { return tuh_cdc_set_control_line_state(dev_addr, false, false, complete_cb); } diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_rndis_host.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_rndis_host.h index 170cb3b0ece..447cc4e97f2 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_rndis_host.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_rndis_host.h @@ -50,7 +50,7 @@ typedef struct { }rndish_data_t; void rndish_init(void); -tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc); +bool rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc); void rndish_xfer_isr(cdch_data_t *p_cdc, pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes); void rndish_close(uint8_t dev_addr); diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/class/vendor/vendor_host.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/class/vendor/vendor_host.h index 07fa56c61b0..65223fbca07 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/class/vendor/vendor_host.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/class/vendor/vendor_host.h @@ -49,16 +49,16 @@ static inline bool tusbh_custom_is_mounted(uint8_t dev_addr, uint16_t vendor_id, return false; } -tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length); -tusb_error_t tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void const * p_data, uint16_t length); +bool tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length); +bool tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void const * p_data, uint16_t length); //--------------------------------------------------------------------+ // Internal Class Driver API //--------------------------------------------------------------------+ -void cush_init(void); -tusb_error_t cush_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length); -void cush_isr(pipe_handle_t pipe_hdl, xfer_result_t event); -void cush_close(uint8_t dev_addr); +void cush_init(void); +bool cush_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length); +void cush_isr(pipe_handle_t pipe_hdl, xfer_result_t event); +void cush_close(uint8_t dev_addr); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h index 26865805e70..58591f0bea0 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h @@ -71,23 +71,10 @@ #include "tusb_compiler.h" #include "tusb_verify.h" #include "tusb_types.h" +#include "tusb_debug.h" -#include "tusb_error.h" // TODO remove #include "tusb_timeout.h" // TODO remove -//--------------------------------------------------------------------+ -// Internal Helper used by Host and Device Stack -//--------------------------------------------------------------------+ - -// Check if endpoint descriptor is valid per USB specs -bool tu_edpt_validate(tusb_desc_endpoint_t const * desc_ep, tusb_speed_t speed); - -// Bind all endpoint of a interface descriptor to class driver -void tu_edpt_bind_driver(uint8_t ep2drv[][2], tusb_desc_interface_t const* p_desc, uint16_t desc_len, uint8_t driver_id); - -// Calculate total length of n interfaces (depending on IAD) -uint16_t tu_desc_get_interface_total_len(tusb_desc_interface_t const* desc_itf, uint8_t itf_count, uint16_t max_len); - //--------------------------------------------------------------------+ // Internal Inline Functions //--------------------------------------------------------------------+ @@ -268,138 +255,6 @@ TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write16 (void* mem, ui + TU_BIN8(dlsb)) #endif -//--------------------------------------------------------------------+ -// Debug Function -//--------------------------------------------------------------------+ - -// CFG_TUSB_DEBUG for debugging -// 0 : no debug -// 1 : print error -// 2 : print warning -// 3 : print info -#if CFG_TUSB_DEBUG - -void tu_print_mem(void const *buf, uint32_t count, uint8_t indent); - -#ifdef CFG_TUSB_DEBUG_PRINTF - extern int CFG_TUSB_DEBUG_PRINTF(const char *format, ...); - #define tu_printf CFG_TUSB_DEBUG_PRINTF -#else - #define tu_printf printf -#endif - -static inline -void tu_print_var(uint8_t const* buf, uint32_t bufsize) -{ - for(uint32_t i=0; i= 2 - #define TU_LOG2 TU_LOG1 - #define TU_LOG2_MEM TU_LOG1_MEM - #define TU_LOG2_VAR TU_LOG1_VAR - #define TU_LOG2_INT TU_LOG1_INT - #define TU_LOG2_HEX TU_LOG1_HEX -#endif - -// Log Level 3: Info -#if CFG_TUSB_DEBUG >= 3 - #define TU_LOG3 TU_LOG1 - #define TU_LOG3_MEM TU_LOG1_MEM - #define TU_LOG3_VAR TU_LOG1_VAR - #define TU_LOG3_INT TU_LOG1_INT - #define TU_LOG3_HEX TU_LOG1_HEX -#endif - -typedef struct -{ - uint32_t key; - const char* data; -} tu_lookup_entry_t; - -typedef struct -{ - uint16_t count; - tu_lookup_entry_t const* items; -} tu_lookup_table_t; - -static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint32_t key) -{ - static char not_found[11]; - - for(uint16_t i=0; icount; i++) - { - if (p_table->items[i].key == key) return p_table->items[i].data; - } - - // not found return the key value in hex - snprintf(not_found, sizeof(not_found), "0x%08lX", (unsigned long) key); - - return not_found; -} - -#endif // CFG_TUSB_DEBUG - -#ifndef TU_LOG -#define TU_LOG(n, ...) -#define TU_LOG_MEM(n, ...) -#define TU_LOG_VAR(n, ...) -#define TU_LOG_INT(n, ...) -#define TU_LOG_HEX(n, ...) -#define TU_LOG_LOCATION() -#define TU_LOG_FAILED() -#endif - -// TODO replace all TU_LOGn with TU_LOG(n) - -#define TU_LOG0(...) -#define TU_LOG0_MEM(...) -#define TU_LOG0_VAR(...) -#define TU_LOG0_INT(...) -#define TU_LOG0_HEX(...) - - -#ifndef TU_LOG1 - #define TU_LOG1(...) - #define TU_LOG1_MEM(...) - #define TU_LOG1_VAR(...) - #define TU_LOG1_INT(...) - #define TU_LOG1_HEX(...) -#endif - -#ifndef TU_LOG2 - #define TU_LOG2(...) - #define TU_LOG2_MEM(...) - #define TU_LOG2_VAR(...) - #define TU_LOG2_INT(...) - #define TU_LOG2_HEX(...) -#endif - -#ifndef TU_LOG3 - #define TU_LOG3(...) - #define TU_LOG3_MEM(...) - #define TU_LOG3_VAR(...) - #define TU_LOG3_INT(...) - #define TU_LOG3_HEX(...) -#endif - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h new file mode 100644 index 00000000000..647e8a8db5d --- /dev/null +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h @@ -0,0 +1,174 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2022, Ha Thach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * This file is part of the TinyUSB stack. + */ + +#ifndef _TUSB_DEBUG_H_ +#define _TUSB_DEBUG_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +//--------------------------------------------------------------------+ +// Debug +//--------------------------------------------------------------------+ + +// CFG_TUSB_DEBUG for debugging +// 0 : no debug +// 1 : print error +// 2 : print warning +// 3 : print info +#if CFG_TUSB_DEBUG + +// Enum to String for debugging purposes +#if CFG_TUSB_DEBUG >= 2 +extern char const* const tu_str_speed[]; +extern char const* const tu_str_std_request[]; +#endif + +void tu_print_mem(void const *buf, uint32_t count, uint8_t indent); + +#ifdef CFG_TUSB_DEBUG_PRINTF + extern int CFG_TUSB_DEBUG_PRINTF(const char *format, ...); + #define tu_printf CFG_TUSB_DEBUG_PRINTF +#else + #define tu_printf printf +#endif + +static inline void tu_print_var(uint8_t const* buf, uint32_t bufsize) +{ + for(uint32_t i=0; i= 2 + #define TU_LOG2 TU_LOG1 + #define TU_LOG2_MEM TU_LOG1_MEM + #define TU_LOG2_VAR TU_LOG1_VAR + #define TU_LOG2_INT TU_LOG1_INT + #define TU_LOG2_HEX TU_LOG1_HEX +#endif + +// Log Level 3: Info +#if CFG_TUSB_DEBUG >= 3 + #define TU_LOG3 TU_LOG1 + #define TU_LOG3_MEM TU_LOG1_MEM + #define TU_LOG3_VAR TU_LOG1_VAR + #define TU_LOG3_INT TU_LOG1_INT + #define TU_LOG3_HEX TU_LOG1_HEX +#endif + +typedef struct +{ + uint32_t key; + const char* data; +} tu_lookup_entry_t; + +typedef struct +{ + uint16_t count; + tu_lookup_entry_t const* items; +} tu_lookup_table_t; + +static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint32_t key) +{ + static char not_found[11]; + + for(uint16_t i=0; icount; i++) + { + if (p_table->items[i].key == key) return p_table->items[i].data; + } + + // not found return the key value in hex + snprintf(not_found, sizeof(not_found), "0x%08lX", (unsigned long) key); + + return not_found; +} + +#endif // CFG_TUSB_DEBUG + +#ifndef TU_LOG + #define TU_LOG(n, ...) + #define TU_LOG_MEM(n, ...) + #define TU_LOG_VAR(n, ...) + #define TU_LOG_INT(n, ...) + #define TU_LOG_HEX(n, ...) + #define TU_LOG_LOCATION() + #define TU_LOG_FAILED() +#endif + +// TODO replace all TU_LOGn with TU_LOG(n) + +#define TU_LOG0(...) +#define TU_LOG0_MEM(...) +#define TU_LOG0_VAR(...) +#define TU_LOG0_INT(...) +#define TU_LOG0_HEX(...) + +#ifndef TU_LOG1 + #define TU_LOG1(...) + #define TU_LOG1_MEM(...) + #define TU_LOG1_VAR(...) + #define TU_LOG1_INT(...) + #define TU_LOG1_HEX(...) +#endif + +#ifndef TU_LOG2 + #define TU_LOG2(...) + #define TU_LOG2_MEM(...) + #define TU_LOG2_VAR(...) + #define TU_LOG2_INT(...) + #define TU_LOG2_HEX(...) +#endif + +#ifndef TU_LOG3 + #define TU_LOG3(...) + #define TU_LOG3_MEM(...) + #define TU_LOG3_VAR(...) + #define TU_LOG3_INT(...) + #define TU_LOG3_HEX(...) +#endif + +#ifdef __cplusplus + } +#endif + +#endif /* _TUSB_DEBUG_H_ */ diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_error.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_error.h deleted file mode 100644 index 42541acd678..00000000000 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_error.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -/** \ingroup Group_Common - * \defgroup Group_Error Error Codes - * @{ */ - -#ifndef _TUSB_ERRORS_H_ -#define _TUSB_ERRORS_H_ - -#include "tusb_option.h" - -#ifdef __cplusplus - extern "C" { -#endif - -#define ERROR_ENUM(x) x, -#define ERROR_STRING(x) #x, - -#define ERROR_TABLE(ENTRY) \ - ENTRY(TUSB_ERROR_NONE )\ - ENTRY(TUSB_ERROR_INVALID_PARA )\ - ENTRY(TUSB_ERROR_DEVICE_NOT_READY )\ - ENTRY(TUSB_ERROR_INTERFACE_IS_BUSY )\ - ENTRY(TUSB_ERROR_HCD_OPEN_PIPE_FAILED )\ - ENTRY(TUSB_ERROR_OSAL_TIMEOUT )\ - ENTRY(TUSB_ERROR_CDCH_DEVICE_NOT_MOUNTED )\ - ENTRY(TUSB_ERROR_MSCH_DEVICE_NOT_MOUNTED )\ - ENTRY(TUSB_ERROR_NOT_SUPPORTED )\ - ENTRY(TUSB_ERROR_NOT_ENOUGH_MEMORY )\ - ENTRY(TUSB_ERROR_FAILED )\ - -/// \brief Error Code returned -/// TODO obsolete and to be remove -typedef enum -{ - ERROR_TABLE(ERROR_ENUM) - TUSB_ERROR_COUNT -}tusb_error_t; - -#if CFG_TUSB_DEBUG -/// Enum to String for debugging purposes. Only available if \ref CFG_TUSB_DEBUG > 0 -extern char const* const tusb_strerr[TUSB_ERROR_COUNT]; -extern char const* const tusb_speed_str[]; - -#endif - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_ERRORS_H_ */ - -/** @} */ diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_private.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_private.h new file mode 100644 index 00000000000..b34506f6500 --- /dev/null +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_private.h @@ -0,0 +1,65 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2022, Ha Thach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * This file is part of the TinyUSB stack. + */ + + +#ifndef _TUSB_PRIVATE_H_ +#define _TUSB_PRIVATE_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +typedef struct TU_ATTR_PACKED +{ + volatile uint8_t busy : 1; + volatile uint8_t stalled : 1; + volatile uint8_t claimed : 1; +}tu_edpt_state_t; + +//--------------------------------------------------------------------+ +// Internal Helper used by Host and Device Stack +//--------------------------------------------------------------------+ + +// Check if endpoint descriptor is valid per USB specs +bool tu_edpt_validate(tusb_desc_endpoint_t const * desc_ep, tusb_speed_t speed); + +// Bind all endpoint of a interface descriptor to class driver +void tu_edpt_bind_driver(uint8_t ep2drv[][2], tusb_desc_interface_t const* p_desc, uint16_t desc_len, uint8_t driver_id); + +// Calculate total length of n interfaces (depending on IAD) +uint16_t tu_desc_get_interface_total_len(tusb_desc_interface_t const* desc_itf, uint8_t itf_count, uint16_t max_len); + +// Claim an endpoint with provided mutex +bool tu_edpt_claim(tu_edpt_state_t* ep_state, osal_mutex_t mutex); + +// Release an endpoint with provided mutex +bool tu_edpt_release(tu_edpt_state_t* ep_state, osal_mutex_t mutex); + +#ifdef __cplusplus + } +#endif + +#endif /* _TUSB_PRIVATE_H_ */ diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h index 5b26f5aece2..e2fa175327f 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h @@ -223,19 +223,13 @@ enum { #define TUSB_DESC_CONFIG_POWER_MA(x) ((x)/2) -/// Device State TODO remove -typedef enum -{ - TUSB_DEVICE_STATE_UNPLUG = 0 , - TUSB_DEVICE_STATE_CONFIGURED , - TUSB_DEVICE_STATE_SUSPENDED , -}tusb_device_state_t; - typedef enum { XFER_RESULT_SUCCESS, XFER_RESULT_FAILED, XFER_RESULT_STALLED, + XFER_RESULT_TIMEOUT, + XFER_RESULT_INVALID }xfer_result_t; enum // TODO remove @@ -265,6 +259,7 @@ typedef enum enum { + CONTROL_STAGE_IDLE, CONTROL_STAGE_SETUP, CONTROL_STAGE_DATA, CONTROL_STAGE_ACK diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h index 8fef11dc720..f4a08ce2f91 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h @@ -74,10 +74,8 @@ #if CFG_TUSB_DEBUG #include - #define _MESS_ERR(_err) tu_printf("%s %d: failed, error = %s\r\n", __func__, __LINE__, tusb_strerr[_err]) #define _MESS_FAILED() tu_printf("%s %d: ASSERT FAILED\r\n", __func__, __LINE__) #else - #define _MESS_ERR(_err) do {} while (0) #define _MESS_FAILED() do {} while (0) #endif @@ -144,32 +142,6 @@ #define TU_ASSERT(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_2ARGS, ASSERT_1ARGS,UNUSED)(__VA_ARGS__) #endif -// TODO remove TU_ASSERT_ERR() later - -/*------------- Generator for TU_VERIFY_ERR and TU_VERIFY_ERR_HDLR -------------*/ -#define TU_VERIFY_ERR_DEF2(_error, _handler) do \ -{ \ - uint32_t _err = (uint32_t)(_error); \ - if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _err; } \ -} while(0) - -#define TU_VERIFY_ERR_DEF3(_error, _handler, _ret) do \ -{ \ - uint32_t _err = (uint32_t)(_error); \ - if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _ret; } \ -} while(0) - -/*------------------------------------------------------------------*/ -/* ASSERT Error - * basically TU_VERIFY Error with TU_BREAKPOINT() as handler - *------------------------------------------------------------------*/ -#define ASSERT_ERR_1ARGS(_error) TU_VERIFY_ERR_DEF2(_error, TU_BREAKPOINT()) -#define ASSERT_ERR_2ARGS(_error, _ret) TU_VERIFY_ERR_DEF3(_error, TU_BREAKPOINT(), _ret) - -#ifndef TU_ASSERT_ERR -#define TU_ASSERT_ERR(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_ERR_2ARGS, ASSERT_ERR_1ARGS,UNUSED)(__VA_ARGS__) -#endif - /*------------------------------------------------------------------*/ /* ASSERT HDLR *------------------------------------------------------------------*/ diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h index dae95cebbe5..29753451ebc 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h @@ -80,7 +80,7 @@ bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16 // If caller does not make any transfer, it must release endpoint for others. bool usbd_edpt_claim(uint8_t rhport, uint8_t ep_addr); -// Release an endpoint without submitting a transfer +// Release claimed endpoint without submitting a transfer bool usbd_edpt_release(uint8_t rhport, uint8_t ep_addr); // Check if endpoint is busy transferring diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/hcd.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/hcd.h index 9819f5f2a8c..c40bea64cec 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/hcd.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/hcd.h @@ -94,7 +94,8 @@ typedef struct } hcd_event_t; -typedef struct { +typedef struct +{ uint8_t rhport; uint8_t hub_addr; uint8_t hub_port; diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/hub.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/hub.h index c4d5441933e..30cf3dd1c33 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/hub.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/hub.h @@ -171,12 +171,35 @@ typedef struct { TU_VERIFY_STATIC( sizeof(hub_port_status_response_t) == 4, "size is not correct"); -bool hub_port_clear_feature(uint8_t hub_addr, uint8_t hub_port, uint8_t feature, tuh_control_complete_cb_t complete_cb); -bool hub_port_set_feature(uint8_t hub_addr, uint8_t hub_port, uint8_t feature, tuh_control_complete_cb_t complete_cb); +// Clear feature +bool hub_port_clear_feature (uint8_t hub_addr, uint8_t hub_port, uint8_t feature, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Set feature +bool hub_port_set_feature (uint8_t hub_addr, uint8_t hub_port, uint8_t feature, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get port status +bool hub_port_get_status (uint8_t hub_addr, uint8_t hub_port, void* resp, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get status from Interrupt endpoint +bool hub_edpt_status_xfer(uint8_t dev_addr); + +// Reset a port +static inline bool hub_port_reset(uint8_t hub_addr, uint8_t hub_port, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg) +{ + return hub_port_set_feature(hub_addr, hub_port, HUB_FEATURE_PORT_RESET, complete_cb, user_arg); +} + +// Clear Reset Change +static inline bool hub_port_clear_reset_change(uint8_t hub_addr, uint8_t hub_port, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg) +{ + return hub_port_clear_feature(hub_addr, hub_port, HUB_FEATURE_PORT_RESET_CHANGE, complete_cb, user_arg); +} -bool hub_port_reset(uint8_t hub_addr, uint8_t hub_port, tuh_control_complete_cb_t complete_cb); -bool hub_port_get_status(uint8_t hub_addr, uint8_t hub_port, void* resp, tuh_control_complete_cb_t complete_cb); -bool hub_status_pipe_queue(uint8_t dev_addr); //--------------------------------------------------------------------+ // Internal Class Driver API diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/usbh.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/usbh.h index 9465d1d1bc7..3bd40c50d67 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/usbh.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/usbh.h @@ -38,7 +38,31 @@ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ -typedef bool (*tuh_control_complete_cb_t)(uint8_t daddr, tusb_control_request_t const * request, xfer_result_t result); +// forward declaration +struct tuh_control_xfer_s; +typedef struct tuh_control_xfer_s tuh_control_xfer_t; + +typedef bool (*tuh_control_xfer_cb_t)(uint8_t daddr, tuh_control_xfer_t const * xfer, xfer_result_t result); + +struct tuh_control_xfer_s +{ + tusb_control_request_t request TU_ATTR_ALIGNED(4); + uint8_t* buffer; + tuh_control_xfer_cb_t complete_cb; + uintptr_t user_arg; +}; + +//--------------------------------------------------------------------+ +// APPLICATION CALLBACK +//--------------------------------------------------------------------+ + +//TU_ATTR_WEAK uint8_t tuh_attach_cb (tusb_desc_device_t const *desc_device); + +// Invoked when device is mounted (configured) +TU_ATTR_WEAK void tuh_mount_cb (uint8_t daddr); + +/// Invoked when device is unmounted (bus reset/unplugged) +TU_ATTR_WEAK void tuh_umount_cb(uint8_t daddr); //--------------------------------------------------------------------+ // APPLICATION API @@ -80,48 +104,102 @@ static inline bool tuh_ready(uint8_t daddr) return tuh_mounted(daddr) && !tuh_suspended(daddr); } -// Carry out control transfer -bool tuh_control_xfer (uint8_t daddr, tusb_control_request_t const* request, void* buffer, tuh_control_complete_cb_t complete_cb); +// Carry out a control transfer +// true on success, false if there is on-going control transfer or incorrect parameters +// Blocking if complete callback is NULL, in this case 'user_arg' must contain xfer_result_t variable +bool tuh_control_xfer (uint8_t daddr, tuh_control_xfer_t const* xfer); + +// Sync (blocking) version of tuh_control_xfer() +// return transfer result +uint8_t tuh_control_xfer_sync(uint8_t daddr, tuh_control_xfer_t const* xfer, uint32_t timeout_ms); -// Set Configuration +// Set Configuration (control transfer) // config_num = 0 will un-configure device. Note: config_num = config_descriptor_index + 1 -bool tuh_configuration_set(uint8_t daddr, uint8_t config_num, tuh_control_complete_cb_t complete_cb); +// true on success, false if there is on-going control transfer or incorrect parameters +// Blocking if complete callback is NULL, in this case 'user_arg' must contain xfer_result_t variable +bool tuh_configuration_set(uint8_t daddr, uint8_t config_num, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); -//------------- descriptors -------------// +//--------------------------------------------------------------------+ +// Descriptors Asynchronous (non-blocking) +//--------------------------------------------------------------------+ -// Get an descriptor -bool tuh_descriptor_get(uint8_t daddr, uint8_t type, uint8_t index, - void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +// Get an descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get(uint8_t daddr, uint8_t type, uint8_t index, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get device descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get_device(uint8_t daddr, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get configuration descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get_configuration(uint8_t daddr, uint8_t index, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get HID report descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get_hid_report(uint8_t daddr, uint8_t itf_num, uint8_t desc_type, uint8_t index, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get string descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +// Blocking if complete callback is NULL, in this case 'user_arg' must contain xfer_result_t variable +bool tuh_descriptor_get_string(uint8_t daddr, uint8_t index, uint16_t language_id, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get manufacturer string descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get_manufacturer_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get product string descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get_product_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); + +// Get serial string descriptor (control transfer) +// true on success, false if there is on-going control transfer or incorrect parameters +bool tuh_descriptor_get_serial_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, + tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg); -// Get device descriptor -bool tuh_descriptor_device_get(uint8_t daddr, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +//--------------------------------------------------------------------+ +// Descriptors Synchronous (blocking) +//--------------------------------------------------------------------+ -// Get configuration descriptor -bool tuh_descriptor_configuration_get(uint8_t daddr, uint8_t index, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +// Sync (blocking) version of tuh_descriptor_get() +// return transfer result +uint8_t tuh_descriptor_get_sync(uint8_t daddr, uint8_t type, uint8_t index, void* buffer, uint16_t len, uint8_t timeout_ms); -// Get string descriptor -bool tuh_descriptor_string_get(uint8_t daddr, uint16_t language_id, uint8_t index, - void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +// Sync (blocking) version of tuh_descriptor_get_device() +// return transfer result +uint8_t tuh_descriptor_get_device_sync(uint8_t daddr, void* buffer, uint16_t len, uint8_t timeout_ms); -// Get manufacturer string descriptor -bool tuh_descriptor_string_manufacturer_get(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +// Sync (blocking) version of tuh_descriptor_get_configuration() +// return transfer result +uint8_t tuh_descriptor_get_configuration_sync(uint8_t daddr, uint8_t index, void* buffer, uint16_t len, uint8_t timeout_ms); -// Get product string descriptor -bool tuh_descriptor_string_product_get(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +// Sync (blocking) version of tuh_descriptor_get_hid_report() +// return transfer result +uint8_t tuh_descriptor_get_hid_report_sync(uint8_t daddr, uint8_t itf_num, uint8_t desc_type, uint8_t index, void* buffer, uint16_t len, uint8_t timeout_ms); -// Get serial string descriptor -bool tuh_descriptor_string_serial_get(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb); +// Sync (blocking) version of tuh_descriptor_get_string() +// return transfer result +uint8_t tuh_descriptor_get_string_sync(uint8_t daddr, uint8_t index, uint16_t language_id, void* buffer, uint16_t len, uint8_t timeout_ms); -//--------------------------------------------------------------------+ -// APPLICATION CALLBACK -//--------------------------------------------------------------------+ -//TU_ATTR_WEAK uint8_t tuh_attach_cb (tusb_desc_device_t const *desc_device); +// Sync (blocking) version of tuh_descriptor_get_manufacturer_string() +// return transfer result +uint8_t tuh_descriptor_get_manufacturer_string_sync(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, uint8_t timeout_ms); -// Invoked when device is mounted (configured) -TU_ATTR_WEAK void tuh_mount_cb (uint8_t daddr); +// Sync (blocking) version of tuh_descriptor_get_product_string() +// return transfer result +uint8_t tuh_descriptor_get_product_string_sync(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, uint8_t timeout_ms); -/// Invoked when device is unmounted (bus reset/unplugged) -TU_ATTR_WEAK void tuh_umount_cb(uint8_t daddr); +// Sync (blocking) version of tuh_descriptor_get_serial_string() +// return transfer result +uint8_t tuh_descriptor_get_serial_string_sync(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, uint8_t timeout_ms); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/usbh_classdriver.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/usbh_classdriver.h index 2f9957cc65a..0435eae701b 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/usbh_classdriver.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/usbh_classdriver.h @@ -73,6 +73,7 @@ bool usbh_edpt_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_ // If caller does not make any transfer, it must release endpoint for others. bool usbh_edpt_claim(uint8_t dev_addr, uint8_t ep_addr); +// Release claimed endpoint without submitting a transfer bool usbh_edpt_release(uint8_t dev_addr, uint8_t ep_addr); // Check if endpoint transferring is complete diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h index e1dd95c3400..4217f042225 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h @@ -111,7 +111,7 @@ typedef struct typedef osal_queue_def_t* osal_queue_t; -// role device/host is used by OS NONE for mutex (disable usb isr) only +// _int_set is used as mutex in OS NONE (disable/enable USB ISR) #define OSAL_QUEUE_DEF(_int_set, _name, _depth, _type) \ uint8_t _name##_buf[_depth*sizeof(_type)]; \ osal_queue_def_t _name = { \ diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/tusb.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/tusb.h index 549f00b4320..222855fcb6b 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/tusb.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/tusb.h @@ -117,8 +117,6 @@ //--------------------------------------------------------------------+ // APPLICATION API //--------------------------------------------------------------------+ -/** \ingroup group_application_api - * @{ */ // Initialize device/host stack // Note: when using with RTOS, this should be called after scheduler/kernel is started. @@ -131,8 +129,6 @@ bool tusb_inited(void); // TODO // bool tusb_teardown(void); -/** @} */ - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/tusb_option.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/tusb_option.h index afd69c38bfc..0352faaed6e 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/tusb_option.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/tusb_option.h @@ -285,6 +285,9 @@ #define CFG_TUSB_OS_INC_PATH #endif +// mutex is only needed for RTOS TODO also required with multiple core MCUs +#define TUSB_OPT_MUTEX (CFG_TUSB_OS != OPT_OS_NONE) + //-------------------------------------------------------------------- // DEVICE OPTIONS //-------------------------------------------------------------------- diff --git a/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_hf_client_api.h b/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_hf_client_api.h index 3c5c05b178c..55569bc5c84 100644 --- a/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_hf_client_api.h +++ b/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_hf_client_api.h @@ -60,6 +60,9 @@ typedef enum { #define ESP_HF_CLIENT_PEER_FEAT_ECC 0x80 /* Enhanced Call Control */ #define ESP_HF_CLIENT_PEER_FEAT_EXTERR 0x100 /* Extended error codes */ #define ESP_HF_CLIENT_PEER_FEAT_CODEC 0x200 /* Codec Negotiation */ +/* HFP 1.7+ */ +#define ESP_HF_CLIENT_PEER_FEAT_HF_IND 0x400 /* HF Indicators */ +#define ESP_HF_CLIENT_PEER_FEAT_ESCO_S4 0x800 /* eSCO S4 Setting Supported */ /* CHLD feature masks of AG */ #define ESP_HF_CLIENT_CHLD_FEAT_REL 0x01 /* 0 Release waiting call or held calls */ diff --git a/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_core.h b/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_core.h index 6ddb0fbe912..f9d96be4ee6 100644 --- a/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_core.h +++ b/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_core.h @@ -49,6 +49,8 @@ typedef enum { RMAKER_EVENT_USER_NODE_MAPPING_DONE, /** Local control started. Associated data is the NULL terminated Service Name */ RMAKER_EVENT_LOCAL_CTRL_STARTED, + /* User reset request successfully sent to ESP RainMaker Cloud */ + RMAKER_EVENT_USER_NODE_MAPPING_RESET, } esp_rmaker_event_t; /** ESP RainMaker Node information */ diff --git a/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h b/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h index a763561f3c2..77a153b02f2 100644 --- a/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h +++ b/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h @@ -19,6 +19,25 @@ extern "C" { #endif +/** User-Node Mapping states */ +typedef enum { + /** Mapping does not exist or is not initialized */ + ESP_RMAKER_USER_MAPPING_RESET = 0, + /** Mapping has started */ + ESP_RMAKER_USER_MAPPING_STARTED, + /** Mapping is done */ + ESP_RMAKER_USER_MAPPING_DONE, +} esp_rmaker_user_mapping_state_t; + +/** + * Get User-Node mapping state + * + * This returns the current user-node mapping state. + * + * @return user mapping state + */ +esp_rmaker_user_mapping_state_t esp_rmaker_user_node_mapping_get_state(void); + /** * Create User Mapping Endpoint * diff --git a/tools/sdk/esp32s3/include/freertos/port/xtensa/include/freertos/portmacro.h b/tools/sdk/esp32s3/include/freertos/port/xtensa/include/freertos/portmacro.h index 934f056816c..2ee4c12c2b8 100644 --- a/tools/sdk/esp32s3/include/freertos/port/xtensa/include/freertos/portmacro.h +++ b/tools/sdk/esp32s3/include/freertos/port/xtensa/include/freertos/portmacro.h @@ -558,14 +558,14 @@ static inline void __attribute__((always_inline)) uxPortCompareSetExtram(volatil // --------------------- Interrupts ------------------------ -static inline UBaseType_t xPortSetInterruptMaskFromISR(void) +static inline UBaseType_t __attribute__((always_inline)) xPortSetInterruptMaskFromISR(void) { UBaseType_t prev_int_level = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); portbenchmarkINTERRUPT_DISABLE(); return prev_int_level; } -static inline void vPortClearInterruptMaskFromISR(UBaseType_t prev_level) +static inline void __attribute__((always_inline)) vPortClearInterruptMaskFromISR(UBaseType_t prev_level) { portbenchmarkINTERRUPT_RESTORE(prev_level); XTOS_RESTORE_JUST_INTLEVEL(prev_level); diff --git a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/gpio_ll.h b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/gpio_ll.h index 14dc4dc3eeb..6a5b7b1b85f 100644 --- a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/gpio_ll.h +++ b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/gpio_ll.h @@ -395,7 +395,7 @@ static inline void gpio_ll_iomux_in(gpio_dev_t *hw, uint32_t gpio, uint32_t sign * @param pin_name Pin name to configure * @param func Function to assign to the pin */ -static inline void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func) +static inline __attribute__((always_inline)) void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func) { if (pin_name == IO_MUX_GPIO19_REG || pin_name == IO_MUX_GPIO20_REG) { CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_USB_PAD_ENABLE); diff --git a/tools/sdk/esp32s3/include/hal/include/hal/emac_hal.h b/tools/sdk/esp32s3/include/hal/include/hal/emac_hal.h index 4f332811aba..27cd38456dc 100644 --- a/tools/sdk/esp32s3/include/hal/include/hal/emac_hal.h +++ b/tools/sdk/esp32s3/include/hal/include/hal/emac_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -225,7 +225,7 @@ void emac_hal_start(emac_hal_context_t *hal); * @param hal EMAC HAL context infostructure * @return * - ESP_OK: succeed - * - ESP_ERR_INVALID_STATE: previous frame transmission is not completed. When this error occurs, + * - ESP_ERR_INVALID_STATE: previous frame transmission/reception is not completed. When this error occurs, * wait and reapeat the EMAC stop again. */ esp_err_t emac_hal_stop(emac_hal_context_t *hal); diff --git a/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_common_events.h b/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_common_events.h index 62c4b208759..b77f8a3d142 100644 --- a/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_common_events.h +++ b/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_common_events.h @@ -35,9 +35,26 @@ typedef enum { RMAKER_MQTT_EVENT_CONNECTED, /** Disconnected from MQTT Broker */ RMAKER_MQTT_EVENT_DISCONNECTED, - /** MQTT message published successfully */ + /** MQTT message published successfully. + * Event data will contain the message ID (integer) of published message. + */ RMAKER_MQTT_EVENT_PUBLISHED, -} esp_rmaker_mqtt_event_t; + /** POSIX Timezone Changed. Associated data would be NULL terminated POSIX Timezone + * Eg. "PST8PDT,M3.2.0,M11.1.0" */ + RMAKER_EVENT_TZ_POSIX_CHANGED, + /** Timezone Changed. Associated data would be NULL terminated Timezone. + * Eg. "America/Los_Angeles" + * Note that whenever this event is received, the RMAKER_EVENT_TZ_POSIX_CHANGED event + * will also be received, but not necessarily vice versa. + */ + RMAKER_EVENT_TZ_CHANGED, + /** + * MQTT message deleted from the outbox if the message couldn't have been sent and acknowledged. + * Event data will contain the message ID (integer) of deleted message. + * Valid only if CONFIG_MQTT_REPORT_DELETED_MESSAGES is enabled. + */ + RMAKER_MQTT_EVENT_MSG_DELETED, +} esp_rmaker_common_event_t; #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h b/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h index 8a9e1ae649d..95744bdf58c 100644 --- a/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h +++ b/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h @@ -52,7 +52,7 @@ typedef esp_rmaker_mqtt_conn_params_t *(*esp_rmaker_mqtt_get_conn_params_t)(void * @param[in] priv_data The private data passed during subscription */ typedef void (*esp_rmaker_mqtt_subscribe_cb_t)(const char *topic, void *payload, size_t payload_len, void *priv_data); - + /** MQTT Init function prototype * * @param[in] conn_params The MQTT connection parameters. If NULL is passed, it should internally use the @@ -63,6 +63,12 @@ typedef void (*esp_rmaker_mqtt_subscribe_cb_t)(const char *topic, void *payload, */ typedef esp_err_t (*esp_rmaker_mqtt_init_t)(esp_rmaker_mqtt_conn_params_t *conn_params); +/** MQTT Deinit function prototype + * + * Call this function after MQTT has disconnected. + */ +typedef void (*esp_rmaker_mqtt_deinit_t)(void); + /** MQTT Connect function prototype * * Starts the connection attempts to the MQTT broker. @@ -124,6 +130,8 @@ typedef struct { esp_rmaker_mqtt_get_conn_params_t get_conn_params; /** Pointer to MQTT Init function. */ esp_rmaker_mqtt_init_t init; + /** Pointer to MQTT Deinit function. */ + esp_rmaker_mqtt_deinit_t deinit; /** Pointer to MQTT Connect function. */ esp_rmaker_mqtt_connect_t connect; /** Pointer to MQTQ Disconnect function */ diff --git a/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_utils.h b/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_utils.h index 9a5ba16f0aa..86ab691d492 100644 --- a/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_utils.h +++ b/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_utils.h @@ -15,12 +15,24 @@ #include #include #include +#include +#include #ifdef __cplusplus extern "C" { #endif +#ifdef CONFIG_SPIRAM +#define MEM_ALLOC_EXTRAM(size) heap_caps_malloc(size, MALLOC_CAP_SPIRAM) +#define MEM_CALLOC_EXTRAM(num, size) heap_caps_calloc(num, size, MALLOC_CAP_SPIRAM) +#define MEM_REALLOC_EXTRAM(ptr, size) heap_caps_realloc(ptr, size, MALLOC_CAP_SPIRAM) +#else +#define MEM_ALLOC_EXTRAM(size) malloc(size) +#define MEM_CALLOC_EXTRAM(num, size) calloc(num, size) +#define MEM_REALLOC_EXTRAM(ptr, size) realloc(ptr, size) +#endif + typedef struct esp_rmaker_time_config { /** If not specified, then 'CONFIG_ESP_RMAKER_SNTP_SERVER_NAME' is used as the SNTP server. */ char *sntp_server_name; diff --git a/tools/sdk/esp32s3/lib/libapp_trace.a b/tools/sdk/esp32s3/lib/libapp_trace.a index 59a3f45a19a..efa1a2b1a57 100644 Binary files a/tools/sdk/esp32s3/lib/libapp_trace.a and b/tools/sdk/esp32s3/lib/libapp_trace.a differ diff --git a/tools/sdk/esp32s3/lib/libapp_update.a b/tools/sdk/esp32s3/lib/libapp_update.a index 372114c40e3..7d5570cd4bc 100644 Binary files a/tools/sdk/esp32s3/lib/libapp_update.a and b/tools/sdk/esp32s3/lib/libapp_update.a differ diff --git a/tools/sdk/esp32s3/lib/libarduino_tinyusb.a b/tools/sdk/esp32s3/lib/libarduino_tinyusb.a index 7dd3400451b..e55df55d049 100644 Binary files a/tools/sdk/esp32s3/lib/libarduino_tinyusb.a and b/tools/sdk/esp32s3/lib/libarduino_tinyusb.a differ diff --git a/tools/sdk/esp32s3/lib/libbutton.a b/tools/sdk/esp32s3/lib/libbutton.a index 9059aba89ee..ab85cdabdee 100644 Binary files a/tools/sdk/esp32s3/lib/libbutton.a and b/tools/sdk/esp32s3/lib/libbutton.a differ diff --git a/tools/sdk/esp32s3/lib/libcoap.a b/tools/sdk/esp32s3/lib/libcoap.a index b43340b3a0d..cb5fd7868a0 100644 Binary files a/tools/sdk/esp32s3/lib/libcoap.a and b/tools/sdk/esp32s3/lib/libcoap.a differ diff --git a/tools/sdk/esp32s3/lib/libdriver.a b/tools/sdk/esp32s3/lib/libdriver.a index 156b52f209d..1ff33083e15 100644 Binary files a/tools/sdk/esp32s3/lib/libdriver.a and b/tools/sdk/esp32s3/lib/libdriver.a differ diff --git a/tools/sdk/esp32s3/lib/libesp-tls.a b/tools/sdk/esp32s3/lib/libesp-tls.a index 1c9ac80c841..2acd9e7e992 100644 Binary files a/tools/sdk/esp32s3/lib/libesp-tls.a and b/tools/sdk/esp32s3/lib/libesp-tls.a differ diff --git a/tools/sdk/esp32s3/lib/libesp_eth.a b/tools/sdk/esp32s3/lib/libesp_eth.a index e5fa2bf8293..6d15e2ff54c 100644 Binary files a/tools/sdk/esp32s3/lib/libesp_eth.a and b/tools/sdk/esp32s3/lib/libesp_eth.a differ diff --git a/tools/sdk/esp32s3/lib/libesp_http_client.a b/tools/sdk/esp32s3/lib/libesp_http_client.a index 0a9a6f8bd51..c4bd3714c3f 100644 Binary files a/tools/sdk/esp32s3/lib/libesp_http_client.a and b/tools/sdk/esp32s3/lib/libesp_http_client.a differ diff --git a/tools/sdk/esp32s3/lib/libesp_http_server.a b/tools/sdk/esp32s3/lib/libesp_http_server.a index b3db9cca2d2..546ca90418e 100644 Binary files a/tools/sdk/esp32s3/lib/libesp_http_server.a and b/tools/sdk/esp32s3/lib/libesp_http_server.a differ diff --git a/tools/sdk/esp32s3/lib/libesp_https_server.a b/tools/sdk/esp32s3/lib/libesp_https_server.a index cd7d7007eca..e9d343ebda7 100644 Binary files a/tools/sdk/esp32s3/lib/libesp_https_server.a and b/tools/sdk/esp32s3/lib/libesp_https_server.a differ diff --git a/tools/sdk/esp32s3/lib/libesp_ipc.a b/tools/sdk/esp32s3/lib/libesp_ipc.a index 872c0a11561..d1ec688d31e 100644 Binary files a/tools/sdk/esp32s3/lib/libesp_ipc.a and b/tools/sdk/esp32s3/lib/libesp_ipc.a differ diff --git a/tools/sdk/esp32s3/lib/libesp_lcd.a b/tools/sdk/esp32s3/lib/libesp_lcd.a index 048437e7832..9c89e9470e8 100644 Binary files a/tools/sdk/esp32s3/lib/libesp_lcd.a and b/tools/sdk/esp32s3/lib/libesp_lcd.a differ diff --git a/tools/sdk/esp32s3/lib/libesp_local_ctrl.a b/tools/sdk/esp32s3/lib/libesp_local_ctrl.a index caa1e6d855b..f8d4ad81eac 100644 Binary files a/tools/sdk/esp32s3/lib/libesp_local_ctrl.a and b/tools/sdk/esp32s3/lib/libesp_local_ctrl.a differ diff --git a/tools/sdk/esp32s3/lib/libesp_pm.a b/tools/sdk/esp32s3/lib/libesp_pm.a index 09bfbc62d15..3a772875b5a 100644 Binary files a/tools/sdk/esp32s3/lib/libesp_pm.a and b/tools/sdk/esp32s3/lib/libesp_pm.a differ diff --git a/tools/sdk/esp32s3/lib/libesp_rainmaker.a b/tools/sdk/esp32s3/lib/libesp_rainmaker.a index da4477d5f7f..96fddf30b19 100644 Binary files a/tools/sdk/esp32s3/lib/libesp_rainmaker.a and b/tools/sdk/esp32s3/lib/libesp_rainmaker.a differ diff --git a/tools/sdk/esp32s3/lib/libesp_websocket_client.a b/tools/sdk/esp32s3/lib/libesp_websocket_client.a index bf641e489d8..ad11feaab51 100644 Binary files a/tools/sdk/esp32s3/lib/libesp_websocket_client.a and b/tools/sdk/esp32s3/lib/libesp_websocket_client.a differ diff --git a/tools/sdk/esp32s3/lib/libfreemodbus.a b/tools/sdk/esp32s3/lib/libfreemodbus.a index 911ffd52101..c4d9ffdb16a 100644 Binary files a/tools/sdk/esp32s3/lib/libfreemodbus.a and b/tools/sdk/esp32s3/lib/libfreemodbus.a differ diff --git a/tools/sdk/esp32s3/lib/liblibsodium.a b/tools/sdk/esp32s3/lib/liblibsodium.a index f8505b41c49..55c07bd4790 100644 Binary files a/tools/sdk/esp32s3/lib/liblibsodium.a and b/tools/sdk/esp32s3/lib/liblibsodium.a differ diff --git a/tools/sdk/esp32s3/lib/libmbedcrypto.a b/tools/sdk/esp32s3/lib/libmbedcrypto.a index af8529623d1..38eb153c603 100644 Binary files a/tools/sdk/esp32s3/lib/libmbedcrypto.a and b/tools/sdk/esp32s3/lib/libmbedcrypto.a differ diff --git a/tools/sdk/esp32s3/lib/libmbedtls.a b/tools/sdk/esp32s3/lib/libmbedtls.a index 9f587f89822..a1a6a10b095 100644 Binary files a/tools/sdk/esp32s3/lib/libmbedtls.a and b/tools/sdk/esp32s3/lib/libmbedtls.a differ diff --git a/tools/sdk/esp32s3/lib/libmbedx509.a b/tools/sdk/esp32s3/lib/libmbedx509.a index 953697547ef..72cf0f21d9b 100644 Binary files a/tools/sdk/esp32s3/lib/libmbedx509.a and b/tools/sdk/esp32s3/lib/libmbedx509.a differ diff --git a/tools/sdk/esp32s3/lib/libmqtt.a b/tools/sdk/esp32s3/lib/libmqtt.a index d37e7645822..472584f8a73 100644 Binary files a/tools/sdk/esp32s3/lib/libmqtt.a and b/tools/sdk/esp32s3/lib/libmqtt.a differ diff --git a/tools/sdk/esp32s3/lib/libopenssl.a b/tools/sdk/esp32s3/lib/libopenssl.a index 9b3e50b5665..32ae5381be4 100644 Binary files a/tools/sdk/esp32s3/lib/libopenssl.a and b/tools/sdk/esp32s3/lib/libopenssl.a differ diff --git a/tools/sdk/esp32s3/lib/libprotocomm.a b/tools/sdk/esp32s3/lib/libprotocomm.a index bfb6aff1bf9..997ed441214 100644 Binary files a/tools/sdk/esp32s3/lib/libprotocomm.a and b/tools/sdk/esp32s3/lib/libprotocomm.a differ diff --git a/tools/sdk/esp32s3/lib/librmaker_common.a b/tools/sdk/esp32s3/lib/librmaker_common.a index 0e97d034a20..25ae299ff0a 100644 Binary files a/tools/sdk/esp32s3/lib/librmaker_common.a and b/tools/sdk/esp32s3/lib/librmaker_common.a differ diff --git a/tools/sdk/esp32s3/lib/libtcp_transport.a b/tools/sdk/esp32s3/lib/libtcp_transport.a index cb130ba133d..32fd51da7c3 100644 Binary files a/tools/sdk/esp32s3/lib/libtcp_transport.a and b/tools/sdk/esp32s3/lib/libtcp_transport.a differ diff --git a/tools/sdk/esp32s3/lib/libwpa_supplicant.a b/tools/sdk/esp32s3/lib/libwpa_supplicant.a index 561288bfc19..58bb755ad0e 100644 Binary files a/tools/sdk/esp32s3/lib/libwpa_supplicant.a and b/tools/sdk/esp32s3/lib/libwpa_supplicant.a differ diff --git a/tools/sdk/esp32s3/opi_opi/include/sdkconfig.h b/tools/sdk/esp32s3/opi_opi/include/sdkconfig.h index 933b63fa1be..e06128e261e 100644 --- a/tools/sdk/esp32s3/opi_opi/include/sdkconfig.h +++ b/tools/sdk/esp32s3/opi_opi/include/sdkconfig.h @@ -53,6 +53,7 @@ #define CONFIG_LIB_BUILDER_FLASHMODE "opi" #define CONFIG_LIB_BUILDER_FLASHFREQ "80m" #define CONFIG_ESP_RMAKER_ASSISTED_CLAIM 1 +#define CONFIG_ESP_RMAKER_CLAIM_TYPE 2 #define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" #define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024 #define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0 1 @@ -636,7 +637,6 @@ #define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2 #define CONFIG_HEAP_POISONING_LIGHT 1 #define CONFIG_HEAP_TRACING_OFF 1 -#define CONFIG_LIBSODIUM_USE_MBEDTLS_SHA 1 #define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1 #define CONFIG_LOG_DEFAULT_LEVEL 1 #define CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT 1 @@ -706,6 +706,7 @@ #define CONFIG_MBEDTLS_HARDWARE_AES 1 #define CONFIG_MBEDTLS_AES_USE_INTERRUPT 1 #define CONFIG_MBEDTLS_HARDWARE_MPI 1 +#define CONFIG_MBEDTLS_HARDWARE_SHA 1 #define CONFIG_MBEDTLS_ROM_MD5 1 #define CONFIG_MBEDTLS_HAVE_TIME 1 #define CONFIG_MBEDTLS_ECDSA_DETERMINISTIC 1 diff --git a/tools/sdk/esp32s3/opi_opi/libbootloader_support.a b/tools/sdk/esp32s3/opi_opi/libbootloader_support.a index 97495687655..8170996f67d 100644 Binary files a/tools/sdk/esp32s3/opi_opi/libbootloader_support.a and b/tools/sdk/esp32s3/opi_opi/libbootloader_support.a differ diff --git a/tools/sdk/esp32s3/opi_opi/libesp_system.a b/tools/sdk/esp32s3/opi_opi/libesp_system.a index 89d98ae51fb..42aab2f1095 100644 Binary files a/tools/sdk/esp32s3/opi_opi/libesp_system.a and b/tools/sdk/esp32s3/opi_opi/libesp_system.a differ diff --git a/tools/sdk/esp32s3/opi_opi/libfreertos.a b/tools/sdk/esp32s3/opi_opi/libfreertos.a index 4d9abc28b60..227ebe00bc5 100644 Binary files a/tools/sdk/esp32s3/opi_opi/libfreertos.a and b/tools/sdk/esp32s3/opi_opi/libfreertos.a differ diff --git a/tools/sdk/esp32s3/opi_opi/libspi_flash.a b/tools/sdk/esp32s3/opi_opi/libspi_flash.a index 05a54df87da..be33ecd26a1 100644 Binary files a/tools/sdk/esp32s3/opi_opi/libspi_flash.a and b/tools/sdk/esp32s3/opi_opi/libspi_flash.a differ diff --git a/tools/sdk/esp32s3/opi_qspi/include/sdkconfig.h b/tools/sdk/esp32s3/opi_qspi/include/sdkconfig.h index 4fc64b4458a..93465e70d5f 100644 --- a/tools/sdk/esp32s3/opi_qspi/include/sdkconfig.h +++ b/tools/sdk/esp32s3/opi_qspi/include/sdkconfig.h @@ -53,6 +53,7 @@ #define CONFIG_LIB_BUILDER_FLASHMODE "opi" #define CONFIG_LIB_BUILDER_FLASHFREQ "80m" #define CONFIG_ESP_RMAKER_ASSISTED_CLAIM 1 +#define CONFIG_ESP_RMAKER_CLAIM_TYPE 2 #define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" #define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024 #define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0 1 @@ -634,7 +635,6 @@ #define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2 #define CONFIG_HEAP_POISONING_LIGHT 1 #define CONFIG_HEAP_TRACING_OFF 1 -#define CONFIG_LIBSODIUM_USE_MBEDTLS_SHA 1 #define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1 #define CONFIG_LOG_DEFAULT_LEVEL 1 #define CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT 1 @@ -704,6 +704,7 @@ #define CONFIG_MBEDTLS_HARDWARE_AES 1 #define CONFIG_MBEDTLS_AES_USE_INTERRUPT 1 #define CONFIG_MBEDTLS_HARDWARE_MPI 1 +#define CONFIG_MBEDTLS_HARDWARE_SHA 1 #define CONFIG_MBEDTLS_ROM_MD5 1 #define CONFIG_MBEDTLS_HAVE_TIME 1 #define CONFIG_MBEDTLS_ECDSA_DETERMINISTIC 1 diff --git a/tools/sdk/esp32s3/opi_qspi/libbootloader_support.a b/tools/sdk/esp32s3/opi_qspi/libbootloader_support.a index 97495687655..8170996f67d 100644 Binary files a/tools/sdk/esp32s3/opi_qspi/libbootloader_support.a and b/tools/sdk/esp32s3/opi_qspi/libbootloader_support.a differ diff --git a/tools/sdk/esp32s3/opi_qspi/libesp_hw_support.a b/tools/sdk/esp32s3/opi_qspi/libesp_hw_support.a index 71ca6de8d28..648084459cd 100644 Binary files a/tools/sdk/esp32s3/opi_qspi/libesp_hw_support.a and b/tools/sdk/esp32s3/opi_qspi/libesp_hw_support.a differ diff --git a/tools/sdk/esp32s3/opi_qspi/libesp_system.a b/tools/sdk/esp32s3/opi_qspi/libesp_system.a index 2c510e97051..abb73097d0a 100644 Binary files a/tools/sdk/esp32s3/opi_qspi/libesp_system.a and b/tools/sdk/esp32s3/opi_qspi/libesp_system.a differ diff --git a/tools/sdk/esp32s3/opi_qspi/libfreertos.a b/tools/sdk/esp32s3/opi_qspi/libfreertos.a index 4d9abc28b60..227ebe00bc5 100644 Binary files a/tools/sdk/esp32s3/opi_qspi/libfreertos.a and b/tools/sdk/esp32s3/opi_qspi/libfreertos.a differ diff --git a/tools/sdk/esp32s3/opi_qspi/libspi_flash.a b/tools/sdk/esp32s3/opi_qspi/libspi_flash.a index 76fe613ea64..579d3578a04 100644 Binary files a/tools/sdk/esp32s3/opi_qspi/libspi_flash.a and b/tools/sdk/esp32s3/opi_qspi/libspi_flash.a differ diff --git a/tools/sdk/esp32s3/opi_qspi/sections.ld b/tools/sdk/esp32s3/opi_qspi/sections.ld index 7edc585deff..b33b8916847 100644 --- a/tools/sdk/esp32s3/opi_qspi/sections.ld +++ b/tools/sdk/esp32s3/opi_qspi/sections.ld @@ -365,8 +365,8 @@ SECTIONS *(.ext_ram.bss*) *(.bss .bss.*) - *(.ext_ram.bss .ext_ram.bss.*) *(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb .gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2 .sbss2.* .scommon .share.mem) + *(.ext_ram.bss .ext_ram.bss.*) *(COMMON) _bt_bss_start = ABSOLUTE(.); *libbt.a:(.bss .bss.* COMMON) diff --git a/tools/sdk/esp32s3/qspi_opi/include/sdkconfig.h b/tools/sdk/esp32s3/qspi_opi/include/sdkconfig.h index 1d71f09735e..72c578bf4e4 100644 --- a/tools/sdk/esp32s3/qspi_opi/include/sdkconfig.h +++ b/tools/sdk/esp32s3/qspi_opi/include/sdkconfig.h @@ -52,6 +52,7 @@ #define CONFIG_LIB_BUILDER_FLASHMODE "qio" #define CONFIG_LIB_BUILDER_FLASHFREQ "80m" #define CONFIG_ESP_RMAKER_ASSISTED_CLAIM 1 +#define CONFIG_ESP_RMAKER_CLAIM_TYPE 2 #define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" #define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024 #define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0 1 @@ -635,7 +636,6 @@ #define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2 #define CONFIG_HEAP_POISONING_LIGHT 1 #define CONFIG_HEAP_TRACING_OFF 1 -#define CONFIG_LIBSODIUM_USE_MBEDTLS_SHA 1 #define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1 #define CONFIG_LOG_DEFAULT_LEVEL 1 #define CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT 1 @@ -705,6 +705,7 @@ #define CONFIG_MBEDTLS_HARDWARE_AES 1 #define CONFIG_MBEDTLS_AES_USE_INTERRUPT 1 #define CONFIG_MBEDTLS_HARDWARE_MPI 1 +#define CONFIG_MBEDTLS_HARDWARE_SHA 1 #define CONFIG_MBEDTLS_ROM_MD5 1 #define CONFIG_MBEDTLS_HAVE_TIME 1 #define CONFIG_MBEDTLS_ECDSA_DETERMINISTIC 1 diff --git a/tools/sdk/esp32s3/qspi_opi/libbootloader_support.a b/tools/sdk/esp32s3/qspi_opi/libbootloader_support.a index 44fa510d303..e7a50225081 100644 Binary files a/tools/sdk/esp32s3/qspi_opi/libbootloader_support.a and b/tools/sdk/esp32s3/qspi_opi/libbootloader_support.a differ diff --git a/tools/sdk/esp32s3/qspi_opi/libesp_system.a b/tools/sdk/esp32s3/qspi_opi/libesp_system.a index 85d4dd9fa9e..aaf6967d5cf 100644 Binary files a/tools/sdk/esp32s3/qspi_opi/libesp_system.a and b/tools/sdk/esp32s3/qspi_opi/libesp_system.a differ diff --git a/tools/sdk/esp32s3/qspi_opi/libfreertos.a b/tools/sdk/esp32s3/qspi_opi/libfreertos.a index 4d9abc28b60..227ebe00bc5 100644 Binary files a/tools/sdk/esp32s3/qspi_opi/libfreertos.a and b/tools/sdk/esp32s3/qspi_opi/libfreertos.a differ diff --git a/tools/sdk/esp32s3/qspi_opi/libspi_flash.a b/tools/sdk/esp32s3/qspi_opi/libspi_flash.a index 41579a35f6f..7ed490d0bd8 100644 Binary files a/tools/sdk/esp32s3/qspi_opi/libspi_flash.a and b/tools/sdk/esp32s3/qspi_opi/libspi_flash.a differ diff --git a/tools/sdk/esp32s3/qspi_opi/sections.ld b/tools/sdk/esp32s3/qspi_opi/sections.ld index a686f42c264..6240bb1efe2 100644 --- a/tools/sdk/esp32s3/qspi_opi/sections.ld +++ b/tools/sdk/esp32s3/qspi_opi/sections.ld @@ -363,8 +363,8 @@ SECTIONS *(.ext_ram.bss*) *(.bss .bss.*) - *(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb .gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2 .sbss2.* .scommon .share.mem) *(.ext_ram.bss .ext_ram.bss.*) + *(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb .gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2 .sbss2.* .scommon .share.mem) *(COMMON) _bt_bss_start = ABSOLUTE(.); *libbt.a:(.bss .bss.* COMMON) diff --git a/tools/sdk/esp32s3/qspi_qspi/include/sdkconfig.h b/tools/sdk/esp32s3/qspi_qspi/include/sdkconfig.h index a3fb3a99512..f0aca26f93f 100644 --- a/tools/sdk/esp32s3/qspi_qspi/include/sdkconfig.h +++ b/tools/sdk/esp32s3/qspi_qspi/include/sdkconfig.h @@ -52,6 +52,7 @@ #define CONFIG_LIB_BUILDER_FLASHMODE "qio" #define CONFIG_LIB_BUILDER_FLASHFREQ "80m" #define CONFIG_ESP_RMAKER_ASSISTED_CLAIM 1 +#define CONFIG_ESP_RMAKER_CLAIM_TYPE 2 #define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" #define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024 #define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0 1 @@ -633,7 +634,6 @@ #define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2 #define CONFIG_HEAP_POISONING_LIGHT 1 #define CONFIG_HEAP_TRACING_OFF 1 -#define CONFIG_LIBSODIUM_USE_MBEDTLS_SHA 1 #define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1 #define CONFIG_LOG_DEFAULT_LEVEL 1 #define CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT 1 @@ -703,6 +703,7 @@ #define CONFIG_MBEDTLS_HARDWARE_AES 1 #define CONFIG_MBEDTLS_AES_USE_INTERRUPT 1 #define CONFIG_MBEDTLS_HARDWARE_MPI 1 +#define CONFIG_MBEDTLS_HARDWARE_SHA 1 #define CONFIG_MBEDTLS_ROM_MD5 1 #define CONFIG_MBEDTLS_HAVE_TIME 1 #define CONFIG_MBEDTLS_ECDSA_DETERMINISTIC 1 diff --git a/tools/sdk/esp32s3/qspi_qspi/libbootloader_support.a b/tools/sdk/esp32s3/qspi_qspi/libbootloader_support.a index 44fa510d303..e7a50225081 100644 Binary files a/tools/sdk/esp32s3/qspi_qspi/libbootloader_support.a and b/tools/sdk/esp32s3/qspi_qspi/libbootloader_support.a differ diff --git a/tools/sdk/esp32s3/qspi_qspi/libesp_hw_support.a b/tools/sdk/esp32s3/qspi_qspi/libesp_hw_support.a index 71ca6de8d28..648084459cd 100644 Binary files a/tools/sdk/esp32s3/qspi_qspi/libesp_hw_support.a and b/tools/sdk/esp32s3/qspi_qspi/libesp_hw_support.a differ diff --git a/tools/sdk/esp32s3/qspi_qspi/libesp_system.a b/tools/sdk/esp32s3/qspi_qspi/libesp_system.a index 090ee286fe9..f6d4f985618 100644 Binary files a/tools/sdk/esp32s3/qspi_qspi/libesp_system.a and b/tools/sdk/esp32s3/qspi_qspi/libesp_system.a differ diff --git a/tools/sdk/esp32s3/qspi_qspi/libfreertos.a b/tools/sdk/esp32s3/qspi_qspi/libfreertos.a index 4d9abc28b60..227ebe00bc5 100644 Binary files a/tools/sdk/esp32s3/qspi_qspi/libfreertos.a and b/tools/sdk/esp32s3/qspi_qspi/libfreertos.a differ diff --git a/tools/sdk/esp32s3/qspi_qspi/libspi_flash.a b/tools/sdk/esp32s3/qspi_qspi/libspi_flash.a index c58472253cf..a317ad8f1b3 100644 Binary files a/tools/sdk/esp32s3/qspi_qspi/libspi_flash.a and b/tools/sdk/esp32s3/qspi_qspi/libspi_flash.a differ diff --git a/tools/sdk/esp32s3/sdkconfig b/tools/sdk/esp32s3/sdkconfig index a34c9a99be0..1a519cf461f 100644 --- a/tools/sdk/esp32s3/sdkconfig +++ b/tools/sdk/esp32s3/sdkconfig @@ -145,7 +145,10 @@ CONFIG_LIB_BUILDER_FLASHFREQ="80m" # # ESP RainMaker Config # +# CONFIG_ESP_RMAKER_NO_CLAIM is not set +# CONFIG_ESP_RMAKER_SELF_CLAIM is not set CONFIG_ESP_RMAKER_ASSISTED_CLAIM=y +CONFIG_ESP_RMAKER_CLAIM_TYPE=2 CONFIG_ESP_RMAKER_MQTT_HOST="a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE=1024 # CONFIG_ESP_RMAKER_DISABLE_USER_MAPPING_PROV is not set @@ -1519,7 +1522,6 @@ CONFIG_HEAP_TRACING_OFF=y # # libsodium # -CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y # end of libsodium # @@ -1729,7 +1731,7 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y CONFIG_MBEDTLS_HARDWARE_AES=y CONFIG_MBEDTLS_AES_USE_INTERRUPT=y CONFIG_MBEDTLS_HARDWARE_MPI=y -# CONFIG_MBEDTLS_HARDWARE_SHA is not set +CONFIG_MBEDTLS_HARDWARE_SHA=y CONFIG_MBEDTLS_ROM_MD5=y # CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set # CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set diff --git a/variants/adafruit_feather_esp32s2/bootloader.bin b/variants/adafruit_feather_esp32s2/bootloader.bin index 857327ea6d4..543dce3106d 100644 Binary files a/variants/adafruit_feather_esp32s2/bootloader.bin and b/variants/adafruit_feather_esp32s2/bootloader.bin differ diff --git a/variants/adafruit_feather_esp32s2/tinyuf2.bin b/variants/adafruit_feather_esp32s2/tinyuf2.bin index 17143a676ee..9b39ac52093 100644 Binary files a/variants/adafruit_feather_esp32s2/tinyuf2.bin and b/variants/adafruit_feather_esp32s2/tinyuf2.bin differ diff --git a/variants/adafruit_feather_esp32s2_tft/variant.cpp b/variants/adafruit_feather_esp32s2_tft/variant.cpp index 750f5f72b02..548ce9ff4a1 100644 --- a/variants/adafruit_feather_esp32s2_tft/variant.cpp +++ b/variants/adafruit_feather_esp32s2_tft/variant.cpp @@ -31,7 +31,12 @@ extern "C" { // Initialize variant/board, called before setup() void initVariant(void) { - + // This board has power control pins, and we must set them to output and high + // in order to enable the NeoPixels, TFT & I2C + pinMode(NEOPIXEL_POWER, OUTPUT); + digitalWrite(NEOPIXEL_POWER, HIGH); + pinMode(TFT_I2C_POWER, OUTPUT); + digitalWrite(TFT_I2C_POWER, HIGH); } } diff --git a/variants/adafruit_feather_esp32s3_nopsram/bootloader.bin b/variants/adafruit_feather_esp32s3_nopsram/bootloader.bin new file mode 100644 index 00000000000..644fd7033ae Binary files /dev/null and b/variants/adafruit_feather_esp32s3_nopsram/bootloader.bin differ diff --git a/variants/adafruit_feather_esp32s3_nopsram/partitions.csv b/variants/adafruit_feather_esp32s3_nopsram/partitions.csv new file mode 100644 index 00000000000..4026378b6fb --- /dev/null +++ b/variants/adafruit_feather_esp32s3_nopsram/partitions.csv @@ -0,0 +1,10 @@ +# 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, 0, ota_0, 0x10000, 2048K, +ota_1, 0, ota_1, 0x210000, 2048K, +uf2, app, factory,0x410000, 256K, +ffat, data, fat, 0x450000, 3776K, diff --git a/variants/adafruit_feather_esp32s3_nopsram/pins_arduino.h b/variants/adafruit_feather_esp32s3_nopsram/pins_arduino.h new file mode 100644 index 00000000000..58a23a17f7c --- /dev/null +++ b/variants/adafruit_feather_esp32s3_nopsram/pins_arduino.h @@ -0,0 +1,71 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x239A +#define USB_PID 0x8113 +#define USB_MANUFACTURER "Adafruit" +#define USB_PRODUCT "Feather ESP32-S3 No PSRAM" +#define USB_SERIAL "" // Empty string for MAC adddress + +#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) + +#define LED_BUILTIN 13 + +#define PIN_NEOPIXEL 33 +#define NEOPIXEL_NUM 1 // number of neopixels +#define NEOPIXEL_POWER 21 // power pin +#define NEOPIXEL_POWER_ON HIGH // power pin state when on +#define I2C_POWER 7 // I2C power pin +#define PIN_I2C_POWER 7 // I2C power pin + + +static const uint8_t TX = 39; +static const uint8_t RX = 38; +#define TX1 TX +#define RX1 RX + +static const uint8_t SDA = 3; +static const uint8_t SCL = 4; + +static const uint8_t SS = 42; +static const uint8_t MOSI = 35; +static const uint8_t SCK = 36; +static const uint8_t MISO = 37; + +static const uint8_t A0 = 18; +static const uint8_t A1 = 17; +static const uint8_t A2 = 16; +static const uint8_t A3 = 15; +static const uint8_t A4 = 14; +static const uint8_t A5 = 8; +static const uint8_t A6 = 3; +static const uint8_t A7 = 4; +static const uint8_t A8 = 5; +static const uint8_t A9 = 6; +static const uint8_t A10 = 9; +static const uint8_t A11 = 10; +static const uint8_t A12 = 11; +static const uint8_t A13 = 12; +static const uint8_t A14 = 13; + +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; +static const uint8_t T10 = 10; +static const uint8_t T11 = 11; +static const uint8_t T12 = 12; +static const uint8_t T13 = 13; +static const uint8_t T14 = 14; + +#endif /* Pins_Arduino_h */ diff --git a/variants/adafruit_feather_esp32s3_nopsram/tinyuf2.bin b/variants/adafruit_feather_esp32s3_nopsram/tinyuf2.bin new file mode 100644 index 00000000000..18c2c554f76 Binary files /dev/null and b/variants/adafruit_feather_esp32s3_nopsram/tinyuf2.bin differ diff --git a/variants/adafruit_feather_esp32s3_nopsram/variant.cpp b/variants/adafruit_feather_esp32s3_nopsram/variant.cpp new file mode 100644 index 00000000000..52acb84102e --- /dev/null +++ b/variants/adafruit_feather_esp32s3_nopsram/variant.cpp @@ -0,0 +1,43 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2021 Ha Thach (tinyusb.org) for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#include "esp32-hal-gpio.h" +#include "pins_arduino.h" + +extern "C" { + +// Initialize variant/board, called before setup() +void initVariant(void) +{ + // This board has a power control pin, and we must set it to output and high + // in order to enable the NeoPixels. + pinMode(NEOPIXEL_POWER, OUTPUT); + digitalWrite(NEOPIXEL_POWER, HIGH); + + // turn on the I2C power by setting LDO enable pin 'high' + pinMode(PIN_I2C_POWER, OUTPUT); + digitalWrite(PIN_I2C_POWER, HIGH); +} +} diff --git a/variants/adafruit_qtpy_esp32s3_nopsram/bootloader.bin b/variants/adafruit_qtpy_esp32s3_nopsram/bootloader.bin new file mode 100644 index 00000000000..c0bf19f1338 Binary files /dev/null and b/variants/adafruit_qtpy_esp32s3_nopsram/bootloader.bin differ diff --git a/variants/adafruit_qtpy_esp32s3_nopsram/partitions.csv b/variants/adafruit_qtpy_esp32s3_nopsram/partitions.csv new file mode 100644 index 00000000000..4026378b6fb --- /dev/null +++ b/variants/adafruit_qtpy_esp32s3_nopsram/partitions.csv @@ -0,0 +1,10 @@ +# 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, 0, ota_0, 0x10000, 2048K, +ota_1, 0, ota_1, 0x210000, 2048K, +uf2, app, factory,0x410000, 256K, +ffat, data, fat, 0x450000, 3776K, diff --git a/variants/adafruit_qtpy_esp32s3_nopsram/pins_arduino.h b/variants/adafruit_qtpy_esp32s3_nopsram/pins_arduino.h new file mode 100644 index 00000000000..86e893129fe --- /dev/null +++ b/variants/adafruit_qtpy_esp32s3_nopsram/pins_arduino.h @@ -0,0 +1,56 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x239A +#define USB_PID 0x8119 +#define USB_MANUFACTURER "Adafruit" +#define USB_PRODUCT "QT Py ESP32-S3 No PSRAM" +#define USB_SERIAL "" // Empty string for MAC adddress + +#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) + +#define PIN_NEOPIXEL 39 +#define NEOPIXEL_NUM 1 // number of neopixels +#define NEOPIXEL_POWER 38 // power pin +#define NEOPIXEL_POWER_ON HIGH // power pin state when on + +static const uint8_t TX = 5; +static const uint8_t RX = 16; +#define TX1 TX +#define RX1 RX + +static const uint8_t SDA = 7; +static const uint8_t SCL = 6; + +static const uint8_t SDA1 = 41; +static const uint8_t SCL1 = 40; + +static const uint8_t SS = 42; +static const uint8_t MOSI = 35; +static const uint8_t SCK = 36; +static const uint8_t MISO = 37; + +static const uint8_t A0 = 18; +static const uint8_t A1 = 17; +static const uint8_t A2 = 9; +static const uint8_t A3 = 8; +static const uint8_t A4 = 7; +static const uint8_t A5 = 6; +static const uint8_t A6 = 5; +static const uint8_t A7 = 16; + +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; + +#endif /* Pins_Arduino_h */ diff --git a/variants/adafruit_qtpy_esp32s3_nopsram/tinyuf2.bin b/variants/adafruit_qtpy_esp32s3_nopsram/tinyuf2.bin new file mode 100644 index 00000000000..748dcb7a608 Binary files /dev/null and b/variants/adafruit_qtpy_esp32s3_nopsram/tinyuf2.bin differ diff --git a/variants/adafruit_qtpy_esp32s3_nopsram/variant.cpp b/variants/adafruit_qtpy_esp32s3_nopsram/variant.cpp new file mode 100644 index 00000000000..5f7a3c0b55d --- /dev/null +++ b/variants/adafruit_qtpy_esp32s3_nopsram/variant.cpp @@ -0,0 +1,39 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2021 Ha Thach (tinyusb.org) for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#include "esp32-hal-gpio.h" +#include "pins_arduino.h" + +extern "C" { + +// Initialize variant/board, called before setup() +void initVariant(void) +{ + // This board has a power control pin, and we must set it to output and high + // in order to enable the NeoPixels. + pinMode(NEOPIXEL_POWER, OUTPUT); + digitalWrite(NEOPIXEL_POWER, HIGH); +} +} diff --git a/variants/esp32s3/pins_arduino.h b/variants/esp32s3/pins_arduino.h index 0824bf05fb7..59f298e4965 100644 --- a/variants/esp32s3/pins_arduino.h +++ b/variants/esp32s3/pins_arduino.h @@ -61,7 +61,4 @@ static const uint8_t T12 = 12; static const uint8_t T13 = 13; static const uint8_t T14 = 14; -static const uint8_t DAC1 = 17; -static const uint8_t DAC2 = 18; - #endif /* Pins_Arduino_h */ diff --git a/variants/esp32s3box/pins_arduino.h b/variants/esp32s3box/pins_arduino.h index 054fe9689d1..73a1527e8a9 100644 --- a/variants/esp32s3box/pins_arduino.h +++ b/variants/esp32s3box/pins_arduino.h @@ -62,6 +62,7 @@ static const uint8_t T14 = 14; #define I2S_SDIN 16 #define I2S_DOUT 15 +<<<<<<< HEAD #define BOARD_HAS_SDMMC #define SDMMC_CLK 13 #define SDMMC_CMD 11 @@ -71,6 +72,8 @@ static const uint8_t T14 = 14; #define SDMMC_D3 9 #define BOARD_MAX_SDMMC_FREQ SDMMC_FREQ_DEFAULT +======= +>>>>>>> orig_master_espressif #define PA_PIN 46 //Audio Amp Power #define MUTE_PIN 1 //MUTE Button #define TS_IRQ 3 //Touch Screen IRQ diff --git a/variants/esp32s3usbotg/pins_arduino.h b/variants/esp32s3usbotg/pins_arduino.h new file mode 100644 index 00000000000..94edeeca74c --- /dev/null +++ b/variants/esp32s3usbotg/pins_arduino.h @@ -0,0 +1,98 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +#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 = 45; +static const uint8_t SCL = 46; + +static const uint8_t SS = 34; +static const uint8_t MOSI = 35; +static const uint8_t MISO = 37; +static const uint8_t SCK = 36; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; + +static const uint8_t T3 = 3; + +// SDCARD Slot +#define BOARD_HAS_SDMMC +#define SDMMC_D2 33 // SDMMC Data2 +#define SDMMC_D3 34 // SDMMC Data3 / SPI CS +#define SDMMC_CMD 35 // SDMMC CMD / SPI MOSI +#define SDMMC_CLK 36 // SDMMC CLK / SPI SCK +#define SDMMC_D0 37 // SDMMC Data0 / SPI MISO +#define SDMMC_D1 38 // SDMMC Data1 +#define BOARD_MAX_SDMMC_FREQ SDMMC_FREQ_DEFAULT + +// 240x240 LCD +#define BOARD_HAS_SPI_LCD +#define LCD_MODEL ST7789 +#define LCD_WIDTH 240 +#define LCD_HEIGHT 240 // *RAM height is actually 320! +#define LCD_MISO -1 // LCD Does not use MISO. +#define LCD_DC 4 // Used to switch data and command status. +#define LCD_CS 5 // used to enable LCD, low level to enable. +#define LCD_CLK 6 // LCD SPI Clock. +#define LCD_MOSI 7 // LCD SPI MOSI. +#define LCD_RST 8 // used to reset LCD, low level to reset. +#define LCD_BL 9 // LCD backlight control. + +// Buttons +#define BUTTON_OK 0 // OK button, low level when pressed. +#define BUTTON_UP 10 // UP button, low level when pressed. +#define BUTTON_DOWN 11 // Down button, low level when pressed. +#define BUTTON_MENU 14 // Menu button, low level when pressed. + +// LEDs +#define LED_GREEN 15 // the light is lit when set high level. +#define LED_YELLOW 16 // the light is lit when set high level. + +// Board Controls +#define DEV_VBUS_EN 12 // High level to enable DEV_VBUS power supply. +#define BOOST_EN 13 // High level to enable Battery Boost circuit. +#define LIMIT_EN 17 // Enable USB_HOST current limiting IC, high level enable. +#define USB_HOST_EN 18 // Used to switch the USB interface. When high level, the USB_HOST interface is enabled. When low level, the USB_DEV interface is enabled. + +// Board Sensors +#define OVER_CURRENT 21 // Current overrun signal, high level means overrun. +#define HOST_VOLTS 1 // USB_DEV voltage monitoring, ADC1 channel 0. actual_v = value_v * 3.7 +#define BAT_VOLTS 2 // Battery voltage monitoring, ADC1 channel 1. actual_v = value_v * 2 + +// USB Port +#define USB_DN 19 // USB D- +#define USB_DP 20 // USB D+ + +// Bottom header +#define MTCK 39 +#define MTDO 40 +#define MTDI 41 +#define MTMS 42 +// #define FREE_6 3 // Idle, can be customized. +// #define FREE_4 26 // Idle, can be customized. +// #define FREE_1 45 // Idle, can be customized. +// #define FREE_2 46 // Idle, can be customized. +// #define FREE_5 47 // Idle, can be customized. +// #define FREE_3 48 // Idle, can be customized. + +typedef enum { USB_HOST_POWER_OFF, USB_HOST_POWER_VBUS, USB_HOST_POWER_BAT } UsbHostPower_t; +void usbHostPower(UsbHostPower_t mode); +void usbHostEnable(bool enable); + +#endif /* Pins_Arduino_h */ diff --git a/variants/esp32s3usbotg/variant.cpp b/variants/esp32s3usbotg/variant.cpp new file mode 100644 index 00000000000..f5f24fdac2a --- /dev/null +++ b/variants/esp32s3usbotg/variant.cpp @@ -0,0 +1,46 @@ +#include "Arduino.h" + +void usbHostPower(UsbHostPower_t mode){ + static UsbHostPower_t m = USB_HOST_POWER_OFF; + if(m == mode){ + return; + } + if(mode == USB_HOST_POWER_OFF){ + digitalWrite(LIMIT_EN, LOW); + if(m == USB_HOST_POWER_VBUS){ + digitalWrite(DEV_VBUS_EN, LOW); + } else if(m == USB_HOST_POWER_BAT){ + digitalWrite(BOOST_EN, LOW); + } + } else if(mode == USB_HOST_POWER_VBUS){ + if(m == USB_HOST_POWER_BAT){ + digitalWrite(BOOST_EN, LOW); + } + digitalWrite(DEV_VBUS_EN, HIGH); + } else if(mode == USB_HOST_POWER_BAT){ + if(m == USB_HOST_POWER_VBUS){ + digitalWrite(DEV_VBUS_EN, LOW); + } + digitalWrite(BOOST_EN, HIGH); + } + if(mode != USB_HOST_POWER_OFF){ + digitalWrite(LIMIT_EN, HIGH); + } + m = mode; +} + +void usbHostEnable(bool enable){ + digitalWrite(USB_HOST_EN, enable); +} + +extern "C" void initVariant(void){ + // Route USB to Device Side + pinMode(BOOST_EN, OUTPUT); digitalWrite(BOOST_EN, LOW); + pinMode(LIMIT_EN, OUTPUT); digitalWrite(LIMIT_EN, LOW); + pinMode(DEV_VBUS_EN, OUTPUT); digitalWrite(DEV_VBUS_EN, LOW); + pinMode(USB_HOST_EN, OUTPUT); digitalWrite(USB_HOST_EN, LOW); + + // Turn Off LCD + pinMode(LCD_RST, OUTPUT); digitalWrite(LCD_RST, LOW); + pinMode(LCD_BL, OUTPUT); digitalWrite(LCD_BL, LOW); +}