Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5831c36a1 | ||
|
|
2d31dc247c | ||
|
|
b289d89f01 | ||
|
|
1198d5a1b9 | ||
|
|
7635f3df69 | ||
|
|
79d850ebed | ||
|
|
461bf9de7d | ||
|
|
0024a79d2a | ||
|
|
81ebbc389a | ||
|
|
d02e8cbb54 | ||
|
|
47fd60f7ca | ||
|
|
8c53d9534b |
+11
-11
@@ -1,21 +1,21 @@
|
||||
## Contributing to ESP_WiFiManager
|
||||
## Contributing to AsyncHTTPRequest_Generic
|
||||
|
||||
### Reporting Bugs
|
||||
|
||||
Please report bugs in ESP_WiFiManager if you find them.
|
||||
Please report bugs in [AsyncHTTPRequest_Generic](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/new) if you find them.
|
||||
|
||||
However, before reporting a bug please check through the following:
|
||||
|
||||
* [Existing Open Issues](https://github.com/khoih-prog/ESP_WiFiManager/issues) - someone might have already encountered this.
|
||||
* [Existing Open Issues](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues) - someone might have already encountered this.
|
||||
|
||||
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/ESP_WiFiManager/issues/new).
|
||||
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/new).
|
||||
|
||||
### How to submit a bug report
|
||||
|
||||
Please ensure to specify the following:
|
||||
|
||||
* Arduino IDE version (e.g. 1.8.11) or Platform.io version
|
||||
* `ESP8266` or `ESP32` Core Version (e.g. ESP8266 core v2.6.3 or ESP32 v1.0.4)
|
||||
* Arduino IDE version (e.g. 1.8.13) or Platform.io version
|
||||
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v2.7.4, ESP32 v1.0.4 or STM32 v1.9.0)
|
||||
* Contextual information (e.g. what you were trying to achieve)
|
||||
* Simplest possible steps to reproduce
|
||||
* Anything that might be relevant in your opinion, such as:
|
||||
@@ -26,10 +26,10 @@ Please ensure to specify the following:
|
||||
### Example
|
||||
|
||||
```
|
||||
Arduino IDE version: 1.8.11
|
||||
ESP8266 Core Version 2.6.3
|
||||
OS: Ubuntu 16.04 LTS
|
||||
Linux Inspiron 4.4.0-170-generic #199-Ubuntu SMP Thu Nov 14 01:45:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
|
||||
Arduino IDE version: 1.8.13
|
||||
ESP32 Core Version 1.0.4
|
||||
OS: Ubuntu 20.04 LTS
|
||||
Linux xy-Inspiron-3593 5.4.0-51-generic #56-Ubuntu SMP Mon Oct 5 14:28:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
|
||||
|
||||
Context:
|
||||
I encountered an endless loop while trying to connect to Local WiFi.
|
||||
@@ -44,7 +44,7 @@ Steps to reproduce:
|
||||
|
||||
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
|
||||
|
||||
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/ESP_WiFiManager/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
|
||||
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
|
||||
|
||||
### Sending Pull Requests
|
||||
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
# Arduino SAMD Core and platform.
|
||||
#
|
||||
# For more info:
|
||||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
|
||||
name=Seeed SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards
|
||||
version=1.7.9
|
||||
|
||||
# Compile variables
|
||||
# -----------------
|
||||
|
||||
compiler.warning_flags=-w
|
||||
compiler.warning_flags.none=-w
|
||||
compiler.warning_flags.default=
|
||||
compiler.warning_flags.more=-Wall -Wno-expansion-to-defined
|
||||
compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined
|
||||
|
||||
compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
|
||||
compiler.c.cmd=arm-none-eabi-gcc
|
||||
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}"""
|
||||
compiler.c.elf.cmd=arm-none-eabi-g++
|
||||
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
|
||||
compiler.S.cmd=arm-none-eabi-gcc
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
|
||||
compiler.cpp.cmd=arm-none-eabi-g++
|
||||
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++14 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}"""
|
||||
compiler.ar.cmd=arm-none-eabi-ar
|
||||
compiler.ar.flags=rcs
|
||||
compiler.objcopy.cmd=arm-none-eabi-objcopy
|
||||
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
|
||||
compiler.elf2hex.bin.flags=-O binary
|
||||
compiler.elf2hex.hex.flags=-O ihex -R .eeprom
|
||||
compiler.elf2hex.cmd=arm-none-eabi-objcopy
|
||||
compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -u _printf_float -u _scanf_float -Wl,--wrap,_write -u __wrap__write
|
||||
compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
build.extra_flags=
|
||||
build.project_flags=
|
||||
build.cache_flags=
|
||||
build.flags.optimize=
|
||||
build.flags.maxspi=
|
||||
build.flags.maxqspi=
|
||||
build.flags.usbstack=
|
||||
build.flags.debug=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
compiler.c.extra_flags=
|
||||
compiler.c.elf.extra_flags=
|
||||
#compiler.c.elf.extra_flags=-v
|
||||
compiler.cpp.extra_flags=
|
||||
compiler.S.extra_flags=
|
||||
compiler.ar.extra_flags=
|
||||
compiler.elf2hex.extra_flags=
|
||||
|
||||
compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.1.path}/CMSIS-Atmel/CMSIS/Device/ATMEL/"
|
||||
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math
|
||||
|
||||
compiler.libraries.ldflags=
|
||||
|
||||
# USB Flags
|
||||
# ---------
|
||||
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
|
||||
|
||||
# Default advertised device power setting in mA
|
||||
build.usb_power=100
|
||||
|
||||
# Default usb manufacturer will be replaced at compile time using
|
||||
# numeric vendor ID if available or by board's specific value.
|
||||
build.usb_manufacturer="Unknown"
|
||||
|
||||
|
||||
# Compile patterns
|
||||
# ----------------
|
||||
|
||||
## Compile c files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile c++ files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile S files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Create archives
|
||||
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
|
||||
archive_file_path={build.path}/{archive_file}
|
||||
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
|
||||
|
||||
## Combine gc-sections, archives, and objects
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group
|
||||
|
||||
## Create output (bin file)
|
||||
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
|
||||
|
||||
## Create output (hex file)
|
||||
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
|
||||
|
||||
build.preferred_out_format=bin
|
||||
|
||||
## Save hex
|
||||
recipe.output.tmp_file={build.project_name}.{build.preferred_out_format}
|
||||
recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format}
|
||||
|
||||
## Compute size
|
||||
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
|
||||
recipe.size.regex=\.text\s+([0-9]+).*
|
||||
|
||||
#
|
||||
# BOSSA
|
||||
#
|
||||
tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path}
|
||||
tools.bossac.cmd=bossac
|
||||
tools.bossac.cmd.windows=bossac.exe
|
||||
|
||||
tools.bossac.upload.params.verbose=-i -d
|
||||
tools.bossac.upload.params.quiet=
|
||||
tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R
|
||||
|
||||
tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
|
||||
|
||||
tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
# v1.8.0
|
||||
|
||||
tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path}
|
||||
tools.bossac18.cmd=bossac
|
||||
|
||||
tools.bossac18.upload.params.verbose=-i -d
|
||||
tools.bossac18.upload.params.quiet=
|
||||
tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R
|
||||
|
||||
tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
#
|
||||
# BOSSA (ignore binary size)
|
||||
#
|
||||
tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path}
|
||||
tools.bossacI.cmd=bossac
|
||||
tools.bossacI.cmd.windows=bossac.exe
|
||||
|
||||
tools.bossacI.upload.params.verbose=-i -d
|
||||
tools.bossacI.upload.params.quiet=
|
||||
tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R
|
||||
|
||||
tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
|
||||
|
||||
tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
|
||||
#
|
||||
# OpenOCD sketch upload
|
||||
#
|
||||
|
||||
tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}
|
||||
tools.openocd.cmd=bin/openocd
|
||||
tools.openocd.cmd.windows=bin/openocd.exe
|
||||
|
||||
tools.openocd.upload.params.verbose=-d2
|
||||
tools.openocd.upload.params.quiet=-d0
|
||||
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
|
||||
|
||||
tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
|
||||
tools.openocd.program.params.verbose=-d2
|
||||
tools.openocd.program.params.quiet=-d0
|
||||
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
|
||||
|
||||
tools.openocd.erase.params.verbose=-d3
|
||||
tools.openocd.erase.params.quiet=-d0
|
||||
tools.openocd.erase.pattern=
|
||||
|
||||
tools.openocd.bootloader.params.verbose=-d2
|
||||
tools.openocd.bootloader.params.quiet=-d0
|
||||
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
|
||||
|
||||
#
|
||||
# OpenOCD sketch upload - version with configurable bootloader size
|
||||
# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences
|
||||
#
|
||||
|
||||
tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path}
|
||||
tools.openocd-withbootsize.cmd=bin/openocd
|
||||
tools.openocd-withbootsize.cmd.windows=bin/openocd.exe
|
||||
|
||||
tools.openocd-withbootsize.upload.params.verbose=-d2
|
||||
tools.openocd-withbootsize.upload.params.quiet=-d0
|
||||
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
|
||||
|
||||
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
|
||||
tools.openocd-withbootsize.program.params.verbose=-d2
|
||||
tools.openocd-withbootsize.program.params.quiet=-d0
|
||||
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
|
||||
|
||||
tools.openocd-withbootsize.erase.params.verbose=-d3
|
||||
tools.openocd-withbootsize.erase.params.quiet=-d0
|
||||
tools.openocd-withbootsize.erase.pattern=
|
||||
|
||||
tools.openocd-withbootsize.bootloader.params.verbose=-d2
|
||||
tools.openocd-withbootsize.bootloader.params.quiet=-d0
|
||||
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
|
||||
@@ -0,0 +1,204 @@
|
||||
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
# Arduino SAMD Core and platform.
|
||||
#
|
||||
# For more info:
|
||||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
|
||||
name=Seeed SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards
|
||||
version=1.8.1
|
||||
|
||||
# Compile variables
|
||||
# -----------------
|
||||
|
||||
compiler.warning_flags=-w
|
||||
compiler.warning_flags.none=-w
|
||||
compiler.warning_flags.default=
|
||||
compiler.warning_flags.more=-Wall -Wno-expansion-to-defined
|
||||
compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined
|
||||
|
||||
compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
|
||||
compiler.c.cmd=arm-none-eabi-gcc
|
||||
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}"""
|
||||
compiler.c.elf.cmd=arm-none-eabi-g++
|
||||
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
|
||||
compiler.S.cmd=arm-none-eabi-gcc
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
|
||||
compiler.cpp.cmd=arm-none-eabi-g++
|
||||
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++14 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}"""
|
||||
compiler.ar.cmd=arm-none-eabi-ar
|
||||
compiler.ar.flags=rcs
|
||||
compiler.objcopy.cmd=arm-none-eabi-objcopy
|
||||
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
|
||||
compiler.elf2hex.bin.flags=-O binary
|
||||
compiler.elf2hex.hex.flags=-O ihex -R .eeprom
|
||||
compiler.elf2hex.cmd=arm-none-eabi-objcopy
|
||||
compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -u _printf_float -u _scanf_float -Wl,--wrap,_write -u __wrap__write
|
||||
compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
build.extra_flags=
|
||||
build.project_flags=
|
||||
build.cache_flags=
|
||||
build.flags.optimize=
|
||||
build.flags.maxspi=
|
||||
build.flags.maxqspi=
|
||||
build.flags.usbstack=
|
||||
build.flags.debug=
|
||||
build.flags.txrxled=
|
||||
build.flags.role=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
compiler.c.extra_flags=
|
||||
compiler.c.elf.extra_flags=
|
||||
#compiler.c.elf.extra_flags=-v
|
||||
compiler.cpp.extra_flags=
|
||||
compiler.S.extra_flags=
|
||||
compiler.ar.extra_flags=
|
||||
compiler.elf2hex.extra_flags=
|
||||
|
||||
compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.1.path}/CMSIS-Atmel/CMSIS/Device/ATMEL/"
|
||||
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math
|
||||
|
||||
compiler.libraries.ldflags=
|
||||
|
||||
# USB Flags
|
||||
# ---------
|
||||
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} {build.flags.role} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
|
||||
|
||||
# Default advertised device power setting in mA
|
||||
build.usb_power=100
|
||||
|
||||
# Default usb manufacturer will be replaced at compile time using
|
||||
# numeric vendor ID if available or by board's specific value.
|
||||
build.usb_manufacturer="Unknown"
|
||||
|
||||
|
||||
# Compile patterns
|
||||
# ----------------
|
||||
|
||||
## Compile c files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.txrxled} {build.flags.role} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile c++ files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {build.flags.debug} {build.flags.txrxled} {build.flags.role} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {build.project_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile S files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.project_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Create archives
|
||||
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
|
||||
archive_file_path={build.path}/{archive_file}
|
||||
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
|
||||
|
||||
## Combine gc-sections, archives, and objects
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group
|
||||
|
||||
## Create output (bin file)
|
||||
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
|
||||
|
||||
## Create output (hex file)
|
||||
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
|
||||
|
||||
build.preferred_out_format=bin
|
||||
|
||||
## Save hex
|
||||
recipe.output.tmp_file={build.project_name}.{build.preferred_out_format}
|
||||
recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format}
|
||||
|
||||
## Compute size
|
||||
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
|
||||
recipe.size.regex=\.text\s+([0-9]+).*
|
||||
|
||||
#
|
||||
# BOSSA
|
||||
#
|
||||
tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path}
|
||||
tools.bossac.cmd=bossac
|
||||
tools.bossac.cmd.windows=bossac.exe
|
||||
tools.bossac.upload.params.verbose=-i -d
|
||||
tools.bossac.upload.params.quiet=
|
||||
tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R
|
||||
tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
|
||||
tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
# v1.8.0
|
||||
tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path}
|
||||
tools.bossac18.cmd=bossac
|
||||
tools.bossac18.upload.params.verbose=-i -d
|
||||
tools.bossac18.upload.params.quiet=
|
||||
tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R
|
||||
tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
#
|
||||
# BOSSA (ignore binary size)
|
||||
#
|
||||
tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path}
|
||||
tools.bossacI.cmd=bossac
|
||||
tools.bossacI.cmd.windows=bossac.exe
|
||||
tools.bossacI.upload.params.verbose=-i -d
|
||||
tools.bossacI.upload.params.quiet=
|
||||
tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R
|
||||
tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
|
||||
tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
#
|
||||
# OpenOCD sketch upload
|
||||
#
|
||||
tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}
|
||||
tools.openocd.cmd=bin/openocd
|
||||
tools.openocd.cmd.windows=bin/openocd.exe
|
||||
tools.openocd.upload.params.verbose=-d2
|
||||
tools.openocd.upload.params.quiet=-d0
|
||||
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
|
||||
tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
|
||||
tools.openocd.program.params.verbose=-d2
|
||||
tools.openocd.program.params.quiet=-d0
|
||||
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
|
||||
tools.openocd.erase.params.verbose=-d3
|
||||
tools.openocd.erase.params.quiet=-d0
|
||||
tools.openocd.erase.pattern=
|
||||
tools.openocd.bootloader.params.verbose=-d2
|
||||
tools.openocd.bootloader.params.quiet=-d0
|
||||
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
|
||||
#
|
||||
# OpenOCD sketch upload - version with configurable bootloader size
|
||||
# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences
|
||||
#
|
||||
tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path}
|
||||
tools.openocd-withbootsize.cmd=bin/openocd
|
||||
tools.openocd-withbootsize.cmd.windows=bin/openocd.exe
|
||||
tools.openocd-withbootsize.upload.params.verbose=-d2
|
||||
tools.openocd-withbootsize.upload.params.quiet=-d0
|
||||
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
|
||||
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
|
||||
tools.openocd-withbootsize.program.params.verbose=-d2
|
||||
tools.openocd-withbootsize.program.params.quiet=-d0
|
||||
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
|
||||
tools.openocd-withbootsize.erase.params.verbose=-d3
|
||||
tools.openocd-withbootsize.erase.params.quiet=-d0
|
||||
tools.openocd-withbootsize.erase.pattern=
|
||||
tools.openocd-withbootsize.bootloader.params.verbose=-d2
|
||||
tools.openocd-withbootsize.bootloader.params.quiet=-d0
|
||||
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
|
||||
@@ -0,0 +1,649 @@
|
||||
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
# Copyright (c) 2016 Sandeep Mistry All right reserved.
|
||||
# Copyright (c) 2017 Adafruit Industries. All right reserved.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
menu.softdevice=Bootloader
|
||||
menu.debug=Debug
|
||||
|
||||
# ----------------------------------
|
||||
# Bluefruit Feather nRF52832
|
||||
# ----------------------------------
|
||||
feather52832.name=Adafruit Feather nRF52832
|
||||
feather52832.bootloader.tool=bootburn
|
||||
|
||||
# Upload
|
||||
feather52832.upload.tool=nrfutil
|
||||
feather52832.upload.protocol=nrfutil
|
||||
feather52832.upload.use_1200bps_touch=false
|
||||
feather52832.upload.wait_for_upload_port=false
|
||||
feather52832.upload.native_usb=false
|
||||
feather52832.upload.maximum_size=290816
|
||||
feather52832.upload.maximum_data_size=52224
|
||||
|
||||
# Build
|
||||
feather52832.build.mcu=cortex-m4
|
||||
feather52832.build.f_cpu=64000000
|
||||
feather52832.build.board=NRF52832_FEATHER
|
||||
feather52832.build.core=nRF5
|
||||
feather52832.build.variant=feather_nrf52832
|
||||
feather52832.build.usb_manufacturer="Adafruit LLC"
|
||||
feather52832.build.usb_product="Feather nRF52832"
|
||||
feather52832.build.extra_flags=-DNRF52832_XXAA -DNRF52
|
||||
feather52832.build.ldscript=nrf52832_s132_v6.ld
|
||||
|
||||
# SofDevice Menu
|
||||
feather52832.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1
|
||||
feather52832.menu.softdevice.s132v6.build.sd_name=s132
|
||||
feather52832.menu.softdevice.s132v6.build.sd_version=6.1.1
|
||||
feather52832.menu.softdevice.s132v6.build.sd_fwid=0x00B7
|
||||
|
||||
# Debug Menu
|
||||
feather52832.menu.debug.l0=Level 0 (Release)
|
||||
feather52832.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
feather52832.menu.debug.l1=Level 1 (Error Message)
|
||||
feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
feather52832.menu.debug.l2=Level 2 (Full Debug)
|
||||
feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
feather52832.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
feather52832.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# ----------------------------------
|
||||
# Bluefruit Feather nRF52840 Express
|
||||
# ----------------------------------
|
||||
feather52840.name=Adafruit Feather nRF52840 Express
|
||||
|
||||
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
|
||||
feather52840.vid.0=0x239A
|
||||
feather52840.pid.0=0x8029
|
||||
feather52840.vid.1=0x239A
|
||||
feather52840.pid.1=0x0029
|
||||
feather52840.vid.2=0x239A
|
||||
feather52840.pid.2=0x002A
|
||||
feather52840.vid.3=0x239A
|
||||
feather52840.pid.3=0x802A
|
||||
|
||||
# Upload
|
||||
feather52840.bootloader.tool=bootburn
|
||||
feather52840.upload.tool=nrfutil
|
||||
feather52840.upload.protocol=nrfutil
|
||||
feather52840.upload.use_1200bps_touch=true
|
||||
feather52840.upload.wait_for_upload_port=true
|
||||
feather52840.upload.maximum_size=815104
|
||||
feather52840.upload.maximum_data_size=237568
|
||||
|
||||
# Build
|
||||
feather52840.build.mcu=cortex-m4
|
||||
feather52840.build.f_cpu=64000000
|
||||
feather52840.build.board=NRF52840_FEATHER
|
||||
feather52840.build.core=nRF5
|
||||
feather52840.build.variant=feather_nrf52840_express
|
||||
feather52840.build.usb_manufacturer="Adafruit LLC"
|
||||
feather52840.build.usb_product="Feather nRF52840 Express"
|
||||
feather52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
feather52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
feather52840.build.vid=0x239A
|
||||
feather52840.build.pid=0x8029
|
||||
|
||||
# SofDevice Menu
|
||||
feather52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1
|
||||
feather52840.menu.softdevice.s140v6.build.sd_name=s140
|
||||
feather52840.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
feather52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
feather52840.menu.debug.l0=Level 0 (Release)
|
||||
feather52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
feather52840.menu.debug.l1=Level 1 (Error Message)
|
||||
feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
feather52840.menu.debug.l2=Level 2 (Full Debug)
|
||||
feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
feather52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
|
||||
# ----------------------------------
|
||||
# Feather Bluefruit sense
|
||||
# ----------------------------------
|
||||
feather52840sense.name=Adafruit Feather Bluefruit Sense
|
||||
|
||||
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
|
||||
feather52840sense.vid.0=0x239A
|
||||
feather52840sense.pid.0=0x8087
|
||||
feather52840sense.vid.1=0x239A
|
||||
feather52840sense.pid.1=0x0087
|
||||
feather52840sense.vid.2=0x239A
|
||||
feather52840sense.pid.2=0x0088
|
||||
feather52840sense.vid.3=0x239A
|
||||
feather52840sense.pid.3=0x8088
|
||||
|
||||
# Upload
|
||||
feather52840sense.bootloader.tool=bootburn
|
||||
feather52840sense.upload.tool=nrfutil
|
||||
feather52840sense.upload.protocol=nrfutil
|
||||
feather52840sense.upload.use_1200bps_touch=true
|
||||
feather52840sense.upload.wait_for_upload_port=true
|
||||
feather52840sense.upload.maximum_size=815104
|
||||
feather52840sense.upload.maximum_data_size=237568
|
||||
|
||||
# Build
|
||||
feather52840sense.build.mcu=cortex-m4
|
||||
feather52840sense.build.f_cpu=64000000
|
||||
feather52840sense.build.board=NRF52840_FEATHER_SENSE
|
||||
feather52840sense.build.core=nRF5
|
||||
feather52840sense.build.variant=feather_nrf52840_sense
|
||||
feather52840sense.build.usb_manufacturer="Adafruit LLC"
|
||||
feather52840sense.build.usb_product="Feather nRF52840 Sense"
|
||||
feather52840sense.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
feather52840sense.build.ldscript=nrf52840_s140_v6.ld
|
||||
feather52840sense.build.vid=0x239A
|
||||
feather52840sense.build.pid=0x8087
|
||||
|
||||
# SofDevice Menu
|
||||
feather52840sense.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1
|
||||
feather52840sense.menu.softdevice.s140v6.build.sd_name=s140
|
||||
feather52840sense.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
feather52840sense.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
feather52840sense.menu.debug.l0=Level 0 (Release)
|
||||
feather52840sense.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
feather52840sense.menu.debug.l1=Level 1 (Error Message)
|
||||
feather52840sense.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
feather52840sense.menu.debug.l2=Level 2 (Full Debug)
|
||||
feather52840sense.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
feather52840sense.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
feather52840sense.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
feather52840sense.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
|
||||
# ---------------------------------------------
|
||||
# Bluefruit ItsyBitsy nRF52840 Express
|
||||
# ---------------------------------------------
|
||||
itsybitsy52840.name=Adafruit ItsyBitsy nRF52840 Express
|
||||
|
||||
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
|
||||
itsybitsy52840.vid.0=0x239A
|
||||
itsybitsy52840.pid.0=0x8051
|
||||
itsybitsy52840.vid.1=0x239A
|
||||
itsybitsy52840.pid.1=0x0051
|
||||
itsybitsy52840.vid.2=0x239A
|
||||
itsybitsy52840.pid.2=0x0052
|
||||
itsybitsy52840.vid.3=0x239A
|
||||
itsybitsy52840.pid.3=0x8052
|
||||
|
||||
# Upload
|
||||
itsybitsy52840.bootloader.tool=bootburn
|
||||
itsybitsy52840.upload.tool=nrfutil
|
||||
itsybitsy52840.upload.protocol=nrfutil
|
||||
itsybitsy52840.upload.use_1200bps_touch=true
|
||||
itsybitsy52840.upload.wait_for_upload_port=true
|
||||
itsybitsy52840.upload.maximum_size=815104
|
||||
itsybitsy52840.upload.maximum_data_size=237568
|
||||
|
||||
# Build
|
||||
itsybitsy52840.build.mcu=cortex-m4
|
||||
itsybitsy52840.build.f_cpu=64000000
|
||||
itsybitsy52840.build.board=NRF52840_ITSYBITSY
|
||||
itsybitsy52840.build.core=nRF5
|
||||
itsybitsy52840.build.variant=itsybitsy_nrf52840_express
|
||||
itsybitsy52840.build.usb_manufacturer="Adafruit LLC"
|
||||
itsybitsy52840.build.usb_product="ItsyBitsy nRF52840 Express"
|
||||
itsybitsy52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52_ITSYBITSY {build.flags.usb}
|
||||
itsybitsy52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
itsybitsy52840.build.vid=0x239A
|
||||
itsybitsy52840.build.pid=0x8051
|
||||
|
||||
# SofDevice Menu
|
||||
itsybitsy52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1
|
||||
itsybitsy52840.menu.softdevice.s140v6.build.sd_name=s140
|
||||
itsybitsy52840.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
itsybitsy52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
itsybitsy52840.menu.debug.l0=Level 0 (Release)
|
||||
itsybitsy52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
itsybitsy52840.menu.debug.l1=Level 1 (Error Message)
|
||||
itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
itsybitsy52840.menu.debug.l2=Level 2 (Full Debug)
|
||||
itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
itsybitsy52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# ---------------------------------------------
|
||||
# Bluefruit Circuit Playground nRF52840 Express
|
||||
# ---------------------------------------------
|
||||
cplaynrf52840.name=Adafruit Circuit Playground Bluefruit
|
||||
|
||||
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
|
||||
cplaynrf52840.vid.0=0x239A
|
||||
cplaynrf52840.pid.0=0x8045
|
||||
cplaynrf52840.vid.1=0x239A
|
||||
cplaynrf52840.pid.1=0x0045
|
||||
cplaynrf52840.vid.2=0x239A
|
||||
cplaynrf52840.pid.2=0x0046
|
||||
cplaynrf52840.vid.3=0x239A
|
||||
cplaynrf52840.pid.3=0x8046
|
||||
|
||||
# Upload
|
||||
cplaynrf52840.bootloader.tool=bootburn
|
||||
cplaynrf52840.upload.tool=nrfutil
|
||||
cplaynrf52840.upload.protocol=nrfutil
|
||||
cplaynrf52840.upload.use_1200bps_touch=true
|
||||
cplaynrf52840.upload.wait_for_upload_port=true
|
||||
cplaynrf52840.upload.maximum_size=815104
|
||||
cplaynrf52840.upload.maximum_data_size=237568
|
||||
|
||||
# Build
|
||||
cplaynrf52840.build.mcu=cortex-m4
|
||||
cplaynrf52840.build.f_cpu=64000000
|
||||
cplaynrf52840.build.board=NRF52840_CIRCUITPLAY
|
||||
cplaynrf52840.build.core=nRF5
|
||||
cplaynrf52840.build.variant=circuitplayground_nrf52840
|
||||
cplaynrf52840.build.usb_manufacturer="Adafruit LLC"
|
||||
cplaynrf52840.build.usb_product="Circuit Playground Bluefruit"
|
||||
cplaynrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
cplaynrf52840.build.vid=0x239A
|
||||
cplaynrf52840.build.pid=0x8045
|
||||
|
||||
# SofDevice Menu
|
||||
cplaynrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1
|
||||
cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140
|
||||
cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
cplaynrf52840.menu.debug.l0=Level 0 (Release)
|
||||
cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
cplaynrf52840.menu.debug.l1=Level 1 (Error Message)
|
||||
cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
cplaynrf52840.menu.debug.l2=Level 2 (Full Debug)
|
||||
cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
cplaynrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
|
||||
# ---------------------------------------------
|
||||
# Clue nRF52840
|
||||
# ---------------------------------------------
|
||||
cluenrf52840.name=Adafruit CLUE
|
||||
|
||||
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
|
||||
cluenrf52840.vid.0=0x239A
|
||||
cluenrf52840.pid.0=0x8072
|
||||
cluenrf52840.vid.1=0x239A
|
||||
cluenrf52840.pid.1=0x0072
|
||||
cluenrf52840.vid.2=0x239A
|
||||
cluenrf52840.pid.2=0x0071
|
||||
cluenrf52840.vid.3=0x239A
|
||||
cluenrf52840.pid.3=0x8071
|
||||
|
||||
# Upload
|
||||
cluenrf52840.bootloader.tool=bootburn
|
||||
cluenrf52840.upload.tool=nrfutil
|
||||
cluenrf52840.upload.protocol=nrfutil
|
||||
cluenrf52840.upload.use_1200bps_touch=true
|
||||
cluenrf52840.upload.wait_for_upload_port=true
|
||||
cluenrf52840.upload.maximum_size=815104
|
||||
cluenrf52840.upload.maximum_data_size=237568
|
||||
|
||||
# Build
|
||||
cluenrf52840.build.mcu=cortex-m4
|
||||
cluenrf52840.build.f_cpu=64000000
|
||||
cluenrf52840.build.board=NRF52840_CLUE
|
||||
cluenrf52840.build.core=nRF5
|
||||
cluenrf52840.build.variant=clue_nrf52840
|
||||
cluenrf52840.build.usb_manufacturer="Adafruit LLC"
|
||||
cluenrf52840.build.usb_product="CLUE"
|
||||
cluenrf52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
cluenrf52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
cluenrf52840.build.vid=0x239A
|
||||
cluenrf52840.build.pid=0x8071
|
||||
|
||||
# SofDevice Menu
|
||||
cluenrf52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1
|
||||
cluenrf52840.menu.softdevice.s140v6.build.sd_name=s140
|
||||
cluenrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
cluenrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
cluenrf52840.menu.debug.l0=Level 0 (Release)
|
||||
cluenrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
cluenrf52840.menu.debug.l1=Level 1 (Error Message)
|
||||
cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
cluenrf52840.menu.debug.l2=Level 2 (Full Debug)
|
||||
cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
cluenrf52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# ----------------------------------
|
||||
# Bluefruit Metro nRF52840 Express
|
||||
# ----------------------------------
|
||||
metro52840.name=Adafruit Bluefruit Metro nRF52840 Express
|
||||
|
||||
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
|
||||
metro52840.vid.0=0x239A
|
||||
metro52840.pid.0=0x803F
|
||||
metro52840.vid.1=0x239A
|
||||
metro52840.pid.1=0x003F
|
||||
metro52840.vid.2=0x239A
|
||||
metro52840.pid.2=0x0040
|
||||
metro52840.vid.3=0x239A
|
||||
metro52840.pid.3=0x8040
|
||||
|
||||
# Upload
|
||||
metro52840.bootloader.tool=bootburn
|
||||
metro52840.upload.tool=nrfutil
|
||||
metro52840.upload.protocol=nrfutil
|
||||
metro52840.upload.use_1200bps_touch=true
|
||||
metro52840.upload.wait_for_upload_port=true
|
||||
metro52840.upload.maximum_size=815104
|
||||
metro52840.upload.maximum_data_size=237568
|
||||
|
||||
# Build
|
||||
metro52840.build.mcu=cortex-m4
|
||||
metro52840.build.f_cpu=64000000
|
||||
metro52840.build.board=NRF52840_METRO
|
||||
metro52840.build.core=nRF5
|
||||
metro52840.build.variant=metro_nrf52840_express
|
||||
metro52840.build.usb_manufacturer="Adafruit LLC"
|
||||
metro52840.build.usb_product="Metro nRF52840 Express"
|
||||
metro52840.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
metro52840.build.ldscript=nrf52840_s140_v6.ld
|
||||
metro52840.build.vid=0x239A
|
||||
metro52840.build.pid=0x803F
|
||||
|
||||
# SofDevice Menu
|
||||
metro52840.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1
|
||||
metro52840.menu.softdevice.s140v6.build.sd_name=s140
|
||||
metro52840.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
metro52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
metro52840.menu.debug.l0=Level 0 (Release)
|
||||
metro52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
metro52840.menu.debug.l1=Level 1 (Error Message)
|
||||
metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
metro52840.menu.debug.l2=Level 2 (Full Debug)
|
||||
metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
metro52840.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
metro52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
|
||||
|
||||
|
||||
# -------------------------------------------------------
|
||||
#
|
||||
# Boards that aren't made by Adafruit
|
||||
#
|
||||
# -------------------------------------------------------
|
||||
|
||||
|
||||
# ----------------------------------
|
||||
# Nordic nRF52840DK (PCA10056)
|
||||
# ----------------------------------
|
||||
pca10056.name=Nordic nRF52840DK (PCA10056)
|
||||
pca10056.bootloader.tool=bootburn
|
||||
|
||||
# Upload
|
||||
pca10056.upload.tool=nrfutil
|
||||
pca10056.upload.protocol=nrfutil
|
||||
pca10056.upload.use_1200bps_touch=true
|
||||
pca10056.upload.wait_for_upload_port=true
|
||||
pca10056.upload.maximum_size=815104
|
||||
pca10056.upload.maximum_data_size=237568
|
||||
|
||||
# Build
|
||||
pca10056.build.mcu=cortex-m4
|
||||
pca10056.build.f_cpu=64000000
|
||||
pca10056.build.board=NRF52840_PCA10056
|
||||
pca10056.build.core=nRF5
|
||||
pca10056.build.variant=pca10056
|
||||
pca10056.build.usb_manufacturer="Nordic"
|
||||
pca10056.build.usb_product="nRF52840 DK"
|
||||
pca10056.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
pca10056.build.ldscript=nrf52840_s140_v6.ld
|
||||
pca10056.build.vid=0x239A
|
||||
pca10056.build.pid=0x8029
|
||||
|
||||
# SofDevice Menu
|
||||
pca10056.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1
|
||||
pca10056.menu.softdevice.s140v6.build.sd_name=s140
|
||||
pca10056.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
pca10056.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
pca10056.menu.debug.l0=Level 0 (Release)
|
||||
pca10056.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
pca10056.menu.debug.l1=Level 1 (Error Message)
|
||||
pca10056.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
pca10056.menu.debug.l2=Level 2 (Full Debug)
|
||||
pca10056.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
pca10056.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
pca10056.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
pca10056.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# ----------------------------------
|
||||
# Particle Xenon
|
||||
# ----------------------------------
|
||||
particle_xenon.name=Particle Xenon
|
||||
|
||||
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
|
||||
particle_xenon.vid.0=0x239A
|
||||
particle_xenon.pid.0=0x8029
|
||||
particle_xenon.vid.1=0x239A
|
||||
particle_xenon.pid.1=0x0029
|
||||
particle_xenon.vid.2=0x239A
|
||||
particle_xenon.pid.2=0x002A
|
||||
particle_xenon.vid.3=0x239A
|
||||
particle_xenon.pid.3=0x802A
|
||||
|
||||
# Upload
|
||||
particle_xenon.bootloader.tool=bootburn
|
||||
particle_xenon.upload.tool=nrfutil
|
||||
particle_xenon.upload.protocol=nrfutil
|
||||
particle_xenon.upload.use_1200bps_touch=true
|
||||
particle_xenon.upload.wait_for_upload_port=true
|
||||
particle_xenon.upload.maximum_size=815104
|
||||
particle_xenon.upload.maximum_data_size=237568
|
||||
|
||||
# Build
|
||||
particle_xenon.build.mcu=cortex-m4
|
||||
particle_xenon.build.f_cpu=64000000
|
||||
particle_xenon.build.board=PARTICLE_XENON
|
||||
particle_xenon.build.core=nRF5
|
||||
particle_xenon.build.variant=particle_xenon
|
||||
particle_xenon.build.usb_manufacturer="Particle Industries"
|
||||
particle_xenon.build.usb_product="Particle Xenon"
|
||||
particle_xenon.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
particle_xenon.build.ldscript=nrf52840_s140_v6.ld
|
||||
particle_xenon.build.vid=0x239A
|
||||
particle_xenon.build.pid=0x8029
|
||||
|
||||
# SofDevice Menu
|
||||
particle_xenon.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1
|
||||
particle_xenon.menu.softdevice.s140v6.build.sd_name=s140
|
||||
particle_xenon.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
particle_xenon.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
particle_xenon.menu.debug.l0=Level 0 (Release)
|
||||
particle_xenon.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
particle_xenon.menu.debug.l1=Level 1 (Error Message)
|
||||
particle_xenon.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
particle_xenon.menu.debug.l2=Level 2 (Full Debug)
|
||||
particle_xenon.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
particle_xenon.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
particle_xenon.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
particle_xenon.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# ----------------------------------
|
||||
# Raytac MDBT50Q - RX
|
||||
# ----------------------------------
|
||||
mdbt50qrx.name=Raytac MDBT50Q-RX Dongle
|
||||
|
||||
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
|
||||
mdbt50qrx.vid.0=0x239A
|
||||
mdbt50qrx.pid.0=0x8029
|
||||
mdbt50qrx.vid.1=0x239A
|
||||
mdbt50qrx.pid.1=0x0029
|
||||
mdbt50qrx.vid.2=0x239A
|
||||
mdbt50qrx.pid.2=0x002A
|
||||
mdbt50qrx.vid.3=0x239A
|
||||
mdbt50qrx.pid.3=0x802A
|
||||
|
||||
# Upload
|
||||
mdbt50qrx.bootloader.tool=bootburn
|
||||
mdbt50qrx.upload.tool=nrfutil
|
||||
mdbt50qrx.upload.protocol=nrfutil
|
||||
mdbt50qrx.upload.use_1200bps_touch=true
|
||||
mdbt50qrx.upload.wait_for_upload_port=true
|
||||
mdbt50qrx.upload.maximum_size=815104
|
||||
mdbt50qrx.upload.maximum_data_size=237568
|
||||
|
||||
# Build
|
||||
mdbt50qrx.build.mcu=cortex-m4
|
||||
mdbt50qrx.build.f_cpu=64000000
|
||||
mdbt50qrx.build.board=MDBT50Q_RX
|
||||
mdbt50qrx.build.core=nRF5
|
||||
mdbt50qrx.build.variant=raytac_mdbt50q_rx
|
||||
mdbt50qrx.build.usb_manufacturer="Raytac Corporation"
|
||||
mdbt50qrx.build.usb_product="Raytac MDBT50Q - RX"
|
||||
mdbt50qrx.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
|
||||
mdbt50qrx.build.ldscript=nrf52840_s140_v6.ld
|
||||
mdbt50qrx.build.vid=0x239A
|
||||
mdbt50qrx.build.pid=0x8029
|
||||
|
||||
# SofDevice Menu
|
||||
mdbt50qrx.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1
|
||||
mdbt50qrx.menu.softdevice.s140v6.build.sd_name=s140
|
||||
mdbt50qrx.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
mdbt50qrx.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
mdbt50qrx.menu.debug.l0=Level 0 (Release)
|
||||
mdbt50qrx.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
mdbt50qrx.menu.debug.l1=Level 1 (Error Message)
|
||||
mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
mdbt50qrx.menu.debug.l2=Level 2 (Full Debug)
|
||||
mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
mdbt50qrx.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# ----------------------------------
|
||||
# NINA B302
|
||||
# ----------------------------------
|
||||
ninab302.name=NINA B302 ublox
|
||||
|
||||
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
|
||||
ninab302.vid.0=0x239A
|
||||
ninab302.pid.0=0x8029
|
||||
ninab302.vid.1=0x239A
|
||||
ninab302.pid.1=0x0029
|
||||
ninab302.vid.2=0x7239A
|
||||
ninab302.pid.2=0x002A
|
||||
ninab302.vid.3=0x239A
|
||||
ninab302.pid.3=0x802A
|
||||
|
||||
# Upload
|
||||
ninab302.bootloader.tool=bootburn
|
||||
ninab302.upload.tool=nrfutil
|
||||
ninab302.upload.protocol=nrfutil
|
||||
ninab302.upload.use_1200bps_touch=true
|
||||
ninab302.upload.wait_for_upload_port=true
|
||||
ninab302.upload.maximum_size=815104
|
||||
ninab302.upload.maximum_data_size=237568
|
||||
|
||||
# Build
|
||||
ninab302.build.mcu=cortex-m4
|
||||
ninab302.build.f_cpu=64000000
|
||||
ninab302.build.board=NINA_B302_ublox
|
||||
ninab302.build.core=nRF5
|
||||
ninab302.build.variant=NINA_B302_ublox
|
||||
ninab302.build.usb_manufacturer="Nordic"
|
||||
ninab302.build.usb_product="NINA B302 ublox"
|
||||
ninab302.build.extra_flags=-DNRF52840_XXAA -DNINA_B302_ublox {build.flags.usb}
|
||||
ninab302.build.ldscript=nrf52840_s140_v6.ld
|
||||
ninab302.build.vid=0x239A
|
||||
ninab302.build.pid=0x8029
|
||||
|
||||
# SofDevice Menu
|
||||
ninab302.menu.softdevice.s140v6=0.3.2 SoftDevice s140 6.1.1
|
||||
ninab302.menu.softdevice.s140v6.build.sd_name=s140
|
||||
ninab302.menu.softdevice.s140v6.build.sd_version=6.1.1
|
||||
ninab302.menu.softdevice.s140v6.build.sd_fwid=0x00B6
|
||||
|
||||
# Debug Menu
|
||||
ninab302.menu.debug.l0=Level 0 (Release)
|
||||
ninab302.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
ninab302.menu.debug.l1=Level 1 (Error Message)
|
||||
ninab302.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
ninab302.menu.debug.l2=Level 2 (Full Debug)
|
||||
ninab302.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
ninab302.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
ninab302.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
ninab302.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
|
||||
# ----------------------------------
|
||||
# NINA B112
|
||||
# ----------------------------------
|
||||
ninab112.name=NINA B112 ublox
|
||||
ninab112.bootloader.tool=bootburn
|
||||
|
||||
# Upload
|
||||
ninab112.upload.tool=nrfutil
|
||||
ninab112.upload.protocol=nrfutil
|
||||
ninab112.upload.use_1200bps_touch=false
|
||||
ninab112.upload.wait_for_upload_port=false
|
||||
ninab112.upload.native_usb=false
|
||||
ninab112.upload.maximum_size=290816
|
||||
ninab112.upload.maximum_data_size=52224
|
||||
|
||||
# Build
|
||||
ninab112.build.mcu=cortex-m4
|
||||
ninab112.build.f_cpu=64000000
|
||||
ninab112.build.board=NINA_B112_ublox
|
||||
ninab112.build.core=nRF5
|
||||
ninab112.build.variant=NINA_B112_ublox
|
||||
feather52840.build.usb_manufacturer="Adafruit LLC"
|
||||
feather52840.build.usb_product="Feather nRF52832"
|
||||
ninab112.build.extra_flags=-DNRF52832_XXAA -DNINA_B112_ublox -DNRF52
|
||||
ninab112.build.ldscript=nrf52832_s132_v6.ld
|
||||
|
||||
# SofDevice Menu
|
||||
ninab112.menu.softdevice.s132v6=0.3.2 SoftDevice s132 6.1.1
|
||||
ninab112.menu.softdevice.s132v6.build.sd_name=s132
|
||||
ninab112.menu.softdevice.s132v6.build.sd_version=6.1.1
|
||||
ninab112.menu.softdevice.s132v6.build.sd_fwid=0x00B7
|
||||
|
||||
# Debug Menu
|
||||
ninab112.menu.debug.l0=Level 0 (Release)
|
||||
ninab112.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
|
||||
ninab112.menu.debug.l1=Level 1 (Error Message)
|
||||
ninab112.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
|
||||
ninab112.menu.debug.l2=Level 2 (Full Debug)
|
||||
ninab112.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
|
||||
ninab112.menu.debug.l3=Level 3 (Segger SystemView)
|
||||
ninab112.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
|
||||
ninab112.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Udp.cpp: Library to send/receive UDP packets.
|
||||
*
|
||||
* NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these)
|
||||
* 1) UDP does not guarantee the order in which assembled UDP packets are received. This
|
||||
* might not happen often in practice, but in larger network topologies, a UDP
|
||||
* packet can be received out of sequence.
|
||||
* 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being
|
||||
* aware of it. Again, this may not be a concern in practice on small local networks.
|
||||
* For more information, see http://www.cafeaulait.org/course/week12/35.html
|
||||
*
|
||||
* MIT License:
|
||||
* Copyright (c) 2008 Bjoern Hartmann
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* bjoern@cs.stanford.edu 12/30/2008
|
||||
*/
|
||||
|
||||
#ifndef udp_h
|
||||
#define udp_h
|
||||
|
||||
#include <Stream.h>
|
||||
#include <IPAddress.h>
|
||||
|
||||
class UDP : public Stream {
|
||||
|
||||
public:
|
||||
virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
|
||||
|
||||
// KH, add virtual function to support Multicast, necessary for many services (MDNS, UPnP, etc.)
|
||||
virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure
|
||||
|
||||
virtual void stop() =0; // Finish with the UDP socket
|
||||
|
||||
// Sending UDP packets
|
||||
|
||||
// Start building up a packet to send to the remote host specific in ip and port
|
||||
// Returns 1 if successful, 0 if there was a problem with the supplied IP address or port
|
||||
virtual int beginPacket(IPAddress ip, uint16_t port) =0;
|
||||
// Start building up a packet to send to the remote host specific in host and port
|
||||
// Returns 1 if successful, 0 if there was a problem resolving the hostname or port
|
||||
virtual int beginPacket(const char *host, uint16_t port) =0;
|
||||
// Finish off this packet and send it
|
||||
// Returns 1 if the packet was sent successfully, 0 if there was an error
|
||||
virtual int endPacket() =0;
|
||||
// Write a single byte into the packet
|
||||
virtual size_t write(uint8_t) =0;
|
||||
// Write size bytes from buffer into the packet
|
||||
virtual size_t write(const uint8_t *buffer, size_t size) =0;
|
||||
|
||||
// Start processing the next available incoming packet
|
||||
// Returns the size of the packet in bytes, or 0 if no packets are available
|
||||
virtual int parsePacket() =0;
|
||||
// Number of bytes remaining in the current packet
|
||||
virtual int available() =0;
|
||||
// Read a single byte from the current packet
|
||||
virtual int read() =0;
|
||||
// Read up to len bytes from the current packet and place them into buffer
|
||||
// Returns the number of bytes read, or 0 if none are available
|
||||
virtual int read(unsigned char* buffer, size_t len) =0;
|
||||
// Read up to len characters from the current packet and place them into buffer
|
||||
// Returns the number of characters read, or 0 if none are available
|
||||
virtual int read(char* buffer, size_t len) =0;
|
||||
// Return the next byte from the current packet without moving on to the next byte
|
||||
virtual int peek() =0;
|
||||
virtual void flush() =0; // Finish reading the current packet
|
||||
|
||||
// Return the IP address of the host who sent the current incoming packet
|
||||
virtual IPAddress remoteIP() =0;
|
||||
// Return the port of the host who sent the current incoming packet
|
||||
virtual uint16_t remotePort() =0;
|
||||
protected:
|
||||
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,164 @@
|
||||
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
# Copyright (c) 2016 Sandeep Mistry All right reserved.
|
||||
# Copyright (c) 2017 Adafruit Industries. All rights reserved.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
name=Adafruit nRF52 Boards
|
||||
version=0.21.0
|
||||
|
||||
# Compile variables
|
||||
# -----------------
|
||||
|
||||
compiler.warning_flags=-w
|
||||
compiler.warning_flags.none=-w
|
||||
compiler.warning_flags.default=
|
||||
compiler.warning_flags.more=-Wall
|
||||
compiler.warning_flags.all=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-pointer-arith
|
||||
|
||||
# Allow changing optimization settings via platform.local.txt / boards.local.txt
|
||||
compiler.optimization_flag=-Ofast
|
||||
|
||||
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
|
||||
compiler.c.cmd=arm-none-eabi-gcc
|
||||
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD
|
||||
|
||||
# KH, Error here to use gcc, must use g++
|
||||
#compiler.c.elf.cmd=arm-none-eabi-gcc
|
||||
compiler.c.elf.cmd=arm-none-eabi-g++
|
||||
|
||||
compiler.c.elf.flags={compiler.optimization_flag} -Wl,--gc-sections -save-temps
|
||||
compiler.S.cmd=arm-none-eabi-gcc
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp
|
||||
compiler.cpp.cmd=arm-none-eabi-g++
|
||||
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD
|
||||
compiler.ar.cmd=arm-none-eabi-ar
|
||||
compiler.ar.flags=rcs
|
||||
compiler.objcopy.cmd=arm-none-eabi-objcopy
|
||||
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
|
||||
compiler.elf2bin.flags=-O binary
|
||||
compiler.elf2bin.cmd=arm-none-eabi-objcopy
|
||||
compiler.elf2hex.flags=-O ihex
|
||||
compiler.elf2hex.cmd=arm-none-eabi-objcopy
|
||||
compiler.ldflags=-mcpu={build.mcu} -mthumb {build.float_flags} -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align --specs=nano.specs --specs=nosys.specs
|
||||
compiler.size.cmd=arm-none-eabi-size
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float
|
||||
build.debug_flags=-DCFG_DEBUG=0
|
||||
build.logger_flags=-DCFG_LOGGER=1
|
||||
build.sysview_flags=-DCFG_SYSVIEW=0
|
||||
|
||||
# common compiler for nrf
|
||||
rtos.path={build.core.path}/freertos
|
||||
nordic.path={build.core.path}/nordic
|
||||
|
||||
# build.logger_flags and build.sysview_flags and intentionally empty,
|
||||
# to allow modification via a user's own boards.local.txt or platform.local.txt files.
|
||||
build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DLFS_NAME_MAX=64 {compiler.optimization_flag} {build.debug_flags} {build.logger_flags} {build.sysview_flags} "-I{build.core.path}/cmsis/Core/Include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include/nrf52" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
|
||||
|
||||
# usb flags
|
||||
build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
compiler.c.extra_flags=
|
||||
compiler.c.elf.extra_flags=
|
||||
compiler.cpp.extra_flags=
|
||||
compiler.S.extra_flags=
|
||||
compiler.ar.extra_flags=
|
||||
compiler.libraries.ldflags=
|
||||
compiler.elf2bin.extra_flags=
|
||||
compiler.elf2hex.extra_flags=
|
||||
|
||||
|
||||
# Compile patterns
|
||||
# ----------------
|
||||
|
||||
## Compile c files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.c.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile c++ files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} '-DARDUINO_BSP_VERSION="{version}"' {compiler.cpp.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile S files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.flags.nrf} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Create archives
|
||||
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
|
||||
|
||||
## Combine gc-sections, archives, and objects
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-L{build.core.path}/linker" "-T{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group -lm "{build.path}/{archive_file}" -Wl,--end-group
|
||||
|
||||
## Create output (bin file)
|
||||
#recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
|
||||
|
||||
## Create output (hex file)
|
||||
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
|
||||
|
||||
## Create dfu package zip file
|
||||
recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip"
|
||||
|
||||
## Create uf2 file
|
||||
#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex"
|
||||
|
||||
## Save bin
|
||||
recipe.output.tmp_file_bin={build.project_name}.bin
|
||||
recipe.output.save_file_bin={build.project_name}.save.bin
|
||||
|
||||
## Save hex
|
||||
recipe.output.tmp_file_hex={build.project_name}.hex
|
||||
recipe.output.save_file_hexu={build.project_name}.save.hex
|
||||
|
||||
## Compute size
|
||||
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
|
||||
recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).*
|
||||
recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).*
|
||||
|
||||
## Export Compiled Binary
|
||||
recipe.output.tmp_file={build.project_name}.hex
|
||||
recipe.output.save_file={build.project_name}.{build.variant}.hex
|
||||
|
||||
#***************************************************
|
||||
# adafruit-nrfutil for uploading
|
||||
# https://github.com/adafruit/Adafruit_nRF52_nrfutil
|
||||
# pre-built binaries are provided for macos and windows
|
||||
#***************************************************
|
||||
tools.nrfutil.cmd=adafruit-nrfutil
|
||||
tools.nrfutil.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe
|
||||
tools.nrfutil.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil
|
||||
|
||||
tools.nrfutil.upload.params.verbose=--verbose
|
||||
tools.nrfutil.upload.params.quiet=
|
||||
tools.nrfutil.upload.pattern="{cmd}" {upload.verbose} dfu serial -pkg "{build.path}/{build.project_name}.zip" -p {serial.port} -b 115200 --singlebank
|
||||
|
||||
#***************************************************
|
||||
# Burning bootloader with either jlink or nrfutil
|
||||
#***************************************************
|
||||
|
||||
# Bootloader version
|
||||
tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.3.2_{build.sd_name}_{build.sd_version}
|
||||
|
||||
tools.bootburn.bootloader.params.verbose=
|
||||
tools.bootburn.bootloader.params.quiet=
|
||||
tools.bootburn.bootloader.pattern={program.burn_pattern}
|
||||
|
||||
# erase flash page while programming
|
||||
tools.bootburn.erase.params.verbose=
|
||||
tools.bootburn.erase.params.quiet=
|
||||
tools.bootburn.erase.pattern=
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
// API compatibility
|
||||
#include "variant.h"
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
Copyright (c) 2016 Sandeep Mistry All right reserved.
|
||||
Copyright (c) 2018, Adafruit Industries (adafruit.com)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip).
|
||||
// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1)
|
||||
|
||||
#include "variant.h"
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
#include "nrf.h"
|
||||
|
||||
const uint32_t g_ADigitalPinMap[] = {
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
31
|
||||
};
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
Copyright (c) 2016 Sandeep Mistry All right reserved.
|
||||
Copyright (c) 2018, Adafruit Industries (adafruit.com)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VARIANT_NINA_B112_UBLOX_
|
||||
#define _VARIANT_NINA_B112_UBLOX_
|
||||
|
||||
#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \
|
||||
.rc_ctiv = 0, \
|
||||
.rc_temp_ctiv = 0, \
|
||||
.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}
|
||||
|
||||
/** Master clock frequency */
|
||||
#define VARIANT_MCK (64000000ul)
|
||||
|
||||
#define USE_LFXO // Board uses 32khz crystal for LF
|
||||
// define USE_LFRC // Board uses RC for LF
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "WVariant.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif // __cplusplus
|
||||
|
||||
// Number of pins defined in PinDescription array
|
||||
#define PINS_COUNT (32u)
|
||||
#define NUM_DIGITAL_PINS (32u)
|
||||
#define NUM_ANALOG_INPUTS (6u)
|
||||
#define NUM_ANALOG_OUTPUTS (0u)
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED LED1
|
||||
#define LED_BUILTIN PIN_LED
|
||||
|
||||
//LEDs onboard
|
||||
#define LED1 (8) // Red
|
||||
#define LED2 (16) // Green/SW1
|
||||
#define LED3 (18) // Blue
|
||||
|
||||
#define LED_STATE_ON 1 // State when LED is litted
|
||||
|
||||
//Switch
|
||||
|
||||
#define SW1 (16)
|
||||
#define SW2 (30)
|
||||
|
||||
// NFC
|
||||
#define PIN_NFC_1 (9) // P0.9
|
||||
#define PIN_NFC_2 (10) // P0.10
|
||||
|
||||
/*
|
||||
* Analog pins
|
||||
*/
|
||||
#define PIN_A0 (3) // P0.03
|
||||
#define PIN_A1 (2) // P0.02
|
||||
#define PIN_A2 (4) // P0.04
|
||||
#define PIN_A3 (30) // P0.30
|
||||
#define PIN_A4 (29) // P0.29
|
||||
#define PIN_A5 (28) // P0.28
|
||||
|
||||
static const uint8_t A0 = PIN_A0 ;
|
||||
static const uint8_t A1 = PIN_A1 ;
|
||||
static const uint8_t A2 = PIN_A2 ;
|
||||
static const uint8_t A3 = PIN_A3 ;
|
||||
static const uint8_t A4 = PIN_A4 ;
|
||||
static const uint8_t A5 = PIN_A5 ;
|
||||
|
||||
#define ADC_RESOLUTION 14
|
||||
|
||||
#define PIN_D0 (5) // P0.05
|
||||
#define PIN_D1 (6) // P0.06
|
||||
#define PIN_D2 (7) // P0.07
|
||||
#define PIN_D3 (31) // P0.31
|
||||
#define PIN_D4 (18) // P0.18
|
||||
#define PIN_D6 (9) // P0.09
|
||||
#define PIN_D7 (10) // P0.10
|
||||
#define PIN_D9 (8) // P0.8
|
||||
#define PIN_D10 (11) // P0.11
|
||||
#define PIN_D11 (13) // P0.13
|
||||
#define PIN_D12 (12) // P0.12
|
||||
#define PIN_D13 (14) // P0.14
|
||||
#define PIN_D14 (2) // P0.02
|
||||
#define PIN_D15 (3) // P0.03
|
||||
|
||||
static const uint8_t D0 = PIN_D0 ;
|
||||
static const uint8_t D1 = PIN_D1 ;
|
||||
static const uint8_t D2 = PIN_D2 ;
|
||||
static const uint8_t D3 = PIN_D3 ;
|
||||
static const uint8_t D4 = PIN_D4 ;
|
||||
static const uint8_t D6 = PIN_D6 ;
|
||||
static const uint8_t D7 = PIN_D7 ;
|
||||
static const uint8_t D9 = PIN_D9 ;
|
||||
static const uint8_t D10 = PIN_D10 ;
|
||||
static const uint8_t D11 = PIN_D11 ;
|
||||
static const uint8_t D12 = PIN_D12 ;
|
||||
static const uint8_t D13 = PIN_D13 ;
|
||||
static const uint8_t D14 = PIN_D14 ;
|
||||
static const uint8_t D15 = PIN_D15 ;
|
||||
|
||||
// Other pins
|
||||
//static const uint8_t AREF = PIN_AREF;
|
||||
|
||||
//#define PIN_AREF (24)
|
||||
//#define PIN_VBAT PIN_A7
|
||||
|
||||
/*
|
||||
* Serial interfaces
|
||||
*/
|
||||
//#define PIN_SERIAL_RX (8) //used for original Adafruit Bootloader
|
||||
//#define PIN_SERIAL_TX (6) //used for original Adafruit Bootloader
|
||||
|
||||
#define PIN_SERIAL_RX (5) // P0.05
|
||||
#define PIN_SERIAL_TX (6) // P0.06
|
||||
#define PIN_SERIAL_CTS (7) // P0.07
|
||||
#define PIN_SERIAL_RTS (31) // P0.31
|
||||
#define PIN_SERIAL_DTR (28) // P0.28
|
||||
#define PIN_SERIAL_DSR (29) // P0.29
|
||||
|
||||
/*
|
||||
* SPI Interfaces
|
||||
*/
|
||||
#define SPI_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_SPI_MISO (12) // P0.12
|
||||
#define PIN_SPI_MOSI (13) // P0.13
|
||||
#define PIN_SPI_SCK (14) // P0.14
|
||||
|
||||
static const uint8_t SS = 11 ; // P0.11
|
||||
static const uint8_t MOSI = PIN_SPI_MOSI ;
|
||||
static const uint8_t MISO = PIN_SPI_MISO ;
|
||||
static const uint8_t SCK = PIN_SPI_SCK ;
|
||||
|
||||
/*
|
||||
* Wire Interfaces
|
||||
*/
|
||||
#define WIRE_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_WIRE_SDA (2) // P0.02
|
||||
#define PIN_WIRE_SCL (3) // P0.03
|
||||
|
||||
static const uint8_t SDA = PIN_WIRE_SDA;
|
||||
static const uint8_t SCL = PIN_WIRE_SCL;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Arduino objects - C++ only
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#endif //_VARIANT_NINA_B112_UBLOX_
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
// API compatibility
|
||||
#include "variant.h"
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
Copyright (c) 2016 Sandeep Mistry All right reserved.
|
||||
Copyright (c) 2018, Adafruit Industries (adafruit.com)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip).
|
||||
// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1)
|
||||
|
||||
#include "variant.h"
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
#include "nrf.h"
|
||||
|
||||
const uint32_t g_ADigitalPinMap[] =
|
||||
{
|
||||
// D0 .. D13
|
||||
29, // D0 is P0.29 (UART TX)
|
||||
45, // D1 is P1.13 (UART RX
|
||||
44, // D2 is P1.12 (NFC2)
|
||||
31, // D3 is P0.31 (LED1)
|
||||
13, // D4 is P0.13 (LED2)
|
||||
11, // D5 is P0.11
|
||||
9, // D6 is P0.09
|
||||
10, // D7 is P0.10 (Button)
|
||||
41, // D8 is P1.09 (NeoPixel)
|
||||
12, // D9 is P0.12
|
||||
14, // D10 is P0.14
|
||||
15, // D11 is P0.15
|
||||
32, // D12 is P1.00
|
||||
7, // D13 is P0.07
|
||||
|
||||
// D14 .. D21 (aka A0 .. A7)
|
||||
4, // D14 is P0.04 (A0)
|
||||
30, // D15 is P0.30 (A1)
|
||||
5, // D16 is P0.05 (A2)
|
||||
2, // D17 is P0.02 (A3)
|
||||
28, // D18 is P0.28 (A4)
|
||||
3, // D19 is P0.03 (A5)
|
||||
29, // D20 is P0.29 (A6, Battery) ????
|
||||
31, // D21 is P0.31 (A7, ARef) ????
|
||||
|
||||
// D22 .. D23 (aka I2C pins)
|
||||
16, // D22 is P0.16 (SDA)
|
||||
24, // D23 is P0.24 (SCL)
|
||||
|
||||
// D24 .. D26 (aka SPI pins)
|
||||
32, // D24 is P1.00 (SPI MISO)
|
||||
15, // D25 is P0.15 (SPI MOSI)
|
||||
7, // D26 is P0.07 (SPI SCK )
|
||||
|
||||
// QSPI pins (not exposed via any header / test point)
|
||||
19, // D27 is P0.19 (QSPI CLK)
|
||||
17, // D28 is P0.17 (QSPI CS)
|
||||
20, // D29 is P0.20 (QSPI Data 0)
|
||||
21, // D30 is P0.21 (QSPI Data 1)
|
||||
22, // D31 is P0.22 (QSPI Data 2)
|
||||
23, // D32 is P0.23 (QSPI Data 3)
|
||||
|
||||
// The remaining NFC pin
|
||||
9, // D33 is P0.09 (NFC1, exposed only via test point on bottom of board)
|
||||
|
||||
// Thus, there are 34 defined pins
|
||||
|
||||
// The remaining pins are not usable:
|
||||
//
|
||||
//
|
||||
// The following pins were never listed as they were considered unusable
|
||||
// 0, // P0.00 is XL1 (attached to 32.768kHz crystal)
|
||||
// 1, // P0.01 is XL2 (attached to 32.768kHz crystal)
|
||||
// 18, // P0.18 is RESET (attached to switch)
|
||||
// 32, // P1.00 is SWO (attached to debug header)
|
||||
//
|
||||
// The remaining pins are not connected (per schematic)
|
||||
// 33, // P1.01 is not connected per schematic
|
||||
// 35, // P1.03 is not connected per schematic
|
||||
// 36, // P1.04 is not connected per schematic
|
||||
// 37, // P1.05 is not connected per schematic
|
||||
// 38, // P1.06 is not connected per schematic
|
||||
// 39, // P1.07 is not connected per schematic
|
||||
// 43, // P1.11 is not connected per schematic
|
||||
// 44, // P1.12 is not connected per schematic
|
||||
// 45, // P1.13 is not connected per schematic
|
||||
// 46, // P1.14 is not connected per schematic
|
||||
};
|
||||
|
||||
void initVariant()
|
||||
{
|
||||
// LED1 & LED2
|
||||
pinMode(PIN_LED1, OUTPUT);
|
||||
ledOff(PIN_LED1);
|
||||
|
||||
pinMode(PIN_LED2, OUTPUT);
|
||||
ledOff(PIN_LED2);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
Copyright (c) 2016 Sandeep Mistry All right reserved.
|
||||
Copyright (c) 2018, Adafruit Industries (adafruit.com)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
// Thanks to great work of [Miguel Alexandre Wisintainer](https://github.com/tcpipchip).
|
||||
// See [u-blox nina b](https://github.com/khoih-prog/WiFiNINA_Generic/issues/1)
|
||||
|
||||
#ifndef _VARIANT_NINA_B302_UBLOX_
|
||||
#define _VARIANT_NINA_B302_UBLOX_
|
||||
|
||||
/** Master clock frequency */
|
||||
#define VARIANT_MCK (64000000ul)
|
||||
|
||||
#define USE_LFXO // Board uses 32khz crystal for LF
|
||||
// define USE_LFRC // Board uses RC for LF
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "WVariant.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif // __cplusplus
|
||||
// (XX) = TABLE INDEX
|
||||
// Number of pins defined in PinDescription array
|
||||
#define PINS_COUNT (34)
|
||||
#define NUM_DIGITAL_PINS (34)
|
||||
#define NUM_ANALOG_INPUTS (6) // A6 is used for battery, A7 is analog reference
|
||||
#define NUM_ANALOG_OUTPUTS (0)
|
||||
|
||||
// LEDs
|
||||
#define PIN_LED1 (3)
|
||||
#define PIN_LED2 (4)
|
||||
#define PIN_NEOPIXEL (8)
|
||||
|
||||
#define LED_BUILTIN PIN_LED1
|
||||
#define LED_CONN PIN_LED2
|
||||
|
||||
#define LED_RED PIN_LED1
|
||||
#define LED_BLUE PIN_LED2
|
||||
|
||||
#define LED_STATE_ON 1 // State when LED is litted
|
||||
|
||||
/*
|
||||
* Buttons
|
||||
*/
|
||||
#define PIN_BUTTON1 (7)
|
||||
|
||||
/*
|
||||
* Analog pins
|
||||
*/
|
||||
#define PIN_A0 (14)
|
||||
#define PIN_A1 (15)
|
||||
#define PIN_A2 (16)
|
||||
#define PIN_A3 (17)
|
||||
#define PIN_A4 (18)
|
||||
#define PIN_A5 (19)
|
||||
#define PIN_A6 (20)
|
||||
#define PIN_A7 (21)
|
||||
|
||||
#define D0 (0)
|
||||
#define D1 (1)
|
||||
#define D2 (2)
|
||||
#define D3 (3)
|
||||
#define D4 (4)
|
||||
#define D5 (5)
|
||||
#define D6 (6)
|
||||
#define D7 (7)
|
||||
#define D8 (8)
|
||||
#define D9 (9)
|
||||
#define D10 (10)
|
||||
#define D11 (11)
|
||||
#define D12 (12)
|
||||
#define D13 (13)
|
||||
|
||||
static const uint8_t A0 = PIN_A0 ;
|
||||
static const uint8_t A1 = PIN_A1 ;
|
||||
static const uint8_t A2 = PIN_A2 ;
|
||||
static const uint8_t A3 = PIN_A3 ;
|
||||
static const uint8_t A4 = PIN_A4 ;
|
||||
static const uint8_t A5 = PIN_A5 ;
|
||||
static const uint8_t A6 = PIN_A6 ;
|
||||
static const uint8_t A7 = PIN_A7 ;
|
||||
#define ADC_RESOLUTION 14
|
||||
|
||||
// Other pins
|
||||
#define PIN_AREF PIN_A7
|
||||
#define PIN_VBAT PIN_A6
|
||||
#define PIN_NFC1 (33)
|
||||
#define PIN_NFC2 (2)
|
||||
|
||||
static const uint8_t AREF = PIN_AREF;
|
||||
|
||||
/*
|
||||
* Serial interfaces
|
||||
*/
|
||||
#define PIN_SERIAL1_RX (1)
|
||||
#define PIN_SERIAL1_TX (0)
|
||||
|
||||
/*
|
||||
* SPI Interfaces
|
||||
*/
|
||||
#define SPI_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_SPI_MISO (24) //24 original
|
||||
#define PIN_SPI_MOSI (25) //25 original
|
||||
#define PIN_SPI_SCK (26) //26 original
|
||||
|
||||
static const uint8_t SS = (13);
|
||||
static const uint8_t MOSI = PIN_SPI_MOSI;
|
||||
static const uint8_t MISO = PIN_SPI_MISO;
|
||||
static const uint8_t SCK = PIN_SPI_SCK;
|
||||
|
||||
/*
|
||||
* Wire Interfaces
|
||||
*/
|
||||
#define WIRE_INTERFACES_COUNT 1
|
||||
|
||||
#define PIN_WIRE_SDA (22)
|
||||
#define PIN_WIRE_SCL (23)
|
||||
|
||||
// QSPI Pins
|
||||
#define PIN_QSPI_SCK 27
|
||||
#define PIN_QSPI_CS 28
|
||||
#define PIN_QSPI_IO0 29
|
||||
#define PIN_QSPI_IO1 30
|
||||
#define PIN_QSPI_IO2 31
|
||||
#define PIN_QSPI_IO3 32
|
||||
|
||||
// On-board QSPI Flash
|
||||
#define EXTERNAL_FLASH_DEVICES GD25Q16C
|
||||
#define EXTERNAL_FLASH_USE_QSPI
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Arduino objects - C++ only
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#endif //_VARIANT_NINA_B302_UBLOX_
|
||||
@@ -0,0 +1,226 @@
|
||||
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
# Arduino SAMD Core and platform.
|
||||
#
|
||||
# For more info:
|
||||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
|
||||
name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards
|
||||
version=1.6.3
|
||||
|
||||
# Compile variables
|
||||
# -----------------
|
||||
|
||||
compiler.warning_flags=-w
|
||||
compiler.warning_flags.none=-w
|
||||
compiler.warning_flags.default=
|
||||
compiler.warning_flags.more=-Wall -Wno-expansion-to-defined
|
||||
compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined
|
||||
|
||||
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
|
||||
compiler.c.cmd=arm-none-eabi-gcc
|
||||
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}"""
|
||||
compiler.c.elf.cmd=arm-none-eabi-g++
|
||||
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
|
||||
compiler.S.cmd=arm-none-eabi-gcc
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
|
||||
compiler.cpp.cmd=arm-none-eabi-g++
|
||||
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}"""
|
||||
compiler.ar.cmd=arm-none-eabi-ar
|
||||
compiler.ar.flags=rcs
|
||||
compiler.objcopy.cmd=arm-none-eabi-objcopy
|
||||
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
|
||||
compiler.elf2hex.bin.flags=-O binary
|
||||
compiler.elf2hex.hex.flags=-O ihex -R .eeprom
|
||||
compiler.elf2hex.cmd=arm-none-eabi-objcopy
|
||||
compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align
|
||||
compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
build.extra_flags=
|
||||
build.cache_flags=
|
||||
build.flags.optimize=
|
||||
build.flags.maxspi=
|
||||
build.flags.maxqspi=
|
||||
build.flags.usbstack=
|
||||
build.flags.debug=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
compiler.c.extra_flags=
|
||||
compiler.c.elf.extra_flags=
|
||||
#compiler.c.elf.extra_flags=-v
|
||||
compiler.cpp.extra_flags=
|
||||
compiler.S.extra_flags=
|
||||
compiler.ar.extra_flags=
|
||||
compiler.elf2hex.extra_flags=
|
||||
|
||||
compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/"
|
||||
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math
|
||||
|
||||
compiler.libraries.ldflags=
|
||||
|
||||
# USB Flags
|
||||
# ---------
|
||||
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
|
||||
|
||||
# Default advertised device power setting in mA
|
||||
build.usb_power=100
|
||||
|
||||
# Default usb manufacturer will be replaced at compile time using
|
||||
# numeric vendor ID if available or by board's specific value.
|
||||
build.usb_manufacturer="Unknown"
|
||||
|
||||
|
||||
# Compile patterns
|
||||
# ----------------
|
||||
|
||||
## Compile c files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile c++ files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile S files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Create archives
|
||||
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
|
||||
archive_file_path={build.path}/{archive_file}
|
||||
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
|
||||
|
||||
## Combine gc-sections, archives, and objects
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group
|
||||
|
||||
## Create output (bin file)
|
||||
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
|
||||
|
||||
## Create output (hex file)
|
||||
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
|
||||
|
||||
build.preferred_out_format=bin
|
||||
|
||||
## Save hex
|
||||
recipe.output.tmp_file={build.project_name}.{build.preferred_out_format}
|
||||
recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format}
|
||||
|
||||
## Compute size
|
||||
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
|
||||
recipe.size.regex=\.text\s+([0-9]+).*
|
||||
|
||||
#
|
||||
# BOSSA
|
||||
#
|
||||
tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path}
|
||||
tools.bossac.cmd=bossac
|
||||
tools.bossac.cmd.windows=bossac.exe
|
||||
|
||||
tools.bossac.upload.params.verbose=-i -d
|
||||
tools.bossac.upload.params.quiet=
|
||||
tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R
|
||||
|
||||
tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
|
||||
|
||||
tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
# v1.8.0
|
||||
|
||||
tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path}
|
||||
tools.bossac18.cmd=bossac
|
||||
|
||||
tools.bossac18.upload.params.verbose=-i -d
|
||||
tools.bossac18.upload.params.quiet=
|
||||
tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R
|
||||
|
||||
tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
#
|
||||
# BOSSA (ignore binary size)
|
||||
#
|
||||
tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path}
|
||||
tools.bossacI.cmd=bossac
|
||||
tools.bossacI.cmd.windows=bossac.exe
|
||||
|
||||
tools.bossacI.upload.params.verbose=-i -d
|
||||
tools.bossacI.upload.params.quiet=
|
||||
tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R
|
||||
|
||||
tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
|
||||
|
||||
tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
|
||||
#
|
||||
# OpenOCD sketch upload
|
||||
#
|
||||
|
||||
tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}
|
||||
tools.openocd.cmd=bin/openocd
|
||||
tools.openocd.cmd.windows=bin/openocd.exe
|
||||
|
||||
tools.openocd.upload.params.verbose=-d2
|
||||
tools.openocd.upload.params.quiet=-d0
|
||||
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
|
||||
|
||||
tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
|
||||
tools.openocd.program.params.verbose=-d2
|
||||
tools.openocd.program.params.quiet=-d0
|
||||
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
|
||||
|
||||
tools.openocd.erase.params.verbose=-d3
|
||||
tools.openocd.erase.params.quiet=-d0
|
||||
tools.openocd.erase.pattern=
|
||||
|
||||
tools.openocd.bootloader.params.verbose=-d2
|
||||
tools.openocd.bootloader.params.quiet=-d0
|
||||
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
|
||||
|
||||
#
|
||||
# OpenOCD sketch upload - version with configurable bootloader size
|
||||
# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences
|
||||
#
|
||||
|
||||
tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path}
|
||||
tools.openocd-withbootsize.cmd=bin/openocd
|
||||
tools.openocd-withbootsize.cmd.windows=bin/openocd.exe
|
||||
|
||||
tools.openocd-withbootsize.upload.params.verbose=-d2
|
||||
tools.openocd-withbootsize.upload.params.quiet=-d0
|
||||
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
|
||||
|
||||
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
|
||||
tools.openocd-withbootsize.program.params.verbose=-d2
|
||||
tools.openocd-withbootsize.program.params.quiet=-d0
|
||||
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
|
||||
|
||||
tools.openocd-withbootsize.erase.params.verbose=-d3
|
||||
tools.openocd-withbootsize.erase.params.quiet=-d0
|
||||
tools.openocd-withbootsize.erase.pattern=
|
||||
|
||||
tools.openocd-withbootsize.bootloader.params.verbose=-d2
|
||||
tools.openocd-withbootsize.bootloader.params.quiet=-d0
|
||||
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
|
||||
@@ -0,0 +1,226 @@
|
||||
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
# Arduino SAMD Core and platform.
|
||||
#
|
||||
# For more info:
|
||||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
|
||||
name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards
|
||||
version=1.6.4
|
||||
|
||||
# Compile variables
|
||||
# -----------------
|
||||
|
||||
compiler.warning_flags=-w
|
||||
compiler.warning_flags.none=-w
|
||||
compiler.warning_flags.default=
|
||||
compiler.warning_flags.more=-Wall -Wno-expansion-to-defined
|
||||
compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined
|
||||
|
||||
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
|
||||
compiler.c.cmd=arm-none-eabi-gcc
|
||||
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}"""
|
||||
compiler.c.elf.cmd=arm-none-eabi-g++
|
||||
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
|
||||
compiler.S.cmd=arm-none-eabi-gcc
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
|
||||
compiler.cpp.cmd=arm-none-eabi-g++
|
||||
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -D__SKETCH_NAME__="""{build.project_name}"""
|
||||
compiler.ar.cmd=arm-none-eabi-ar
|
||||
compiler.ar.flags=rcs
|
||||
compiler.objcopy.cmd=arm-none-eabi-objcopy
|
||||
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
|
||||
compiler.elf2hex.bin.flags=-O binary
|
||||
compiler.elf2hex.hex.flags=-O ihex -R .eeprom
|
||||
compiler.elf2hex.cmd=arm-none-eabi-objcopy
|
||||
compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align
|
||||
compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
build.extra_flags=
|
||||
build.cache_flags=
|
||||
build.flags.optimize=
|
||||
build.flags.maxspi=
|
||||
build.flags.maxqspi=
|
||||
build.flags.usbstack=
|
||||
build.flags.debug=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
compiler.c.extra_flags=
|
||||
compiler.c.elf.extra_flags=
|
||||
#compiler.c.elf.extra_flags=-v
|
||||
compiler.cpp.extra_flags=
|
||||
compiler.S.extra_flags=
|
||||
compiler.ar.extra_flags=
|
||||
compiler.elf2hex.extra_flags=
|
||||
|
||||
compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/"
|
||||
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math
|
||||
|
||||
compiler.libraries.ldflags=
|
||||
|
||||
# USB Flags
|
||||
# ---------
|
||||
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
|
||||
|
||||
# Default advertised device power setting in mA
|
||||
build.usb_power=100
|
||||
|
||||
# Default usb manufacturer will be replaced at compile time using
|
||||
# numeric vendor ID if available or by board's specific value.
|
||||
build.usb_manufacturer="Unknown"
|
||||
|
||||
|
||||
# Compile patterns
|
||||
# ----------------
|
||||
|
||||
## Compile c files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile c++ files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile S files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Create archives
|
||||
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
|
||||
archive_file_path={build.path}/{archive_file}
|
||||
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
|
||||
|
||||
## Combine gc-sections, archives, and objects
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group
|
||||
|
||||
## Create output (bin file)
|
||||
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
|
||||
|
||||
## Create output (hex file)
|
||||
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
|
||||
|
||||
build.preferred_out_format=bin
|
||||
|
||||
## Save hex
|
||||
recipe.output.tmp_file={build.project_name}.{build.preferred_out_format}
|
||||
recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format}
|
||||
|
||||
## Compute size
|
||||
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
|
||||
recipe.size.regex=\.text\s+([0-9]+).*
|
||||
|
||||
#
|
||||
# BOSSA
|
||||
#
|
||||
tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path}
|
||||
tools.bossac.cmd=bossac
|
||||
tools.bossac.cmd.windows=bossac.exe
|
||||
|
||||
tools.bossac.upload.params.verbose=-i -d
|
||||
tools.bossac.upload.params.quiet=
|
||||
tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R
|
||||
|
||||
tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
|
||||
|
||||
tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
# v1.8.0
|
||||
|
||||
tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path}
|
||||
tools.bossac18.cmd=bossac
|
||||
|
||||
tools.bossac18.upload.params.verbose=-i -d
|
||||
tools.bossac18.upload.params.quiet=
|
||||
tools.bossac18.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R
|
||||
|
||||
tools.bossac18.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossac18.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
#
|
||||
# BOSSA (ignore binary size)
|
||||
#
|
||||
tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path}
|
||||
tools.bossacI.cmd=bossac
|
||||
tools.bossacI.cmd.windows=bossac.exe
|
||||
|
||||
tools.bossacI.upload.params.verbose=-i -d
|
||||
tools.bossacI.upload.params.quiet=
|
||||
tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R
|
||||
|
||||
tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
|
||||
|
||||
tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
|
||||
#
|
||||
# OpenOCD sketch upload
|
||||
#
|
||||
|
||||
tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}
|
||||
tools.openocd.cmd=bin/openocd
|
||||
tools.openocd.cmd.windows=bin/openocd.exe
|
||||
|
||||
tools.openocd.upload.params.verbose=-d2
|
||||
tools.openocd.upload.params.quiet=-d0
|
||||
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
|
||||
|
||||
tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
|
||||
tools.openocd.program.params.verbose=-d2
|
||||
tools.openocd.program.params.quiet=-d0
|
||||
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
|
||||
|
||||
tools.openocd.erase.params.verbose=-d3
|
||||
tools.openocd.erase.params.quiet=-d0
|
||||
tools.openocd.erase.pattern=
|
||||
|
||||
tools.openocd.bootloader.params.verbose=-d2
|
||||
tools.openocd.bootloader.params.quiet=-d0
|
||||
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
|
||||
|
||||
#
|
||||
# OpenOCD sketch upload - version with configurable bootloader size
|
||||
# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences
|
||||
#
|
||||
|
||||
tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path}
|
||||
tools.openocd-withbootsize.cmd=bin/openocd
|
||||
tools.openocd-withbootsize.cmd.windows=bin/openocd.exe
|
||||
|
||||
tools.openocd-withbootsize.upload.params.verbose=-d2
|
||||
tools.openocd-withbootsize.upload.params.quiet=-d0
|
||||
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
|
||||
|
||||
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
|
||||
tools.openocd-withbootsize.program.params.verbose=-d2
|
||||
tools.openocd-withbootsize.program.params.quiet=-d0
|
||||
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
|
||||
|
||||
tools.openocd-withbootsize.erase.params.verbose=-d3
|
||||
tools.openocd-withbootsize.erase.params.quiet=-d0
|
||||
tools.openocd-withbootsize.erase.pattern=
|
||||
|
||||
tools.openocd-withbootsize.bootloader.params.verbose=-d2
|
||||
tools.openocd-withbootsize.bootloader.params.quiet=-d0
|
||||
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
|
||||
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
Arduino.h - Main include file for the Arduino SDK
|
||||
Copyright (c) 2014 Arduino LLC. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
// KH, This is the fix according to https://github.com/arduino/ArduinoCore-samd/pull/399
|
||||
// to avoid notorious compiler error while uing STL (min and max macro error)
|
||||
// It's terrible Arduino has just released new core and still don't merge the PR
|
||||
|
||||
#ifndef Arduino_h
|
||||
#define Arduino_h
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
typedef bool boolean;
|
||||
typedef uint8_t byte;
|
||||
typedef uint16_t word;
|
||||
|
||||
// some libraries and sketches depend on this AVR stuff,
|
||||
// assuming Arduino.h or WProgram.h automatically includes it...
|
||||
//
|
||||
#include "avr/pgmspace.h"
|
||||
#include "avr/interrupt.h"
|
||||
#include "avr/io.h"
|
||||
|
||||
#include "binary.h"
|
||||
#include "itoa.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif // __cplusplus
|
||||
|
||||
// Include Atmel headers
|
||||
#include "sam.h"
|
||||
|
||||
#include "wiring_constants.h"
|
||||
|
||||
#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
|
||||
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
|
||||
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )
|
||||
|
||||
void yield( void ) ;
|
||||
|
||||
/* system functions */
|
||||
int main( void );
|
||||
void init( void );
|
||||
|
||||
/* sketch */
|
||||
void setup( void ) ;
|
||||
void loop( void ) ;
|
||||
|
||||
#include "WVariant.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
// The following headers are for C++ only compilation
|
||||
#ifdef __cplusplus
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "Tone.h"
|
||||
#include "WMath.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "pulse.h"
|
||||
#include <bits/stl_algobase.h>
|
||||
#endif
|
||||
|
||||
#include "delay.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "Uart.h"
|
||||
#endif
|
||||
|
||||
// Include board variant
|
||||
#include "variant.h"
|
||||
#include "wiring.h"
|
||||
#include "wiring_digital.h"
|
||||
#include "wiring_analog.h"
|
||||
#include "wiring_shift.h"
|
||||
#include "WInterrupts.h"
|
||||
|
||||
#ifndef __cplusplus
|
||||
// undefine stdlib's abs if encountered
|
||||
#ifdef abs
|
||||
#undef abs
|
||||
#endif // abs
|
||||
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
#define abs(x) ((x)>0?(x):-(x))
|
||||
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
|
||||
|
||||
#else
|
||||
//using std::min;
|
||||
//using std::max;
|
||||
template<class T, class L>
|
||||
auto min(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (b < a) ? b : a;
|
||||
}
|
||||
|
||||
template<class T, class L>
|
||||
auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (a < b) ? b : a;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
|
||||
#define radians(deg) ((deg)*DEG_TO_RAD)
|
||||
#define degrees(rad) ((rad)*RAD_TO_DEG)
|
||||
#define sq(x) ((x)*(x))
|
||||
|
||||
#define interrupts() __enable_irq()
|
||||
#define noInterrupts() __disable_irq()
|
||||
|
||||
#define lowByte(w) ((uint8_t) ((w) & 0xff))
|
||||
#define highByte(w) ((uint8_t) ((w) >> 8))
|
||||
|
||||
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
|
||||
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
|
||||
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
|
||||
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
|
||||
#define bit(b) (1UL << (b))
|
||||
|
||||
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
|
||||
// Interrupts
|
||||
#define digitalPinToInterrupt(P) ( P )
|
||||
#endif
|
||||
|
||||
// Allows publishing the Beta core under samd-beta / arduino organization
|
||||
#ifndef ARDUINO_ARCH_SAMD
|
||||
#define ARDUINO_ARCH_SAMD
|
||||
#endif
|
||||
|
||||
// USB Device
|
||||
#include "USB/USBDesc.h"
|
||||
#include "USB/USBCore.h"
|
||||
#include "USB/USBAPI.h"
|
||||
#include "USB/USB_host.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "USB/CDC.h"
|
||||
#endif
|
||||
|
||||
#endif // Arduino_h
|
||||
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
Arduino.h - Main include file for the Arduino SDK
|
||||
Copyright (c) 2014 Arduino LLC. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
// KH, This is the fix according to https://github.com/arduino/ArduinoCore-samd/pull/399
|
||||
// to avoid notorious compiler error while uing STL (min and max macro error)
|
||||
// It's terrible Arduino has just released new core and still don't merge the PR
|
||||
|
||||
#ifndef Arduino_h
|
||||
#define Arduino_h
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
typedef bool boolean;
|
||||
typedef uint8_t byte;
|
||||
typedef uint16_t word;
|
||||
|
||||
// some libraries and sketches depend on this AVR stuff,
|
||||
// assuming Arduino.h or WProgram.h automatically includes it...
|
||||
//
|
||||
#include "avr/pgmspace.h"
|
||||
#include "avr/interrupt.h"
|
||||
#include "avr/io.h"
|
||||
|
||||
#include "binary.h"
|
||||
#include "itoa.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif // __cplusplus
|
||||
|
||||
// Include Atmel headers
|
||||
#include "sam.h"
|
||||
|
||||
#include "wiring_constants.h"
|
||||
|
||||
#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
|
||||
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
|
||||
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )
|
||||
|
||||
void yield( void ) ;
|
||||
|
||||
/* system functions */
|
||||
int main( void );
|
||||
void init( void );
|
||||
|
||||
/* sketch */
|
||||
void setup( void ) ;
|
||||
void loop( void ) ;
|
||||
|
||||
#include "WVariant.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
// The following headers are for C++ only compilation
|
||||
#ifdef __cplusplus
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "Tone.h"
|
||||
#include "WMath.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "pulse.h"
|
||||
#include <bits/stl_algobase.h>
|
||||
#endif
|
||||
|
||||
#include "delay.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "Uart.h"
|
||||
#endif
|
||||
|
||||
// Include board variant
|
||||
#include "variant.h"
|
||||
#include "wiring.h"
|
||||
#include "wiring_digital.h"
|
||||
#include "wiring_analog.h"
|
||||
#include "wiring_shift.h"
|
||||
#include "WInterrupts.h"
|
||||
|
||||
#ifndef __cplusplus
|
||||
// undefine stdlib's abs if encountered
|
||||
#ifdef abs
|
||||
#undef abs
|
||||
#endif // abs
|
||||
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
#define abs(x) ((x)>0?(x):-(x))
|
||||
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
|
||||
|
||||
#else
|
||||
//using std::min;
|
||||
//using std::max;
|
||||
template<class T, class L>
|
||||
auto min(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (b < a) ? b : a;
|
||||
}
|
||||
|
||||
template<class T, class L>
|
||||
auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (a < b) ? b : a;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
|
||||
#define radians(deg) ((deg)*DEG_TO_RAD)
|
||||
#define degrees(rad) ((rad)*RAD_TO_DEG)
|
||||
#define sq(x) ((x)*(x))
|
||||
|
||||
#define interrupts() __enable_irq()
|
||||
#define noInterrupts() __disable_irq()
|
||||
|
||||
#define lowByte(w) ((uint8_t) ((w) & 0xff))
|
||||
#define highByte(w) ((uint8_t) ((w) >> 8))
|
||||
|
||||
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
|
||||
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
|
||||
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
|
||||
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
|
||||
#define bit(b) (1UL << (b))
|
||||
|
||||
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
|
||||
// Interrupts
|
||||
#define digitalPinToInterrupt(P) ( P )
|
||||
#endif
|
||||
|
||||
// Allows publishing the Beta core under samd-beta / arduino organization
|
||||
#ifndef ARDUINO_ARCH_SAMD
|
||||
#define ARDUINO_ARCH_SAMD
|
||||
#endif
|
||||
|
||||
// USB Device
|
||||
#include "USB/USBDesc.h"
|
||||
#include "USB/USBCore.h"
|
||||
#include "USB/USBAPI.h"
|
||||
#include "USB/USB_host.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "USB/CDC.h"
|
||||
#endif
|
||||
|
||||
#endif // Arduino_h
|
||||
@@ -0,0 +1,242 @@
|
||||
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
# Arduino SAMD Core and platform.
|
||||
#
|
||||
# For more info:
|
||||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
|
||||
name=Arduino SAMD (32-bits ARM Cortex-M0+) Boards
|
||||
version=1.8.9
|
||||
|
||||
# Compile variables
|
||||
# -----------------
|
||||
|
||||
compiler.warning_flags=-w
|
||||
compiler.warning_flags.none=-w
|
||||
compiler.warning_flags.default=
|
||||
compiler.warning_flags.more=-Wall -Wno-expansion-to-defined
|
||||
compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined
|
||||
|
||||
# EXPERIMENTAL feature: optimization flags
|
||||
# - this is alpha and may be subject to change without notice
|
||||
compiler.optimization_flags=-Os
|
||||
compiler.optimization_flags.release=-Os
|
||||
compiler.optimization_flags.debug=-Og -g3
|
||||
|
||||
compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
|
||||
compiler.c.cmd=arm-none-eabi-gcc
|
||||
compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD
|
||||
compiler.c.elf.cmd=arm-none-eabi-g++
|
||||
compiler.c.elf.flags={compiler.optimization_flags} -Wl,--gc-sections -save-temps
|
||||
compiler.S.cmd=arm-none-eabi-gcc
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
|
||||
compiler.cpp.cmd=arm-none-eabi-g++
|
||||
compiler.cpp.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.optimization_flags} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD
|
||||
compiler.ar.cmd=arm-none-eabi-ar
|
||||
compiler.ar.flags=rcs
|
||||
compiler.objcopy.cmd=arm-none-eabi-objcopy
|
||||
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
|
||||
compiler.elf2hex.bin.flags=-O binary
|
||||
compiler.elf2hex.hex.flags=-O ihex -R .eeprom
|
||||
compiler.elf2hex.cmd=arm-none-eabi-objcopy
|
||||
compiler.ldflags=-mcpu={build.mcu} -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align
|
||||
compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
build.extra_flags=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
compiler.c.extra_flags=
|
||||
compiler.c.elf.extra_flags=
|
||||
#compiler.c.elf.extra_flags=-v
|
||||
compiler.cpp.extra_flags=
|
||||
compiler.S.extra_flags=
|
||||
compiler.ar.extra_flags=
|
||||
compiler.elf2hex.extra_flags=
|
||||
|
||||
compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/"
|
||||
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math
|
||||
|
||||
compiler.libraries.ldflags=
|
||||
|
||||
# USB Flags
|
||||
# ---------
|
||||
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
|
||||
|
||||
# Default usb manufacturer will be replaced at compile time using
|
||||
# numeric vendor ID if available or by board's specific value.
|
||||
build.usb_manufacturer="Unknown"
|
||||
|
||||
# Compile patterns
|
||||
# ----------------
|
||||
|
||||
## Compile c files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile c++ files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DBOARD_NAME="{build.board}" -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile S files
|
||||
## KH Add -DBOARD_NAME="{build.board}"
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DBOARD_NAME="{build.board}" -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Create archives
|
||||
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
|
||||
archive_file_path={build.path}/{archive_file}
|
||||
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
|
||||
|
||||
## Combine gc-sections, archives, and objects
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" -Wl,--end-group
|
||||
|
||||
## Create output (bin file)
|
||||
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
|
||||
|
||||
## Create output (hex file)
|
||||
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
|
||||
|
||||
build.preferred_out_format=bin
|
||||
|
||||
## Save hex
|
||||
recipe.output.tmp_file={build.project_name}.{build.preferred_out_format}
|
||||
recipe.output.save_file={build.project_name}.{build.variant}.{build.preferred_out_format}
|
||||
|
||||
## Compute size
|
||||
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
|
||||
recipe.size.regex=^(?:\.text|\.data|)\s+([0-9]+).*
|
||||
recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).*
|
||||
|
||||
# Upload/Debug tools
|
||||
# ------------------
|
||||
|
||||
#
|
||||
# AVRDUDE
|
||||
#
|
||||
tools.avrdude.path={runtime.tools.avrdude.path}
|
||||
tools.avrdude.cmd={path}/bin/avrdude
|
||||
tools.avrdude.config.path={path}/etc/avrdude.conf
|
||||
|
||||
tools.avrdude.upload.params.verbose=-v -v
|
||||
tools.avrdude.upload.params.quiet=-q -q
|
||||
tools.avrdude.upload.params.noverify=-V
|
||||
tools.avrdude.upload.pattern="{cmd}" "-C{config.path}" {upload.verbose} -p{build.emu.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} "-Uflash:w:{build.path}/{build.project_name}.hex:i"
|
||||
|
||||
tools.avrdude_remote.upload.pattern="openocd --version 2>&1 | grep 2016 && if opkg update; then opkg upgrade openocd; exit 1; else echo 'Please connect your board to the Internet in order to upgrade tools' >&2; exit 1; fi || /usr/bin/run-avrdude /tmp/sketch.hex"
|
||||
|
||||
tools.avrdude.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
#
|
||||
# BOSSA
|
||||
#
|
||||
tools.bossac.path={runtime.tools.bossac-1.7.0-arduino3.path}
|
||||
tools.bossac.cmd=bossac
|
||||
tools.bossac.cmd.windows=bossac.exe
|
||||
|
||||
tools.bossac.upload.params.verbose=-i -d
|
||||
tools.bossac.upload.params.quiet=
|
||||
tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -i -e -w -v "{build.path}/{build.project_name}.bin" -R
|
||||
|
||||
tools.bossac_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
|
||||
|
||||
arduinoota.extraflags=
|
||||
tools.bossac.network_cmd={runtime.tools.arduinoOTA-1.3.0.path}/bin/arduinoOTA
|
||||
tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags}
|
||||
|
||||
#
|
||||
# BOSSA (ignore binary size)
|
||||
#
|
||||
tools.bossacI.path={runtime.tools.bossac-1.7.0-arduino3.path}
|
||||
tools.bossacI.cmd=bossac
|
||||
tools.bossacI.cmd.windows=bossac.exe
|
||||
|
||||
tools.bossacI.upload.params.verbose=-i -d
|
||||
tools.bossacI.upload.params.quiet=
|
||||
tools.bossacI.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -I -U {upload.native_usb} -i -e -w "{build.path}/{build.project_name}.bin" -R
|
||||
|
||||
tools.bossacI_remote.upload.pattern=/usr/bin/run-bossac {upload.verbose} --port=ttyATH0 -U {upload.native_usb} -e -w -v /tmp/sketch.bin -R
|
||||
|
||||
tools.bossacI.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
|
||||
#
|
||||
# OpenOCD sketch upload
|
||||
#
|
||||
|
||||
tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}
|
||||
tools.openocd.cmd=bin/openocd
|
||||
tools.openocd.cmd.windows=bin/openocd.exe
|
||||
|
||||
tools.openocd.upload.params.verbose=-d2
|
||||
tools.openocd.upload.params.quiet=-d0
|
||||
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown"
|
||||
|
||||
tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
|
||||
tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
|
||||
|
||||
tools.openocd.program.params.verbose=-d2
|
||||
tools.openocd.program.params.quiet=-d0
|
||||
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.hex} verify reset; shutdown"
|
||||
|
||||
tools.openocd.erase.params.verbose=-d3
|
||||
tools.openocd.erase.params.quiet=-d0
|
||||
tools.openocd.erase.pattern=
|
||||
|
||||
tools.openocd.bootloader.params.verbose=-d2
|
||||
tools.openocd.bootloader.params.quiet=-d0
|
||||
tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
|
||||
|
||||
#
|
||||
# OpenOCD sketch upload - version with configurable bootloader size
|
||||
# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences
|
||||
#
|
||||
|
||||
tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path}
|
||||
tools.openocd-withbootsize.cmd=bin/openocd
|
||||
tools.openocd-withbootsize.cmd.windows=bin/openocd.exe
|
||||
|
||||
tools.openocd-withbootsize.upload.params.verbose=-d2
|
||||
tools.openocd-withbootsize.upload.params.quiet=-d0
|
||||
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"
|
||||
|
||||
# Program flashes the binary at 0x0000, so use the linker script without_bootloader
|
||||
tools.openocd-withbootsize.program.params.verbose=-d2
|
||||
tools.openocd-withbootsize.program.params.quiet=-d0
|
||||
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"
|
||||
|
||||
tools.openocd-withbootsize.erase.params.verbose=-d3
|
||||
tools.openocd-withbootsize.erase.params.quiet=-d0
|
||||
tools.openocd-withbootsize.erase.pattern=
|
||||
|
||||
tools.openocd-withbootsize.bootloader.params.verbose=-d2
|
||||
tools.openocd-withbootsize.bootloader.params.quiet=-d0
|
||||
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"
|
||||
|
||||
#
|
||||
# GDB (Debugger)
|
||||
#
|
||||
# EXPERIMENTAL feature: debug.pattern
|
||||
# - this is alpha and may be subject to change without notice
|
||||
tools.gdb-openocd.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
|
||||
tools.gdb-openocd.cmd=arm-none-eabi-gdb
|
||||
tools.gdb-openocd.cmd.windows=arm-none-eabi-gdb.exe
|
||||
tools.gdb-openocd.interpreter=console
|
||||
tools.gdb-openocd.debug.pattern="{path}/{cmd}" --interpreter={interpreter} -ex "set remotetimeout 5" -ex "set pagination off" -ex 'target extended-remote | "{tools.openocd.path}/{tools.openocd.cmd}" -s "{tools.openocd.path}/share/openocd/scripts/" --file "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "gdb_port pipe" -c "telnet_port 0"' "{build.path}/{build.project_name}.elf"
|
||||
@@ -45,9 +45,18 @@ Chunked responses are recognized and handled transparently.
|
||||
---
|
||||
---
|
||||
|
||||
### Releases v1.0.2
|
||||
|
||||
1. Make Mutex Lock and delete more reliable and error-proof to prevent random crash.
|
||||
|
||||
### Releases v1.0.1
|
||||
|
||||
1. Restore cpp code besides Impl.h code to use in case of `multiple definition` linker error. Thanks to [Daniel Brunner](https://github.com/0xFEEDC0DE64) to report and make PR in [**Fixed linker errors when included in multiple .cpp files**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/pull/1). See [**HOWTO Fix `Multiple Definitions` Linker Error**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic#HOWTO-Fix-Multiple-Definitions-Linker-Error)
|
||||
|
||||
|
||||
### Releases v1.0.0
|
||||
|
||||
1. Initial coding to add support to STM32F/L/H/G/WB/MP1 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1. Initial coding to add support to **STM32F/L/H/G/WB/MP1** using built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
2. Add examples using STM32 boards.
|
||||
|
||||
#### Currently Supported Boards
|
||||
@@ -67,12 +76,14 @@ Chunked responses are recognized and handled transparently.
|
||||
This library is based on, modified from:
|
||||
|
||||
1. [Bob Lemaire's asyncHTTPrequest Library](https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
## Prerequisite
|
||||
|
||||
1. [`Arduino IDE 1.8.12+` for Arduino](https://www.arduino.cc/en/Main/Software)
|
||||
2. [`ESP8266 Core 2.7.3+`](https://github.com/esp8266/Arduino) for ESP8266-based boards.
|
||||
1. [`Arduino IDE 1.8.13+` for Arduino](https://www.arduino.cc/en/Main/Software)
|
||||
2. [`ESP8266 Core 2.7.4+`](https://github.com/esp8266/Arduino) for ESP8266-based boards.
|
||||
3. [`ESP32 Core 1.0.4+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards
|
||||
4. [`Arduino Core for STM32 1.9.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for for STM32 using built-in Ethernet LAN8742A.
|
||||
5. [`ESPAsyncTCP v1.2.2+`](https://github.com/me-no-dev/ESPAsyncTCP) for ESP8266.
|
||||
@@ -95,7 +106,8 @@ The best and easiest way is to use `Arduino Library Manager`. Search for `AsyncH
|
||||
3. Extract the zip file to `AsyncHTTPRequest_Generic-master` directory
|
||||
4. Copy the whole `AsyncHTTPRequest_Generic-master` folder to Arduino libraries' directory such as `~/Arduino/libraries/`.
|
||||
|
||||
### VS Code & PlatformIO:
|
||||
### VS Code & PlatformIO
|
||||
|
||||
1. Install [VS Code](https://code.visualstudio.com/)
|
||||
2. Install [PlatformIO](https://platformio.org/platformio-ide)
|
||||
3. Install **AsyncHTTPRequest_Generic** library by using [Library Manager](https://docs.platformio.org/en/latest/librarymanager/). Search for ***AsyncHTTPRequest_Generic*** in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22)
|
||||
@@ -106,16 +118,16 @@ The best and easiest way is to use `Arduino Library Manager`. Search for `AsyncH
|
||||
|
||||
### Packages' Patches
|
||||
|
||||
1. ***To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards***, you have to copy the whole [nRF52 0.20.5](Packages_Patches/adafruit/hardware/nrf52/0.20.5) directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5).
|
||||
1. ***To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards***, you have to copy the whole [nRF52 0.21.0](Packages_Patches/adafruit/hardware/nrf52/0.21.0) directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0).
|
||||
|
||||
Supposing the Adafruit nRF52 version is 0.20.5. These files must be copied into the directory:
|
||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/platform.txt`
|
||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/boards.txt`
|
||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/variant.h`
|
||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/variants/NINA_B302_ublox/variant.cpp`
|
||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/variant.h`
|
||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/variants/NINA_B112_ublox/variant.cpp`
|
||||
- ***`~/.arduino15/packages/adafruit/hardware/nrf52/0.20.5/cores/nRF5/Udp.h`***
|
||||
Supposing the Adafruit nRF52 version is 0.21.0. These files must be copied into the directory:
|
||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/platform.txt`
|
||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/boards.txt`
|
||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.h`
|
||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.cpp`
|
||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.h`
|
||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.cpp`
|
||||
- ***`~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Udp.h`***
|
||||
|
||||
Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z
|
||||
These files must be copied into the directory:
|
||||
@@ -150,11 +162,11 @@ This file must be copied into the directory:
|
||||
|
||||
- `~/.arduino15/packages/arduino/hardware/sam/x.yy.zz/platform.txt`
|
||||
|
||||
4. ***To be able to compile without error and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards***, you have to copy the whole [Arduino SAMD cores 1.8.8](Packages_Patches/arduino/hardware/samd/1.8.8) directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.8).
|
||||
4. ***To be able to compile without error and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards***, you have to copy the whole [Arduino SAMD cores 1.8.9](Packages_Patches/arduino/hardware/samd/1.8.9) directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.9).
|
||||
|
||||
Supposing the Arduino SAMD version is 1.8.8. These files must be copied into the directory:
|
||||
- `~/.arduino15/packages/arduino/hardware/samd/1.8.8/platform.txt`
|
||||
- ***`~/.arduino15/packages/arduino/hardware/samd/1.8.8/cores/arduino/Arduino.h`***
|
||||
Supposing the Arduino SAMD version is 1.8.9. These files must be copied into the directory:
|
||||
- `~/.arduino15/packages/arduino/hardware/samd/1.8.9/platform.txt`
|
||||
- ***`~/.arduino15/packages/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.h`***
|
||||
|
||||
Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z
|
||||
|
||||
@@ -172,22 +184,22 @@ These files must be copied into the directory:
|
||||
|
||||
Whenever the above-mentioned compiler error issue is fixed with the new Arduino SAMD release, you don't need to copy the `Arduino.h` file anymore.
|
||||
|
||||
5. ***To be able to automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the file [Adafruit SAMD platform.txt](Packages_Patches/adafruit/hardware/samd/1.6.0) into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.6.0).
|
||||
5. ***To be able to automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the file [Adafruit SAMD platform.txt](Packages_Patches/adafruit/hardware/samd/1.6.4) into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.6.4).
|
||||
|
||||
Supposing the Adafruit SAMD core version is 1.6.0. This file must be copied into the directory:
|
||||
Supposing the Adafruit SAMD core version is 1.6.4. This file must be copied into the directory:
|
||||
|
||||
- `~/.arduino15/packages/adafruit/hardware/samd/1.6.0/platform.txt`
|
||||
- `~/.arduino15/packages/adafruit/hardware/samd/1.6.4/platform.txt`
|
||||
|
||||
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
|
||||
This file must be copied into the directory:
|
||||
|
||||
- `~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/platform.txt`
|
||||
|
||||
6. ***To be able to automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards***, you have to copy the file [Seeeduino SAMD platform.txt](Packages_Patches/Seeeduino/hardware/samd/1.7.8) into Adafruit samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.7.8).
|
||||
6. ***To be able to automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards***, you have to copy the file [Seeeduino SAMD platform.txt](Packages_Patches/Seeeduino/hardware/samd/1.8.1) into Adafruit samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.1).
|
||||
|
||||
Supposing the Seeeduino SAMD core version is 1.7.8. This file must be copied into the directory:
|
||||
Supposing the Seeeduino SAMD core version is 1.8.1. This file must be copied into the directory:
|
||||
|
||||
- `~/.arduino15/packages/Seeeduino/hardware/samd/1.7.8/platform.txt`
|
||||
- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.1/platform.txt`
|
||||
|
||||
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
|
||||
This file must be copied into the directory:
|
||||
@@ -210,12 +222,69 @@ theses files must be copied into the corresponding directory:
|
||||
---
|
||||
---
|
||||
|
||||
### HOWTO Fix `Multiple Definitions` Linker Error
|
||||
|
||||
The current library implementation, using xyz-Impl.h instead of standard xyz.cpp, possibly creates certain `Multiple Definitions` Linker error in certain use cases. Although it's simple to just modify several lines of code, either in the library or in the application, the library is adding a separate source directory, named src_cpp, besides the standard src directory.
|
||||
|
||||
To use the old standard cpp way, just
|
||||
|
||||
1. **Rename the h-only src directory into src_h.**
|
||||
2. **Then rename the cpp src_cpp directory into src.**
|
||||
3. Close then reopen the application code in Arduino IDE, etc. to recompile from scratch.
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
### HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)
|
||||
|
||||
Please have a look at [**ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example**](https://github.com/khoih-prog/ESP_WiFiManager/issues/39) to have more detailed description and solution of the issue.
|
||||
|
||||
#### 1. ESP32 has 2 ADCs, named ADC1 and ADC2
|
||||
|
||||
#### 2. ESP32 ADCs functions
|
||||
|
||||
- ADC1 controls ADC function for pins **GPIO32-GPIO39**
|
||||
- ADC2 controls ADC function for pins **GPIO0, 2, 4, 12-15, 25-27**
|
||||
|
||||
#### 3.. ESP32 WiFi uses ADC2 for WiFi functions
|
||||
|
||||
Look in file [**adc_common.c**](https://github.com/espressif/esp-idf/blob/master/components/driver/adc_common.c#L61)
|
||||
|
||||
> In ADC2, there're two locks used for different cases:
|
||||
> 1. lock shared with app and Wi-Fi:
|
||||
> ESP32:
|
||||
> When Wi-Fi using the ADC2, we assume it will never stop, so app checks the lock and returns immediately if failed.
|
||||
> ESP32S2:
|
||||
> The controller's control over the ADC is determined by the arbiter. There is no need to control by lock.
|
||||
>
|
||||
> 2. lock shared between tasks:
|
||||
> when several tasks sharing the ADC2, we want to guarantee
|
||||
> all the requests will be handled.
|
||||
> Since conversions are short (about 31us), app returns the lock very soon,
|
||||
> we use a spinlock to stand there waiting to do conversions one by one.
|
||||
>
|
||||
> adc2_spinlock should be acquired first, then adc2_wifi_lock or rtc_spinlock.
|
||||
|
||||
|
||||
- In order to use ADC2 for other functions, we have to **acquire complicated firmware locks and very difficult to do**
|
||||
- So, it's not advisable to use ADC2 with WiFi/BlueTooth (BT/BLE).
|
||||
- Use ADC1, and pins GPIO32-GPIO39
|
||||
- If somehow it's a must to use those pins serviced by ADC2 (**GPIO0, 2, 4, 12, 13, 14, 15, 25, 26 and 27**), use the **fix mentioned at the end** of [**ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example**](https://github.com/khoih-prog/ESP_WiFiManager/issues/39) to work with ESP32 WiFi/BlueTooth (BT/BLE).
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
### Examples
|
||||
|
||||
Also see examples:
|
||||
1. [AsyncHTTPRequest_ESP](examples/AsyncHTTPRequest_ESP)
|
||||
2. [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager)
|
||||
3. [AsyncHTTPRequest_STM32](examples/AsyncHTTPRequest_STM32)
|
||||
4. [AsyncCustomHeader_STM32](examples/AsyncCustomHeader_STM32)
|
||||
5. [AsyncDweetGet_STM32](examples/AsyncDweetGet_STM32)
|
||||
6. [AsyncDweetPost_STM32](examples/AsyncDweetPost_STM32)
|
||||
7. [AsyncSimpleGET_STM32](examples/AsyncSimpleGET_STM32)
|
||||
8. [AsyncWebClientRepeating_STM32](examples/AsyncWebClientRepeating_STM32)
|
||||
|
||||
---
|
||||
|
||||
@@ -228,12 +297,12 @@ Please take a look at other examples, as well.
|
||||
```cpp
|
||||
#include "defines.h"
|
||||
|
||||
// 600s = 10 minutes to not flooding
|
||||
#define HTTP_REQUEST_INTERVAL_MS 600000
|
||||
// 600s = 10 minutes to not flooding, 10s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 10000 // 600000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
@@ -435,7 +504,7 @@ AsyncHTTPRequest @ IP : 192.168.2.72
|
||||
|
||||
**************************************
|
||||
abbreviation: EDT
|
||||
client_ip: 216.154.52.212
|
||||
client_ip: aaa.bbb.ccc.ddd
|
||||
datetime: 2020-09-13T18:22:59.555816-04:00
|
||||
day_of_week: 0
|
||||
day_of_year: 257
|
||||
@@ -452,7 +521,7 @@ week_number: 37
|
||||
|
||||
**************************************
|
||||
abbreviation: EDT
|
||||
client_ip: 216.154.52.212
|
||||
client_ip: aaa.bbb.ccc.ddd
|
||||
datetime: 2020-09-13T18:27:57.586325-04:00
|
||||
day_of_week: 0
|
||||
day_of_year: 257
|
||||
@@ -482,7 +551,7 @@ After waiting 3.43 secs more in setup(), connection result is connected. Local I
|
||||
H
|
||||
**************************************
|
||||
abbreviation: EDT
|
||||
client_ip: 216.154.52.212
|
||||
client_ip: aaa.bbb.ccc.ddd
|
||||
datetime: 2020-09-13T19:35:37.951609-04:00
|
||||
day_of_week: 0
|
||||
day_of_year: 257
|
||||
@@ -514,7 +583,7 @@ After waiting 2.35 secs more in setup(), connection result is connected. Local I
|
||||
H
|
||||
**************************************
|
||||
abbreviation: EDT
|
||||
client_ip: 216.154.52.212
|
||||
client_ip: aaa.bbb.ccc.ddd
|
||||
datetime: 2020-09-13T19:37:02.118166-04:00
|
||||
day_of_week: 0
|
||||
day_of_year: 257
|
||||
@@ -532,7 +601,7 @@ week_number: 37
|
||||
HHHHHHHHH HHHHHHHHHH HHHHHHHHHH H
|
||||
**************************************
|
||||
abbreviation: EDT
|
||||
client_ip: 216.154.52.212
|
||||
client_ip: aaa.bbb.ccc.ddd
|
||||
datetime: 2020-09-13T19:42:01.507586-04:00
|
||||
day_of_week: 0
|
||||
day_of_year: 257
|
||||
@@ -563,7 +632,7 @@ HTTP WebServer is @ IP : 192.168.2.81
|
||||
|
||||
**************************************
|
||||
abbreviation: EDT
|
||||
client_ip: 216.154.52.212
|
||||
client_ip: aaa.bbb.ccc.ddd
|
||||
datetime: 2020-09-13T19:56:28.295033-04:00
|
||||
day_of_week: 0
|
||||
day_of_year: 257
|
||||
@@ -581,6 +650,60 @@ week_number: 37
|
||||
HHHHHHHHH HHHHHHHHHH HHHHHHHHHH H
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### 5. [AsyncWebClientRepeating_STM32](examples/AsyncWebClientRepeating_STM32) running on STM32F7 Nucleo-144 NUCLEO_F767ZI using built-in LAN8742A
|
||||
|
||||
|
||||
```
|
||||
Start AsyncWebClientRepeating_STM32 on NUCLEO_F767ZI
|
||||
AsyncHTTPRequest @ IP : 192.168.2.72
|
||||
|
||||
**************************************
|
||||
|
||||
`:;;;,` .:;;:.
|
||||
.;;;;;;;;;;;` :;;;;;;;;;;: TM
|
||||
`;;;;;;;;;;;;;;;` :;;;;;;;;;;;;;;;
|
||||
:;;;;;;;;;;;;;;;;;; `;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;; .;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;:` `;;;;;;;;; ,;;;;;;;;.` .;;;;;;;;
|
||||
.;;;;;;, :;;;;;;; .;;;;;;; ;;;;;;;
|
||||
;;;;;; ;;;;;;; ;;;;;;, ;;;;;;.
|
||||
,;;;;; ;;;;;;.;;;;;;` ;;;;;;
|
||||
;;;;;. ;;;;;;;;;;;` ``` ;;;;;`
|
||||
;;;;; ;;;;;;;;;, ;;; .;;;;;
|
||||
`;;;;: `;;;;;;;; ;;; ;;;;;
|
||||
,;;;;` `,,,,,,,, ;;;;;;; .,,;;;,,, ;;;;;
|
||||
:;;;;` .;;;;;;;; ;;;;;, :;;;;;;;; ;;;;;
|
||||
:;;;;` .;;;;;;;; `;;;;;; :;;;;;;;; ;;;;;
|
||||
.;;;;. ;;;;;;;. ;;; ;;;;;
|
||||
;;;;; ;;;;;;;;; ;;; ;;;;;
|
||||
;;;;; .;;;;;;;;;; ;;; ;;;;;,
|
||||
;;;;;; `;;;;;;;;;;;; ;;;;;
|
||||
`;;;;;, .;;;;;; ;;;;;;; ;;;;;;
|
||||
;;;;;;: :;;;;;;. ;;;;;;; ;;;;;;
|
||||
;;;;;;;` .;;;;;;;, ;;;;;;;; ;;;;;;;:
|
||||
;;;;;;;;;:,:;;;;;;;;;: ;;;;;;;;;;:,;;;;;;;;;;
|
||||
`;;;;;;;;;;;;;;;;;;;. ;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;; :;;;;;;;;;;;;;;;;:
|
||||
,;;;;;;;;;;;;;, ;;;;;;;;;;;;;;
|
||||
.;;;;;;;;;` ,;;;;;;;;:
|
||||
|
||||
|
||||
|
||||
|
||||
;;; ;;;;;` ;;;;: .;; ;; ,;;;;;, ;;. `;, ;;;;
|
||||
;;; ;;:;;; ;;;;;; .;; ;; ,;;;;;: ;;; `;, ;;;:;;
|
||||
,;:; ;; ;; ;; ;; .;; ;; ,;, ;;;,`;, ;; ;;
|
||||
;; ;: ;; ;; ;; ;; .;; ;; ,;, ;;;;`;, ;; ;;.
|
||||
;: ;; ;;;;;: ;; ;; .;; ;; ,;, ;;`;;;, ;; ;;`
|
||||
,;;;;; ;;`;; ;; ;; .;; ;; ,;, ;; ;;;, ;; ;;
|
||||
;; ,;, ;; .;; ;;;;;: ;;;;;: ,;;;;;: ;; ;;, ;;;;;;
|
||||
;; ;; ;; ;;` ;;;;. `;;;: ,;;;;;, ;; ;;, ;;;;
|
||||
|
||||
|
||||
```
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
@@ -629,9 +752,17 @@ Submit issues to: [AsyncHTTPRequest_Generic issues](https://github.com/khoih-pro
|
||||
---
|
||||
---
|
||||
|
||||
### Releases v1.0.2
|
||||
|
||||
1. Make Mutex Lock and delete more reliable and error-proof to prevent random crash.
|
||||
|
||||
### Releases v1.0.1
|
||||
|
||||
1. Restore cpp code besides Impl.h code to use in case of `multiple definition` linker error. Thanks to [Daniel Brunner](https://github.com/0xFEEDC0DE64) to report and make PR in [**Fixed linker errors when included in multiple .cpp files**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/pull/1). See [**HOWTO Fix `Multiple Definitions` Linker Error**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic#HOWTO-Fix-Multiple-Definitions-Linker-Error)
|
||||
|
||||
### Releases v1.0.0
|
||||
|
||||
1. Initial coding to add support to STM32F/L/H/G/WB/MP1 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1. Initial coding to add support to **STM32F/L/H/G/WB/MP1** using built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
2. Add examples using STM32 boards.
|
||||
|
||||
---
|
||||
@@ -641,16 +772,19 @@ Submit issues to: [AsyncHTTPRequest_Generic issues](https://github.com/khoih-pro
|
||||
|
||||
This library is based on, modified, bug-fixed and improved from:
|
||||
|
||||
1. [Bob Lemaire's asyncHTTPrequest Library](https://github.com/boblemaire/asyncHTTPrequest)
|
||||
1. [Bob Lemaire's **asyncHTTPrequest Library**](https://github.com/boblemaire/asyncHTTPrequest) to use the better **asynchronous** features of these following Async TCP Libraries : ( [`ESPAsyncTCP`](https://github.com/me-no-dev/ESPAsyncTCP), [`AsyncTCP`](https://github.com/me-no-dev/AsyncTCP), and [`STM32AsyncTCP`](https://github.com/philbowles/STM32AsyncTCP) ).
|
||||
|
||||
to use the better **asynchronous** features of these following Async TCP Libraries : ( [`ESPAsyncTCP`](https://github.com/me-no-dev/ESPAsyncTCP), [`AsyncTCP`](https://github.com/me-no-dev/AsyncTCP), and [`STM32AsyncTCP`](https://github.com/philbowles/STM32AsyncTCP) ).
|
||||
2. Thanks to [Daniel Brunner](https://github.com/0xFEEDC0DE64) to report and make PR in [Fixed linker errors when included in multiple .cpp files](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/pull/1) leading to v1.0.1. See [**HOWTO Fix `Multiple Definitions` Linker Error**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic#HOWTO-Fix-Multiple-Definitions-Linker-Error)
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/boblemaire"><img src="https://github.com/boblemaire.png" width="100px;" alt="boblemaire"/><br /><sub><b>⭐️ Bob Lemaire</b></sub></a><br /></td>
|
||||
<td align="center"><a href="https://github.com/0xFEEDC0DE64"><img src="https://github.com/0xFEEDC0DE64.png" width="100px;" alt="0xFEEDC0DE64"/><br /><sub><b>Daniel Brunner</b></sub></a><br /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
---
|
||||
|
||||
### Contributing
|
||||
|
||||
If you want to contribute to this project:
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncCustomHeader_STM32.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// Select a test server address
|
||||
//char GET_ServerAddress[] = "192.168.2.110/";
|
||||
char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt";
|
||||
|
||||
// 600s = 10 minutes to not flooding, 10s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 10000 //600000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
{
|
||||
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
|
||||
{
|
||||
Serial.println("\nSending GET Request to " + String(GET_ServerAddress));
|
||||
|
||||
request.open("GET", GET_ServerAddress);
|
||||
//request.setReqHeader("X-CUSTOM-HEADER", "custom_value");
|
||||
request.send();
|
||||
}
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
{
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("\nStart AsyncCustomHeader_STM32 on " + String(BOARD_NAME));
|
||||
|
||||
// start the ethernet connection and the server
|
||||
// Use random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
// Use Static IP
|
||||
//Ethernet.begin(mac[index], ip);
|
||||
// Use DHCP dynamic IP and random mac
|
||||
Ethernet.begin(mac[index]);
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(Ethernet.localIP());
|
||||
Serial.println();
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
// 5s timeout
|
||||
request.setTimeout(5);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
|
||||
sendHTTPRequest.start(); //start the ticker.
|
||||
|
||||
// Send first request now
|
||||
delay(10000);
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/****************************************************************************************************************************
|
||||
defines.h
|
||||
|
||||
Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
/*
|
||||
Currently support
|
||||
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
|
||||
- Nucleo-144 (F429ZI, F767ZI)
|
||||
- Discovery (STM32F746G-DISCOVERY)
|
||||
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
|
||||
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
|
||||
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
|
||||
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
|
||||
*/
|
||||
|
||||
#ifndef defines_h
|
||||
#define defines_h
|
||||
|
||||
#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
|
||||
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
||||
defined(STM32WB) || defined(STM32MP1) )
|
||||
#error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
|
||||
#if defined(STM32F0)
|
||||
#warning STM32F0 board selected
|
||||
#define BOARD_TYPE "STM32F0"
|
||||
#elif defined(STM32F1)
|
||||
#warning STM32F1 board selected
|
||||
#define BOARD_TYPE "STM32F1"
|
||||
#elif defined(STM32F2)
|
||||
#warning STM32F2 board selected
|
||||
#define BOARD_TYPE "STM32F2"
|
||||
#elif defined(STM32F3)
|
||||
#warning STM32F3 board selected
|
||||
#define BOARD_TYPE "STM32F3"
|
||||
#elif defined(STM32F4)
|
||||
#warning STM32F4 board selected
|
||||
#define BOARD_TYPE "STM32F4"
|
||||
#elif defined(STM32F7)
|
||||
#warning STM32F7 board selected
|
||||
#define BOARD_TYPE "STM32F7"
|
||||
#elif defined(STM32L0)
|
||||
#warning STM32L0 board selected
|
||||
#define BOARD_TYPE "STM32L0"
|
||||
#elif defined(STM32L1)
|
||||
#warning STM32L1 board selected
|
||||
#define BOARD_TYPE "STM32L1"
|
||||
#elif defined(STM32L4)
|
||||
#warning STM32L4 board selected
|
||||
#define BOARD_TYPE "STM32L4"
|
||||
#elif defined(STM32H7)
|
||||
#warning STM32H7 board selected
|
||||
#define BOARD_TYPE "STM32H7"
|
||||
#elif defined(STM32G0)
|
||||
#warning STM32G0 board selected
|
||||
#define BOARD_TYPE "STM32G0"
|
||||
#elif defined(STM32G4)
|
||||
#warning STM32G4 board selected
|
||||
#define BOARD_TYPE "STM32G4"
|
||||
#elif defined(STM32WB)
|
||||
#warning STM32WB board selected
|
||||
#define BOARD_TYPE "STM32WB"
|
||||
#elif defined(STM32MP1)
|
||||
#warning STM32MP1 board selected
|
||||
#define BOARD_TYPE "STM32MP1"
|
||||
#else
|
||||
#warning STM32 unknown board selected
|
||||
#define BOARD_TYPE "STM32 Unknown"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_NAME
|
||||
#define BOARD_NAME BOARD_TYPE
|
||||
#endif
|
||||
|
||||
#include <LwIP.h>
|
||||
#include <STM32Ethernet.h>
|
||||
|
||||
//#include <AsyncUDP_STM32.h>
|
||||
|
||||
// Enter a MAC address and IP address for your controller below.
|
||||
#define NUMBER_OF_MAC 20
|
||||
|
||||
byte mac[][NUMBER_OF_MAC] =
|
||||
{
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
|
||||
};
|
||||
|
||||
// Select the static IP address according to your local network
|
||||
IPAddress ip(192, 168, 2, 232);
|
||||
|
||||
#endif //defines_h
|
||||
@@ -0,0 +1,149 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncDweetGET_STM32.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
/**
|
||||
Connects to dweet.io once every 1 minutes, sends a GET request and a request body.
|
||||
|
||||
Shows how to use Strings to assemble path and parse content from response.
|
||||
dweet.io expects: https://dweet.io/dweet/for/thingName
|
||||
|
||||
For more on dweet.io, see https://dweet.io/play/
|
||||
* */
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// Select a test server address
|
||||
const char GET_ServerAddress[] = "dweet.io";
|
||||
|
||||
// use your own thing name here
|
||||
String dweetName = "/dweet/for/currentSecond?second=";
|
||||
|
||||
// 10s = 10 seconds to not flooding the server
|
||||
#define HTTP_REQUEST_INTERVAL_MS 10000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
{
|
||||
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
|
||||
{
|
||||
request.open("GET", (GET_ServerAddress + dweetName + String(millis()/1000)).c_str() );
|
||||
request.send();
|
||||
}
|
||||
}
|
||||
|
||||
void parseResponse(String responseText)
|
||||
{
|
||||
/*
|
||||
Typical response is:
|
||||
{"this":"succeeded",
|
||||
"by":"getting",
|
||||
"the":"dweets",
|
||||
"with":[{"thing":"my-thing-name",
|
||||
"created":"2016-02-16T05:10:36.589Z",
|
||||
"content":{"sensorValue":456}}]}
|
||||
|
||||
You want "content": numberValue
|
||||
*/
|
||||
// now parse the response looking for "content":
|
||||
int labelStart = responseText.indexOf("content\":");
|
||||
// find the first { after "content":
|
||||
int contentStart = responseText.indexOf("{", labelStart);
|
||||
// find the following } and get what's between the braces:
|
||||
int contentEnd = responseText.indexOf("}", labelStart);
|
||||
String content = responseText.substring(contentStart + 1, contentEnd);
|
||||
|
||||
Serial.println(content);
|
||||
|
||||
// now get the value after the colon, and convert to an int:
|
||||
int valueStart = content.indexOf(":");
|
||||
String valueString = content.substring(valueStart + 1);
|
||||
int number = valueString.toInt();
|
||||
|
||||
Serial.print("Value string: ");
|
||||
Serial.println(valueString);
|
||||
Serial.print("Actual value: ");
|
||||
Serial.println(number);
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
{
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
String responseText = request->responseText();
|
||||
|
||||
Serial.println("\n**************************************");
|
||||
//Serial.println(request->responseText());
|
||||
Serial.println(responseText);
|
||||
Serial.println("**************************************");
|
||||
|
||||
parseResponse(responseText);
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("\nStart AsyncDweetGET_STM32 on " + String(BOARD_NAME));
|
||||
|
||||
// start the ethernet connection and the server
|
||||
// Use random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
// Use Static IP
|
||||
//Ethernet.begin(mac[index], ip);
|
||||
// Use DHCP dynamic IP and random mac
|
||||
Ethernet.begin(mac[index]);
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(Ethernet.localIP());
|
||||
Serial.println();
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
sendHTTPRequest.start(); //start the ticker.
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/****************************************************************************************************************************
|
||||
defines.h
|
||||
|
||||
Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
/*
|
||||
Currently support
|
||||
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
|
||||
- Nucleo-144 (F429ZI, F767ZI)
|
||||
- Discovery (STM32F746G-DISCOVERY)
|
||||
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
|
||||
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
|
||||
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
|
||||
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
|
||||
*/
|
||||
|
||||
#ifndef defines_h
|
||||
#define defines_h
|
||||
|
||||
#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
|
||||
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
||||
defined(STM32WB) || defined(STM32MP1) )
|
||||
#error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
|
||||
#if defined(STM32F0)
|
||||
#warning STM32F0 board selected
|
||||
#define BOARD_TYPE "STM32F0"
|
||||
#elif defined(STM32F1)
|
||||
#warning STM32F1 board selected
|
||||
#define BOARD_TYPE "STM32F1"
|
||||
#elif defined(STM32F2)
|
||||
#warning STM32F2 board selected
|
||||
#define BOARD_TYPE "STM32F2"
|
||||
#elif defined(STM32F3)
|
||||
#warning STM32F3 board selected
|
||||
#define BOARD_TYPE "STM32F3"
|
||||
#elif defined(STM32F4)
|
||||
#warning STM32F4 board selected
|
||||
#define BOARD_TYPE "STM32F4"
|
||||
#elif defined(STM32F7)
|
||||
#warning STM32F7 board selected
|
||||
#define BOARD_TYPE "STM32F7"
|
||||
#elif defined(STM32L0)
|
||||
#warning STM32L0 board selected
|
||||
#define BOARD_TYPE "STM32L0"
|
||||
#elif defined(STM32L1)
|
||||
#warning STM32L1 board selected
|
||||
#define BOARD_TYPE "STM32L1"
|
||||
#elif defined(STM32L4)
|
||||
#warning STM32L4 board selected
|
||||
#define BOARD_TYPE "STM32L4"
|
||||
#elif defined(STM32H7)
|
||||
#warning STM32H7 board selected
|
||||
#define BOARD_TYPE "STM32H7"
|
||||
#elif defined(STM32G0)
|
||||
#warning STM32G0 board selected
|
||||
#define BOARD_TYPE "STM32G0"
|
||||
#elif defined(STM32G4)
|
||||
#warning STM32G4 board selected
|
||||
#define BOARD_TYPE "STM32G4"
|
||||
#elif defined(STM32WB)
|
||||
#warning STM32WB board selected
|
||||
#define BOARD_TYPE "STM32WB"
|
||||
#elif defined(STM32MP1)
|
||||
#warning STM32MP1 board selected
|
||||
#define BOARD_TYPE "STM32MP1"
|
||||
#else
|
||||
#warning STM32 unknown board selected
|
||||
#define BOARD_TYPE "STM32 Unknown"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_NAME
|
||||
#define BOARD_NAME BOARD_TYPE
|
||||
#endif
|
||||
|
||||
#include <LwIP.h>
|
||||
#include <STM32Ethernet.h>
|
||||
|
||||
//#include <AsyncUDP_STM32.h>
|
||||
|
||||
// Enter a MAC address and IP address for your controller below.
|
||||
#define NUMBER_OF_MAC 20
|
||||
|
||||
byte mac[][NUMBER_OF_MAC] =
|
||||
{
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
|
||||
};
|
||||
|
||||
// Select the static IP address according to your local network
|
||||
IPAddress ip(192, 168, 2, 232);
|
||||
|
||||
#endif //defines_h
|
||||
@@ -0,0 +1,148 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncDweetPOST_STM32.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
// Dweet.io POST client. Connects to dweet.io once every ten seconds, sends a POST request and a request body.
|
||||
// Shows how to use Strings to assemble path and body
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// Select a test server address
|
||||
const char POST_ServerAddress[] = "dweet.io";
|
||||
|
||||
// use your own thing name here
|
||||
String dweetName = "/dweet/for/pinA0-Read?";
|
||||
|
||||
// 10s = 10 seconds to not flooding the server
|
||||
#define HTTP_REQUEST_INTERVAL_MS 10000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
{
|
||||
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
|
||||
{
|
||||
String postData = "sensorValue=";
|
||||
postData += analogRead(A0);
|
||||
|
||||
Serial.println("\nMaking new POST request");
|
||||
|
||||
request.open("POST", (POST_ServerAddress + dweetName + postData).c_str() );
|
||||
request.send();
|
||||
}
|
||||
}
|
||||
|
||||
void parseResponse(String responseText)
|
||||
{
|
||||
/*
|
||||
Typical response is:
|
||||
{"this":"succeeded",
|
||||
"by":"getting",
|
||||
"the":"dweets",
|
||||
"with":[{"thing":"my-thing-name",
|
||||
"created":"2016-02-16T05:10:36.589Z",
|
||||
"content":{"sensorValue":456}}]}
|
||||
|
||||
You want "content": numberValue
|
||||
*/
|
||||
// now parse the response looking for "content":
|
||||
int labelStart = responseText.indexOf("content\":");
|
||||
// find the first { after "content":
|
||||
int contentStart = responseText.indexOf("{", labelStart);
|
||||
// find the following } and get what's between the braces:
|
||||
int contentEnd = responseText.indexOf("}", labelStart);
|
||||
String content = responseText.substring(contentStart + 1, contentEnd);
|
||||
|
||||
Serial.println(content);
|
||||
|
||||
// now get the value after the colon, and convert to an int:
|
||||
int valueStart = content.indexOf(":");
|
||||
String valueString = content.substring(valueStart + 1);
|
||||
int number = valueString.toInt();
|
||||
|
||||
Serial.print("Value string: ");
|
||||
Serial.println(valueString);
|
||||
Serial.print("Actual value: ");
|
||||
Serial.println(number);
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
{
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
String responseText = request->responseText();
|
||||
|
||||
Serial.println("\n**************************************");
|
||||
//Serial.println(request->responseText());
|
||||
Serial.println(responseText);
|
||||
Serial.println("**************************************");
|
||||
|
||||
parseResponse(responseText);
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("\nStart AsyncDweetPOST_STM32 on " + String(BOARD_NAME));
|
||||
|
||||
// start the ethernet connection and the server
|
||||
// Use random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
// Use Static IP
|
||||
//Ethernet.begin(mac[index], ip);
|
||||
// Use DHCP dynamic IP and random mac
|
||||
Ethernet.begin(mac[index]);
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(Ethernet.localIP());
|
||||
Serial.println();
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
sendHTTPRequest.start(); //start the ticker.
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/****************************************************************************************************************************
|
||||
defines.h
|
||||
|
||||
Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
/*
|
||||
Currently support
|
||||
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
|
||||
- Nucleo-144 (F429ZI, F767ZI)
|
||||
- Discovery (STM32F746G-DISCOVERY)
|
||||
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
|
||||
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
|
||||
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
|
||||
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
|
||||
*/
|
||||
|
||||
#ifndef defines_h
|
||||
#define defines_h
|
||||
|
||||
#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
|
||||
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
||||
defined(STM32WB) || defined(STM32MP1) )
|
||||
#error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
|
||||
#if defined(STM32F0)
|
||||
#warning STM32F0 board selected
|
||||
#define BOARD_TYPE "STM32F0"
|
||||
#elif defined(STM32F1)
|
||||
#warning STM32F1 board selected
|
||||
#define BOARD_TYPE "STM32F1"
|
||||
#elif defined(STM32F2)
|
||||
#warning STM32F2 board selected
|
||||
#define BOARD_TYPE "STM32F2"
|
||||
#elif defined(STM32F3)
|
||||
#warning STM32F3 board selected
|
||||
#define BOARD_TYPE "STM32F3"
|
||||
#elif defined(STM32F4)
|
||||
#warning STM32F4 board selected
|
||||
#define BOARD_TYPE "STM32F4"
|
||||
#elif defined(STM32F7)
|
||||
#warning STM32F7 board selected
|
||||
#define BOARD_TYPE "STM32F7"
|
||||
#elif defined(STM32L0)
|
||||
#warning STM32L0 board selected
|
||||
#define BOARD_TYPE "STM32L0"
|
||||
#elif defined(STM32L1)
|
||||
#warning STM32L1 board selected
|
||||
#define BOARD_TYPE "STM32L1"
|
||||
#elif defined(STM32L4)
|
||||
#warning STM32L4 board selected
|
||||
#define BOARD_TYPE "STM32L4"
|
||||
#elif defined(STM32H7)
|
||||
#warning STM32H7 board selected
|
||||
#define BOARD_TYPE "STM32H7"
|
||||
#elif defined(STM32G0)
|
||||
#warning STM32G0 board selected
|
||||
#define BOARD_TYPE "STM32G0"
|
||||
#elif defined(STM32G4)
|
||||
#warning STM32G4 board selected
|
||||
#define BOARD_TYPE "STM32G4"
|
||||
#elif defined(STM32WB)
|
||||
#warning STM32WB board selected
|
||||
#define BOARD_TYPE "STM32WB"
|
||||
#elif defined(STM32MP1)
|
||||
#warning STM32MP1 board selected
|
||||
#define BOARD_TYPE "STM32MP1"
|
||||
#else
|
||||
#warning STM32 unknown board selected
|
||||
#define BOARD_TYPE "STM32 Unknown"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_NAME
|
||||
#define BOARD_NAME BOARD_TYPE
|
||||
#endif
|
||||
|
||||
#include <LwIP.h>
|
||||
#include <STM32Ethernet.h>
|
||||
|
||||
//#include <AsyncUDP_STM32.h>
|
||||
|
||||
// Enter a MAC address and IP address for your controller below.
|
||||
#define NUMBER_OF_MAC 20
|
||||
|
||||
byte mac[][NUMBER_OF_MAC] =
|
||||
{
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
|
||||
};
|
||||
|
||||
// Select the static IP address according to your local network
|
||||
IPAddress ip(192, 168, 2, 232);
|
||||
|
||||
#endif //defines_h
|
||||
@@ -17,11 +17,13 @@
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.0
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
//************************************************************************************************************
|
||||
//
|
||||
@@ -55,7 +57,7 @@
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
// 300s = 5 minutes to not flooding
|
||||
#define HTTP_REQUEST_INTERVAL 300
|
||||
#define HTTP_REQUEST_INTERVAL 30 //300
|
||||
|
||||
// 10s
|
||||
#define HEARTBEAT_INTERVAL 10
|
||||
@@ -76,6 +78,7 @@ const char* password = "your_pass";
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
Ticker ticker;
|
||||
Ticker ticker1;
|
||||
|
||||
void heartBeatPrint(void)
|
||||
{
|
||||
@@ -105,6 +108,10 @@ void sendRequest()
|
||||
request.open("GET", "http://worldtimeapi.org/api/timezone/America/Toronto.txt");
|
||||
request.send();
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Can't send request");
|
||||
}
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
@@ -129,13 +136,6 @@ void setup()
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
if (WiFi.status() == WL_NO_SHIELD)
|
||||
{
|
||||
Serial.println(F("WiFi shield not present"));
|
||||
// don't continue
|
||||
while (true);
|
||||
}
|
||||
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
Serial.println("Connecting to WiFi SSID: " + String(ssid));
|
||||
@@ -154,7 +154,7 @@ void setup()
|
||||
request.onReadyStateChange(requestCB);
|
||||
ticker.attach(HTTP_REQUEST_INTERVAL, sendRequest);
|
||||
|
||||
ticker.attach(HEARTBEAT_INTERVAL, heartBeatPrint);
|
||||
ticker1.attach(HEARTBEAT_INTERVAL, heartBeatPrint);
|
||||
|
||||
// Send first request now
|
||||
sendRequest();
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.0
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
//************************************************************************************************************
|
||||
//
|
||||
@@ -54,8 +56,8 @@
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
// 300s = 5 minutes to not flooding
|
||||
#define HTTP_REQUEST_INTERVAL 300
|
||||
// 300s = 5 minutes to not flooding, 10s in testing
|
||||
#define HTTP_REQUEST_INTERVAL 10 //300
|
||||
|
||||
//Ported to ESP32
|
||||
#ifdef ESP32
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.0
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
//************************************************************************************************************
|
||||
//
|
||||
@@ -48,8 +50,8 @@
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// 600s = 10 minutes to not flooding
|
||||
#define HTTP_REQUEST_INTERVAL_MS 600000
|
||||
// 600s = 10 minutes to not flooding, 10s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 10000 //600000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.0
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
/*
|
||||
Currently support
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncSimpleGET_STM32.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// Select a test server address
|
||||
//char GET_ServerAddress[] = "ipv4bot.whatismyipaddress.com/";
|
||||
char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt";
|
||||
|
||||
// 600s = 10 minutes to not flooding, 10s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 10000 //600000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
{
|
||||
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
|
||||
{
|
||||
request.open("GET", GET_ServerAddress);
|
||||
request.send();
|
||||
}
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
{
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("\nStart AsyncSimpleGET_STM32 on " + String(BOARD_NAME));
|
||||
|
||||
// start the ethernet connection and the server
|
||||
// Use random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
// Use Static IP
|
||||
//Ethernet.begin(mac[index], ip);
|
||||
// Use DHCP dynamic IP and random mac
|
||||
Ethernet.begin(mac[index]);
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(Ethernet.localIP());
|
||||
Serial.println();
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
sendHTTPRequest.start(); //start the ticker.
|
||||
|
||||
// Send first request now
|
||||
delay(10000);
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/****************************************************************************************************************************
|
||||
defines.h
|
||||
|
||||
Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
/*
|
||||
Currently support
|
||||
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
|
||||
- Nucleo-144 (F429ZI, F767ZI)
|
||||
- Discovery (STM32F746G-DISCOVERY)
|
||||
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
|
||||
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
|
||||
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
|
||||
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
|
||||
*/
|
||||
|
||||
#ifndef defines_h
|
||||
#define defines_h
|
||||
|
||||
#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
|
||||
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
||||
defined(STM32WB) || defined(STM32MP1) )
|
||||
#error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
|
||||
#if defined(STM32F0)
|
||||
#warning STM32F0 board selected
|
||||
#define BOARD_TYPE "STM32F0"
|
||||
#elif defined(STM32F1)
|
||||
#warning STM32F1 board selected
|
||||
#define BOARD_TYPE "STM32F1"
|
||||
#elif defined(STM32F2)
|
||||
#warning STM32F2 board selected
|
||||
#define BOARD_TYPE "STM32F2"
|
||||
#elif defined(STM32F3)
|
||||
#warning STM32F3 board selected
|
||||
#define BOARD_TYPE "STM32F3"
|
||||
#elif defined(STM32F4)
|
||||
#warning STM32F4 board selected
|
||||
#define BOARD_TYPE "STM32F4"
|
||||
#elif defined(STM32F7)
|
||||
#warning STM32F7 board selected
|
||||
#define BOARD_TYPE "STM32F7"
|
||||
#elif defined(STM32L0)
|
||||
#warning STM32L0 board selected
|
||||
#define BOARD_TYPE "STM32L0"
|
||||
#elif defined(STM32L1)
|
||||
#warning STM32L1 board selected
|
||||
#define BOARD_TYPE "STM32L1"
|
||||
#elif defined(STM32L4)
|
||||
#warning STM32L4 board selected
|
||||
#define BOARD_TYPE "STM32L4"
|
||||
#elif defined(STM32H7)
|
||||
#warning STM32H7 board selected
|
||||
#define BOARD_TYPE "STM32H7"
|
||||
#elif defined(STM32G0)
|
||||
#warning STM32G0 board selected
|
||||
#define BOARD_TYPE "STM32G0"
|
||||
#elif defined(STM32G4)
|
||||
#warning STM32G4 board selected
|
||||
#define BOARD_TYPE "STM32G4"
|
||||
#elif defined(STM32WB)
|
||||
#warning STM32WB board selected
|
||||
#define BOARD_TYPE "STM32WB"
|
||||
#elif defined(STM32MP1)
|
||||
#warning STM32MP1 board selected
|
||||
#define BOARD_TYPE "STM32MP1"
|
||||
#else
|
||||
#warning STM32 unknown board selected
|
||||
#define BOARD_TYPE "STM32 Unknown"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_NAME
|
||||
#define BOARD_NAME BOARD_TYPE
|
||||
#endif
|
||||
|
||||
#include <LwIP.h>
|
||||
#include <STM32Ethernet.h>
|
||||
|
||||
//#include <AsyncUDP_STM32.h>
|
||||
|
||||
// Enter a MAC address and IP address for your controller below.
|
||||
#define NUMBER_OF_MAC 20
|
||||
|
||||
byte mac[][NUMBER_OF_MAC] =
|
||||
{
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
|
||||
};
|
||||
|
||||
// Select the static IP address according to your local network
|
||||
IPAddress ip(192, 168, 2, 232);
|
||||
|
||||
#endif //defines_h
|
||||
@@ -0,0 +1,105 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncWebClientRepeating_STM32.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// Select a test server address
|
||||
const char GET_ServerAddress[] = "arduino.cc";
|
||||
|
||||
// GET location
|
||||
String GET_Location = "/asciilogo.txt";
|
||||
|
||||
// 10s = 10 seconds to not flooding the server
|
||||
#define HTTP_REQUEST_INTERVAL_MS 10000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
{
|
||||
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
|
||||
{
|
||||
request.open("GET", (GET_ServerAddress + GET_Location).c_str());
|
||||
|
||||
request.send();
|
||||
}
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
{
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("\nStart AsyncWebClientRepeating_STM32 on " + String(BOARD_NAME));
|
||||
|
||||
// start the ethernet connection and the server
|
||||
// Use random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
// Use Static IP
|
||||
//Ethernet.begin(mac[index], ip);
|
||||
// Use DHCP dynamic IP and random mac
|
||||
Ethernet.begin(mac[index]);
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(Ethernet.localIP());
|
||||
Serial.println();
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
sendHTTPRequest.start(); //start the ticker
|
||||
|
||||
// Send first request now
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/****************************************************************************************************************************
|
||||
defines.h
|
||||
|
||||
Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
/*
|
||||
Currently support
|
||||
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
|
||||
- Nucleo-144 (F429ZI, F767ZI)
|
||||
- Discovery (STM32F746G-DISCOVERY)
|
||||
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
|
||||
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
|
||||
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
|
||||
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
|
||||
*/
|
||||
|
||||
#ifndef defines_h
|
||||
#define defines_h
|
||||
|
||||
#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
|
||||
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
||||
defined(STM32WB) || defined(STM32MP1) )
|
||||
#error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
|
||||
#if defined(STM32F0)
|
||||
#warning STM32F0 board selected
|
||||
#define BOARD_TYPE "STM32F0"
|
||||
#elif defined(STM32F1)
|
||||
#warning STM32F1 board selected
|
||||
#define BOARD_TYPE "STM32F1"
|
||||
#elif defined(STM32F2)
|
||||
#warning STM32F2 board selected
|
||||
#define BOARD_TYPE "STM32F2"
|
||||
#elif defined(STM32F3)
|
||||
#warning STM32F3 board selected
|
||||
#define BOARD_TYPE "STM32F3"
|
||||
#elif defined(STM32F4)
|
||||
#warning STM32F4 board selected
|
||||
#define BOARD_TYPE "STM32F4"
|
||||
#elif defined(STM32F7)
|
||||
#warning STM32F7 board selected
|
||||
#define BOARD_TYPE "STM32F7"
|
||||
#elif defined(STM32L0)
|
||||
#warning STM32L0 board selected
|
||||
#define BOARD_TYPE "STM32L0"
|
||||
#elif defined(STM32L1)
|
||||
#warning STM32L1 board selected
|
||||
#define BOARD_TYPE "STM32L1"
|
||||
#elif defined(STM32L4)
|
||||
#warning STM32L4 board selected
|
||||
#define BOARD_TYPE "STM32L4"
|
||||
#elif defined(STM32H7)
|
||||
#warning STM32H7 board selected
|
||||
#define BOARD_TYPE "STM32H7"
|
||||
#elif defined(STM32G0)
|
||||
#warning STM32G0 board selected
|
||||
#define BOARD_TYPE "STM32G0"
|
||||
#elif defined(STM32G4)
|
||||
#warning STM32G4 board selected
|
||||
#define BOARD_TYPE "STM32G4"
|
||||
#elif defined(STM32WB)
|
||||
#warning STM32WB board selected
|
||||
#define BOARD_TYPE "STM32WB"
|
||||
#elif defined(STM32MP1)
|
||||
#warning STM32MP1 board selected
|
||||
#define BOARD_TYPE "STM32MP1"
|
||||
#else
|
||||
#warning STM32 unknown board selected
|
||||
#define BOARD_TYPE "STM32 Unknown"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_NAME
|
||||
#define BOARD_NAME BOARD_TYPE
|
||||
#endif
|
||||
|
||||
#include <LwIP.h>
|
||||
#include <STM32Ethernet.h>
|
||||
|
||||
//#include <AsyncUDP_STM32.h>
|
||||
|
||||
// Enter a MAC address and IP address for your controller below.
|
||||
#define NUMBER_OF_MAC 20
|
||||
|
||||
byte mac[][NUMBER_OF_MAC] =
|
||||
{
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
|
||||
};
|
||||
|
||||
// Select the static IP address according to your local network
|
||||
IPAddress ip(192, 168, 2, 232);
|
||||
|
||||
#endif //defines_h
|
||||
+6
-6
@@ -1,18 +1,18 @@
|
||||
{
|
||||
"name":"AsyncHTTPRequest_Generic",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.2",
|
||||
"description":"Simple Async HTTP Request library, supporting GET and POST, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32, ESP8266 and currently STM32 with built-in LAN8742A Ethernet.",
|
||||
"keywords":"async,tcp,http,ESP8266,ESP32,ESPAsyncTCP,AsyncTCP_STM32,stm32,ethernet,wifi,lan8742a",
|
||||
"keywords":"async,tcp,http,ESP8266,ESP32,ESPAsyncTCP,AsyncTCP,stm32,ethernet,wifi,lan8742a",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Bob Lemaire",
|
||||
"url": "https://github.com/boblemaire",
|
||||
}
|
||||
"url": "https://github.com/boblemaire"
|
||||
},
|
||||
{
|
||||
"name": "Khoi Hoang",
|
||||
"url": "https://github.com/khoih-prog",
|
||||
"email": "khoih.prog@gmail.com",
|
||||
"maintainer": true,
|
||||
"maintainer": true
|
||||
}
|
||||
],
|
||||
"repository":
|
||||
@@ -43,7 +43,7 @@
|
||||
{
|
||||
"name": "STM32duino STM32Ethernet",
|
||||
"platforms": "ststm32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "STM32 AsyncTCP",
|
||||
"platforms": "ststm32"
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
name=AsyncHTTPRequest_Generic
|
||||
version=1.0.0
|
||||
author=Bob Lemaire,Khoi Hoang
|
||||
version=1.0.2
|
||||
author=Bob Lemaire,Khoi Hoang <khoih.prog@gmail.com>
|
||||
maintainer=Khoi Hoang <khoih.prog@gmail.com>
|
||||
license=MIT
|
||||
sentence=Simple Async HTTP Request library, supporting GET and POST, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32, ESP8266 and currently STM32 with built-in LAN8742A Ethernet.
|
||||
|
||||
@@ -34,13 +34,21 @@ upload_speed = 921600
|
||||
;monitor_port = COM11
|
||||
|
||||
lib_deps =
|
||||
; PlatformIO 4.x
|
||||
AsyncTCP@~1.1.1
|
||||
ESP AsyncTCP@~1.2.2
|
||||
STM32 AsyncTCP@~1.0.0
|
||||
ESPAsyncTCP@~1.2.2
|
||||
STM32AsyncTCP@~1.0.0
|
||||
STM32duino LwIP@~2.1.2
|
||||
STM32duino STM32Ethernet@~1.2.0
|
||||
ESPAsync_WiFiManager@~1.1.1
|
||||
|
||||
ESPAsync_WiFiManager@~1.1.2
|
||||
; PlatformIO 5.x
|
||||
; me-no-dev/AsyncTCP@~1.1.1
|
||||
; me-no-dev/ESPAsyncTCP@~1.2.2
|
||||
; philbowles/STM32AsyncTCP@~1.0.0
|
||||
; stm32duino/STM32duino LwIP@~2.1.2
|
||||
; stm32duino/STM32duino STM32Ethernet@~1.2.0
|
||||
; khoih-prog/ESPAsync_WiFiManager@~1.1.2
|
||||
|
||||
build_flags =
|
||||
; set your debug output (default=Serial)
|
||||
; -D DEBUG_ESP_PORT=Serial
|
||||
|
||||
@@ -17,15 +17,16 @@
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.0
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#ifndef AsyncHTTPRequest_Debug_STM32_H
|
||||
#define AsyncHTTPRequest_Debug_STM32_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef ASYNC_HTTP_DEBUG_PORT
|
||||
#define A_DBG_PORT ASYNC_HTTP_DEBUG_PORT
|
||||
@@ -68,4 +69,3 @@
|
||||
#define AHTTP_LOGDEBUG2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
||||
#define AHTTP_LOGDEBUG3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
||||
|
||||
#endif // AsyncHTTPRequest_Debug_STM32_H
|
||||
|
||||
@@ -17,17 +17,18 @@
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.0
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#ifndef AsyncHTTPRequest_Generic_h
|
||||
#define AsyncHTTPRequest_Generic_h
|
||||
|
||||
#define AsyncHTTPRequest_Generic_version "1.0.0"
|
||||
#pragma once
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "1.0.2"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
@@ -43,15 +44,29 @@
|
||||
#define DEBUG_IOTA_HTTP_SET false
|
||||
#endif
|
||||
|
||||
|
||||
// KH add
|
||||
#define SAFE_DELETE(object) if (object) { delete object;}
|
||||
#define SAFE_DELETE_ARRAY(object) if (object) { delete[] object;}
|
||||
|
||||
#if ESP32
|
||||
|
||||
#include <AsyncTCP.h>
|
||||
|
||||
// KH mod
|
||||
#define MUTEX_LOCK_NR if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return;}
|
||||
#define MUTEX_LOCK(returnVal) if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return returnVal;}
|
||||
|
||||
#define _lock xSemaphoreTakeRecursive(threadLock,portMAX_DELAY)
|
||||
#define _unlock xSemaphoreGiveRecursive(threadLock)
|
||||
|
||||
#elif ESP8266
|
||||
|
||||
#include <ESPAsyncTCP.h>
|
||||
|
||||
#define MUTEX_LOCK_NR
|
||||
#define MUTEX_LOCK(returnVal)
|
||||
|
||||
#define _lock
|
||||
#define _unlock
|
||||
|
||||
@@ -60,6 +75,9 @@
|
||||
defined(STM32WB) || defined(STM32MP1) )
|
||||
|
||||
#include "STM32AsyncTCP.h"
|
||||
|
||||
#define MUTEX_LOCK_NR
|
||||
#define MUTEX_LOCK(returnVal)
|
||||
#define _lock
|
||||
#define _unlock
|
||||
|
||||
@@ -108,9 +126,12 @@ class AsyncHTTPRequest
|
||||
|
||||
~header()
|
||||
{
|
||||
delete[] name;
|
||||
delete[] value;
|
||||
delete next;
|
||||
SAFE_DELETE_ARRAY(name)
|
||||
SAFE_DELETE_ARRAY(value)
|
||||
SAFE_DELETE(next)
|
||||
//delete[] name;
|
||||
//delete[] value;
|
||||
//delete next;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -131,13 +152,13 @@ class AsyncHTTPRequest
|
||||
|
||||
~URL()
|
||||
{
|
||||
delete[] scheme;
|
||||
delete[] user;
|
||||
delete[] pwd;
|
||||
delete[] host;
|
||||
delete[] path;
|
||||
delete[] query;
|
||||
delete[] fragment;
|
||||
SAFE_DELETE_ARRAY(scheme)
|
||||
SAFE_DELETE_ARRAY(user)
|
||||
SAFE_DELETE_ARRAY(pwd)
|
||||
SAFE_DELETE_ARRAY(host)
|
||||
SAFE_DELETE_ARRAY(path)
|
||||
SAFE_DELETE_ARRAY(query)
|
||||
SAFE_DELETE_ARRAY(fragment)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -265,5 +286,3 @@ class AsyncHTTPRequest
|
||||
};
|
||||
|
||||
#include "AsyncHTTPRequest_Impl_Generic.h"
|
||||
|
||||
#endif // AsyncHTTPRequest_Generic_h
|
||||
|
||||
@@ -17,18 +17,17 @@
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.0
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef AsyncHTTPRequest_Impl_Generic_h
|
||||
#define AsyncHTTPRequest_Impl_Generic_h
|
||||
|
||||
|
||||
//**************************************************************************************************************
|
||||
AsyncHTTPRequest::AsyncHTTPRequest(): _readyState(readyStateUnsent), _HTTPcode(0), _chunked(false), _debug(DEBUG_IOTA_HTTP_SET)
|
||||
@@ -48,15 +47,20 @@ AsyncHTTPRequest::~AsyncHTTPRequest()
|
||||
if (_client)
|
||||
_client->close(true);
|
||||
|
||||
delete _URL;
|
||||
delete _headers;
|
||||
delete _request;
|
||||
delete _response;
|
||||
delete _chunks;
|
||||
delete[] _connectedHost;
|
||||
|
||||
SAFE_DELETE(_URL)
|
||||
SAFE_DELETE(_headers)
|
||||
SAFE_DELETE(_request)
|
||||
SAFE_DELETE(_response)
|
||||
SAFE_DELETE(_chunks)
|
||||
SAFE_DELETE_ARRAY(_connectedHost)
|
||||
|
||||
#ifdef ESP32
|
||||
vSemaphoreDelete(threadLock);
|
||||
// KH add
|
||||
if (threadLock)
|
||||
{
|
||||
vSemaphoreDelete(threadLock);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -67,8 +71,9 @@ void AsyncHTTPRequest::setDebug(bool debug)
|
||||
{
|
||||
_debug = true;
|
||||
|
||||
AHTTP_LOGDEBUG3("setDebug(", debug ? "on" : "off", ") version", AsyncHTTPRequest_Generic_version);
|
||||
AHTTP_LOGDEBUG3("setDebug(", debug ? "on" : "off", ") version", ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
}
|
||||
|
||||
_debug = debug;
|
||||
}
|
||||
|
||||
@@ -90,13 +95,13 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
|
||||
|
||||
_requestStartTime = millis();
|
||||
|
||||
delete _URL;
|
||||
delete _headers;
|
||||
delete _request;
|
||||
delete _response;
|
||||
delete _chunks;
|
||||
SAFE_DELETE(_URL)
|
||||
SAFE_DELETE(_headers)
|
||||
SAFE_DELETE(_request)
|
||||
SAFE_DELETE(_response)
|
||||
SAFE_DELETE(_chunks)
|
||||
|
||||
_URL = nullptr;
|
||||
_URL = nullptr;
|
||||
_headers = nullptr;
|
||||
_response = nullptr;
|
||||
_request = nullptr;
|
||||
@@ -126,12 +131,20 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
|
||||
}
|
||||
|
||||
char* hostName = new char[strlen(_URL->host) + 10];
|
||||
sprintf(hostName, "%s:%d", _URL->host, _URL->port);
|
||||
_addHeader("host", hostName);
|
||||
delete[] hostName;
|
||||
_lastActivity = millis();
|
||||
|
||||
if (hostName)
|
||||
{
|
||||
sprintf(hostName, "%s:%d", _URL->host, _URL->port);
|
||||
_addHeader("host", hostName);
|
||||
|
||||
SAFE_DELETE_ARRAY(hostName)
|
||||
|
||||
_lastActivity = millis();
|
||||
|
||||
return _connect();
|
||||
return _connect();
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
//**************************************************************************************************************
|
||||
void AsyncHTTPRequest::onReadyStateChange(readyStateChangeCB cb, void* arg)
|
||||
@@ -153,12 +166,13 @@ bool AsyncHTTPRequest::send()
|
||||
{
|
||||
AHTTP_LOGDEBUG("send()");
|
||||
|
||||
_lock;
|
||||
MUTEX_LOCK(false)
|
||||
|
||||
if ( ! _buildRequest())
|
||||
return false;
|
||||
|
||||
_send();
|
||||
|
||||
_unlock;
|
||||
|
||||
return true;
|
||||
@@ -169,17 +183,20 @@ bool AsyncHTTPRequest::send(String body)
|
||||
{
|
||||
AHTTP_LOGDEBUG3("send(String)", body.substring(0, 16).c_str(), ", length =", body.length());
|
||||
|
||||
_lock;
|
||||
MUTEX_LOCK(false)
|
||||
|
||||
_addHeader("Content-Length", String(body.length()).c_str());
|
||||
|
||||
if ( ! _buildRequest())
|
||||
{
|
||||
_unlock;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
_request->write(body);
|
||||
_send();
|
||||
|
||||
_unlock;
|
||||
|
||||
return true;
|
||||
@@ -190,7 +207,8 @@ bool AsyncHTTPRequest::send(const char* body)
|
||||
{
|
||||
AHTTP_LOGDEBUG3("send(char)", body, ", length =", strlen(body));
|
||||
|
||||
_lock;
|
||||
MUTEX_LOCK(false)
|
||||
|
||||
_addHeader("Content-Length", String(strlen(body)).c_str());
|
||||
|
||||
if ( ! _buildRequest())
|
||||
@@ -202,6 +220,7 @@ bool AsyncHTTPRequest::send(const char* body)
|
||||
|
||||
_request->write(body);
|
||||
_send();
|
||||
|
||||
_unlock;
|
||||
|
||||
return true;
|
||||
@@ -212,7 +231,8 @@ bool AsyncHTTPRequest::send(const uint8_t* body, size_t len)
|
||||
{
|
||||
AHTTP_LOGDEBUG3("send(char)", (char*) body, ", length =", len);
|
||||
|
||||
_lock;
|
||||
MUTEX_LOCK(false)
|
||||
|
||||
_addHeader("Content-Length", String(len).c_str());
|
||||
|
||||
if ( ! _buildRequest())
|
||||
@@ -224,6 +244,7 @@ bool AsyncHTTPRequest::send(const uint8_t* body, size_t len)
|
||||
|
||||
_request->write(body, len);
|
||||
_send();
|
||||
|
||||
_unlock;
|
||||
|
||||
return true;
|
||||
@@ -234,7 +255,8 @@ bool AsyncHTTPRequest::send(xbuf* body, size_t len)
|
||||
{
|
||||
AHTTP_LOGDEBUG3("send(char)", body->peekString(16).c_str(), ", length =", len);
|
||||
|
||||
_lock;
|
||||
MUTEX_LOCK(false)
|
||||
|
||||
_addHeader("Content-Length", String(len).c_str());
|
||||
|
||||
if ( ! _buildRequest())
|
||||
@@ -246,6 +268,7 @@ bool AsyncHTTPRequest::send(xbuf* body, size_t len)
|
||||
|
||||
_request->write(body, len);
|
||||
_send();
|
||||
|
||||
_unlock;
|
||||
|
||||
return true;
|
||||
@@ -256,12 +279,15 @@ void AsyncHTTPRequest::abort()
|
||||
{
|
||||
AHTTP_LOGDEBUG("abort()");
|
||||
|
||||
_lock;
|
||||
|
||||
if (! _client)
|
||||
if (! _client)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MUTEX_LOCK_NR
|
||||
|
||||
_client->abort();
|
||||
|
||||
_unlock;
|
||||
}
|
||||
//**************************************************************************************************************
|
||||
@@ -281,7 +307,7 @@ String AsyncHTTPRequest::responseText()
|
||||
{
|
||||
AHTTP_LOGDEBUG("responseText()");
|
||||
|
||||
_lock;
|
||||
MUTEX_LOCK(String())
|
||||
|
||||
if ( ! _response || _readyState < readyStateLoading || ! available())
|
||||
{
|
||||
@@ -301,12 +327,13 @@ String AsyncHTTPRequest::responseText()
|
||||
|
||||
_HTTPcode = HTTPCODE_TOO_LESS_RAM;
|
||||
_client->abort();
|
||||
|
||||
_unlock;
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
localString = _response->readString(avail);
|
||||
localString = _response->readString(avail);
|
||||
_contentRead += localString.length();
|
||||
|
||||
AHTTP_LOGDEBUG3("responseText(char)", localString.substring(0, 16).c_str(), ", avail =", avail);
|
||||
@@ -321,19 +348,20 @@ size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len)
|
||||
{
|
||||
if ( ! _response || _readyState < readyStateLoading || ! available())
|
||||
{
|
||||
//DEBUG_HTTP("responseRead() no data\r\n");
|
||||
AHTTP_LOGDEBUG("responseRead() no data");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_lock;
|
||||
MUTEX_LOCK(0)
|
||||
|
||||
size_t avail = available() > len ? len : available();
|
||||
_response->read(buf, avail);
|
||||
|
||||
AHTTP_LOGDEBUG3("responseRead(char)", (char*) buf, ", avail =", avail);
|
||||
|
||||
_contentRead += avail;
|
||||
|
||||
_unlock;
|
||||
|
||||
return avail;
|
||||
@@ -388,7 +416,7 @@ uint32_t AsyncHTTPRequest::elapsedTime()
|
||||
//**************************************************************************************************************
|
||||
String AsyncHTTPRequest::version()
|
||||
{
|
||||
return String(AsyncHTTPRequest_Generic_version);
|
||||
return String(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
}
|
||||
|
||||
/*______________________________________________________________________________________________________________
|
||||
@@ -409,11 +437,22 @@ bool AsyncHTTPRequest::_parseURL(const char* url)
|
||||
//**************************************************************************************************************
|
||||
bool AsyncHTTPRequest::_parseURL(String url)
|
||||
{
|
||||
delete _URL;
|
||||
SAFE_DELETE(_URL)
|
||||
|
||||
int hostBeg = 0;
|
||||
|
||||
_URL = new URL;
|
||||
_URL->scheme = new char[8];
|
||||
|
||||
if (_URL)
|
||||
{
|
||||
_URL->scheme = new char[8];
|
||||
|
||||
if (! (_URL->scheme) )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
strcpy(_URL->scheme, "HTTP://");
|
||||
|
||||
if (url.substring(0, 7).equalsIgnoreCase("HTTP://"))
|
||||
@@ -440,6 +479,10 @@ bool AsyncHTTPRequest::_parseURL(String url)
|
||||
}
|
||||
|
||||
_URL->host = new char[hostEnd - hostBeg + 1];
|
||||
|
||||
if (_URL->host == nullptr)
|
||||
return false;
|
||||
|
||||
strcpy(_URL->host, url.substring(hostBeg, hostEnd).c_str());
|
||||
|
||||
int queryBeg = url.indexOf('?');
|
||||
@@ -448,8 +491,17 @@ bool AsyncHTTPRequest::_parseURL(String url)
|
||||
queryBeg = url.length();
|
||||
|
||||
_URL->path = new char[queryBeg - pathBeg + 1];
|
||||
|
||||
if (_URL->path == nullptr)
|
||||
return false;
|
||||
|
||||
strcpy(_URL->path, url.substring(pathBeg, queryBeg).c_str());
|
||||
|
||||
_URL->query = new char[url.length() - queryBeg + 1];
|
||||
|
||||
if (_URL->query == nullptr)
|
||||
return false;
|
||||
|
||||
strcpy(_URL->query, url.substring(queryBeg).c_str());
|
||||
|
||||
AHTTP_LOGDEBUG2("_parseURL(): scheme+host", _URL->scheme, _URL->host);
|
||||
@@ -466,11 +518,18 @@ bool AsyncHTTPRequest::_connect()
|
||||
if ( ! _client)
|
||||
{
|
||||
_client = new AsyncClient();
|
||||
|
||||
if (! _client)
|
||||
return false;
|
||||
}
|
||||
|
||||
delete[] _connectedHost;
|
||||
SAFE_DELETE_ARRAY(_connectedHost)
|
||||
|
||||
_connectedHost = new char[strlen(_URL->host) + 1];
|
||||
|
||||
if (_connectedHost == nullptr)
|
||||
return false;
|
||||
|
||||
strcpy(_connectedHost, _URL->host);
|
||||
_connectedPort = _URL->port;
|
||||
|
||||
@@ -523,14 +582,21 @@ bool AsyncHTTPRequest::_buildRequest()
|
||||
|
||||
// Build the header.
|
||||
if ( ! _request)
|
||||
{
|
||||
_request = new xbuf;
|
||||
|
||||
if ( ! _request)
|
||||
return false;
|
||||
}
|
||||
|
||||
_request->write(_HTTPmethod == HTTPmethodGET ? "GET " : "POST ");
|
||||
_request->write(_URL->path);
|
||||
_request->write(_URL->query);
|
||||
_request->write(" HTTP/1.1\r\n");
|
||||
|
||||
AHTTP_LOGDEBUG3(_HTTPmethod == HTTPmethodGET ? "GET " : "POST ", _URL->path, _URL->query, " HTTP/1.1\r\n" );
|
||||
|
||||
delete _URL;
|
||||
SAFE_DELETE(_URL)
|
||||
|
||||
_URL = nullptr;
|
||||
header* hdr = _headers;
|
||||
@@ -541,10 +607,14 @@ bool AsyncHTTPRequest::_buildRequest()
|
||||
_request->write(':');
|
||||
_request->write(hdr->value);
|
||||
_request->write("\r\n");
|
||||
|
||||
AHTTP_LOGDEBUG3(hdr->name, ":", hdr->value, "\r\n" );
|
||||
|
||||
hdr = hdr->next;
|
||||
}
|
||||
|
||||
delete _headers;
|
||||
SAFE_DELETE(_headers)
|
||||
|
||||
_headers = nullptr;
|
||||
_request->write("\r\n");
|
||||
|
||||
@@ -574,19 +644,26 @@ size_t AsyncHTTPRequest::_send()
|
||||
|
||||
size_t sent = 0;
|
||||
uint8_t* temp = new uint8_t[100];
|
||||
|
||||
if (!temp)
|
||||
return 0;
|
||||
|
||||
while (supply)
|
||||
{
|
||||
size_t chunk = supply < 100 ? supply : 100;
|
||||
supply -= _request->read(temp, chunk);
|
||||
sent += _client->add((char*)temp, chunk);
|
||||
|
||||
supply -= _request->read(temp, chunk);
|
||||
sent += _client->add((char*)temp, chunk);
|
||||
}
|
||||
|
||||
delete temp;
|
||||
// KH, Must be delete [] temp;
|
||||
SAFE_DELETE_ARRAY(temp)
|
||||
|
||||
if (_request->available() == 0)
|
||||
{
|
||||
delete _request;
|
||||
//delete _request;
|
||||
SAFE_DELETE(_request)
|
||||
|
||||
_request = nullptr;
|
||||
}
|
||||
|
||||
@@ -676,10 +753,20 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client)
|
||||
{
|
||||
AHTTP_LOGDEBUG("_onConnect handler");
|
||||
|
||||
_lock;
|
||||
MUTEX_LOCK_NR
|
||||
|
||||
_client = client;
|
||||
_setReadyState(readyStateOpened);
|
||||
|
||||
_response = new xbuf;
|
||||
|
||||
if (!_response)
|
||||
{
|
||||
_unlock;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_contentLength = 0;
|
||||
_contentRead = 0;
|
||||
_chunked = false;
|
||||
@@ -700,13 +787,14 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client)
|
||||
}
|
||||
|
||||
_lastActivity = millis();
|
||||
|
||||
_unlock;
|
||||
}
|
||||
|
||||
//**************************************************************************************************************
|
||||
void AsyncHTTPRequest::_onPoll(AsyncClient* client)
|
||||
{
|
||||
_lock;
|
||||
MUTEX_LOCK_NR
|
||||
|
||||
if (_timeout && (millis() - _lastActivity) > (_timeout * 1000))
|
||||
{
|
||||
@@ -737,7 +825,7 @@ void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)
|
||||
{
|
||||
AHTTP_LOGDEBUG("\n_onDisconnect handler");
|
||||
|
||||
_lock;
|
||||
MUTEX_LOCK_NR
|
||||
|
||||
if (_readyState < readyStateOpened)
|
||||
{
|
||||
@@ -749,16 +837,19 @@ void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)
|
||||
_HTTPcode = HTTPCODE_CONNECTION_LOST;
|
||||
}
|
||||
|
||||
delete _client;
|
||||
SAFE_DELETE(_client)
|
||||
|
||||
_client = nullptr;
|
||||
|
||||
delete[] _connectedHost;
|
||||
SAFE_DELETE_ARRAY(_connectedHost)
|
||||
|
||||
_connectedHost = nullptr;
|
||||
|
||||
_connectedPort = -1;
|
||||
_connectedPort = -1;
|
||||
_requestEndTime = millis();
|
||||
_lastActivity = 0;
|
||||
_lastActivity = 0;
|
||||
_setReadyState(readyStateDone);
|
||||
|
||||
_unlock;
|
||||
}
|
||||
|
||||
@@ -767,6 +858,8 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
|
||||
{
|
||||
AHTTP_LOGDEBUG3("_onData handler", (char*) Vbuf, ", len =", len);
|
||||
|
||||
MUTEX_LOCK_NR
|
||||
|
||||
_lastActivity = millis();
|
||||
|
||||
// Transfer data to xbuf
|
||||
@@ -783,8 +876,12 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
|
||||
// if headers not complete, collect them. If still not complete, just return.
|
||||
if (_readyState == readyStateOpened)
|
||||
{
|
||||
if ( ! _collectHeaders())
|
||||
if ( ! _collectHeaders())
|
||||
{
|
||||
_unlock;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If there's data in the buffer and not Done, advance readyState to Loading.
|
||||
@@ -929,7 +1026,8 @@ void AsyncHTTPRequest::setReqHeader(const char* name, const __FlashStringHelper*
|
||||
{
|
||||
char* _value = _charstar(value);
|
||||
_addHeader(name, _value);
|
||||
delete[] _value;
|
||||
|
||||
SAFE_DELETE_ARRAY(_value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -940,7 +1038,8 @@ void AsyncHTTPRequest::setReqHeader(const __FlashStringHelper *name, const char*
|
||||
{
|
||||
char* _name = _charstar(name);
|
||||
_addHeader(_name, value);
|
||||
delete[] _name;
|
||||
|
||||
SAFE_DELETE_ARRAY(_name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -952,8 +1051,9 @@ void AsyncHTTPRequest::setReqHeader(const __FlashStringHelper *name, const __Fla
|
||||
char* _name = _charstar(name);
|
||||
char* _value = _charstar(value);
|
||||
_addHeader(_name, _value);
|
||||
delete[] _name;
|
||||
delete[] _value;
|
||||
|
||||
SAFE_DELETE_ARRAY(_name)
|
||||
SAFE_DELETE_ARRAY(_value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -964,7 +1064,8 @@ void AsyncHTTPRequest::setReqHeader(const __FlashStringHelper *name, int32_t val
|
||||
{
|
||||
char* _name = _charstar(name);
|
||||
setReqHeader(_name, String(value).c_str());
|
||||
delete[] _name;
|
||||
|
||||
SAFE_DELETE_ARRAY(_name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1055,7 +1156,8 @@ char* AsyncHTTPRequest::respHeaderValue(const __FlashStringHelper *name)
|
||||
|
||||
char* _name = _charstar(name);
|
||||
header* hdr = _getHeader(_name);
|
||||
delete[] _name;
|
||||
|
||||
SAFE_DELETE_ARRAY(_name)
|
||||
|
||||
if ( ! hdr)
|
||||
return nullptr;
|
||||
@@ -1071,7 +1173,8 @@ bool AsyncHTTPRequest::respHeaderExists(const __FlashStringHelper *name)
|
||||
|
||||
char* _name = _charstar(name);
|
||||
header* hdr = _getHeader(_name);
|
||||
delete[] _name;
|
||||
|
||||
SAFE_DELETE_ARRAY(_name)
|
||||
|
||||
if ( ! hdr)
|
||||
return false;
|
||||
@@ -1084,7 +1187,8 @@ bool AsyncHTTPRequest::respHeaderExists(const __FlashStringHelper *name)
|
||||
//**************************************************************************************************************
|
||||
String AsyncHTTPRequest::headers()
|
||||
{
|
||||
_lock;
|
||||
MUTEX_LOCK(String())
|
||||
|
||||
String _response = "";
|
||||
header* hdr = _headers;
|
||||
|
||||
@@ -1098,6 +1202,7 @@ String AsyncHTTPRequest::headers()
|
||||
}
|
||||
|
||||
_response += "\r\n";
|
||||
|
||||
_unlock;
|
||||
|
||||
return _response;
|
||||
@@ -1106,17 +1211,19 @@ String AsyncHTTPRequest::headers()
|
||||
//**************************************************************************************************************
|
||||
AsyncHTTPRequest::header* AsyncHTTPRequest::_addHeader(const char* name, const char* value)
|
||||
{
|
||||
_lock;
|
||||
MUTEX_LOCK(nullptr)
|
||||
|
||||
header* hdr = (header*) &_headers;
|
||||
|
||||
while (hdr->next)
|
||||
{
|
||||
if (strcasecmp(name, hdr->next->name) == 0)
|
||||
{
|
||||
header* oldHdr = hdr->next;
|
||||
hdr->next = hdr->next->next;
|
||||
oldHdr->next = nullptr;
|
||||
delete oldHdr;
|
||||
header* oldHdr = hdr->next;
|
||||
hdr->next = hdr->next->next;
|
||||
oldHdr->next = nullptr;
|
||||
|
||||
SAFE_DELETE(oldHdr)
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1125,10 +1232,37 @@ AsyncHTTPRequest::header* AsyncHTTPRequest::_addHeader(const char* name, const
|
||||
}
|
||||
|
||||
hdr->next = new header;
|
||||
hdr->next->name = new char[strlen(name) + 1];
|
||||
strcpy(hdr->next->name, name);
|
||||
hdr->next->value = new char[strlen(value) + 1];
|
||||
strcpy(hdr->next->value, value);
|
||||
|
||||
if (hdr->next)
|
||||
{
|
||||
hdr->next->name = new char[strlen(name) + 1];
|
||||
|
||||
if (hdr->next->name)
|
||||
strcpy(hdr->next->name, name);
|
||||
else
|
||||
{
|
||||
SAFE_DELETE(hdr->next)
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
hdr->next->value = new char[strlen(value) + 1];
|
||||
|
||||
if (hdr->next->value)
|
||||
strcpy(hdr->next->value, value);
|
||||
else
|
||||
{
|
||||
SAFE_DELETE_ARRAY(hdr->next->name)
|
||||
SAFE_DELETE(hdr->next)
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
_unlock;
|
||||
|
||||
return hdr->next;
|
||||
@@ -1137,7 +1271,8 @@ AsyncHTTPRequest::header* AsyncHTTPRequest::_addHeader(const char* name, const
|
||||
//**************************************************************************************************************
|
||||
AsyncHTTPRequest::header* AsyncHTTPRequest::_getHeader(const char* name)
|
||||
{
|
||||
_lock;
|
||||
MUTEX_LOCK(nullptr)
|
||||
|
||||
header* hdr = _headers;
|
||||
|
||||
while (hdr)
|
||||
@@ -1156,7 +1291,8 @@ AsyncHTTPRequest::header* AsyncHTTPRequest::_getHeader(const char* name)
|
||||
//**************************************************************************************************************
|
||||
AsyncHTTPRequest::header* AsyncHTTPRequest::_getHeader(int ndx)
|
||||
{
|
||||
_lock;
|
||||
MUTEX_LOCK(nullptr)
|
||||
|
||||
header* hdr = _headers;
|
||||
|
||||
while (hdr)
|
||||
@@ -1181,11 +1317,14 @@ char* AsyncHTTPRequest::_charstar(const __FlashStringHelper * str)
|
||||
return nullptr;
|
||||
|
||||
char* ptr = new char[strlen_P((PGM_P)str) + 1];
|
||||
strcpy_P(ptr, (PGM_P)str);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
strcpy_P(ptr, (PGM_P)str);
|
||||
}
|
||||
|
||||
// Rturn good ptr or nullptr
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // AsyncHTTPRequest_Impl_Generic_h
|
||||
|
||||
+3
-5
@@ -17,11 +17,13 @@
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.0
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
/********************************************************************************************
|
||||
@@ -44,9 +46,6 @@
|
||||
********************************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#ifndef xbuf_h
|
||||
#define xbuf_h
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
struct xseg
|
||||
@@ -150,4 +149,3 @@ class xbuf: public Print
|
||||
|
||||
#include "utility/xbuf_Impl.h"
|
||||
|
||||
#endif // xbuf_h
|
||||
|
||||
+11
-7
@@ -17,17 +17,16 @@
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.0
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#ifndef xbuf_Impl_h
|
||||
#define xbuf_Impl_h
|
||||
|
||||
//#include "utility/xbuf.h"
|
||||
#pragma once
|
||||
|
||||
xbuf::xbuf(const uint16_t segSize) : _head(nullptr), _tail(nullptr), _used(0), _free(0), _offset(0)
|
||||
{
|
||||
@@ -363,14 +362,20 @@ void xbuf::addSeg()
|
||||
if (_tail)
|
||||
{
|
||||
_tail->next = (xseg*) new uint32_t[_segSize / 4 + 1];
|
||||
|
||||
// KH, Must check NULL here
|
||||
_tail = _tail->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
// KH, Must check NULL here
|
||||
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
|
||||
}
|
||||
|
||||
_tail->next = nullptr;
|
||||
// KH, Must check NULL here
|
||||
if (_tail)
|
||||
_tail->next = nullptr;
|
||||
|
||||
_free += _segSize;
|
||||
}
|
||||
|
||||
@@ -392,4 +397,3 @@ void xbuf::remSeg()
|
||||
_offset = 0;
|
||||
}
|
||||
|
||||
#endif // xbuf_Impl_h
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncHTTPRequest_Debug_Generic.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef ASYNC_HTTP_DEBUG_PORT
|
||||
#define A_DBG_PORT ASYNC_HTTP_DEBUG_PORT
|
||||
#else
|
||||
#define A_DBG_PORT Serial
|
||||
#endif
|
||||
|
||||
// Change _ASYNC_HTTP_LOGLEVEL_ to set tracing and logging verbosity
|
||||
// 0: DISABLED: no logging
|
||||
// 1: ERROR: errors
|
||||
// 2: WARN: errors and warnings
|
||||
// 3: INFO: errors, warnings and informational (default)
|
||||
// 4: DEBUG: errors, warnings, informational and debug
|
||||
|
||||
#ifndef _ASYNC_HTTP_LOGLEVEL_
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 0
|
||||
#endif
|
||||
|
||||
#define AHTTP_LOGERROR(x) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.println(x); }
|
||||
#define AHTTP_LOGERROR0(x) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print(x); }
|
||||
#define AHTTP_LOGERROR1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.println(y); }
|
||||
#define AHTTP_LOGERROR2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
||||
#define AHTTP_LOGERROR3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
||||
|
||||
#define AHTTP_LOGWARN(x) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.println(x); }
|
||||
#define AHTTP_LOGWARN0(x) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print(x); }
|
||||
#define AHTTP_LOGWARN1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.println(y); }
|
||||
#define AHTTP_LOGWARN2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
||||
#define AHTTP_LOGWARN3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
||||
|
||||
#define AHTTP_LOGINFO(x) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.println(x); }
|
||||
#define AHTTP_LOGINFO0(x) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print(x); }
|
||||
#define AHTTP_LOGINFO1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.println(y); }
|
||||
#define AHTTP_LOGINFO2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
||||
#define AHTTP_LOGINFO3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
||||
|
||||
#define AHTTP_LOGDEBUG(x) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.println(x); }
|
||||
#define AHTTP_LOGDEBUG0(x) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print(x); }
|
||||
#define AHTTP_LOGDEBUG1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.println(y); }
|
||||
#define AHTTP_LOGDEBUG2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
||||
#define AHTTP_LOGDEBUG3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,287 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncHTTPRequest_Generic.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "1.0.2"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "AsyncHTTPRequest_Debug_Generic.h"
|
||||
|
||||
#ifndef DEBUG_IOTA_PORT
|
||||
#define DEBUG_IOTA_PORT Serial
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_IOTA_HTTP
|
||||
#define DEBUG_IOTA_HTTP_SET true
|
||||
#else
|
||||
#define DEBUG_IOTA_HTTP_SET false
|
||||
#endif
|
||||
|
||||
|
||||
// KH add
|
||||
#define SAFE_DELETE(object) if (object) { delete object;}
|
||||
#define SAFE_DELETE_ARRAY(object) if (object) { delete[] object;}
|
||||
|
||||
#if ESP32
|
||||
|
||||
#include <AsyncTCP.h>
|
||||
|
||||
// KH mod
|
||||
#define MUTEX_LOCK_NR if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return;}
|
||||
#define MUTEX_LOCK(returnVal) if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return returnVal;}
|
||||
|
||||
#define _lock xSemaphoreTakeRecursive(threadLock,portMAX_DELAY)
|
||||
#define _unlock xSemaphoreGiveRecursive(threadLock)
|
||||
|
||||
#elif ESP8266
|
||||
|
||||
#include <ESPAsyncTCP.h>
|
||||
|
||||
#define MUTEX_LOCK_NR
|
||||
#define MUTEX_LOCK(returnVal)
|
||||
|
||||
#define _lock
|
||||
#define _unlock
|
||||
|
||||
#elif ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
|
||||
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
||||
defined(STM32WB) || defined(STM32MP1) )
|
||||
|
||||
#include "STM32AsyncTCP.h"
|
||||
|
||||
#define MUTEX_LOCK_NR
|
||||
#define MUTEX_LOCK(returnVal)
|
||||
#define _lock
|
||||
#define _unlock
|
||||
|
||||
#endif
|
||||
|
||||
#include <pgmspace.h>
|
||||
#include <utility/xbuf.h>
|
||||
|
||||
#define DEBUG_HTTP(format,...) if(_debug){\
|
||||
DEBUG_IOTA_PORT.printf("Debug(%3ld): ", millis()-_requestStartTime);\
|
||||
DEBUG_IOTA_PORT.printf_P(PSTR(format),##__VA_ARGS__);}
|
||||
|
||||
#define DEFAULT_RX_TIMEOUT 3 // Seconds for timeout
|
||||
|
||||
#define HTTPCODE_CONNECTION_REFUSED (-1)
|
||||
#define HTTPCODE_SEND_HEADER_FAILED (-2)
|
||||
#define HTTPCODE_SEND_PAYLOAD_FAILED (-3)
|
||||
#define HTTPCODE_NOT_CONNECTED (-4)
|
||||
#define HTTPCODE_CONNECTION_LOST (-5)
|
||||
#define HTTPCODE_NO_STREAM (-6)
|
||||
#define HTTPCODE_NO_HTTP_SERVER (-7)
|
||||
#define HTTPCODE_TOO_LESS_RAM (-8)
|
||||
#define HTTPCODE_ENCODING (-9)
|
||||
#define HTTPCODE_STREAM_WRITE (-10)
|
||||
#define HTTPCODE_TIMEOUT (-11)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
readyStateUnsent = 0, // Client created, open not yet called
|
||||
readyStateOpened = 1, // open() has been called, connected
|
||||
readyStateHdrsRecvd = 2, // send() called, response headers available
|
||||
readyStateLoading = 3, // receiving, partial data available
|
||||
readyStateDone = 4 // Request complete, all data available.
|
||||
} reqStates;
|
||||
|
||||
class AsyncHTTPRequest
|
||||
{
|
||||
struct header
|
||||
{
|
||||
header* next;
|
||||
char* name;
|
||||
char* value;
|
||||
|
||||
header(): next(nullptr), name(nullptr), value(nullptr)
|
||||
{};
|
||||
|
||||
~header()
|
||||
{
|
||||
SAFE_DELETE_ARRAY(name)
|
||||
SAFE_DELETE_ARRAY(value)
|
||||
SAFE_DELETE(next)
|
||||
//delete[] name;
|
||||
//delete[] value;
|
||||
//delete next;
|
||||
}
|
||||
};
|
||||
|
||||
struct URL
|
||||
{
|
||||
char* scheme;
|
||||
char* user;
|
||||
char* pwd;
|
||||
char* host;
|
||||
int port;
|
||||
char* path;
|
||||
char* query;
|
||||
char* fragment;
|
||||
|
||||
URL(): scheme(nullptr), user(nullptr), pwd(nullptr), host(nullptr),
|
||||
port(80), path(nullptr), query(nullptr), fragment(nullptr)
|
||||
{};
|
||||
|
||||
~URL()
|
||||
{
|
||||
SAFE_DELETE_ARRAY(scheme)
|
||||
SAFE_DELETE_ARRAY(user)
|
||||
SAFE_DELETE_ARRAY(pwd)
|
||||
SAFE_DELETE_ARRAY(host)
|
||||
SAFE_DELETE_ARRAY(path)
|
||||
SAFE_DELETE_ARRAY(query)
|
||||
SAFE_DELETE_ARRAY(fragment)
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::function<void(void*, AsyncHTTPRequest*, int readyState)> readyStateChangeCB;
|
||||
typedef std::function<void(void*, AsyncHTTPRequest*, size_t available)> onDataCB;
|
||||
|
||||
public:
|
||||
AsyncHTTPRequest();
|
||||
~AsyncHTTPRequest();
|
||||
|
||||
|
||||
//External functions in typical order of use:
|
||||
//__________________________________________________________________________________________________________*/
|
||||
void setDebug(bool); // Turn debug message on/off
|
||||
bool debug(); // is debug on or off?
|
||||
|
||||
bool open(const char* /*GET/POST*/, const char* URL); // Initiate a request
|
||||
void onReadyStateChange(readyStateChangeCB, void* arg = 0); // Optional event handler for ready state change
|
||||
// or you can simply poll readyState()
|
||||
void setTimeout(int); // overide default timeout (seconds)
|
||||
|
||||
void setReqHeader(const char* name, const char* value); // add a request header
|
||||
void setReqHeader(const char* name, int32_t value); // overload to use integer value
|
||||
|
||||
#if (ESP32 || ESP8266)
|
||||
void setReqHeader(const char* name, const __FlashStringHelper* value);
|
||||
void setReqHeader(const __FlashStringHelper *name, const char* value);
|
||||
void setReqHeader(const __FlashStringHelper *name, const __FlashStringHelper* value);
|
||||
void setReqHeader(const __FlashStringHelper *name, int32_t value);
|
||||
#endif
|
||||
|
||||
bool send(); // Send the request (GET)
|
||||
bool send(String body); // Send the request (POST)
|
||||
bool send(const char* body); // Send the request (POST)
|
||||
bool send(const uint8_t* buffer, size_t len); // Send the request (POST) (binary data?)
|
||||
bool send(xbuf* body, size_t len); // Send the request (POST) data in an xbuf
|
||||
void abort(); // Abort the current operation
|
||||
|
||||
reqStates readyState(); // Return the ready state
|
||||
|
||||
int respHeaderCount(); // Retrieve count of response headers
|
||||
char* respHeaderName(int index); // Return header name by index
|
||||
char* respHeaderValue(int index); // Return header value by index
|
||||
char* respHeaderValue(const char* name); // Return header value by name
|
||||
|
||||
bool respHeaderExists(const char* name); // Does header exist by name?
|
||||
|
||||
#if (ESP32 || ESP8266)
|
||||
char* respHeaderValue(const __FlashStringHelper *name);
|
||||
bool respHeaderExists(const __FlashStringHelper *name);
|
||||
#endif
|
||||
|
||||
String headers(); // Return all headers as String
|
||||
|
||||
void onData(onDataCB, void* arg = 0); // Notify when min data is available
|
||||
size_t available(); // response available
|
||||
size_t responseLength(); // indicated response length or sum of chunks to date
|
||||
int responseHTTPcode(); // HTTP response code or (negative) error code
|
||||
String responseText(); // response (whole* or partial* as string)
|
||||
size_t responseRead(uint8_t* buffer, size_t len); // Read response into buffer
|
||||
uint32_t elapsedTime(); // Elapsed time of in progress transaction or last completed (ms)
|
||||
String version(); // Version of AsyncHTTPRequest
|
||||
//___________________________________________________________________________________________________________________________________
|
||||
|
||||
private:
|
||||
|
||||
enum {HTTPmethodGET, HTTPmethodPOST} _HTTPmethod;
|
||||
|
||||
reqStates _readyState;
|
||||
|
||||
int16_t _HTTPcode; // HTTP response code or (negative) exception code
|
||||
bool _chunked; // Processing chunked response
|
||||
bool _debug; // Debug state
|
||||
uint32_t _timeout; // Default or user overide RxTimeout in seconds
|
||||
uint32_t _lastActivity; // Time of last activity
|
||||
uint32_t _requestStartTime; // Time last open() issued
|
||||
uint32_t _requestEndTime; // Time of last disconnect
|
||||
URL* _URL; // -> URL data structure
|
||||
char* _connectedHost; // Host when connected
|
||||
int _connectedPort; // Port when connected
|
||||
AsyncClient* _client; // ESPAsyncTCP AsyncClient instance
|
||||
size_t _contentLength; // content-length header value or sum of chunk headers
|
||||
size_t _contentRead; // number of bytes retrieved by user since last open()
|
||||
readyStateChangeCB _readyStateChangeCB; // optional callback for readyState change
|
||||
void* _readyStateChangeCBarg; // associated user argument
|
||||
onDataCB _onDataCB; // optional callback when data received
|
||||
void* _onDataCBarg; // associated user argument
|
||||
|
||||
#ifdef ESP32
|
||||
SemaphoreHandle_t threadLock;
|
||||
#endif
|
||||
|
||||
// request and response String buffers and header list (same queue for request and response).
|
||||
|
||||
xbuf* _request; // Tx data buffer
|
||||
xbuf* _response; // Rx data buffer for headers
|
||||
xbuf* _chunks; // First stage for chunked response
|
||||
header* _headers; // request or (readyState > readyStateHdrsRcvd) response headers
|
||||
|
||||
// Protected functions
|
||||
|
||||
header* _addHeader(const char*, const char*);
|
||||
header* _getHeader(const char*);
|
||||
header* _getHeader(int);
|
||||
bool _buildRequest();
|
||||
bool _parseURL(const char*);
|
||||
bool _parseURL(String);
|
||||
void _processChunks();
|
||||
bool _connect();
|
||||
size_t _send();
|
||||
void _setReadyState(reqStates);
|
||||
|
||||
#if (ESP32 || ESP8266)
|
||||
char* _charstar(const __FlashStringHelper *str);
|
||||
#endif
|
||||
|
||||
// callbacks
|
||||
|
||||
void _onConnect(AsyncClient*);
|
||||
void _onDisconnect(AsyncClient*);
|
||||
void _onData(void*, size_t);
|
||||
void _onError(AsyncClient*, int8_t);
|
||||
void _onPoll(AsyncClient*);
|
||||
bool _collectHeaders();
|
||||
};
|
||||
|
||||
@@ -0,0 +1,399 @@
|
||||
/****************************************************************************************************************************
|
||||
xbuf_Impl.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#include "utility/xbuf.h"
|
||||
|
||||
xbuf::xbuf(const uint16_t segSize) : _head(nullptr), _tail(nullptr), _used(0), _free(0), _offset(0)
|
||||
{
|
||||
_segSize = (segSize + 3) & -4;//((segSize + 3) >> 2) << 2;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
xbuf::~xbuf()
|
||||
{
|
||||
flush();
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::write(const uint8_t byte)
|
||||
{
|
||||
return write((uint8_t*) &byte, 1);
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::write(const char* buf)
|
||||
{
|
||||
return write((uint8_t*)buf, strlen(buf));
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::write(String string)
|
||||
{
|
||||
return write((uint8_t*)string.c_str(), string.length());
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::write(const uint8_t* buf, const size_t len)
|
||||
{
|
||||
size_t supply = len;
|
||||
|
||||
while (supply)
|
||||
{
|
||||
if (!_free)
|
||||
{
|
||||
addSeg();
|
||||
}
|
||||
|
||||
size_t demand = _free < supply ? _free : supply;
|
||||
memcpy(_tail->data + ((_offset + _used) % _segSize), buf + (len - supply), demand);
|
||||
_free -= demand;
|
||||
_used += demand;
|
||||
supply -= demand;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::write(xbuf* buf, const size_t len)
|
||||
{
|
||||
size_t supply = len;
|
||||
|
||||
if (supply > buf->available())
|
||||
{
|
||||
supply = buf->available();
|
||||
}
|
||||
|
||||
size_t read = 0;
|
||||
|
||||
while (supply)
|
||||
{
|
||||
if (!_free)
|
||||
{
|
||||
addSeg();
|
||||
}
|
||||
|
||||
size_t demand = _free < supply ? _free : supply;
|
||||
read += buf->read(_tail->data + ((_offset + _used) % _segSize), demand);
|
||||
_free -= demand;
|
||||
_used += demand;
|
||||
supply -= demand;
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
uint8_t xbuf::read()
|
||||
{
|
||||
uint8_t byte = 0;
|
||||
read((uint8_t*) &byte, 1);
|
||||
|
||||
return byte;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
uint8_t xbuf::peek()
|
||||
{
|
||||
uint8_t byte = 0;
|
||||
peek((uint8_t*) &byte, 1);
|
||||
|
||||
return byte;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::read(uint8_t* buf, const size_t len)
|
||||
{
|
||||
size_t read = 0;
|
||||
|
||||
while (read < len && _used)
|
||||
{
|
||||
size_t supply = (_offset + _used) > _segSize ? _segSize - _offset : _used;
|
||||
size_t demand = len - read;
|
||||
size_t chunk = supply < demand ? supply : demand;
|
||||
memcpy(buf + read, _head->data + _offset, chunk);
|
||||
_offset += chunk;
|
||||
_used -= chunk;
|
||||
read += chunk;
|
||||
|
||||
if (_offset == _segSize)
|
||||
{
|
||||
remSeg();
|
||||
_offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! _used)
|
||||
{
|
||||
flush();
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::peek(uint8_t* buf, const size_t len)
|
||||
{
|
||||
size_t read = 0;
|
||||
xseg* seg = _head;
|
||||
size_t offset = _offset;
|
||||
size_t used = _used;
|
||||
|
||||
while (read < len && used)
|
||||
{
|
||||
size_t supply = (offset + used) > _segSize ? _segSize - offset : used;
|
||||
size_t demand = len - read;
|
||||
size_t chunk = supply < demand ? supply : demand;
|
||||
|
||||
memcpy(buf + read, seg->data + offset, chunk);
|
||||
|
||||
offset += chunk;
|
||||
used -= chunk;
|
||||
read += chunk;
|
||||
|
||||
if (offset == _segSize)
|
||||
{
|
||||
seg = seg->next;
|
||||
offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::available()
|
||||
{
|
||||
return _used;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
int xbuf::indexOf(const char target, const size_t begin)
|
||||
{
|
||||
char targetstr[2] = " ";
|
||||
targetstr[0] = target;
|
||||
|
||||
return indexOf(targetstr, begin);
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
int xbuf::indexOf(const char* target, const size_t begin)
|
||||
{
|
||||
size_t targetLen = strlen(target);
|
||||
|
||||
if (targetLen > _segSize || targetLen > _used)
|
||||
return -1;
|
||||
|
||||
size_t searchPos = _offset + begin;
|
||||
size_t searchEnd = _offset + _used - targetLen;
|
||||
|
||||
if (searchPos > searchEnd)
|
||||
return -1;
|
||||
|
||||
size_t searchSeg = searchPos / _segSize;
|
||||
xseg* seg = _head;
|
||||
|
||||
while (searchSeg)
|
||||
{
|
||||
seg = seg->next;
|
||||
searchSeg --;
|
||||
}
|
||||
|
||||
size_t segPos = searchPos % _segSize;
|
||||
|
||||
while (searchPos <= searchEnd)
|
||||
{
|
||||
size_t compLen = targetLen;
|
||||
|
||||
if (compLen <= (_segSize - segPos))
|
||||
{
|
||||
if (memcmp(target, seg->data + segPos, compLen) == 0)
|
||||
{
|
||||
return searchPos - _offset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t compLen = _segSize - segPos;
|
||||
|
||||
if (memcmp(target, seg->data + segPos, compLen) == 0)
|
||||
{
|
||||
compLen = targetLen - compLen;
|
||||
|
||||
if (memcmp(target + targetLen - compLen, seg->next->data, compLen) == 0)
|
||||
{
|
||||
return searchPos - _offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
searchPos++;
|
||||
segPos++;
|
||||
|
||||
if (segPos == _segSize)
|
||||
{
|
||||
seg = seg->next;
|
||||
segPos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
String xbuf::readStringUntil(const char target)
|
||||
{
|
||||
return readString(indexOf(target) + 1);
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
String xbuf::readStringUntil(const char* target)
|
||||
{
|
||||
int index = indexOf(target);
|
||||
|
||||
if (index < 0)
|
||||
return String();
|
||||
|
||||
return readString(index + strlen(target));
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
String xbuf::readString(int endPos)
|
||||
{
|
||||
String result;
|
||||
|
||||
if ( ! result.reserve(endPos + 1))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (endPos > _used)
|
||||
{
|
||||
endPos = _used;
|
||||
}
|
||||
|
||||
if (endPos > 0 && result.reserve(endPos + 1))
|
||||
{
|
||||
while (endPos--)
|
||||
{
|
||||
result += (char)_head->data[_offset++];
|
||||
_used--;
|
||||
|
||||
if (_offset >= _segSize)
|
||||
{
|
||||
remSeg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
String xbuf::peekString(int endPos)
|
||||
{
|
||||
String result;
|
||||
|
||||
xseg* seg = _head;
|
||||
size_t offset = _offset;
|
||||
|
||||
if (endPos > _used)
|
||||
{
|
||||
endPos = _used;
|
||||
}
|
||||
|
||||
if (endPos > 0 && result.reserve(endPos + 1))
|
||||
{
|
||||
while (endPos--)
|
||||
{
|
||||
result += (char)seg->data[offset++];
|
||||
|
||||
if ( offset >= _segSize)
|
||||
{
|
||||
seg = seg->next;
|
||||
offset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
void xbuf::flush()
|
||||
{
|
||||
while (_head)
|
||||
remSeg();
|
||||
|
||||
_tail = nullptr;
|
||||
_offset = 0;
|
||||
_used = 0;
|
||||
_free = 0;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
void xbuf::addSeg()
|
||||
{
|
||||
if (_tail)
|
||||
{
|
||||
_tail->next = (xseg*) new uint32_t[_segSize / 4 + 1];
|
||||
|
||||
// KH, Must check NULL here
|
||||
_tail = _tail->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
// KH, Must check NULL here
|
||||
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
|
||||
}
|
||||
|
||||
// KH, Must check NULL here
|
||||
if (_tail)
|
||||
_tail->next = nullptr;
|
||||
|
||||
_free += _segSize;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
void xbuf::remSeg()
|
||||
{
|
||||
if (_head)
|
||||
{
|
||||
xseg *next = _head->next;
|
||||
delete[] (uint32_t*) _head;
|
||||
_head = next;
|
||||
|
||||
if ( ! _head)
|
||||
{
|
||||
_tail = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
_offset = 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/****************************************************************************************************************************
|
||||
xbuf.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
/********************************************************************************************
|
||||
xbuf is a dynamic buffering system that supports reading and writing much like cbuf.
|
||||
The class has it's own provision for writing from buffers, Strings and other xbufs
|
||||
as well as the inherited Print functions.
|
||||
Rather than use a large contiguous heap allocation, xbuf uses a linked chain of segments
|
||||
to dynamically grow and shrink with the contents.
|
||||
There are other benefits as well to using smaller heap allocation units:
|
||||
1) A buffer can work fine in a fragmented heap environment (admittedly contributing to it)
|
||||
2) xbuf contents can be copied from one buffer to another without the need for
|
||||
2x heap during the copy.
|
||||
The segment size defaults to 64 but can be dynamically set in the constructor at creation.
|
||||
The inclusion of indexOf and read/peek until functions make it useful for handling
|
||||
data streams like HTTP, and in fact is why it was created.
|
||||
|
||||
NOTE: The size of the indexOf() search string is limited to the segment size.
|
||||
It could be extended but didn't seem to be a practical consideration.
|
||||
|
||||
********************************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
struct xseg
|
||||
{
|
||||
xseg *next;
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
class xbuf: public Print
|
||||
{
|
||||
public:
|
||||
|
||||
xbuf(const uint16_t segSize = 64);
|
||||
virtual ~xbuf();
|
||||
|
||||
size_t write(const uint8_t);
|
||||
size_t write(const char*);
|
||||
size_t write(const uint8_t*, const size_t);
|
||||
size_t write(xbuf*, const size_t);
|
||||
size_t write(String);
|
||||
size_t available();
|
||||
int indexOf(const char, const size_t begin = 0);
|
||||
int indexOf(const char*, const size_t begin = 0);
|
||||
uint8_t read();
|
||||
size_t read(uint8_t*, size_t);
|
||||
String readStringUntil(const char);
|
||||
String readStringUntil(const char*);
|
||||
String readString(int);
|
||||
|
||||
String readString()
|
||||
{
|
||||
return readString(available());
|
||||
}
|
||||
|
||||
void flush();
|
||||
|
||||
uint8_t peek();
|
||||
size_t peek(uint8_t*, const size_t);
|
||||
|
||||
String peekStringUntil(const char target)
|
||||
{
|
||||
return peekString(indexOf(target, 0));
|
||||
}
|
||||
|
||||
String peekStringUntil(const char* target)
|
||||
{
|
||||
return peekString(indexOf(target, 0));
|
||||
}
|
||||
|
||||
String peekString()
|
||||
{
|
||||
return peekString(_used);
|
||||
}
|
||||
|
||||
String peekString(int);
|
||||
|
||||
/* In addition to the above functions,
|
||||
the following inherited functions from the Print class are available.
|
||||
|
||||
size_t printf(const char * format, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
size_t printf_P(PGM_P format, ...) __attribute__((format(printf, 2, 3)));
|
||||
size_t print(const __FlashStringHelper *);
|
||||
size_t print(const String &);
|
||||
size_t print(const char[]);
|
||||
size_t print(char);
|
||||
size_t print(unsigned char, int = DEC);
|
||||
size_t print(int, int = DEC);
|
||||
size_t print(unsigned int, int = DEC);
|
||||
size_t print(long, int = DEC);
|
||||
size_t print(unsigned long, int = DEC);
|
||||
size_t print(double, int = 2);
|
||||
size_t print(const Printable&);
|
||||
|
||||
size_t println(const __FlashStringHelper *);
|
||||
size_t println(const String &s);
|
||||
size_t println(const char[]);
|
||||
size_t println(char);
|
||||
size_t println(unsigned char, int = DEC);
|
||||
size_t println(int, int = DEC);
|
||||
size_t println(unsigned int, int = DEC);
|
||||
size_t println(long, int = DEC);
|
||||
size_t println(unsigned long, int = DEC);
|
||||
size_t println(double, int = 2);
|
||||
size_t println(const Printable&);
|
||||
size_t println(void);
|
||||
*/
|
||||
|
||||
protected:
|
||||
|
||||
xseg *_head;
|
||||
xseg *_tail;
|
||||
uint16_t _used;
|
||||
uint16_t _free;
|
||||
uint16_t _offset;
|
||||
uint16_t _segSize;
|
||||
|
||||
void addSeg();
|
||||
void remSeg();
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncHTTPRequest_Debug_Generic.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef ASYNC_HTTP_DEBUG_PORT
|
||||
#define A_DBG_PORT ASYNC_HTTP_DEBUG_PORT
|
||||
#else
|
||||
#define A_DBG_PORT Serial
|
||||
#endif
|
||||
|
||||
// Change _ASYNC_HTTP_LOGLEVEL_ to set tracing and logging verbosity
|
||||
// 0: DISABLED: no logging
|
||||
// 1: ERROR: errors
|
||||
// 2: WARN: errors and warnings
|
||||
// 3: INFO: errors, warnings and informational (default)
|
||||
// 4: DEBUG: errors, warnings, informational and debug
|
||||
|
||||
#ifndef _ASYNC_HTTP_LOGLEVEL_
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 0
|
||||
#endif
|
||||
|
||||
#define AHTTP_LOGERROR(x) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.println(x); }
|
||||
#define AHTTP_LOGERROR0(x) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print(x); }
|
||||
#define AHTTP_LOGERROR1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.println(y); }
|
||||
#define AHTTP_LOGERROR2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
||||
#define AHTTP_LOGERROR3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>0) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
||||
|
||||
#define AHTTP_LOGWARN(x) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.println(x); }
|
||||
#define AHTTP_LOGWARN0(x) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print(x); }
|
||||
#define AHTTP_LOGWARN1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.println(y); }
|
||||
#define AHTTP_LOGWARN2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
||||
#define AHTTP_LOGWARN3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>1) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
||||
|
||||
#define AHTTP_LOGINFO(x) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.println(x); }
|
||||
#define AHTTP_LOGINFO0(x) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print(x); }
|
||||
#define AHTTP_LOGINFO1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.println(y); }
|
||||
#define AHTTP_LOGINFO2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
||||
#define AHTTP_LOGINFO3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>2) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
||||
|
||||
#define AHTTP_LOGDEBUG(x) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.println(x); }
|
||||
#define AHTTP_LOGDEBUG0(x) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print(x); }
|
||||
#define AHTTP_LOGDEBUG1(x,y) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.println(y); }
|
||||
#define AHTTP_LOGDEBUG2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
||||
#define AHTTP_LOGDEBUG3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncHTTPRequest_Generic.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "1.0.2"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "AsyncHTTPRequest_Debug_Generic.h"
|
||||
|
||||
#ifndef DEBUG_IOTA_PORT
|
||||
#define DEBUG_IOTA_PORT Serial
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_IOTA_HTTP
|
||||
#define DEBUG_IOTA_HTTP_SET true
|
||||
#else
|
||||
#define DEBUG_IOTA_HTTP_SET false
|
||||
#endif
|
||||
|
||||
|
||||
// KH add
|
||||
#define SAFE_DELETE(object) if (object) { delete object;}
|
||||
#define SAFE_DELETE_ARRAY(object) if (object) { delete[] object;}
|
||||
|
||||
#if ESP32
|
||||
|
||||
#include <AsyncTCP.h>
|
||||
|
||||
// KH mod
|
||||
#define MUTEX_LOCK_NR if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return;}
|
||||
#define MUTEX_LOCK(returnVal) if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return returnVal;}
|
||||
|
||||
#define _lock xSemaphoreTakeRecursive(threadLock,portMAX_DELAY)
|
||||
#define _unlock xSemaphoreGiveRecursive(threadLock)
|
||||
|
||||
#elif ESP8266
|
||||
|
||||
#include <ESPAsyncTCP.h>
|
||||
|
||||
#define MUTEX_LOCK_NR
|
||||
#define MUTEX_LOCK(returnVal)
|
||||
|
||||
#define _lock
|
||||
#define _unlock
|
||||
|
||||
#elif ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
|
||||
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
||||
defined(STM32WB) || defined(STM32MP1) )
|
||||
|
||||
#include "STM32AsyncTCP.h"
|
||||
|
||||
#define MUTEX_LOCK_NR
|
||||
#define MUTEX_LOCK(returnVal)
|
||||
#define _lock
|
||||
#define _unlock
|
||||
|
||||
#endif
|
||||
|
||||
#include <pgmspace.h>
|
||||
#include <utility/xbuf.h>
|
||||
|
||||
#define DEBUG_HTTP(format,...) if(_debug){\
|
||||
DEBUG_IOTA_PORT.printf("Debug(%3ld): ", millis()-_requestStartTime);\
|
||||
DEBUG_IOTA_PORT.printf_P(PSTR(format),##__VA_ARGS__);}
|
||||
|
||||
#define DEFAULT_RX_TIMEOUT 3 // Seconds for timeout
|
||||
|
||||
#define HTTPCODE_CONNECTION_REFUSED (-1)
|
||||
#define HTTPCODE_SEND_HEADER_FAILED (-2)
|
||||
#define HTTPCODE_SEND_PAYLOAD_FAILED (-3)
|
||||
#define HTTPCODE_NOT_CONNECTED (-4)
|
||||
#define HTTPCODE_CONNECTION_LOST (-5)
|
||||
#define HTTPCODE_NO_STREAM (-6)
|
||||
#define HTTPCODE_NO_HTTP_SERVER (-7)
|
||||
#define HTTPCODE_TOO_LESS_RAM (-8)
|
||||
#define HTTPCODE_ENCODING (-9)
|
||||
#define HTTPCODE_STREAM_WRITE (-10)
|
||||
#define HTTPCODE_TIMEOUT (-11)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
readyStateUnsent = 0, // Client created, open not yet called
|
||||
readyStateOpened = 1, // open() has been called, connected
|
||||
readyStateHdrsRecvd = 2, // send() called, response headers available
|
||||
readyStateLoading = 3, // receiving, partial data available
|
||||
readyStateDone = 4 // Request complete, all data available.
|
||||
} reqStates;
|
||||
|
||||
class AsyncHTTPRequest
|
||||
{
|
||||
struct header
|
||||
{
|
||||
header* next;
|
||||
char* name;
|
||||
char* value;
|
||||
|
||||
header(): next(nullptr), name(nullptr), value(nullptr)
|
||||
{};
|
||||
|
||||
~header()
|
||||
{
|
||||
SAFE_DELETE_ARRAY(name)
|
||||
SAFE_DELETE_ARRAY(value)
|
||||
SAFE_DELETE(next)
|
||||
//delete[] name;
|
||||
//delete[] value;
|
||||
//delete next;
|
||||
}
|
||||
};
|
||||
|
||||
struct URL
|
||||
{
|
||||
char* scheme;
|
||||
char* user;
|
||||
char* pwd;
|
||||
char* host;
|
||||
int port;
|
||||
char* path;
|
||||
char* query;
|
||||
char* fragment;
|
||||
|
||||
URL(): scheme(nullptr), user(nullptr), pwd(nullptr), host(nullptr),
|
||||
port(80), path(nullptr), query(nullptr), fragment(nullptr)
|
||||
{};
|
||||
|
||||
~URL()
|
||||
{
|
||||
SAFE_DELETE_ARRAY(scheme)
|
||||
SAFE_DELETE_ARRAY(user)
|
||||
SAFE_DELETE_ARRAY(pwd)
|
||||
SAFE_DELETE_ARRAY(host)
|
||||
SAFE_DELETE_ARRAY(path)
|
||||
SAFE_DELETE_ARRAY(query)
|
||||
SAFE_DELETE_ARRAY(fragment)
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::function<void(void*, AsyncHTTPRequest*, int readyState)> readyStateChangeCB;
|
||||
typedef std::function<void(void*, AsyncHTTPRequest*, size_t available)> onDataCB;
|
||||
|
||||
public:
|
||||
AsyncHTTPRequest();
|
||||
~AsyncHTTPRequest();
|
||||
|
||||
|
||||
//External functions in typical order of use:
|
||||
//__________________________________________________________________________________________________________*/
|
||||
void setDebug(bool); // Turn debug message on/off
|
||||
bool debug(); // is debug on or off?
|
||||
|
||||
bool open(const char* /*GET/POST*/, const char* URL); // Initiate a request
|
||||
void onReadyStateChange(readyStateChangeCB, void* arg = 0); // Optional event handler for ready state change
|
||||
// or you can simply poll readyState()
|
||||
void setTimeout(int); // overide default timeout (seconds)
|
||||
|
||||
void setReqHeader(const char* name, const char* value); // add a request header
|
||||
void setReqHeader(const char* name, int32_t value); // overload to use integer value
|
||||
|
||||
#if (ESP32 || ESP8266)
|
||||
void setReqHeader(const char* name, const __FlashStringHelper* value);
|
||||
void setReqHeader(const __FlashStringHelper *name, const char* value);
|
||||
void setReqHeader(const __FlashStringHelper *name, const __FlashStringHelper* value);
|
||||
void setReqHeader(const __FlashStringHelper *name, int32_t value);
|
||||
#endif
|
||||
|
||||
bool send(); // Send the request (GET)
|
||||
bool send(String body); // Send the request (POST)
|
||||
bool send(const char* body); // Send the request (POST)
|
||||
bool send(const uint8_t* buffer, size_t len); // Send the request (POST) (binary data?)
|
||||
bool send(xbuf* body, size_t len); // Send the request (POST) data in an xbuf
|
||||
void abort(); // Abort the current operation
|
||||
|
||||
reqStates readyState(); // Return the ready state
|
||||
|
||||
int respHeaderCount(); // Retrieve count of response headers
|
||||
char* respHeaderName(int index); // Return header name by index
|
||||
char* respHeaderValue(int index); // Return header value by index
|
||||
char* respHeaderValue(const char* name); // Return header value by name
|
||||
|
||||
bool respHeaderExists(const char* name); // Does header exist by name?
|
||||
|
||||
#if (ESP32 || ESP8266)
|
||||
char* respHeaderValue(const __FlashStringHelper *name);
|
||||
bool respHeaderExists(const __FlashStringHelper *name);
|
||||
#endif
|
||||
|
||||
String headers(); // Return all headers as String
|
||||
|
||||
void onData(onDataCB, void* arg = 0); // Notify when min data is available
|
||||
size_t available(); // response available
|
||||
size_t responseLength(); // indicated response length or sum of chunks to date
|
||||
int responseHTTPcode(); // HTTP response code or (negative) error code
|
||||
String responseText(); // response (whole* or partial* as string)
|
||||
size_t responseRead(uint8_t* buffer, size_t len); // Read response into buffer
|
||||
uint32_t elapsedTime(); // Elapsed time of in progress transaction or last completed (ms)
|
||||
String version(); // Version of AsyncHTTPRequest
|
||||
//___________________________________________________________________________________________________________________________________
|
||||
|
||||
private:
|
||||
|
||||
enum {HTTPmethodGET, HTTPmethodPOST} _HTTPmethod;
|
||||
|
||||
reqStates _readyState;
|
||||
|
||||
int16_t _HTTPcode; // HTTP response code or (negative) exception code
|
||||
bool _chunked; // Processing chunked response
|
||||
bool _debug; // Debug state
|
||||
uint32_t _timeout; // Default or user overide RxTimeout in seconds
|
||||
uint32_t _lastActivity; // Time of last activity
|
||||
uint32_t _requestStartTime; // Time last open() issued
|
||||
uint32_t _requestEndTime; // Time of last disconnect
|
||||
URL* _URL; // -> URL data structure
|
||||
char* _connectedHost; // Host when connected
|
||||
int _connectedPort; // Port when connected
|
||||
AsyncClient* _client; // ESPAsyncTCP AsyncClient instance
|
||||
size_t _contentLength; // content-length header value or sum of chunk headers
|
||||
size_t _contentRead; // number of bytes retrieved by user since last open()
|
||||
readyStateChangeCB _readyStateChangeCB; // optional callback for readyState change
|
||||
void* _readyStateChangeCBarg; // associated user argument
|
||||
onDataCB _onDataCB; // optional callback when data received
|
||||
void* _onDataCBarg; // associated user argument
|
||||
|
||||
#ifdef ESP32
|
||||
SemaphoreHandle_t threadLock;
|
||||
#endif
|
||||
|
||||
// request and response String buffers and header list (same queue for request and response).
|
||||
|
||||
xbuf* _request; // Tx data buffer
|
||||
xbuf* _response; // Rx data buffer for headers
|
||||
xbuf* _chunks; // First stage for chunked response
|
||||
header* _headers; // request or (readyState > readyStateHdrsRcvd) response headers
|
||||
|
||||
// Protected functions
|
||||
|
||||
header* _addHeader(const char*, const char*);
|
||||
header* _getHeader(const char*);
|
||||
header* _getHeader(int);
|
||||
bool _buildRequest();
|
||||
bool _parseURL(const char*);
|
||||
bool _parseURL(String);
|
||||
void _processChunks();
|
||||
bool _connect();
|
||||
size_t _send();
|
||||
void _setReadyState(reqStates);
|
||||
|
||||
#if (ESP32 || ESP8266)
|
||||
char* _charstar(const __FlashStringHelper *str);
|
||||
#endif
|
||||
|
||||
// callbacks
|
||||
|
||||
void _onConnect(AsyncClient*);
|
||||
void _onDisconnect(AsyncClient*);
|
||||
void _onData(void*, size_t);
|
||||
void _onError(AsyncClient*, int8_t);
|
||||
void _onPoll(AsyncClient*);
|
||||
bool _collectHeaders();
|
||||
};
|
||||
|
||||
#include "AsyncHTTPRequest_Impl_Generic.h"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,151 @@
|
||||
/****************************************************************************************************************************
|
||||
xbuf.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
/********************************************************************************************
|
||||
xbuf is a dynamic buffering system that supports reading and writing much like cbuf.
|
||||
The class has it's own provision for writing from buffers, Strings and other xbufs
|
||||
as well as the inherited Print functions.
|
||||
Rather than use a large contiguous heap allocation, xbuf uses a linked chain of segments
|
||||
to dynamically grow and shrink with the contents.
|
||||
There are other benefits as well to using smaller heap allocation units:
|
||||
1) A buffer can work fine in a fragmented heap environment (admittedly contributing to it)
|
||||
2) xbuf contents can be copied from one buffer to another without the need for
|
||||
2x heap during the copy.
|
||||
The segment size defaults to 64 but can be dynamically set in the constructor at creation.
|
||||
The inclusion of indexOf and read/peek until functions make it useful for handling
|
||||
data streams like HTTP, and in fact is why it was created.
|
||||
|
||||
NOTE: The size of the indexOf() search string is limited to the segment size.
|
||||
It could be extended but didn't seem to be a practical consideration.
|
||||
|
||||
********************************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
struct xseg
|
||||
{
|
||||
xseg *next;
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
class xbuf: public Print
|
||||
{
|
||||
public:
|
||||
|
||||
xbuf(const uint16_t segSize = 64);
|
||||
virtual ~xbuf();
|
||||
|
||||
size_t write(const uint8_t);
|
||||
size_t write(const char*);
|
||||
size_t write(const uint8_t*, const size_t);
|
||||
size_t write(xbuf*, const size_t);
|
||||
size_t write(String);
|
||||
size_t available();
|
||||
int indexOf(const char, const size_t begin = 0);
|
||||
int indexOf(const char*, const size_t begin = 0);
|
||||
uint8_t read();
|
||||
size_t read(uint8_t*, size_t);
|
||||
String readStringUntil(const char);
|
||||
String readStringUntil(const char*);
|
||||
String readString(int);
|
||||
|
||||
String readString()
|
||||
{
|
||||
return readString(available());
|
||||
}
|
||||
|
||||
void flush();
|
||||
|
||||
uint8_t peek();
|
||||
size_t peek(uint8_t*, const size_t);
|
||||
|
||||
String peekStringUntil(const char target)
|
||||
{
|
||||
return peekString(indexOf(target, 0));
|
||||
}
|
||||
|
||||
String peekStringUntil(const char* target)
|
||||
{
|
||||
return peekString(indexOf(target, 0));
|
||||
}
|
||||
|
||||
String peekString()
|
||||
{
|
||||
return peekString(_used);
|
||||
}
|
||||
|
||||
String peekString(int);
|
||||
|
||||
/* In addition to the above functions,
|
||||
the following inherited functions from the Print class are available.
|
||||
|
||||
size_t printf(const char * format, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
size_t printf_P(PGM_P format, ...) __attribute__((format(printf, 2, 3)));
|
||||
size_t print(const __FlashStringHelper *);
|
||||
size_t print(const String &);
|
||||
size_t print(const char[]);
|
||||
size_t print(char);
|
||||
size_t print(unsigned char, int = DEC);
|
||||
size_t print(int, int = DEC);
|
||||
size_t print(unsigned int, int = DEC);
|
||||
size_t print(long, int = DEC);
|
||||
size_t print(unsigned long, int = DEC);
|
||||
size_t print(double, int = 2);
|
||||
size_t print(const Printable&);
|
||||
|
||||
size_t println(const __FlashStringHelper *);
|
||||
size_t println(const String &s);
|
||||
size_t println(const char[]);
|
||||
size_t println(char);
|
||||
size_t println(unsigned char, int = DEC);
|
||||
size_t println(int, int = DEC);
|
||||
size_t println(unsigned int, int = DEC);
|
||||
size_t println(long, int = DEC);
|
||||
size_t println(unsigned long, int = DEC);
|
||||
size_t println(double, int = 2);
|
||||
size_t println(const Printable&);
|
||||
size_t println(void);
|
||||
*/
|
||||
|
||||
protected:
|
||||
|
||||
xseg *_head;
|
||||
xseg *_tail;
|
||||
uint16_t _used;
|
||||
uint16_t _free;
|
||||
uint16_t _offset;
|
||||
uint16_t _segSize;
|
||||
|
||||
void addSeg();
|
||||
void remSeg();
|
||||
|
||||
};
|
||||
|
||||
#include "utility/xbuf_Impl.h"
|
||||
|
||||
@@ -0,0 +1,399 @@
|
||||
/****************************************************************************************************************************
|
||||
xbuf_Impl.h - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_STM32 is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.0.2
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
xbuf::xbuf(const uint16_t segSize) : _head(nullptr), _tail(nullptr), _used(0), _free(0), _offset(0)
|
||||
{
|
||||
_segSize = (segSize + 3) & -4;//((segSize + 3) >> 2) << 2;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
xbuf::~xbuf()
|
||||
{
|
||||
flush();
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::write(const uint8_t byte)
|
||||
{
|
||||
return write((uint8_t*) &byte, 1);
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::write(const char* buf)
|
||||
{
|
||||
return write((uint8_t*)buf, strlen(buf));
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::write(String string)
|
||||
{
|
||||
return write((uint8_t*)string.c_str(), string.length());
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::write(const uint8_t* buf, const size_t len)
|
||||
{
|
||||
size_t supply = len;
|
||||
|
||||
while (supply)
|
||||
{
|
||||
if (!_free)
|
||||
{
|
||||
addSeg();
|
||||
}
|
||||
|
||||
size_t demand = _free < supply ? _free : supply;
|
||||
memcpy(_tail->data + ((_offset + _used) % _segSize), buf + (len - supply), demand);
|
||||
_free -= demand;
|
||||
_used += demand;
|
||||
supply -= demand;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::write(xbuf* buf, const size_t len)
|
||||
{
|
||||
size_t supply = len;
|
||||
|
||||
if (supply > buf->available())
|
||||
{
|
||||
supply = buf->available();
|
||||
}
|
||||
|
||||
size_t read = 0;
|
||||
|
||||
while (supply)
|
||||
{
|
||||
if (!_free)
|
||||
{
|
||||
addSeg();
|
||||
}
|
||||
|
||||
size_t demand = _free < supply ? _free : supply;
|
||||
read += buf->read(_tail->data + ((_offset + _used) % _segSize), demand);
|
||||
_free -= demand;
|
||||
_used += demand;
|
||||
supply -= demand;
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
uint8_t xbuf::read()
|
||||
{
|
||||
uint8_t byte = 0;
|
||||
read((uint8_t*) &byte, 1);
|
||||
|
||||
return byte;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
uint8_t xbuf::peek()
|
||||
{
|
||||
uint8_t byte = 0;
|
||||
peek((uint8_t*) &byte, 1);
|
||||
|
||||
return byte;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::read(uint8_t* buf, const size_t len)
|
||||
{
|
||||
size_t read = 0;
|
||||
|
||||
while (read < len && _used)
|
||||
{
|
||||
size_t supply = (_offset + _used) > _segSize ? _segSize - _offset : _used;
|
||||
size_t demand = len - read;
|
||||
size_t chunk = supply < demand ? supply : demand;
|
||||
memcpy(buf + read, _head->data + _offset, chunk);
|
||||
_offset += chunk;
|
||||
_used -= chunk;
|
||||
read += chunk;
|
||||
|
||||
if (_offset == _segSize)
|
||||
{
|
||||
remSeg();
|
||||
_offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! _used)
|
||||
{
|
||||
flush();
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::peek(uint8_t* buf, const size_t len)
|
||||
{
|
||||
size_t read = 0;
|
||||
xseg* seg = _head;
|
||||
size_t offset = _offset;
|
||||
size_t used = _used;
|
||||
|
||||
while (read < len && used)
|
||||
{
|
||||
size_t supply = (offset + used) > _segSize ? _segSize - offset : used;
|
||||
size_t demand = len - read;
|
||||
size_t chunk = supply < demand ? supply : demand;
|
||||
|
||||
memcpy(buf + read, seg->data + offset, chunk);
|
||||
|
||||
offset += chunk;
|
||||
used -= chunk;
|
||||
read += chunk;
|
||||
|
||||
if (offset == _segSize)
|
||||
{
|
||||
seg = seg->next;
|
||||
offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
size_t xbuf::available()
|
||||
{
|
||||
return _used;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
int xbuf::indexOf(const char target, const size_t begin)
|
||||
{
|
||||
char targetstr[2] = " ";
|
||||
targetstr[0] = target;
|
||||
|
||||
return indexOf(targetstr, begin);
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
int xbuf::indexOf(const char* target, const size_t begin)
|
||||
{
|
||||
size_t targetLen = strlen(target);
|
||||
|
||||
if (targetLen > _segSize || targetLen > _used)
|
||||
return -1;
|
||||
|
||||
size_t searchPos = _offset + begin;
|
||||
size_t searchEnd = _offset + _used - targetLen;
|
||||
|
||||
if (searchPos > searchEnd)
|
||||
return -1;
|
||||
|
||||
size_t searchSeg = searchPos / _segSize;
|
||||
xseg* seg = _head;
|
||||
|
||||
while (searchSeg)
|
||||
{
|
||||
seg = seg->next;
|
||||
searchSeg --;
|
||||
}
|
||||
|
||||
size_t segPos = searchPos % _segSize;
|
||||
|
||||
while (searchPos <= searchEnd)
|
||||
{
|
||||
size_t compLen = targetLen;
|
||||
|
||||
if (compLen <= (_segSize - segPos))
|
||||
{
|
||||
if (memcmp(target, seg->data + segPos, compLen) == 0)
|
||||
{
|
||||
return searchPos - _offset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t compLen = _segSize - segPos;
|
||||
|
||||
if (memcmp(target, seg->data + segPos, compLen) == 0)
|
||||
{
|
||||
compLen = targetLen - compLen;
|
||||
|
||||
if (memcmp(target + targetLen - compLen, seg->next->data, compLen) == 0)
|
||||
{
|
||||
return searchPos - _offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
searchPos++;
|
||||
segPos++;
|
||||
|
||||
if (segPos == _segSize)
|
||||
{
|
||||
seg = seg->next;
|
||||
segPos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
String xbuf::readStringUntil(const char target)
|
||||
{
|
||||
return readString(indexOf(target) + 1);
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
String xbuf::readStringUntil(const char* target)
|
||||
{
|
||||
int index = indexOf(target);
|
||||
|
||||
if (index < 0)
|
||||
return String();
|
||||
|
||||
return readString(index + strlen(target));
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
String xbuf::readString(int endPos)
|
||||
{
|
||||
String result;
|
||||
|
||||
if ( ! result.reserve(endPos + 1))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (endPos > _used)
|
||||
{
|
||||
endPos = _used;
|
||||
}
|
||||
|
||||
if (endPos > 0 && result.reserve(endPos + 1))
|
||||
{
|
||||
while (endPos--)
|
||||
{
|
||||
result += (char)_head->data[_offset++];
|
||||
_used--;
|
||||
|
||||
if (_offset >= _segSize)
|
||||
{
|
||||
remSeg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
String xbuf::peekString(int endPos)
|
||||
{
|
||||
String result;
|
||||
|
||||
xseg* seg = _head;
|
||||
size_t offset = _offset;
|
||||
|
||||
if (endPos > _used)
|
||||
{
|
||||
endPos = _used;
|
||||
}
|
||||
|
||||
if (endPos > 0 && result.reserve(endPos + 1))
|
||||
{
|
||||
while (endPos--)
|
||||
{
|
||||
result += (char)seg->data[offset++];
|
||||
|
||||
if ( offset >= _segSize)
|
||||
{
|
||||
seg = seg->next;
|
||||
offset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
void xbuf::flush()
|
||||
{
|
||||
while (_head)
|
||||
remSeg();
|
||||
|
||||
_tail = nullptr;
|
||||
_offset = 0;
|
||||
_used = 0;
|
||||
_free = 0;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
void xbuf::addSeg()
|
||||
{
|
||||
if (_tail)
|
||||
{
|
||||
_tail->next = (xseg*) new uint32_t[_segSize / 4 + 1];
|
||||
|
||||
// KH, Must check NULL here
|
||||
_tail = _tail->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
// KH, Must check NULL here
|
||||
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
|
||||
}
|
||||
|
||||
// KH, Must check NULL here
|
||||
if (_tail)
|
||||
_tail->next = nullptr;
|
||||
|
||||
_free += _segSize;
|
||||
}
|
||||
|
||||
//*******************************************************************************************************************
|
||||
void xbuf::remSeg()
|
||||
{
|
||||
if (_head)
|
||||
{
|
||||
xseg *next = _head->next;
|
||||
delete[] (uint32_t*) _head;
|
||||
_head = next;
|
||||
|
||||
if ( ! _head)
|
||||
{
|
||||
_tail = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
_offset = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user