diff --git a/Jenkinsfile b/Jenkinsfile index f2d40d5f06..0331a984f8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ node { stage('Checkout') { checkout scm sh 'rm -rf esp-idf' - sh 'git clone --depth=1 --recursive -b idf_v3.2 https://github.com/pycom/pycom-esp-idf.git esp-idf' + sh 'git clone --depth=1 --recursive -b idf_v3.3.1 https://github.com/pycom/pycom-esp-idf.git esp-idf' } stage('git-tag') { diff --git a/README.md b/README.md index c440a719da..13446f79da 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ board (PyBoard), the officially supported reference electronic circuit board. The following components are actively maintained by Pycom: - py/ -- the core Python implementation, including compiler, runtime, and core library. -- exp32/ -- a version of MicroPython that runs on the ESP32 based boards from Pycom. +- esp32/ -- a version of MicroPython that runs on the ESP32 based boards from Pycom. - tests/ -- test framework and test scripts. Additional components: @@ -74,7 +74,7 @@ Then when you need the toolchain you can type ``get_esp32`` on the command line You also need the ESP IDF along side this repository in order to build the ESP32 port. To get it: - $ git clone --recursive -b idf_v3.2 https://github.com/pycom/pycom-esp-idf.git + $ git clone --recursive -b idf_v3.3.1 https://github.com/pycom/pycom-esp-idf.git After cloning, if you did not specify the --recursive option, make sure to checkout all the submodules: diff --git a/esp32/Makefile b/esp32/Makefile index 9be1f4155a..cee2ea1ffc 100644 --- a/esp32/Makefile +++ b/esp32/Makefile @@ -14,7 +14,7 @@ ifeq ($(wildcard boards/$(BOARD)/.),) $(error Invalid BOARD specified) endif -IDF_VERSION=3.2 +IDF_VERSION=3.3.1 TARGET ?= boot_app @@ -103,17 +103,10 @@ LIBS = -L$(ESP_IDF_COMP_PATH)/esp32/lib -L$(ESP_IDF_COMP_PATH)/esp32/ld -L$(ESP_ $(ESP_IDF_COMP_PATH)/newlib/lib/libc-psram-workaround.a \ -lfreertos -ljson -ljsmn -llwip -lnewlib -lvfs -lopenssl -lmbedtls -lwpa_supplicant \ -lxtensa-debug-module -lbt -lsdmmc -lsoc -lheap -lbootloader_support -lmicro-ecc \ - -u ld_include_panic_highint_hdl -lsmartconfig_ack -lmesh -lesp_ringbuf -lcoap -ifeq ($(BOARD), $(filter $(BOARD), FIPY)) - LIBS += sigfox/modsigfox_fipy.a -endif - -ifeq ($(BOARD), $(filter $(BOARD), LOPY4)) - LIBS += sigfox/modsigfox_lopy4.a -endif - -ifeq ($(BOARD), $(filter $(BOARD), SIPY)) - LIBS += sigfox/modsigfox_sipy.a + -u ld_include_panic_highint_hdl -lsmartconfig_ack -lmesh -lesp_ringbuf -lcoap -lmdns -lefuse -lespcoredump -lapp_update +ifeq ($(BOARD), $(filter $(BOARD), SIPY LOPY4 FIPY)) + LIBS += sigfox/modsigfox_$(BOARD).a +$(BUILD)/application.elf: sigfox/modsigfox_$(BOARD).a endif ifeq ($(OPENTHREAD), on) @@ -134,7 +127,7 @@ endif #ifeq ($(LTE_LOG_BUFF),1) B_LIBS = -Lbootloader/lib -Lbootloader -L$(BUILD)/bootloader -L$(ESP_IDF_COMP_PATH)/esp32/ld \ -L$(ESP_IDF_COMP_PATH)/esp32/lib -llog -lcore -lbootloader_support \ - -lspi_flash -lsoc -lmicro-ecc -lgcc -lstdc++ -lgcov + -lspi_flash -lsoc -lmicro-ecc -lgcc -lstdc++ -lgcov -lefuse # objcopy paramters, to transform a binary file into an object file OBJCOPY_EMBED_ARGS = --input-target binary --output-target elf32-xtensa-le --binary-architecture xtensa --rename-section .data=.rodata.embedded diff --git a/esp32/PyJTAG/Readme.md b/esp32/PyJTAG/Readme.md new file mode 100644 index 0000000000..eae62c271e --- /dev/null +++ b/esp32/PyJTAG/Readme.md @@ -0,0 +1,57 @@ +# Short readme for how to use the PyJTAG + +Create the firmware with `BTYPE=debug` flag. +Do not use the default pins assigned to UART, SPI, CAN because they are used by the JTAG. Pins not to be used: P4, P9, P10, P23 + +Detailed information are here: https://pycomiot.atlassian.net/wiki/spaces/FIR/pages/966295564/Usage+of+PyJTAG + +Setup the PyJTAG board's switches: + * ESP32 JTAG: all turned ON + * ESP32 B.LOADER: all turned ON except SAFE_BOOT_SW which is OFF + * TO LTE UART 1/2: does not matter + * CURRENT SHUNTS: connected + +Place the Pycom board with the reset button towards the Current Shunts. + +Generally follow these rules to setup JTAG debugging on your OS: https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/jtag-debugging/index.html + +(Download link of OpenOCD for ESP32 from Espressif: https://github.com/espressif/openocd-esp32/releases) + +Connect the PyJTAG via usb. You see four new USB devices: +``` +$ lsusb -d 0403: +Bus 001 Device 010: ID 0403:6011 Future Technology Devices International, Ltd FT4232H Quad HS USB-UART/FIFO IC +$ ls /dev/ttyUSB? +/dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3 +``` + +Go to `esp32` folder in Firmware-Development repository and run: +``` +PATH_TO_OPENOCD/bin/openocd -s PATH_TO_OPENOCD/share/openocd/scripts -s PyJTAG -f PyJTAG/interface/ftdi/esp32-pycom.cfg -f PyJTAG/board/esp32-pycom.cfg +``` + +Output should be like: +``` +Open On-Chip Debugger v0.10.0-esp32-20191114 (2019-11-14-14:15) +Licensed under GNU GPL v2 +For bug reports, read + http://openocd.org/doc/doxygen/bugs.html +none separate +adapter speed: 20000 kHz +Info : Configured 2 cores +Info : Listening on port 6666 for tcl connections +Info : Listening on port 4444 for telnet connections +Error: type 'esp32' is missing virt2phys +Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling" +Info : clock speed 20000 kHz +Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) +Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) +Info : Listening on port 3333 for gdb connections +``` + +When OpenOCD is running, start GDB from `esp32` folder. Assuming you have a FIPY: +``` +xtensa-esp32-elf-gdb -x PyJTAG/gdbinit build/FIPY/debug/application.elf +``` + +In `PyJTAG/gdbinit` a breakpoint is configured at `TASK_Micropython`, so execution should stop there first. diff --git a/esp32/PyJTAG/board/esp32-pycom.cfg b/esp32/PyJTAG/board/esp32-pycom.cfg new file mode 100644 index 0000000000..c294242718 --- /dev/null +++ b/esp32/PyJTAG/board/esp32-pycom.cfg @@ -0,0 +1,2 @@ +set ESP32_FLASH_VOLTAGE 3.3 +source [find target/esp32-pycom.cfg] \ No newline at end of file diff --git a/esp32/PyJTAG/gdbinit b/esp32/PyJTAG/gdbinit new file mode 100644 index 0000000000..00351df9ae --- /dev/null +++ b/esp32/PyJTAG/gdbinit @@ -0,0 +1,5 @@ +target remote :3333 +mon reset halt +flushregs +thb TASK_Micropython +c diff --git a/esp32/PyJTAG/interface/ftdi/esp32-pycom.cfg b/esp32/PyJTAG/interface/ftdi/esp32-pycom.cfg new file mode 100644 index 0000000000..ebc6a2d22a --- /dev/null +++ b/esp32/PyJTAG/interface/ftdi/esp32-pycom.cfg @@ -0,0 +1,35 @@ +# +# Driver for the FT4232HL JTAG chip on the Pycom's PyJTAG board +# + + +interface ftdi +ftdi_vid_pid 0x0403 0x6011 + +# interface 1 is the uart +ftdi_channel 0 + +# TCK, TDI, TDO, TMS: ADBUS0-3 +# LEDs: ACBUS4-7 + +ftdi_layout_init 0x0008 0xf00b +#ftdi_layout_signal LED -data 0x1000 +#ftdi_layout_signal LED2 -data 0x2000 +#ftdi_layout_signal LED3 -data 0x4000 +#ftdi_layout_signal LED4 -data 0x8000 + +# ESP32 series chips do not have a TRST input, and the SRST line is connected +# to the EN pin. +# The target code doesn't handle SRST reset properly yet, so this is +# commented out: +# ftdi_layout_signal nSRST -oe 0x0020 + +reset_config none + +# The speed of the JTAG interface, in KHz. If you get DSR/DIR errors (and they +# do not relate to OpenOCD trying to read from a memory range without physical +# memory being present there), you can try lowering this. +# +# On DevKit-J, this can go as high as 20MHz if CPU frequency is 80MHz, or 26MHz +# if CPU frequency is 160MHz or 240MHz. +adapter_khz 20000 diff --git a/esp32/PyJTAG/target/esp32-pycom.cfg b/esp32/PyJTAG/target/esp32-pycom.cfg new file mode 100644 index 0000000000..35fd8c0e3b --- /dev/null +++ b/esp32/PyJTAG/target/esp32-pycom.cfg @@ -0,0 +1,69 @@ +# The ESP32 only supports JTAG. +transport select jtag + +# Source the ESP common configuration file +source [find target/esp_common.cfg] + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME esp32 +} + +if { [info exists CPUTAPID] } { + set _CPUTAPID $CPUTAPID +} else { + set _CPUTAPID 0x120034e5 +} + +if { [info exists ESP32_ONLYCPU] } { + set _ONLYCPU $ESP32_ONLYCPU +} else { + set _ONLYCPU 3 +} + +if { [info exists ESP32_FLASH_VOLTAGE] } { + set _FLASH_VOLTAGE $ESP32_FLASH_VOLTAGE +} else { + set _FLASH_VOLTAGE 3.3 +} + +set _TARGETNAME $_CHIPNAME +set _CPU0NAME cpu0 +set _CPU1NAME cpu1 +set _TAPNAME $_CHIPNAME.$_CPU0NAME + +jtag newtap $_CHIPNAME $_CPU0NAME -irlen 5 -expected-id $_CPUTAPID +if { $_ONLYCPU != 1 } { + jtag newtap $_CHIPNAME $_CPU1NAME -irlen 5 -expected-id $_CPUTAPID +} else { + jtag newtap $_CHIPNAME $_CPU1NAME -irlen 5 -disable -expected-id $_CPUTAPID +} + +if { $_RTOS == "none" } { + target create $_TARGETNAME esp32 -endian little -chain-position $_TAPNAME +} else { + target create $_TARGETNAME esp32 -endian little -chain-position $_TAPNAME -rtos $_RTOS +} + +configure_esp_workarea $_TARGETNAME 0x40090000 0x3400 0x3FFC0000 0x6000 +configure_esp_flash_bank $_TARGETNAME $_TARGETNAME $_FLASH_SIZE + +esp32 flashbootstrap $_FLASH_VOLTAGE +esp32 maskisr on +if { $_SEMIHOST_BASEDIR != "" } { + esp32 semihost_basedir $_SEMIHOST_BASEDIR +} +if { $_FLASH_SIZE == 0 } { + gdb_breakpoint_override hard +} + +# special function to program ESP32, it differs from the original 'program' that +# it verifies written image by reading flash directly, instead of reading memory mapped flash regions +proc program_esp32 {filename args} { + program_esp $filename $args +} + +add_help_text program_esp32 "write an image to flash, address is only required for binary images. verify, reset, exit are optional" +add_usage_text program_esp32 " \[address\] \[verify\] \[reset\] \[exit\]" + diff --git a/esp32/application.mk b/esp32/application.mk index a9878b71e3..a119b8a616 100644 --- a/esp32/application.mk +++ b/esp32/application.mk @@ -77,6 +77,7 @@ APP_INC += -I$(ESP_IDF_COMP_PATH)/coap/libcoap/include/coap APP_INC += -I$(ESP_IDF_COMP_PATH)/coap/libcoap/examples APP_INC += -I$(ESP_IDF_COMP_PATH)/coap/port/include APP_INC += -I$(ESP_IDF_COMP_PATH)/coap/port/include/coap +APP_INC += -I$(ESP_IDF_COMP_PATH)/mdns/include APP_INC += -I../lib/mp-readline APP_INC += -I../lib/netutils APP_INC += -I../lib/oofatfs @@ -160,6 +161,7 @@ APP_MODS_SRC_C = $(addprefix mods/,\ lwipsocket.c \ machtouch.c \ modcoap.c \ + modmdns.c \ ) APP_MODS_LORA_SRC_C = $(addprefix mods/,\ @@ -183,6 +185,7 @@ APP_UTIL_SRC_C = $(addprefix util/,\ mpsleep.c \ timeutils.c \ esp32chipinfo.c \ + pycom_general_util.c \ ) APP_FATFS_SRC_C = $(addprefix fatfs/src/,\ @@ -245,7 +248,7 @@ APP_SX1276_SRC_C = $(addprefix drivers/sx127x/,\ sx1276/sx1276.c \ ) -APP_SIGFOX_SRC_SIPY_C = $(addprefix sigfox/,\ +APP_SIGFOX_SRC_SIPY_C = $(addprefix sigfox/src/,\ manufacturer_api.c \ radio.c \ ti_aes_128.c \ @@ -254,7 +257,7 @@ APP_SIGFOX_SRC_SIPY_C = $(addprefix sigfox/,\ modsigfox.c \ ) -APP_SIGFOX_SRC_FIPY_LOPY4_C = $(addprefix sigfox/,\ +APP_SIGFOX_SRC_FIPY_LOPY4_C = $(addprefix sigfox/src/,\ manufacturer_api.c \ radio_sx127x.c \ ti_aes_128.c \ @@ -267,7 +270,7 @@ APP_SIGFOX_MOD_SRC_C = $(addprefix mods/,\ modsigfox_api.c \ ) -APP_SIGFOX_TARGET_SRC_C = $(addprefix sigfox/targets/,\ +APP_SIGFOX_TARGET_SRC_C = $(addprefix sigfox/src/targets/,\ cc112x_spi.c \ hal_int.c \ hal_spi_rf_trxeb.c \ @@ -366,7 +369,7 @@ SRC_QSTR_AUTO_DEPS += BOOT_LDFLAGS = $(LDFLAGS) -T esp32.bootloader.ld -T esp32.rom.ld -T esp32.peripherals.ld -T esp32.bootloader.rom.ld -T esp32.rom.spiram_incompatible_fns.ld # add the application linker script(s) -APP_LDFLAGS += $(LDFLAGS) -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -T wifi_iram.ld +APP_LDFLAGS += $(LDFLAGS) -T esp32_out.ld -T esp32.project.ld -T esp32.rom.ld -T esp32.peripherals.ld # add the application specific CFLAGS CFLAGS += $(APP_INC) -DMICROPY_NLR_SETJMP=1 -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"' -DHAVE_CONFIG_H -DESP_PLATFORM -DFFCONF_H=\"lib/oofatfs/ffconf.h\" -DWITH_POSIX @@ -512,6 +515,9 @@ endif ifeq ($(TARGET), boot_app) all: $(BOOT_BIN) $(APP_BIN) endif +ifeq ($(TARGET), sigfox) +include sigfox.mk +endif .PHONY: all CHECK_DEP $(info $(VARIANT) Variant) @@ -525,6 +531,14 @@ CFLAGS += -DCONFIG_FLASH_ENCRYPTION_ENABLED=1 # it can also be added permanently in sdkconfig.h CFLAGS += -DCONFIG_SECURE_BOOT_ENABLED=1 +define resolvepath +$(abspath $(foreach dir,$(1),$(if $(filter /%,$(dir)),$(dir),$(subst //,/,$(2)/$(dir))))) +endef + +define dequote +$(subst ",,$(1)) +endef + # find the configured private key file ORIG_SECURE_KEY := $(call resolvepath,$(call dequote,$(SECURE_KEY)),$(PROJECT_PATH)) @@ -639,7 +653,7 @@ $(BUILD)/application.a: $(OBJ) $(ECHO) "AR $@" $(Q) rm -f $@ $(Q) $(AR) cru $@ $^ -$(BUILD)/application.elf: $(BUILD)/application.a $(BUILD)/esp32_out.ld $(SECURE_BOOT_VERIFICATION_KEY) +$(BUILD)/application.elf: $(BUILD)/application.a $(BUILD)/esp32_out.ld esp32.project.ld $(SECURE_BOOT_VERIFICATION_KEY) ifeq ($(SECURE), on) # unpack libbootloader_support.a, and archive again using the right key for verifying signatures $(ECHO) "Inserting verification key $(SECURE_BOOT_VERIFICATION_KEY) in $@" @@ -807,6 +821,7 @@ $(OBJ): | $(GEN_PINS_HDR) CHECK_DEP: $(Q) bash tools/idfVerCheck.sh $(IDF_PATH) "$(IDF_VERSION)" $(Q) bash tools/mpy-build-check.sh $(BOARD) $(BTYPE) $(VARIANT) + $(Q) $(PYTHON) check_secure_boot.py --SECURE $(SECURE) ifeq ($(COPY_IDF_LIB), 1) $(ECHO) "COPY IDF LIBRARIES" $(Q) $(PYTHON) get_idf_libs.py --idflibs $(IDF_PATH)/examples/wifi/scan/build diff --git a/esp32/bootloader/lib/libbootloader_support.a b/esp32/bootloader/lib/libbootloader_support.a index df62723f04..3e926b9c93 100644 Binary files a/esp32/bootloader/lib/libbootloader_support.a and b/esp32/bootloader/lib/libbootloader_support.a differ diff --git a/esp32/bootloader/lib/libefuse.a b/esp32/bootloader/lib/libefuse.a new file mode 100644 index 0000000000..e0b44b4dd2 Binary files /dev/null and b/esp32/bootloader/lib/libefuse.a differ diff --git a/esp32/bootloader/lib/liblog.a b/esp32/bootloader/lib/liblog.a index 3abb4163f3..45c1880351 100644 Binary files a/esp32/bootloader/lib/liblog.a and b/esp32/bootloader/lib/liblog.a differ diff --git a/esp32/bootloader/lib/libmicro-ecc.a b/esp32/bootloader/lib/libmicro-ecc.a index f2bcb6bbb1..dd735bbb70 100644 Binary files a/esp32/bootloader/lib/libmicro-ecc.a and b/esp32/bootloader/lib/libmicro-ecc.a differ diff --git a/esp32/bootloader/lib/libsoc.a b/esp32/bootloader/lib/libsoc.a index 5e1d9d8c61..5836d3a4cf 100644 Binary files a/esp32/bootloader/lib/libsoc.a and b/esp32/bootloader/lib/libsoc.a differ diff --git a/esp32/bootloader/lib/libspi_flash.a b/esp32/bootloader/lib/libspi_flash.a index 1d353388d1..e5d9e1b443 100644 Binary files a/esp32/bootloader/lib/libspi_flash.a and b/esp32/bootloader/lib/libspi_flash.a differ diff --git a/esp32/check_secure_boot.py b/esp32/check_secure_boot.py new file mode 100644 index 0000000000..f8dd2b4728 --- /dev/null +++ b/esp32/check_secure_boot.py @@ -0,0 +1,18 @@ +import argparse + + +def main(): + cmd_parser = argparse.ArgumentParser() + cmd_parser.add_argument('--SECURE', default=None) + cmd_args = cmd_parser.parse_args() + + secure = cmd_args.SECURE + with open("sdkconfig.h") as sdkconfig: + if any("CONFIG_SECURE_BOOT_ENABLED" in l for l in sdkconfig.readlines()): + if(secure != "on"): + print("If CONFIG_SECURE_BOOT_ENABLED is defined in sdkconfig.h, the SECURE=on must be used when building the Firmware!") + # Non zero exit code means error + exit(1) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/esp32/esp32.project.ld b/esp32/esp32.project.ld new file mode 100644 index 0000000000..ea944aeded --- /dev/null +++ b/esp32/esp32.project.ld @@ -0,0 +1,618 @@ +/* Automatically generated file; DO NOT EDIT */ +/* Espressif IoT Development Framework Linker Script */ +/* Generated from: /home/gezahusi/Work/Repositories/pycom-esp-idf/components/esp32/ld/esp32.project.ld.in */ + +/* Default entry point: */ +ENTRY(call_start_cpu0); + +SECTIONS +{ + /* RTC fast memory holds RTC wake stub code, + including from any source file named rtc_wake_stub*.c + */ + .rtc.text : + { + . = ALIGN(4); + + *( .rtc.literal .rtc.text .rtc.text.*) + + *rtc_wake_stub*.*(.literal .text .literal.* .text.*) + _rtc_text_end = ABSOLUTE(.); + } > rtc_iram_seg + + /* + This section is required to skip rtc.text area because rtc_iram_seg and + rtc_data_seg are reflect the same address space on different buses. + */ + .rtc.dummy : + { + _rtc_dummy_start = ABSOLUTE(.); + _rtc_fast_start = ABSOLUTE(.); + . = SIZEOF(.rtc.text); + _rtc_dummy_end = ABSOLUTE(.); + } > rtc_data_seg + + /* This section located in RTC FAST Memory area. + It holds data marked with RTC_FAST_ATTR attribute. + See the file "esp_attr.h" for more information. + */ + .rtc.force_fast : + { + . = ALIGN(4); + _rtc_force_fast_start = ABSOLUTE(.); + *(.rtc.force_fast .rtc.force_fast.*) + . = ALIGN(4) ; + _rtc_force_fast_end = ABSOLUTE(.); + } > rtc_data_seg + + /* RTC data section holds RTC wake stub + data/rodata, including from any source file + named rtc_wake_stub*.c and the data marked with + RTC_DATA_ATTR, RTC_RODATA_ATTR attributes. + The memory location of the data is dependent on + CONFIG_ESP32_RTCDATA_IN_FAST_MEM option. + */ + .rtc.data : + { + _rtc_data_start = ABSOLUTE(.); + + *( .rtc.data .rtc.data.* .rtc.rodata .rtc.rodata.*) + + *rtc_wake_stub*.*(.data .rodata .data.* .rodata.* .bss .bss.*) + _rtc_data_end = ABSOLUTE(.); + } > rtc_data_location + + /* RTC bss, from any source file named rtc_wake_stub*.c */ + .rtc.bss (NOLOAD) : + { + _rtc_bss_start = ABSOLUTE(.); + *rtc_wake_stub*.*(.bss .bss.*) + *rtc_wake_stub*.*(COMMON) + + *( .rtc.bss) + + _rtc_bss_end = ABSOLUTE(.); + } > rtc_data_location + + /* This section holds data that should not be initialized at power up + and will be retained during deep sleep. + User data marked with RTC_NOINIT_ATTR will be placed + into this section. See the file "esp_attr.h" for more information. + The memory location of the data is dependent on + CONFIG_ESP32_RTCDATA_IN_FAST_MEM option. + */ + .rtc_noinit (NOLOAD): + { + . = ALIGN(4); + _rtc_noinit_start = ABSOLUTE(.); + *(.rtc_noinit .rtc_noinit.*) + . = ALIGN(4) ; + _rtc_noinit_end = ABSOLUTE(.); + } > rtc_data_location + + /* This section located in RTC SLOW Memory area. + It holds data marked with RTC_SLOW_ATTR attribute. + See the file "esp_attr.h" for more information. + */ + .rtc.force_slow : + { + . = ALIGN(4); + _rtc_force_slow_start = ABSOLUTE(.); + *(.rtc.force_slow .rtc.force_slow.*) + . = ALIGN(4) ; + _rtc_force_slow_end = ABSOLUTE(.); + } > rtc_slow_seg + + /* Get size of rtc slow data based on rtc_data_location alias */ + _rtc_slow_length = (ORIGIN(rtc_slow_seg) == ORIGIN(rtc_data_location)) + ? (_rtc_force_slow_end - _rtc_data_start) + : (_rtc_force_slow_end - _rtc_force_slow_start); + + _rtc_fast_length = (ORIGIN(rtc_slow_seg) == ORIGIN(rtc_data_location)) + ? (_rtc_force_fast_end - _rtc_fast_start) + : (_rtc_noinit_end - _rtc_fast_start); + + ASSERT((_rtc_slow_length <= LENGTH(rtc_slow_seg)), + "RTC_SLOW segment data does not fit.") + + ASSERT((_rtc_fast_length <= LENGTH(rtc_data_seg)), + "RTC_FAST segment data does not fit.") + + /* Send .iram0 code to iram */ + .iram0.vectors : + { + _iram_start = ABSOLUTE(.); + /* Vectors go to IRAM */ + _init_start = ABSOLUTE(.); + /* Vectors according to builds/RF-2015.2-win32/esp108_v1_2_s5_512int_2/config.html */ + . = 0x0; + KEEP(*(.WindowVectors.text)); + . = 0x180; + KEEP(*(.Level2InterruptVector.text)); + . = 0x1c0; + KEEP(*(.Level3InterruptVector.text)); + . = 0x200; + KEEP(*(.Level4InterruptVector.text)); + . = 0x240; + KEEP(*(.Level5InterruptVector.text)); + . = 0x280; + KEEP(*(.DebugExceptionVector.text)); + . = 0x2c0; + KEEP(*(.NMIExceptionVector.text)); + . = 0x300; + KEEP(*(.KernelExceptionVector.text)); + . = 0x340; + KEEP(*(.UserExceptionVector.text)); + . = 0x3C0; + KEEP(*(.DoubleExceptionVector.text)); + . = 0x400; + *(.*Vector.literal) + + *(.UserEnter.literal); + *(.UserEnter.text); + . = ALIGN (16); + *(.entry.text) + *(.init.literal) + *(.init) + _init_end = ABSOLUTE(.); + } > iram0_0_seg + + .iram0.text : + { + /* Code marked as runnning out of IRAM */ + _iram_text_start = ABSOLUTE(.); + + *( .iram1 .iram1.*) + *libspi_flash.a:spi_flash_rom_patch.*( .literal .literal.* .text .text.*) + *libesp_ringbuf.a:( .literal .literal.* .text .text.*) + *libhal.a:( .literal .literal.* .text .text.*) + *libapp_trace.a:( .literal .literal.* .text .text.*) + *libesp32.a:panic.*( .literal .literal.* .text .text.*) + *libespcoredump.a:core_dump_port.*( .literal .literal.* .text .text.*) + *libespcoredump.a:core_dump_flash.*( .literal .literal.* .text .text.*) + *libespcoredump.a:core_dump_uart.*( .literal .literal.* .text .text.*) + *libespcoredump.a:core_dump_common.*( .literal .literal.* .text .text.*) + *librtc.a:( .literal .literal.* .text .text.*) + *libgcc.a:lib2funcs.*( .literal .literal.* .text .text.*) + *libsoc.a:rtc_time.*( .literal .literal.* .text .text.*) + *libsoc.a:cpu_util.*( .literal .literal.* .text .text.*) + *libsoc.a:rtc_sleep.*( .literal .literal.* .text .text.*) + *libsoc.a:rtc_clk_init.*( .literal .literal.* .text .text.*) + *libsoc.a:rtc_clk.*( .literal .literal.* .text .text.*) + *libsoc.a:rtc_init.*( .literal .literal.* .text .text.*) + *libsoc.a:rtc_pm.*( .literal .literal.* .text .text.*) + *libsoc.a:rtc_wdt.*( .literal .literal.* .text .text.*) + *libsoc.a:rtc_periph.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-time.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-makebuf.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strcasestr.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-tzlock.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-memset.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strdup.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-environ.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-tzcalc_limits.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-labs.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strlcat.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-isdigit.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-ungetc.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-sccl.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strlen.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-stdio.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-tzset_r.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-asctime_r.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-tolower.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-memccpy.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-wctomb_r.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strcspn.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strcasecmp.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-iscntrl.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strncasecmp.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-abs.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-sf_nan.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-asctime.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strncmp.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-fvwrite.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-isblank.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-read.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-tzset.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-rand_r.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-ispunct.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-s_fpclassify.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-quorem.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strspn.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strrchr.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strndup.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-gettzinfo.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-fclose.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-isalnum.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strtol.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-creat.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-fwalk.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-memcmp.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strcmp.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-rshift.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-toascii.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-lcltime_r.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-isalpha.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-wcrtomb.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-tzvars.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strcoll.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strndup_r.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-gmtime.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-gmtime_r.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:isatty.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-wbuf.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-mktime.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-ctime_r.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-isascii.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-memcpy.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-sysclose.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-setjmp.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-srand.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strcat.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-bzero.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-month_lengths.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strncat.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strftime.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-isupper.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-wsetup.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-close.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-islower.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strncpy.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-raise.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-atol.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-ldiv.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-getenv_r.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-isspace.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-system.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strchr.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-memchr.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-refill.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-atoi.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:creat.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-envlock.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strnlen.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-isgraph.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-syssbrk.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-sysread.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-longjmp.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-sbrk.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-timelocal.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strlcpy.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strdup_r.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-sysopen.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-toupper.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strtoul.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strsep.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-itoa.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-memrchr.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-open.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-utoa.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strcpy.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-fputwc.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strtok_r.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strstr.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-memmove.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-isprint.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-syswrite.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-impure.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-rand.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-ctime.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-fflush.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strupr.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-lcltime.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strlwr.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-strptime.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-findfp.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-systimes.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-div.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lib_a-ctype_.*( .literal .literal.* .text .text.*) + *libc-psram-workaround.a:lock.*( .literal .literal.* .text .text.*) + *libfreertos.a:( .literal .literal.* .text .text.*) + *libgcov.a:( .literal .literal.* .text .text.*) + *libxtensa-debug-module.a:eri.*( .literal .literal.* .text .text.*) + *libheap.a:multi_heap.*( .literal .literal.* .text .text.*) + *libheap.a:multi_heap_poisoning.*( .literal .literal.* .text .text.*) + + _iram_text_end = ABSOLUTE(.); + _iram_end = ABSOLUTE(.); + } > iram0_0_seg + + ASSERT(((_iram_text_end - ORIGIN(iram0_0_seg)) <= LENGTH(iram0_0_seg)), + "IRAM0 segment data does not fit.") + + .dram0.data : + { + _data_start = ABSOLUTE(.); + _bt_data_start = ABSOLUTE(.); + *libbt.a:(.data .data.*) + . = ALIGN (4); + _bt_data_end = ABSOLUTE(.); + _btdm_data_start = ABSOLUTE(.); + *libbtdm_app.a:(.data .data.*) + . = ALIGN (4); + _btdm_data_end = ABSOLUTE(.); + *(.gnu.linkonce.d.*) + *(.data1) + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + *(.jcr) + + *( .data .data.* .dram1 .dram1.*) + *libapp_trace.a:( .rodata .rodata.*) + *libesp32.a:panic.*( .rodata .rodata.*) + *libphy.a:( .rodata .rodata.*) + *libsoc.a:rtc_clk.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-time.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-makebuf.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strcasestr.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-tzlock.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-memset.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strdup.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-environ.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-tzcalc_limits.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-labs.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strlcat.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-isdigit.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-ungetc.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-sccl.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strlen.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-stdio.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-tzset_r.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-asctime_r.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-tolower.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-memccpy.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-wctomb_r.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strcspn.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strcasecmp.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-iscntrl.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strncasecmp.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-abs.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-sf_nan.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-asctime.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strncmp.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-fvwrite.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-isblank.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-read.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-tzset.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-rand_r.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-ispunct.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-s_fpclassify.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-quorem.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strspn.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strrchr.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strndup.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-gettzinfo.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-fclose.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-isalnum.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strtol.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-creat.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-fwalk.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-memcmp.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strcmp.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-rshift.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-toascii.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-lcltime_r.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-isalpha.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-wcrtomb.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-tzvars.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strcoll.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strndup_r.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-gmtime.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-gmtime_r.*( .rodata .rodata.*) + *libc-psram-workaround.a:isatty.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-wbuf.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-mktime.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-ctime_r.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-isascii.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-memcpy.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-sysclose.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-setjmp.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-srand.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strcat.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-bzero.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-month_lengths.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strncat.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strftime.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-isupper.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-wsetup.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-close.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-islower.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strncpy.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-raise.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-atol.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-ldiv.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-getenv_r.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-isspace.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-system.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strchr.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-memchr.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-refill.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-atoi.*( .rodata .rodata.*) + *libc-psram-workaround.a:creat.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-envlock.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strnlen.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-isgraph.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-syssbrk.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-sysread.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-longjmp.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-sbrk.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-timelocal.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strlcpy.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strdup_r.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-sysopen.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-toupper.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strtoul.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strsep.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-itoa.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-memrchr.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-open.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-utoa.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strcpy.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-fputwc.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strtok_r.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strstr.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-memmove.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-isprint.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-syswrite.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-impure.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-rand.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-ctime.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-fflush.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strupr.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-lcltime.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strlwr.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-strptime.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-findfp.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-systimes.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-div.*( .rodata .rodata.*) + *libc-psram-workaround.a:lib_a-ctype_.*( .rodata .rodata.*) + *libc-psram-workaround.a:lock.*( .rodata .rodata.*) + *libgcov.a:( .rodata .rodata.*) + *libheap.a:multi_heap.*( .rodata .rodata.*) + *libheap.a:multi_heap_poisoning.*( .rodata .rodata.*) + + _data_end = ABSOLUTE(.); + . = ALIGN(4); + } > dram0_0_seg + + /*This section holds data that should not be initialized at power up. + The section located in Internal SRAM memory region. The macro _NOINIT + can be used as attribute to place data into this section. + See the esp_attr.h file for more information. + */ + .noinit (NOLOAD): + { + . = ALIGN(4); + _noinit_start = ABSOLUTE(.); + *(.noinit .noinit.*) + . = ALIGN(4) ; + _noinit_end = ABSOLUTE(.); + } > dram0_0_seg + + /* Shared RAM */ + .dram0.bss (NOLOAD) : + { + . = ALIGN (8); + _bss_start = ABSOLUTE(.); + *(.ext_ram.bss*) + _bt_bss_start = ABSOLUTE(.); + *libbt.a:(.bss .bss.* COMMON) + . = ALIGN (4); + _bt_bss_end = ABSOLUTE(.); + _btdm_bss_start = ABSOLUTE(.); + *libbtdm_app.a:(.bss .bss.* COMMON) + . = ALIGN (4); + _btdm_bss_end = ABSOLUTE(.); + + *( .bss .bss.* COMMON) + + *(.dynsbss) + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + *(.scommon) + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + *(.dynbss) + *(.share.mem) + *(.gnu.linkonce.b.*) + + . = ALIGN (8); + _bss_end = ABSOLUTE(.); + /* The heap starts right after end of this section */ + _heap_start = ABSOLUTE(.); + } > dram0_0_seg + + ASSERT(((_bss_end - ORIGIN(dram0_0_seg)) <= LENGTH(dram0_0_seg)), + "DRAM segment data does not fit.") + + .flash.rodata : + { + _rodata_start = ABSOLUTE(.); + + *(.rodata_desc .rodata_desc.*) /* Should be the first. App version info. DO NOT PUT ANYTHING BEFORE IT! */ + *(.rodata_custom_desc .rodata_custom_desc.*) /* Should be the second. Custom app version info. DO NOT PUT ANYTHING BEFORE IT! */ + + *(EXCLUDE_FILE(*libapp_trace.a *libesp32.a:panic.* *libphy.a *libsoc.a:rtc_clk.* *libc-psram-workaround.a:lock.* *libc-psram-workaround.a:lib_a-ctype_.* *libc-psram-workaround.a:lib_a-div.* *libc-psram-workaround.a:lib_a-systimes.* *libc-psram-workaround.a:lib_a-findfp.* *libc-psram-workaround.a:lib_a-strptime.* *libc-psram-workaround.a:lib_a-strlwr.* *libc-psram-workaround.a:lib_a-lcltime.* *libc-psram-workaround.a:lib_a-strupr.* *libc-psram-workaround.a:lib_a-fflush.* *libc-psram-workaround.a:lib_a-ctime.* *libc-psram-workaround.a:lib_a-rand.* *libc-psram-workaround.a:lib_a-impure.* *libc-psram-workaround.a:lib_a-syswrite.* *libc-psram-workaround.a:lib_a-isprint.* *libc-psram-workaround.a:lib_a-memmove.* *libc-psram-workaround.a:lib_a-strstr.* *libc-psram-workaround.a:lib_a-strtok_r.* *libc-psram-workaround.a:lib_a-fputwc.* *libc-psram-workaround.a:lib_a-strcpy.* *libc-psram-workaround.a:lib_a-utoa.* *libc-psram-workaround.a:lib_a-open.* *libc-psram-workaround.a:lib_a-memrchr.* *libc-psram-workaround.a:lib_a-itoa.* *libc-psram-workaround.a:lib_a-strsep.* *libc-psram-workaround.a:lib_a-strtoul.* *libc-psram-workaround.a:lib_a-toupper.* *libc-psram-workaround.a:lib_a-sysopen.* *libc-psram-workaround.a:lib_a-strdup_r.* *libc-psram-workaround.a:lib_a-strlcpy.* *libc-psram-workaround.a:lib_a-timelocal.* *libc-psram-workaround.a:lib_a-sbrk.* *libc-psram-workaround.a:lib_a-longjmp.* *libc-psram-workaround.a:lib_a-sysread.* *libc-psram-workaround.a:lib_a-syssbrk.* *libc-psram-workaround.a:lib_a-isgraph.* *libc-psram-workaround.a:lib_a-strnlen.* *libc-psram-workaround.a:lib_a-envlock.* *libc-psram-workaround.a:creat.* *libc-psram-workaround.a:lib_a-atoi.* *libc-psram-workaround.a:lib_a-refill.* *libc-psram-workaround.a:lib_a-memchr.* *libc-psram-workaround.a:lib_a-strchr.* *libc-psram-workaround.a:lib_a-system.* *libc-psram-workaround.a:lib_a-isspace.* *libc-psram-workaround.a:lib_a-getenv_r.* *libc-psram-workaround.a:lib_a-ldiv.* *libc-psram-workaround.a:lib_a-atol.* *libc-psram-workaround.a:lib_a-raise.* *libc-psram-workaround.a:lib_a-strncpy.* *libc-psram-workaround.a:lib_a-islower.* *libc-psram-workaround.a:lib_a-close.* *libc-psram-workaround.a:lib_a-wsetup.* *libc-psram-workaround.a:lib_a-isupper.* *libc-psram-workaround.a:lib_a-strftime.* *libc-psram-workaround.a:lib_a-strncat.* *libc-psram-workaround.a:lib_a-month_lengths.* *libc-psram-workaround.a:lib_a-bzero.* *libc-psram-workaround.a:lib_a-strcat.* *libc-psram-workaround.a:lib_a-srand.* *libc-psram-workaround.a:lib_a-setjmp.* *libc-psram-workaround.a:lib_a-sysclose.* *libc-psram-workaround.a:lib_a-memcpy.* *libc-psram-workaround.a:lib_a-isascii.* *libc-psram-workaround.a:lib_a-ctime_r.* *libc-psram-workaround.a:lib_a-mktime.* *libc-psram-workaround.a:lib_a-wbuf.* *libc-psram-workaround.a:isatty.* *libc-psram-workaround.a:lib_a-gmtime_r.* *libc-psram-workaround.a:lib_a-gmtime.* *libc-psram-workaround.a:lib_a-strndup_r.* *libc-psram-workaround.a:lib_a-strcoll.* *libc-psram-workaround.a:lib_a-tzvars.* *libc-psram-workaround.a:lib_a-wcrtomb.* *libc-psram-workaround.a:lib_a-isalpha.* *libc-psram-workaround.a:lib_a-lcltime_r.* *libc-psram-workaround.a:lib_a-toascii.* *libc-psram-workaround.a:lib_a-rshift.* *libc-psram-workaround.a:lib_a-strcmp.* *libc-psram-workaround.a:lib_a-memcmp.* *libc-psram-workaround.a:lib_a-fwalk.* *libc-psram-workaround.a:lib_a-creat.* *libc-psram-workaround.a:lib_a-strtol.* *libc-psram-workaround.a:lib_a-isalnum.* *libc-psram-workaround.a:lib_a-fclose.* *libc-psram-workaround.a:lib_a-gettzinfo.* *libc-psram-workaround.a:lib_a-strndup.* *libc-psram-workaround.a:lib_a-strrchr.* *libc-psram-workaround.a:lib_a-strspn.* *libc-psram-workaround.a:lib_a-quorem.* *libc-psram-workaround.a:lib_a-s_fpclassify.* *libc-psram-workaround.a:lib_a-ispunct.* *libc-psram-workaround.a:lib_a-rand_r.* *libc-psram-workaround.a:lib_a-tzset.* *libc-psram-workaround.a:lib_a-read.* *libc-psram-workaround.a:lib_a-isblank.* *libc-psram-workaround.a:lib_a-fvwrite.* *libc-psram-workaround.a:lib_a-strncmp.* *libc-psram-workaround.a:lib_a-asctime.* *libc-psram-workaround.a:lib_a-sf_nan.* *libc-psram-workaround.a:lib_a-abs.* *libc-psram-workaround.a:lib_a-strncasecmp.* *libc-psram-workaround.a:lib_a-iscntrl.* *libc-psram-workaround.a:lib_a-strcasecmp.* *libc-psram-workaround.a:lib_a-strcspn.* *libc-psram-workaround.a:lib_a-wctomb_r.* *libc-psram-workaround.a:lib_a-memccpy.* *libc-psram-workaround.a:lib_a-tolower.* *libc-psram-workaround.a:lib_a-asctime_r.* *libc-psram-workaround.a:lib_a-tzset_r.* *libc-psram-workaround.a:lib_a-stdio.* *libc-psram-workaround.a:lib_a-strlen.* *libc-psram-workaround.a:lib_a-sccl.* *libc-psram-workaround.a:lib_a-ungetc.* *libc-psram-workaround.a:lib_a-isdigit.* *libc-psram-workaround.a:lib_a-strlcat.* *libc-psram-workaround.a:lib_a-labs.* *libc-psram-workaround.a:lib_a-tzcalc_limits.* *libc-psram-workaround.a:lib_a-environ.* *libc-psram-workaround.a:lib_a-strdup.* *libc-psram-workaround.a:lib_a-memset.* *libc-psram-workaround.a:lib_a-tzlock.* *libc-psram-workaround.a:lib_a-strcasestr.* *libc-psram-workaround.a:lib_a-makebuf.* *libc-psram-workaround.a:lib_a-time.* *libgcov.a *libheap.a:multi_heap_poisoning.* *libheap.a:multi_heap.*) .rodata EXCLUDE_FILE(*libapp_trace.a *libesp32.a:panic.* *libphy.a *libsoc.a:rtc_clk.* *libc-psram-workaround.a:lock.* *libc-psram-workaround.a:lib_a-ctype_.* *libc-psram-workaround.a:lib_a-div.* *libc-psram-workaround.a:lib_a-systimes.* *libc-psram-workaround.a:lib_a-findfp.* *libc-psram-workaround.a:lib_a-strptime.* *libc-psram-workaround.a:lib_a-strlwr.* *libc-psram-workaround.a:lib_a-lcltime.* *libc-psram-workaround.a:lib_a-strupr.* *libc-psram-workaround.a:lib_a-fflush.* *libc-psram-workaround.a:lib_a-ctime.* *libc-psram-workaround.a:lib_a-rand.* *libc-psram-workaround.a:lib_a-impure.* *libc-psram-workaround.a:lib_a-syswrite.* *libc-psram-workaround.a:lib_a-isprint.* *libc-psram-workaround.a:lib_a-memmove.* *libc-psram-workaround.a:lib_a-strstr.* *libc-psram-workaround.a:lib_a-strtok_r.* *libc-psram-workaround.a:lib_a-fputwc.* *libc-psram-workaround.a:lib_a-strcpy.* *libc-psram-workaround.a:lib_a-utoa.* *libc-psram-workaround.a:lib_a-open.* *libc-psram-workaround.a:lib_a-memrchr.* *libc-psram-workaround.a:lib_a-itoa.* *libc-psram-workaround.a:lib_a-strsep.* *libc-psram-workaround.a:lib_a-strtoul.* *libc-psram-workaround.a:lib_a-toupper.* *libc-psram-workaround.a:lib_a-sysopen.* *libc-psram-workaround.a:lib_a-strdup_r.* *libc-psram-workaround.a:lib_a-strlcpy.* *libc-psram-workaround.a:lib_a-timelocal.* *libc-psram-workaround.a:lib_a-sbrk.* *libc-psram-workaround.a:lib_a-longjmp.* *libc-psram-workaround.a:lib_a-sysread.* *libc-psram-workaround.a:lib_a-syssbrk.* *libc-psram-workaround.a:lib_a-isgraph.* *libc-psram-workaround.a:lib_a-strnlen.* *libc-psram-workaround.a:lib_a-envlock.* *libc-psram-workaround.a:creat.* *libc-psram-workaround.a:lib_a-atoi.* *libc-psram-workaround.a:lib_a-refill.* *libc-psram-workaround.a:lib_a-memchr.* *libc-psram-workaround.a:lib_a-strchr.* *libc-psram-workaround.a:lib_a-system.* *libc-psram-workaround.a:lib_a-isspace.* *libc-psram-workaround.a:lib_a-getenv_r.* *libc-psram-workaround.a:lib_a-ldiv.* *libc-psram-workaround.a:lib_a-atol.* *libc-psram-workaround.a:lib_a-raise.* *libc-psram-workaround.a:lib_a-strncpy.* *libc-psram-workaround.a:lib_a-islower.* *libc-psram-workaround.a:lib_a-close.* *libc-psram-workaround.a:lib_a-wsetup.* *libc-psram-workaround.a:lib_a-isupper.* *libc-psram-workaround.a:lib_a-strftime.* *libc-psram-workaround.a:lib_a-strncat.* *libc-psram-workaround.a:lib_a-month_lengths.* *libc-psram-workaround.a:lib_a-bzero.* *libc-psram-workaround.a:lib_a-strcat.* *libc-psram-workaround.a:lib_a-srand.* *libc-psram-workaround.a:lib_a-setjmp.* *libc-psram-workaround.a:lib_a-sysclose.* *libc-psram-workaround.a:lib_a-memcpy.* *libc-psram-workaround.a:lib_a-isascii.* *libc-psram-workaround.a:lib_a-ctime_r.* *libc-psram-workaround.a:lib_a-mktime.* *libc-psram-workaround.a:lib_a-wbuf.* *libc-psram-workaround.a:isatty.* *libc-psram-workaround.a:lib_a-gmtime_r.* *libc-psram-workaround.a:lib_a-gmtime.* *libc-psram-workaround.a:lib_a-strndup_r.* *libc-psram-workaround.a:lib_a-strcoll.* *libc-psram-workaround.a:lib_a-tzvars.* *libc-psram-workaround.a:lib_a-wcrtomb.* *libc-psram-workaround.a:lib_a-isalpha.* *libc-psram-workaround.a:lib_a-lcltime_r.* *libc-psram-workaround.a:lib_a-toascii.* *libc-psram-workaround.a:lib_a-rshift.* *libc-psram-workaround.a:lib_a-strcmp.* *libc-psram-workaround.a:lib_a-memcmp.* *libc-psram-workaround.a:lib_a-fwalk.* *libc-psram-workaround.a:lib_a-creat.* *libc-psram-workaround.a:lib_a-strtol.* *libc-psram-workaround.a:lib_a-isalnum.* *libc-psram-workaround.a:lib_a-fclose.* *libc-psram-workaround.a:lib_a-gettzinfo.* *libc-psram-workaround.a:lib_a-strndup.* *libc-psram-workaround.a:lib_a-strrchr.* *libc-psram-workaround.a:lib_a-strspn.* *libc-psram-workaround.a:lib_a-quorem.* *libc-psram-workaround.a:lib_a-s_fpclassify.* *libc-psram-workaround.a:lib_a-ispunct.* *libc-psram-workaround.a:lib_a-rand_r.* *libc-psram-workaround.a:lib_a-tzset.* *libc-psram-workaround.a:lib_a-read.* *libc-psram-workaround.a:lib_a-isblank.* *libc-psram-workaround.a:lib_a-fvwrite.* *libc-psram-workaround.a:lib_a-strncmp.* *libc-psram-workaround.a:lib_a-asctime.* *libc-psram-workaround.a:lib_a-sf_nan.* *libc-psram-workaround.a:lib_a-abs.* *libc-psram-workaround.a:lib_a-strncasecmp.* *libc-psram-workaround.a:lib_a-iscntrl.* *libc-psram-workaround.a:lib_a-strcasecmp.* *libc-psram-workaround.a:lib_a-strcspn.* *libc-psram-workaround.a:lib_a-wctomb_r.* *libc-psram-workaround.a:lib_a-memccpy.* *libc-psram-workaround.a:lib_a-tolower.* *libc-psram-workaround.a:lib_a-asctime_r.* *libc-psram-workaround.a:lib_a-tzset_r.* *libc-psram-workaround.a:lib_a-stdio.* *libc-psram-workaround.a:lib_a-strlen.* *libc-psram-workaround.a:lib_a-sccl.* *libc-psram-workaround.a:lib_a-ungetc.* *libc-psram-workaround.a:lib_a-isdigit.* *libc-psram-workaround.a:lib_a-strlcat.* *libc-psram-workaround.a:lib_a-labs.* *libc-psram-workaround.a:lib_a-tzcalc_limits.* *libc-psram-workaround.a:lib_a-environ.* *libc-psram-workaround.a:lib_a-strdup.* *libc-psram-workaround.a:lib_a-memset.* *libc-psram-workaround.a:lib_a-tzlock.* *libc-psram-workaround.a:lib_a-strcasestr.* *libc-psram-workaround.a:lib_a-makebuf.* *libc-psram-workaround.a:lib_a-time.* *libgcov.a *libheap.a:multi_heap_poisoning.* *libheap.a:multi_heap.*) .rodata.*) + + *(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */ + *(.gnu.linkonce.r.*) + *(.rodata1) + __XT_EXCEPTION_TABLE_ = ABSOLUTE(.); + *(.xt_except_table) + *(.gcc_except_table .gcc_except_table.*) + *(.gnu.linkonce.e.*) + *(.gnu.version_r) + . = (. + 3) & ~ 3; + __eh_frame = ABSOLUTE(.); + KEEP(*(.eh_frame)) + . = (. + 7) & ~ 3; + /* C++ constructor and destructor tables, properly ordered: */ + __init_array_start = ABSOLUTE(.); + KEEP (*crtbegin.*(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __init_array_end = ABSOLUTE(.); + KEEP (*crtbegin.*(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + /* C++ exception handlers table: */ + __XT_EXCEPTION_DESCS_ = ABSOLUTE(.); + *(.xt_except_desc) + *(.gnu.linkonce.h.*) + __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); + *(.xt_except_desc_end) + *(.dynamic) + *(.gnu.version_d) + /* Addresses of memory regions reserved via + SOC_RESERVE_MEMORY_REGION() */ + soc_reserved_memory_region_start = ABSOLUTE(.); + KEEP (*(.reserved_memory_address)) + soc_reserved_memory_region_end = ABSOLUTE(.); + _rodata_end = ABSOLUTE(.); + /* Literals are also RO data. */ + _lit4_start = ABSOLUTE(.); + *(*.lit4) + *(.lit4.*) + *(.gnu.linkonce.lit4.*) + _lit4_end = ABSOLUTE(.); + . = ALIGN(4); + _thread_local_start = ABSOLUTE(.); + *(.tdata) + *(.tdata.*) + *(.tbss) + *(.tbss.*) + _thread_local_end = ABSOLUTE(.); + . = ALIGN(4); + } >drom0_0_seg + + .flash.text : + { + _stext = .; + _text_start = ABSOLUTE(.); + + *(EXCLUDE_FILE(*libspi_flash.a:spi_flash_rom_patch.* *libesp_ringbuf.a *libhal.a *libapp_trace.a *libesp32.a:panic.* *libespcoredump.a:core_dump_common.* *libespcoredump.a:core_dump_uart.* *libespcoredump.a:core_dump_flash.* *libespcoredump.a:core_dump_port.* *librtc.a *libgcc.a:lib2funcs.* *libsoc.a:rtc_periph.* *libsoc.a:rtc_wdt.* *libsoc.a:rtc_pm.* *libsoc.a:rtc_init.* *libsoc.a:rtc_clk.* *libsoc.a:rtc_clk_init.* *libsoc.a:rtc_sleep.* *libsoc.a:cpu_util.* *libsoc.a:rtc_time.* *libc-psram-workaround.a:lock.* *libc-psram-workaround.a:lib_a-ctype_.* *libc-psram-workaround.a:lib_a-div.* *libc-psram-workaround.a:lib_a-systimes.* *libc-psram-workaround.a:lib_a-findfp.* *libc-psram-workaround.a:lib_a-strptime.* *libc-psram-workaround.a:lib_a-strlwr.* *libc-psram-workaround.a:lib_a-lcltime.* *libc-psram-workaround.a:lib_a-strupr.* *libc-psram-workaround.a:lib_a-fflush.* *libc-psram-workaround.a:lib_a-ctime.* *libc-psram-workaround.a:lib_a-rand.* *libc-psram-workaround.a:lib_a-impure.* *libc-psram-workaround.a:lib_a-syswrite.* *libc-psram-workaround.a:lib_a-isprint.* *libc-psram-workaround.a:lib_a-memmove.* *libc-psram-workaround.a:lib_a-strstr.* *libc-psram-workaround.a:lib_a-strtok_r.* *libc-psram-workaround.a:lib_a-fputwc.* *libc-psram-workaround.a:lib_a-strcpy.* *libc-psram-workaround.a:lib_a-utoa.* *libc-psram-workaround.a:lib_a-open.* *libc-psram-workaround.a:lib_a-memrchr.* *libc-psram-workaround.a:lib_a-itoa.* *libc-psram-workaround.a:lib_a-strsep.* *libc-psram-workaround.a:lib_a-strtoul.* *libc-psram-workaround.a:lib_a-toupper.* *libc-psram-workaround.a:lib_a-sysopen.* *libc-psram-workaround.a:lib_a-strdup_r.* *libc-psram-workaround.a:lib_a-strlcpy.* *libc-psram-workaround.a:lib_a-timelocal.* *libc-psram-workaround.a:lib_a-sbrk.* *libc-psram-workaround.a:lib_a-longjmp.* *libc-psram-workaround.a:lib_a-sysread.* *libc-psram-workaround.a:lib_a-syssbrk.* *libc-psram-workaround.a:lib_a-isgraph.* *libc-psram-workaround.a:lib_a-strnlen.* *libc-psram-workaround.a:lib_a-envlock.* *libc-psram-workaround.a:creat.* *libc-psram-workaround.a:lib_a-atoi.* *libc-psram-workaround.a:lib_a-refill.* *libc-psram-workaround.a:lib_a-memchr.* *libc-psram-workaround.a:lib_a-strchr.* *libc-psram-workaround.a:lib_a-system.* *libc-psram-workaround.a:lib_a-isspace.* *libc-psram-workaround.a:lib_a-getenv_r.* *libc-psram-workaround.a:lib_a-ldiv.* *libc-psram-workaround.a:lib_a-atol.* *libc-psram-workaround.a:lib_a-raise.* *libc-psram-workaround.a:lib_a-strncpy.* *libc-psram-workaround.a:lib_a-islower.* *libc-psram-workaround.a:lib_a-close.* *libc-psram-workaround.a:lib_a-wsetup.* *libc-psram-workaround.a:lib_a-isupper.* *libc-psram-workaround.a:lib_a-strftime.* *libc-psram-workaround.a:lib_a-strncat.* *libc-psram-workaround.a:lib_a-month_lengths.* *libc-psram-workaround.a:lib_a-bzero.* *libc-psram-workaround.a:lib_a-strcat.* *libc-psram-workaround.a:lib_a-srand.* *libc-psram-workaround.a:lib_a-setjmp.* *libc-psram-workaround.a:lib_a-sysclose.* *libc-psram-workaround.a:lib_a-memcpy.* *libc-psram-workaround.a:lib_a-isascii.* *libc-psram-workaround.a:lib_a-ctime_r.* *libc-psram-workaround.a:lib_a-mktime.* *libc-psram-workaround.a:lib_a-wbuf.* *libc-psram-workaround.a:isatty.* *libc-psram-workaround.a:lib_a-gmtime_r.* *libc-psram-workaround.a:lib_a-gmtime.* *libc-psram-workaround.a:lib_a-strndup_r.* *libc-psram-workaround.a:lib_a-strcoll.* *libc-psram-workaround.a:lib_a-tzvars.* *libc-psram-workaround.a:lib_a-wcrtomb.* *libc-psram-workaround.a:lib_a-isalpha.* *libc-psram-workaround.a:lib_a-lcltime_r.* *libc-psram-workaround.a:lib_a-toascii.* *libc-psram-workaround.a:lib_a-rshift.* *libc-psram-workaround.a:lib_a-strcmp.* *libc-psram-workaround.a:lib_a-memcmp.* *libc-psram-workaround.a:lib_a-fwalk.* *libc-psram-workaround.a:lib_a-creat.* *libc-psram-workaround.a:lib_a-strtol.* *libc-psram-workaround.a:lib_a-isalnum.* *libc-psram-workaround.a:lib_a-fclose.* *libc-psram-workaround.a:lib_a-gettzinfo.* *libc-psram-workaround.a:lib_a-strndup.* *libc-psram-workaround.a:lib_a-strrchr.* *libc-psram-workaround.a:lib_a-strspn.* *libc-psram-workaround.a:lib_a-quorem.* *libc-psram-workaround.a:lib_a-s_fpclassify.* *libc-psram-workaround.a:lib_a-ispunct.* *libc-psram-workaround.a:lib_a-rand_r.* *libc-psram-workaround.a:lib_a-tzset.* *libc-psram-workaround.a:lib_a-read.* *libc-psram-workaround.a:lib_a-isblank.* *libc-psram-workaround.a:lib_a-fvwrite.* *libc-psram-workaround.a:lib_a-strncmp.* *libc-psram-workaround.a:lib_a-asctime.* *libc-psram-workaround.a:lib_a-sf_nan.* *libc-psram-workaround.a:lib_a-abs.* *libc-psram-workaround.a:lib_a-strncasecmp.* *libc-psram-workaround.a:lib_a-iscntrl.* *libc-psram-workaround.a:lib_a-strcasecmp.* *libc-psram-workaround.a:lib_a-strcspn.* *libc-psram-workaround.a:lib_a-wctomb_r.* *libc-psram-workaround.a:lib_a-memccpy.* *libc-psram-workaround.a:lib_a-tolower.* *libc-psram-workaround.a:lib_a-asctime_r.* *libc-psram-workaround.a:lib_a-tzset_r.* *libc-psram-workaround.a:lib_a-stdio.* *libc-psram-workaround.a:lib_a-strlen.* *libc-psram-workaround.a:lib_a-sccl.* *libc-psram-workaround.a:lib_a-ungetc.* *libc-psram-workaround.a:lib_a-isdigit.* *libc-psram-workaround.a:lib_a-strlcat.* *libc-psram-workaround.a:lib_a-labs.* *libc-psram-workaround.a:lib_a-tzcalc_limits.* *libc-psram-workaround.a:lib_a-environ.* *libc-psram-workaround.a:lib_a-strdup.* *libc-psram-workaround.a:lib_a-memset.* *libc-psram-workaround.a:lib_a-tzlock.* *libc-psram-workaround.a:lib_a-strcasestr.* *libc-psram-workaround.a:lib_a-makebuf.* *libc-psram-workaround.a:lib_a-time.* *libfreertos.a *libgcov.a *libxtensa-debug-module.a:eri.* *libheap.a:multi_heap_poisoning.* *libheap.a:multi_heap.*) .literal EXCLUDE_FILE(*libspi_flash.a:spi_flash_rom_patch.* *libesp_ringbuf.a *libhal.a *libapp_trace.a *libesp32.a:panic.* *libespcoredump.a:core_dump_common.* *libespcoredump.a:core_dump_uart.* *libespcoredump.a:core_dump_flash.* *libespcoredump.a:core_dump_port.* *librtc.a *libgcc.a:lib2funcs.* *libsoc.a:rtc_periph.* *libsoc.a:rtc_wdt.* *libsoc.a:rtc_pm.* *libsoc.a:rtc_init.* *libsoc.a:rtc_clk.* *libsoc.a:rtc_clk_init.* *libsoc.a:rtc_sleep.* *libsoc.a:cpu_util.* *libsoc.a:rtc_time.* *libc-psram-workaround.a:lock.* *libc-psram-workaround.a:lib_a-ctype_.* *libc-psram-workaround.a:lib_a-div.* *libc-psram-workaround.a:lib_a-systimes.* *libc-psram-workaround.a:lib_a-findfp.* *libc-psram-workaround.a:lib_a-strptime.* *libc-psram-workaround.a:lib_a-strlwr.* *libc-psram-workaround.a:lib_a-lcltime.* *libc-psram-workaround.a:lib_a-strupr.* *libc-psram-workaround.a:lib_a-fflush.* *libc-psram-workaround.a:lib_a-ctime.* *libc-psram-workaround.a:lib_a-rand.* *libc-psram-workaround.a:lib_a-impure.* *libc-psram-workaround.a:lib_a-syswrite.* *libc-psram-workaround.a:lib_a-isprint.* *libc-psram-workaround.a:lib_a-memmove.* *libc-psram-workaround.a:lib_a-strstr.* *libc-psram-workaround.a:lib_a-strtok_r.* *libc-psram-workaround.a:lib_a-fputwc.* *libc-psram-workaround.a:lib_a-strcpy.* *libc-psram-workaround.a:lib_a-utoa.* *libc-psram-workaround.a:lib_a-open.* *libc-psram-workaround.a:lib_a-memrchr.* *libc-psram-workaround.a:lib_a-itoa.* *libc-psram-workaround.a:lib_a-strsep.* *libc-psram-workaround.a:lib_a-strtoul.* *libc-psram-workaround.a:lib_a-toupper.* *libc-psram-workaround.a:lib_a-sysopen.* *libc-psram-workaround.a:lib_a-strdup_r.* *libc-psram-workaround.a:lib_a-strlcpy.* *libc-psram-workaround.a:lib_a-timelocal.* *libc-psram-workaround.a:lib_a-sbrk.* *libc-psram-workaround.a:lib_a-longjmp.* *libc-psram-workaround.a:lib_a-sysread.* *libc-psram-workaround.a:lib_a-syssbrk.* *libc-psram-workaround.a:lib_a-isgraph.* *libc-psram-workaround.a:lib_a-strnlen.* *libc-psram-workaround.a:lib_a-envlock.* *libc-psram-workaround.a:creat.* *libc-psram-workaround.a:lib_a-atoi.* *libc-psram-workaround.a:lib_a-refill.* *libc-psram-workaround.a:lib_a-memchr.* *libc-psram-workaround.a:lib_a-strchr.* *libc-psram-workaround.a:lib_a-system.* *libc-psram-workaround.a:lib_a-isspace.* *libc-psram-workaround.a:lib_a-getenv_r.* *libc-psram-workaround.a:lib_a-ldiv.* *libc-psram-workaround.a:lib_a-atol.* *libc-psram-workaround.a:lib_a-raise.* *libc-psram-workaround.a:lib_a-strncpy.* *libc-psram-workaround.a:lib_a-islower.* *libc-psram-workaround.a:lib_a-close.* *libc-psram-workaround.a:lib_a-wsetup.* *libc-psram-workaround.a:lib_a-isupper.* *libc-psram-workaround.a:lib_a-strftime.* *libc-psram-workaround.a:lib_a-strncat.* *libc-psram-workaround.a:lib_a-month_lengths.* *libc-psram-workaround.a:lib_a-bzero.* *libc-psram-workaround.a:lib_a-strcat.* *libc-psram-workaround.a:lib_a-srand.* *libc-psram-workaround.a:lib_a-setjmp.* *libc-psram-workaround.a:lib_a-sysclose.* *libc-psram-workaround.a:lib_a-memcpy.* *libc-psram-workaround.a:lib_a-isascii.* *libc-psram-workaround.a:lib_a-ctime_r.* *libc-psram-workaround.a:lib_a-mktime.* *libc-psram-workaround.a:lib_a-wbuf.* *libc-psram-workaround.a:isatty.* *libc-psram-workaround.a:lib_a-gmtime_r.* *libc-psram-workaround.a:lib_a-gmtime.* *libc-psram-workaround.a:lib_a-strndup_r.* *libc-psram-workaround.a:lib_a-strcoll.* *libc-psram-workaround.a:lib_a-tzvars.* *libc-psram-workaround.a:lib_a-wcrtomb.* *libc-psram-workaround.a:lib_a-isalpha.* *libc-psram-workaround.a:lib_a-lcltime_r.* *libc-psram-workaround.a:lib_a-toascii.* *libc-psram-workaround.a:lib_a-rshift.* *libc-psram-workaround.a:lib_a-strcmp.* *libc-psram-workaround.a:lib_a-memcmp.* *libc-psram-workaround.a:lib_a-fwalk.* *libc-psram-workaround.a:lib_a-creat.* *libc-psram-workaround.a:lib_a-strtol.* *libc-psram-workaround.a:lib_a-isalnum.* *libc-psram-workaround.a:lib_a-fclose.* *libc-psram-workaround.a:lib_a-gettzinfo.* *libc-psram-workaround.a:lib_a-strndup.* *libc-psram-workaround.a:lib_a-strrchr.* *libc-psram-workaround.a:lib_a-strspn.* *libc-psram-workaround.a:lib_a-quorem.* *libc-psram-workaround.a:lib_a-s_fpclassify.* *libc-psram-workaround.a:lib_a-ispunct.* *libc-psram-workaround.a:lib_a-rand_r.* *libc-psram-workaround.a:lib_a-tzset.* *libc-psram-workaround.a:lib_a-read.* *libc-psram-workaround.a:lib_a-isblank.* *libc-psram-workaround.a:lib_a-fvwrite.* *libc-psram-workaround.a:lib_a-strncmp.* *libc-psram-workaround.a:lib_a-asctime.* *libc-psram-workaround.a:lib_a-sf_nan.* *libc-psram-workaround.a:lib_a-abs.* *libc-psram-workaround.a:lib_a-strncasecmp.* *libc-psram-workaround.a:lib_a-iscntrl.* *libc-psram-workaround.a:lib_a-strcasecmp.* *libc-psram-workaround.a:lib_a-strcspn.* *libc-psram-workaround.a:lib_a-wctomb_r.* *libc-psram-workaround.a:lib_a-memccpy.* *libc-psram-workaround.a:lib_a-tolower.* *libc-psram-workaround.a:lib_a-asctime_r.* *libc-psram-workaround.a:lib_a-tzset_r.* *libc-psram-workaround.a:lib_a-stdio.* *libc-psram-workaround.a:lib_a-strlen.* *libc-psram-workaround.a:lib_a-sccl.* *libc-psram-workaround.a:lib_a-ungetc.* *libc-psram-workaround.a:lib_a-isdigit.* *libc-psram-workaround.a:lib_a-strlcat.* *libc-psram-workaround.a:lib_a-labs.* *libc-psram-workaround.a:lib_a-tzcalc_limits.* *libc-psram-workaround.a:lib_a-environ.* *libc-psram-workaround.a:lib_a-strdup.* *libc-psram-workaround.a:lib_a-memset.* *libc-psram-workaround.a:lib_a-tzlock.* *libc-psram-workaround.a:lib_a-strcasestr.* *libc-psram-workaround.a:lib_a-makebuf.* *libc-psram-workaround.a:lib_a-time.* *libfreertos.a *libgcov.a *libxtensa-debug-module.a:eri.* *libheap.a:multi_heap_poisoning.* *libheap.a:multi_heap.*) .literal.* EXCLUDE_FILE(*libspi_flash.a:spi_flash_rom_patch.* *libesp_ringbuf.a *libhal.a *libapp_trace.a *libesp32.a:panic.* *libespcoredump.a:core_dump_common.* *libespcoredump.a:core_dump_uart.* *libespcoredump.a:core_dump_flash.* *libespcoredump.a:core_dump_port.* *librtc.a *libgcc.a:lib2funcs.* *libsoc.a:rtc_periph.* *libsoc.a:rtc_wdt.* *libsoc.a:rtc_pm.* *libsoc.a:rtc_init.* *libsoc.a:rtc_clk.* *libsoc.a:rtc_clk_init.* *libsoc.a:rtc_sleep.* *libsoc.a:cpu_util.* *libsoc.a:rtc_time.* *libc-psram-workaround.a:lock.* *libc-psram-workaround.a:lib_a-ctype_.* *libc-psram-workaround.a:lib_a-div.* *libc-psram-workaround.a:lib_a-systimes.* *libc-psram-workaround.a:lib_a-findfp.* *libc-psram-workaround.a:lib_a-strptime.* *libc-psram-workaround.a:lib_a-strlwr.* *libc-psram-workaround.a:lib_a-lcltime.* *libc-psram-workaround.a:lib_a-strupr.* *libc-psram-workaround.a:lib_a-fflush.* *libc-psram-workaround.a:lib_a-ctime.* *libc-psram-workaround.a:lib_a-rand.* *libc-psram-workaround.a:lib_a-impure.* *libc-psram-workaround.a:lib_a-syswrite.* *libc-psram-workaround.a:lib_a-isprint.* *libc-psram-workaround.a:lib_a-memmove.* *libc-psram-workaround.a:lib_a-strstr.* *libc-psram-workaround.a:lib_a-strtok_r.* *libc-psram-workaround.a:lib_a-fputwc.* *libc-psram-workaround.a:lib_a-strcpy.* *libc-psram-workaround.a:lib_a-utoa.* *libc-psram-workaround.a:lib_a-open.* *libc-psram-workaround.a:lib_a-memrchr.* *libc-psram-workaround.a:lib_a-itoa.* *libc-psram-workaround.a:lib_a-strsep.* *libc-psram-workaround.a:lib_a-strtoul.* *libc-psram-workaround.a:lib_a-toupper.* *libc-psram-workaround.a:lib_a-sysopen.* *libc-psram-workaround.a:lib_a-strdup_r.* *libc-psram-workaround.a:lib_a-strlcpy.* *libc-psram-workaround.a:lib_a-timelocal.* *libc-psram-workaround.a:lib_a-sbrk.* *libc-psram-workaround.a:lib_a-longjmp.* *libc-psram-workaround.a:lib_a-sysread.* *libc-psram-workaround.a:lib_a-syssbrk.* *libc-psram-workaround.a:lib_a-isgraph.* *libc-psram-workaround.a:lib_a-strnlen.* *libc-psram-workaround.a:lib_a-envlock.* *libc-psram-workaround.a:creat.* *libc-psram-workaround.a:lib_a-atoi.* *libc-psram-workaround.a:lib_a-refill.* *libc-psram-workaround.a:lib_a-memchr.* *libc-psram-workaround.a:lib_a-strchr.* *libc-psram-workaround.a:lib_a-system.* *libc-psram-workaround.a:lib_a-isspace.* *libc-psram-workaround.a:lib_a-getenv_r.* *libc-psram-workaround.a:lib_a-ldiv.* *libc-psram-workaround.a:lib_a-atol.* *libc-psram-workaround.a:lib_a-raise.* *libc-psram-workaround.a:lib_a-strncpy.* *libc-psram-workaround.a:lib_a-islower.* *libc-psram-workaround.a:lib_a-close.* *libc-psram-workaround.a:lib_a-wsetup.* *libc-psram-workaround.a:lib_a-isupper.* *libc-psram-workaround.a:lib_a-strftime.* *libc-psram-workaround.a:lib_a-strncat.* *libc-psram-workaround.a:lib_a-month_lengths.* *libc-psram-workaround.a:lib_a-bzero.* *libc-psram-workaround.a:lib_a-strcat.* *libc-psram-workaround.a:lib_a-srand.* *libc-psram-workaround.a:lib_a-setjmp.* *libc-psram-workaround.a:lib_a-sysclose.* *libc-psram-workaround.a:lib_a-memcpy.* *libc-psram-workaround.a:lib_a-isascii.* *libc-psram-workaround.a:lib_a-ctime_r.* *libc-psram-workaround.a:lib_a-mktime.* *libc-psram-workaround.a:lib_a-wbuf.* *libc-psram-workaround.a:isatty.* *libc-psram-workaround.a:lib_a-gmtime_r.* *libc-psram-workaround.a:lib_a-gmtime.* *libc-psram-workaround.a:lib_a-strndup_r.* *libc-psram-workaround.a:lib_a-strcoll.* *libc-psram-workaround.a:lib_a-tzvars.* *libc-psram-workaround.a:lib_a-wcrtomb.* *libc-psram-workaround.a:lib_a-isalpha.* *libc-psram-workaround.a:lib_a-lcltime_r.* *libc-psram-workaround.a:lib_a-toascii.* *libc-psram-workaround.a:lib_a-rshift.* *libc-psram-workaround.a:lib_a-strcmp.* *libc-psram-workaround.a:lib_a-memcmp.* *libc-psram-workaround.a:lib_a-fwalk.* *libc-psram-workaround.a:lib_a-creat.* *libc-psram-workaround.a:lib_a-strtol.* *libc-psram-workaround.a:lib_a-isalnum.* *libc-psram-workaround.a:lib_a-fclose.* *libc-psram-workaround.a:lib_a-gettzinfo.* *libc-psram-workaround.a:lib_a-strndup.* *libc-psram-workaround.a:lib_a-strrchr.* *libc-psram-workaround.a:lib_a-strspn.* *libc-psram-workaround.a:lib_a-quorem.* *libc-psram-workaround.a:lib_a-s_fpclassify.* *libc-psram-workaround.a:lib_a-ispunct.* *libc-psram-workaround.a:lib_a-rand_r.* *libc-psram-workaround.a:lib_a-tzset.* *libc-psram-workaround.a:lib_a-read.* *libc-psram-workaround.a:lib_a-isblank.* *libc-psram-workaround.a:lib_a-fvwrite.* *libc-psram-workaround.a:lib_a-strncmp.* *libc-psram-workaround.a:lib_a-asctime.* *libc-psram-workaround.a:lib_a-sf_nan.* *libc-psram-workaround.a:lib_a-abs.* *libc-psram-workaround.a:lib_a-strncasecmp.* *libc-psram-workaround.a:lib_a-iscntrl.* *libc-psram-workaround.a:lib_a-strcasecmp.* *libc-psram-workaround.a:lib_a-strcspn.* *libc-psram-workaround.a:lib_a-wctomb_r.* *libc-psram-workaround.a:lib_a-memccpy.* *libc-psram-workaround.a:lib_a-tolower.* *libc-psram-workaround.a:lib_a-asctime_r.* *libc-psram-workaround.a:lib_a-tzset_r.* *libc-psram-workaround.a:lib_a-stdio.* *libc-psram-workaround.a:lib_a-strlen.* *libc-psram-workaround.a:lib_a-sccl.* *libc-psram-workaround.a:lib_a-ungetc.* *libc-psram-workaround.a:lib_a-isdigit.* *libc-psram-workaround.a:lib_a-strlcat.* *libc-psram-workaround.a:lib_a-labs.* *libc-psram-workaround.a:lib_a-tzcalc_limits.* *libc-psram-workaround.a:lib_a-environ.* *libc-psram-workaround.a:lib_a-strdup.* *libc-psram-workaround.a:lib_a-memset.* *libc-psram-workaround.a:lib_a-tzlock.* *libc-psram-workaround.a:lib_a-strcasestr.* *libc-psram-workaround.a:lib_a-makebuf.* *libc-psram-workaround.a:lib_a-time.* *libfreertos.a *libgcov.a *libxtensa-debug-module.a:eri.* *libheap.a:multi_heap_poisoning.* *libheap.a:multi_heap.*) .text EXCLUDE_FILE(*libspi_flash.a:spi_flash_rom_patch.* *libesp_ringbuf.a *libhal.a *libapp_trace.a *libesp32.a:panic.* *libespcoredump.a:core_dump_common.* *libespcoredump.a:core_dump_uart.* *libespcoredump.a:core_dump_flash.* *libespcoredump.a:core_dump_port.* *librtc.a *libgcc.a:lib2funcs.* *libsoc.a:rtc_periph.* *libsoc.a:rtc_wdt.* *libsoc.a:rtc_pm.* *libsoc.a:rtc_init.* *libsoc.a:rtc_clk.* *libsoc.a:rtc_clk_init.* *libsoc.a:rtc_sleep.* *libsoc.a:cpu_util.* *libsoc.a:rtc_time.* *libc-psram-workaround.a:lock.* *libc-psram-workaround.a:lib_a-ctype_.* *libc-psram-workaround.a:lib_a-div.* *libc-psram-workaround.a:lib_a-systimes.* *libc-psram-workaround.a:lib_a-findfp.* *libc-psram-workaround.a:lib_a-strptime.* *libc-psram-workaround.a:lib_a-strlwr.* *libc-psram-workaround.a:lib_a-lcltime.* *libc-psram-workaround.a:lib_a-strupr.* *libc-psram-workaround.a:lib_a-fflush.* *libc-psram-workaround.a:lib_a-ctime.* *libc-psram-workaround.a:lib_a-rand.* *libc-psram-workaround.a:lib_a-impure.* *libc-psram-workaround.a:lib_a-syswrite.* *libc-psram-workaround.a:lib_a-isprint.* *libc-psram-workaround.a:lib_a-memmove.* *libc-psram-workaround.a:lib_a-strstr.* *libc-psram-workaround.a:lib_a-strtok_r.* *libc-psram-workaround.a:lib_a-fputwc.* *libc-psram-workaround.a:lib_a-strcpy.* *libc-psram-workaround.a:lib_a-utoa.* *libc-psram-workaround.a:lib_a-open.* *libc-psram-workaround.a:lib_a-memrchr.* *libc-psram-workaround.a:lib_a-itoa.* *libc-psram-workaround.a:lib_a-strsep.* *libc-psram-workaround.a:lib_a-strtoul.* *libc-psram-workaround.a:lib_a-toupper.* *libc-psram-workaround.a:lib_a-sysopen.* *libc-psram-workaround.a:lib_a-strdup_r.* *libc-psram-workaround.a:lib_a-strlcpy.* *libc-psram-workaround.a:lib_a-timelocal.* *libc-psram-workaround.a:lib_a-sbrk.* *libc-psram-workaround.a:lib_a-longjmp.* *libc-psram-workaround.a:lib_a-sysread.* *libc-psram-workaround.a:lib_a-syssbrk.* *libc-psram-workaround.a:lib_a-isgraph.* *libc-psram-workaround.a:lib_a-strnlen.* *libc-psram-workaround.a:lib_a-envlock.* *libc-psram-workaround.a:creat.* *libc-psram-workaround.a:lib_a-atoi.* *libc-psram-workaround.a:lib_a-refill.* *libc-psram-workaround.a:lib_a-memchr.* *libc-psram-workaround.a:lib_a-strchr.* *libc-psram-workaround.a:lib_a-system.* *libc-psram-workaround.a:lib_a-isspace.* *libc-psram-workaround.a:lib_a-getenv_r.* *libc-psram-workaround.a:lib_a-ldiv.* *libc-psram-workaround.a:lib_a-atol.* *libc-psram-workaround.a:lib_a-raise.* *libc-psram-workaround.a:lib_a-strncpy.* *libc-psram-workaround.a:lib_a-islower.* *libc-psram-workaround.a:lib_a-close.* *libc-psram-workaround.a:lib_a-wsetup.* *libc-psram-workaround.a:lib_a-isupper.* *libc-psram-workaround.a:lib_a-strftime.* *libc-psram-workaround.a:lib_a-strncat.* *libc-psram-workaround.a:lib_a-month_lengths.* *libc-psram-workaround.a:lib_a-bzero.* *libc-psram-workaround.a:lib_a-strcat.* *libc-psram-workaround.a:lib_a-srand.* *libc-psram-workaround.a:lib_a-setjmp.* *libc-psram-workaround.a:lib_a-sysclose.* *libc-psram-workaround.a:lib_a-memcpy.* *libc-psram-workaround.a:lib_a-isascii.* *libc-psram-workaround.a:lib_a-ctime_r.* *libc-psram-workaround.a:lib_a-mktime.* *libc-psram-workaround.a:lib_a-wbuf.* *libc-psram-workaround.a:isatty.* *libc-psram-workaround.a:lib_a-gmtime_r.* *libc-psram-workaround.a:lib_a-gmtime.* *libc-psram-workaround.a:lib_a-strndup_r.* *libc-psram-workaround.a:lib_a-strcoll.* *libc-psram-workaround.a:lib_a-tzvars.* *libc-psram-workaround.a:lib_a-wcrtomb.* *libc-psram-workaround.a:lib_a-isalpha.* *libc-psram-workaround.a:lib_a-lcltime_r.* *libc-psram-workaround.a:lib_a-toascii.* *libc-psram-workaround.a:lib_a-rshift.* *libc-psram-workaround.a:lib_a-strcmp.* *libc-psram-workaround.a:lib_a-memcmp.* *libc-psram-workaround.a:lib_a-fwalk.* *libc-psram-workaround.a:lib_a-creat.* *libc-psram-workaround.a:lib_a-strtol.* *libc-psram-workaround.a:lib_a-isalnum.* *libc-psram-workaround.a:lib_a-fclose.* *libc-psram-workaround.a:lib_a-gettzinfo.* *libc-psram-workaround.a:lib_a-strndup.* *libc-psram-workaround.a:lib_a-strrchr.* *libc-psram-workaround.a:lib_a-strspn.* *libc-psram-workaround.a:lib_a-quorem.* *libc-psram-workaround.a:lib_a-s_fpclassify.* *libc-psram-workaround.a:lib_a-ispunct.* *libc-psram-workaround.a:lib_a-rand_r.* *libc-psram-workaround.a:lib_a-tzset.* *libc-psram-workaround.a:lib_a-read.* *libc-psram-workaround.a:lib_a-isblank.* *libc-psram-workaround.a:lib_a-fvwrite.* *libc-psram-workaround.a:lib_a-strncmp.* *libc-psram-workaround.a:lib_a-asctime.* *libc-psram-workaround.a:lib_a-sf_nan.* *libc-psram-workaround.a:lib_a-abs.* *libc-psram-workaround.a:lib_a-strncasecmp.* *libc-psram-workaround.a:lib_a-iscntrl.* *libc-psram-workaround.a:lib_a-strcasecmp.* *libc-psram-workaround.a:lib_a-strcspn.* *libc-psram-workaround.a:lib_a-wctomb_r.* *libc-psram-workaround.a:lib_a-memccpy.* *libc-psram-workaround.a:lib_a-tolower.* *libc-psram-workaround.a:lib_a-asctime_r.* *libc-psram-workaround.a:lib_a-tzset_r.* *libc-psram-workaround.a:lib_a-stdio.* *libc-psram-workaround.a:lib_a-strlen.* *libc-psram-workaround.a:lib_a-sccl.* *libc-psram-workaround.a:lib_a-ungetc.* *libc-psram-workaround.a:lib_a-isdigit.* *libc-psram-workaround.a:lib_a-strlcat.* *libc-psram-workaround.a:lib_a-labs.* *libc-psram-workaround.a:lib_a-tzcalc_limits.* *libc-psram-workaround.a:lib_a-environ.* *libc-psram-workaround.a:lib_a-strdup.* *libc-psram-workaround.a:lib_a-memset.* *libc-psram-workaround.a:lib_a-tzlock.* *libc-psram-workaround.a:lib_a-strcasestr.* *libc-psram-workaround.a:lib_a-makebuf.* *libc-psram-workaround.a:lib_a-time.* *libfreertos.a *libgcov.a *libxtensa-debug-module.a:eri.* *libheap.a:multi_heap_poisoning.* *libheap.a:multi_heap.*) .text.* .wifi0iram .wifi0iram.*) + + *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) + *(.irom0.text) /* catch stray ICACHE_RODATA_ATTR */ + *(.fini.literal) + *(.fini) + *(.gnu.version) + _text_end = ABSOLUTE(.); + _etext = .; + + /* Similar to _iram_start, this symbol goes here so it is + resolved by addr2line in preference to the first symbol in + the flash.text segment. + */ + _flash_cache_start = ABSOLUTE(0); + } >iram0_2_seg +} diff --git a/esp32/frozen/Pybytes/_main.py b/esp32/frozen/Pybytes/_main.py index 54e77ec3fa..e69de29bb2 100644 --- a/esp32/frozen/Pybytes/_main.py +++ b/esp32/frozen/Pybytes/_main.py @@ -1,99 +0,0 @@ - -''' -Copyright (c) 2019, Pycom Limited. -This software is licensed under the GNU GPL version 3 or any -later version, with permitted additional terms. For more information -see the Pycom Licence v1.0 document supplied with this file, or -available at https://www.pycom.io/opensource/licensing - -This is the main.py file for Pybytes -This code and included libraries are intended for users wishing to fully -customise pybytes. It is the same code that is included in the Pybytes firmware -If you're planning to use the Pybytes firmware, please check out the -examples in the examples directory which are much easier to use. -If you make changes to any of the libraries in the lib directory, -you only need to upload the changed files if using the Pybytes firmware. -The other libraries will be loaded from the built-in code. -If you make changes above "Please put your USER code below this line" while -using a Pybytes enabled firmware, you need to disable auto-start. -You can disable auto-start by setting "pybytes_autostart": false in -pybytes_project.json or pybytes_config.json. -If using the Pybytes firmware, the configuration is already loaded and this -cannot be deactivated. However if you disable auto-start, you can modify the -configuration before connecting to Pybytes manually using pybytes.connect() -''' - -# Load configuration, migrate to pybytes_config.json if necessary -if 'pybytes_config' not in globals().keys(): - try: - from pybytes_config import PybytesConfig - except: - from _pybytes_config import PybytesConfig - try: - from pybytes import Pybytes - except: - from _pybytes import Pybytes - - pybytes_config = PybytesConfig().read_config() - -if (not pybytes_config.get('pybytes_autostart', True)) and pybytes_config.get('cfg_msg') is not None: - print(pybytes_config.get('cfg_msg')) - print("Not starting Pybytes as auto-start is disabled") - -else: - # Load Pybytes if it is not already loaded - if 'pybytes' not in globals().keys(): - pybytes = Pybytes(pybytes_config, pybytes_config.get('cfg_msg') is None, True) - - # Please put your USER code below this line - - # SEND SIGNAL - # You can currently send Strings, Int32, Float32 and Tuples to pybytes using this method. - # pybytes.send_signal(signalNumber, value) - - # SEND SENSOR DATA THROUGH SIGNALS - # # If you use a Pysense, some libraries are necessary to access its sensors - # # you can find them here: https://github.com/pycom/pycom-libraries - # - # # Include the libraries in the lib folder then import the ones you want to use here: - # from SI7006A20 import SI7006A20 - # si = SI7006A20() - # from LTR329ALS01 import LTR329ALS01 - # ltr = LTR329ALS01() - # - # # Import what is necessary to create a thread - # import _thread - # from time import sleep - # from machine import Pin - # - # # Define your thread's behaviour, here it's a loop sending sensors data every 10 seconds - # def send_env_data(): - # while (pybytes): - # pybytes.send_signal(1, si.humidity()) - # pybytes.send_signal(2, si.temperature()) - # pybytes.send_signal(3, ltr.light()); - # sleep(10) - # - # # Start your thread - # _thread.start_new_thread(send_env_data, ()) - - # SET THE BATTERY LEVEL - # pybytes.send_battery_level(23) - - # SEND DIGITAL VALUE - # pybytes.send_digital_pin_value(False, 12, Pin.PULL_UP) - - # SEND ANALOG VALUE - # pybytes.send_analog_pin_value(False, 13) - - # REGISTER PERIODICAL DIGIAL VALUE SEND - # pybytes.register_periodical_digital_pin_publish(False, PIN_NUMBER, Pin.PULL_UP, INTERVAL_SECONDS) - - # REGISTER PERIODICAL ANALOG VALUE SEND - # pybytes.register_periodical_analog_pin_publish(False, PIN_NUMBER, INTERVAL_SECONDS) - - # CUSTOM METHOD EXAMPLE - # def custom_print(params): - # print("Custom method called") - # return [255, 20] - # pybytes.add_custom_method(0, custom_print) diff --git a/esp32/frozen/Pybytes/_pybytes.py b/esp32/frozen/Pybytes/_pybytes.py index 607e3a6d70..0b1d646dcb 100644 --- a/esp32/frozen/Pybytes/_pybytes.py +++ b/esp32/frozen/Pybytes/_pybytes.py @@ -8,6 +8,7 @@ import os, json, binascii import time, pycom +import sys from network import WLAN from machine import Timer @@ -50,12 +51,7 @@ def __init__(self, config, activation=False, autoconnect=False): pycom.wifi_on_boot(False, True) self.__check_dump_ca() - try: - from pybytes_connection import PybytesConnection - except: - from _pybytes_connection import PybytesConnection - self.__pybytes_connection = PybytesConnection(self.__conf, self.__recv_message) - + self.__create_pybytes_connection(self.__conf) self.start(autoconnect) if autoconnect: self.print_cfg_msg() @@ -63,6 +59,13 @@ def __init__(self, config, activation=False, autoconnect=False): if (hasattr(pycom, 'smart_config_on_boot') and pycom.smart_config_on_boot()): self.smart_config(True) + def __create_pybytes_connection(self, conf): + try: + from pybytes_connection import PybytesConnection + except: + from _pybytes_connection import PybytesConnection + self.__pybytes_connection = PybytesConnection(conf, self.__recv_message) + def __check_config(self): try: print_debug(99, self.__conf) @@ -91,17 +94,17 @@ def connect_wifi(self, reconnect=True, check_interval=0.5): self.__check_init() return self.__pybytes_connection.connect_wifi(reconnect, check_interval) - def connect_lte(self, reconnect=True, check_interval=0.5): + def connect_lte(self): self.__check_init() - return self.__pybytes_connection.connect_lte(reconnect, check_interval) + return self.__pybytes_connection.connect_lte() def connect_lora_abp(self, timeout, nanogateway=False): self.__check_init() return self.__pybytes_connection.connect_lora_abp(timeout, nanogateway) - def connect_lora_otta(self, timeout=120, nanogateway=False): + def connect_lora_otaa(self, timeout=120, nanogateway=False): self.__check_init() - return self.__pybytes_connection.connect_lora_otta(timeout, nanogateway) + return self.__pybytes_connection.connect_lora_otaa(timeout, nanogateway) def connect_sigfox(self): self.__check_init() @@ -139,9 +142,9 @@ def send_analog_pin_value(self, persistent, pin): self.__check_init() self.__pybytes_connection.__pybytes_protocol.send_pybytes_analog_value(pin) - def send_signal(self, pin, value): + def send_signal(self, signal_number, value): self.__check_init() - self.__pybytes_connection.__pybytes_protocol.send_pybytes_custom_method_values(pin, [value]) + self.__pybytes_connection.__pybytes_protocol.send_pybytes_custom_method_values(signal_number, [value]) def send_virtual_pin_value(self, persistent, pin, value): self.__check_init() @@ -216,11 +219,7 @@ def connect(self): lora_joining_timeout = 120 # seconds to wait for LoRa joining if self.__config_updated: if self.__check_config(): - try: - from pybytes_connection import PybytesConnection - except: - from _pybytes_connection import PybytesConnection - self.__pybytes_connection = PybytesConnection(self.__conf, self.__recv_message) + self.__create_pybytes_connection(self.__conf) self.__config_updated = False self.__check_init() @@ -239,7 +238,7 @@ def connect(self): if self.connect_lora_abp(lora_joining_timeout): break elif net == 'lora_otaa': - if self.connect_lora_otta(lora_joining_timeout): + if self.connect_lora_otaa(lora_joining_timeout): break elif net == 'sigfox': if self.connect_sigfox(): @@ -315,14 +314,24 @@ def set_config( def update_config(self, key, value=None, permanent=True, silent=False, reconnect=False): try: - self.__conf[key].update(value) + if isinstance(self.__conf[key], dict): + self.__conf[key].update(value) + elif type(self.__conf[key]) is list: + # set new list + self.__conf[key] = [] + values = list(value.split(",")) + # removes leading whitespaces on array itens + values = [item.strip() for item in values] + self.__conf[key] = values + else: + self.__conf[key] = value self.__config_updated = True if permanent: self.write_config(silent=silent) if reconnect: self.reconnect() except Exception as ex: print('Error updating configuration!') - print('{}: {}'.format(ex.__name__, ex)) + sys.print_exception(ex) def read_config(self, file='/flash/pybytes_config.json', reconnect=False): @@ -449,14 +458,15 @@ def activate(self, activation_string): except: from _pybytes_config import PybytesConfig try: - self.__conf = PybytesConfig().cli_config(activation_info=jstring) + self.__create_pybytes_connection(None) + self.__conf = PybytesConfig().cli_config(activation_info=jstring, pybytes_connection=self.__pybytes_connection) if self.__conf is not None: self.start() else: print('Activation failed!') except Exception as ex: print('Activation failed! Please try again...') - print_debug(1, ex) + sys.print_exception(ex) if hasattr(pycom, 'smart_config_on_boot'): def smart_config(self, status=None, reset_ap=False): diff --git a/esp32/frozen/Pybytes/_pybytes_config.py b/esp32/frozen/Pybytes/_pybytes_config.py index 346ed9647f..b52c0e1831 100644 --- a/esp32/frozen/Pybytes/_pybytes_config.py +++ b/esp32/frozen/Pybytes/_pybytes_config.py @@ -111,7 +111,6 @@ def __read_cli_activation(self, activation_token): import _urequest as urequest from uhashlib import sha512 - print('Wifi connection established... activating device!') self.__pybytes_cli_activation = None data = { "activationToken": activation_token['a'], "deviceMacAddress": binascii.hexlify(machine.unique_id()).upper()} time.sleep(1) @@ -146,6 +145,7 @@ def __process_sigfox_registration(self, activation_token): time.sleep(15) try: self.__pybytes_sigfox_registration = urequest.post('https://api.{}/v2/register-sigfox'.format(constants.__DEFAULT_DOMAIN), json=data, headers={'content-type': 'application/json'}) + print_debug(2, '/v2/register-sigfox returned response: {}'.format(self.__pybytes_sigfox_registration.text)) jsigfox = self.__pybytes_sigfox_registration.json() except: jsigfox = None @@ -171,7 +171,7 @@ def __process_sigfox_registration(self, activation_token): def __process_cli_activation(self, filename, activation_token): try: if not self.__pybytes_cli_activation.status_code == 200: - print_debug(3, 'Activation request returned {}.'.format(self.__pybytes_cli_activation.status_code)) + print_debug(3, 'Activation request returned {} with text: "{}".'.format(self.__pybytes_cli_activation.status_code, self.__pybytes_cli_activation.text)) else: print_debug(99, 'Activation response:\n{}'.format(self.__pybytes_cli_activation.json())) if self.__process_sigfox_registration(activation_token): @@ -182,6 +182,10 @@ def __process_cli_activation(self, filename, activation_token): pass return self.__pybytes_config else: + try: + self.__pybytes_cli_activation.close() + except: + pass print('Unable to provision Sigfox! Please try again.') return None @@ -233,39 +237,38 @@ def __read_cb_config(self): return config_block def __generate_cli_config(self): - cli_config = {} + pybytes_config = self.__pybytes_cli_activation.json() + cli_config = { + 'userId' : pybytes_config.get('userId'), + 'device_token' : pybytes_config.get('deviceToken'), + 'mqttServiceAddress' : pybytes_config.get('mqttServiceAddress'), + 'network_preferences' : pybytes_config.get('network_preferences'), + 'wifi_ssid': '', + 'wifi_pwd': '', + } try: - cli_config = { - 'userId' : self.__pybytes_cli_activation.json().get('userId'), - 'device_token' : self.__pybytes_cli_activation.json().get('deviceToken'), - 'mqttServiceAddress' : self.__pybytes_cli_activation.json().get('mqttServiceAddress'), - 'network_preferences' : self.__pybytes_cli_activation.json().get('network_preferences'), - 'wifi_ssid' : self.__pybytes_cli_activation.json().get('wifi').get('ssid'), - 'wifi_pwd': self.__pybytes_cli_activation.json().get('wifi').get('password') - } + cli_config.update({'wifi_ssid' : pybytes_config.get('wifi').get('ssid')}) except: - pass - - cli_lte_config = {} + print_debug(3, '__generate_cli_config: config does not contain wifi_ssid') try: - cli_lte_config = { - 'carrier' : self.__pybytes_cli_activation.json().get('lte').get('carrier').lower(), - 'apn' : self.__pybytes_cli_activation.json().get('lte').get('apn'), - 'cid' : self.__pybytes_cli_activation.json().get('lte').get('cid'), - 'band' : self.__pybytes_cli_activation.json().get('lte').get('band'), - 'reset' : self.__pybytes_cli_activation.json().get('lte').get('reset'), - 'protocol' : self.__pybytes_cli_activation.json().get('lte').get('protocol') - } + cli_config.update({'wifi_pwd': pybytes_config.get('wifi').get('password')}) except: - pass + print_debug(3, '__generate_cli_config: config does not contain wifi_password') try: - cli_config.update({'extra_preferences' :self.__pybytes_cli_activation.json().get('extra_preferences', '')}) + cli_config.update({ + 'carrier' : pybytes_config.get('lte').get('carrier').lower(), + 'apn' : pybytes_config.get('lte').get('apn'), + 'cid' : pybytes_config.get('lte').get('cid'), + 'band' : pybytes_config.get('lte').get('band'), + 'reset' : pybytes_config.get('lte').get('reset'), + 'protocol' : pybytes_config.get('lte').get('protocol') + }) except: - pass + print_debug(3, '__generate_cli_config: config does not contain LTE configuration') try: - cli_config.update(cli_lte_config) + cli_config.update({'extra_preferences' :pybytes_config.get('extra_preferences', '')}) except: - pass + print_debug(3, '__generate_cli_config: config does not contain extra_preferences') return cli_config def __process_config(self, filename, configuration): @@ -342,7 +345,6 @@ def __process_config(self, filename, configuration): print_debug(2, 'Exception __process_config[lte]\n{}'.format(e)) try: - #if True: self.__pybytes_config = { 'username': configuration['userId'], # Pybytes username 'device_id': configuration['device_token'], # device token @@ -406,8 +408,20 @@ def smart_config(self, filename='/flash/pybytes_config.json'): time.sleep(10) return self.__pybytes_config - def cli_config(self, filename='/flash/pybytes_config.json', activation_info=None, timeout = 60): + def cli_config(self, pybytes_connection, filename='/flash/pybytes_config.json', activation_info=None): print_debug(99, activation_info) + if 's' in activation_info: + print_debug(3, 'performing Wi-Fi activation') + self.__cli_activation_over_wifi(activation_info) + print('Wifi connection established... activating device!') + if 'apn' in activation_info: + print_debug(3, 'performing LTE activation') + pybytes_connection.connect_lte(activation_info=activation_info, start_mqtt=False) + + self.__read_cli_activation(activation_info) + return self.__process_cli_activation(filename, activation_info) + + def __cli_activation_over_wifi(self, activation_info): print('Please wait while we try to connect to {}'.format(activation_info.get('s'))) from network import WLAN wlan = WLAN(mode=WLAN.STA) @@ -436,8 +450,11 @@ def cli_config(self, filename='/flash/pybytes_config.json', activation_info=None net_to_use = net_to_use[0] pwd = dict(known_nets)[net_to_use] sec = [e.sec for e in available_nets if e.ssid == net_to_use][0] # noqa - print_debug(2, "Connecting with {} and {}".format(net_to_use, pwd)) - wlan.connect(net_to_use, (sec, pwd), timeout=10000) + print_debug(99, "Connecting with {} and {}".format(net_to_use, pwd)) + if sec == 0: + wlan.connect(net_to_use, timeout=10000) + else: + wlan.connect(net_to_use, (sec, pwd), timeout=10000) start_time = time.time() while not wlan.isconnected(): if time.time() - start_time > timeout: @@ -451,9 +468,6 @@ def cli_config(self, filename='/flash/pybytes_config.json', activation_info=None elif attempt == 3: print("Error connecting using WIFI: %s" % e) return None - self.__read_cli_activation(activation_info) - return self.__process_cli_activation(filename, activation_info) - def read_config(self, filename='/flash/pybytes_config.json'): try: diff --git a/esp32/frozen/Pybytes/_pybytes_connection.py b/esp32/frozen/Pybytes/_pybytes_connection.py index bc86eb6c59..8fd76c551c 100644 --- a/esp32/frozen/Pybytes/_pybytes_connection.py +++ b/esp32/frozen/Pybytes/_pybytes_connection.py @@ -27,6 +27,7 @@ from _pybytes_debug import print_debug import os +import sys import _thread import time import socket @@ -38,23 +39,23 @@ class PybytesConnection: def __init__(self, config, message_callback): - self.__conf = config - try: - self.__host = pycom.nvs_get('pybytes_server') - except: - self.__host = config.get('server') - self.__ssl = config.get('ssl', False) - self.__ssl_params = config.get('ssl_params', {}) - self.__user_name = config.get('username') - self.__device_id = config.get('device_id') - self.__mqtt_download_topic = "d" + self.__device_id - self.__mqtt_upload_topic = "u" + self.__device_id + if config is not None: + self.__conf = config + try: + self.__host = pycom.nvs_get('pybytes_server') + except: + self.__host = config.get('server') + self.__ssl = config.get('ssl', False) + self.__ssl_params = config.get('ssl_params', {}) + self.__user_name = config.get('username') + self.__device_id = config.get('device_id') + self.__mqtt_download_topic = "d" + self.__device_id + self.__mqtt_upload_topic = "u" + self.__device_id + self.__pybytes_protocol = PybytesProtocol( + config, message_callback, pybytes_connection=self + ) self.__connection = None -# self.__thread_stack_size = 8192 self.__connection_status = constants.__CONNECTION_STATUS_DISCONNECTED - self.__pybytes_protocol = PybytesProtocol( - config, message_callback, pybytes_connection=self - ) self.__lora_socket = None self.lora = None self.lora_lock = _thread.allocate_lock() @@ -130,7 +131,10 @@ def connect_wifi(self, reconnect=True, check_interval=0.5, timeout=120): pwd = dict(known_nets)[net_to_use] sec = [e.sec for e in available_nets if e.ssid == net_to_use][0] # noqa print_debug(99, "Connecting with {} and {}".format(net_to_use, pwd)) - self.wlan.connect(net_to_use, (sec, pwd), timeout=10000) + if sec == 0: + self.wlan.connect(net_to_use, timeout=10000) + else: + self.wlan.connect(net_to_use, (sec, pwd), timeout=10000) start_time = time.time() while not self.wlan.isconnected(): if time.time() - start_time > timeout: @@ -174,10 +178,13 @@ def connect_wifi(self, reconnect=True, check_interval=0.5, timeout=120): return False # Establish a connection through LTE before connecting to mqtt server - def connect_lte(self, reconnect=True, check_interval=0.5): - self.__initialise_watchdog() + def connect_lte(self, activation_info=False, start_mqtt=True): + if activation_info: + lte_cfg = activation_info + else: + lte_cfg = self.__conf.get('lte') + self.__initialise_watchdog() - lte_cfg = self.__conf.get('lte') if lte_cfg is not None: if (os.uname()[0] not in ['FiPy', 'GPy']): print("You need a device with FiPy or GPy firmware to connect via LTE") # noqa @@ -225,32 +232,35 @@ def connect_lte(self, reconnect=True, check_interval=0.5): time.sleep(0.25) print("LTE connection established") self.__network_type = constants.__NETWORK_TYPE_LTE - try: - self.__connection = MQTTClient( - self.__device_id, - self.__host, - self.__mqtt_download_topic, - self.__pybytes_protocol, - user=self.__user_name, - password=self.__device_id - ) - self.__connection.connect() - self.__connection_status = constants.__CONNECTION_STATUS_CONNECTED_MQTT_LTE # noqa - self.__pybytes_protocol.start_MQTT( - self, - constants.__NETWORK_TYPE_WIFI - ) - print("Connected to MQTT {}".format(self.__host)) - return True - except Exception as ex: - if '{}'.format(ex) == '4': - print('MQTT ERROR! Bad credentials when connecting to server: "{}"'.format(self.__host)) # noqa - else: - print("MQTT ERROR! {}".format(ex)) - return False + + if start_mqtt: + try: + self.__connection = MQTTClient( + self.__device_id, + self.__host, + self.__mqtt_download_topic, + self.__pybytes_protocol, + user=self.__user_name, + password=self.__device_id + ) + self.__connection.connect() + self.__connection_status = constants.__CONNECTION_STATUS_CONNECTED_MQTT_LTE # noqa + self.__pybytes_protocol.start_MQTT( + self, + constants.__NETWORK_TYPE_LTE + ) + print("Connected to MQTT {}".format(self.__host)) + return True + except Exception as ex: + if '{}'.format(ex) == '4': + print('MQTT ERROR! Bad credentials when connecting to server: "{}"'.format(self.__host)) # noqa + else: + print("MQTT ERROR! {}".format(ex)) + return False except Exception as ex: print("Exception connect_lte: {}".format(ex)) - return False + sys.print_exception(ex) + return False else: print("Error... missing configuration!") return False @@ -267,10 +277,11 @@ def connect_lora_abp(self, lora_timeout, nanogateway): print("This device does not support LoRa connections: %s" % ex) return False + lora_class = self.__conf.get('lora', {}).get('class', 0) if self.__conf.get('lora', {}).get('region') is not None: - self.lora = LoRa(mode=LoRa.LORAWAN, region=self.__conf.get('lora', {}).get('region')) + self.lora = LoRa(mode=LoRa.LORAWAN, region=self.__conf.get('lora').get('region'), device_class=lora_class) else: - self.lora = LoRa(mode=LoRa.LORAWAN) + self.lora = LoRa(mode=LoRa.LORAWAN, device_class=lora_class) self.lora.nvram_restore() try: @@ -313,10 +324,10 @@ def connect_lora_abp(self, lora_timeout, nanogateway): print_debug(3, 'Exception in LoRa connect: {}'.format(e)) return False - def connect_lora_otta(self, lora_timeout, nanogateway): + def connect_lora_otaa(self, lora_timeout, nanogateway): print_debug(1,'Attempting to connect via LoRa') if (self.__connection_status != constants.__CONNECTION_STATUS_DISCONNECTED): # noqa - print("Error connect_lora_otta: Connection already exists. Disconnect First") # noqa + print("Error connect_lora_otaa: Connection already exists. Disconnect First") # noqa return False try: from network import LoRa @@ -335,10 +346,11 @@ def connect_lora_otta(self, lora_timeout, nanogateway): timeout_ms = self.__conf.get('lora_timeout', lora_timeout) * 1000 + lora_class = self.__conf.get('lora', {}).get('class', 0) if self.__conf.get('lora', {}).get('region') is not None: - self.lora = LoRa(mode=LoRa.LORAWAN, region=self.__conf.get('lora', {}).get('region')) + self.lora = LoRa(mode=LoRa.LORAWAN, region=self.__conf.get('lora', {}).get('region'), device_class=lora_class) else: - self.lora = LoRa(mode=LoRa.LORAWAN) + self.lora = LoRa(mode=LoRa.LORAWAN, device_class=lora_class) self.lora.nvram_restore() dev_eui = binascii.unhexlify(dev_eui.replace(' ', '')) diff --git a/esp32/frozen/Pybytes/_pybytes_main.py b/esp32/frozen/Pybytes/_pybytes_main.py new file mode 100644 index 0000000000..54e77ec3fa --- /dev/null +++ b/esp32/frozen/Pybytes/_pybytes_main.py @@ -0,0 +1,99 @@ + +''' +Copyright (c) 2019, Pycom Limited. +This software is licensed under the GNU GPL version 3 or any +later version, with permitted additional terms. For more information +see the Pycom Licence v1.0 document supplied with this file, or +available at https://www.pycom.io/opensource/licensing + +This is the main.py file for Pybytes +This code and included libraries are intended for users wishing to fully +customise pybytes. It is the same code that is included in the Pybytes firmware +If you're planning to use the Pybytes firmware, please check out the +examples in the examples directory which are much easier to use. +If you make changes to any of the libraries in the lib directory, +you only need to upload the changed files if using the Pybytes firmware. +The other libraries will be loaded from the built-in code. +If you make changes above "Please put your USER code below this line" while +using a Pybytes enabled firmware, you need to disable auto-start. +You can disable auto-start by setting "pybytes_autostart": false in +pybytes_project.json or pybytes_config.json. +If using the Pybytes firmware, the configuration is already loaded and this +cannot be deactivated. However if you disable auto-start, you can modify the +configuration before connecting to Pybytes manually using pybytes.connect() +''' + +# Load configuration, migrate to pybytes_config.json if necessary +if 'pybytes_config' not in globals().keys(): + try: + from pybytes_config import PybytesConfig + except: + from _pybytes_config import PybytesConfig + try: + from pybytes import Pybytes + except: + from _pybytes import Pybytes + + pybytes_config = PybytesConfig().read_config() + +if (not pybytes_config.get('pybytes_autostart', True)) and pybytes_config.get('cfg_msg') is not None: + print(pybytes_config.get('cfg_msg')) + print("Not starting Pybytes as auto-start is disabled") + +else: + # Load Pybytes if it is not already loaded + if 'pybytes' not in globals().keys(): + pybytes = Pybytes(pybytes_config, pybytes_config.get('cfg_msg') is None, True) + + # Please put your USER code below this line + + # SEND SIGNAL + # You can currently send Strings, Int32, Float32 and Tuples to pybytes using this method. + # pybytes.send_signal(signalNumber, value) + + # SEND SENSOR DATA THROUGH SIGNALS + # # If you use a Pysense, some libraries are necessary to access its sensors + # # you can find them here: https://github.com/pycom/pycom-libraries + # + # # Include the libraries in the lib folder then import the ones you want to use here: + # from SI7006A20 import SI7006A20 + # si = SI7006A20() + # from LTR329ALS01 import LTR329ALS01 + # ltr = LTR329ALS01() + # + # # Import what is necessary to create a thread + # import _thread + # from time import sleep + # from machine import Pin + # + # # Define your thread's behaviour, here it's a loop sending sensors data every 10 seconds + # def send_env_data(): + # while (pybytes): + # pybytes.send_signal(1, si.humidity()) + # pybytes.send_signal(2, si.temperature()) + # pybytes.send_signal(3, ltr.light()); + # sleep(10) + # + # # Start your thread + # _thread.start_new_thread(send_env_data, ()) + + # SET THE BATTERY LEVEL + # pybytes.send_battery_level(23) + + # SEND DIGITAL VALUE + # pybytes.send_digital_pin_value(False, 12, Pin.PULL_UP) + + # SEND ANALOG VALUE + # pybytes.send_analog_pin_value(False, 13) + + # REGISTER PERIODICAL DIGIAL VALUE SEND + # pybytes.register_periodical_digital_pin_publish(False, PIN_NUMBER, Pin.PULL_UP, INTERVAL_SECONDS) + + # REGISTER PERIODICAL ANALOG VALUE SEND + # pybytes.register_periodical_analog_pin_publish(False, PIN_NUMBER, INTERVAL_SECONDS) + + # CUSTOM METHOD EXAMPLE + # def custom_print(params): + # print("Custom method called") + # return [255, 20] + # pybytes.add_custom_method(0, custom_print) diff --git a/esp32/frozen/Pybytes/_pybytes_protocol.py b/esp32/frozen/Pybytes/_pybytes_protocol.py index ba11c509e3..685d9d9c9a 100644 --- a/esp32/frozen/Pybytes/_pybytes_protocol.py +++ b/esp32/frozen/Pybytes/_pybytes_protocol.py @@ -323,7 +323,7 @@ def __process_recv_message(self, message): if (method_return is not None and len(method_return) > 0): # noqa self.send_pybytes_custom_method_values( - pin_number, method_return + signal_number, method_return ) else: @@ -459,13 +459,13 @@ def send_pybytes_digital_value(self, pin_number, pull_mode): if (pin_number not in self.__pins): self.__configure_digital_pin(pin_number, Pin.IN, pull_mode) pin = self.__pins[pin_number] - self.send_pybytes_custom_method_values(pin_number, [pin()]) + self.send_pybytes_custom_method_values(signal_number, [pin()]) def send_pybytes_analog_value(self, pin_number): if (pin_number not in self.__pins): self.__configure_analog_pin(pin_number) pin = self.__pins[pin_number] - self.send_pybytes_custom_method_values(pin_number, [pin()]) + self.send_pybytes_custom_method_values(signal_number, [pin()]) def send_pybytes_custom_method_values(self, method_id, parameters): if(isinstance(parameters[0], int)): diff --git a/esp32/get_idf_libs.py b/esp32/get_idf_libs.py index 9cac0c5401..6dae1bc242 100644 --- a/esp32/get_idf_libs.py +++ b/esp32/get_idf_libs.py @@ -28,6 +28,7 @@ def main(): shutil.copy(src + '/bootloader/micro-ecc/libmicro-ecc.a', dsttmpbl) shutil.copy(src + '/bootloader/soc/libsoc.a', dsttmpbl) shutil.copy(src + '/bootloader/spi_flash/libspi_flash.a', dsttmpbl) + shutil.copy(src + '/bootloader/efuse/libefuse.a', dsttmpbl) # copy the application libraries @@ -61,6 +62,11 @@ def main(): shutil.copy(src + '/xtensa-debug-module/libxtensa-debug-module.a', dsttmpapp) shutil.copy(src + '/esp_ringbuf/libesp_ringbuf.a', dsttmpapp) shutil.copy(src + '/coap/libcoap.a', dsttmpapp) + shutil.copy(src + '/mdns/libmdns.a', dsttmpapp) + shutil.copy(src + '/efuse/libefuse.a', dsttmpapp) + shutil.copy(src + '/espcoredump/libespcoredump.a', dsttmpapp) + shutil.copy(src + '/app_update/libapp_update.a', dsttmpapp) + except: print("Couldn't Copy IDF libs defaulting to Local Lib Folders!") traceback.print_exc() @@ -74,10 +80,16 @@ def main(): for item in os.listdir(dsttmpapp): shutil.copy(dsttmpapp + '/' + item, dstapp + '/' + item) + # copy the project's linker script + shutil.copy(src + '/esp32/esp32.project.ld', ".") + + # copy the generated sdkconfig.h + shutil.copy(src + '/include/sdkconfig.h', ".") + shutil.rmtree(dsttmpbl) shutil.rmtree(dsttmpapp) - print("IDF Libs copied Successfully!") + print("IDF Libs, linker script and sdkconfig.h copied successfully!") if __name__ == "__main__": diff --git a/esp32/get_sigfox_libs.py b/esp32/get_sigfox_libs.py new file mode 100755 index 0000000000..92ba7f0375 --- /dev/null +++ b/esp32/get_sigfox_libs.py @@ -0,0 +1,24 @@ +#!/usr/bin/python3 + +import os +import sys +import argparse +import shutil +import traceback + + +def main(): + try: + shutil.copy('./build/FIPY/release/sigfox/sigfox.a', './sigfox/modsigfox_FIPY.a') + shutil.copy('./build/LOPY4/release/sigfox/sigfox.a', './sigfox/modsigfox_LOPY4.a') + shutil.copy('./build/SIPY/release/sigfox/sigfox.a', './sigfox/modsigfox_SIPY.a') + except: + print("Couldn't copy Sigfox libs!") + traceback.print_exc() + return + + print("Sigfox libs copied successfully!") + + +if __name__ == "__main__": + main() diff --git a/esp32/lib/libapp_update.a b/esp32/lib/libapp_update.a new file mode 100644 index 0000000000..459a61bc6b Binary files /dev/null and b/esp32/lib/libapp_update.a differ diff --git a/esp32/lib/libbootloader_support.a b/esp32/lib/libbootloader_support.a index 827bda5744..97e60ce4ba 100644 Binary files a/esp32/lib/libbootloader_support.a and b/esp32/lib/libbootloader_support.a differ diff --git a/esp32/lib/libbt.a b/esp32/lib/libbt.a index fea2543c3f..76cd4d136f 100644 Binary files a/esp32/lib/libbt.a and b/esp32/lib/libbt.a differ diff --git a/esp32/lib/libcoap.a b/esp32/lib/libcoap.a index e4dedc793e..216e7ed683 100644 Binary files a/esp32/lib/libcoap.a and b/esp32/lib/libcoap.a differ diff --git a/esp32/lib/libcxx.a b/esp32/lib/libcxx.a index f82dfa4760..78e4b4e780 100644 Binary files a/esp32/lib/libcxx.a and b/esp32/lib/libcxx.a differ diff --git a/esp32/lib/libdriver.a b/esp32/lib/libdriver.a index bfda23dee8..90067f3d2a 100644 Binary files a/esp32/lib/libdriver.a and b/esp32/lib/libdriver.a differ diff --git a/esp32/lib/libefuse.a b/esp32/lib/libefuse.a new file mode 100644 index 0000000000..33b5ad9d4c Binary files /dev/null and b/esp32/lib/libefuse.a differ diff --git a/esp32/lib/libesp32.a b/esp32/lib/libesp32.a index 3545e7ab13..77fdbf3bca 100644 Binary files a/esp32/lib/libesp32.a and b/esp32/lib/libesp32.a differ diff --git a/esp32/lib/libesp_adc_cal.a b/esp32/lib/libesp_adc_cal.a index 064cc3cb26..14721e2424 100644 Binary files a/esp32/lib/libesp_adc_cal.a and b/esp32/lib/libesp_adc_cal.a differ diff --git a/esp32/lib/libesp_ringbuf.a b/esp32/lib/libesp_ringbuf.a index 9984660ba7..a15816cf08 100644 Binary files a/esp32/lib/libesp_ringbuf.a and b/esp32/lib/libesp_ringbuf.a differ diff --git a/esp32/lib/libespcoredump.a b/esp32/lib/libespcoredump.a new file mode 100644 index 0000000000..ee8e067f09 Binary files /dev/null and b/esp32/lib/libespcoredump.a differ diff --git a/esp32/lib/libexpat.a b/esp32/lib/libexpat.a index 59a7bea4ef..c9e8c87a2e 100644 Binary files a/esp32/lib/libexpat.a and b/esp32/lib/libexpat.a differ diff --git a/esp32/lib/libfreertos.a b/esp32/lib/libfreertos.a index 41eaa61b75..782d964b08 100644 Binary files a/esp32/lib/libfreertos.a and b/esp32/lib/libfreertos.a differ diff --git a/esp32/lib/libheap.a b/esp32/lib/libheap.a index 4e26d21651..fdce0e1419 100644 Binary files a/esp32/lib/libheap.a and b/esp32/lib/libheap.a differ diff --git a/esp32/lib/libjsmn.a b/esp32/lib/libjsmn.a index cb8fcdd8fa..5855766e6e 100644 Binary files a/esp32/lib/libjsmn.a and b/esp32/lib/libjsmn.a differ diff --git a/esp32/lib/libjson.a b/esp32/lib/libjson.a index acc84d42a4..1410e76d88 100644 Binary files a/esp32/lib/libjson.a and b/esp32/lib/libjson.a differ diff --git a/esp32/lib/liblog.a b/esp32/lib/liblog.a index df43624c42..8ac452e826 100644 Binary files a/esp32/lib/liblog.a and b/esp32/lib/liblog.a differ diff --git a/esp32/lib/liblwip.a b/esp32/lib/liblwip.a index c3840f8adb..bb5b120612 100644 Binary files a/esp32/lib/liblwip.a and b/esp32/lib/liblwip.a differ diff --git a/esp32/lib/libmbedtls.a b/esp32/lib/libmbedtls.a index 1ddd73744f..6653884d71 100644 Binary files a/esp32/lib/libmbedtls.a and b/esp32/lib/libmbedtls.a differ diff --git a/esp32/lib/libmdns.a b/esp32/lib/libmdns.a new file mode 100644 index 0000000000..f76144ca38 Binary files /dev/null and b/esp32/lib/libmdns.a differ diff --git a/esp32/lib/libmicro-ecc.a b/esp32/lib/libmicro-ecc.a index 3fac87564c..79f74067af 100644 Binary files a/esp32/lib/libmicro-ecc.a and b/esp32/lib/libmicro-ecc.a differ diff --git a/esp32/lib/libnewlib.a b/esp32/lib/libnewlib.a index ce45de2f81..d33a81dba6 100644 Binary files a/esp32/lib/libnewlib.a and b/esp32/lib/libnewlib.a differ diff --git a/esp32/lib/libnghttp.a b/esp32/lib/libnghttp.a index 3cb3159025..921be622f3 100644 Binary files a/esp32/lib/libnghttp.a and b/esp32/lib/libnghttp.a differ diff --git a/esp32/lib/libnvs_flash.a b/esp32/lib/libnvs_flash.a index 1dd0272fbd..972e284757 100644 Binary files a/esp32/lib/libnvs_flash.a and b/esp32/lib/libnvs_flash.a differ diff --git a/esp32/lib/libopenssl.a b/esp32/lib/libopenssl.a index 3a7ba5afe1..4bc1c06152 100644 Binary files a/esp32/lib/libopenssl.a and b/esp32/lib/libopenssl.a differ diff --git a/esp32/lib/libpthread.a b/esp32/lib/libpthread.a index 74263519b5..8c83b9d0c2 100644 Binary files a/esp32/lib/libpthread.a and b/esp32/lib/libpthread.a differ diff --git a/esp32/lib/libsdmmc.a b/esp32/lib/libsdmmc.a index 83544cc3fa..7b033859d2 100644 Binary files a/esp32/lib/libsdmmc.a and b/esp32/lib/libsdmmc.a differ diff --git a/esp32/lib/libsmartconfig_ack.a b/esp32/lib/libsmartconfig_ack.a index c7ecd2c0d7..b06df822ef 100644 Binary files a/esp32/lib/libsmartconfig_ack.a and b/esp32/lib/libsmartconfig_ack.a differ diff --git a/esp32/lib/libsoc.a b/esp32/lib/libsoc.a index c9ad01eb5f..255749e5e8 100644 Binary files a/esp32/lib/libsoc.a and b/esp32/lib/libsoc.a differ diff --git a/esp32/lib/libspi_flash.a b/esp32/lib/libspi_flash.a index 276b95b5ac..2257f24746 100644 Binary files a/esp32/lib/libspi_flash.a and b/esp32/lib/libspi_flash.a differ diff --git a/esp32/lib/libtcpip_adapter.a b/esp32/lib/libtcpip_adapter.a index a90caa38f1..bada9c87da 100644 Binary files a/esp32/lib/libtcpip_adapter.a and b/esp32/lib/libtcpip_adapter.a differ diff --git a/esp32/lib/libvfs.a b/esp32/lib/libvfs.a index 7a5bdde185..85f5ae7b97 100644 Binary files a/esp32/lib/libvfs.a and b/esp32/lib/libvfs.a differ diff --git a/esp32/lib/libwpa_supplicant.a b/esp32/lib/libwpa_supplicant.a index d9cde52574..5831a3e3f5 100644 Binary files a/esp32/lib/libwpa_supplicant.a and b/esp32/lib/libwpa_supplicant.a differ diff --git a/esp32/lib/libxtensa-debug-module.a b/esp32/lib/libxtensa-debug-module.a index 6708183cc0..a8767ed69c 100644 Binary files a/esp32/lib/libxtensa-debug-module.a and b/esp32/lib/libxtensa-debug-module.a differ diff --git a/esp32/lora/timer-board.c b/esp32/lora/timer-board.c index 61620ca2c3..04f63f47a9 100644 --- a/esp32/lora/timer-board.c +++ b/esp32/lora/timer-board.c @@ -56,17 +56,11 @@ static TimerTime_t TimerTickCounterContext = 0; * Value trigging the IRQ */ DRAM_ATTR volatile TimerTime_t TimeoutCntValue = 0; -extern TaskHandle_t xLoRaTimerTaskHndl; static IRAM_ATTR void TimerCallback (void) { - BaseType_t xHigherPriorityTaskWoken = pdFALSE; - TimerTickCounter++; if (TimeoutCntValue > 0 && TimerTickCounter == TimeoutCntValue) { TimerIrqHandler(); - // Notify the thread so it will wake up when the ISR is complete - vTaskNotifyGiveFromISR(xLoRaTimerTaskHndl, &xHigherPriorityTaskWoken); - portYIELD_FROM_ISR(); } } diff --git a/esp32/main.c b/esp32/main.c index f337a05578..ebdf380c7e 100644 --- a/esp32/main.c +++ b/esp32/main.c @@ -58,7 +58,7 @@ TaskHandle_t svTaskHandle; TaskHandle_t SmartConfTaskHandle; #if defined(LOPY) || defined (LOPY4) || defined (FIPY) TaskHandle_t xLoRaTaskHndl; -TaskHandle_t xLoRaTimerTaskHndl; +DRAM_ATTR TaskHandle_t xLoRaTimerTaskHndl; #endif #if defined(SIPY) || defined (LOPY4) || defined (FIPY) TaskHandle_t xSigfoxTaskHndl; diff --git a/esp32/mods/machpin.c b/esp32/mods/machpin.c index 51c087c22b..2f885a0d7f 100644 --- a/esp32/mods/machpin.c +++ b/esp32/mods/machpin.c @@ -118,6 +118,7 @@ void pin_init0(void) { pin_obj_t *self = (pin_obj_t *)named_map->table[i].value; if (self != &PIN_MODULE_P1) { // temporal while we remove all the IDF logs #ifdef DEBUG + // Pins needed for JTAG if (self == &PIN_MODULE_P4 || self == &PIN_MODULE_P9 || self == &PIN_MODULE_P10 || self == &PIN_MODULE_P23) { continue; } diff --git a/esp32/mods/modbt.c b/esp32/mods/modbt.c index 6c3e389b64..462b2154c7 100644 --- a/esp32/mods/modbt.c +++ b/esp32/mods/modbt.c @@ -220,6 +220,14 @@ typedef union { uint8_t value[4]; } bt_hash_obj_t; +typedef struct { + bt_gatts_char_obj_t *chr; + uint32_t event; + uint32_t data_length; + uint8_t* data; +} char_cbk_arg_t; + + /****************************************************************************** DECLARE PRIVATE DATA ******************************************************************************/ @@ -659,7 +667,7 @@ static void gap_events_handler (esp_gap_ble_cb_event_t event, esp_ble_gap_cb_par xQueueSend(xScanQueue, (void *)&bt_event_result, (TickType_t)0); bt_obj.events |= MOD_BT_GATTC_ADV_EVT; if (bt_obj.trigger & MOD_BT_GATTC_ADV_EVT) { - mp_irq_queue_interrupt(bluetooth_callback_handler, (void *)&bt_obj); + mp_irq_queue_interrupt_non_ISR(bluetooth_callback_handler, (void *)&bt_obj); } break; case ESP_GAP_SEARCH_DISC_RES_EVT: @@ -765,7 +773,7 @@ static void gattc_events_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc char_obj->events |= MOD_BT_GATTC_INDICATE_EVT; } if ((char_obj->trigger & MOD_BT_GATTC_NOTIFY_EVT) || (char_obj->trigger & MOD_BT_GATTC_INDICATE_EVT)) { - mp_irq_queue_interrupt(gattc_char_callback_handler, char_obj); + mp_irq_queue_interrupt_non_ISR(gattc_char_callback_handler, char_obj); } } break; @@ -805,10 +813,21 @@ STATIC void gattc_char_callback_handler(void *arg) { // this function will be called by the interrupt thread STATIC void gatts_char_callback_handler(void *arg) { - bt_gatts_char_obj_t *chr = arg; + + bt_gatts_char_obj_t *chr = ((char_cbk_arg_t*)arg)->chr; if (chr->handler && chr->handler != mp_const_none) { - mp_obj_t r_value = mp_call_function_1(chr->handler, chr->handler_arg); + + mp_obj_t tuple[2]; + tuple[0] = mp_obj_new_int(((char_cbk_arg_t*)arg)->event); + tuple[1] = mp_const_none; + if(((char_cbk_arg_t*)arg)->data_length > 0) { + tuple[1] = mp_obj_new_bytes(((char_cbk_arg_t*)arg)->data, ((char_cbk_arg_t*)arg)->data_length); + heap_caps_free(((char_cbk_arg_t*)arg)->data); + heap_caps_free((char_cbk_arg_t*)arg); + } + + mp_obj_t r_value = mp_call_function_2(chr->handler, chr->handler_arg, mp_obj_new_tuple(2, tuple)); if (chr->read_request) { uint32_t u_value; @@ -867,7 +886,15 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ if (char_obj->trigger & MOD_BT_GATTS_READ_EVT) { char_obj->read_request = true; char_obj->trans_id = p->read.trans_id; - mp_irq_queue_interrupt(gatts_char_callback_handler, char_obj); + + char_cbk_arg_t *cbk_arg = heap_caps_malloc(sizeof(char_cbk_arg_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); + + cbk_arg->chr = char_obj; + cbk_arg->event = MOD_BT_GATTS_READ_EVT; + cbk_arg->data_length = 0; + cbk_arg->data = NULL; + + mp_irq_queue_interrupt_non_ISR(gatts_char_callback_handler, cbk_arg); break; } } @@ -894,7 +921,16 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ bt_gatts_char_obj_t *char_obj = (bt_gatts_char_obj_t *)attr_obj; char_obj->events |= MOD_BT_GATTS_WRITE_EVT; if (char_obj->trigger & MOD_BT_GATTS_WRITE_EVT) { - mp_irq_queue_interrupt(gatts_char_callback_handler, char_obj); + + char_cbk_arg_t *cbk_arg = heap_caps_malloc(sizeof(char_cbk_arg_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); + + cbk_arg->chr = char_obj; + cbk_arg->event = MOD_BT_GATTS_WRITE_EVT; + cbk_arg->data_length = write_len; + cbk_arg->data = heap_caps_malloc(cbk_arg->data_length, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); + memcpy(cbk_arg->data, p->write.value, cbk_arg->data_length); + + mp_irq_queue_interrupt_non_ISR(gatts_char_callback_handler, cbk_arg); } } else { // descriptor if (attr_obj->uuid.len == ESP_UUID_LEN_16 && attr_obj->uuid.uuid.uuid16 == GATT_UUID_CHAR_CLIENT_CONFIG) { @@ -903,7 +939,15 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ char_obj->config = value; char_obj->events |= MOD_BT_GATTS_SUBSCRIBE_EVT; if (char_obj->trigger & MOD_BT_GATTS_SUBSCRIBE_EVT) { - mp_irq_queue_interrupt(gatts_char_callback_handler, char_obj); + + char_cbk_arg_t *cbk_arg = heap_caps_malloc(sizeof(char_cbk_arg_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); + + cbk_arg->chr = char_obj; + cbk_arg->event = MOD_BT_GATTS_SUBSCRIBE_EVT; + cbk_arg->data_length = 0; + cbk_arg->data = NULL; + + mp_irq_queue_interrupt_non_ISR(gatts_char_callback_handler, cbk_arg); } if (value == 0x0001) { // notifications enabled @@ -961,7 +1005,7 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ bt_obj.gatts_conn_id = p->connect.conn_id; bt_obj.events |= MOD_BT_GATTS_CONN_EVT; if (bt_obj.trigger & MOD_BT_GATTS_CONN_EVT) { - mp_irq_queue_interrupt(bluetooth_callback_handler, (void *)&bt_obj); + mp_irq_queue_interrupt_non_ISR(bluetooth_callback_handler, (void *)&bt_obj); } if (bt_obj.secure){ esp_ble_set_encryption(p->connect.remote_bda, ESP_BLE_SEC_ENCRYPT_MITM); @@ -981,7 +1025,7 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ bt_obj.events |= MOD_BT_GATTS_DISCONN_EVT; xEventGroupSetBits(bt_event_group, MOD_BT_GATTS_DISCONN_EVT); if (bt_obj.trigger & MOD_BT_GATTS_DISCONN_EVT) { - mp_irq_queue_interrupt(bluetooth_callback_handler, (void *)&bt_obj); + mp_irq_queue_interrupt_non_ISR(bluetooth_callback_handler, (void *)&bt_obj); } break; case ESP_GATTS_CLOSE_EVT: @@ -1376,6 +1420,8 @@ static mp_obj_t bt_connect_helper(mp_obj_t addr, TickType_t timeout){ MP_THREAD_GIL_EXIT(); if (xQueueReceive(xScanQueue, &bt_event, timeout) == pdTRUE) { + MP_THREAD_GIL_ENTER(); + if (bt_event.connection.conn_id < 0) { nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "connection refused")); } @@ -1385,7 +1431,11 @@ static mp_obj_t bt_connect_helper(mp_obj_t addr, TickType_t timeout){ conn->base.type = (mp_obj_t)&mod_bt_connection_type; conn->conn_id = bt_event.connection.conn_id; conn->gatt_if = bt_event.connection.gatt_if; + + MP_THREAD_GIL_EXIT(); uxBits = xEventGroupWaitBits(bt_event_group, MOD_BT_GATTC_MTU_EVT, true, true, 1000/portTICK_PERIOD_MS); + MP_THREAD_GIL_ENTER(); + if(uxBits & MOD_BT_GATTC_MTU_EVT) { conn->mtu = bt_conn_mtu; @@ -1396,10 +1446,11 @@ static mp_obj_t bt_connect_helper(mp_obj_t addr, TickType_t timeout){ } else { + MP_THREAD_GIL_ENTER(); + (void)esp_ble_gap_disconnect(bufinfo.buf); nlr_raise(mp_obj_new_exception_msg(&mp_type_TimeoutError, "timed out")); } - MP_THREAD_GIL_ENTER(); return mp_const_none; } diff --git a/esp32/mods/modlora.c b/esp32/mods/modlora.c index f28d88f5b4..679c4068c0 100644 --- a/esp32/mods/modlora.c +++ b/esp32/mods/modlora.c @@ -262,7 +262,6 @@ static const char *modlora_nvs_data_key[E_LORA_NVS_NUM_KEYS] = { "JOINED", "UPLN "MACPARAMS", "CHANNELS", "SRVACK", "MACNXTTX", "MACBUFIDX", "MACRPTIDX", "MACBUF", "MACRPTBUF", "REGION", "CHANMASK", "CHANMASKREM" }; -DRAM_ATTR static modlora_timerCallback modlora_timer_cb; /****************************************************************************** DECLARE PUBLIC DATA ******************************************************************************/ @@ -394,10 +393,16 @@ bool modlora_is_module_sleep(void) IRAM_ATTR void modlora_set_timer_callback(modlora_timerCallback cb) { - modlora_timer_cb = cb; if(cb != NULL) { - xQueueSendFromISR(xCbQueue, &cb, NULL); + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + + xQueueSendFromISR(xCbQueue, &cb, &xHigherPriorityTaskWoken); + + if( xHigherPriorityTaskWoken) + { + portYIELD_FROM_ISR(); + } } } @@ -1185,20 +1190,14 @@ static void TASK_LoRa (void *pvParameters) { static void TASK_LoRa_Timer (void *pvParameters) { - static uint32_t thread_notification; - for(;;) { - thread_notification = ulTaskNotifyTake(pdTRUE, portMAX_DELAY); - if (thread_notification) { - - modlora_timerCallback cb; - while (pdTRUE == xQueueReceive(xCbQueue, &cb, 0)) + modlora_timerCallback cb; + while (pdTRUE == xQueueReceive(xCbQueue, &cb, portMAX_DELAY)) + { + if(cb != NULL) { - if(cb != NULL) - { - cb(); - } + cb(); } } } diff --git a/esp32/mods/modlora.h b/esp32/mods/modlora.h index 2bfae486b1..11a2bb7421 100644 --- a/esp32/mods/modlora.h +++ b/esp32/mods/modlora.h @@ -144,7 +144,7 @@ typedef void ( *modlora_timerCallback )( void ); /****************************************************************************** EXPORTED DATA ******************************************************************************/ -extern TaskHandle_t xLoRaTimerTaskHndl; +extern DRAM_ATTR TaskHandle_t xLoRaTimerTaskHndl; /****************************************************************************** DECLARE FUNCTIONS ******************************************************************************/ diff --git a/esp32/mods/modlte.c b/esp32/mods/modlte.c index d1aa837e11..7a4948dae9 100644 --- a/esp32/mods/modlte.c +++ b/esp32/mods/modlte.c @@ -612,6 +612,84 @@ STATIC mp_obj_t lte_deinit(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(lte_deinit_obj, 1, lte_deinit); +STATIC void lte_add_band(uint32_t band, bool is_hw_new_band_support, bool is_sw_new_band_support, int version) +{ + /* Check band support */ + switch(band) + { + case 5: + case 8: + if (!is_hw_new_band_support) + { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "band %d not supported by this board hardware!", band)); + } + else if(version < SQNS_SW_5_8_BAND_SUPPORT) + { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "band %d not supported by current modem Firmware [%d], please upgrade!", band, version)); + } + break; + case 1: + case 2: + case 14: + case 17: + case 18: + case 19: + case 25: + case 26: + case 66: + if(!is_sw_new_band_support) + { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "band %d not supported by current modem Firmware [%d], please upgrade!", band, version)); + } + if (!is_hw_new_band_support) + { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "band %d not supported by this board hardware!", band)); + } + break; + default: + break; + } + + if (band == 1) { + lte_push_at_command("AT!=\"RRC::addScanBand band=1\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 2) { + lte_push_at_command("AT!=\"RRC::addScanBand band=2\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 3) { + lte_push_at_command("AT!=\"RRC::addScanBand band=3\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 4) { + lte_push_at_command("AT!=\"RRC::addScanBand band=4\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 5) { + lte_push_at_command("AT!=\"RRC::addScanBand band=5\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 8) { + lte_push_at_command("AT!=\"RRC::addScanBand band=8\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 12) { + lte_push_at_command("AT!=\"RRC::addScanBand band=12\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 13) { + lte_push_at_command("AT!=\"RRC::addScanBand band=13\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 14) { + lte_push_at_command("AT!=\"RRC::addScanBand band=14\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 17) { + lte_push_at_command("AT!=\"RRC::addScanBand band=17\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 18) { + lte_push_at_command("AT!=\"RRC::addScanBand band=18\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 19) { + lte_push_at_command("AT!=\"RRC::addScanBand band=19\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 20) { + lte_push_at_command("AT!=\"RRC::addScanBand band=20\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 25) { + lte_push_at_command("AT!=\"RRC::addScanBand band=25\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 26) { + lte_push_at_command("AT!=\"RRC::addScanBand band=26\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 28) { + lte_push_at_command("AT!=\"RRC::addScanBand band=28\"", LTE_RX_TIMEOUT_MIN_MS); + } else if (band == 66) { + lte_push_at_command("AT!=\"RRC::addScanBand band=66\"", LTE_RX_TIMEOUT_MIN_MS); + } else { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "band %d not supported", band)); + } +} + + STATIC mp_obj_t lte_attach(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { lte_check_init(); bool is_hw_new_band_support = false; @@ -623,7 +701,7 @@ STATIC mp_obj_t lte_attach(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t { MP_QSTR_cid, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_obj = mp_const_none} }, { MP_QSTR_type, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_legacyattach, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - + { MP_QSTR_bands, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; // parse args @@ -675,7 +753,8 @@ STATIC mp_obj_t lte_attach(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t // Delay to ensure next addScan command is not discarded vTaskDelay(1000); - if (args[0].u_obj == mp_const_none) { + if (args[0].u_obj == mp_const_none && args[6].u_obj == mp_const_none) { + // neither the argument 'band', nor 'bands' was supplied lte_push_at_command("AT!=\"RRC::addScanBand band=3\"", LTE_RX_TIMEOUT_MIN_MS); lte_push_at_command("AT!=\"RRC::addScanBand band=4\"", LTE_RX_TIMEOUT_MIN_MS); if (is_hw_new_band_support && version > SQNS_SW_5_8_BAND_SUPPORT) { @@ -689,78 +768,21 @@ STATIC mp_obj_t lte_attach(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t } else { - uint32_t band = mp_obj_get_int(args[0].u_obj); - /* Check band support */ - switch(band) - { - case 5: - case 8: - if (!is_hw_new_band_support) - { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "band %d not supported by this board hardware!", band)); - } - else if(version < SQNS_SW_5_8_BAND_SUPPORT) - { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "band %d not supported by current modem Firmware [%d], please upgrade!", band, version)); - } - break; - case 1: - case 2: - case 14: - case 17: - case 18: - case 19: - case 25: - case 26: - case 66: - if(!is_sw_new_band_support) - { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "band %d not supported by current modem Firmware [%d], please upgrade!", band, version)); - } - if (!is_hw_new_band_support) - { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "band %d not supported by this board hardware!", band)); - } - break; - default: - break; + if (args[0].u_obj != mp_const_none) { + // argument 'band' + lte_add_band(mp_obj_get_int(args[0].u_obj), is_hw_new_band_support, is_sw_new_band_support, version); } - if (band == 1) { - lte_push_at_command("AT!=\"RRC::addScanBand band=1\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 2) { - lte_push_at_command("AT!=\"RRC::addScanBand band=2\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 3) { - lte_push_at_command("AT!=\"RRC::addScanBand band=3\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 4) { - lte_push_at_command("AT!=\"RRC::addScanBand band=4\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 5) { - lte_push_at_command("AT!=\"RRC::addScanBand band=5\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 8) { - lte_push_at_command("AT!=\"RRC::addScanBand band=8\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 12) { - lte_push_at_command("AT!=\"RRC::addScanBand band=12\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 13) { - lte_push_at_command("AT!=\"RRC::addScanBand band=13\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 14) { - lte_push_at_command("AT!=\"RRC::addScanBand band=14\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 17) { - lte_push_at_command("AT!=\"RRC::addScanBand band=17\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 18) { - lte_push_at_command("AT!=\"RRC::addScanBand band=18\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 19) { - lte_push_at_command("AT!=\"RRC::addScanBand band=19\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 20) { - lte_push_at_command("AT!=\"RRC::addScanBand band=20\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 25) { - lte_push_at_command("AT!=\"RRC::addScanBand band=25\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 26) { - lte_push_at_command("AT!=\"RRC::addScanBand band=26\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 28) { - lte_push_at_command("AT!=\"RRC::addScanBand band=28\"", LTE_RX_TIMEOUT_MIN_MS); - } else if (band == 66) { - lte_push_at_command("AT!=\"RRC::addScanBand band=66\"", LTE_RX_TIMEOUT_MIN_MS); - } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "band %d not supported", band)); + + if (args[6].u_obj != mp_const_none){ + // argument 'bands' + mp_obj_t *bands; + size_t n_bands=0; + mp_obj_get_array(args[6].u_obj, &n_bands, &bands); + + for (size_t b = 0 ; b < n_bands ; ++b ) + { + lte_add_band(mp_obj_get_int(bands[b]), is_hw_new_band_support, is_sw_new_band_support, version); + } } } } else { @@ -1090,13 +1112,11 @@ STATIC mp_obj_t lte_send_at_cmd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m vstr_t vstr; vstr_init(&vstr, 0); vstr_add_str(&vstr, modlte_rsp.data); - MP_THREAD_GIL_EXIT(); while(modlte_rsp.data_remaining) { lte_push_at_command_ext("Pycom_Dummy", LTE_RX_TIMEOUT_MAX_MS, NULL, strlen("Pycom_Dummy") ); vstr_add_str(&vstr, modlte_rsp.data); } - MP_THREAD_GIL_ENTER(); return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(lte_send_at_cmd_obj, 1, lte_send_at_cmd); diff --git a/esp32/mods/modmdns.c b/esp32/mods/modmdns.c new file mode 100644 index 0000000000..de9ae5324e --- /dev/null +++ b/esp32/mods/modmdns.c @@ -0,0 +1,387 @@ +/* + * Copyright (c) 2019, Pycom Limited. + * + * This software is licensed under the GNU GPL version 3 or any + * later version, with permitted additional terms. For more information + * see the Pycom Licence v1.0 document supplied with this file, or + * available at https://www.pycom.io/opensource/licensing + */ + + +#include "py/mpconfig.h" +#include "py/obj.h" +#include "py/runtime.h" +#include "py/gc.h" +#include + +#include "mdns.h" +#include "netutils.h" + +#include "modmdns.h" +#include "modnetwork.h" + + +/****************************************************************************** + DEFINE CONSTANTS + ******************************************************************************/ +#define MOD_MDNS_PROTO_TCP (0) +#define MOD_MDNS_PROTO_UDP (1) + +/****************************************************************************** + DEFINE PRIVATE TYPES + ******************************************************************************/ +typedef struct mod_mdns_query_obj_s { + mp_obj_base_t base; + mp_obj_t instance_name; /* instance name */ + mp_obj_t hostname; /* hostname */ + mp_obj_t port; /* service port */ + mp_obj_t txt; /* txt record */ + mp_obj_t addr; /* linked list of IP addresses found */ +}mod_mdns_query_obj_t; +/****************************************************************************** + DECLARE PRIVATE FUNCTIONS + ******************************************************************************/ + +/****************************************************************************** + DEFINE PRIVATE VARIABLES + ******************************************************************************/ +STATIC bool initialized = false; +STATIC const mp_obj_type_t mod_mdns_query_type; + +/****************************************************************************** + DEFINE PRIVATE FUNCTIONS + ******************************************************************************/ + +/****************************************************************************** + DEFINE MDNS CLASS FUNCTIONS + ******************************************************************************/ + +// Initialize the module and start advertisement +STATIC mp_obj_t mod_mdns_init() { + + // The MDNS module should be initialized only once + if(initialized == false) { + + //initialize mDNS service + esp_err_t ret = mdns_init(); + if (ret != ESP_OK) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_RuntimeError, "MDNS module could not be initialized, error code: %d", ret)); + // Just to fulfill the compiler's needs + return mp_const_none; + } + + initialized = true; + } + else { + nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "MDNS module already initialized!")); + } + + return mp_const_none; +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_mdns_init_obj, mod_mdns_init); + +// Deinitialize the module and stop advertisement +STATIC mp_obj_t mod_mdns_deinit() { + + if(initialized == true) { + + mdns_service_remove_all(); + mdns_free(); + initialized = false; + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_mdns_deinit_obj, mod_mdns_deinit); + + +// Set the host name and instance name of the device to advertise +STATIC mp_obj_t mod_mdns_set_name(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + + STATIC const mp_arg_t mod_mdns_set_name_args[] = { + { MP_QSTR_hostname, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL}}, + { MP_QSTR_instance_name, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL}} + }; + + if(initialized == true) { + + mp_arg_val_t args[MP_ARRAY_SIZE(mod_mdns_set_name_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(args), mod_mdns_set_name_args, args); + + //set host name if specified + if(args[0].u_obj != MP_OBJ_NULL) { + const char* hostname = mp_obj_str_get_str(args[0].u_obj); + mdns_hostname_set(hostname); + } + + //set instance name if specified + if(args[1].u_obj != MP_OBJ_NULL) { + const char* instance_name = mp_obj_str_get_str(args[1].u_obj); + mdns_instance_name_set(instance_name); + } + } + else { + nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "MDNS module is not initialized!")); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_mdns_set_name_obj, 0, mod_mdns_set_name); + +// Add a new service to advertise +STATIC mp_obj_t mod_mdns_add_service(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + + STATIC const mp_arg_t mod_mdns_add_service_args[] = { + { MP_QSTR_service_type, MP_ARG_OBJ | MP_ARG_REQUIRED, }, + { MP_QSTR_proto, MP_ARG_INT | MP_ARG_REQUIRED, }, + { MP_QSTR_port, MP_ARG_INT | MP_ARG_REQUIRED, }, + { MP_QSTR_txt, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL}}, + }; + + if(initialized == true) { + + mp_arg_val_t args[MP_ARRAY_SIZE(mod_mdns_add_service_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(args), mod_mdns_add_service_args, args); + + // Get service type + const char* service_type = mp_obj_str_get_str(args[0].u_obj); + if(service_type == NULL) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "service_type must be a valid string")); + } + + // Get protocol + mp_int_t proto_num = args[1].u_int; + if(proto_num != MOD_MDNS_PROTO_TCP && proto_num != MOD_MDNS_PROTO_UDP) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "proto must be 0 (TCP) or 1 (UDP)")); + } + const char* proto = proto_num == MOD_MDNS_PROTO_TCP ? "_tcp" : "_udp"; + + // Get port number + mp_int_t port = args[2].u_int; + + // Get txt + mdns_txt_item_t* service_txt = NULL; + size_t length_total = 0; + + if(args[3].u_obj != MP_OBJ_NULL) { + mp_obj_t* items; + mp_obj_tuple_get(args[3].u_obj, &length_total, &items); + + service_txt = m_malloc(length_total * sizeof(mdns_txt_item_t)); + + for(int i = 0; i < length_total; i++) { + size_t length_elem = 0; + mp_obj_t* item; + mp_obj_tuple_get(items[i], &length_elem, &item); + + // There should be only key-value pair here + if(length_elem != 2) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Txt must contain key-value pair strings")); + } + + service_txt[i].key = (char*)mp_obj_str_get_str(item[0]); + service_txt[i].value = (char*)mp_obj_str_get_str(item[1]); + } + } + + esp_err_t ret = mdns_service_add(NULL, service_type, proto, port, service_txt, length_total); + if(ret != ESP_OK) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_RuntimeError, "Service could not be added, error code: %d", ret)); + } + } + else { + nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "MDNS module is not initialized!")); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_mdns_add_service_obj, 3, mod_mdns_add_service); + +// Remove a service +STATIC mp_obj_t mod_mdns_remove_service(mp_obj_t service_type_in, mp_obj_t proto_in) { + + if(initialized == true) { + + const char* service_type = mp_obj_str_get_str(service_type_in); + if(service_type == NULL) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "service_type must be a valid string")); + } + + mp_int_t proto_num = mp_obj_get_int(proto_in); + if(proto_num != MOD_MDNS_PROTO_TCP && proto_num != MOD_MDNS_PROTO_UDP) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "proto must be 0 (TCP) or 1 (UDP)")); + } + const char* proto = proto_num == MOD_MDNS_PROTO_TCP ? "_tcp" : "_udp"; + + esp_err_t ret = mdns_service_remove(service_type, proto); + if(ret != ESP_OK) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_RuntimeError, "Service could not be removed, error code: %d", ret)); + } + } + else { + nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "MDNS module is not initialized!")); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_mdns_remove_service_obj, mod_mdns_remove_service); + + +// Initiate a new query +STATIC mp_obj_t mod_mdns_query(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + + STATIC const mp_arg_t mod_mdns_query_args[] = { + { MP_QSTR_timeout, MP_ARG_INT | MP_ARG_REQUIRED, }, + { MP_QSTR_service_type, MP_ARG_OBJ | MP_ARG_REQUIRED, }, + { MP_QSTR_proto, MP_ARG_INT | MP_ARG_REQUIRED, }, + { MP_QSTR_instance_name, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL}}, + }; + + if(initialized == true) { + + mp_arg_val_t args[MP_ARRAY_SIZE(mod_mdns_query_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(args), mod_mdns_query_args, args); + + // Get timeout value + uint32_t timeout = args[0].u_int; + + // Get service type + const char * service_type = mp_obj_str_get_str(args[1].u_obj); + + // Get proto + const char * proto = NULL; + mp_int_t proto_num = args[2].u_int; + if(proto_num != MOD_MDNS_PROTO_TCP && proto_num != MOD_MDNS_PROTO_UDP) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "proto must be 0 (TCP) or 1 (UDP)")); + } + proto = proto_num == MOD_MDNS_PROTO_TCP ? "_tcp" : "_udp"; + + // Get instance name + const char * instance_name = NULL; + if(args[3].u_obj != NULL) { + instance_name = mp_obj_str_get_str(args[3].u_obj); + } + + + mdns_result_t *results; + esp_err_t ret; + + if(instance_name == NULL) { + ret = mdns_query_ptr(service_type, proto, timeout, 10, &results); + } + else { + ret = mdns_query_srv(instance_name, service_type, proto, timeout, &results); + } + + + if(ret != ESP_OK) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_RuntimeError, "Query failed, error code: %d", ret)); + } + else { + mdns_result_t *result = results; + mp_obj_t queries_list = mp_obj_new_list(0, NULL); + while(result != NULL) { + mod_mdns_query_obj_t *query_obj = m_new(mod_mdns_query_obj_t, 1); + query_obj->base.type = (mp_obj_t)&mod_mdns_query_type; + query_obj->instance_name = mp_obj_new_str(result->instance_name, strlen(result->instance_name)); + query_obj->hostname = mp_obj_new_str(result->hostname, strlen(result->hostname)); + query_obj->port = mp_obj_new_int(result->port); + + query_obj->txt = mp_obj_new_list(0, NULL); + for(int i = 0; i < result->txt_count; i++) { + mp_obj_t tuple[2]; + tuple[0] = mp_obj_new_str(result->txt[i].key, strlen(result->txt[i].key)); + tuple[1] = mp_obj_new_str(result->txt[i].value, strlen(result->txt[i].value)); + mp_obj_list_append(query_obj->txt, mp_obj_new_tuple(2, tuple)); + } + query_obj->addr = netutils_format_ipv4_addr((uint8_t *)&result->addr->addr.u_addr.ip4.addr, NETUTILS_BIG); + + mp_obj_list_append(queries_list, query_obj); + + result = result->next; + } + + mdns_query_results_free(results); + + return queries_list; + + } + } + else { + nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "MDNS module is not initialized!")); + } + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_mdns_query_obj, 3, mod_mdns_query); + +STATIC mp_obj_t mod_mdns_query_instance_name(mp_obj_t self) { + + return ((mod_mdns_query_obj_t *)self)->instance_name; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_mdns_query_instance_name_obj, mod_mdns_query_instance_name); + +STATIC mp_obj_t mod_mdns_query_hostname(mp_obj_t self) { + + return ((mod_mdns_query_obj_t *)self)->hostname; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_mdns_query_hostname_obj, mod_mdns_query_hostname); + +STATIC mp_obj_t mod_mdns_query_port(mp_obj_t self) { + + return ((mod_mdns_query_obj_t *)self)->port; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_mdns_query_port_obj, mod_mdns_query_port); + +STATIC mp_obj_t mod_mdns_query_txt(mp_obj_t self) { + + return ((mod_mdns_query_obj_t *)self)->txt; + +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_mdns_query_txt_obj, mod_mdns_query_txt); + +STATIC mp_obj_t mod_mdns_query_addr(mp_obj_t self) { + + return ((mod_mdns_query_obj_t *)self)->addr; + +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_mdns_query_addr_obj, mod_mdns_query_addr); + +STATIC const mp_map_elem_t mod_mdns_query_locals_dict_table[] = { + // instance methods + { MP_OBJ_NEW_QSTR(MP_QSTR_instance_name), (mp_obj_t)&mod_mdns_query_instance_name_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_hostname), (mp_obj_t)&mod_mdns_query_hostname_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_port), (mp_obj_t)&mod_mdns_query_port_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_txt), (mp_obj_t)&mod_mdns_query_txt_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_addr), (mp_obj_t)&mod_mdns_query_addr_obj }, +}; +STATIC MP_DEFINE_CONST_DICT(mod_mdns_query_locals_dict, mod_mdns_query_locals_dict_table); + +static const mp_obj_type_t mod_mdns_query_type = { + { &mp_type_type }, + .name = MP_QSTR_MDNS_Query, + .locals_dict = (mp_obj_t)&mod_mdns_query_locals_dict, +}; + + +STATIC const mp_map_elem_t mod_mdns_globals_table[] = { + { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_mdns) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_init), (mp_obj_t)&mod_mdns_init_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_deinit), (mp_obj_t)&mod_mdns_deinit_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_set_name), (mp_obj_t)&mod_mdns_set_name_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_add_service), (mp_obj_t)&mod_mdns_add_service_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_remove_service), (mp_obj_t)&mod_mdns_remove_service_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_query), (mp_obj_t)&mod_mdns_query_obj }, + + // class constants + { MP_OBJ_NEW_QSTR(MP_QSTR_PROTO_TCP), MP_OBJ_NEW_SMALL_INT(MOD_MDNS_PROTO_TCP) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_PROTO_UDP), MP_OBJ_NEW_SMALL_INT(MOD_MDNS_PROTO_UDP) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mod_mdns_globals, mod_mdns_globals_table); + +const mp_obj_module_t mod_mdns = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mod_mdns_globals, +}; diff --git a/esp32/mods/modmdns.h b/esp32/mods/modmdns.h new file mode 100644 index 0000000000..1c4b7ec780 --- /dev/null +++ b/esp32/mods/modmdns.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2019, Pycom Limited. + * + * This software is licensed under the GNU GPL version 3 or any + * later version, with permitted additional terms. For more information + * see the Pycom Licence v1.0 document supplied with this file, or + * available at https://www.pycom.io/opensource/licensing + */ + +#ifndef MODMDNS_H_ +#define MODMDNS_H_ + + +extern const mp_obj_module_t mod_mdns; + +#endif // MODMDNS_H_ diff --git a/esp32/mods/modnetwork.c b/esp32/mods/modnetwork.c index 7de4a93f5c..c55d6ed5ee 100644 --- a/esp32/mods/modnetwork.c +++ b/esp32/mods/modnetwork.c @@ -48,6 +48,7 @@ #include "serverstask.h" #include "modusocket.h" #include "modcoap.h" +#include "modmdns.h" #include "lwip/sockets.h" @@ -241,6 +242,7 @@ STATIC const mp_map_elem_t mp_module_network_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_Bluetooth), (mp_obj_t)&mod_network_nic_type_bt }, { MP_OBJ_NEW_QSTR(MP_QSTR_Server), (mp_obj_t)&network_server_type }, { MP_OBJ_NEW_QSTR(MP_QSTR_Coap), (mp_obj_t)&mod_coap }, + { MP_OBJ_NEW_QSTR(MP_QSTR_MDNS), (mp_obj_t)&mod_mdns }, }; STATIC MP_DEFINE_CONST_DICT(mp_module_network_globals, mp_module_network_globals_table); diff --git a/esp32/mods/modpycom.c b/esp32/mods/modpycom.c index 7b1f976659..5d754ddcf7 100644 --- a/esp32/mods/modpycom.c +++ b/esp32/mods/modpycom.c @@ -571,6 +571,17 @@ STATIC mp_obj_t mod_pycom_lte_modem_on_boot (mp_uint_t n_args, const mp_obj_t *a } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_pycom_lte_modem_on_boot_obj, 0, 1, mod_pycom_lte_modem_on_boot); +STATIC mp_obj_t mod_pycom_pybytes_on_boot (mp_uint_t n_args, const mp_obj_t *args) { + if (n_args) { + config_set_pybytes_autostart (mp_obj_is_true(args[0])); + } else { + return mp_obj_new_bool(config_get_pybytes_autostart()); + } + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_pycom_pybytes_on_boot_obj, 0, 1, mod_pycom_pybytes_on_boot); + + STATIC mp_obj_t mod_pycom_pybytes_lte_config (size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_carrier, ARG_apn, ARG_cid, ARG_band, ARG_type, ARG_reset }; STATIC const mp_arg_t allowed_args[] = { @@ -1026,6 +1037,8 @@ STATIC const mp_map_elem_t pycom_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_pybytes_force_update), (mp_obj_t)&mod_pycom_pybytes_force_update_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_smart_config_on_boot), (mp_obj_t)&mod_pycom_smartConfig_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_pybytes_lte_config), (mp_obj_t)&mod_pycom_pybytes_lte_config_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_pybytes_on_boot), (mp_obj_t)&mod_pycom_pybytes_on_boot_obj }, + #endif //(VARIANT == PYBYTES) { MP_OBJ_NEW_QSTR(MP_QSTR_bootmgr), (mp_obj_t)&mod_pycom_bootmgr_obj }, diff --git a/esp32/mods/modussl.c b/esp32/mods/modussl.c index fa2c2d62d8..035185aab5 100644 --- a/esp32/mods/modussl.c +++ b/esp32/mods/modussl.c @@ -27,22 +27,16 @@ #include "modusocket.h" #include "modussl.h" #include "mptask.h" +#include "pycom_general_util.h" -#include "ff.h" -#include "lfs.h" -#include "extmod/vfs.h" - -#include "mptask.h" /****************************************************************************** DEFINE CONSTANTS ******************************************************************************/ -#define FILE_READ_SIZE 256 #define DEFAULT_SSL_READ_TIMEOUT 10 //sec /****************************************************************************** DECLARE PRIVATE FUNCTIONS ******************************************************************************/ -static char *mod_ssl_read_file (const char *file_path, vstr_t *vstr); /****************************************************************************** DECLARE PRIVATE DATA @@ -59,8 +53,8 @@ STATIC const mp_obj_type_t ssl_socket_type = { }; static int32_t mod_ssl_setup_socket (mp_obj_ssl_socket_t *ssl_sock, const char *host_name, - const char *ca_cert_path, const char *client_cert_path, - const char *key_path, uint32_t ssl_verify, uint32_t client_or_server) { + const char *ca_cert, const char *client_cert, const char *client_key, + uint32_t ssl_verify, uint32_t client_or_server) { int32_t ret; mbedtls_ssl_init(&ssl_sock->ssl); @@ -76,42 +70,29 @@ static int32_t mod_ssl_setup_socket (mp_obj_ssl_socket_t *ssl_sock, const char * return ret; } - if (ca_cert_path) { - const char *ca_cert = mod_ssl_read_file(ca_cert_path, &ssl_sock->vstr_ca); - if (ca_cert) { - // printf("Loading the CA root certificate...\n"); - ret = mbedtls_x509_crt_parse(&ssl_sock->cacert, (uint8_t *)ca_cert, strlen(ca_cert) + 1); - if (ret < 0) { - // printf("mbedtls_x509_crt_parse returned -0x%x\n\n", -ret); - return ret; - } - } else { - nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "CA file not found")); + if (ca_cert) { + // printf("Loading the CA root certificate...\n"); + ret = mbedtls_x509_crt_parse(&ssl_sock->cacert, (uint8_t *)ca_cert, strlen(ca_cert) + 1); + if (ret < 0) { + // printf("mbedtls_x509_crt_parse returned -0x%x\n\n", -ret); + return ret; } } - if (client_cert_path && key_path) { - const char *client_cert = mod_ssl_read_file(client_cert_path, &ssl_sock->vstr_cert); - if (client_cert) { - // printf("Loading the own certificate...\n"); - ret = mbedtls_x509_crt_parse(&ssl_sock->own_cert, (uint8_t *)client_cert, strlen(client_cert) + 1); - if (ret < 0) { - // printf("mbedtls_x509_crt_parse returned -0x%x\n\n", -ret); - return ret; - } - } else { - nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "certificate file not found")); + if (client_cert) { + // printf("Loading the own certificate...\n"); + ret = mbedtls_x509_crt_parse(&ssl_sock->own_cert, (uint8_t *)client_cert, strlen(client_cert) + 1); + if (ret < 0) { + // printf("mbedtls_x509_crt_parse returned -0x%x\n\n", -ret); + return ret; } + } - const char *client_key = mod_ssl_read_file(key_path, &ssl_sock->vstr_key); - if (client_key) { - ret = mbedtls_pk_parse_key(&ssl_sock->pk_key, (uint8_t *)client_key, strlen(client_key) + 1, (const unsigned char *)"", 0); - if (ret < 0) { - // printf("mbedtls_pk_parse_key returned -0x%x\n\n", -ret); - return ret; - } - } else { - nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "key file not found")); + if (client_key) { + ret = mbedtls_pk_parse_key(&ssl_sock->pk_key, (uint8_t *)client_key, strlen(client_key) + 1, (const unsigned char *)"", 0); + if (ret < 0) { + // printf("mbedtls_pk_parse_key returned -0x%x\n\n", -ret); + return ret; } } @@ -126,7 +107,7 @@ static int32_t mod_ssl_setup_socket (mp_obj_ssl_socket_t *ssl_sock, const char * mbedtls_ssl_conf_authmode(&ssl_sock->conf, ssl_verify); mbedtls_ssl_conf_rng(&ssl_sock->conf, mbedtls_ctr_drbg_random, &ssl_sock->ctr_drbg); mbedtls_ssl_conf_ca_chain(&ssl_sock->conf, &ssl_sock->cacert, NULL); - if (client_cert_path && key_path) { + if (client_cert && client_key) { if ((ret = mbedtls_ssl_conf_own_cert(&ssl_sock->conf, &ssl_sock->own_cert, &ssl_sock->pk_key)) != 0) { @@ -189,79 +170,6 @@ static int32_t mod_ssl_setup_socket (mp_obj_ssl_socket_t *ssl_sock, const char * return 0; } -static char *mod_ssl_read_file (const char *file_path, vstr_t *vstr) { - vstr_init(vstr, FILE_READ_SIZE); - char *filebuf = vstr->buf; - mp_uint_t actualsize; - mp_uint_t totalsize = 0; - static const TCHAR *path_relative; - - if(isLittleFs(file_path)) - { - vfs_lfs_struct_t* littlefs = lookup_path_littlefs(file_path, &path_relative); - if (littlefs == NULL) { - return NULL; - } - - lfs_file_t fp; - - xSemaphoreTake(littlefs->mutex, portMAX_DELAY); - - int res = lfs_file_open(&littlefs->lfs, &fp, path_relative, LFS_O_RDONLY); - if(res < LFS_ERR_OK) - { - return NULL; - } - - while (true) { - actualsize = lfs_file_read(&littlefs->lfs, &fp, filebuf, FILE_READ_SIZE); - if (actualsize < LFS_ERR_OK) { - return NULL; - } - totalsize += actualsize; - if (actualsize < FILE_READ_SIZE) { - break; - } else { - filebuf = vstr_extend(vstr, FILE_READ_SIZE); - } - } - lfs_file_close(&littlefs->lfs, &fp); - - xSemaphoreGive(littlefs->mutex); - - } - else - { - FATFS *fs = lookup_path_fatfs(file_path, &path_relative); - if (fs == NULL) { - return NULL; - } - FIL fp; - FRESULT res = f_open(fs, &fp, path_relative, FA_READ); - if (res != FR_OK) { - return NULL; - } - - while (true) { - FRESULT res = f_read(&fp, filebuf, FILE_READ_SIZE, (UINT *)&actualsize); - if (res != FR_OK) { - f_close(&fp); - return NULL; - } - totalsize += actualsize; - if (actualsize < FILE_READ_SIZE) { - break; - } else { - filebuf = vstr_extend(vstr, FILE_READ_SIZE); - } - } - f_close(&fp); - } - - vstr->len = totalsize; - vstr_null_terminated_str(vstr); - return vstr->buf; -} /******************************************************************************/ // Micro Python bindings; SSL class @@ -321,9 +229,31 @@ STATIC mp_obj_t mod_ssl_wrap_socket(mp_uint_t n_args, const mp_obj_t *pos_args, ssl_sock->read_timeout = mp_obj_get_int(args[8].u_obj); } + const char *ca_cert = NULL; + if (cafile_path) { + ca_cert = pycom_util_read_file(cafile_path, &ssl_sock->vstr_ca); + if(ca_cert == NULL) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "CA file not found")); + } + } + + const char *client_cert = NULL; + const char *client_key = NULL; + if (certfile_path && keyfile_path) { + client_cert = pycom_util_read_file(certfile_path, &ssl_sock->vstr_ca); + if(client_cert == NULL) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "certificate file not found")); + } + client_key = pycom_util_read_file(keyfile_path, &ssl_sock->vstr_ca); + if(client_key == NULL) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "key file not found")); + } + } + + MP_THREAD_GIL_EXIT(); - _error = mod_ssl_setup_socket(ssl_sock, host_name, cafile_path, certfile_path, keyfile_path, + _error = mod_ssl_setup_socket(ssl_sock, host_name, ca_cert, client_cert, client_key, verify_type, server_side ? MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT); MP_THREAD_GIL_ENTER(); diff --git a/esp32/mods/modwlan.c b/esp32/mods/modwlan.c index af8a1554c9..7a4b396596 100644 --- a/esp32/mods/modwlan.c +++ b/esp32/mods/modwlan.c @@ -29,9 +29,6 @@ #include "esp_wifi.h" #include "esp_wifi_types.h" #include "esp_event_loop.h" -#include "ff.h" -#include "lfs.h" -#include "vfs_littlefs.h" #include "esp_wpa2.h" #include "esp_smartconfig.h" @@ -58,6 +55,7 @@ #include "mpirq.h" #include "mptask.h" #include "pycom_config.h" +#include "pycom_general_util.h" /****************************************************************************** DEFINE TYPES @@ -67,7 +65,6 @@ DEFINE CONSTANTS ******************************************************************************/ -#define FILE_READ_SIZE 256 #define BSSID_MAX_SIZE 6 #define MAX_WLAN_KEY_SIZE 65 #define MAX_AP_CONNECTED_STA 4 @@ -164,7 +161,6 @@ STATIC void wlan_set_antenna (uint8_t antenna); static esp_err_t wlan_event_handler(void *ctx, system_event_t *event); STATIC void wlan_do_connect (const char* ssid, const char* bssid, const wifi_auth_mode_t auth, const char* key, int32_t timeout, const wlan_wpa2_ent_obj_t * const wpa2_ent, const char *hostname, uint8_t channel); static void wlan_init_wlan_recover_params(void); -static char *wlan_read_file (const char *file_path, vstr_t *vstr); static void wlan_timer_callback( TimerHandle_t xTimer ); static void wlan_validate_country(const char * country); static void wlan_validate_country_policy(uint8_t policy); @@ -286,6 +282,7 @@ void wlan_setup (wlan_internal_setup_t *config) { { case WIFI_MODE_AP: MP_THREAD_GIL_EXIT(); + // wlan_setup_ap must be called only when GIL is not locked wlan_setup_ap (config->ssid_ap, config->auth, config->key_ap, config->channel, config->add_mac, config->hidden); // Start Wifi esp_wifi_start(); @@ -294,15 +291,33 @@ void wlan_setup (wlan_internal_setup_t *config) { break; case WIFI_MODE_APSTA: case WIFI_MODE_STA: + MP_THREAD_GIL_EXIT(); if(config->mode == WIFI_MODE_APSTA) { + // wlan_setup_ap must be called only when GIL is not locked wlan_setup_ap (config->ssid_ap, config->auth, config->key_ap, config->channel, config->add_mac, config->hidden); } - MP_THREAD_GIL_EXIT(); // Start Wifi esp_wifi_start(); wlan_obj.started = true; if (config->ssid_sta != NULL) { + if (config->auth == WIFI_AUTH_WPA2_ENTERPRISE) { + + // Take back the GIL as the pycom_util_read_file() uses MicroPython APIs (allocates memory with GC) + MP_THREAD_GIL_ENTER(); + + if (wlan_wpa2_ent.ca_certs_path != NULL) { + pycom_util_read_file(wlan_wpa2_ent.ca_certs_path, &wlan_obj.vstr_ca); + } + + if (wlan_wpa2_ent.client_key_path != NULL && wlan_wpa2_ent.client_cert_path != NULL) { + pycom_util_read_file(wlan_wpa2_ent.client_key_path, &wlan_obj.vstr_key); + pycom_util_read_file(wlan_wpa2_ent.client_cert_path, &wlan_obj.vstr_cert); + } + + MP_THREAD_GIL_EXIT(); + } + // connect to the requested access point wlan_do_connect (config->ssid_sta, NULL, config->auth, config->key_sta, 30000, &wlan_wpa2_ent, NULL, 0); } @@ -504,6 +519,7 @@ STATIC void wlan_servers_stop (void) { } } +// Must be called only when GIL is not locked STATIC void wlan_setup_ap (const char *ssid, uint32_t auth, const char *key, uint32_t channel, bool add_mac, bool hidden) { uint32_t ssid_len = wlan_set_ssid_internal (ssid, strlen(ssid), add_mac); wlan_set_security_internal(auth, key); @@ -523,7 +539,10 @@ STATIC void wlan_setup_ap (const char *ssid, uint32_t auth, const char *key, uin //get mac of AP esp_wifi_get_mac(WIFI_IF_AP, wlan_obj.mac_ap); + // Need to take back the GIL as mod_network_register_nic() uses MicroPython API and wlan_setup_ap() is called when GIL is not locked + MP_THREAD_GIL_ENTER(); mod_network_register_nic(&wlan_obj); + MP_THREAD_GIL_EXIT(); } STATIC void wlan_validate_mode (uint mode) { @@ -743,10 +762,11 @@ STATIC void wlan_do_connect (const char* ssid, const char* bssid, const wifi_aut goto os_error; } + // The certificate files are already read at this point because this function runs outside of GIL, and the file_read functions uses MicroPython APIs if (auth == WIFI_AUTH_WPA2_ENTERPRISE) { // CA Certificate is not mandatory if (wpa2_ent->ca_certs_path != NULL) { - if (wlan_read_file(wpa2_ent->ca_certs_path, &wlan_obj.vstr_ca)) { + if (wlan_obj.vstr_ca.buf != NULL) { if (ESP_OK != esp_wifi_sta_wpa2_ent_set_ca_cert((unsigned char*)wlan_obj.vstr_ca.buf, (int)wlan_obj.vstr_ca.len)) { goto os_error; } @@ -757,7 +777,7 @@ STATIC void wlan_do_connect (const char* ssid, const char* bssid, const wifi_aut // client certificate is necessary only in EAP-TLS method, this is ensured by wlan_validate_certificates() function if (wpa2_ent->client_key_path != NULL && wpa2_ent->client_cert_path != NULL) { - if (wlan_read_file(wpa2_ent->client_key_path, &wlan_obj.vstr_key) && wlan_read_file(wpa2_ent->client_cert_path, &wlan_obj.vstr_cert)) { + if ((wlan_obj.vstr_cert.buf != NULL) && (wlan_obj.vstr_key.buf != NULL)) { if (ESP_OK != esp_wifi_sta_wpa2_ent_set_cert_key((unsigned char*)wlan_obj.vstr_cert.buf, (int)wlan_obj.vstr_cert.len, (unsigned char*)wlan_obj.vstr_key.buf, (int)wlan_obj.vstr_key.len, NULL, 0)) { goto os_error; @@ -822,78 +842,6 @@ STATIC void wlan_do_connect (const char* ssid, const char* bssid, const wifi_aut nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed)); } -STATIC char *wlan_read_file (const char *file_path, vstr_t *vstr) { - vstr_init(vstr, FILE_READ_SIZE); - char *filebuf = vstr->buf; - mp_uint_t actualsize; - mp_uint_t totalsize = 0; - static const TCHAR *path_relative; - - if(isLittleFs(file_path)) - { - vfs_lfs_struct_t* littlefs = lookup_path_littlefs(file_path, &path_relative); - if (littlefs == NULL) { - return NULL; - } - - xSemaphoreTake(littlefs->mutex, portMAX_DELAY); - - lfs_file_t fp; - int res = lfs_file_open(&littlefs->lfs, &fp, path_relative, LFS_O_RDONLY); - if(res < LFS_ERR_OK) - { - return NULL; - } - - while (true) { - actualsize = lfs_file_read(&littlefs->lfs, &fp, filebuf, FILE_READ_SIZE); - if (actualsize < LFS_ERR_OK) { - return NULL; - } - totalsize += actualsize; - if (actualsize < FILE_READ_SIZE) { - break; - } else { - filebuf = vstr_extend(vstr, FILE_READ_SIZE); - } - } - lfs_file_close(&littlefs->lfs, &fp); - - xSemaphoreGive(littlefs->mutex); - - } - else - { - FATFS *fs = lookup_path_fatfs(file_path, &path_relative); - if (fs == NULL) { - return NULL; - } - FIL fp; - FRESULT res = f_open(fs, &fp, path_relative, FA_READ); - if (res != FR_OK) { - return NULL; - } - - while (true) { - FRESULT res = f_read(&fp, filebuf, FILE_READ_SIZE, (UINT *)&actualsize); - if (res != FR_OK) { - f_close(&fp); - return NULL; - } - totalsize += actualsize; - if (actualsize < FILE_READ_SIZE) { - break; - } else { - filebuf = vstr_extend(vstr, FILE_READ_SIZE); - } - } - f_close(&fp); - } - - vstr->len = totalsize; - vstr_null_terminated_str(vstr); - return vstr->buf; -} static void wlan_init_wlan_recover_params(void) { diff --git a/esp32/mptask.c b/esp32/mptask.c index 61c3a6059c..f941fcbc11 100644 --- a/esp32/mptask.c +++ b/esp32/mptask.c @@ -298,7 +298,12 @@ void TASK_Micropython (void *pvParameters) { if (!safeboot) { // execute the frozen main first - pyexec_frozen_module("_main.py"); + //pyexec_frozen_module("_main.py"); + if (config_get_pybytes_autostart()) { + pyexec_frozen_module("_main_pybytes.py"); + } else { + pyexec_frozen_module("_main.py"); + } // run the main script from the current directory. if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) { diff --git a/esp32/pycom_config.c b/esp32/pycom_config.c index 8aa40dab0a..bd5a14a1c0 100644 --- a/esp32/pycom_config.c +++ b/esp32/pycom_config.c @@ -393,6 +393,18 @@ bool config_set_boot_fs_type (const uint8_t boot_fs_type) { return config_write(); } +bool config_set_pybytes_autostart (bool pybytes_autostart) { + if (pycom_config_block.pybytes_config.auto_start != (uint8_t)pybytes_autostart) { + pycom_config_block.pybytes_config.auto_start = (uint8_t)pybytes_autostart; + return config_write(); + } + return true; +} + +bool config_get_pybytes_autostart (void) { + return (bool)pycom_config_block.pybytes_config.auto_start; +} + static bool config_write (void) { // erase the block first if (ESP_OK == spi_flash_erase_sector(CONFIG_DATA_FLASH_BLOCK)) { diff --git a/esp32/pycom_config.h b/esp32/pycom_config.h index b8f5d8a2e8..5fae07b887 100644 --- a/esp32/pycom_config.h +++ b/esp32/pycom_config.h @@ -62,7 +62,8 @@ typedef struct { uint8_t network_preferences[55]; uint8_t extra_preferences[100]; uint8_t force_update; - uint8_t reserved[12]; + uint8_t auto_start; + uint8_t reserved[11]; } pycom_pybytes_config_t; typedef struct { @@ -82,12 +83,12 @@ typedef struct { } pycom_lte_config_t; typedef struct { - uint8_t carrier[129]; - uint8_t apn[129]; - uint8_t type[17]; - uint8_t cid; - uint8_t band; - uint8_t reset; + uint8_t carrier[129]; + uint8_t apn[129]; + uint8_t type[17]; + uint8_t cid; + uint8_t band; + uint8_t reset; } pycom_pybytes_lte_config_t; typedef struct { @@ -219,4 +220,8 @@ bool config_set_lte_modem_enable_on_boot (bool lte_modem_en_on_boot); bool config_get_lte_modem_enable_on_boot (void); +bool config_set_pybytes_autostart (bool pybytes_autostart); + +bool config_get_pybytes_autostart (void); + #endif /* PYCOM_CONFIG_H_ */ diff --git a/esp32/pycom_version.h b/esp32/pycom_version.h index ffcc8015fb..0e03d38178 100644 --- a/esp32/pycom_version.h +++ b/esp32/pycom_version.h @@ -10,14 +10,14 @@ #ifndef VERSION_H_ #define VERSION_H_ -#define SW_VERSION_NUMBER "1.20.1.r2" +#define SW_VERSION_NUMBER "1.20.2.rc2" #define LORAWAN_VERSION_NUMBER "1.0.2" #define SIGFOX_VERSION_NUMBER "1.0.1" #if (VARIANT == PYBYTES) -#define PYBYTES_VERSION_NUMBER "1.3.0" +#define PYBYTES_VERSION_NUMBER "1.3.1" #endif #endif /* VERSION_H_ */ diff --git a/esp32/sdkconfig.h b/esp32/sdkconfig.h index 3960eaef97..fabbc160b4 100644 --- a/esp32/sdkconfig.h +++ b/esp32/sdkconfig.h @@ -8,9 +8,11 @@ #define CONFIG_ESP32_PHY_MAX_TX_POWER 20 #define CONFIG_TRACEMEM_RESERVE_DRAM 0x0 #define CONFIG_FREERTOS_MAX_TASK_NAME_LEN 16 +#define CONFIG_SECURE_BOOT_SIGNING_KEY "secure_boot_signing_key.pem" #define CONFIG_BLE_SMP_ENABLE 1 #define CONFIG_FATFS_LFN_NONE 1 #define CONFIG_SPIRAM_TYPE_AUTO 1 +#define CONFIG_SMP_SLAVE_CON_PARAMS_UPD_ENABLE 1 #define CONFIG_MB_SERIAL_TASK_PRIO 10 #define CONFIG_TCP_RECVMBOX_SIZE 6 #define CONFIG_FATFS_CODEPAGE_437 1 @@ -23,6 +25,7 @@ #define CONFIG_SPIFFS_USE_MAGIC_LENGTH 1 #define CONFIG_ESPTOOLPY_FLASHSIZE_4MB 1 #define CONFIG_IPC_TASK_STACK_SIZE 1024 +#define CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES 16 #define CONFIG_FATFS_PER_FILE_CACHE 1 #define CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY 1 #define CONFIG_ESPTOOLPY_FLASHFREQ "80m" @@ -55,6 +58,7 @@ #define CONFIG_MBEDTLS_SSL_ALPN 1 #define CONFIG_MBEDTLS_PEM_WRITE_C 1 #define CONFIG_BT_RESERVE_DRAM 0xdb5c +#define CONFIG_APP_COMPILE_TIME_DATE 1 #define CONFIG_SECURE_SIGNED_ON_BOOT 1 #define CONFIG_D2WD_PSRAM_CLK_IO 9 #define CONFIG_FATFS_FS_LOCK 0 @@ -71,18 +75,20 @@ #define CONFIG_LWIP_MAX_SOCKETS 10 #define CONFIG_LWIP_NETIF_LOOPBACK 1 #define CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL 16384 +#define CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT "pthread" #define CONFIG_EMAC_TASK_PRIORITY 20 #define CONFIG_TIMER_TASK_STACK_DEPTH 2560 #define CONFIG_TCP_MSS 1436 #define CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED 1 +#define CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR 1 #define CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF 3 +#define CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4 1 #define CONFIG_TCPIP_TASK_AFFINITY_CPU0 1 #define CONFIG_FATFS_CODEPAGE 437 #define CONFIG_ESP32_DEFAULT_CPU_FREQ_160 1 #define CONFIG_ULP_COPROC_RESERVE_MEM 0 #define CONFIG_SECURE_SIGNED_APPS 1 #define CONFIG_LWIP_MAX_UDP_PCBS 16 -#define CONFIG_SMP_ENABLE 1 #define CONFIG_ESPTOOLPY_BAUD 921600 #define CONFIG_ADC_CAL_LUT_ENABLE 1 #define CONFIG_WIFI_FAST_SCAN 1 @@ -107,11 +113,13 @@ #define CONFIG_TIMER_TASK_STACK_SIZE 2560 #define CONFIG_MBEDTLS_X509_CRL_PARSE_C 1 #define CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC 1 +#define CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER 1 #define CONFIG_HTTPD_PURGE_BUF_LEN 32 #define CONFIG_SCAN_DUPLICATE_BY_DEVICE_ADDR 1 #define CONFIG_MB_SERIAL_TASK_STACK_SIZE 768 #define CONFIG_GATTS_SEND_SERVICE_CHANGE_AUTO 1 #define CONFIG_LWIP_DHCPS_LEASE_UNIT 60 +#define CONFIG_EFUSE_MAX_BLK_LEN 192 #define CONFIG_SPIFFS_USE_MAGIC 1 #define CONFIG_TCPIP_TASK_STACK_SIZE 3072 #define CONFIG_BLUEDROID_PINNED_TO_CORE_0 1 @@ -146,9 +154,11 @@ #define CONFIG_ESP32_WIFI_TX_BA_WIN 6 #define CONFIG_ESP32_WIFI_NVS_ENABLED 1 #define CONFIG_MDNS_MAX_SERVICES 10 +#define CONFIG_IDF_TARGET_ESP32 1 #define CONFIG_EMAC_CHECK_LINK_PERIOD_MS 2000 #define CONFIG_BTDM_LPCLK_SEL_MAIN_XTAL 1 #define CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED 1 +#define CONFIG_LWIP_SNTP_UPDATE_DELAY 3600000 #define CONFIG_LIBSODIUM_USE_MBEDTLS_SHA 1 #define CONFIG_DMA_RX_BUF_NUM 10 #define CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED 1 @@ -213,10 +223,13 @@ #define CONFIG_MBEDTLS_TLS_ENABLED 1 #define CONFIG_LWIP_MAX_RAW_PCBS 16 #define CONFIG_SPIRAM_IGNORE_NOTFOUND 1 +#define CONFIG_BTU_TASK_STACK_SIZE 4096 +#define CONFIG_SMP_ENABLE 1 #define CONFIG_SPIRAM_SIZE -1 #define CONFIG_FAST_SCAN_MINIMUM_SIGNAL -127 #define CONFIG_MBEDTLS_SSL_SESSION_TICKETS 1 #define CONFIG_SPIFFS_MAX_PARTITIONS 3 +#define CONFIG_ESP32_CORE_DUMP_MAX_TASKS_NUM 64 #define CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE_0 1 #define CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK 1 #define CONFIG_MBEDTLS_SSL_RENEGOTIATION 1 @@ -249,34 +262,39 @@ #define CONFIG_PPP_PAP_SUPPORT 1 #define CONFIG_MBEDTLS_TLS_CLIENT 1 #define CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI 1 -#define CONFIG_BTDM_CONTROLLER_BR_EDR_SCO_DATA_PATH_EFF 0 #define CONFIG_BT_ENABLED 1 +#define CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY 1 #define CONFIG_D0WD_PSRAM_CLK_IO 17 #define CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED 1 #define CONFIG_MONITOR_BAUD 115200 +#define CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT -1 #define CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT 30 #define CONFIG_TCPIP_LWIP 1 #define CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES 1 #define CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST 1 #define CONFIG_FREERTOS_CORETIMER_0 1 #define CONFIG_IDF_FIRMWARE_CHIP_ID 0x0000 +#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv" #define CONFIG_MBEDTLS_HAVE_TIME 1 #define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1 #define CONFIG_TCP_QUEUE_OOSEQ 1 -#define CONFIG_ESP32_CORE_DUMP_LOG_LEVEL 1 +#define CONFIG_FATFS_ALLOC_PREFER_EXTRAM 1 #define CONFIG_GATTS_ENABLE 1 #define CONFIG_ADC_CAL_EFUSE_VREF_ENABLE 1 #define CONFIG_MBEDTLS_TLS_SERVER 1 #define CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT 1 +#define CONFIG_APP_EXCLUDE_PROJECT_VER_VAR 1 #define CONFIG_SPIRAM_BOOT_INIT 1 #define CONFIG_ESPTOOLPY_AFTER_NORESET 1 #define CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED 1 #define CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL 16384 #define CONFIG_FREERTOS_ISR_STACKSIZE 2560 #define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1 +#define CONFIG_IDF_TARGET "esp32" #define CONFIG_WL_SECTOR_SIZE_4096 1 #define CONFIG_FREERTOS_NO_AFFINITY 0x7FFFFFFF #define CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED 1 +#define CONFIG_HTTPD_ERR_RESP_NO_DELAY 1 #define CONFIG_SCAN_DUPLICATE_TYPE 0 #define CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED 1 #define CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED 1 @@ -304,6 +322,7 @@ #define CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF 1 #define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0" #define CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS 1 +#define CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF 0 #define CONFIG_OPTIMIZATION_LEVEL_RELEASE 1 #define CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD 20 #define CONFIG_BLUEDROID_PINNED_TO_CORE 0 diff --git a/esp32/sigfox.mk b/esp32/sigfox.mk new file mode 100644 index 0000000000..7cb17d6cb2 --- /dev/null +++ b/esp32/sigfox.mk @@ -0,0 +1,24 @@ +ifeq ($(BOARD), $(filter $(BOARD), SIPY)) +SFX_OBJ += $(addprefix $(BUILD)/, $(APP_SIGFOX_SRC_SIPY_C:.c=.o) $(APP_SIGFOX_TARGET_SRC_C:.c=.o) $(APP_SIGFOX_SPI_SRC_C:.c=.o)) +endif +ifeq ($(BOARD), $(filter $(BOARD), LOPY4 FIPY)) +SFX_OBJ += $(addprefix $(BUILD)/, $(APP_SIGFOX_SRC_FIPY_LOPY4_C:.c=.o) $(APP_SIGFOX_SPI_SRC_C:.c=.o)) +endif + +OBJ += $(SFX_OBJ) + +# the build process generates .d files and expects the same directory structure in $(BUILD) as it is in the sources, so we need to mkdir them +SFX_DEP_DIRS := $(BUILD)/sigfox $(BUILD)/sigfox/src $(BUILD)/sigfox/src/targets $(BUILD)/lora +$(SFX_DEP_DIRS): + $(MKDIR) -p $@ + +all: $(SFX_DEP_DIRS) $(BUILD)/sigfox/sigfox.a + +# $(SFX_OBJ): | CHECK_DEP +# $(SFX_OBJ): | $(GEN_PINS_HDR) +$(SFX_OBJ): | $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/mpversion.h + +$(BUILD)/sigfox/sigfox.a: $(SFX_OBJ) + $(ECHO) "AR $@" + $(Q) rm -f $@ + $(Q) $(AR) cru $@ $^ diff --git a/esp32/sigfox/.gitignore b/esp32/sigfox/.gitignore new file mode 100644 index 0000000000..8eba6c8dd4 --- /dev/null +++ b/esp32/sigfox/.gitignore @@ -0,0 +1 @@ +src/ diff --git a/esp32/sigfox/README b/esp32/sigfox/README new file mode 100644 index 0000000000..6b2cc122ba --- /dev/null +++ b/esp32/sigfox/README @@ -0,0 +1,26 @@ +This directory contains the sigfox support. + +There are three prebuilt libraries for SIPY, LOPY4, and FIPY. + +@Pycom In order to build these libraries execute the following steps using the private pyupython repository: + +git clone -b sigfox git@github.com:pycom/pyupython.git src +cd src +git checkout ba89a617475d0e4f57bb135f395b9ecf48eaa3b0 +cd ../.. +make BOARD=LOPY4 TARGET=sigfox +make BOARD=FIPY TARGET=sigfox +make BOARD=SIPY TARGET=sigfox +./get_sigfox_libs.py + +Now you see the updated .a files with + +git status sigfox + +which can be PR-ed in parallel with any sigfox code changes. + +If you update the sigfox code, be sure to: + +a) PR your sigfox changes to pyupython +b) PR the .a files to Firmware-Development and +c) update the git hash further up in this README file, so it is clear from which commit the libraries were built diff --git a/esp32/sigfox/modsigfox_FIPY.a b/esp32/sigfox/modsigfox_FIPY.a new file mode 100644 index 0000000000..dbe87115c9 Binary files /dev/null and b/esp32/sigfox/modsigfox_FIPY.a differ diff --git a/esp32/sigfox/modsigfox_LOPY4.a b/esp32/sigfox/modsigfox_LOPY4.a new file mode 100644 index 0000000000..5dc016b666 Binary files /dev/null and b/esp32/sigfox/modsigfox_LOPY4.a differ diff --git a/esp32/sigfox/modsigfox_sipy.a b/esp32/sigfox/modsigfox_SIPY.a similarity index 50% rename from esp32/sigfox/modsigfox_sipy.a rename to esp32/sigfox/modsigfox_SIPY.a index fd2eaf3536..cad1fe2702 100644 Binary files a/esp32/sigfox/modsigfox_sipy.a and b/esp32/sigfox/modsigfox_SIPY.a differ diff --git a/esp32/sigfox/modsigfox_fipy.a b/esp32/sigfox/modsigfox_fipy.a deleted file mode 100644 index 6a1f684a9b..0000000000 Binary files a/esp32/sigfox/modsigfox_fipy.a and /dev/null differ diff --git a/esp32/sigfox/modsigfox_lopy4.a b/esp32/sigfox/modsigfox_lopy4.a deleted file mode 100644 index 9f16878e0a..0000000000 Binary files a/esp32/sigfox/modsigfox_lopy4.a and /dev/null differ diff --git a/esp32/util/mpirq.c b/esp32/util/mpirq.c index 841006b66f..6b01cdaed6 100644 --- a/esp32/util/mpirq.c +++ b/esp32/util/mpirq.c @@ -148,7 +148,20 @@ mp_obj_tuple_t *mp_irq_find (mp_obj_t parent) { void IRAM_ATTR mp_irq_queue_interrupt(void (* handler)(void *), void *arg) { mp_callback_obj_t cb = {.handler = handler, .arg = arg}; - xQueueSendFromISR(InterruptsQueue, &cb, NULL); + + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + + xQueueSendFromISR(InterruptsQueue, &cb, &xHigherPriorityTaskWoken); + + if( xHigherPriorityTaskWoken) + { + portYIELD_FROM_ISR(); + } +} + +void mp_irq_queue_interrupt_non_ISR(void (* handler)(void *), void *arg) { + mp_callback_obj_t cb = {.handler = handler, .arg = arg}; + (void)xQueueSend(InterruptsQueue, &cb, 0); } void IRAM_ATTR mp_irq_queue_interrupt_immediate_thread_delete(TaskHandle_t id) { diff --git a/esp32/util/mpirq.h b/esp32/util/mpirq.h index a0930c3e03..68f0db7036 100644 --- a/esp32/util/mpirq.h +++ b/esp32/util/mpirq.h @@ -49,6 +49,7 @@ void mp_irq_add (mp_obj_t parent, mp_obj_t handler); void mp_irq_remove (mp_obj_t parent); mp_obj_tuple_t *mp_irq_find (mp_obj_t parent); void mp_irq_queue_interrupt(void (* handler)(void *), void *arg); +void mp_irq_queue_interrupt_non_ISR(void (* handler)(void *), void *arg); void mp_irq_queue_interrupt_immediate_thread_delete(TaskHandle_t id); void mp_irq_kill(void); #endif /* MPIRQ_H_ */ diff --git a/esp32/util/pycom_general_util.c b/esp32/util/pycom_general_util.c new file mode 100644 index 0000000000..ca79f8c398 --- /dev/null +++ b/esp32/util/pycom_general_util.c @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2019, Pycom Limited. + * + * This software is licensed under the GNU GPL version 3 or any + * later version, with permitted additional terms. For more information + * see the Pycom Licence v1.0 document supplied with this file, or + * available at https://www.pycom.io/opensource/licensing + */ + +#include + +#include "freertos/FreeRTOS.h" + +#include "py/mpconfig.h" +#include "py/runtime.h" +#include "mptask.h" +#include "pycom_general_util.h" + + +/****************************************************************************** + DEFINE CONSTANTS + ******************************************************************************/ +#define FILE_READ_SIZE 256 + +/****************************************************************************** + DEFINE PUBLIC FUNCTIONS + ******************************************************************************/ +char *pycom_util_read_file (const char *file_path, vstr_t *vstr) { + vstr_init(vstr, FILE_READ_SIZE); + char *filebuf = vstr->buf; + mp_uint_t actualsize; + mp_uint_t totalsize = 0; + static const TCHAR *path_relative; + // THis is needed to be able to clean the VSTR if any error occurred + bool error = false; + + if(isLittleFs(file_path)) { + + vfs_lfs_struct_t* littlefs = lookup_path_littlefs(file_path, &path_relative); + if (littlefs == NULL) { + error = true; + } + else { + + lfs_file_t fp; + + xSemaphoreTake(littlefs->mutex, portMAX_DELAY); + + int res = lfs_file_open(&littlefs->lfs, &fp, path_relative, LFS_O_RDONLY); + if(res < LFS_ERR_OK) { + error = true; + } + else { + while (error == false) { + actualsize = lfs_file_read(&littlefs->lfs, &fp, filebuf, FILE_READ_SIZE); + if (actualsize < LFS_ERR_OK) { + error = true; + } + else { + totalsize += actualsize; + if (actualsize < FILE_READ_SIZE) { + break; + } else { + filebuf = vstr_extend(vstr, FILE_READ_SIZE); + } + } + } + + lfs_file_close(&littlefs->lfs, &fp); + } + + xSemaphoreGive(littlefs->mutex); + } + } + else + { + FATFS *fs = lookup_path_fatfs(file_path, &path_relative); + if (fs == NULL) { + error = true; + } + else { + FIL fp; + FRESULT res = f_open(fs, &fp, path_relative, FA_READ); + if (res != FR_OK) { + error = true; + } + else { + while (error == false) { + FRESULT res = f_read(&fp, filebuf, FILE_READ_SIZE, (UINT *)&actualsize); + if (res != FR_OK) { + f_close(&fp); + error = true; + } + else { + totalsize += actualsize; + if (actualsize < FILE_READ_SIZE) { + break; + } else { + filebuf = vstr_extend(vstr, FILE_READ_SIZE); + } + } + } + f_close(&fp); + } + } + } + + if(error == true) { + vstr_clear(vstr); + return NULL; + } + else { + vstr->len = totalsize; + vstr_null_terminated_str(vstr); + return vstr->buf; + } +} diff --git a/esp32/util/pycom_general_util.h b/esp32/util/pycom_general_util.h new file mode 100644 index 0000000000..ceef2d0c86 --- /dev/null +++ b/esp32/util/pycom_general_util.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2019, Pycom Limited. + * + * This software is licensed under the GNU GPL version 3 or any + * later version, with permitted additional terms. For more information + * see the Pycom Licence v1.0 document supplied with this file, or + * available at https://www.pycom.io/opensource/licensing + */ + +#ifndef ESP32_UTIL_PYCOM_GENERAL_UTIL_H_ +#define ESP32_UTIL_PYCOM_GENERAL_UTIL_H_ + +#include "py/obj.h" + +char *pycom_util_read_file(const char *file_path, vstr_t *vstr); + +#endif /* ESP32_UTIL_PYCOM_GENERAL_UTIL_H_ */ diff --git a/lib/lora/mac/LoRaMac.h b/lib/lora/mac/LoRaMac.h index b53b5b41d1..2a77564b10 100644 --- a/lib/lora/mac/LoRaMac.h +++ b/lib/lora/mac/LoRaMac.h @@ -1715,6 +1715,11 @@ typedef enum eLoRaMacRegion_t * North american band on 915MHz with a maximum of 16 channels */ LORAMAC_REGION_US915_HYBRID, + + /*! + * Invalid region + */ + LORAMAC_REGION_MAX }LoRaMacRegion_t; /*! diff --git a/lib/lora/mac/region/Region.c b/lib/lora/mac/region/Region.c index b393c931cc..8fa0e22c41 100644 --- a/lib/lora/mac/region/Region.c +++ b/lib/lora/mac/region/Region.c @@ -33,35 +33,34 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae // Setup regions #ifdef REGION_AS923 #include "RegionAS923.h" -#define AS923_CASE case LORAMAC_REGION_AS923: -#define AS923_IS_ACTIVE( ) AS923_CASE { return true; } -#define AS923_GET_PHY_PARAM( ) AS923_CASE { return RegionAS923GetPhyParam( getPhy ); } -#define AS923_SET_BAND_TX_DONE( ) AS923_CASE { RegionAS923SetBandTxDone( txDone ); break; } -#define AS923_INIT_DEFAULTS( ) AS923_CASE { RegionAS923InitDefaults( type ); break; } -#define AS923_VERIFY( ) AS923_CASE { return RegionAS923Verify( verify, phyAttribute ); } -#define AS923_APPLY_CF_LIST( ) AS923_CASE { RegionAS923ApplyCFList( applyCFList ); break; } -#define AS923_CHAN_MASK_SET( ) AS923_CASE { return RegionAS923ChanMaskSet( chanMaskSet ); } -#define AS923_ADR_NEXT( ) AS923_CASE { return RegionAS923AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } -#define AS923_COMPUTE_RX_WINDOW_PARAMETERS( ) AS923_CASE { RegionAS923ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define AS923_RX_CONFIG( ) AS923_CASE { return RegionAS923RxConfig( rxConfig, datarate ); } -#define AS923_TX_CONFIG( ) AS923_CASE { return RegionAS923TxConfig( txConfig, txPower, txTimeOnAir ); } -#define AS923_LINK_ADR_REQ( ) AS923_CASE { return RegionAS923LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define AS923_RX_PARAM_SETUP_REQ( ) AS923_CASE { return RegionAS923RxParamSetupReq( rxParamSetupReq ); } -#define AS923_NEW_CHANNEL_REQ( ) AS923_CASE { return RegionAS923NewChannelReq( newChannelReq ); } -#define AS923_TX_PARAM_SETUP_REQ( ) AS923_CASE { return RegionAS923TxParamSetupReq( txParamSetupReq ); } -#define AS923_DL_CHANNEL_REQ( ) AS923_CASE { return RegionAS923DlChannelReq( dlChannelReq ); } -#define AS923_ALTERNATE_DR( ) AS923_CASE { return RegionAS923AlternateDr( alternateDr ); } -#define AS923_CALC_BACKOFF( ) AS923_CASE { RegionAS923CalcBackOff( calcBackOff ); break; } -#define AS923_NEXT_CHANNEL( ) AS923_CASE { return RegionAS923NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define AS923_CHANNEL_ADD( ) AS923_CASE { return RegionAS923ChannelAdd( channelAdd ); } -#define AS923_CHANNEL_REMOVE( ) AS923_CASE { return RegionAS923ChannelsRemove( channelRemove ); } -#define AS923_CHANNEL_MANUAL_ADD( ) AS923_CASE { return RegionAS923ChannelManualAdd( channelAdd ); } -#define AS923_CHANNEL_MANUAL_REMOVE( ) AS923_CASE { return RegionAS923ChannelsRemove( channelRemove ); } -#define AS923_SET_CONTINUOUS_WAVE( ) AS923_CASE { RegionAS923SetContinuousWave( continuousWave ); break; } -#define AS923_APPLY_DR_OFFSET( ) AS923_CASE { return RegionAS923ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define AS923_GET_CHANNELS( ) AS923_CASE { return RegionAS923GetChannels( channels, size ); } -#define AS923_GET_CHANNEL_MASK( ) AS923_CASE { return RegionAS923GetChannelMask( channelmask, size ); } -#define AS923_FORCE_JOIN_DATARATE( ) AS923_CASE { return RegionAS923ForceJoinDataRate( joinDr, alternateDr ); } +#define AS923_IS_ACTIVE( ) else if(region == LORAMAC_REGION_AS923) { return true; } +#define AS923_GET_PHY_PARAM( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923GetPhyParam( getPhy ); } +#define AS923_SET_BAND_TX_DONE( ) else if(region == LORAMAC_REGION_AS923) { RegionAS923SetBandTxDone( txDone );} +#define AS923_INIT_DEFAULTS( ) else if(region == LORAMAC_REGION_AS923) { RegionAS923InitDefaults( type );} +#define AS923_VERIFY( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923Verify( verify, phyAttribute ); } +#define AS923_APPLY_CF_LIST( ) else if(region == LORAMAC_REGION_AS923) { RegionAS923ApplyCFList( applyCFList );} +#define AS923_CHAN_MASK_SET( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923ChanMaskSet( chanMaskSet ); } +#define AS923_ADR_NEXT( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } +#define AS923_COMPUTE_RX_WINDOW_PARAMETERS( ) else if(region == LORAMAC_REGION_AS923) { RegionAS923ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams );} +#define AS923_RX_CONFIG( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923RxConfig( rxConfig, datarate ); } +#define AS923_TX_CONFIG( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923TxConfig( txConfig, txPower, txTimeOnAir ); } +#define AS923_LINK_ADR_REQ( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define AS923_RX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923RxParamSetupReq( rxParamSetupReq ); } +#define AS923_NEW_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923NewChannelReq( newChannelReq ); } +#define AS923_TX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923TxParamSetupReq( txParamSetupReq ); } +#define AS923_DL_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923DlChannelReq( dlChannelReq ); } +#define AS923_ALTERNATE_DR( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923AlternateDr( alternateDr ); } +#define AS923_CALC_BACKOFF( ) else if(region == LORAMAC_REGION_AS923) { RegionAS923CalcBackOff( calcBackOff );} +#define AS923_NEXT_CHANNEL( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define AS923_CHANNEL_ADD( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923ChannelAdd( channelAdd ); } +#define AS923_CHANNEL_REMOVE( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923ChannelsRemove( channelRemove ); } +#define AS923_CHANNEL_MANUAL_ADD( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923ChannelManualAdd( channelAdd ); } +#define AS923_CHANNEL_MANUAL_REMOVE( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923ChannelsRemove( channelRemove ); } +#define AS923_SET_CONTINUOUS_WAVE( ) else if(region == LORAMAC_REGION_AS923) { RegionAS923SetContinuousWave( continuousWave );} +#define AS923_APPLY_DR_OFFSET( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define AS923_GET_CHANNELS( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923GetChannels( channels, size ); } +#define AS923_GET_CHANNEL_MASK( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923GetChannelMask( channelmask, size ); } +#define AS923_FORCE_JOIN_DATARATE( ) else if(region == LORAMAC_REGION_AS923) { return RegionAS923ForceJoinDataRate( joinDr, alternateDr ); } #else #define AS923_IS_ACTIVE( ) #define AS923_GET_PHY_PARAM( ) @@ -95,36 +94,35 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #ifdef REGION_AU915 #include "RegionAU915.h" -#define AU915_CASE case LORAMAC_REGION_AU915: -#define AU915_IS_ACTIVE( ) AU915_CASE { return true; } -#define AU915_GET_PHY_PARAM( ) AU915_CASE { return RegionAU915GetPhyParam( getPhy ); } -#define AU915_SET_BAND_TX_DONE( ) AU915_CASE { RegionAU915SetBandTxDone( txDone ); break; } -#define AU915_INIT_DEFAULTS( ) AU915_CASE { RegionAU915InitDefaults( type ); break; } -#define AU915_VERIFY( ) AU915_CASE { return RegionAU915Verify( verify, phyAttribute ); } -#define AU915_APPLY_CF_LIST( ) AU915_CASE { RegionAU915ApplyCFList( applyCFList ); break; } -#define AU915_CHAN_MASK_SET( ) AU915_CASE { return RegionAU915ChanMaskSet( chanMaskSet ); } -#define AU915_ADR_NEXT( ) AU915_CASE { return RegionAU915AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } -#define AU915_COMPUTE_RX_WINDOW_PARAMETERS( ) AU915_CASE { RegionAU915ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define AU915_RX_CONFIG( ) AU915_CASE { return RegionAU915RxConfig( rxConfig, datarate ); } -#define AU915_TX_CONFIG( ) AU915_CASE { return RegionAU915TxConfig( txConfig, txPower, txTimeOnAir ); } -#define AU915_LINK_ADR_REQ( ) AU915_CASE { return RegionAU915LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define AU915_RX_PARAM_SETUP_REQ( ) AU915_CASE { return RegionAU915RxParamSetupReq( rxParamSetupReq ); } -#define AU915_NEW_CHANNEL_REQ( ) AU915_CASE { return RegionAU915NewChannelReq( newChannelReq ); } -#define AU915_TX_PARAM_SETUP_REQ( ) AU915_CASE { return RegionAU915TxParamSetupReq( txParamSetupReq ); } -#define AU915_DL_CHANNEL_REQ( ) AU915_CASE { return RegionAU915DlChannelReq( dlChannelReq ); } -#define AU915_ALTERNATE_DR( ) AU915_CASE { return RegionAU915AlternateDr( alternateDr ); } -#define AU915_CALC_BACKOFF( ) AU915_CASE { RegionAU915CalcBackOff( calcBackOff ); break; } -#define AU915_NEXT_CHANNEL( ) AU915_CASE { return RegionAU915NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define AU915_CHANNEL_ADD( ) AU915_CASE { return RegionAU915ChannelAdd( channelAdd ); } -#define AU915_CHANNEL_REMOVE( ) AU915_CASE { return RegionAU915ChannelsRemove( channelRemove ); } -#define AU915_CHANNEL_MANUAL_ADD( ) AU915_CASE { return RegionAU915ChannelManualAdd( channelAdd ); } -#define AU915_CHANNEL_MANUAL_REMOVE( ) AU915_CASE { return RegionAU915ChannelsManualRemove( channelRemove ); } -#define AU915_SET_CONTINUOUS_WAVE( ) AU915_CASE { RegionAU915SetContinuousWave( continuousWave ); break; } -#define AU915_APPLY_DR_OFFSET( ) AU915_CASE { return RegionAU915ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define AU915_GET_CHANNELS( ) AU915_CASE { return RegionAU915GetChannels( channels, size ); } -#define AU915_GET_CHANNEL_MASK( ) AU915_CASE { return RegionAU915GetChannelMask( channelmask, size ); } -#define AU915_GET_CHANNEL_MASK_REMAINING( ) AU915_CASE { return RegionAU915GetChannelMaskRemaining( channelmask, size ); } -#define AU915_FORCE_JOIN_DATARATE( ) AU915_CASE { return RegionAU915ForceJoinDataRate( joinDr, alternateDr ); } +#define AU915_IS_ACTIVE( ) else if(region == LORAMAC_REGION_AU915) { return true; } +#define AU915_GET_PHY_PARAM( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915GetPhyParam( getPhy ); } +#define AU915_SET_BAND_TX_DONE( ) else if(region == LORAMAC_REGION_AU915) { RegionAU915SetBandTxDone( txDone );} +#define AU915_INIT_DEFAULTS( ) else if(region == LORAMAC_REGION_AU915) { RegionAU915InitDefaults( type );} +#define AU915_VERIFY( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915Verify( verify, phyAttribute ); } +#define AU915_APPLY_CF_LIST( ) else if(region == LORAMAC_REGION_AU915) { RegionAU915ApplyCFList( applyCFList );} +#define AU915_CHAN_MASK_SET( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915ChanMaskSet( chanMaskSet ); } +#define AU915_ADR_NEXT( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } +#define AU915_COMPUTE_RX_WINDOW_PARAMETERS( ) else if(region == LORAMAC_REGION_AU915) { RegionAU915ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams );} +#define AU915_RX_CONFIG( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915RxConfig( rxConfig, datarate ); } +#define AU915_TX_CONFIG( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915TxConfig( txConfig, txPower, txTimeOnAir ); } +#define AU915_LINK_ADR_REQ( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define AU915_RX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915RxParamSetupReq( rxParamSetupReq ); } +#define AU915_NEW_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915NewChannelReq( newChannelReq ); } +#define AU915_TX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915TxParamSetupReq( txParamSetupReq ); } +#define AU915_DL_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915DlChannelReq( dlChannelReq ); } +#define AU915_ALTERNATE_DR( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915AlternateDr( alternateDr ); } +#define AU915_CALC_BACKOFF( ) else if(region == LORAMAC_REGION_AU915) { RegionAU915CalcBackOff( calcBackOff );} +#define AU915_NEXT_CHANNEL( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define AU915_CHANNEL_ADD( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915ChannelAdd( channelAdd ); } +#define AU915_CHANNEL_REMOVE( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915ChannelsRemove( channelRemove ); } +#define AU915_CHANNEL_MANUAL_ADD( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915ChannelManualAdd( channelAdd ); } +#define AU915_CHANNEL_MANUAL_REMOVE( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915ChannelsManualRemove( channelRemove ); } +#define AU915_SET_CONTINUOUS_WAVE( ) else if(region == LORAMAC_REGION_AU915) { RegionAU915SetContinuousWave( continuousWave );} +#define AU915_APPLY_DR_OFFSET( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define AU915_GET_CHANNELS( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915GetChannels( channels, size ); } +#define AU915_GET_CHANNEL_MASK( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915GetChannelMask( channelmask, size ); } +#define AU915_GET_CHANNEL_MASK_REMAINING( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915GetChannelMaskRemaining( channelmask, size ); } +#define AU915_FORCE_JOIN_DATARATE( ) else if(region == LORAMAC_REGION_AU915) { return RegionAU915ForceJoinDataRate( joinDr, alternateDr ); } #else #define AU915_IS_ACTIVE( ) #define AU915_GET_PHY_PARAM( ) @@ -159,33 +157,32 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #ifdef REGION_CN470 #include "RegionCN470.h" -#define CN470_CASE case LORAMAC_REGION_CN470: -#define CN470_IS_ACTIVE( ) CN470_CASE { return true; } -#define CN470_GET_PHY_PARAM( ) CN470_CASE { return RegionCN470GetPhyParam( getPhy ); } -#define CN470_SET_BAND_TX_DONE( ) CN470_CASE { RegionCN470SetBandTxDone( txDone ); break; } -#define CN470_INIT_DEFAULTS( ) CN470_CASE { RegionCN470InitDefaults( type ); break; } -#define CN470_VERIFY( ) CN470_CASE { return RegionCN470Verify( verify, phyAttribute ); } -#define CN470_APPLY_CF_LIST( ) CN470_CASE { RegionCN470ApplyCFList( applyCFList ); break; } -#define CN470_CHAN_MASK_SET( ) CN470_CASE { return RegionCN470ChanMaskSet( chanMaskSet ); } -#define CN470_ADR_NEXT( ) CN470_CASE { return RegionCN470AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } -#define CN470_COMPUTE_RX_WINDOW_PARAMETERS( ) CN470_CASE { RegionCN470ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define CN470_RX_CONFIG( ) CN470_CASE { return RegionCN470RxConfig( rxConfig, datarate ); } -#define CN470_TX_CONFIG( ) CN470_CASE { return RegionCN470TxConfig( txConfig, txPower, txTimeOnAir ); } -#define CN470_LINK_ADR_REQ( ) CN470_CASE { return RegionCN470LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define CN470_RX_PARAM_SETUP_REQ( ) CN470_CASE { return RegionCN470RxParamSetupReq( rxParamSetupReq ); } -#define CN470_NEW_CHANNEL_REQ( ) CN470_CASE { return RegionCN470NewChannelReq( newChannelReq ); } -#define CN470_TX_PARAM_SETUP_REQ( ) CN470_CASE { return RegionCN470TxParamSetupReq( txParamSetupReq ); } -#define CN470_DL_CHANNEL_REQ( ) CN470_CASE { return RegionCN470DlChannelReq( dlChannelReq ); } -#define CN470_ALTERNATE_DR( ) CN470_CASE { return RegionCN470AlternateDr( alternateDr ); } -#define CN470_CALC_BACKOFF( ) CN470_CASE { RegionCN470CalcBackOff( calcBackOff ); break; } -#define CN470_NEXT_CHANNEL( ) CN470_CASE { return RegionCN470NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define CN470_CHANNEL_ADD( ) CN470_CASE { return RegionCN470ChannelAdd( channelAdd ); } -#define CN470_CHANNEL_REMOVE( ) CN470_CASE { return RegionCN470ChannelsRemove( channelRemove ); } -#define CN470_CHANNEL_MANUAL_ADD( ) CN470_CASE { return RegionCN470ChannelManualAdd( channelAdd ); } -#define CN470_CHANNEL_MANUAL_REMOVE( ) CN470_CASE { return RegionCN470ChannelsRemove( channelRemove ); } -#define CN470_SET_CONTINUOUS_WAVE( ) CN470_CASE { RegionCN470SetContinuousWave( continuousWave ); break; } -#define CN470_APPLY_DR_OFFSET( ) CN470_CASE { return RegionCN470ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define CN470_FORCE_JOIN_DATARATE( ) CN470_CASE { return RegionCN470ForceJoinDataRate( joinDr, alternateDr ); } +#define CN470_IS_ACTIVE( ) else if(region == LORAMAC_REGION_CN470) { return true; } +#define CN470_GET_PHY_PARAM( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470GetPhyParam( getPhy ); } +#define CN470_SET_BAND_TX_DONE( ) else if(region == LORAMAC_REGION_CN470) { RegionCN470SetBandTxDone( txDone );} +#define CN470_INIT_DEFAULTS( ) else if(region == LORAMAC_REGION_CN470) { RegionCN470InitDefaults( type );} +#define CN470_VERIFY( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470Verify( verify, phyAttribute ); } +#define CN470_APPLY_CF_LIST( ) else if(region == LORAMAC_REGION_CN470) { RegionCN470ApplyCFList( applyCFList );} +#define CN470_CHAN_MASK_SET( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470ChanMaskSet( chanMaskSet ); } +#define CN470_ADR_NEXT( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } +#define CN470_COMPUTE_RX_WINDOW_PARAMETERS( ) else if(region == LORAMAC_REGION_CN470) { RegionCN470ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams );} +#define CN470_RX_CONFIG( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470RxConfig( rxConfig, datarate ); } +#define CN470_TX_CONFIG( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470TxConfig( txConfig, txPower, txTimeOnAir ); } +#define CN470_LINK_ADR_REQ( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define CN470_RX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470RxParamSetupReq( rxParamSetupReq ); } +#define CN470_NEW_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470NewChannelReq( newChannelReq ); } +#define CN470_TX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470TxParamSetupReq( txParamSetupReq ); } +#define CN470_DL_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470DlChannelReq( dlChannelReq ); } +#define CN470_ALTERNATE_DR( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470AlternateDr( alternateDr ); } +#define CN470_CALC_BACKOFF( ) else if(region == LORAMAC_REGION_CN470) { RegionCN470CalcBackOff( calcBackOff );} +#define CN470_NEXT_CHANNEL( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define CN470_CHANNEL_ADD( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470ChannelAdd( channelAdd ); } +#define CN470_CHANNEL_REMOVE( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470ChannelsRemove( channelRemove ); } +#define CN470_CHANNEL_MANUAL_ADD( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470ChannelManualAdd( channelAdd ); } +#define CN470_CHANNEL_MANUAL_REMOVE( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470ChannelsRemove( channelRemove ); } +#define CN470_SET_CONTINUOUS_WAVE( ) else if(region == LORAMAC_REGION_CN470) { RegionCN470SetContinuousWave( continuousWave );} +#define CN470_APPLY_DR_OFFSET( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define CN470_FORCE_JOIN_DATARATE( ) else if(region == LORAMAC_REGION_CN470) { return RegionCN470ForceJoinDataRate( joinDr, alternateDr ); } #else #define CN470_IS_ACTIVE( ) #define CN470_GET_PHY_PARAM( ) @@ -217,30 +214,29 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #ifdef REGION_CN779 #include "RegionCN779.h" -#define CN779_CASE case LORAMAC_REGION_CN779: -#define CN779_IS_ACTIVE( ) CN779_CASE { return true; } -#define CN779_GET_PHY_PARAM( ) CN779_CASE { return RegionCN779GetPhyParam( getPhy ); } -#define CN779_SET_BAND_TX_DONE( ) CN779_CASE { RegionCN779SetBandTxDone( txDone ); break; } -#define CN779_INIT_DEFAULTS( ) CN779_CASE { RegionCN779InitDefaults( type ); break; } -#define CN779_VERIFY( ) CN779_CASE { return RegionCN779Verify( verify, phyAttribute ); } -#define CN779_APPLY_CF_LIST( ) CN779_CASE { RegionCN779ApplyCFList( applyCFList ); break; } -#define CN779_CHAN_MASK_SET( ) CN779_CASE { return RegionCN779ChanMaskSet( chanMaskSet ); } -#define CN779_ADR_NEXT( ) CN779_CASE { return RegionCN779AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } -#define CN779_COMPUTE_RX_WINDOW_PARAMETERS( ) CN779_CASE { RegionCN779ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define CN779_RX_CONFIG( ) CN779_CASE { return RegionCN779RxConfig( rxConfig, datarate ); } -#define CN779_TX_CONFIG( ) CN779_CASE { return RegionCN779TxConfig( txConfig, txPower, txTimeOnAir ); } -#define CN779_LINK_ADR_REQ( ) CN779_CASE { return RegionCN779LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define CN779_RX_PARAM_SETUP_REQ( ) CN779_CASE { return RegionCN779RxParamSetupReq( rxParamSetupReq ); } -#define CN779_NEW_CHANNEL_REQ( ) CN779_CASE { return RegionCN779NewChannelReq( newChannelReq ); } -#define CN779_TX_PARAM_SETUP_REQ( ) CN779_CASE { return RegionCN779TxParamSetupReq( txParamSetupReq ); } -#define CN779_DL_CHANNEL_REQ( ) CN779_CASE { return RegionCN779DlChannelReq( dlChannelReq ); } -#define CN779_ALTERNATE_DR( ) CN779_CASE { return RegionCN779AlternateDr( alternateDr ); } -#define CN779_CALC_BACKOFF( ) CN779_CASE { RegionCN779CalcBackOff( calcBackOff ); break; } -#define CN779_NEXT_CHANNEL( ) CN779_CASE { return RegionCN779NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define CN779_CHANNEL_ADD( ) CN779_CASE { return RegionCN779ChannelAdd( channelAdd ); } -#define CN779_CHANNEL_REMOVE( ) CN779_CASE { return RegionCN779ChannelsRemove( channelRemove ); } -#define CN779_SET_CONTINUOUS_WAVE( ) CN779_CASE { RegionCN779SetContinuousWave( continuousWave ); break; } -#define CN779_APPLY_DR_OFFSET( ) CN779_CASE { return RegionCN779ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define CN779_IS_ACTIVE( ) else if(region == LORAMAC_REGION_CN779) { return true; } +#define CN779_GET_PHY_PARAM( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779GetPhyParam( getPhy ); } +#define CN779_SET_BAND_TX_DONE( ) else if(region == LORAMAC_REGION_CN779) { RegionCN779SetBandTxDone( txDone );} +#define CN779_INIT_DEFAULTS( ) else if(region == LORAMAC_REGION_CN779) { RegionCN779InitDefaults( type );} +#define CN779_VERIFY( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779Verify( verify, phyAttribute ); } +#define CN779_APPLY_CF_LIST( ) else if(region == LORAMAC_REGION_CN779) { RegionCN779ApplyCFList( applyCFList );} +#define CN779_CHAN_MASK_SET( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779ChanMaskSet( chanMaskSet ); } +#define CN779_ADR_NEXT( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } +#define CN779_COMPUTE_RX_WINDOW_PARAMETERS( ) else if(region == LORAMAC_REGION_CN779) { RegionCN779ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams );} +#define CN779_RX_CONFIG( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779RxConfig( rxConfig, datarate ); } +#define CN779_TX_CONFIG( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779TxConfig( txConfig, txPower, txTimeOnAir ); } +#define CN779_LINK_ADR_REQ( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define CN779_RX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779RxParamSetupReq( rxParamSetupReq ); } +#define CN779_NEW_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779NewChannelReq( newChannelReq ); } +#define CN779_TX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779TxParamSetupReq( txParamSetupReq ); } +#define CN779_DL_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779DlChannelReq( dlChannelReq ); } +#define CN779_ALTERNATE_DR( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779AlternateDr( alternateDr ); } +#define CN779_CALC_BACKOFF( ) else if(region == LORAMAC_REGION_CN779) { RegionCN779CalcBackOff( calcBackOff );} +#define CN779_NEXT_CHANNEL( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define CN779_CHANNEL_ADD( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779ChannelAdd( channelAdd ); } +#define CN779_CHANNEL_REMOVE( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779ChannelsRemove( channelRemove ); } +#define CN779_SET_CONTINUOUS_WAVE( ) else if(region == LORAMAC_REGION_CN779) { RegionCN779SetContinuousWave( continuousWave );} +#define CN779_APPLY_DR_OFFSET( ) else if(region == LORAMAC_REGION_CN779) { return RegionCN779ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } #else #define CN779_IS_ACTIVE( ) #define CN779_GET_PHY_PARAM( ) @@ -269,30 +265,29 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #ifdef REGION_EU433 #include "RegionEU433.h" -#define EU433_CASE case LORAMAC_REGION_EU433: -#define EU433_IS_ACTIVE( ) EU433_CASE { return true; } -#define EU433_GET_PHY_PARAM( ) EU433_CASE { return RegionEU433GetPhyParam( getPhy ); } -#define EU433_SET_BAND_TX_DONE( ) EU433_CASE { RegionEU433SetBandTxDone( txDone ); break; } -#define EU433_INIT_DEFAULTS( ) EU433_CASE { RegionEU433InitDefaults( type ); break; } -#define EU433_VERIFY( ) EU433_CASE { return RegionEU433Verify( verify, phyAttribute ); } -#define EU433_APPLY_CF_LIST( ) EU433_CASE { RegionEU433ApplyCFList( applyCFList ); break; } -#define EU433_CHAN_MASK_SET( ) EU433_CASE { return RegionEU433ChanMaskSet( chanMaskSet ); } -#define EU433_ADR_NEXT( ) EU433_CASE { return RegionEU433AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } -#define EU433_COMPUTE_RX_WINDOW_PARAMETERS( ) EU433_CASE { RegionEU433ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define EU433_RX_CONFIG( ) EU433_CASE { return RegionEU433RxConfig( rxConfig, datarate ); } -#define EU433_TX_CONFIG( ) EU433_CASE { return RegionEU433TxConfig( txConfig, txPower, txTimeOnAir ); } -#define EU433_LINK_ADR_REQ( ) EU433_CASE { return RegionEU433LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define EU433_RX_PARAM_SETUP_REQ( ) EU433_CASE { return RegionEU433RxParamSetupReq( rxParamSetupReq ); } -#define EU433_NEW_CHANNEL_REQ( ) EU433_CASE { return RegionEU433NewChannelReq( newChannelReq ); } -#define EU433_TX_PARAM_SETUP_REQ( ) EU433_CASE { return RegionEU433TxParamSetupReq( txParamSetupReq ); } -#define EU433_DL_CHANNEL_REQ( ) EU433_CASE { return RegionEU433DlChannelReq( dlChannelReq ); } -#define EU433_ALTERNATE_DR( ) EU433_CASE { return RegionEU433AlternateDr( alternateDr ); } -#define EU433_CALC_BACKOFF( ) EU433_CASE { RegionEU433CalcBackOff( calcBackOff ); break; } -#define EU433_NEXT_CHANNEL( ) EU433_CASE { return RegionEU433NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define EU433_CHANNEL_ADD( ) EU433_CASE { return RegionEU433ChannelAdd( channelAdd ); } -#define EU433_CHANNEL_REMOVE( ) EU433_CASE { return RegionEU433ChannelsRemove( channelRemove ); } -#define EU433_SET_CONTINUOUS_WAVE( ) EU433_CASE { RegionEU433SetContinuousWave( continuousWave ); break; } -#define EU433_APPLY_DR_OFFSET( ) EU433_CASE { return RegionEU433ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define EU433_IS_ACTIVE( ) else if(region == LORAMAC_REGION_EU433) { return true; } +#define EU433_GET_PHY_PARAM( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433GetPhyParam( getPhy ); } +#define EU433_SET_BAND_TX_DONE( ) else if(region == LORAMAC_REGION_EU433) { RegionEU433SetBandTxDone( txDone );} +#define EU433_INIT_DEFAULTS( ) else if(region == LORAMAC_REGION_EU433) { RegionEU433InitDefaults( type );} +#define EU433_VERIFY( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433Verify( verify, phyAttribute ); } +#define EU433_APPLY_CF_LIST( ) else if(region == LORAMAC_REGION_EU433) { RegionEU433ApplyCFList( applyCFList );} +#define EU433_CHAN_MASK_SET( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433ChanMaskSet( chanMaskSet ); } +#define EU433_ADR_NEXT( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } +#define EU433_COMPUTE_RX_WINDOW_PARAMETERS( ) else if(region == LORAMAC_REGION_EU433) { RegionEU433ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams );} +#define EU433_RX_CONFIG( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433RxConfig( rxConfig, datarate ); } +#define EU433_TX_CONFIG( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433TxConfig( txConfig, txPower, txTimeOnAir ); } +#define EU433_LINK_ADR_REQ( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define EU433_RX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433RxParamSetupReq( rxParamSetupReq ); } +#define EU433_NEW_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433NewChannelReq( newChannelReq ); } +#define EU433_TX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433TxParamSetupReq( txParamSetupReq ); } +#define EU433_DL_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433DlChannelReq( dlChannelReq ); } +#define EU433_ALTERNATE_DR( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433AlternateDr( alternateDr ); } +#define EU433_CALC_BACKOFF( ) else if(region == LORAMAC_REGION_EU433) { RegionEU433CalcBackOff( calcBackOff );} +#define EU433_NEXT_CHANNEL( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define EU433_CHANNEL_ADD( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433ChannelAdd( channelAdd ); } +#define EU433_CHANNEL_REMOVE( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433ChannelsRemove( channelRemove ); } +#define EU433_SET_CONTINUOUS_WAVE( ) else if(region == LORAMAC_REGION_EU433) { RegionEU433SetContinuousWave( continuousWave );} +#define EU433_APPLY_DR_OFFSET( ) else if(region == LORAMAC_REGION_EU433) { return RegionEU433ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } #else #define EU433_IS_ACTIVE( ) #define EU433_GET_PHY_PARAM( ) @@ -321,35 +316,34 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #ifdef REGION_EU868 #include "RegionEU868.h" -#define EU868_CASE case LORAMAC_REGION_EU868: -#define EU868_IS_ACTIVE( ) EU868_CASE { return true; } -#define EU868_GET_PHY_PARAM( ) EU868_CASE { return RegionEU868GetPhyParam( getPhy ); } -#define EU868_SET_BAND_TX_DONE( ) EU868_CASE { RegionEU868SetBandTxDone( txDone ); break; } -#define EU868_INIT_DEFAULTS( ) EU868_CASE { RegionEU868InitDefaults( type ); break; } -#define EU868_VERIFY( ) EU868_CASE { return RegionEU868Verify( verify, phyAttribute ); } -#define EU868_APPLY_CF_LIST( ) EU868_CASE { RegionEU868ApplyCFList( applyCFList ); break; } -#define EU868_CHAN_MASK_SET( ) EU868_CASE { return RegionEU868ChanMaskSet( chanMaskSet ); } -#define EU868_ADR_NEXT( ) EU868_CASE { return RegionEU868AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } -#define EU868_COMPUTE_RX_WINDOW_PARAMETERS( ) EU868_CASE { RegionEU868ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define EU868_RX_CONFIG( ) EU868_CASE { return RegionEU868RxConfig( rxConfig, datarate ); } -#define EU868_TX_CONFIG( ) EU868_CASE { return RegionEU868TxConfig( txConfig, txPower, txTimeOnAir ); } -#define EU868_LINK_ADR_REQ( ) EU868_CASE { return RegionEU868LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define EU868_RX_PARAM_SETUP_REQ( ) EU868_CASE { return RegionEU868RxParamSetupReq( rxParamSetupReq ); } -#define EU868_NEW_CHANNEL_REQ( ) EU868_CASE { return RegionEU868NewChannelReq( newChannelReq ); } -#define EU868_TX_PARAM_SETUP_REQ( ) EU868_CASE { return RegionEU868TxParamSetupReq( txParamSetupReq ); } -#define EU868_DL_CHANNEL_REQ( ) EU868_CASE { return RegionEU868DlChannelReq( dlChannelReq ); } -#define EU868_ALTERNATE_DR( ) EU868_CASE { return RegionEU868AlternateDr( alternateDr ); } -#define EU868_CALC_BACKOFF( ) EU868_CASE { RegionEU868CalcBackOff( calcBackOff ); break; } -#define EU868_NEXT_CHANNEL( ) EU868_CASE { return RegionEU868NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define EU868_CHANNEL_ADD( ) EU868_CASE { return RegionEU868ChannelAdd( channelAdd ); } -#define EU868_CHANNEL_REMOVE( ) EU868_CASE { return RegionEU868ChannelsRemove( channelRemove ); } -#define EU868_CHANNEL_MANUAL_ADD( ) EU868_CASE { return RegionEU868ChannelManualAdd( channelAdd ); } -#define EU868_CHANNEL_MANUAL_REMOVE( ) EU868_CASE { return RegionEU868ChannelsRemove( channelRemove ); } -#define EU868_SET_CONTINUOUS_WAVE( ) EU868_CASE { RegionEU868SetContinuousWave( continuousWave ); break; } -#define EU868_APPLY_DR_OFFSET( ) EU868_CASE { return RegionEU868ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define EU868_GET_CHANNELS( ) EU868_CASE { return RegionEU868GetChannels( channels, size ); } -#define EU868_GET_CHANNEL_MASK( ) EU868_CASE { return RegionEU868GetChannelMask( channelmask, size ); } -#define EU868_FORCE_JOIN_DATARATE( ) EU868_CASE { return RegionEU868ForceJoinDataRate( joinDr, alternateDr ); } +#define EU868_IS_ACTIVE( ) else if(region == LORAMAC_REGION_EU868) { return true; } +#define EU868_GET_PHY_PARAM( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868GetPhyParam( getPhy ); } +#define EU868_SET_BAND_TX_DONE( ) else if(region == LORAMAC_REGION_EU868) { RegionEU868SetBandTxDone( txDone );} +#define EU868_INIT_DEFAULTS( ) else if(region == LORAMAC_REGION_EU868) { RegionEU868InitDefaults( type );} +#define EU868_VERIFY( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868Verify( verify, phyAttribute ); } +#define EU868_APPLY_CF_LIST( ) else if(region == LORAMAC_REGION_EU868) { RegionEU868ApplyCFList( applyCFList );} +#define EU868_CHAN_MASK_SET( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868ChanMaskSet( chanMaskSet ); } +#define EU868_ADR_NEXT( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } +#define EU868_COMPUTE_RX_WINDOW_PARAMETERS( ) else if(region == LORAMAC_REGION_EU868) { RegionEU868ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams );} +#define EU868_RX_CONFIG( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868RxConfig( rxConfig, datarate ); } +#define EU868_TX_CONFIG( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868TxConfig( txConfig, txPower, txTimeOnAir ); } +#define EU868_LINK_ADR_REQ( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define EU868_RX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868RxParamSetupReq( rxParamSetupReq ); } +#define EU868_NEW_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868NewChannelReq( newChannelReq ); } +#define EU868_TX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868TxParamSetupReq( txParamSetupReq ); } +#define EU868_DL_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868DlChannelReq( dlChannelReq ); } +#define EU868_ALTERNATE_DR( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868AlternateDr( alternateDr ); } +#define EU868_CALC_BACKOFF( ) else if(region == LORAMAC_REGION_EU868) { RegionEU868CalcBackOff( calcBackOff );} +#define EU868_NEXT_CHANNEL( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define EU868_CHANNEL_ADD( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868ChannelAdd( channelAdd ); } +#define EU868_CHANNEL_REMOVE( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868ChannelsRemove( channelRemove ); } +#define EU868_CHANNEL_MANUAL_ADD( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868ChannelManualAdd( channelAdd ); } +#define EU868_CHANNEL_MANUAL_REMOVE( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868ChannelsRemove( channelRemove ); } +#define EU868_SET_CONTINUOUS_WAVE( ) else if(region == LORAMAC_REGION_EU868) { RegionEU868SetContinuousWave( continuousWave );} +#define EU868_APPLY_DR_OFFSET( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define EU868_GET_CHANNELS( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868GetChannels( channels, size ); } +#define EU868_GET_CHANNEL_MASK( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868GetChannelMask( channelmask, size ); } +#define EU868_FORCE_JOIN_DATARATE( ) else if(region == LORAMAC_REGION_EU868) { return RegionEU868ForceJoinDataRate( joinDr, alternateDr ); } #else #define EU868_IS_ACTIVE( ) #define EU868_GET_PHY_PARAM( ) @@ -383,30 +377,29 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #ifdef REGION_KR920 #include "RegionKR920.h" -#define KR920_CASE case LORAMAC_REGION_KR920: -#define KR920_IS_ACTIVE( ) KR920_CASE { return true; } -#define KR920_GET_PHY_PARAM( ) KR920_CASE { return RegionKR920GetPhyParam( getPhy ); } -#define KR920_SET_BAND_TX_DONE( ) KR920_CASE { RegionKR920SetBandTxDone( txDone ); break; } -#define KR920_INIT_DEFAULTS( ) KR920_CASE { RegionKR920InitDefaults( type ); break; } -#define KR920_VERIFY( ) KR920_CASE { return RegionKR920Verify( verify, phyAttribute ); } -#define KR920_APPLY_CF_LIST( ) KR920_CASE { RegionKR920ApplyCFList( applyCFList ); break; } -#define KR920_CHAN_MASK_SET( ) KR920_CASE { return RegionKR920ChanMaskSet( chanMaskSet ); } -#define KR920_ADR_NEXT( ) KR920_CASE { return RegionKR920AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } -#define KR920_COMPUTE_RX_WINDOW_PARAMETERS( ) KR920_CASE { RegionKR920ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define KR920_RX_CONFIG( ) KR920_CASE { return RegionKR920RxConfig( rxConfig, datarate ); } -#define KR920_TX_CONFIG( ) KR920_CASE { return RegionKR920TxConfig( txConfig, txPower, txTimeOnAir ); } -#define KR920_LINK_ADR_REQ( ) KR920_CASE { return RegionKR920LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define KR920_RX_PARAM_SETUP_REQ( ) KR920_CASE { return RegionKR920RxParamSetupReq( rxParamSetupReq ); } -#define KR920_NEW_CHANNEL_REQ( ) KR920_CASE { return RegionKR920NewChannelReq( newChannelReq ); } -#define KR920_TX_PARAM_SETUP_REQ( ) KR920_CASE { return RegionKR920TxParamSetupReq( txParamSetupReq ); } -#define KR920_DL_CHANNEL_REQ( ) KR920_CASE { return RegionKR920DlChannelReq( dlChannelReq ); } -#define KR920_ALTERNATE_DR( ) KR920_CASE { return RegionKR920AlternateDr( alternateDr ); } -#define KR920_CALC_BACKOFF( ) KR920_CASE { RegionKR920CalcBackOff( calcBackOff ); break; } -#define KR920_NEXT_CHANNEL( ) KR920_CASE { return RegionKR920NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define KR920_CHANNEL_ADD( ) KR920_CASE { return RegionKR920ChannelAdd( channelAdd ); } -#define KR920_CHANNEL_REMOVE( ) KR920_CASE { return RegionKR920ChannelsRemove( channelRemove ); } -#define KR920_SET_CONTINUOUS_WAVE( ) KR920_CASE { RegionKR920SetContinuousWave( continuousWave ); break; } -#define KR920_APPLY_DR_OFFSET( ) KR920_CASE { return RegionKR920ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define KR920_IS_ACTIVE( ) else if(region == LORAMAC_REGION_KR920) { return true; } +#define KR920_GET_PHY_PARAM( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920GetPhyParam( getPhy ); } +#define KR920_SET_BAND_TX_DONE( ) else if(region == LORAMAC_REGION_KR920) { RegionKR920SetBandTxDone( txDone );} +#define KR920_INIT_DEFAULTS( ) else if(region == LORAMAC_REGION_KR920) { RegionKR920InitDefaults( type );} +#define KR920_VERIFY( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920Verify( verify, phyAttribute ); } +#define KR920_APPLY_CF_LIST( ) else if(region == LORAMAC_REGION_KR920) { RegionKR920ApplyCFList( applyCFList );} +#define KR920_CHAN_MASK_SET( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920ChanMaskSet( chanMaskSet ); } +#define KR920_ADR_NEXT( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } +#define KR920_COMPUTE_RX_WINDOW_PARAMETERS( ) else if(region == LORAMAC_REGION_KR920) { RegionKR920ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams );} +#define KR920_RX_CONFIG( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920RxConfig( rxConfig, datarate ); } +#define KR920_TX_CONFIG( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920TxConfig( txConfig, txPower, txTimeOnAir ); } +#define KR920_LINK_ADR_REQ( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define KR920_RX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920RxParamSetupReq( rxParamSetupReq ); } +#define KR920_NEW_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920NewChannelReq( newChannelReq ); } +#define KR920_TX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920TxParamSetupReq( txParamSetupReq ); } +#define KR920_DL_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920DlChannelReq( dlChannelReq ); } +#define KR920_ALTERNATE_DR( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920AlternateDr( alternateDr ); } +#define KR920_CALC_BACKOFF( ) else if(region == LORAMAC_REGION_KR920) { RegionKR920CalcBackOff( calcBackOff );} +#define KR920_NEXT_CHANNEL( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define KR920_CHANNEL_ADD( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920ChannelAdd( channelAdd ); } +#define KR920_CHANNEL_REMOVE( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920ChannelsRemove( channelRemove ); } +#define KR920_SET_CONTINUOUS_WAVE( ) else if(region == LORAMAC_REGION_KR920) { RegionKR920SetContinuousWave( continuousWave );} +#define KR920_APPLY_DR_OFFSET( ) else if(region == LORAMAC_REGION_KR920) { return RegionKR920ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } #else #define KR920_IS_ACTIVE( ) #define KR920_GET_PHY_PARAM( ) @@ -435,35 +428,34 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #ifdef REGION_IN865 #include "RegionIN865.h" -#define IN865_CASE case LORAMAC_REGION_IN865: -#define IN865_IS_ACTIVE( ) IN865_CASE { return true; } -#define IN865_GET_PHY_PARAM( ) IN865_CASE { return RegionIN865GetPhyParam( getPhy ); } -#define IN865_SET_BAND_TX_DONE( ) IN865_CASE { RegionIN865SetBandTxDone( txDone ); break; } -#define IN865_INIT_DEFAULTS( ) IN865_CASE { RegionIN865InitDefaults( type ); break; } -#define IN865_VERIFY( ) IN865_CASE { return RegionIN865Verify( verify, phyAttribute ); } -#define IN865_APPLY_CF_LIST( ) IN865_CASE { RegionIN865ApplyCFList( applyCFList ); break; } -#define IN865_CHAN_MASK_SET( ) IN865_CASE { return RegionIN865ChanMaskSet( chanMaskSet ); } -#define IN865_ADR_NEXT( ) IN865_CASE { return RegionIN865AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } -#define IN865_COMPUTE_RX_WINDOW_PARAMETERS( ) IN865_CASE { RegionIN865ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define IN865_RX_CONFIG( ) IN865_CASE { return RegionIN865RxConfig( rxConfig, datarate ); } -#define IN865_TX_CONFIG( ) IN865_CASE { return RegionIN865TxConfig( txConfig, txPower, txTimeOnAir ); } -#define IN865_LINK_ADR_REQ( ) IN865_CASE { return RegionIN865LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define IN865_RX_PARAM_SETUP_REQ( ) IN865_CASE { return RegionIN865RxParamSetupReq( rxParamSetupReq ); } -#define IN865_NEW_CHANNEL_REQ( ) IN865_CASE { return RegionIN865NewChannelReq( newChannelReq ); } -#define IN865_TX_PARAM_SETUP_REQ( ) IN865_CASE { return RegionIN865TxParamSetupReq( txParamSetupReq ); } -#define IN865_DL_CHANNEL_REQ( ) IN865_CASE { return RegionIN865DlChannelReq( dlChannelReq ); } -#define IN865_ALTERNATE_DR( ) IN865_CASE { return RegionIN865AlternateDr( alternateDr ); } -#define IN865_CALC_BACKOFF( ) IN865_CASE { RegionIN865CalcBackOff( calcBackOff ); break; } -#define IN865_NEXT_CHANNEL( ) IN865_CASE { return RegionIN865NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define IN865_CHANNEL_ADD( ) IN865_CASE { return RegionIN865ChannelAdd( channelAdd ); } -#define IN865_CHANNEL_REMOVE( ) IN865_CASE { return RegionIN865ChannelsRemove( channelRemove ); } -#define IN865_CHANNEL_MANUAL_ADD( ) IN865_CASE { return RegionIN865ChannelManualAdd( channelAdd ); } -#define IN865_CHANNEL_MANUAL_REMOVE( ) IN865_CASE { return RegionIN865ChannelsRemove( channelRemove ); } -#define IN865_SET_CONTINUOUS_WAVE( ) IN865_CASE { RegionIN865SetContinuousWave( continuousWave ); break; } -#define IN865_APPLY_DR_OFFSET( ) IN865_CASE { return RegionIN865ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define IN865_GET_CHANNELS( ) IN865_CASE { return RegionIN865GetChannels( channels, size ); } -#define IN865_GET_CHANNEL_MASK( ) IN865_CASE { return RegionIN865GetChannelMask( channelmask, size ); } -#define IN865_FORCE_JOIN_DATARATE( ) IN865_CASE { return RegionIN865ForceJoinDataRate( joinDr, alternateDr ); } +#define IN865_IS_ACTIVE( ) else if(region == LORAMAC_REGION_IN865) { return true; } +#define IN865_GET_PHY_PARAM( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865GetPhyParam( getPhy ); } +#define IN865_SET_BAND_TX_DONE( ) else if(region == LORAMAC_REGION_IN865) { RegionIN865SetBandTxDone( txDone );} +#define IN865_INIT_DEFAULTS( ) else if(region == LORAMAC_REGION_IN865) { RegionIN865InitDefaults( type );} +#define IN865_VERIFY( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865Verify( verify, phyAttribute ); } +#define IN865_APPLY_CF_LIST( ) else if(region == LORAMAC_REGION_IN865) { RegionIN865ApplyCFList( applyCFList );} +#define IN865_CHAN_MASK_SET( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865ChanMaskSet( chanMaskSet ); } +#define IN865_ADR_NEXT( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } +#define IN865_COMPUTE_RX_WINDOW_PARAMETERS( ) else if(region == LORAMAC_REGION_IN865) { RegionIN865ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams );} +#define IN865_RX_CONFIG( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865RxConfig( rxConfig, datarate ); } +#define IN865_TX_CONFIG( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865TxConfig( txConfig, txPower, txTimeOnAir ); } +#define IN865_LINK_ADR_REQ( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define IN865_RX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865RxParamSetupReq( rxParamSetupReq ); } +#define IN865_NEW_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865NewChannelReq( newChannelReq ); } +#define IN865_TX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865TxParamSetupReq( txParamSetupReq ); } +#define IN865_DL_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865DlChannelReq( dlChannelReq ); } +#define IN865_ALTERNATE_DR( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865AlternateDr( alternateDr ); } +#define IN865_CALC_BACKOFF( ) else if(region == LORAMAC_REGION_IN865) { RegionIN865CalcBackOff( calcBackOff );} +#define IN865_NEXT_CHANNEL( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define IN865_CHANNEL_ADD( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865ChannelAdd( channelAdd ); } +#define IN865_CHANNEL_REMOVE( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865ChannelsRemove( channelRemove ); } +#define IN865_CHANNEL_MANUAL_ADD( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865ChannelManualAdd( channelAdd ); } +#define IN865_CHANNEL_MANUAL_REMOVE( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865ChannelsRemove( channelRemove ); } +#define IN865_SET_CONTINUOUS_WAVE( ) else if(region == LORAMAC_REGION_IN865) { RegionIN865SetContinuousWave( continuousWave );} +#define IN865_APPLY_DR_OFFSET( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define IN865_GET_CHANNELS( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865GetChannels( channels, size ); } +#define IN865_GET_CHANNEL_MASK( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865GetChannelMask( channelmask, size ); } +#define IN865_FORCE_JOIN_DATARATE( ) else if(region == LORAMAC_REGION_IN865) { return RegionIN865ForceJoinDataRate( joinDr, alternateDr ); } #else #define IN865_IS_ACTIVE( ) #define IN865_GET_PHY_PARAM( ) @@ -497,36 +489,35 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #ifdef REGION_US915 #include "RegionUS915.h" -#define US915_CASE case LORAMAC_REGION_US915: -#define US915_IS_ACTIVE( ) US915_CASE { return true; } -#define US915_GET_PHY_PARAM( ) US915_CASE { return RegionUS915GetPhyParam( getPhy ); } -#define US915_SET_BAND_TX_DONE( ) US915_CASE { RegionUS915SetBandTxDone( txDone ); break; } -#define US915_INIT_DEFAULTS( ) US915_CASE { RegionUS915InitDefaults( type ); break; } -#define US915_VERIFY( ) US915_CASE { return RegionUS915Verify( verify, phyAttribute ); } -#define US915_APPLY_CF_LIST( ) US915_CASE { RegionUS915ApplyCFList( applyCFList ); break; } -#define US915_CHAN_MASK_SET( ) US915_CASE { return RegionUS915ChanMaskSet( chanMaskSet ); } -#define US915_ADR_NEXT( ) US915_CASE { return RegionUS915AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } -#define US915_COMPUTE_RX_WINDOW_PARAMETERS( ) US915_CASE { RegionUS915ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define US915_RX_CONFIG( ) US915_CASE { return RegionUS915RxConfig( rxConfig, datarate ); } -#define US915_TX_CONFIG( ) US915_CASE { return RegionUS915TxConfig( txConfig, txPower, txTimeOnAir ); } -#define US915_LINK_ADR_REQ( ) US915_CASE { return RegionUS915LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define US915_RX_PARAM_SETUP_REQ( ) US915_CASE { return RegionUS915RxParamSetupReq( rxParamSetupReq ); } -#define US915_NEW_CHANNEL_REQ( ) US915_CASE { return RegionUS915NewChannelReq( newChannelReq ); } -#define US915_TX_PARAM_SETUP_REQ( ) US915_CASE { return RegionUS915TxParamSetupReq( txParamSetupReq ); } -#define US915_DL_CHANNEL_REQ( ) US915_CASE { return RegionUS915DlChannelReq( dlChannelReq ); } -#define US915_ALTERNATE_DR( ) US915_CASE { return RegionUS915AlternateDr( alternateDr ); } -#define US915_CALC_BACKOFF( ) US915_CASE { RegionUS915CalcBackOff( calcBackOff ); break; } -#define US915_NEXT_CHANNEL( ) US915_CASE { return RegionUS915NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define US915_CHANNEL_ADD( ) US915_CASE { return RegionUS915ChannelAdd( channelAdd ); } -#define US915_CHANNEL_REMOVE( ) US915_CASE { return RegionUS915ChannelsRemove( channelRemove ); } -#define US915_CHANNEL_MANUAL_ADD( ) US915_CASE { return RegionUS915ChannelManualAdd( channelAdd ); } -#define US915_CHANNEL_MANUAL_REMOVE( ) US915_CASE { return RegionUS915ChannelsManualRemove( channelRemove ); } -#define US915_SET_CONTINUOUS_WAVE( ) US915_CASE { RegionUS915SetContinuousWave( continuousWave ); break; } -#define US915_APPLY_DR_OFFSET( ) US915_CASE { return RegionUS915ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define US915_GET_CHANNELS( ) US915_CASE { return RegionUS915GetChannels( channels, size ); } -#define US915_GET_CHANNEL_MASK( ) US915_CASE { return RegionUS915GetChannelMask( channelmask, size ); } -#define US915_GET_CHANNEL_MASK_REMAINING( ) US915_CASE { return RegionUS915GetChannelMaskRemaining( channelmask, size ); } -#define US915_FORCE_JOIN_DATARATE( ) US915_CASE { return RegionUS915ForceJoinDataRate( joinDr, alternateDr ); } +#define US915_IS_ACTIVE( ) else if(region == LORAMAC_REGION_US915) { return true; } +#define US915_GET_PHY_PARAM( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915GetPhyParam( getPhy ); } +#define US915_SET_BAND_TX_DONE( ) else if(region == LORAMAC_REGION_US915) { RegionUS915SetBandTxDone( txDone );} +#define US915_INIT_DEFAULTS( ) else if(region == LORAMAC_REGION_US915) { RegionUS915InitDefaults( type );} +#define US915_VERIFY( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915Verify( verify, phyAttribute ); } +#define US915_APPLY_CF_LIST( ) else if(region == LORAMAC_REGION_US915) { RegionUS915ApplyCFList( applyCFList );} +#define US915_CHAN_MASK_SET( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915ChanMaskSet( chanMaskSet ); } +#define US915_ADR_NEXT( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915AdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } +#define US915_COMPUTE_RX_WINDOW_PARAMETERS( ) else if(region == LORAMAC_REGION_US915) { RegionUS915ComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams );} +#define US915_RX_CONFIG( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915RxConfig( rxConfig, datarate ); } +#define US915_TX_CONFIG( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915TxConfig( txConfig, txPower, txTimeOnAir ); } +#define US915_LINK_ADR_REQ( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915LinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define US915_RX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915RxParamSetupReq( rxParamSetupReq ); } +#define US915_NEW_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915NewChannelReq( newChannelReq ); } +#define US915_TX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915TxParamSetupReq( txParamSetupReq ); } +#define US915_DL_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915DlChannelReq( dlChannelReq ); } +#define US915_ALTERNATE_DR( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915AlternateDr( alternateDr ); } +#define US915_CALC_BACKOFF( ) else if(region == LORAMAC_REGION_US915) { RegionUS915CalcBackOff( calcBackOff );} +#define US915_NEXT_CHANNEL( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915NextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define US915_CHANNEL_ADD( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915ChannelAdd( channelAdd ); } +#define US915_CHANNEL_REMOVE( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915ChannelsRemove( channelRemove ); } +#define US915_CHANNEL_MANUAL_ADD( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915ChannelManualAdd( channelAdd ); } +#define US915_CHANNEL_MANUAL_REMOVE( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915ChannelsManualRemove( channelRemove ); } +#define US915_SET_CONTINUOUS_WAVE( ) else if(region == LORAMAC_REGION_US915) { RegionUS915SetContinuousWave( continuousWave );} +#define US915_APPLY_DR_OFFSET( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915ApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define US915_GET_CHANNELS( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915GetChannels( channels, size ); } +#define US915_GET_CHANNEL_MASK( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915GetChannelMask( channelmask, size ); } +#define US915_GET_CHANNEL_MASK_REMAINING( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915GetChannelMaskRemaining( channelmask, size ); } +#define US915_FORCE_JOIN_DATARATE( ) else if(region == LORAMAC_REGION_US915) { return RegionUS915ForceJoinDataRate( joinDr, alternateDr ); } #else #define US915_IS_ACTIVE( ) #define US915_GET_PHY_PARAM( ) @@ -561,36 +552,35 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #ifdef REGION_US915_HYBRID #include "RegionUS915-Hybrid.h" -#define US915_HYBRID_CASE case LORAMAC_REGION_US915_HYBRID: -#define US915_HYBRID_IS_ACTIVE( ) US915_HYBRID_CASE { return true; } -#define US915_HYBRID_GET_PHY_PARAM( ) US915_HYBRID_CASE { return RegionUS915HybridGetPhyParam( getPhy ); } -#define US915_HYBRID_SET_BAND_TX_DONE( ) US915_HYBRID_CASE { RegionUS915HybridSetBandTxDone( txDone ); break; } -#define US915_HYBRID_INIT_DEFAULTS( ) US915_HYBRID_CASE { RegionUS915HybridInitDefaults( type ); break; } -#define US915_HYBRID_VERIFY( ) US915_HYBRID_CASE { return RegionUS915HybridVerify( verify, phyAttribute ); } -#define US915_HYBRID_APPLY_CF_LIST( ) US915_HYBRID_CASE { RegionUS915HybridApplyCFList( applyCFList ); break; } -#define US915_HYBRID_CHAN_MASK_SET( ) US915_HYBRID_CASE { return RegionUS915HybridChanMaskSet( chanMaskSet ); } -#define US915_HYBRID_ADR_NEXT( ) US915_HYBRID_CASE { return RegionUS915HybridAdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } -#define US915_HYBRID_COMPUTE_RX_WINDOW_PARAMETERS( ) US915_HYBRID_CASE { RegionUS915HybridComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams ); break; } -#define US915_HYBRID_RX_CONFIG( ) US915_HYBRID_CASE { return RegionUS915HybridRxConfig( rxConfig, datarate ); } -#define US915_HYBRID_TX_CONFIG( ) US915_HYBRID_CASE { return RegionUS915HybridTxConfig( txConfig, txPower, txTimeOnAir ); } -#define US915_HYBRID_LINK_ADR_REQ( ) US915_HYBRID_CASE { return RegionUS915HybridLinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } -#define US915_HYBRID_RX_PARAM_SETUP_REQ( ) US915_HYBRID_CASE { return RegionUS915HybridRxParamSetupReq( rxParamSetupReq ); } -#define US915_HYBRID_NEW_CHANNEL_REQ( ) US915_HYBRID_CASE { return RegionUS915HybridNewChannelReq( newChannelReq ); } -#define US915_HYBRID_TX_PARAM_SETUP_REQ( ) US915_HYBRID_CASE { return RegionUS915HybridTxParamSetupReq( txParamSetupReq ); } -#define US915_HYBRID_DL_CHANNEL_REQ( ) US915_HYBRID_CASE { return RegionUS915HybridDlChannelReq( dlChannelReq ); } -#define US915_HYBRID_ALTERNATE_DR( ) US915_HYBRID_CASE { return RegionUS915HybridAlternateDr( alternateDr ); } -#define US915_HYBRID_CALC_BACKOFF( ) US915_HYBRID_CASE { RegionUS915HybridCalcBackOff( calcBackOff ); break; } -#define US915_HYBRID_NEXT_CHANNEL( ) US915_HYBRID_CASE { return RegionUS915HybridNextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } -#define US915_HYBRID_CHANNEL_ADD( ) US915_HYBRID_CASE { return RegionUS915HybridChannelAdd( channelAdd ); } -#define US915_HYBRID_CHANNEL_REMOVE( ) US915_HYBRID_CASE { return RegionUS915HybridChannelsRemove( channelRemove ); } -#define US915_HYBRID_CHANNEL_MANUAL_ADD( ) US915_HYBRID_CASE { return RegionUS915HybridChannelManualAdd( channelAdd ); } -#define US915_HYBRID_CHANNEL_MANUAL_REMOVE( ) US915_HYBRID_CASE { return RegionUS915HybridChannelsManualRemove( channelRemove ); } -#define US915_HYBRID_SET_CONTINUOUS_WAVE( ) US915_HYBRID_CASE { RegionUS915HybridSetContinuousWave( continuousWave ); break; } -#define US915_HYBRID_APPLY_DR_OFFSET( ) US915_HYBRID_CASE { return RegionUS915HybridApplyDrOffset( downlinkDwellTime, dr, drOffset ); } -#define US915_HYBRID_GET_CHANNELS( ) US915_HYBRID_CASE { return RegionUS915HybridGetChannels( channels, size ); } -#define US915_HYBRID_GET_CHANNEL_MASK( ) US915_HYBRID_CASE { return RegionUS915HybridGetChannelMask( channelmask, size ); } -#define US915_HYBRID_GET_CHANNEL_MASK_REMAINING( ) US915_HYBRID_CASE { return RegionUS915HybridGetChannelMaskRemaining( channelmask, size ); } -#define US915_HYBRID_FORCE_JOIN_DATARATE( ) US915_HYBRID_CASE { return RegionUS915HybridForceJoinDataRate( joinDr, alternateDr ); } +#define US915_HYBRID_IS_ACTIVE( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return true; } +#define US915_HYBRID_GET_PHY_PARAM( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridGetPhyParam( getPhy ); } +#define US915_HYBRID_SET_BAND_TX_DONE( ) else if(region == LORAMAC_REGION_US915_HYBRID) { RegionUS915HybridSetBandTxDone( txDone );} +#define US915_HYBRID_INIT_DEFAULTS( ) else if(region == LORAMAC_REGION_US915_HYBRID) { RegionUS915HybridInitDefaults( type );} +#define US915_HYBRID_VERIFY( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridVerify( verify, phyAttribute ); } +#define US915_HYBRID_APPLY_CF_LIST( ) else if(region == LORAMAC_REGION_US915_HYBRID) { RegionUS915HybridApplyCFList( applyCFList );} +#define US915_HYBRID_CHAN_MASK_SET( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridChanMaskSet( chanMaskSet ); } +#define US915_HYBRID_ADR_NEXT( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridAdrNext( adrNext, drOut, txPowOut, adrAckCounter ); } +#define US915_HYBRID_COMPUTE_RX_WINDOW_PARAMETERS( ) else if(region == LORAMAC_REGION_US915_HYBRID) { RegionUS915HybridComputeRxWindowParameters( datarate, minRxSymbols, rxError, rxConfigParams );} +#define US915_HYBRID_RX_CONFIG( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridRxConfig( rxConfig, datarate ); } +#define US915_HYBRID_TX_CONFIG( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridTxConfig( txConfig, txPower, txTimeOnAir ); } +#define US915_HYBRID_LINK_ADR_REQ( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridLinkAdrReq( linkAdrReq, drOut, txPowOut, nbRepOut, nbBytesParsed ); } +#define US915_HYBRID_RX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridRxParamSetupReq( rxParamSetupReq ); } +#define US915_HYBRID_NEW_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridNewChannelReq( newChannelReq ); } +#define US915_HYBRID_TX_PARAM_SETUP_REQ( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridTxParamSetupReq( txParamSetupReq ); } +#define US915_HYBRID_DL_CHANNEL_REQ( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridDlChannelReq( dlChannelReq ); } +#define US915_HYBRID_ALTERNATE_DR( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridAlternateDr( alternateDr ); } +#define US915_HYBRID_CALC_BACKOFF( ) else if(region == LORAMAC_REGION_US915_HYBRID) { RegionUS915HybridCalcBackOff( calcBackOff );} +#define US915_HYBRID_NEXT_CHANNEL( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridNextChannel( nextChanParams, channel, time, aggregatedTimeOff ); } +#define US915_HYBRID_CHANNEL_ADD( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridChannelAdd( channelAdd ); } +#define US915_HYBRID_CHANNEL_REMOVE( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridChannelsRemove( channelRemove ); } +#define US915_HYBRID_CHANNEL_MANUAL_ADD( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridChannelManualAdd( channelAdd ); } +#define US915_HYBRID_CHANNEL_MANUAL_REMOVE( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridChannelsManualRemove( channelRemove ); } +#define US915_HYBRID_SET_CONTINUOUS_WAVE( ) else if(region == LORAMAC_REGION_US915_HYBRID) { RegionUS915HybridSetContinuousWave( continuousWave );} +#define US915_HYBRID_APPLY_DR_OFFSET( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridApplyDrOffset( downlinkDwellTime, dr, drOffset ); } +#define US915_HYBRID_GET_CHANNELS( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridGetChannels( channels, size ); } +#define US915_HYBRID_GET_CHANNEL_MASK( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridGetChannelMask( channelmask, size ); } +#define US915_HYBRID_GET_CHANNEL_MASK_REMAINING( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridGetChannelMaskRemaining( channelmask, size ); } +#define US915_HYBRID_FORCE_JOIN_DATARATE( ) else if(region == LORAMAC_REGION_US915_HYBRID) { return RegionUS915HybridForceJoinDataRate( joinDr, alternateDr ); } #else #define US915_HYBRID_IS_ACTIVE( ) #define US915_HYBRID_GET_PHY_PARAM( ) @@ -625,584 +615,570 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae bool RegionIsActive( LoRaMacRegion_t region ) { - switch( region ) - { - AS923_IS_ACTIVE( ); - AU915_IS_ACTIVE( ); - CN470_IS_ACTIVE( ); - CN779_IS_ACTIVE( ); - EU433_IS_ACTIVE( ); - EU868_IS_ACTIVE( ); - KR920_IS_ACTIVE( ); - IN865_IS_ACTIVE( ); - US915_IS_ACTIVE( ); - US915_HYBRID_IS_ACTIVE( ); - default: - { - return false; - } + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AS923_IS_ACTIVE( ) + AU915_IS_ACTIVE( ) + CN470_IS_ACTIVE( ) + CN779_IS_ACTIVE( ) + EU433_IS_ACTIVE( ) + EU868_IS_ACTIVE( ) + KR920_IS_ACTIVE( ) + IN865_IS_ACTIVE( ) + US915_IS_ACTIVE( ) + US915_HYBRID_IS_ACTIVE( ) + else { + return false; } } IRAM_ATTR PhyParam_t RegionGetPhyParam( LoRaMacRegion_t region, GetPhyParams_t* getPhy ) { PhyParam_t phyParam = { 0 }; - switch( region ) - { - AS923_GET_PHY_PARAM( ); - AU915_GET_PHY_PARAM( ); - CN470_GET_PHY_PARAM( ); - CN779_GET_PHY_PARAM( ); - EU433_GET_PHY_PARAM( ); - EU868_GET_PHY_PARAM( ); - KR920_GET_PHY_PARAM( ); - IN865_GET_PHY_PARAM( ); - US915_GET_PHY_PARAM( ); - US915_HYBRID_GET_PHY_PARAM( ); - default: - { - return phyParam; - } + + if(region >= LORAMAC_REGION_MAX) { + return phyParam; + } + AS923_GET_PHY_PARAM( ) + AU915_GET_PHY_PARAM( ) + CN470_GET_PHY_PARAM( ) + CN779_GET_PHY_PARAM( ) + EU433_GET_PHY_PARAM( ) + EU868_GET_PHY_PARAM( ) + KR920_GET_PHY_PARAM( ) + IN865_GET_PHY_PARAM( ) + US915_GET_PHY_PARAM( ) + US915_HYBRID_GET_PHY_PARAM( ) + else { + return phyParam; } } IRAM_ATTR void RegionSetBandTxDone( LoRaMacRegion_t region, SetBandTxDoneParams_t* txDone ) { - switch( region ) - { - AS923_SET_BAND_TX_DONE( ); - AU915_SET_BAND_TX_DONE( ); - CN470_SET_BAND_TX_DONE( ); - CN779_SET_BAND_TX_DONE( ); - EU433_SET_BAND_TX_DONE( ); - EU868_SET_BAND_TX_DONE( ); - KR920_SET_BAND_TX_DONE( ); - IN865_SET_BAND_TX_DONE( ); - US915_SET_BAND_TX_DONE( ); - US915_HYBRID_SET_BAND_TX_DONE( ); - default: - { - return; - } + if(region >= LORAMAC_REGION_MAX) { + return; } + AS923_SET_BAND_TX_DONE( ) + AU915_SET_BAND_TX_DONE( ) + CN470_SET_BAND_TX_DONE( ) + CN779_SET_BAND_TX_DONE( ) + EU433_SET_BAND_TX_DONE( ) + EU868_SET_BAND_TX_DONE( ) + KR920_SET_BAND_TX_DONE( ) + IN865_SET_BAND_TX_DONE( ) + US915_SET_BAND_TX_DONE( ) + US915_HYBRID_SET_BAND_TX_DONE( ) } void RegionInitDefaults( LoRaMacRegion_t region, InitType_t type ) { - switch( region ) - { - AS923_INIT_DEFAULTS( ); - AU915_INIT_DEFAULTS( ); - CN470_INIT_DEFAULTS( ); - CN779_INIT_DEFAULTS( ); - EU433_INIT_DEFAULTS( ); - EU868_INIT_DEFAULTS( ); - KR920_INIT_DEFAULTS( ); - IN865_INIT_DEFAULTS( ); - US915_INIT_DEFAULTS( ); - US915_HYBRID_INIT_DEFAULTS( ); - default: - { - break; - } + + if(region >= LORAMAC_REGION_MAX) { + return; } + AS923_INIT_DEFAULTS( ) + AU915_INIT_DEFAULTS( ) + CN470_INIT_DEFAULTS( ) + CN779_INIT_DEFAULTS( ) + EU433_INIT_DEFAULTS( ) + EU868_INIT_DEFAULTS( ) + KR920_INIT_DEFAULTS( ) + IN865_INIT_DEFAULTS( ) + US915_INIT_DEFAULTS( ) + US915_HYBRID_INIT_DEFAULTS( ) } bool RegionVerify( LoRaMacRegion_t region, VerifyParams_t* verify, PhyAttribute_t phyAttribute ) { - switch( region ) - { - AS923_VERIFY( ); - AU915_VERIFY( ); - CN470_VERIFY( ); - CN779_VERIFY( ); - EU433_VERIFY( ); - EU868_VERIFY( ); - KR920_VERIFY( ); - IN865_VERIFY( ); - US915_VERIFY( ); - US915_HYBRID_VERIFY( ); - default: - { - return false; - } + + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AS923_VERIFY( ) + AU915_VERIFY( ) + CN470_VERIFY( ) + CN779_VERIFY( ) + EU433_VERIFY( ) + EU868_VERIFY( ) + KR920_VERIFY( ) + IN865_VERIFY( ) + US915_VERIFY( ) + US915_HYBRID_VERIFY( ) + else { + return false; } } void RegionApplyCFList( LoRaMacRegion_t region, ApplyCFListParams_t* applyCFList ) { - switch( region ) - { - AS923_APPLY_CF_LIST( ); - AU915_APPLY_CF_LIST( ); - CN470_APPLY_CF_LIST( ); - CN779_APPLY_CF_LIST( ); - EU433_APPLY_CF_LIST( ); - EU868_APPLY_CF_LIST( ); - KR920_APPLY_CF_LIST( ); - IN865_APPLY_CF_LIST( ); - US915_APPLY_CF_LIST( ); - US915_HYBRID_APPLY_CF_LIST( ); - default: - { - break; - } + + if(region >= LORAMAC_REGION_MAX) { + return; } + AS923_APPLY_CF_LIST( ) + AU915_APPLY_CF_LIST( ) + CN470_APPLY_CF_LIST( ) + CN779_APPLY_CF_LIST( ) + EU433_APPLY_CF_LIST( ) + EU868_APPLY_CF_LIST( ) + KR920_APPLY_CF_LIST( ) + IN865_APPLY_CF_LIST( ) + US915_APPLY_CF_LIST( ) + US915_HYBRID_APPLY_CF_LIST( ) } bool RegionChanMaskSet( LoRaMacRegion_t region, ChanMaskSetParams_t* chanMaskSet ) { - switch( region ) - { - AS923_CHAN_MASK_SET( ); - AU915_CHAN_MASK_SET( ); - CN470_CHAN_MASK_SET( ); - CN779_CHAN_MASK_SET( ); - EU433_CHAN_MASK_SET( ); - EU868_CHAN_MASK_SET( ); - KR920_CHAN_MASK_SET( ); - IN865_CHAN_MASK_SET( ); - US915_CHAN_MASK_SET( ); - US915_HYBRID_CHAN_MASK_SET( ); - default: - { - return false; - } + + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AS923_CHAN_MASK_SET( ) + AU915_CHAN_MASK_SET( ) + CN470_CHAN_MASK_SET( ) + CN779_CHAN_MASK_SET( ) + EU433_CHAN_MASK_SET( ) + EU868_CHAN_MASK_SET( ) + KR920_CHAN_MASK_SET( ) + IN865_CHAN_MASK_SET( ) + US915_CHAN_MASK_SET( ) + US915_HYBRID_CHAN_MASK_SET( ) + else { + return false; } } bool RegionAdrNext( LoRaMacRegion_t region, AdrNextParams_t* adrNext, int8_t* drOut, int8_t* txPowOut, uint32_t* adrAckCounter ) { - switch( region ) - { - AS923_ADR_NEXT( ); - AU915_ADR_NEXT( ); - CN470_ADR_NEXT( ); - CN779_ADR_NEXT( ); - EU433_ADR_NEXT( ); - EU868_ADR_NEXT( ); - KR920_ADR_NEXT( ); - IN865_ADR_NEXT( ); - US915_ADR_NEXT( ); - US915_HYBRID_ADR_NEXT( ); - default: - { - return false; - } + + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AS923_ADR_NEXT( ) + AU915_ADR_NEXT( ) + CN470_ADR_NEXT( ) + CN779_ADR_NEXT( ) + EU433_ADR_NEXT( ) + EU868_ADR_NEXT( ) + KR920_ADR_NEXT( ) + IN865_ADR_NEXT( ) + US915_ADR_NEXT( ) + US915_HYBRID_ADR_NEXT( ) + else { + return false; } } void RegionComputeRxWindowParameters( LoRaMacRegion_t region, int8_t datarate, uint8_t minRxSymbols, uint32_t rxError, RxConfigParams_t *rxConfigParams ) { - switch( region ) - { - AS923_COMPUTE_RX_WINDOW_PARAMETERS( ); - AU915_COMPUTE_RX_WINDOW_PARAMETERS( ); - CN470_COMPUTE_RX_WINDOW_PARAMETERS( ); - CN779_COMPUTE_RX_WINDOW_PARAMETERS( ); - EU433_COMPUTE_RX_WINDOW_PARAMETERS( ); - EU868_COMPUTE_RX_WINDOW_PARAMETERS( ); - KR920_COMPUTE_RX_WINDOW_PARAMETERS( ); - IN865_COMPUTE_RX_WINDOW_PARAMETERS( ); - US915_COMPUTE_RX_WINDOW_PARAMETERS( ); - US915_HYBRID_COMPUTE_RX_WINDOW_PARAMETERS( ); - default: - { - break; - } + + if(region >= LORAMAC_REGION_MAX) { + return; } + AS923_COMPUTE_RX_WINDOW_PARAMETERS( ) + AU915_COMPUTE_RX_WINDOW_PARAMETERS( ) + CN470_COMPUTE_RX_WINDOW_PARAMETERS( ) + CN779_COMPUTE_RX_WINDOW_PARAMETERS( ) + EU433_COMPUTE_RX_WINDOW_PARAMETERS( ) + EU868_COMPUTE_RX_WINDOW_PARAMETERS( ) + KR920_COMPUTE_RX_WINDOW_PARAMETERS( ) + IN865_COMPUTE_RX_WINDOW_PARAMETERS( ) + US915_COMPUTE_RX_WINDOW_PARAMETERS( ) + US915_HYBRID_COMPUTE_RX_WINDOW_PARAMETERS( ) } bool RegionRxConfig( LoRaMacRegion_t region, RxConfigParams_t* rxConfig, int8_t* datarate ) { - switch( region ) - { - AS923_RX_CONFIG( ); - AU915_RX_CONFIG( ); - CN470_RX_CONFIG( ); - CN779_RX_CONFIG( ); - EU433_RX_CONFIG( ); - EU868_RX_CONFIG( ); - KR920_RX_CONFIG( ); - IN865_RX_CONFIG( ); - US915_RX_CONFIG( ); - US915_HYBRID_RX_CONFIG( ); - default: - { - return false; - } + + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AS923_RX_CONFIG( ) + AU915_RX_CONFIG( ) + CN470_RX_CONFIG( ) + CN779_RX_CONFIG( ) + EU433_RX_CONFIG( ) + EU868_RX_CONFIG( ) + KR920_RX_CONFIG( ) + IN865_RX_CONFIG( ) + US915_RX_CONFIG( ) + US915_HYBRID_RX_CONFIG( ) + else { + return false; } } bool RegionTxConfig( LoRaMacRegion_t region, TxConfigParams_t* txConfig, int8_t* txPower, TimerTime_t* txTimeOnAir ) { - switch( region ) - { - AS923_TX_CONFIG( ); - AU915_TX_CONFIG( ); - CN470_TX_CONFIG( ); - CN779_TX_CONFIG( ); - EU433_TX_CONFIG( ); - EU868_TX_CONFIG( ); - KR920_TX_CONFIG( ); - IN865_TX_CONFIG( ); - US915_TX_CONFIG( ); - US915_HYBRID_TX_CONFIG( ); - default: - { - return false; - } + + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AS923_TX_CONFIG( ) + AU915_TX_CONFIG( ) + CN470_TX_CONFIG( ) + CN779_TX_CONFIG( ) + EU433_TX_CONFIG( ) + EU868_TX_CONFIG( ) + KR920_TX_CONFIG( ) + IN865_TX_CONFIG( ) + US915_TX_CONFIG( ) + US915_HYBRID_TX_CONFIG( ) + else { + return false; } } uint8_t RegionLinkAdrReq( LoRaMacRegion_t region, LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed ) { - switch( region ) - { - AS923_LINK_ADR_REQ( ); - AU915_LINK_ADR_REQ( ); - CN470_LINK_ADR_REQ( ); - CN779_LINK_ADR_REQ( ); - EU433_LINK_ADR_REQ( ); - EU868_LINK_ADR_REQ( ); - KR920_LINK_ADR_REQ( ); - IN865_LINK_ADR_REQ( ); - US915_LINK_ADR_REQ( ); - US915_HYBRID_LINK_ADR_REQ( ); - default: - { - return 0; - } + + if(region >= LORAMAC_REGION_MAX) { + return 0; + } + AS923_LINK_ADR_REQ( ) + AU915_LINK_ADR_REQ( ) + CN470_LINK_ADR_REQ( ) + CN779_LINK_ADR_REQ( ) + EU433_LINK_ADR_REQ( ) + EU868_LINK_ADR_REQ( ) + KR920_LINK_ADR_REQ( ) + IN865_LINK_ADR_REQ( ) + US915_LINK_ADR_REQ( ) + US915_HYBRID_LINK_ADR_REQ( ) + else { + return 0; } } uint8_t RegionRxParamSetupReq( LoRaMacRegion_t region, RxParamSetupReqParams_t* rxParamSetupReq ) { - switch( region ) - { - AS923_RX_PARAM_SETUP_REQ( ); - AU915_RX_PARAM_SETUP_REQ( ); - CN470_RX_PARAM_SETUP_REQ( ); - CN779_RX_PARAM_SETUP_REQ( ); - EU433_RX_PARAM_SETUP_REQ( ); - EU868_RX_PARAM_SETUP_REQ( ); - KR920_RX_PARAM_SETUP_REQ( ); - IN865_RX_PARAM_SETUP_REQ( ); - US915_RX_PARAM_SETUP_REQ( ); - US915_HYBRID_RX_PARAM_SETUP_REQ( ); - default: - { - return 0; - } + + if(region >= LORAMAC_REGION_MAX) { + return 0; + } + AS923_RX_PARAM_SETUP_REQ( ) + AU915_RX_PARAM_SETUP_REQ( ) + CN470_RX_PARAM_SETUP_REQ( ) + CN779_RX_PARAM_SETUP_REQ( ) + EU433_RX_PARAM_SETUP_REQ( ) + EU868_RX_PARAM_SETUP_REQ( ) + KR920_RX_PARAM_SETUP_REQ( ) + IN865_RX_PARAM_SETUP_REQ( ) + US915_RX_PARAM_SETUP_REQ( ) + US915_HYBRID_RX_PARAM_SETUP_REQ( ) + else { + return 0; } } uint8_t RegionNewChannelReq( LoRaMacRegion_t region, NewChannelReqParams_t* newChannelReq ) { - switch( region ) - { - AS923_NEW_CHANNEL_REQ( ); - AU915_NEW_CHANNEL_REQ( ); - CN470_NEW_CHANNEL_REQ( ); - CN779_NEW_CHANNEL_REQ( ); - EU433_NEW_CHANNEL_REQ( ); - EU868_NEW_CHANNEL_REQ( ); - KR920_NEW_CHANNEL_REQ( ); - IN865_NEW_CHANNEL_REQ( ); - US915_NEW_CHANNEL_REQ( ); - US915_HYBRID_NEW_CHANNEL_REQ( ); - default: - { - return 0; - } + + if(region >= LORAMAC_REGION_MAX) { + return 0; + } + AS923_NEW_CHANNEL_REQ( ) + AU915_NEW_CHANNEL_REQ( ) + CN470_NEW_CHANNEL_REQ( ) + CN779_NEW_CHANNEL_REQ( ) + EU433_NEW_CHANNEL_REQ( ) + EU868_NEW_CHANNEL_REQ( ) + KR920_NEW_CHANNEL_REQ( ) + IN865_NEW_CHANNEL_REQ( ) + US915_NEW_CHANNEL_REQ( ) + US915_HYBRID_NEW_CHANNEL_REQ( ) + else { + return 0; } } int8_t RegionTxParamSetupReq( LoRaMacRegion_t region, TxParamSetupReqParams_t* txParamSetupReq ) { - switch( region ) - { - AS923_TX_PARAM_SETUP_REQ( ); - AU915_TX_PARAM_SETUP_REQ( ); - CN470_TX_PARAM_SETUP_REQ( ); - CN779_TX_PARAM_SETUP_REQ( ); - EU433_TX_PARAM_SETUP_REQ( ); - EU868_TX_PARAM_SETUP_REQ( ); - KR920_TX_PARAM_SETUP_REQ( ); - IN865_TX_PARAM_SETUP_REQ( ); - US915_TX_PARAM_SETUP_REQ( ); - US915_HYBRID_TX_PARAM_SETUP_REQ( ); - default: - { - return 0; - } + + if(region >= LORAMAC_REGION_MAX) { + return 0; + } + AS923_TX_PARAM_SETUP_REQ( ) + AU915_TX_PARAM_SETUP_REQ( ) + CN470_TX_PARAM_SETUP_REQ( ) + CN779_TX_PARAM_SETUP_REQ( ) + EU433_TX_PARAM_SETUP_REQ( ) + EU868_TX_PARAM_SETUP_REQ( ) + KR920_TX_PARAM_SETUP_REQ( ) + IN865_TX_PARAM_SETUP_REQ( ) + US915_TX_PARAM_SETUP_REQ( ) + US915_HYBRID_TX_PARAM_SETUP_REQ( ) + else { + return 0; } } uint8_t RegionDlChannelReq( LoRaMacRegion_t region, DlChannelReqParams_t* dlChannelReq ) { - switch( region ) - { - AS923_DL_CHANNEL_REQ( ); - AU915_DL_CHANNEL_REQ( ); - CN470_DL_CHANNEL_REQ( ); - CN779_DL_CHANNEL_REQ( ); - EU433_DL_CHANNEL_REQ( ); - EU868_DL_CHANNEL_REQ( ); - KR920_DL_CHANNEL_REQ( ); - IN865_DL_CHANNEL_REQ( ); - US915_DL_CHANNEL_REQ( ); - US915_HYBRID_DL_CHANNEL_REQ( ); - default: - { - return 0; - } + + if(region >= LORAMAC_REGION_MAX) { + return 0; + } + AS923_DL_CHANNEL_REQ( ) + AU915_DL_CHANNEL_REQ( ) + CN470_DL_CHANNEL_REQ( ) + CN779_DL_CHANNEL_REQ( ) + EU433_DL_CHANNEL_REQ( ) + EU868_DL_CHANNEL_REQ( ) + KR920_DL_CHANNEL_REQ( ) + IN865_DL_CHANNEL_REQ( ) + US915_DL_CHANNEL_REQ( ) + US915_HYBRID_DL_CHANNEL_REQ( ) + else { + return 0; } } int8_t RegionAlternateDr( LoRaMacRegion_t region, AlternateDrParams_t* alternateDr ) { - switch( region ) - { - AS923_ALTERNATE_DR( ); - AU915_ALTERNATE_DR( ); - CN470_ALTERNATE_DR( ); - CN779_ALTERNATE_DR( ); - EU433_ALTERNATE_DR( ); - EU868_ALTERNATE_DR( ); - KR920_ALTERNATE_DR( ); - IN865_ALTERNATE_DR( ); - US915_ALTERNATE_DR( ); - US915_HYBRID_ALTERNATE_DR( ); - default: - { - return 0; - } + + if(region >= LORAMAC_REGION_MAX) { + return 0; + } + AS923_ALTERNATE_DR( ) + AU915_ALTERNATE_DR( ) + CN470_ALTERNATE_DR( ) + CN779_ALTERNATE_DR( ) + EU433_ALTERNATE_DR( ) + EU868_ALTERNATE_DR( ) + KR920_ALTERNATE_DR( ) + IN865_ALTERNATE_DR( ) + US915_ALTERNATE_DR( ) + US915_HYBRID_ALTERNATE_DR( ) + else { + return 0; } } void RegionCalcBackOff( LoRaMacRegion_t region, CalcBackOffParams_t* calcBackOff ) { - switch( region ) - { - AS923_CALC_BACKOFF( ); - AU915_CALC_BACKOFF( ); - CN470_CALC_BACKOFF( ); - CN779_CALC_BACKOFF( ); - EU433_CALC_BACKOFF( ); - EU868_CALC_BACKOFF( ); - KR920_CALC_BACKOFF( ); - IN865_CALC_BACKOFF( ); - US915_CALC_BACKOFF( ); - US915_HYBRID_CALC_BACKOFF( ); - default: - { - break; - } + + if(region >= LORAMAC_REGION_MAX) { + return; } + AS923_CALC_BACKOFF( ) + AU915_CALC_BACKOFF( ) + CN470_CALC_BACKOFF( ) + CN779_CALC_BACKOFF( ) + EU433_CALC_BACKOFF( ) + EU868_CALC_BACKOFF( ) + KR920_CALC_BACKOFF( ) + IN865_CALC_BACKOFF( ) + US915_CALC_BACKOFF( ) + US915_HYBRID_CALC_BACKOFF( ) } bool RegionNextChannel( LoRaMacRegion_t region, NextChanParams_t* nextChanParams, uint8_t* channel, TimerTime_t* time, TimerTime_t* aggregatedTimeOff ) { - switch( region ) - { - AS923_NEXT_CHANNEL( ); - AU915_NEXT_CHANNEL( ); - CN470_NEXT_CHANNEL( ); - CN779_NEXT_CHANNEL( ); - EU433_NEXT_CHANNEL( ); - EU868_NEXT_CHANNEL( ); - KR920_NEXT_CHANNEL( ); - IN865_NEXT_CHANNEL( ); - US915_NEXT_CHANNEL( ); - US915_HYBRID_NEXT_CHANNEL( ); - default: - { - return false; - } + + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AS923_NEXT_CHANNEL( ) + AU915_NEXT_CHANNEL( ) + CN470_NEXT_CHANNEL( ) + CN779_NEXT_CHANNEL( ) + EU433_NEXT_CHANNEL( ) + EU868_NEXT_CHANNEL( ) + KR920_NEXT_CHANNEL( ) + IN865_NEXT_CHANNEL( ) + US915_NEXT_CHANNEL( ) + US915_HYBRID_NEXT_CHANNEL( ) + else { + return false; } } LoRaMacStatus_t RegionChannelAdd( LoRaMacRegion_t region, ChannelAddParams_t* channelAdd ) { - switch( region ) - { - AS923_CHANNEL_ADD( ); - AU915_CHANNEL_ADD( ); - CN470_CHANNEL_ADD( ); - CN779_CHANNEL_ADD( ); - EU433_CHANNEL_ADD( ); - EU868_CHANNEL_ADD( ); - KR920_CHANNEL_ADD( ); - IN865_CHANNEL_ADD( ); - US915_CHANNEL_ADD( ); - US915_HYBRID_CHANNEL_ADD( ); - default: - { - return LORAMAC_STATUS_PARAMETER_INVALID; - } + + if(region >= LORAMAC_REGION_MAX) { + return LORAMAC_STATUS_PARAMETER_INVALID; + } + AS923_CHANNEL_ADD( ) + AU915_CHANNEL_ADD( ) + CN470_CHANNEL_ADD( ) + CN779_CHANNEL_ADD( ) + EU433_CHANNEL_ADD( ) + EU868_CHANNEL_ADD( ) + KR920_CHANNEL_ADD( ) + IN865_CHANNEL_ADD( ) + US915_CHANNEL_ADD( ) + US915_HYBRID_CHANNEL_ADD( ) + else { + return LORAMAC_STATUS_PARAMETER_INVALID; } } LoRaMacStatus_t RegionChannelManualAdd( LoRaMacRegion_t region, ChannelAddParams_t* channelAdd ) { - switch( region ) - { - AS923_CHANNEL_MANUAL_ADD( ); - AU915_CHANNEL_MANUAL_ADD( ); - EU868_CHANNEL_MANUAL_ADD( ); - US915_CHANNEL_MANUAL_ADD( ); - CN470_CHANNEL_MANUAL_ADD( ); - IN865_CHANNEL_MANUAL_ADD( ); - US915_HYBRID_CHANNEL_MANUAL_ADD( ); - default: - { - return LORAMAC_STATUS_PARAMETER_INVALID; - } + + if(region >= LORAMAC_REGION_MAX) { + return LORAMAC_STATUS_PARAMETER_INVALID; + } + AS923_CHANNEL_MANUAL_ADD( ) + AU915_CHANNEL_MANUAL_ADD( ) + EU868_CHANNEL_MANUAL_ADD( ) + US915_CHANNEL_MANUAL_ADD( ) + CN470_CHANNEL_MANUAL_ADD( ) + IN865_CHANNEL_MANUAL_ADD( ) + US915_HYBRID_CHANNEL_MANUAL_ADD( ) + else { + return LORAMAC_STATUS_PARAMETER_INVALID; } } bool RegionChannelsRemove( LoRaMacRegion_t region, ChannelRemoveParams_t* channelRemove ) { - switch( region ) - { - AS923_CHANNEL_REMOVE( ); - AU915_CHANNEL_REMOVE( ); - CN470_CHANNEL_REMOVE( ); - CN779_CHANNEL_REMOVE( ); - EU433_CHANNEL_REMOVE( ); - EU868_CHANNEL_REMOVE( ); - KR920_CHANNEL_REMOVE( ); - IN865_CHANNEL_REMOVE( ); - US915_CHANNEL_REMOVE( ); - US915_HYBRID_CHANNEL_REMOVE( ); - default: - { - return false; - } + + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AS923_CHANNEL_REMOVE( ) + AU915_CHANNEL_REMOVE( ) + CN470_CHANNEL_REMOVE( ) + CN779_CHANNEL_REMOVE( ) + EU433_CHANNEL_REMOVE( ) + EU868_CHANNEL_REMOVE( ) + KR920_CHANNEL_REMOVE( ) + IN865_CHANNEL_REMOVE( ) + US915_CHANNEL_REMOVE( ) + US915_HYBRID_CHANNEL_REMOVE( ) + else { + return false; } } bool RegionChannelsManualRemove( LoRaMacRegion_t region, ChannelRemoveParams_t* channelRemove ) { - switch( region ) - { - AS923_CHANNEL_MANUAL_REMOVE( ); - AU915_CHANNEL_MANUAL_REMOVE( ); - EU868_CHANNEL_MANUAL_REMOVE( ); - US915_CHANNEL_MANUAL_REMOVE( ); - CN470_CHANNEL_MANUAL_REMOVE( ); - IN865_CHANNEL_MANUAL_REMOVE( ); - US915_HYBRID_CHANNEL_MANUAL_REMOVE( ); - default: - { - return false; - } + + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AS923_CHANNEL_MANUAL_REMOVE( ) + AU915_CHANNEL_MANUAL_REMOVE( ) + EU868_CHANNEL_MANUAL_REMOVE( ) + US915_CHANNEL_MANUAL_REMOVE( ) + CN470_CHANNEL_MANUAL_REMOVE( ) + IN865_CHANNEL_MANUAL_REMOVE( ) + US915_HYBRID_CHANNEL_MANUAL_REMOVE( ) + US915_HYBRID_CHANNEL_REMOVE( ) + else { + return false; } } void RegionSetContinuousWave( LoRaMacRegion_t region, ContinuousWaveParams_t* continuousWave ) { - switch( region ) - { - AS923_SET_CONTINUOUS_WAVE( ); - AU915_SET_CONTINUOUS_WAVE( ); - CN470_SET_CONTINUOUS_WAVE( ); - CN779_SET_CONTINUOUS_WAVE( ); - EU433_SET_CONTINUOUS_WAVE( ); - EU868_SET_CONTINUOUS_WAVE( ); - KR920_SET_CONTINUOUS_WAVE( ); - IN865_SET_CONTINUOUS_WAVE( ); - US915_SET_CONTINUOUS_WAVE( ); - US915_HYBRID_SET_CONTINUOUS_WAVE( ); - default: - { - break; - } + + if(region >= LORAMAC_REGION_MAX) { + return; } + AS923_SET_CONTINUOUS_WAVE( ) + AU915_SET_CONTINUOUS_WAVE( ) + CN470_SET_CONTINUOUS_WAVE( ) + CN779_SET_CONTINUOUS_WAVE( ) + EU433_SET_CONTINUOUS_WAVE( ) + EU868_SET_CONTINUOUS_WAVE( ) + KR920_SET_CONTINUOUS_WAVE( ) + IN865_SET_CONTINUOUS_WAVE( ) + US915_SET_CONTINUOUS_WAVE( ) + US915_HYBRID_SET_CONTINUOUS_WAVE( ) } uint8_t RegionApplyDrOffset( LoRaMacRegion_t region, uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset ) { - switch( region ) - { - AS923_APPLY_DR_OFFSET( ); - AU915_APPLY_DR_OFFSET( ); - CN470_APPLY_DR_OFFSET( ); - CN779_APPLY_DR_OFFSET( ); - EU433_APPLY_DR_OFFSET( ); - EU868_APPLY_DR_OFFSET( ); - KR920_APPLY_DR_OFFSET( ); - IN865_APPLY_DR_OFFSET( ); - US915_APPLY_DR_OFFSET( ); - US915_HYBRID_APPLY_DR_OFFSET( ); - default: - { - return dr; - } + + if(region >= LORAMAC_REGION_MAX) { + return dr; + } + AS923_APPLY_DR_OFFSET( ) + AU915_APPLY_DR_OFFSET( ) + CN470_APPLY_DR_OFFSET( ) + CN779_APPLY_DR_OFFSET( ) + EU433_APPLY_DR_OFFSET( ) + EU868_APPLY_DR_OFFSET( ) + KR920_APPLY_DR_OFFSET( ) + IN865_APPLY_DR_OFFSET( ) + US915_APPLY_DR_OFFSET( ) + US915_HYBRID_APPLY_DR_OFFSET( ) + US915_HYBRID_CHANNEL_REMOVE( ) + else { + return dr; } } bool RegionGetChannels( LoRaMacRegion_t region, ChannelParams_t** channels, uint32_t *size ) { - switch( region ) - { - AS923_GET_CHANNELS( ); - AU915_GET_CHANNELS( ); - EU868_GET_CHANNELS( ); - IN865_GET_CHANNELS( ); - US915_GET_CHANNELS( ); - US915_HYBRID_GET_CHANNELS( ); - default: - { - return false; - } + + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AS923_GET_CHANNELS( ) + AU915_GET_CHANNELS( ) + EU868_GET_CHANNELS( ) + IN865_GET_CHANNELS( ) + US915_GET_CHANNELS( ) + US915_HYBRID_GET_CHANNELS( ) + US915_HYBRID_CHANNEL_REMOVE( ) + else { + return false; } } bool RegionGetChannelMask(LoRaMacRegion_t region, uint16_t **channelmask, uint32_t *size ) { - switch( region ) - { - AS923_GET_CHANNEL_MASK( ); - AU915_GET_CHANNEL_MASK( ); - EU868_GET_CHANNEL_MASK( ); - IN865_GET_CHANNEL_MASK( ); - US915_GET_CHANNEL_MASK( ); - US915_HYBRID_GET_CHANNEL_MASK( ); - default: - { - return false; - } + + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AS923_GET_CHANNEL_MASK( ) + AU915_GET_CHANNEL_MASK( ) + EU868_GET_CHANNEL_MASK( ) + IN865_GET_CHANNEL_MASK( ) + US915_GET_CHANNEL_MASK( ) + US915_HYBRID_GET_CHANNEL_MASK( ) + US915_HYBRID_CHANNEL_REMOVE( ) + else { + return false; } } bool RegionGetChannelMaskRemaining(LoRaMacRegion_t region, uint16_t **channelmask, uint32_t *size ) { - switch( region ) - { - AU915_GET_CHANNEL_MASK_REMAINING( ); - US915_GET_CHANNEL_MASK_REMAINING( ); - US915_HYBRID_GET_CHANNEL_MASK_REMAINING( ); - default: - { - return false; - } + + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AU915_GET_CHANNEL_MASK_REMAINING( ) + US915_GET_CHANNEL_MASK_REMAINING( ) + US915_HYBRID_GET_CHANNEL_MASK_REMAINING( ) + US915_HYBRID_CHANNEL_REMOVE( ) + else { + return false; } } bool RegionForceJoinDataRate( LoRaMacRegion_t region, int8_t joinDr, AlternateDrParams_t* alternateDr ) { - switch( region ) - { - AS923_FORCE_JOIN_DATARATE( ); - AU915_FORCE_JOIN_DATARATE( ); - EU868_FORCE_JOIN_DATARATE( ); - US915_FORCE_JOIN_DATARATE( ); - CN470_FORCE_JOIN_DATARATE( ); - IN865_FORCE_JOIN_DATARATE( ); - US915_HYBRID_FORCE_JOIN_DATARATE( ); - default: - { - return false; - } + + if(region >= LORAMAC_REGION_MAX) { + return false; + } + AS923_FORCE_JOIN_DATARATE( ) + AU915_FORCE_JOIN_DATARATE( ) + EU868_FORCE_JOIN_DATARATE( ) + US915_FORCE_JOIN_DATARATE( ) + CN470_FORCE_JOIN_DATARATE( ) + IN865_FORCE_JOIN_DATARATE( ) + US915_HYBRID_FORCE_JOIN_DATARATE( ) + US915_HYBRID_CHANNEL_REMOVE( ) + else { + return false; } } diff --git a/lib/lora/system/timer.c b/lib/lora/system/timer.c index f4f77554ea..26e6b358de 100644 --- a/lib/lora/system/timer.c +++ b/lib/lora/system/timer.c @@ -228,6 +228,7 @@ IRAM_ATTR void TimerIrqHandler( void ) if( elapsedTimer->Callback != NULL ) { + // Callback will be processed out of the Interrupt context in a Thread modlora_set_timer_callback(elapsedTimer->Callback); } } diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c index 78524035d4..c5fa5ffaec 100644 --- a/lib/utils/pyexec.c +++ b/lib/utils/pyexec.c @@ -43,6 +43,7 @@ #include "lib/utils/pyexec.h" #include "genhdr/mpversion.h" #include "esp32/pycom_version.h" +#include "esp32/pycom_config.h" pyexec_mode_kind_t pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL; int pyexec_system_exit = 0; @@ -421,7 +422,9 @@ int pyexec_friendly_repl(void) { friendly_repl_reset: mp_hal_stdout_tx_str("Pycom MicroPython " SW_VERSION_NUMBER " [" MICROPY_GIT_TAG "] on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n"); #if (VARIANT == PYBYTES) - mp_hal_stdout_tx_str("Pybytes Version: " PYBYTES_VERSION_NUMBER "\r\n"); + if (config_get_pybytes_autostart()) { + mp_hal_stdout_tx_str("Pybytes Version: " PYBYTES_VERSION_NUMBER "\r\n"); + } #endif #if MICROPY_PY_BUILTINS_HELP mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n");