Compare commits

...

23 Commits

Author SHA1 Message Date
0acf19af8f Update IDF to v3.2 977854975 (#2771)
* Update IDF to v3.2 977854975

* Update app_httpd.cpp
2019-05-12 18:52:23 +03:00
aff2e42ac6 Add Pycom GPy board (#2754) 2019-05-11 11:24:11 +03:00
2743e7b739 Update mac.md (#2745) 2019-05-11 11:21:25 +03:00
c453a0037b Adding TTGO T1 board definition (#2744)
Fixes https://github.com/espressif/arduino-esp32/issues/2740
2019-05-11 11:20:57 +03:00
2f249edb8e Use std::abs for a float-compatible abs() function (#2738)
* Other Arduino cores uses a macro to redefine libc abs() to take any
  type, meaning abs(-3.3) == 3.3 not the normal libc result of 3.

* 1e4bf14a3 (#1783) replaced similar min, max macros with c++ stdlib. However
  this change includes <algorithm> after the line which defines the abs() macro.
  <algorithm> includes <cstdlib> which undefines abs() and re-defines it.

* This means abs() becomes the plain libc version again which only takes
  integers, so abs(-3.3) == 3. As reported here:
  https://github.com/espressif/esp-idf/issues/3405

This fix tries to keep in the spirit of #1783 by using libstdc++. The other
option would be to include <cstdlib> before defining the abs() macro, so it
doesn't get undef-ed again later on.
2019-05-11 11:18:39 +03:00
bd57ff4ab4 StreamString SSO fix (#2736)
As found by @mongozmaki in https://github.com/esp8266/Arduino/pull/6035

With SSO implementation in String, StreamString::write generates wrong
strings under some circumstances.  Reason is that String::len() returns
strlen(sso_buf) if SSO=true but with newly written data
(in StreamString::write) the null-termination missing at the time len()
is called.

Furthermore, len() is called twice which is inefficient if SSO=true.
2019-05-11 11:16:05 +03:00
43bf393dbf Fix semaphores in IDF & std::string assert (#2728)
* Fix semaphores in IDF & std::string assert 

Fixes the problem of giving a mutex from a callback with the latest IDF. Also addresses an occasional assert that happens when the btc_task callback gives the semaphore and causes an assert due to both cores potentially writing m_owner concurrently.

* Restored m_owner position in wait() as requested

* Reapply assert fix and move setting m_owner in ::give() 

Revert previous revert commit and move setting of m_owner in ::give to before giving the semaphore to prevent race condition possibility.
2019-05-11 11:03:09 +03:00
bea7bd1852 Implemented ability to change BLE address (#2690)
Implemented the ability to change the ESP32s BLE device address as
according the the BLE specification. This address is used when
advertising the ESP32 over BLE.
2019-05-11 11:02:26 +03:00
7dd537f8d3 Fix libgcc not being in rom
fixes: https://github.com/espressif/arduino-esp32/issues/2758
2019-05-09 13:07:49 +03:00
50d142950d Update esp32-hal-rmt.c 2019-05-01 20:10:41 +03:00
d13de284b8 Undo the redefinition of FPSTR from 8266 merge (#2726)
Fixes Arduino.h redefinition errors.
2019-04-30 16:52:14 +03:00
697d4ff7c4 Add board "WEMOS D1 MINI ESP32". (#2710) 2019-04-27 14:10:21 +03:00
ab309e40d5 Copy ESP8266 String w/SSO to ESP32 repo (#2715)
I redid the ESP8266 WString library to enable small string optimization
(SSO) a while back, and think it would be helpful even on the ESP32 with
its higher memory complement.

SSO avoids lots of tiny mallocs() on the heap which cause fragmentation
by using the memory in the class object itself to store the actual
string and only mallocing() for buffers that are larger than what can
fit in thie class object.  Modern C++ std::string implementations have
this optimization as well, but since we're using Arduino strings we had
to roll our own.
2019-04-26 19:41:42 +03:00
932666a03f Ensure that _size is properly set in begin (#2706)
* Ensure that _size is properly set in begin

* NULL check on _data assignment

* Changed _data to malloc in order to catch alloc fails
2019-04-26 19:39:22 +03:00
a0ad987029 Add TTGO T-Watch board definition (#2681) 2019-04-25 12:16:26 +03:00
271e5cd206 Fix Werror=reorder for idf.py build (#2707) 2019-04-25 12:02:21 +03:00
619568db5b Converted EEPROM library to use nvs instead of partition. (#2678)
* Converted EEPROM library to use nvs instead of partition.  Removed eeprom partition from all partition table CSV files.
* Changed variable names, added some comments, formatting as per me-no-dev's requests
* Checks for memory on malloc
* Moved include nvs.h from header to code
* Reworked the extra example to make it more clear how to actually use the library and persist data
2019-04-23 23:55:12 +03:00
0202ba7c21 Fix reorder error in WebServer (#2700) 2019-04-23 17:57:33 +03:00
119ece2b0f Portability from ESP8266, virtual Stream member functions. (#2701) 2019-04-23 17:56:49 +03:00
606446a830 Update ALKS board (#2694) 2019-04-23 10:52:24 +03:00
a28cf00295 add lolin32 CPU freq choice (#2682) 2019-04-22 22:00:23 +03:00
672e4faa92 Add optional support for CORS headers (#2688)
* add support for CORS headers

* remove accidental function impl

* rename setCORS to enableCORS, and add aliased function enableCrossOrigin
2019-04-22 21:52:39 +03:00
f8eebb5c39 Fix indentation 2019-04-17 23:27:32 +03:00
142 changed files with 2163 additions and 2074 deletions

View File

@ -378,6 +378,128 @@ ttgo-lora32-v1.menu.DebugLevel.verbose.build.code_debug=5
##############################################################
ttgo-t1.name=TTGO T1
ttgo-t1.upload.tool=esptool_py
ttgo-t1.upload.maximum_size=1310720
ttgo-t1.upload.maximum_data_size=327680
ttgo-t1.upload.wait_for_upload_port=true
ttgo-t1.serial.disableDTR=true
ttgo-t1.serial.disableRTS=true
ttgo-t1.build.mcu=esp32
ttgo-t1.build.core=esp32
ttgo-t1.build.variant=ttgo-t1
ttgo-t1.build.board=TTGO_T1
ttgo-t1.build.f_cpu=240000000L
ttgo-t1.build.flash_size=4MB
ttgo-t1.build.flash_freq=40m
ttgo-t1.build.flash_mode=dio
ttgo-t1.build.boot=dio
ttgo-t1.build.partitions=default
ttgo-t1.build.defines=
ttgo-t1.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
ttgo-t1.menu.PartitionScheme.default.build.partitions=default
ttgo-t1.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
ttgo-t1.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
ttgo-t1.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
ttgo-t1.menu.PartitionScheme.minimal.build.partitions=minimal
ttgo-t1.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
ttgo-t1.menu.PartitionScheme.no_ota.build.partitions=no_ota
ttgo-t1.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
ttgo-t1.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
ttgo-t1.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
ttgo-t1.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
ttgo-t1.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
ttgo-t1.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
ttgo-t1.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
ttgo-t1.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
ttgo-t1.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
ttgo-t1.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
ttgo-t1.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
ttgo-t1.menu.PartitionScheme.huge_app.build.partitions=huge_app
ttgo-t1.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
ttgo-t1.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
ttgo-t1.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
ttgo-t1.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
ttgo-t1.menu.CPUFreq.240=240MHz (WiFi/BT)
ttgo-t1.menu.CPUFreq.240.build.f_cpu=240000000L
ttgo-t1.menu.CPUFreq.160=160MHz (WiFi/BT)
ttgo-t1.menu.CPUFreq.160.build.f_cpu=160000000L
ttgo-t1.menu.CPUFreq.80=80MHz (WiFi/BT)
ttgo-t1.menu.CPUFreq.80.build.f_cpu=80000000L
ttgo-t1.menu.CPUFreq.40=40MHz (40MHz XTAL)
ttgo-t1.menu.CPUFreq.40.build.f_cpu=40000000L
ttgo-t1.menu.CPUFreq.26=26MHz (26MHz XTAL)
ttgo-t1.menu.CPUFreq.26.build.f_cpu=26000000L
ttgo-t1.menu.CPUFreq.20=20MHz (40MHz XTAL)
ttgo-t1.menu.CPUFreq.20.build.f_cpu=20000000L
ttgo-t1.menu.CPUFreq.13=13MHz (26MHz XTAL)
ttgo-t1.menu.CPUFreq.13.build.f_cpu=13000000L
ttgo-t1.menu.CPUFreq.10=10MHz (40MHz XTAL)
ttgo-t1.menu.CPUFreq.10.build.f_cpu=10000000L
ttgo-t1.menu.FlashMode.qio=QIO
ttgo-t1.menu.FlashMode.qio.build.flash_mode=dio
ttgo-t1.menu.FlashMode.qio.build.boot=qio
ttgo-t1.menu.FlashMode.dio=DIO
ttgo-t1.menu.FlashMode.dio.build.flash_mode=dio
ttgo-t1.menu.FlashMode.dio.build.boot=dio
ttgo-t1.menu.FlashMode.qout=QOUT
ttgo-t1.menu.FlashMode.qout.build.flash_mode=dout
ttgo-t1.menu.FlashMode.qout.build.boot=qout
ttgo-t1.menu.FlashMode.dout=DOUT
ttgo-t1.menu.FlashMode.dout.build.flash_mode=dout
ttgo-t1.menu.FlashMode.dout.build.boot=dout
ttgo-t1.menu.FlashFreq.80=80MHz
ttgo-t1.menu.FlashFreq.80.build.flash_freq=80m
ttgo-t1.menu.FlashFreq.40=40MHz
ttgo-t1.menu.FlashFreq.40.build.flash_freq=40m
ttgo-t1.menu.FlashSize.4M=4MB (32Mb)
ttgo-t1.menu.FlashSize.4M.build.flash_size=4MB
ttgo-t1.menu.FlashSize.2M=2MB (16Mb)
ttgo-t1.menu.FlashSize.2M.build.flash_size=2MB
ttgo-t1.menu.FlashSize.2M.build.partitions=minimal
ttgo-t1.menu.FlashSize.16M=16MB (128Mb)
ttgo-t1.menu.FlashSize.16M.build.flash_size=16MB
ttgo-t1.menu.FlashSize.16M.build.partitions=ffat
ttgo-t1.menu.UploadSpeed.921600=921600
ttgo-t1.menu.UploadSpeed.921600.upload.speed=921600
ttgo-t1.menu.UploadSpeed.115200=115200
ttgo-t1.menu.UploadSpeed.115200.upload.speed=115200
ttgo-t1.menu.UploadSpeed.256000.windows=256000
ttgo-t1.menu.UploadSpeed.256000.upload.speed=256000
ttgo-t1.menu.UploadSpeed.230400.windows.upload.speed=256000
ttgo-t1.menu.UploadSpeed.230400=230400
ttgo-t1.menu.UploadSpeed.230400.upload.speed=230400
ttgo-t1.menu.UploadSpeed.460800.linux=460800
ttgo-t1.menu.UploadSpeed.460800.macosx=460800
ttgo-t1.menu.UploadSpeed.460800.upload.speed=460800
ttgo-t1.menu.UploadSpeed.512000.windows=512000
ttgo-t1.menu.UploadSpeed.512000.upload.speed=512000
ttgo-t1.menu.DebugLevel.none=None
ttgo-t1.menu.DebugLevel.none.build.code_debug=0
ttgo-t1.menu.DebugLevel.error=Error
ttgo-t1.menu.DebugLevel.error.build.code_debug=1
ttgo-t1.menu.DebugLevel.warn=Warn
ttgo-t1.menu.DebugLevel.warn.build.code_debug=2
ttgo-t1.menu.DebugLevel.info=Info
ttgo-t1.menu.DebugLevel.info.build.code_debug=3
ttgo-t1.menu.DebugLevel.debug=Debug
ttgo-t1.menu.DebugLevel.debug.build.code_debug=4
ttgo-t1.menu.DebugLevel.verbose=Verbose
ttgo-t1.menu.DebugLevel.verbose.build.code_debug=5
##############################################################
cw02.name=XinaBox CW02
cw02.upload.tool=esptool_py
@ -879,6 +1001,23 @@ lolin32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
lolin32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
lolin32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
lolin32.menu.CPUFreq.240=240MHz (WiFi/BT)
lolin32.menu.CPUFreq.240.build.f_cpu=240000000L
lolin32.menu.CPUFreq.160=160MHz (WiFi/BT)
lolin32.menu.CPUFreq.160.build.f_cpu=160000000L
lolin32.menu.CPUFreq.80=80MHz (WiFi/BT)
lolin32.menu.CPUFreq.80.build.f_cpu=80000000L
lolin32.menu.CPUFreq.40=40MHz (40MHz XTAL)
lolin32.menu.CPUFreq.40.build.f_cpu=40000000L
lolin32.menu.CPUFreq.26=26MHz (26MHz XTAL)
lolin32.menu.CPUFreq.26.build.f_cpu=26000000L
lolin32.menu.CPUFreq.20=20MHz (40MHz XTAL)
lolin32.menu.CPUFreq.20.build.f_cpu=20000000L
lolin32.menu.CPUFreq.13=13MHz (26MHz XTAL)
lolin32.menu.CPUFreq.13.build.f_cpu=13000000L
lolin32.menu.CPUFreq.10=10MHz (40MHz XTAL)
lolin32.menu.CPUFreq.10.build.f_cpu=10000000L
lolin32.menu.UploadSpeed.921600=921600
lolin32.menu.UploadSpeed.921600.upload.speed=921600
lolin32.menu.UploadSpeed.115200=115200
@ -2744,16 +2883,54 @@ alksesp32.build.boot=dio
alksesp32.build.partitions=default
alksesp32.build.defines=
alksesp32.menu.PartitionScheme.default=Default
alksesp32.menu.PSRAM.disabled=Disabled
alksesp32.menu.PSRAM.disabled.build.defines=
alksesp32.menu.PSRAM.enabled=Enabled
alksesp32.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue
alksesp32.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
alksesp32.menu.PartitionScheme.default.build.partitions=default
alksesp32.menu.PartitionScheme.minimal=Minimal (2MB FLASH)
alksesp32.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
alksesp32.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
alksesp32.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
alksesp32.menu.PartitionScheme.minimal.build.partitions=minimal
alksesp32.menu.PartitionScheme.no_ota=No OTA (Large APP)
alksesp32.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
alksesp32.menu.PartitionScheme.no_ota.build.partitions=no_ota
alksesp32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
alksesp32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
alksesp32.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
alksesp32.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
alksesp32.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
alksesp32.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
alksesp32.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
alksesp32.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
alksesp32.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
alksesp32.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
alksesp32.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
alksesp32.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
alksesp32.menu.PartitionScheme.huge_app.build.partitions=huge_app
alksesp32.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
alksesp32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
alksesp32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
alksesp32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
alksesp32.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT)
alksesp32.menu.PartitionScheme.fatflash.build.partitions=ffat
alksesp32.menu.CPUFreq.240=240MHz (WiFi/BT)
alksesp32.menu.CPUFreq.240.build.f_cpu=240000000L
alksesp32.menu.CPUFreq.160=160MHz (WiFi/BT)
alksesp32.menu.CPUFreq.160.build.f_cpu=160000000L
alksesp32.menu.CPUFreq.80=80MHz (WiFi/BT)
alksesp32.menu.CPUFreq.80.build.f_cpu=80000000L
alksesp32.menu.CPUFreq.40=40MHz (40MHz XTAL)
alksesp32.menu.CPUFreq.40.build.f_cpu=40000000L
alksesp32.menu.CPUFreq.26=26MHz (26MHz XTAL)
alksesp32.menu.CPUFreq.26.build.f_cpu=26000000L
alksesp32.menu.CPUFreq.20=20MHz (40MHz XTAL)
alksesp32.menu.CPUFreq.20.build.f_cpu=20000000L
alksesp32.menu.CPUFreq.13=13MHz (26MHz XTAL)
alksesp32.menu.CPUFreq.13.build.f_cpu=13000000L
alksesp32.menu.CPUFreq.10=10MHz (40MHz XTAL)
alksesp32.menu.CPUFreq.10.build.f_cpu=10000000L
alksesp32.menu.FlashMode.qio=QIO
alksesp32.menu.FlashMode.qio.build.flash_mode=dio
@ -2778,6 +2955,9 @@ alksesp32.menu.FlashSize.4M.build.flash_size=4MB
alksesp32.menu.FlashSize.2M=2MB (16Mb)
alksesp32.menu.FlashSize.2M.build.flash_size=2MB
alksesp32.menu.FlashSize.2M.build.partitions=minimal
alksesp32.menu.FlashSize.16M=16MB (128Mb)
alksesp32.menu.FlashSize.16M.build.flash_size=16MB
alksesp32.menu.FlashSize.16M.build.partitions=ffat
alksesp32.menu.UploadSpeed.921600=921600
alksesp32.menu.UploadSpeed.921600.upload.speed=921600
@ -3522,4 +3702,197 @@ sparkfun_lora_gateway_1-channel.menu.UploadSpeed.512000.upload.speed=512000
##############################################################
ttgo-t-watch.name=TTGO T-Watch
ttgo-t-watch.upload.tool=esptool_py
ttgo-t-watch.upload.maximum_size=6553600
ttgo-t-watch.upload.maximum_data_size=4521984
ttgo-t-watch.upload.wait_for_upload_port=true
ttgo-t-watch.serial.disableDTR=true
ttgo-t-watch.serial.disableRTS=true
ttgo-t-watch.build.mcu=esp32
ttgo-t-watch.build.core=esp32
ttgo-t-watch.build.variant=twatch
ttgo-t-watch.build.board=T-Watch
ttgo-t-watch.build.f_cpu=240000000L
ttgo-t-watch.build.flash_size=16MB
ttgo-t-watch.build.flash_freq=80m
ttgo-t-watch.build.flash_mode=dio
ttgo-t-watch.build.boot=dio
ttgo-t-watch.build.partitions=default_16MB
ttgo-t-watch.build.defines=
ttgo-t-watch.menu.PSRAM.enabled=Enabled
ttgo-t-watch.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue
ttgo-t-watch.menu.PSRAM.disabled=Disabled
ttgo-t-watch.menu.PSRAM.disabled.build.defines=
ttgo-t-watch.menu.PartitionScheme.default=Default (2 x 6.5 MB app, 3.6 MB SPIFFS)
ttgo-t-watch.menu.PartitionScheme.default.build.partitions=default_16MB
ttgo-t-watch.menu.PartitionScheme.large_spiffs=Large SPIFFS (7 MB)
ttgo-t-watch.menu.PartitionScheme.large_spiffs.build.partitions=large_spiffs_16MB
ttgo-t-watch.menu.PartitionScheme.large_spiffs.upload.maximum_size=4685824
ttgo-t-watch.menu.UploadSpeed.2000000=2000000
ttgo-t-watch.menu.UploadSpeed.2000000.upload.speed=2000000
ttgo-t-watch.menu.UploadSpeed.1152000=1152000
ttgo-t-watch.menu.UploadSpeed.1152000.upload.speed=1152000
ttgo-t-watch.menu.UploadSpeed.921600=921600
ttgo-t-watch.menu.UploadSpeed.921600.upload.speed=921600
ttgo-t-watch.menu.UploadSpeed.115200=115200
ttgo-t-watch.menu.UploadSpeed.115200.upload.speed=115200
ttgo-t-watch.menu.UploadSpeed.256000.windows=256000
ttgo-t-watch.menu.UploadSpeed.256000.upload.speed=256000
ttgo-t-watch.menu.UploadSpeed.230400.windows.upload.speed=256000
ttgo-t-watch.menu.UploadSpeed.230400=230400
ttgo-t-watch.menu.UploadSpeed.230400.upload.speed=230400
ttgo-t-watch.menu.UploadSpeed.460800.linux=460800
ttgo-t-watch.menu.UploadSpeed.460800.macosx=460800
ttgo-t-watch.menu.UploadSpeed.460800.upload.speed=460800
ttgo-t-watch.menu.UploadSpeed.512000.windows=512000
ttgo-t-watch.menu.UploadSpeed.512000.upload.speed=512000
ttgo-t-watch.menu.DebugLevel.none=None
ttgo-t-watch.menu.DebugLevel.none.build.code_debug=0
ttgo-t-watch.menu.DebugLevel.error=Error
ttgo-t-watch.menu.DebugLevel.error.build.code_debug=1
ttgo-t-watch.menu.DebugLevel.warn=Warn
ttgo-t-watch.menu.DebugLevel.warn.build.code_debug=2
ttgo-t-watch.menu.DebugLevel.info=Info
ttgo-t-watch.menu.DebugLevel.info.build.code_debug=3
ttgo-t-watch.menu.DebugLevel.debug=Debug
ttgo-t-watch.menu.DebugLevel.debug.build.code_debug=4
ttgo-t-watch.menu.DebugLevel.verbose=Verbose
ttgo-t-watch.menu.DebugLevel.verbose.build.code_debug=5
##############################################################
d1_mini32.name=WEMOS D1 MINI ESP32
d1_mini32.upload.tool=esptool_py
d1_mini32.upload.maximum_size=1310720
d1_mini32.upload.maximum_data_size=327680
d1_mini32.upload.wait_for_upload_port=true
d1_mini32.serial.disableDTR=true
d1_mini32.serial.disableRTS=true
d1_mini32.build.mcu=esp32
d1_mini32.build.core=esp32
d1_mini32.build.variant=d1_mini32
d1_mini32.build.board=D1_MINI32
d1_mini32.build.f_cpu=240000000L
d1_mini32.build.flash_mode=dio
d1_mini32.build.flash_size=4MB
d1_mini32.build.boot=dio
d1_mini32.build.partitions=default
d1_mini32.build.defines=
d1_mini32.menu.FlashFreq.80=80MHz
d1_mini32.menu.FlashFreq.80.build.flash_freq=80m
d1_mini32.menu.FlashFreq.40=40MHz
d1_mini32.menu.FlashFreq.40.build.flash_freq=40m
d1_mini32.menu.PartitionScheme.default=Default
d1_mini32.menu.PartitionScheme.default.build.partitions=default
d1_mini32.menu.PartitionScheme.no_ota=No OTA (Large APP)
d1_mini32.menu.PartitionScheme.no_ota.build.partitions=no_ota
d1_mini32.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
d1_mini32.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
d1_mini32.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
d1_mini32.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
d1_mini32.menu.CPUFreq.240=240MHz (WiFi/BT)
d1_mini32.menu.CPUFreq.240.build.f_cpu=240000000L
d1_mini32.menu.CPUFreq.160=160MHz (WiFi/BT)
d1_mini32.menu.CPUFreq.160.build.f_cpu=160000000L
d1_mini32.menu.CPUFreq.80=80MHz (WiFi/BT)
d1_mini32.menu.CPUFreq.80.build.f_cpu=80000000L
d1_mini32.menu.CPUFreq.40=40MHz (40MHz XTAL)
d1_mini32.menu.CPUFreq.40.build.f_cpu=40000000L
d1_mini32.menu.CPUFreq.26=26MHz (26MHz XTAL)
d1_mini32.menu.CPUFreq.26.build.f_cpu=26000000L
d1_mini32.menu.CPUFreq.20=20MHz (40MHz XTAL)
d1_mini32.menu.CPUFreq.20.build.f_cpu=20000000L
d1_mini32.menu.CPUFreq.13=13MHz (26MHz XTAL)
d1_mini32.menu.CPUFreq.13.build.f_cpu=13000000L
d1_mini32.menu.CPUFreq.10=10MHz (40MHz XTAL)
d1_mini32.menu.CPUFreq.10.build.f_cpu=10000000L
d1_mini32.menu.UploadSpeed.921600=921600
d1_mini32.menu.UploadSpeed.921600.upload.speed=921600
d1_mini32.menu.UploadSpeed.115200=115200
d1_mini32.menu.UploadSpeed.115200.upload.speed=115200
d1_mini32.menu.UploadSpeed.256000.windows=256000
d1_mini32.menu.UploadSpeed.256000.upload.speed=256000
d1_mini32.menu.UploadSpeed.230400.windows.upload.speed=256000
d1_mini32.menu.UploadSpeed.230400=230400
d1_mini32.menu.UploadSpeed.230400.upload.speed=230400
d1_mini32.menu.UploadSpeed.460800.linux=460800
d1_mini32.menu.UploadSpeed.460800.macosx=460800
d1_mini32.menu.UploadSpeed.460800.upload.speed=460800
d1_mini32.menu.UploadSpeed.512000.windows=512000
d1_mini32.menu.UploadSpeed.512000.upload.speed=512000
##############################################################
gpy.name=Pycom GPy
gpy.upload.tool=esptool_py
gpy.upload.maximum_size=1310720
gpy.upload.maximum_data_size=327680
gpy.upload.wait_for_upload_port=true
gpy.serial.disableDTR=true
gpy.serial.disableRTS=true
gpy.build.mcu=esp32
gpy.build.core=esp32
gpy.build.variant=gpy
gpy.build.board=PYCOM_GPY
gpy.build.f_cpu=240000000L
gpy.build.flash_mode=dio
gpy.build.flash_size=8MB
gpy.build.boot=dio
gpy.build.partitions=default
gpy.menu.FlashFreq.80=80MHz
gpy.menu.FlashFreq.80.build.flash_freq=80m
gpy.menu.FlashFreq.40=40MHz
gpy.menu.FlashFreq.40.build.flash_freq=40m
gpy.menu.UploadSpeed.921600=921600
gpy.menu.UploadSpeed.921600.upload.speed=921600
gpy.menu.UploadSpeed.115200=115200
gpy.menu.UploadSpeed.115200.upload.speed=115200
gpy.menu.UploadSpeed.256000.windows=256000
gpy.menu.UploadSpeed.256000.upload.speed=256000
gpy.menu.UploadSpeed.230400.windows.upload.speed=256000
gpy.menu.UploadSpeed.230400=230400
gpy.menu.UploadSpeed.230400.upload.speed=230400
gpy.menu.UploadSpeed.460800.linux=460800
gpy.menu.UploadSpeed.460800.macosx=460800
gpy.menu.UploadSpeed.460800.upload.speed=460800
gpy.menu.UploadSpeed.512000.windows=512000
gpy.menu.UploadSpeed.512000.upload.speed=512000
gpy.menu.DebugLevel.none=None
gpy.menu.DebugLevel.none.build.code_debug=0
gpy.menu.DebugLevel.error=Error
gpy.menu.DebugLevel.error.build.code_debug=1
gpy.menu.DebugLevel.warn=Warn
gpy.menu.DebugLevel.warn.build.code_debug=2
gpy.menu.DebugLevel.info=Info
gpy.menu.DebugLevel.info.build.code_debug=3
gpy.menu.DebugLevel.debug=Debug
gpy.menu.DebugLevel.debug.build.code_debug=4
gpy.menu.DebugLevel.verbose=Verbose
gpy.menu.DebugLevel.verbose.build.code_debug=5
##############################################################

View File

@ -68,12 +68,6 @@
#define __STRINGIFY(a) #a
#endif
// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#endif
#define abs(x) ((x)>0?(x):-(x))
#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)
@ -160,6 +154,7 @@ void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
#include "HardwareSerial.h"
#include "Esp.h"
using std::abs;
using std::isinf;
using std::isnan;
using std::max;

View File

@ -97,8 +97,8 @@ public:
float parseFloat(); // float version of parseInt
size_t readBytes(char *buffer, size_t length); // read chars from stream into buffer
size_t readBytes(uint8_t *buffer, size_t length)
virtual size_t readBytes(char *buffer, size_t length); // read chars from stream into buffer
virtual size_t readBytes(uint8_t *buffer, size_t length)
{
return readBytes((char *) buffer, length);
}
@ -114,7 +114,7 @@ public:
// returns the number of characters placed in the buffer (0 means no valid data found)
// Arduino String functions to be added here
String readString();
virtual String readString();
String readStringUntil(char terminator);
protected:

View File

@ -2,6 +2,7 @@
StreamString.cpp
Copyright (c) 2015 Markus Sattler. All rights reserved.
This file is part of the esp8266 core for Arduino environment.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -22,31 +23,28 @@
#include <Arduino.h>
#include "StreamString.h"
size_t StreamString::write(const uint8_t *data, size_t size)
{
size_t StreamString::write(const uint8_t *data, size_t size) {
if(size && data) {
if(reserve(length() + size + 1)) {
memcpy((void *) (buffer + len), (const void *) data, size);
len += size;
*(buffer + len) = 0x00; // add null for string end
const unsigned int newlen = length() + size;
if(reserve(newlen + 1)) {
memcpy((void *) (wbuffer() + len()), (const void *) data, size);
setLen(newlen);
*(wbuffer() + newlen) = 0x00; // add null for string end
return size;
}
}
return 0;
}
size_t StreamString::write(uint8_t data)
{
size_t StreamString::write(uint8_t data) {
return concat((char) data);
}
int StreamString::available()
{
int StreamString::available() {
return length();
}
int StreamString::read()
{
int StreamString::read() {
if(length()) {
char c = charAt(0);
remove(0, 1);
@ -56,8 +54,7 @@ int StreamString::read()
return -1;
}
int StreamString::peek()
{
int StreamString::peek() {
if(length()) {
char c = charAt(0);
return c;
@ -65,7 +62,6 @@ int StreamString::peek()
return -1;
}
void StreamString::flush()
{
void StreamString::flush() {
}

File diff suppressed because it is too large Load Diff

View File

@ -38,292 +38,288 @@ class __FlashStringHelper;
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
// The string class
class String
{
// use a function pointer to allow for "if (s)" without the
// complications of an operator bool(). for more information, see:
// http://www.artima.com/cppsource/safebool.html
typedef void (String::*StringIfHelperType)() const;
void StringIfHelper() const
{
}
public:
// constructors
// creates a copy of the initial value.
// if the initial value is null or invalid, or if memory allocation
// fails, the string will be marked as invalid (i.e. "if (s)" will
// be false).
String(const char *cstr = "");
String(const String &str);
String(const __FlashStringHelper *str) : String(reinterpret_cast<const char *>(str)) {};
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String(String &&rval);
String(StringSumHelper &&rval);
#endif
explicit String(char c);
explicit String(unsigned char, unsigned char base = 10);
explicit String(int, unsigned char base = 10);
explicit String(unsigned int, unsigned char base = 10);
explicit String(long, unsigned char base = 10);
explicit String(unsigned long, unsigned char base = 10);
explicit String(float, unsigned char decimalPlaces = 2);
explicit String(double, unsigned char decimalPlaces = 2);
~String(void);
// memory management
// return true on success, false on failure (in which case, the string
// is left unchanged). reserve(0), if successful, will validate an
// invalid string (i.e., "if (s)" will be true afterwards)
unsigned char reserve(unsigned int size);
inline unsigned int length(void) const
{
if(buffer) {
return len;
} else {
return 0;
class String {
// use a function pointer to allow for "if (s)" without the
// complications of an operator bool(). for more information, see:
// http://www.artima.com/cppsource/safebool.html
typedef void (String::*StringIfHelperType)() const;
void StringIfHelper() const {
}
}
// creates a copy of the assigned value. if the value is null or
// invalid, or if the memory allocation fails, the string will be
// marked as invalid ("if (s)" will be false).
String & operator =(const String &rhs);
String & operator =(const char *cstr);
String & operator = (const __FlashStringHelper *str);
public:
// constructors
// creates a copy of the initial value.
// if the initial value is null or invalid, or if memory allocation
// fails, the string will be marked as invalid (i.e. "if (s)" will
// be false).
String(const char *cstr = "");
String(const String &str);
String(const __FlashStringHelper *str);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String & operator =(String &&rval);
String & operator =(StringSumHelper &&rval);
String(String &&rval);
String(StringSumHelper &&rval);
#endif
explicit String(char c);
explicit String(unsigned char, unsigned char base = 10);
explicit String(int, unsigned char base = 10);
explicit String(unsigned int, unsigned char base = 10);
explicit String(long, unsigned char base = 10);
explicit String(unsigned long, unsigned char base = 10);
explicit String(float, unsigned char decimalPlaces = 2);
explicit String(double, unsigned char decimalPlaces = 2);
~String(void);
// memory management
// return true on success, false on failure (in which case, the string
// is left unchanged). reserve(0), if successful, will validate an
// invalid string (i.e., "if (s)" will be true afterwards)
unsigned char reserve(unsigned int size);
inline unsigned int length(void) const {
if(buffer()) {
return len();
} else {
return 0;
}
}
// creates a copy of the assigned value. if the value is null or
// invalid, or if the memory allocation fails, the string will be
// marked as invalid ("if (s)" will be false).
String & operator =(const String &rhs);
String & operator =(const char *cstr);
String & operator = (const __FlashStringHelper *str);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String & operator =(String &&rval);
String & operator =(StringSumHelper &&rval);
#endif
// concatenate (works w/ built-in types)
// concatenate (works w/ built-in types)
// returns true on success, false on failure (in which case, the string
// is left unchanged). if the argument is null or invalid, the
// concatenation is considered unsucessful.
unsigned char concat(const String &str);
unsigned char concat(const char *cstr);
unsigned char concat(char c);
unsigned char concat(unsigned char c);
unsigned char concat(int num);
unsigned char concat(unsigned int num);
unsigned char concat(long num);
unsigned char concat(unsigned long num);
unsigned char concat(float num);
unsigned char concat(double num);
unsigned char concat(const __FlashStringHelper * str);
// returns true on success, false on failure (in which case, the string
// is left unchanged). if the argument is null or invalid, the
// concatenation is considered unsucessful.
unsigned char concat(const String &str);
unsigned char concat(const char *cstr);
unsigned char concat(char c);
unsigned char concat(unsigned char c);
unsigned char concat(int num);
unsigned char concat(unsigned int num);
unsigned char concat(long num);
unsigned char concat(unsigned long num);
unsigned char concat(float num);
unsigned char concat(double num);
unsigned char concat(const __FlashStringHelper * str);
// if there's not enough memory for the concatenated value, the string
// will be left unchanged (but this isn't signalled in any way)
String & operator +=(const String &rhs)
{
concat(rhs);
return (*this);
}
String & operator +=(const char *cstr)
{
concat(cstr);
return (*this);
}
String & operator +=(char c)
{
concat(c);
return (*this);
}
String & operator +=(unsigned char num)
{
concat(num);
return (*this);
}
String & operator +=(int num)
{
concat(num);
return (*this);
}
String & operator +=(unsigned int num)
{
concat(num);
return (*this);
}
String & operator +=(long num)
{
concat(num);
return (*this);
}
String & operator +=(unsigned long num)
{
concat(num);
return (*this);
}
String & operator +=(float num)
{
concat(num);
return (*this);
}
String & operator +=(double num)
{
concat(num);
return (*this);
}
String & operator += (const __FlashStringHelper *str)
{
concat(str);
return (*this);
}
// if there's not enough memory for the concatenated value, the string
// will be left unchanged (but this isn't signalled in any way)
String & operator +=(const String &rhs) {
concat(rhs);
return (*this);
}
String & operator +=(const char *cstr) {
concat(cstr);
return (*this);
}
String & operator +=(char c) {
concat(c);
return (*this);
}
String & operator +=(unsigned char num) {
concat(num);
return (*this);
}
String & operator +=(int num) {
concat(num);
return (*this);
}
String & operator +=(unsigned int num) {
concat(num);
return (*this);
}
String & operator +=(long num) {
concat(num);
return (*this);
}
String & operator +=(unsigned long num) {
concat(num);
return (*this);
}
String & operator +=(float num) {
concat(num);
return (*this);
}
String & operator +=(double num) {
concat(num);
return (*this);
}
String & operator += (const __FlashStringHelper *str){
concat(str);
return (*this);
}
friend StringSumHelper & operator +(const StringSumHelper &lhs, const String &rhs);
friend StringSumHelper & operator +(const StringSumHelper &lhs, const char *cstr);
friend StringSumHelper & operator +(const StringSumHelper &lhs, char c);
friend StringSumHelper & operator +(const StringSumHelper &lhs, unsigned char num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, int num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, unsigned int num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, long num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, unsigned long num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, float num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, double num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, const __FlashStringHelper *rhs);
friend StringSumHelper & operator +(const StringSumHelper &lhs, const String &rhs);
friend StringSumHelper & operator +(const StringSumHelper &lhs, const char *cstr);
friend StringSumHelper & operator +(const StringSumHelper &lhs, char c);
friend StringSumHelper & operator +(const StringSumHelper &lhs, unsigned char num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, int num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, unsigned int num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, long num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, unsigned long num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, float num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, double num);
friend StringSumHelper & operator +(const StringSumHelper &lhs, const __FlashStringHelper *rhs);
// comparison (only works w/ Strings and "strings")
operator StringIfHelperType() const
{
return buffer ? &String::StringIfHelper : 0;
}
int compareTo(const String &s) const;
unsigned char equals(const String &s) const;
unsigned char equals(const char *cstr) const;
unsigned char operator ==(const String &rhs) const
{
return equals(rhs);
}
unsigned char operator ==(const char *cstr) const
{
return equals(cstr);
}
unsigned char operator !=(const String &rhs) const
{
return !equals(rhs);
}
unsigned char operator !=(const char *cstr) const
{
return !equals(cstr);
}
unsigned char operator <(const String &rhs) const;
unsigned char operator >(const String &rhs) const;
unsigned char operator <=(const String &rhs) const;
unsigned char operator >=(const String &rhs) const;
unsigned char equalsIgnoreCase(const String &s) const;
unsigned char equalsConstantTime(const String &s) const;
unsigned char startsWith(const String &prefix) const;
unsigned char startsWith(const String &prefix, unsigned int offset) const;
unsigned char endsWith(const String &suffix) const;
// comparison (only works w/ Strings and "strings")
operator StringIfHelperType() const {
return buffer() ? &String::StringIfHelper : 0;
}
int compareTo(const String &s) const;
unsigned char equals(const String &s) const;
unsigned char equals(const char *cstr) const;
unsigned char operator ==(const String &rhs) const {
return equals(rhs);
}
unsigned char operator ==(const char *cstr) const {
return equals(cstr);
}
unsigned char operator !=(const String &rhs) const {
return !equals(rhs);
}
unsigned char operator !=(const char *cstr) const {
return !equals(cstr);
}
unsigned char operator <(const String &rhs) const;
unsigned char operator >(const String &rhs) const;
unsigned char operator <=(const String &rhs) const;
unsigned char operator >=(const String &rhs) const;
unsigned char equalsIgnoreCase(const String &s) const;
unsigned char equalsConstantTime(const String &s) const;
unsigned char startsWith(const String &prefix) const;
unsigned char startsWith(const String &prefix, unsigned int offset) const;
unsigned char endsWith(const String &suffix) const;
// character acccess
char charAt(unsigned int index) const;
void setCharAt(unsigned int index, char c);
char operator [](unsigned int index) const;
char& operator [](unsigned int index);
void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index = 0) const;
void toCharArray(char *buf, unsigned int bufsize, unsigned int index = 0) const
{
getBytes((unsigned char *) buf, bufsize, index);
}
const char * c_str() const
{
return buffer;
}
// character acccess
char charAt(unsigned int index) const;
void setCharAt(unsigned int index, char c);
char operator [](unsigned int index) const;
char& operator [](unsigned int index);
void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index = 0) const;
void toCharArray(char *buf, unsigned int bufsize, unsigned int index = 0) const {
getBytes((unsigned char *) buf, bufsize, index);
}
const char* c_str() const { return buffer(); }
char* begin() { return wbuffer(); }
char* end() { return wbuffer() + length(); }
const char* begin() const { return c_str(); }
const char* end() const { return c_str() + length(); }
// search
int indexOf(char ch) const;
int indexOf(char ch, unsigned int fromIndex) const;
int indexOf(const String &str) const;
int indexOf(const String &str, unsigned int fromIndex) const;
int lastIndexOf(char ch) const;
int lastIndexOf(char ch, unsigned int fromIndex) const;
int lastIndexOf(const String &str) const;
int lastIndexOf(const String &str, unsigned int fromIndex) const;
String substring(unsigned int beginIndex) const
{
return substring(beginIndex, len);
}
;
String substring(unsigned int beginIndex, unsigned int endIndex) const;
// search
int indexOf(char ch) const;
int indexOf(char ch, unsigned int fromIndex) const;
int indexOf(const String &str) const;
int indexOf(const String &str, unsigned int fromIndex) const;
int lastIndexOf(char ch) const;
int lastIndexOf(char ch, unsigned int fromIndex) const;
int lastIndexOf(const String &str) const;
int lastIndexOf(const String &str, unsigned int fromIndex) const;
String substring(unsigned int beginIndex) const {
return substring(beginIndex, len());
}
;
String substring(unsigned int beginIndex, unsigned int endIndex) const;
// modification
void replace(char find, char replace);
void replace(const String& find, const String& replace);
void remove(unsigned int index);
void remove(unsigned int index, unsigned int count);
void toLowerCase(void);
void toUpperCase(void);
void trim(void);
// modification
void replace(char find, char replace);
void replace(const String& find, const String& replace);
void remove(unsigned int index);
void remove(unsigned int index, unsigned int count);
void toLowerCase(void);
void toUpperCase(void);
void trim(void);
// parsing/conversion
long toInt(void) const;
float toFloat(void) const;
double toDouble(void) const;
// parsing/conversion
long toInt(void) const;
float toFloat(void) const;
double toDouble(void) const;
protected:
char *buffer; // the actual char array
unsigned int capacity; // the array length minus one (for the '\0')
unsigned int len; // the String length (not counting the '\0')
protected:
void init(void);
void invalidate(void);
unsigned char changeBuffer(unsigned int maxStrLen);
unsigned char concat(const char *cstr, unsigned int length);
protected:
// Contains the string info when we're not in SSO mode
struct _ptr {
char * buff;
uint16_t cap;
uint16_t len;
};
// copy and move
String & copy(const char *cstr, unsigned int length);
String & copy(const __FlashStringHelper *pstr, unsigned int length);
// SSO is handled by checking the last byte of sso_buff.
// When not in SSO mode, that byte is set to 0xff, while when in SSO mode it is always 0x00 (so it can serve as the string terminator as well as a flag)
// This allows strings up up to 12 (11 + \0 termination) without any extra space.
enum { SSOSIZE = sizeof(struct _ptr) + 4 }; // Characters to allocate space for SSO, must be 12 or more
enum { CAPACITY_MAX = 65535 }; // If size of capacity changed, be sure to update this enum
union {
struct _ptr ptr;
char sso_buf[SSOSIZE];
};
// Accessor functions
inline bool sso() const { return sso_buf[SSOSIZE - 1] == 0; }
inline unsigned int len() const { return sso() ? strlen(sso_buf) : ptr.len; }
inline unsigned int capacity() const { return sso() ? SSOSIZE - 1 : ptr.cap; }
inline void setSSO(bool sso) { sso_buf[SSOSIZE - 1] = sso ? 0x00 : 0xff; }
inline void setLen(int len) { if (!sso()) ptr.len = len; }
inline void setCapacity(int cap) { if (!sso()) ptr.cap = cap; }
inline void setBuffer(char *buff) { if (!sso()) ptr.buff = buff; }
// Buffer accessor functions
inline const char *buffer() const { return (const char *)(sso() ? sso_buf : ptr.buff); }
inline char *wbuffer() const { return sso() ? const_cast<char *>(sso_buf) : ptr.buff; } // Writable version of buffer
protected:
void init(void);
void invalidate(void);
unsigned char changeBuffer(unsigned int maxStrLen);
unsigned char concat(const char *cstr, unsigned int length);
// copy and move
String & copy(const char *cstr, unsigned int length);
String & copy(const __FlashStringHelper *pstr, unsigned int length);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void move(String &rhs);
void move(String &rhs);
#endif
};
class StringSumHelper: public String
{
public:
StringSumHelper(const String &s) :
String(s)
{
}
StringSumHelper(const char *p) :
String(p)
{
}
StringSumHelper(char c) :
String(c)
{
}
StringSumHelper(unsigned char num) :
String(num)
{
}
StringSumHelper(int num) :
String(num)
{
}
StringSumHelper(unsigned int num) :
String(num)
{
}
StringSumHelper(long num) :
String(num)
{
}
StringSumHelper(unsigned long num) :
String(num)
{
}
StringSumHelper(float num) :
String(num)
{
}
StringSumHelper(double num) :
String(num)
{
}
class StringSumHelper: public String {
public:
StringSumHelper(const String &s) :
String(s) {
}
StringSumHelper(const char *p) :
String(p) {
}
StringSumHelper(char c) :
String(c) {
}
StringSumHelper(unsigned char num) :
String(num) {
}
StringSumHelper(int num) :
String(num) {
}
StringSumHelper(unsigned int num) :
String(num) {
}
StringSumHelper(long num) :
String(num) {
}
StringSumHelper(unsigned long num) :
String(num) {
}
StringSumHelper(float num) :
String(num) {
}
StringSumHelper(double num) :
String(num) {
}
};
extern const String emptyString;
#endif // __cplusplus
#endif // String_class_h

View File

@ -665,7 +665,6 @@ static void IRAM_ATTR _rmt_isr(void* arg)
}
if (intr_val & _INT_ERROR(ch)) {
digitalWrite(2, 1);
// clear the flag
RMT.int_clr.val = _INT_ERROR(ch);
RMT.int_ena.val &= ~_INT_ERROR(ch);

View File

@ -23,5 +23,7 @@ Installation instructions for Mac OS
- Try `python3` instead of `python` if you get the error: `IOError: [Errno socket error] [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)` when running `python get.py`
- If you get the following error when running `python get.py` urllib.error.URLError: <urlopen error SSL: CERTIFICATE_VERIFY_FAILED, go to Macintosh HD > Applications > Python3.6 folder (or any other python version), and run the following scripts: Install Certificates.command and Update Shell Profile.command
- Restart Arduino IDE

View File

@ -253,6 +253,27 @@ void BLEAdvertising::stop() {
log_v("<< stop");
} // stop
/**
* @brief Set BLE address.
* @param [in] Bluetooth address.
* @param [in] Bluetooth address type.
* Set BLE address.
*/
void BLEAdvertising::setDeviceAddress(esp_bd_addr_t addr, esp_ble_addr_type_t type)
{
log_v(">> setPrivateAddress")
m_advParams.own_addr_type = type;
esp_err_t errRc = esp_ble_gap_set_rand_addr((uint8_t*)addr);
if (errRc != ESP_OK)
{
log_e("esp_ble_gap_set_rand_addr: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
return;
}
log_v("<< setPrivateAddress")
} // setPrivateAddress
/**
* @brief Add data to the payload to be advertised.
* @param [in] data The data to be added to the payload.

View File

@ -58,6 +58,7 @@ public:
void setScanFilter(bool scanRequertWhitelistOnly, bool connectWhitelistOnly);
void setScanResponseData(BLEAdvertisementData& advertisementData);
void setPrivateAddress(esp_ble_addr_type_t type = BLE_ADDR_TYPE_RANDOM);
void setDeviceAddress(esp_bd_addr_t addr, esp_ble_addr_type_t type = BLE_ADDR_TYPE_RANDOM);
void handleGAPEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* param);
void setMinPreferred(uint16_t);

View File

@ -61,15 +61,13 @@ uint32_t FreeRTOS::getTimeSinceStart() {
*/
uint32_t FreeRTOS::Semaphore::wait(std::string owner) {
log_v(">> wait: Semaphore waiting: %s for %s", toString().c_str(), owner.c_str());
if (m_usePthreads) {
pthread_mutex_lock(&m_pthread_mutex);
} else {
xSemaphoreTake(m_semaphore, portMAX_DELAY);
}
m_owner = owner;
if (m_usePthreads) {
pthread_mutex_unlock(&m_pthread_mutex);
} else {
@ -77,7 +75,6 @@ uint32_t FreeRTOS::Semaphore::wait(std::string owner) {
}
log_v("<< wait: Semaphore released: %s", toString().c_str());
m_owner = std::string("<N/A>");
return m_value;
} // wait
@ -87,7 +84,8 @@ FreeRTOS::Semaphore::Semaphore(std::string name) {
if (m_usePthreads) {
pthread_mutex_init(&m_pthread_mutex, nullptr);
} else {
m_semaphore = xSemaphoreCreateMutex();
m_semaphore = xSemaphoreCreateBinary();
xSemaphoreGive(m_semaphore);
}
m_name = name;
@ -111,6 +109,8 @@ FreeRTOS::Semaphore::~Semaphore() {
*/
void FreeRTOS::Semaphore::give() {
log_v("Semaphore giving: %s", toString().c_str());
m_owner = std::string("<N/A>");
if (m_usePthreads) {
pthread_mutex_unlock(&m_pthread_mutex);
} else {
@ -120,7 +120,6 @@ void FreeRTOS::Semaphore::give() {
// FreeRTOS::sleep(10);
// #endif
m_owner = std::string("<N/A>");
} // Semaphore::give

View File

@ -0,0 +1,4 @@
## EEPROM
EEPROM is deprecated. For new applications on ESP32, use Preferences. EEPROM is provided for backwards compatibility with existing Arduino applications.
EEPROM is implemented using a single blob within NVS, so it is a container within a container. As such, it is not going to be a high performance storage method. Preferences will directly use nvs, and store each entry as a single object therein.

View File

@ -26,8 +26,8 @@
#include "EEPROM.h"
// Instantiate eeprom objects with parameter/argument names and size same as in the partition table
EEPROMClass NAMES("eeprom0", 0x1000);
EEPROMClass HEIGHT("eeprom1", 0x500);
EEPROMClass NAMES("eeprom0", 0x500);
EEPROMClass HEIGHT("eeprom1", 0x200);
EEPROMClass AGE("eeprom2", 0x100);
void setup() {

View File

@ -13,78 +13,127 @@ void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("\nTesting EEPROM Library\n");
if (!EEPROM.begin(EEPROM.length())) {
if (!EEPROM.begin(1000)) {
Serial.println("Failed to initialise EEPROM");
Serial.println("Restarting...");
delay(1000);
ESP.restart();
}
int address = 0; // Same address is used through the example
int address = 0;
EEPROM.writeByte(address, -128); // -2^7
Serial.println(EEPROM.readByte(address));
address += sizeof(byte);
EEPROM.writeChar(address, 'A'); // Same as writyByte and readByte
Serial.println(char(EEPROM.readChar(address)));
address += sizeof(char);
EEPROM.writeUChar(address, 255); // 2^8 - 1
Serial.println(EEPROM.readUChar(address));
address += sizeof(unsigned char);
EEPROM.writeShort(address, -32768); // -2^15
Serial.println(EEPROM.readShort(address));
address += sizeof(short);
EEPROM.writeUShort(address, 65535); // 2^16 - 1
Serial.println(EEPROM.readUShort(address));
address += sizeof(unsigned short);
EEPROM.writeInt(address, -2147483648); // -2^31
Serial.println(EEPROM.readInt(address));
address += sizeof(int);
EEPROM.writeUInt(address, 4294967295); // 2^32 - 1
Serial.println(EEPROM.readUInt(address));
address += sizeof(unsigned int);
EEPROM.writeLong(address, -2147483648); // Same as writeInt and readInt
Serial.println(EEPROM.readLong(address));
address += sizeof(long);
EEPROM.writeULong(address, 4294967295); // Same as writeUInt and readUInt
Serial.println(EEPROM.readULong(address));
address += sizeof(unsigned long);
int64_t value = -9223372036854775808; // -2^63
EEPROM.writeLong64(address, value);
value = 0; // Clear value
value = EEPROM.readLong64(value);
Serial.printf("0x%08X", (uint32_t)(value >> 32)); // Print High 4 bytes in HEX
Serial.printf("%08X\n", (uint32_t)value); // Print Low 4 bytes in HEX
address += sizeof(int64_t);
uint64_t Value = 18446744073709551615; // 2^64 - 1
EEPROM.writeULong64(address, Value);
address += sizeof(uint64_t);
EEPROM.writeFloat(address, 1234.1234);
address += sizeof(float);
EEPROM.writeDouble(address, 123456789.123456789);
address += sizeof(double);
EEPROM.writeBool(address, true);
address += sizeof(bool);
String sentence = "I love ESP32.";
EEPROM.writeString(address, sentence);
address += sentence.length() + 1;
char gratitude[21] = "Thank You Espressif!";
EEPROM.writeString(address, gratitude);
address += 21;
// See also the general purpose writeBytes() and readBytes() for BLOB in EEPROM library
EEPROM.commit();
address = 0;
Serial.println(EEPROM.readByte(address));
address += sizeof(byte);
Serial.println((char)EEPROM.readChar(address));
address += sizeof(char);
Serial.println(EEPROM.readUChar(address));
address += sizeof(unsigned char);
Serial.println(EEPROM.readShort(address));
address += sizeof(short);
Serial.println(EEPROM.readUShort(address));
address += sizeof(unsigned short);
Serial.println(EEPROM.readInt(address));
address += sizeof(int);
Serial.println(EEPROM.readUInt(address));
address += sizeof(unsigned int);
Serial.println(EEPROM.readLong(address));
address += sizeof(long);
Serial.println(EEPROM.readULong(address));
address += sizeof(unsigned long);
value = 0;
value = EEPROM.readLong64(value);
Serial.printf("0x%08X", (uint32_t)(value >> 32)); // Print High 4 bytes in HEX
Serial.printf("%08X\n", (uint32_t)value); // Print Low 4 bytes in HEX
address += sizeof(int64_t);
Value = 0; // Clear Value
Value = EEPROM.readULong64(Value);
Serial.printf("0x%08X", (uint32_t)(Value >> 32)); // Print High 4 bytes in HEX
Serial.printf("%08X\n", (uint32_t)Value); // Print Low 4 bytes in HEX
address += sizeof(uint64_t);
EEPROM.writeFloat(address, 1234.1234);
Serial.println(EEPROM.readFloat(address), 4);
address += sizeof(float);
EEPROM.writeDouble(address, 123456789.123456789);
Serial.println(EEPROM.readDouble(address), 8);
address += sizeof(double);
EEPROM.writeBool(address, true);
Serial.println(EEPROM.readBool(address));
address += sizeof(bool);
String sentence = "I love ESP32.";
EEPROM.writeString(address, sentence);
Serial.println(EEPROM.readString(address));
address += sentence.length() + 1;
char gratitude[] = "Thank You Espressif!";
EEPROM.writeString(address, gratitude);
Serial.println(EEPROM.readString(address));
// See also the general purpose writeBytes() and readBytes() for BLOB in EEPROM library
// To avoid data overwrite, next address should be chosen/offset by using "address =+ sizeof(previousData)"
address += 21;
}
void loop() {
// put your main code here, to run repeatedly:
}
}

View File

@ -1,10 +1,9 @@
/*
EEPROM.h -ported by Paolo Becchi to Esp32 from esp8266 EEPROM
-Modified by Elochukwu Ifediora <ifedioraelochukwuc@gmail.com>
-Converted to nvs lbernstone@gmail.com
Uses a one sector flash partition defined in partition table
OR
Multiple sector flash partitions defined by the name column in the partition table
Uses a nvs byte array to emulate EEPROM
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
This file is part of the esp8266 core for Arduino environment.
@ -25,72 +24,120 @@
*/
#include "EEPROM.h"
#include <nvs.h>
#include <esp_log.h>
EEPROMClass::EEPROMClass(uint32_t sector)
: _sector(sector)
EEPROMClass::EEPROMClass(void)
: _handle(NULL)
, _data(0)
, _size(0)
, _dirty(false)
, _name("eeprom")
, _user_defined_size(0)
{
}
EEPROMClass::EEPROMClass(uint32_t sector)
// Only for compatiility, no sectors in nvs!
: _handle(NULL)
, _data(0)
, _size(0)
, _dirty(false)
, _mypart(NULL)
, _name("eeprom")
, _user_defined_size(0)
{
}
EEPROMClass::EEPROMClass(const char* name, uint32_t user_defined_size)
: _sector(0)
: _handle(NULL)
, _data(0)
, _size(0)
, _dirty(false)
, _mypart(NULL)
, _name(name)
, _user_defined_size(user_defined_size)
{
}
EEPROMClass::EEPROMClass(void)
: _sector(0)// (((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE))
, _data(0)
, _size(0)
, _dirty(false)
, _mypart(NULL)
, _name("eeprom")
, _user_defined_size(0)
{
}
EEPROMClass::~EEPROMClass() {
// end();
}
bool EEPROMClass::begin(size_t size) {
if (size <= 0) {
return false;
if (!size) {
return false;
}
if (size > SPI_FLASH_SEC_SIZE) {
size = SPI_FLASH_SEC_SIZE;
esp_err_t res = nvs_open(_name, NVS_READWRITE, &_handle);
if (res != ESP_OK) {
log_e("Unable to open NVS namespace: %d", res);
return false;
}
// _mypart = esp_partition_find_first(ESP_PARTITION_TYPE_DATA,ESP_PARTITION_SUBTYPE_ANY, EEPROM_FLASH_PARTITION_NAME);
_mypart = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, _name);
if (_mypart == NULL) {
return false;
size_t key_size = 0;
res = nvs_get_blob(_handle, _name, NULL, &key_size);
if(res != ESP_OK && res != ESP_ERR_NVS_NOT_FOUND) {
log_e("Unable to read NVS key: %d", res);
return false;
}
if (size < key_size) { // truncate
log_w("truncating EEPROM from %d to %d", key_size, size);
uint8_t* key_data = (uint8_t*) malloc(key_size);
if(!key_data) {
log_e("Not enough memory to truncate EEPROM!");
return false;
}
nvs_get_blob(_handle, _name, key_data, &key_size);
nvs_set_blob(_handle, _name, key_data, size);
nvs_commit(_handle);
free(key_data);
}
else if (size > key_size) { // expand or new
size_t expand_size = size - key_size;
uint8_t* expand_key = (uint8_t*) malloc(expand_size);
if(!expand_key) {
log_e("Not enough memory to expand EEPROM!");
return false;
}
// check for adequate free space
if(nvs_set_blob(_handle, "expand", expand_key, expand_size)) {
log_e("Not enough space to expand EEPROM from %d to %d", key_size, size);
free(expand_key);
return false;
}
free(expand_key);
nvs_erase_key(_handle, "expand");
uint8_t* key_data = (uint8_t*) malloc(size);
if(!key_data) {
log_e("Not enough memory to expand EEPROM!");
return false;
}
memset(key_data, 0, size);
if(key_size) {
log_i("Expanding EEPROM from %d to %d", key_size, size);
// hold data while key is deleted
nvs_get_blob(_handle, _name, key_data, &key_size);
nvs_erase_key(_handle, _name);
} else {
log_i("New EEPROM of %d bytes", size);
}
nvs_commit(_handle);
nvs_set_blob(_handle, _name, key_data, size);
free(key_data);
nvs_commit(_handle);
}
size = (size + 3) & (~3);
if (_data) {
delete[] _data;
}
_data = new uint8_t[size];
_size = size;
bool ret = false;
if (esp_partition_read (_mypart, 0, (void *) _data, _size) == ESP_OK) {
ret = true;
_data = (uint8_t*) malloc(size);
if(!_data) {
log_e("Not enough memory for %d bytes in EEPROM");
return false;
}
return ret;
_size = size;
nvs_get_blob(_handle, _name, _data, &_size);
return true;
}
void EEPROMClass::end() {
@ -134,29 +181,21 @@ void EEPROMClass::write(int address, uint8_t value) {
bool EEPROMClass::commit() {
bool ret = false;
if (!_size)
return false;
if (!_dirty)
return true;
if (!_data)
return false;
if (esp_partition_erase_range(_mypart, 0, SPI_FLASH_SEC_SIZE) != ESP_OK)
{
log_e( "partition erase err.");
if (!_size) {
return false;
}
else
{
if (esp_partition_write(_mypart, 0, (void *)_data, _size) == ESP_ERR_INVALID_SIZE)
{
log_e( "error in Write");
}
else
{
if (!_data) {
return false;
}
if (!_dirty) {
return true;
}
if (ESP_OK != nvs_set_blob(_handle, _name, _data, _size)) {
log_e( "error in write");
} else {
_dirty = false;
ret = true;
}
}
return ret;

View File

@ -1,10 +1,9 @@
/*
EEPROM.h -ported by Paolo Becchi to Esp32 from esp8266 EEPROM
-Modified by Elochukwu Ifediora <ifedioraelochukwuc@gmail.com>
-Converted to nvs lbernstone@gmail.com
Uses a one sector flash partition defined in partition table
OR
Multiple sector flash partitions defined by the name column in the partition table
Uses a nvs byte array to emulate EEPROM
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
This file is part of the esp8266 core for Arduino environment.
@ -30,19 +29,9 @@
#define EEPROM_FLASH_PARTITION_NAME "eeprom"
#endif
#include <Arduino.h>
extern "C" {
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <esp_partition.h>
}
typedef uint32_t nvs_handle;
//
// need to define AT LEAST a flash partition for EEPROM with above name
//
// eeprom , data , 0x99, start address, 0x1000
//
class EEPROMClass {
public:
EEPROMClass(uint32_t sector);
@ -117,11 +106,10 @@ class EEPROMClass {
template <class T> T writeAll (int address, const T &);
protected:
uint32_t _sector;
nvs_handle _handle;
uint8_t* _data;
size_t _size;
bool _dirty;
const esp_partition_t * _mypart;
const char* _name;
uint32_t _user_defined_size;
};

View File

@ -20,7 +20,6 @@
#include "fb_gfx.h"
#include "fd_forward.h"
#include "dl_lib.h"
#include "fr_forward.h"
#define ENROLL_CONFIRM_TIMES 5

View File

@ -39,7 +39,8 @@ static const char Content_Length[] = "Content-Length";
WebServer::WebServer(IPAddress addr, int port)
: _server(addr, port)
: _corsEnabled(false)
, _server(addr, port)
, _currentMethod(HTTP_ANY)
, _currentVersion(0)
, _currentStatus(HC_NONE)
@ -59,7 +60,8 @@ WebServer::WebServer(IPAddress addr, int port)
}
WebServer::WebServer(int port)
: _server(port)
: _corsEnabled(false)
, _server(port)
, _currentMethod(HTTP_ANY)
, _currentVersion(0)
, _currentStatus(HC_NONE)
@ -104,7 +106,7 @@ void WebServer::begin(uint16_t port) {
String WebServer::_extractParam(String& authReq,const String& param,const char delimit){
int _begin = authReq.indexOf(param);
if (_begin == -1)
if (_begin == -1)
return "";
return authReq.substring(_begin+param.length(),authReq.indexOf(delimit,_begin+param.length()));
}
@ -366,6 +368,14 @@ void WebServer::setContentLength(const size_t contentLength) {
_contentLength = contentLength;
}
void WebServer::enableCORS(boolean value) {
_corsEnabled = value;
}
void WebServer::enableCrossOrigin(boolean value) {
enableCORS(value);
}
void WebServer::_prepareHeader(String& response, int code, const char* content_type, size_t contentLength) {
response = String(F("HTTP/1.")) + String(_currentVersion) + ' ';
response += String(code);
@ -388,6 +398,9 @@ void WebServer::_prepareHeader(String& response, int code, const char* content_t
sendHeader(String(F("Accept-Ranges")),String(F("none")));
sendHeader(String(F("Transfer-Encoding")),String(F("chunked")));
}
if (_corsEnabled) {
sendHeader(String(FPSTR("Access-Control-Allow-Origin")), String("*"));
}
sendHeader(String(F("Connection")), String(F("close")));
response += _responseHeaders;
@ -494,7 +507,7 @@ void WebServer::_streamFileCore(const size_t fileSize, const String & fileName,
send(200, contentType, "");
}
String WebServer::pathArg(unsigned int i) {
String WebServer::pathArg(unsigned int i) {
if (_currentHandler != nullptr)
return _currentHandler->pathArg(i);
return "";

View File

@ -122,6 +122,9 @@ public:
void send_P(int code, PGM_P content_type, PGM_P content);
void send_P(int code, PGM_P content_type, PGM_P content, size_t contentLength);
void enableCORS(boolean value = true);
void enableCrossOrigin(boolean value = true);
void setContentLength(const size_t contentLength);
void sendHeader(const String& name, const String& value, bool first = false);
void sendContent(const String& content);
@ -130,12 +133,12 @@ public:
static String urlDecode(const String& text);
template<typename T>
template<typename T>
size_t streamFile(T &file, const String& contentType) {
_streamFileCore(file.size(), file.name(), contentType);
return _currentClient.write(file);
}
protected:
virtual size_t _currentClientWrite(const char* b, size_t l) { return _currentClient.write( b, l ); }
virtual size_t _currentClientWrite_P(PGM_P b, size_t l) { return _currentClient.write_P( b, l ); }
@ -151,7 +154,7 @@ protected:
int _uploadReadByte(WiFiClient& client);
void _prepareHeader(String& response, int code, const char* content_type, size_t contentLength);
bool _collectHeader(const char* headerName, const char* headerValue);
void _streamFileCore(const size_t fileSize, const String & fileName, const String & contentType);
String _getRandomHexString();
@ -163,6 +166,7 @@ protected:
String value;
};
boolean _corsEnabled;
WiFiServer _server;
WiFiClient _currentClient;

View File

@ -27,6 +27,9 @@
},
{
"name": "WEMOS LoLin32"
},
{
"name": "WEMOS D1 MINI ESP32"
}
],
"toolsDependencies": [

View File

@ -34,8 +34,8 @@ compiler.S.cmd=xtensa-esp32-elf-gcc
compiler.S.flags=-c -g3 -x assembler-with-cpp -MMD -mlongcalls
compiler.c.elf.cmd=xtensa-esp32-elf-gcc
compiler.c.elf.flags=-nostdlib "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -T esp32.rom.spiram_incompatible_fns.ld -u ld_include_panic_highint_hdl -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority -u __cxa_guard_dummy -u __cxx_fatal_exception
compiler.c.elf.libs=-lgcc -lopenssl -lbtdm_app -lfatfs -lwps -lcoexist -lwear_levelling -lesp_http_client -lprotobuf-c -lhal -lnewlib -ldriver -lbootloader_support -lpp -lfreemodbus -lmesh -lsmartconfig -ljsmn -lwpa -lethernet -lphy -lfrmn -lapp_trace -lfr_coefficients -lconsole -lulp -lwpa_supplicant -lfreertos -lbt -lmicro-ecc -lesp32-camera -lcxx -lxtensa-debug-module -ltcp_transport -lmdns -lvfs -lmtmn -lesp_ringbuf -lsoc -lcore -lfb_gfx -lsdmmc -llibsodium -lcoap -ltcpip_adapter -lprotocomm -lesp_event -limage_util -lc_nano -lesp-tls -lasio -lrtc -lspi_flash -lwpa2 -lwifi_provisioning -lesp32 -lface_recognition -lapp_update -lnghttp -lspiffs -lface_detection -lespnow -lnvs_flash -lesp_adc_cal -llog -ldl_lib -lsmartconfig_ack -lexpat -lfd_coefficients -lm -lmqtt -lc -lheap -lmbedtls -llwip -lnet80211 -lesp_http_server -lpthread -ljson -lesp_https_ota -lstdc++
compiler.c.elf.flags=-nostdlib "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -T esp32.rom.libgcc.ld -T esp32.rom.spiram_incompatible_fns.ld -u ld_include_panic_highint_hdl -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority -u __cxa_guard_dummy -u __cxx_fatal_exception
compiler.c.elf.libs=-lgcc -lopenssl -lbtdm_app -lfatfs -lwps -lcoexist -lwear_levelling -lesp_http_client -lprotobuf-c -lhal -lnewlib -ldriver -lbootloader_support -lpp -lfreemodbus -lmesh -lsmartconfig -ljsmn -lwpa -lethernet -lphy -lapp_trace -lconsole -lulp -lwpa_supplicant -lfreertos -lbt -lmicro-ecc -lesp32-camera -lcxx -lxtensa-debug-module -ltcp_transport -lmdns -lvfs -lesp_ringbuf -lsoc -lcore -lfb_gfx -lsdmmc -llibsodium -lcoap -ltcpip_adapter -lprotocomm -lesp_event -limage_util -lc_nano -lesp-tls -lasio -lrtc -lspi_flash -lwpa2 -lwifi_provisioning -lesp32 -lface_recognition -lapp_update -lnghttp -lspiffs -lface_detection -lespnow -lnvs_flash -lesp_adc_cal -llog -ldl_lib -lsmartconfig_ack -lexpat -lm -lfr -lmqtt -lc -lheap -lmbedtls -llwip -lnet80211 -lesp_http_server -lpthread -ljson -lesp_https_ota -lfd -lstdc++
compiler.as.cmd=xtensa-esp32-elf-as

View File

@ -3,5 +3,4 @@ nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x140000,
app1, app, ota_1, 0x150000,0x140000,
eeprom, data, 0x99, 0x290000,0x1000,
spiffs, data, spiffs, 0x291000,0x16F000,
spiffs, data, spiffs, 0x290000,0x170000,

1 # Name Type SubType Offset Size Flags
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x140000
5 app1 app ota_1 0x150000 0x140000
6 eeprom spiffs data 0x99 spiffs 0x290000 0x1000 0x170000
spiffs data spiffs 0x291000 0x16F000

View File

@ -3,5 +3,4 @@ nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x640000,
app1, app, ota_1, 0x650000,0x640000,
eeprom, data, 0x99, 0xc90000,0x1000,
spiffs, data, spiffs, 0xc91000,0x36F000,
spiffs, data, spiffs, 0xc90000,0x370000,

1 # Name Type SubType Offset Size Flags
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x640000
5 app1 app ota_1 0x650000 0x640000
6 eeprom spiffs data 0x99 spiffs 0xc90000 0x1000 0x370000
spiffs data spiffs 0xc91000 0x36F000

View File

@ -3,5 +3,4 @@ nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x330000,
app1, app, ota_1, 0x340000,0x330000,
eeprom, data, 0x99, 0x670000,0x1000,
spiffs, data, spiffs, 0x671000,0x18F000,
spiffs, data, spiffs, 0x670000,0x190000,

1 # Name Type SubType Offset Size Flags
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x330000
5 app1 app ota_1 0x340000 0x330000
6 eeprom spiffs data 0x99 spiffs 0x670000 0x1000 0x190000
spiffs data spiffs 0x671000 0x18F000

View File

@ -3,5 +3,4 @@ nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x140000,
app1, app, ota_1, 0x150000,0x140000,
eeprom, data, 0x99, 0x290000,0x1000,
ffat, data, fat, 0x291000,0x16F000,
ffat, data, fat, 0x291000,0x170000,

1 # Name Type SubType Offset Size Flags
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x140000
5 app1 app ota_1 0x150000 0x140000
6 eeprom ffat data 0x99 fat 0x290000 0x291000 0x1000 0x170000
ffat data fat 0x291000 0x16F000

View File

@ -3,6 +3,5 @@ nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x200000,
app1, app, ota_1, 0x210000,0x200000,
eeprom, data, 0x99, 0x410000,0x1000,
ffat, data, fat, 0x411000,0xBEE000,
ffat, data, fat, 0x410000,0xBEF000,
# to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage

1 # Name, Type, SubType, Offset, Size, Flags
3 otadata, data, ota, 0xe000, 0x2000,
4 app0, app, ota_0, 0x10000, 0x200000,
5 app1, app, ota_1, 0x210000,0x200000,
6 eeprom, data, 0x99, 0x410000,0x1000, ffat, data, fat, 0x410000,0xBEF000,
ffat, data, fat, 0x411000,0xBEE000,
7 # to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage

View File

@ -2,5 +2,4 @@
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x300000,
eeprom, data, 0x99, 0x310000,0x1000,
spiffs, data, spiffs, 0x311000,0xEF000,
spiffs, data, spiffs, 0x310000,0xF0000,

1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x300000
5 eeprom spiffs data 0x99 spiffs 0x310000 0x1000 0xF0000
spiffs data spiffs 0x311000 0xEF000

View File

@ -3,5 +3,4 @@ nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x480000,
app1, app, ota_1, 0x490000,0x480000,
eeprom, data, 0x99, 0x910000,0x1000,
spiffs, data, spiffs, 0x911000,0x6EF000,
spiffs, data, spiffs, 0x910000,0x6F0000,

1 # Name Type SubType Offset Size Flags
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x480000
5 app1 app ota_1 0x490000 0x480000
6 eeprom spiffs data 0x99 spiffs 0x910000 0x1000 0x6F0000
spiffs data spiffs 0x911000 0x6EF000

View File

@ -3,5 +3,4 @@ nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x1E0000,
app1, app, ota_1, 0x1F0000,0x1E0000,
eeprom, data, 0x99, 0x3D0000,0x1000,
spiffs, data, spiffs, 0x3D1000,0x2F000,
spiffs, data, spiffs, 0x3D0000,0x30000,

1 # Name Type SubType Offset Size Flags
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x1E0000
5 app1 app ota_1 0x1F0000 0x1E0000
6 eeprom spiffs data 0x99 spiffs 0x3D0000 0x1000 0x30000
spiffs data spiffs 0x3D1000 0x2F000

View File

@ -2,5 +2,4 @@
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x140000,
eeprom, data, 0x99, 0x150000, 0x1000,
spiffs, data, spiffs, 0x151000, 0xAF000,
spiffs, data, spiffs, 0x150000, 0xB0000,

1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x140000
5 eeprom spiffs data 0x99 spiffs 0x150000 0x1000 0xB0000
spiffs data spiffs 0x151000 0xAF000

View File

@ -2,5 +2,4 @@
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x200000,
eeprom, data, 0x99, 0x210000,0x1000,
spiffs, data, spiffs, 0x211000,0x1EF000,
spiffs, data, spiffs, 0x210000,0x1F0000,

1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x200000
5 eeprom spiffs data 0x99 spiffs 0x210000 0x1000 0x1F0000
spiffs data spiffs 0x211000 0x1EF000

View File

@ -2,5 +2,4 @@
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x100000,
eeprom, data, 0x99, 0x110000,0x1000,
spiffs, data, spiffs, 0x111000,0x2EF000,
spiffs, data, spiffs, 0x110000,0x2F0000,

1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x100000
5 eeprom spiffs data 0x99 spiffs 0x110000 0x1000 0x2F0000
spiffs data spiffs 0x111000 0x2EF000

View File

@ -2,6 +2,5 @@
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x100000,
eeprom, data, 0x99, 0x110000,0x1000,
ffat, data, fat, 0x111000,0x2EF000,
ffat, data, fat, 0x110000,0x2F0000,
# to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage

1 # Name, Type, SubType, Offset, Size, Flags
2 nvs, data, nvs, 0x9000, 0x5000,
3 otadata, data, ota, 0xe000, 0x2000,
4 app0, app, ota_0, 0x10000, 0x100000,
5 eeprom, data, 0x99, 0x110000,0x1000, ffat, data, fat, 0x110000,0x2F0000,
ffat, data, fat, 0x111000,0x2EF000,
6 # to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage

View File

@ -2,6 +2,5 @@
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x200000,
eeprom, data, 0x99, 0x210000,0x1000,
ffat, data, fat, 0x211000,0x1EF000,
ffat, data, fat, 0x210000,0x1F0000,
# to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage

1 # Name, Type, SubType, Offset, Size, Flags
2 nvs, data, nvs, 0x9000, 0x5000,
3 otadata, data, ota, 0xe000, 0x2000,
4 app0, app, ota_0, 0x10000, 0x200000,
5 eeprom, data, 0x99, 0x210000,0x1000, ffat, data, fat, 0x210000,0x1F0000,
ffat, data, fat, 0x211000,0x1EF000,
6 # to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage

View File

@ -59,7 +59,8 @@ env.Append(
"-Wno-unused-parameter",
"-Wno-sign-compare",
"-fstack-protector",
"-fexceptions"
"-fexceptions",
"-Werror=reorder"
],
CXXFLAGS=[
@ -78,6 +79,7 @@ env.Append(
"-T", "esp32.common.ld",
"-T", "esp32.rom.ld",
"-T", "esp32.peripherals.ld",
"-T", "esp32.rom.libgcc.ld",
"-T", "esp32.rom.spiram_incompatible_fns.ld",
"-u", "ld_include_panic_highint_hdl",
"-u", "__cxa_guard_dummy",
@ -162,7 +164,7 @@ env.Append(
],
LIBS=[
"-lgcc", "-lopenssl", "-lbtdm_app", "-lfatfs", "-lwps", "-lcoexist", "-lwear_levelling", "-lesp_http_client", "-lprotobuf-c", "-lhal", "-lnewlib", "-ldriver", "-lbootloader_support", "-lpp", "-lfreemodbus", "-lmesh", "-lsmartconfig", "-ljsmn", "-lwpa", "-lethernet", "-lphy", "-lfrmn", "-lapp_trace", "-lfr_coefficients", "-lconsole", "-lulp", "-lwpa_supplicant", "-lfreertos", "-lbt", "-lmicro-ecc", "-lesp32-camera", "-lcxx", "-lxtensa-debug-module", "-ltcp_transport", "-lmdns", "-lvfs", "-lmtmn", "-lesp_ringbuf", "-lsoc", "-lcore", "-lfb_gfx", "-lsdmmc", "-llibsodium", "-lcoap", "-ltcpip_adapter", "-lprotocomm", "-lesp_event", "-limage_util", "-lc_nano", "-lesp-tls", "-lasio", "-lrtc", "-lspi_flash", "-lwpa2", "-lwifi_provisioning", "-lesp32", "-lface_recognition", "-lapp_update", "-lnghttp", "-lspiffs", "-lface_detection", "-lespnow", "-lnvs_flash", "-lesp_adc_cal", "-llog", "-ldl_lib", "-lsmartconfig_ack", "-lexpat", "-lfd_coefficients", "-lm", "-lmqtt", "-lc", "-lheap", "-lmbedtls", "-llwip", "-lnet80211", "-lesp_http_server", "-lpthread", "-ljson", "-lesp_https_ota", "-lstdc++"
"-lgcc", "-lopenssl", "-lbtdm_app", "-lfatfs", "-lwps", "-lcoexist", "-lwear_levelling", "-lesp_http_client", "-lprotobuf-c", "-lhal", "-lnewlib", "-ldriver", "-lbootloader_support", "-lpp", "-lfreemodbus", "-lmesh", "-lsmartconfig", "-ljsmn", "-lwpa", "-lethernet", "-lphy", "-lapp_trace", "-lconsole", "-lulp", "-lwpa_supplicant", "-lfreertos", "-lbt", "-lmicro-ecc", "-lesp32-camera", "-lcxx", "-lxtensa-debug-module", "-ltcp_transport", "-lmdns", "-lvfs", "-lesp_ringbuf", "-lsoc", "-lcore", "-lfb_gfx", "-lsdmmc", "-llibsodium", "-lcoap", "-ltcpip_adapter", "-lprotocomm", "-lesp_event", "-limage_util", "-lc_nano", "-lesp-tls", "-lasio", "-lrtc", "-lspi_flash", "-lwpa2", "-lwifi_provisioning", "-lesp32", "-lface_recognition", "-lapp_update", "-lnghttp", "-lspiffs", "-lface_detection", "-lespnow", "-lnvs_flash", "-lesp_adc_cal", "-llog", "-ldl_lib", "-lsmartconfig_ack", "-lexpat", "-lm", "-lfr", "-lmqtt", "-lc", "-lheap", "-lmbedtls", "-llwip", "-lnet80211", "-lesp_http_server", "-lpthread", "-ljson", "-lesp_https_ota", "-lfd", "-lstdc++"
],
LIBSOURCE_DIRS=[

Binary file not shown.

View File

@ -584,12 +584,18 @@ typedef enum {
typedef enum {
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR = 0, /*!< BLE advertising address , device info will be added into ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID, /*!< BLE mesh link ID, it is for BLE mesh, device info will be added into ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_BEACON_TYPE, /*!< BLE mesh beacon AD type, the format is | Len | 0x2B | Beacon Type | Beacon Data | */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROV_SRV_ADV, /*!< BLE mesh provisioning service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1827 | .... |` */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SRV_ADV, /*!< BLE mesh adv with proxy service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1828 | .... |` */
} esp_ble_duplicate_exceptional_info_type_t;
typedef enum {
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST = BLE_BIT(0), /*!< duplicate scan exceptional addr list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST = BLE_BIT(1), /*!< duplicate scan exceptional mesh link ID list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ALL_LIST = (BLE_BIT(0) | BLE_BIT(1)), /*!< duplicate scan exceptional all list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST = BLE_BIT(0), /*!< duplicate scan exceptional addr list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST = BLE_BIT(1), /*!< duplicate scan exceptional mesh link ID list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_BEACON_TYPE_LIST = BLE_BIT(2), /*!< duplicate scan exceptional mesh beacon type list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROV_SRV_ADV_LIST = BLE_BIT(3), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROXY_SRV_ADV_LIST = BLE_BIT(4), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ALL_LIST = 0xFFFF, /*!< duplicate scan exceptional all list */
} esp_duplicate_scan_exceptional_list_type_t;
typedef uint8_t esp_duplicate_info_t[ESP_BD_ADDR_LEN];
@ -1046,6 +1052,7 @@ esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr);
*
*
* @param[in] type: device info type, it is defined in esp_ble_duplicate_exceptional_info_type_t
* when type is MESH_BEACON_TYPE, MESH_PROV_SRV_ADV or MESH_PROXY_SRV_ADV , device_info is invalid.
* @param[in] device_info: the device information.
* @return
* - ESP_OK : success
@ -1058,6 +1065,7 @@ esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_ex
*
*
* @param[in] type: device info type, it is defined in esp_ble_duplicate_exceptional_info_type_t
* when type is MESH_BEACON_TYPE, MESH_PROV_SRV_ADV or MESH_PROXY_SRV_ADV , device_info is invalid.
* @param[in] device_info: the device information.
* @return
* - ESP_OK : success

View File

@ -190,8 +190,8 @@
#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 1
#define CONFIG_LWIP_SO_REUSE_RXTOALL 1
#define CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT 20
#define CONFIG_ESP32_WIFI_MGMT_SBUF_NUM 32
#define CONFIG_PARTITION_TABLE_SINGLE_APP 1
#define CONFIG_XTENSA_IMPL 1
#define CONFIG_ESP32_WIFI_RX_BA_WIN 16
#define CONFIG_MBEDTLS_X509_CSR_PARSE_C 1
#define CONFIG_SPIFFS_USE_MTIME 1
@ -278,6 +278,7 @@
#define CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED 1
#define CONFIG_MONITOR_BAUD 115200
#define CONFIG_ESP32_DEBUG_STUBS_ENABLE 1
#define CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT 30
#define CONFIG_TCPIP_LWIP 1
#define CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST 1
#define CONFIG_REDUCE_PHY_TX_POWER 1

View File

@ -1,336 +0,0 @@
#ifndef DL_LIB_H
#define DL_LIB_H
#ifdef __cplusplus
extern "C" {
#endif
#include "dl_lib_matrix.h"
#include "dl_lib_matrixq.h"
#include "dl_lib_matrix3d.h"
#include "dl_lib_matrix3dq.h"
typedef int padding_state;
/**
* @brief Does a fast version of the exp() operation on a floating point number.
*
* As described in https://codingforspeed.com/using-faster-exponential-approximation/
* Should be good til an input of 5 or so with a steps factor of 8.
*
* @param in Floating point input
* @param steps Approximation steps. More is more precise. 8 or 10 should be good enough for most purposes.
* @return Exp()'ed output
*/
fptp_t fast_exp(double x, int steps);
/**
* @brief Does a softmax operation on a matrix.
*
* @param in Input matrix
* @param out Output matrix. Can be the same as the input matrix; if so,
output results overwrite the input.
*/
void dl_softmax(const dl_matrix2d_t *in,
dl_matrix2d_t *out);
/**
* @brief Does a softmax operation on a quantized matrix.
*
* @param in Input matrix
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
*/
void dl_softmax_q(const dl_matrix2dq_t *in, dl_matrix2dq_t *out);
/**
* @brief Does a sigmoid operation on a floating point number
*
* @param in Floating point input
* @return Sigmoid output
*/
fptp_t dl_sigmoid_op(fptp_t in);
/**
* @brief Does a sigmoid operation on a matrix.
*
* @param in Input matrix
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
*/
void dl_sigmoid(const dl_matrix2d_t *in, dl_matrix2d_t *out);
/**
* @brief Does a tanh operation on a floating point number
*
* @param in Floating point input number
* @return Tanh value
*/
fptp_t dl_tanh_op(fptp_t v);
/**
* @brief Does a tanh operation on a matrix.
*
* @param in Input matrix
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
*/
void dl_tanh(const dl_matrix2d_t *in, dl_matrix2d_t *out);
/**
* @brief Does a relu (Rectifier Linear Unit) operation on a floating point number
*
* @param in Floating point input
* @param clip If value is higher than this, it will be clipped to this value
* @return Relu output
*/
fptp_t dl_relu_op(fptp_t in, fptp_t clip);
/**
* @brief Does a ReLu operation on a matrix.
*
* @param in Input matrix
* @param clip If values are higher than this, they will be clipped to this value
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
*/
void dl_relu(const dl_matrix2d_t *in, fptp_t clip, dl_matrix2d_t *out);
/**
* @brief Fully connected layer operation
*
* @param in Input vector
* @param weight Weights of the neurons
* @param bias Biases for the neurons. Can be NULL if a bias of 0 is required.
* @param out Output array. Outputs are placed here. Needs to be an initialized, weight->w by in->h in size, matrix.
*/
void dl_fully_connect_layer(const dl_matrix2d_t *in,
const dl_matrix2d_t *weight,
const dl_matrix2d_t *bias,
dl_matrix2d_t *out);
/**
* @brief Pre-calculate the sqrtvari variable for the batch_normalize function.
* The sqrtvari matrix depends on the variance and epsilon values, which normally are constant. Hence,
* this matrix only needs to be calculated once. This function does that.
*
* @param
* @return
*/
void dl_batch_normalize_get_sqrtvar(const dl_matrix2d_t *variance,
fptp_t epsilon,
dl_matrix2d_t *out);
/**
* @brief Batch-normalize a matrix
*
* @param m The matrix to normalize
* @param offset Offset matrix
* @param scale Scale matrix
* @param mean Mean matrix
* @param sqrtvari Matrix precalculated using dl_batch_normalize_get_sqrtvar
* @return
*/
void dl_batch_normalize(dl_matrix2d_t *m,
const dl_matrix2d_t *offset,
const dl_matrix2d_t *scale,
const dl_matrix2d_t *mean,
const dl_matrix2d_t *sqrtvari);
/**
* @brief Do a basic LSTM layer pass.
*
* @warning Returns state_h pointer, so do not free result.
* @param in Input vector
* @param state_c Internal state of the LSTM network
* @param state_h Internal state (previous output values) of the LSTM network
* @param weights Weights for the neurons
* @param bias Bias for the neurons. Can be NULL if no bias is required
* @return Output values of the neurons
*/
dl_matrix2d_t *dl_basic_lstm_layer(const dl_matrix2d_t *in,
dl_matrix2d_t *state_c,
dl_matrix2d_t *state_h,
const dl_matrix2d_t *weight,
const dl_matrix2d_t *bias);
/**
* @brief Do a basic LSTM layer pass, partial quantized version.
* This LSTM function accepts 16-bit fixed-point weights and 32-bit float-point bias.
*
* @warning Returns state_h pointer, so do not free result.
* @param in Input vector
* @param state_c Internal state of the LSTM network
* @param state_h Internal state (previous output values) of the LSTM network
* @param weights Weights for the neurons, need to be quantised
* @param bias Bias for the neurons. Can be NULL if no bias is required
* @return Output values of the neurons
*/
dl_matrix2d_t *dl_basic_lstm_layer_quantised_weights(const dl_matrix2d_t *in,
dl_matrix2d_t *state_c,
dl_matrix2d_t *state_h,
const dl_matrix2dq_t *weight,
const dl_matrix2d_t *bias);
/**
* @brief Do a fully-connected layer pass, fully-quantized version.
*
* @param in Input vector
* @param weight Weights of the neurons
* @param bias Bias values of the neurons. Can be NULL if no bias is needed.
* @param shift Number of bits to shift the result back by. See dl_lib_matrixq.h for more info
* @return Output values of the neurons
*/
void dl_fully_connect_layer_q(const dl_matrix2dq_t *in,
const dl_matrix2dq_t *weight,
const dl_matrix2dq_t *bias,
dl_matrix2dq_t *out,
int shift);
/**
* @brief Do a basic LSTM layer pass, fully-quantized version
*
* @warning Returns state_h pointer, so do not free result.
* @param in Input vector
* @param state_c Internal state of the LSTM network
* @param state_h Internal state (previous output values) of the LSTM network
* @param weights Weights for the neurons
* @param bias Bias for the neurons. Can be NULL if no bias is required
* @param shift Number of bits to shift the result back by. See dl_lib_matrixq.h for more info
* @return Output values of the neurons
*/
dl_matrix2dq_t *dl_basic_lstm_layer_q(const dl_matrix2dq_t *in,
dl_matrix2dq_t *state_c,
dl_matrix2dq_t *state_h,
const dl_matrix2dq_t *weight,
const dl_matrix2dq_t *bias,
int shift);
/**
* @brief Batch-normalize a matrix, fully-quantized version
*
* @param m The matrix to normalize
* @param offset Offset matrix
* @param scale Scale matrix
* @param mean Mean matrix
* @param sqrtvari Matrix precalculated using dl_batch_normalize_get_sqrtvar
* @param shift Number of bits to shift the result back by. See dl_lib_matrixq.h for more info
* @return
*/
void dl_batch_normalize_q(dl_matrix2dq_t *m,
const dl_matrix2dq_t *offset,
const dl_matrix2dq_t *scale,
const dl_matrix2dq_t *mean,
const dl_matrix2dq_t *sqrtvari,
int shift);
/**
* @brief Does a relu (Rectifier Linear Unit) operation on a fixed-point number
* This accepts and returns fixed-point 32-bit number with the last 15 bits being the bits after the decimal
* point. (Equivalent to a mantissa in a quantized matrix with exponent -15.)
*
* @param in Fixed-point input
* @param clip If value is higher than this, it will be clipped to this value
* @return Relu output
*/
qtp_t dl_relu_q_op(qtp_t in,
qtp_t clip);
/**
* @brief Does a ReLu operation on a matrix, quantized version
*
* @param in Input matrix
* @param clip If values are higher than this, they will be clipped to this value
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
*/
void dl_relu_q(const dl_matrix2dq_t *in,
fptp_t clip,
dl_matrix2dq_t *out);
/**
* @brief Does a sigmoid operation on a fixed-point number.
* This accepts and returns a fixed-point 32-bit number with the last 15 bits being the bits after the decimal
* point. (Equivalent to a mantissa in a quantized matrix with exponent -15.)
*
* @param in Fixed-point input
* @return Sigmoid output
*/
int dl_sigmoid_op_q(const int in);
/**
* @brief Does a sigmoid operation on a matrix, quantized version
*
* @param in Input matrix
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
*/
void dl_sigmoid_q(const dl_matrix2dq_t *in,
dl_matrix2dq_t *out);
/**
* @brief Does a tanh operation on a matrix, quantized version
*
* @param in Input matrix
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
*/
void dl_tanh_q(const dl_matrix2dq_t *in,
dl_matrix2dq_t *out);
/**
* @brief Do a basic CNN layer pass.
*
* @Warning This just supports the single channel input image, and the output is single row matrix.
That is to say, the height of output is 1, and the weight of output is out_channels*out_image_width*out_image_height
*
* @param in Input single channel image
* @param weight Weights of the neurons, weight->w = out_channels, weight->h = filter_width*filter_height
* @param bias Bias for the CNN layer.
* @param filter_height The height of convolution kernel
* @param filter_width The width of convolution kernel
* @param out_channels The number of output channels of convolution kernel
* @param stride_x The step length of the convolution window in x(width) direction
* @param stride_y The step length of the convolution window in y(height) direction
* @param pad One of `"VALID"` or `"SAME"`, 0 is "VALID" and the other is "SAME"
* @param out The result of CNN layer, out->h=1.
* @return The result of CNN layer.
*/
dl_matrix2d_t *dl_basic_conv_layer(const dl_matrix2d_t *in,
const dl_matrix2d_t *weight,
const dl_matrix2d_t *bias,
int filter_width,
int filter_height,
const int out_channels,
const int stride_x,
const int stride_y,
padding_state pad,
const dl_matrix2d_t *out);
/**
* @brief Do a basic CNN layer pass, quantised wersion.
*
* @Warning This just supports the single channel input image, and the output is single row matrix.
That is to say, the height of output is 1, and the weight of output is out_channels*out_image_width*out_image_height
*
* @param in Input single channel image
* @param weight Weights of the neurons, weight->w = out_channels, weight->h = filter_width*filter_height,
* @param bias Bias of the neurons.
* @param filter_height The height of convolution kernel
* @param filter_width The width of convolution kernel
* @param out_channels The number of output channels of convolution kernel
* @param stride_x The step length of the convolution window in x(width) direction
* @param stride_y The step length of the convolution window in y(height) direction
* @param pad One of `"VALID"` or `"SAME"`, 0 is "VALID" and the other is "SAME"
* @param out The result of CNN layer, out->h=1
* @return The result of CNN layer
*/
dl_matrix2d_t *dl_basic_conv_layer_quantised_weight(const dl_matrix2d_t *in,
const dl_matrix2dq_t *weight,
const dl_matrix2d_t *bias,
int filter_width,
int filter_height,
const int out_channels,
const int stride_x,
const int stride_y,
padding_state pad,
const dl_matrix2d_t *out);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,47 +0,0 @@
#ifndef DL_LIB_COEFGETTER_IF_H
#define DL_LIB_COEFGETTER_IF_H
#include "dl_lib_matrix.h"
#include "dl_lib_matrixq.h"
#include "dl_lib_matrix3d.h"
#include "dl_lib_matrix3dq.h"
//Set this if the coefficient requested is a batch-normalization popvar matrix which needs to be preprocessed by
//dl_batch_normalize_get_sqrtvar first.
#define COEF_GETTER_HINT_BNVAR (1<<0)
/*
This struct describes the basic information of model data:
word_num: the number of wake words or speech commands
word_list: the name list of wake words or speech commands
thres_list: the threshold list of wake words or speech commands
info_str: the string used to reflect the version and information of model data
which consist of the architecture of network, the version of model data, wake words and their threshold
*/
typedef struct {
int word_num;
char **word_list;
int *win_list;
float *thresh_list;
char *info_str;
} model_info_t;
/*
This struct describes a generic coefficient getter: a way to get the constant coefficients needed for a neural network.
For the two getters, the name describes the name of the coefficient matrix, usually the same as the Numpy filename the
coefficient was originally stored in. The arg argument can be used to optionally pass an additional user-defined argument
to the getter (e.g. the directory to look for files in the case of the Numpy file loader getter). The hint argument
is a bitwise OR of the COEF_GETTER_HINT_* flags or 0 when none is needed. Use the free_f/free_q functions to release the
memory for the returned matrices, when applicable.
*/
typedef struct {
const dl_matrix2d_t* (*getter_f)(const char *name, void *arg, int hint);
const dl_matrix2dq_t* (*getter_q)(const char *name, void *arg, int hint);
const dl_matrix3d_t* (*getter_3d)(const char *name, void *arg, int hint);
const dl_matrix3dq_t* (*getter_3dq)(const char *name, void *arg, int hint);
void (*free_f)(const dl_matrix2d_t *m);
void (*free_q)(const dl_matrix2dq_t *m);
const model_info_t* (*getter_info)(void *arg);
} model_coeff_getter_t;
#endif

View File

@ -1,216 +0,0 @@
#ifndef DL_LIB_MATRIX_H
#define DL_LIB_MATRIX_H
typedef float fptp_t;
//Flags for matrices
#define DL_MF_FOREIGNDATA (1<<0) /*< Matrix *item data actually points to another matrix and should not be freed */
//'Normal' float matrix
typedef struct {
int w; /*< Width */
int h; /*< Height */
int stride; /*< Row stride, essentially how many items to skip to get to the same position in the next row */
int flags; /*< Flags. OR of DL_MF_* values */
fptp_t *item; /*< Pointer to item array */
} dl_matrix2d_t;
//Macro to quickly access the raw items in a matrix
#define DL_ITM(m, x, y) m->item[(x)+(y)*m->stride]
//#define DL_ITM3D(m, n, x, y, z) (m)->item[(n) * (m)->stride * (m)->c + (z) * (m)->stride + (y) * (m)->w + (x)]
/**
* @brief Allocate a matrix
*
* @param w Width of the matrix
* @param h Height of the matrix
* @return The matrix, or NULL if out of memory
*/
dl_matrix2d_t *dl_matrix_alloc(int w, int h);
/**
* @brief Free a matrix
* Frees the matrix structure and (if it doesn't have the DL_MF_FOREIGNDATA flag set) the m->items space as well.
*
* @param m Matrix to free
*/
void dl_matrix_free(dl_matrix2d_t *m);
/**
* @brief Zero out the matrix
* Sets all entries in the matrix to 0.
*
* @param m Matrix to zero
*/
void dl_matrix_zero(dl_matrix2d_t *m);
/**
* @brief Generate a new matrix using a range of items from an existing matrix.
* When using this, the data of the new matrix is not allocated/copied but it re-uses a pointer
* to the existing data. Changing the data in the resulting matrix, as a result, will also change
* the data in the existing matrix that has been sliced.
*
* @param x X-offset of the origin of the returned matrix within the sliced matrix
* @param y Y-offset of the origin of the returned matrix within the sliced matrix
* @param w Width of the resulting matrix
* @param h Height of the resulting matrix
* @param in Old matrix (with foreign data) to re-use. Passing NULL will allocate a new matrix.
* @return The resulting slice matrix, or NULL if out of memory
*/
dl_matrix2d_t *dl_matrix_slice(const dl_matrix2d_t *src, int x, int y, int w, int h, dl_matrix2d_t *in);
/**
* @brief select a range of items from an existing matrix and flatten them into one dimension.
*
* @Warning The results are flattened in row-major order.
*
* @param x X-offset of the origin of the returned matrix within the sliced matrix
* @param y Y-offset of the origin of the returned matrix within the sliced matrix
* @param w Width of the resulting matrix
* @param h Height of the resulting matrix
* @param in Old matrix to re-use. Passing NULL will allocate a new matrix.
* @return The resulting flatten matrix, or NULL if out of memory
*/
dl_matrix2d_t *dl_matrix_flatten(const dl_matrix2d_t *src, int x, int y, int w, int h, dl_matrix2d_t *in);
/**
* @brief Generate a matrix from existing floating-point data
*
* @param w Width of resulting matrix
* @param h Height of resulting matrix
* @param data Data to populate matrix with
* @return A newaly allocated matrix populated with the given input data, or NULL if out of memory.
*/
dl_matrix2d_t *dl_matrix_from_data(int w, int h, int stride, const void *data);
/**
* @brief Multiply a pair of matrices item-by-item: res=a*b
*
* @param a First multiplicand
* @param b Second multiplicand
* @param res Multiplicated data. Can be equal to a or b to overwrite that.
*/
void dl_matrix_mul(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *res);
/**
* @brief Do a dotproduct of two matrices : res=a.b
*
* @param a First multiplicand
* @param b Second multiplicand
* @param res Dotproduct data. *Must* be a *different* matrix from a or b!
*/
void dl_matrix_dot(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *res);
/**
* @brief Add a pair of matrices item-by-item: res=a-b
*
* @param a First matrix
* @param b Second matrix
* @param res Added data. Can be equal to a or b to overwrite that.
*/
void dl_matrix_add(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *out);
/**
* @brief Divide a pair of matrices item-by-item: res=a/b
*
* @param a First matrix
* @param b Second matrix
* @param res Divided data. Can be equal to a or b to overwrite that.
*/
void dl_matrix_div(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *out);
/**
* @brief Subtract a matrix from another, item-by-item: res=a-b
*
* @param a First matrix
* @param b Second matrix
* @param res Subtracted data. Can be equal to a or b to overwrite that.
*/
void dl_matrix_sub(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *out);
/**
* @brief Add a constant to every item of the matrix
*
* @param subj Matrix to add the constant to
* @param add The constant
*/
void dl_matrix_add_const(dl_matrix2d_t *subj, const fptp_t add);
/**
* @brief Concatenate the rows of two matrices into a new matrix
*
* @param a First matrix
* @param b Second matrix
* @return A newly allocated array with as avlues a|b
*/
dl_matrix2d_t *dl_matrix_concat(const dl_matrix2d_t *a, const dl_matrix2d_t *b);
/**
* @brief Print the contents of a matrix to stdout. Used for debugging.
*
* @param a The matrix to print.
*/
void dl_printmatrix(const dl_matrix2d_t *a);
/**
* @brief Return the average square error given a correct and a test matrix.
*
* ...Well, more or less. If anything, it gives an indication of the error between
* the two. Check the code for the exact implementation.
*
* @param a First of the two matrices to compare
* @param b Second of the two matrices to compare
* @return value indicating the relative difference between matrices
*/
float dl_matrix_get_avg_sq_err(const dl_matrix2d_t *a, const dl_matrix2d_t *b);
/**
* @brief Check if two matrices have the same shape, that is, the same amount of rows and columns
*
* @param a First of the two matrices to compare
* @param b Second of the two matrices to compare
* @return true if the two matrices are shaped the same, false otherwise.
*/
int dl_matrix_same_shape(const dl_matrix2d_t *a, const dl_matrix2d_t *b);
/**
* @brief Get a specific item from the matrix
*
* Please use these for external matrix access instead of DL_ITM
*
* @param m Matrix to access
* @param x Column address
* @param y Row address
* @return Value in that position
*/
inline static fptp_t dl_matrix_get(const dl_matrix2d_t *m, const int x, const int y) {
return DL_ITM(m, x, y);
}
/**
* @brief Set a specific item in the matrix to the given value
*
* Please use these for external matrix access instead of DL_ITM
*
* @param m Matrix to access
* @param x Column address
* @param y Row address
* @param val Value to write to that position
*/
inline static void dl_matrix_set(dl_matrix2d_t *m, const int x, const int y, fptp_t val) {
DL_ITM(m, x, y)=val;
}
#endif

View File

@ -1,5 +1,6 @@
#pragma once
#include <stdint.h>
typedef float fptp_t;
typedef uint8_t uc_t;
@ -92,6 +93,16 @@ void dl_matrix3d_free(dl_matrix3d_t *m);
*/
void dl_matrix3du_free(dl_matrix3du_t *m);
/*
* @brief Dot product with a vector and matrix
*
* @param out Space to put the result
* @param in input vector
* @param f filter matrix
*/
void dl_matrix3d_dot_product(dl_matrix3d_t *out, dl_matrix3d_t *in, dl_matrix3d_t *f);
/**
* @brief Do a relu (Rectifier Linear Unit) operation, update the input matrix3d
*
@ -162,6 +173,9 @@ void dl_matrix3du_slice_copy(dl_matrix3du_t *dst,
int w,
int h);
void dl_matrix3d_conv_1x1 (dl_matrix3d_t *out, dl_matrix3d_t *in, dl_matrix3d_t *f);
/**
* @brief Do a general CNN layer pass, dimension is (number, width, height, channel)
*
@ -183,6 +197,11 @@ dl_matrix3d_t *dl_matrix3d_conv(dl_matrix3d_t *in,
int padding,
int mode);
void dl_matrix3d_conv_3x3_normal (dl_matrix3d_t *out,
dl_matrix3d_t *in,
dl_matrix3d_t *f,
int step_x,
int step_y);
/**
* @brief Do a general CNN layer pass, dimension is (number, width, height, channel)
*
@ -223,6 +242,11 @@ dl_matrix3d_t *dl_matrix3d_depthwise_conv(dl_matrix3d_t *in,
int padding,
int mode);
void dl_matrix3d_depthwise_conv_3x3_normal(dl_matrix3d_t *out,
dl_matrix3d_t *in,
dl_matrix3d_t *f,
int step_x,
int step_y);
/**
* @brief Do a mobilenet block forward, dimension is (number, width, height, channel)
*
@ -418,3 +442,8 @@ void dl_matrix3d_print(dl_matrix3d_t *m, char *message);
* @param message name of matrix
*/
void dl_matrix3du_print(dl_matrix3du_t *m, char *message);
void dl_matrix3d_init_bias (dl_matrix3d_t *out, dl_matrix3d_t *bias);
void dl_matrix3d_multiply(dl_matrix3d_t *out, dl_matrix3d_t *in1, dl_matrix3d_t *in2);

View File

@ -85,6 +85,22 @@ dl_matrix3dq_t *dl_matrix3dq_conv (dl_matrix3dq_t *in, dl_matrix3dq_t *filter, d
dl_matrix3dq_t *dl_matrix3dq_conv_normal (dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *bias,
int stride_x, int stride_y, int padding, int exponent, int mode);
void dl_matrix3dq_conv_1x1 (dl_matrix3dq_t *out, dl_matrix3dq_t *in, dl_matrix3dq_t *f, dl_conv_mode mode);
void dl_matrix3dq_conv_3x3_normal (dl_matrix3dq_t *out,
dl_matrix3dq_t *in,
dl_matrix3dq_t *f,
int step_x,
int step_y);
dl_matrix3dq_t *dl_matrix3dq_conv_3x3_with_bn (dl_matrix3dq_t *in,
dl_matrix3dq_t *f,
dl_matrix3dq_t *scale,
dl_matrix3dq_t *offset,
int step_x,
int step_y,
int padding,
int exponent,
int relu);
/**
* @brief Print the matrix3d items
*
@ -95,6 +111,15 @@ void dl_matrix3dq_print (dl_matrix3dq_t *m, char *message);
dl_matrix3dq_t *dl_matrix3dq_depthwise_conv (dl_matrix3dq_t *in, dl_matrix3dq_t *filter,
int stride_x, int stride_y, int padding, int exponent, int mode);
dl_matrix3dq_t *dl_matrix3dq_depthwise_conv_3x3_with_bn(dl_matrix3dq_t *in,
dl_matrix3dq_t *f,
dl_matrix3dq_t *scale,
dl_matrix3dq_t *offset,
int step_x,
int step_y,
int padding,
int exponent,
int relu);
void dl_matrix3dq_relu (dl_matrix3dq_t *m, fptp_t clip);

View File

@ -1,359 +0,0 @@
#ifndef DL_LIB_MATRIXQ_H
#define DL_LIB_MATRIXQ_H
#include <stdint.h>
#include "dl_lib_matrix.h"
typedef int16_t qtp_t;
//Quantized matrix. Uses fixed numbers and has the storage for the rows/columns inverted
//for easy use as a multiplicand without stressing out the flash cache too much.
typedef struct {
int w;
int h;
int stride; //Normally equals h, not w!
int flags;
int exponent; //The values in items should be multiplied by pow(2,exponent) to get the real values.
qtp_t *itemq;
} dl_matrix2dq_t;
#define DL_QTP_SHIFT 15
#define DL_QTP_RANGE ((1<<DL_QTP_SHIFT)-1)
#define DL_ITMQ(m, x, y) m->itemq[(y)+(x)*m->stride]
#define DL_QTP_EXP_NA 255 //non-applicable exponent because matrix is null
#define DL_SHIFT_AUTO 32
/**
* @info About quantized matrices and shift values
*
* Grab a coffee (or tea, or hot water) and sit down when you read this for the first
* time. Quantized matrices can speed up your operations, but come with some quirks, and
* it's good to understand how they work before using them.
*
* The data in the quantized matrix type is stored similarily to floating-point types:
* when storing a real value, the value is stored as a mantissa (base number) and an
* exponent. The 'real' value that can be re-derived from those two numbers is something
* similar to mantissa*2^exponent. Up to this point, there's not that much difference from
* the standard floating point implementations like e.g. IEEE-754.
*
* The difference with respect to quantized matrices is that for a quantized matrix, it is
* assumed all values stored have more-or-less the same order of magnitude. This allows the
* matrix to only store all the mantissas, while the exponents are shared; there is only one
* exponent for the entire matrix. This makes it quicker to handle matrix operations - the
* logic to fix the exponents only needs to happen once, while the rest can be done in simple
* integer arithmetic. It also nets us some memory savings - while normally a floating point
* number is 32-bit, storing only 16-bit mantissas as the matrix items almost halves the
* memory requirements.
*
* While most of the details of handling the intricacies of the quantized matrixes are done
* transparently by the code in dl_lib_matrixq.c, some implementation details leak out,
* specifically in places where addition/subtraction/division happens.
*
* The problem is that the routines do not know what the size of the resulting operation is. For
* instance, when adding two matrices of numbers, the resulting numbers *could* be large enough
* to overflow the mantissa of the result if the exponent is the same. However, if by default we
* assume the mantissas needs to be scaled back, we may lose precision.
*
* In order to counter this, all operations that have this issue have a ``shift`` argument. If
* the argument is zero, the routine will be conservative, that is, increase the exponent of
* the result to such an extent it's mathematically impossible a value in the result will exceed
* the maximum value that can be stored. However, when this argument is larger than zero, the
* algorithm will hold back on this scaling by the indicated amount of bits, preserving precision
* but increasing the chance of some of the calculated values not fitting in the mantissa anymore.
* If this happens, the value will be clipped to the largest (or, for negative values, smallest)
* value possible. (Neural networks usually are okay with this happening for a limited amount
* of matrix indices).
*
* For deciding on these shift values, it is recommended to start with a shift value of one, then
* use dl_matrixq_check_sanity on the result. If this indicates clipping, lower the shift value.
* If it indicates bits are under-used, increase it. Note that for adding and subtraction, only
* shift values of 0 or 1 make sense; these routines will error out if you try to do something
* else.
*
* For neural networks and other noise-tolerant applications, note that even when
* dl_matrixq_check_sanity does not indicate any problems, twiddling with the shift value may lead
* to slightly improved precision. Feel free to experiment.
**/
/**
* @brief Allocate a matrix
*
* @param w Width of the matrix
* @param h Height of the matrix
* @return The matrix, or NULL if out of memory
*/
dl_matrix2dq_t *dl_matrixq_alloc(int w, int h);
/**
* @brief Convert a floating-point matrix to a quantized matrix
*
* @param m Floating-point matrix to convert
* @param out Quantized matrix to re-use. If NULL, allocate a new one.
* @Return The quantized version of the floating-point matrix
*/
dl_matrix2dq_t *dl_matrixq_from_matrix2d(const dl_matrix2d_t *m, dl_matrix2dq_t *out);
/**
* TODO: DESCRIBE THIS FUNCTION
*/
dl_matrix2dq_t *dl_matrixq_from_matrix2d_by_qmf(const dl_matrix2d_t *m, dl_matrix2dq_t *out, int m_bit, int f_bit);
/**
* @brief Convert a quantized matrix to a floating-point one.
*
* @param m Floating-point matrix to convert
* @param out Quantized matrix to re-use. If NULL, allocate a new one.
* @Return The quantized version of the floating-point matrix
**/
dl_matrix2d_t *dl_matrix2d_from_matrixq(const dl_matrix2dq_t *m, dl_matrix2d_t *out);
/**
* @brief Free a quantized matrix
* Frees the matrix structure and (if it doesn't have the DL_MF_FOREIGNDATA flag set) the m->items space as well.
*
* @param m Matrix to free
*/
void dl_matrixq_free(dl_matrix2dq_t *m);
/**
* @brief Zero out the matrix
* Sets all entries in the matrix to 0.
*
* @param m Matrix to zero
*/
void dl_matrixq_zero(dl_matrix2dq_t *m);
/**
* @brief Do a dotproduct of two quantized matrices : res=a.b, Result is a fixed-point matrix.
*
* @param a First multiplicand
* @param b Second multiplicand
* @param res Dotproduct data. *Must* be a *different* matrix from a or b!
* @param shift Shift ratio
*/
void dl_matrixq_dot(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2dq_t *res, int shift);
/**
* @brief Do a dotproduct of two quantized matrices: res=a.b, Result is a floating-point matrix.
*
* @param a First multiplicand
* @param b Second multiplicand
* @param res Dotproduct data. *Must* be a *different* matrix from a or b!
*/
void dl_matrixq_dot_matrix_out(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2d_t *res);
/**
* @brief Do a dotproduct of two quantized matrices : res=a.b. This always uses the simple & stupid C algo for the dot product.
*
* Result is a fixed-point matrix.
*
* Use this only if you expect something is wrong with the accelerated routines that dl_matrixq_dot calls; this function can be
* much slower than dl_matrixq_dot .
*
* @param a First multiplicand
* @param b Second multiplicand
* @param res Dotproduct data. *Must* be a *different* matrix from a or b!
* @param shift Shift ratio
*/
void dl_matrixq_dot_c_impl(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2dq_t *res, int shift);
/**
* @brief Do a dotproduct of two quantized matrices : res=a.b. This always uses the simple & stupid C algo for the dot product.
*
* Result is a floating-point matrix.
*
* Use this only if you expect something is wrong with the accelerated routines that dl_matrixq_dot_matrix_out calls; this function can be
* much slower than dl_matrixq_dot_matrix_out.
*
* @param a First multiplicand
* @param b Second multiplicand
* @param res Dotproduct data. *Must* be a *different* matrix from a or b!
*/
void dl_matrixq_dot_matrix_out_c_impl(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2d_t *res);
/**
* @brief Do a dotproduct of a floating point and a quantized matrix. Result is a floating-point matrix.
*
* @param a First multiplicand; float matrix
* @param b Second multiplicand; quantized matrix
* @param res Dotproduct data; float matrix. *Must* be a *different* matrix from a or b!
*/
void dl_matrix_matrixq_dot(const dl_matrix2d_t *a, const dl_matrix2dq_t *b, dl_matrix2d_t *res);
/**
* @brief Print the contents of a quantized matrix to stdout. Used for debugging.
*
* @param a The matrix to print.
*/
void dl_printmatrixq(const dl_matrix2dq_t *a);
/**
* @brief Add a pair of quantizedmatrices item-by-item: res=a-b
*
* @param a First matrix
* @param b Second matrix
* @param res Added data. Can be equal to a or b to overwrite that.
* @param shift Shift value. Only 0 or 1 makes sense here. <ToDo: check>
*/
void dl_matrixq_add(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2dq_t *res, int shift);
/**
* @brief Generate a new matrix using a range of items from an existing matrix.
* When using this, the data of the new matrix is not allocated/copied but it re-uses a pointer
* to the existing data. Changing the data in the resulting matrix, as a result, will also change
* the data in the existing matrix that has been sliced.
*
* @Warning In contrast to the floating point equivalent of this function, the fixed-point version
* of this has the issue that as soon as the output exponent of one of the slices changes, the data
* in the sliced matrix gets corrupted (because the exponent of that matrix is still the same.) If you
* use this function, either treat the slices as read-only, or assume the sliced matrix contains
* garbage after modifying the data in one of the slices.
*
* @param x X-offset of the origin of the returned matrix within the sliced matrix
* @param y Y-offset of the origin of the returned matrix within the sliced matrix
* @param w Width of the resulting matrix
* @param h Height of the resulting matrix
* @param in Old matrix (with foreign data) to re-use. Passing NULL will allocate a new matrix.
* @return The resulting slice matrix, or NULL if out of memory
*/
dl_matrix2dq_t *dl_matrixq_slice(const dl_matrix2dq_t *src, int x, int y, int w, int h, dl_matrix2dq_t *in);
/**
* @brief select a range of items from an existing matrix and flatten them into one dimension.
*
* @Warning The results are flattened in row-major order.
*
* @param x X-offset of the origin of the returned matrix within the sliced matrix
* @param y Y-offset of the origin of the returned matrix within the sliced matrix
* @param w Width of the resulting matrix
* @param h Height of the resulting matrix
* @param in Old matrix to re-use. Passing NULL will allocate a new matrix.
* @return The resulting flatten matrix, or NULL if out of memory
*/
dl_matrix2dq_t *dl_matrixq_flatten(const dl_matrix2dq_t *src, int x, int y, int w, int h, dl_matrix2dq_t *in);
/**
* @brief Subtract a quantized matrix from another, item-by-item: res=a-b
*
* @param a First matrix
* @param b Second matrix
* @param res Subtracted data. Can be equal to a or b to overwrite that.
* @param shift Shift value. Only 0 or 1 makes sense here. <ToDo: check>
*/
void dl_matrixq_sub(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2dq_t *res, int shift);
/**
* @brief Multiply a pair of quantized matrices item-by-item: res=a*b
*
* @param a First multiplicand
* @param b Second multiplicand
* @param res Multiplicated data. Can be equal to a or b to overwrite that matrix.
*/
void dl_matrixq_mul(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2dq_t *res);
/**
* @brief Divide a pair of quantized matrices item-by-item: res=a/b
*
* @param a First matrix
* @param b Second matrix
* @param res Divided data. Can be equal to a or b to overwrite that.
*/
void dl_matrixq_div(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2dq_t *out, int shift);
/**
* @brief Check if two quantized matrices have the same shape, that is, the same amount of
* rows and columns
*
* @param a First of the two matrices to compare
* @param b Second of the two matrices to compare
* @return true if the two matrices are shaped the same, false otherwise.
*/
int dl_matrixq_same_shape(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b);
/**
* @brief Concatenate the rows of two quantized matrices into a new matrix
*
* @param a First matrix
* @param b Second matrix
* @return A newly allocated quantized matrix with as values a|b
*/
dl_matrix2dq_t *dl_matrixq_concat(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b);
/**
* @brief Add a constant to every item of the quantized matrix
*
* @param subj Matrix to add the constant to
* @param add The constant
*/
void dl_matrixq_add_const(dl_matrix2dq_t *subj, const fptp_t add, int shift);
/**
* @brief Check the sanity of a quantized matrix
*
* Due to the nature of quantized matrices, depending on the calculations a quantized
* matrix is the result of and the shift values chosen in those calculations, a quantized
* matrix may have an exponent and mantissas that lead to a loss of precision, either because
* most significant mantissa bits are unused, or because a fair amount of mantissas are
* clipped. This function checks if this is the case and will report a message to stdout
* if significant loss of precision is detected.
*
* @param m The quantized matrix to check
* @param name A string to be displayed in the message if the sanity check fails
* @return True if matrix is sane, false otherwise
**/
int dl_matrixq_check_sanity(dl_matrix2dq_t *m, const char *name);
/**
* @brief re-adjust the exponent of the matrix to fit the mantissa better
*
* This function will shift up all the data in the mantissas so there are no
* most-significant bits that are unused in all mantissas. It will also adjust
* the exponent to keep the actua values in the matrix the same.
*
* Some operations done on a matrix, especially operations that re-use the
* result of earlier operations done in the same way, can lead to the loss of
* data because the exponent of the quantized matrix is never re-adjusted. You
* can do that implicitely by calling this function.
*
* @param m The matrix to re-adjust
**/
void dl_matrixq_readjust_exp(dl_matrix2dq_t *m);
/**
* @brief Get the floating-point value of a specific item from the quantized matrix
*
* @param m Matrix to access
* @param x Column address
* @param y Row address
* @return Value in that position
*/
fptp_t dl_matrixq_get(const dl_matrix2dq_t *m, const int x, const int y);
/**
* @brief Set a specific item in the quantized matrix to the given
* floating-point value
*
* @warning If the given value is more than the exponent in the quantized matrix
* allows for, all mantissas in the matrix will be shifted down to make the value
* 'fit'. If, however, the exponent is such that the value would result in a
* quantized mantissa of 0, nothing is done.
*
* @param m Matrix to access
* @param x Column address
* @param y Row address
* @param val Value to write to that position
*/
void dl_matrixq_set(dl_matrix2dq_t *m, const int x, const int y, fptp_t val);
#endif

View File

@ -29,22 +29,41 @@ extern "C"
#endif
#include "image_util.h"
#include "dl_lib.h"
#include "dl_lib_matrix3d.h"
#include "mtmn.h"
typedef enum
{
FAST = 0,
NORMAL = 1,
} mtmn_resize_type;
typedef struct
{
float min_face; /// the minimum size of face can be detected
float pyramid; /// the pyramid scale
int pyramid_times; /// the pyramid resizing times
threshold_config_t p_threshold; /// score, nms and candidate threshold of pnet
threshold_config_t r_threshold; /// score, nms and candidate threshold of rnet
threshold_config_t o_threshold; /// score, nms and candidate threshold of onet
mtmn_resize_type type; /// image resize type. 'pyramid' will lose efficacy, when 'type'==FAST.
} mtmn_config_t;
static inline mtmn_config_t mtmn_init_config()
{
mtmn_config_t mtmn_config;
mtmn_config.type = FAST;
mtmn_config.min_face = 80;
mtmn_config.pyramid = 0.7;
mtmn_config.pyramid = 0.707;
mtmn_config.pyramid_times = 4;
mtmn_config.p_threshold.score = 0.6;
mtmn_config.p_threshold.nms = 0.7;
mtmn_config.p_threshold.candidate_number = 100;
mtmn_config.r_threshold.score = 0.6;
mtmn_config.p_threshold.candidate_number = 20;
mtmn_config.r_threshold.score = 0.7;
mtmn_config.r_threshold.nms = 0.7;
mtmn_config.r_threshold.candidate_number = 4;
mtmn_config.o_threshold.score = 0.6;
mtmn_config.o_threshold.nms = 0.4;
mtmn_config.r_threshold.candidate_number = 10;
mtmn_config.o_threshold.score = 0.7;
mtmn_config.o_threshold.nms = 0.7;
mtmn_config.o_threshold.candidate_number = 1;
return mtmn_config;

View File

@ -6,7 +6,7 @@ extern "C"
#endif
#include "image_util.h"
#include "dl_lib.h"
#include "dl_lib_matrix3d.h"
#include "frmn.h"
#define FACE_WIDTH 56
@ -38,23 +38,22 @@ extern "C"
typedef struct
{
face_id_node *head; /*!< head pointer of the id list */
face_id_node *tail; /*!< tail pointer of the id list */
uint8_t count; /*!< number of enrolled ids */
uint8_t confirm_times; /*!< images needed for one enrolling */
face_id_node *head; /*!< head pointer of the id list */
face_id_node *tail; /*!< tail pointer of the id list */
uint8_t count; /*!< number of enrolled ids */
uint8_t confirm_times; /*!< images needed for one enrolling */
} face_id_name_list;
typedef struct
{
uint8_t head; /*!< head index of the id list */
uint8_t tail; /*!< tail index of the id list */
uint8_t count; /*!< number of enrolled ids */
uint8_t size; /*!< max len of id list */
uint8_t confirm_times; /*!< images needed for one enrolling */
dl_matrix3d_t **id_list; /*!< stores face id vectors */
uint8_t head; /*!< head index of the id list */
uint8_t tail; /*!< tail index of the id list */
uint8_t count; /*!< number of enrolled ids */
uint8_t size; /*!< max len of id list */
uint8_t confirm_times; /*!< images needed for one enrolling */
dl_matrix3d_t **id_list; /*!< stores face id vectors */
} face_id_list;
/**
* @brief Initialize face id list
*
@ -86,6 +85,10 @@ extern "C"
dl_matrix3du_t *src,
dl_matrix3du_t *dest);
int8_t align_face2(fptp_t *landmark,
dl_matrix3du_t *src,
dl_matrix3du_t *dest);
dl_matrix3d_t *get_face_id(dl_matrix3du_t *aligned_face);
/**
@ -104,11 +107,9 @@ extern "C"
* @param id_list An ID list
* @return int8_t Matched face id
*/
int8_t recognize_face(face_id_list *l,
dl_matrix3du_t *algined_face);
face_id_node *recognize_face_with_name(face_id_name_list *l,
dl_matrix3d_t *face_id);
int8_t recognize_face(face_id_list *l, dl_matrix3du_t *algined_face);
face_id_node *recognize_face_with_name(face_id_name_list *l, dl_matrix3d_t *face_id);
/**
* @brief Produce face id according to the input aligned face, and save it to dest_id.
*
@ -119,12 +120,11 @@ extern "C"
* @return 0 Enrollment finish
* @return >=1 The left piece of aligned faces should be input
*/
int8_t enroll_face(face_id_list *l,
dl_matrix3du_t *aligned_face);
int8_t enroll_face_with_name(face_id_name_list *l,
dl_matrix3d_t *new_id,
char *name);
int8_t enroll_face(face_id_list *l, dl_matrix3du_t *aligned_face);
int8_t enroll_face_with_name(face_id_name_list *l,
dl_matrix3d_t *new_id,
char *name);
/**
* @brief Alloc memory for aligned face.
@ -133,7 +133,7 @@ extern "C"
* @return uint8_t left count
*/
uint8_t delete_face(face_id_list *l);
int8_t delete_face_with_name(face_id_name_list *l, char *name);
int8_t delete_face_with_name(face_id_name_list *l, char *name);
void delete_face_all_with_name(face_id_name_list *l);
#if __cplusplus
}

View File

@ -5,7 +5,8 @@ extern "C"
{
#endif
#include "dl_lib.h"
#include "dl_lib_matrix3d.h"
#include "dl_lib_matrix3dq.h"
/**
* @brief

View File

@ -27,6 +27,7 @@ extern "C"
{
#endif
#include <stdint.h>
#include <math.h>
#include "mtmn.h"
#define MAX_VALID_COUNT_PER_IMAGE (30)
@ -57,6 +58,7 @@ extern "C"
typedef struct tag_box_list
{
fptp_t *score;
box_t *box;
landmark_t *landmark;
int len;
@ -142,12 +144,19 @@ extern "C"
for (int i = 0; i < boxes->len; i++)
{
box_t *box = &(boxes->box[i]);
float w, h;
image_get_width_and_height(box, &w, &h);
float l = DL_IMAGE_MAX(w, h);
box->box_p[0] = DL_IMAGE_MAX(0, box->box_p[0] + 0.5 * (w - l));
box->box_p[1] = DL_IMAGE_MAX(0, box->box_p[1] + 0.5 * (h - l));
int x1 = round(box->box_p[0]);
int y1 = round(box->box_p[1]);
int x2 = round(box->box_p[2]);
int y2 = round(box->box_p[3]);
int w = x2 - x1 + 1;
int h = y2 - y1 + 1;
int l = DL_IMAGE_MAX(w, h);
box->box_p[0] = round(DL_IMAGE_MAX(0, x1) + 0.5 * (w - l));
box->box_p[1] = round(DL_IMAGE_MAX(0, y1) + 0.5 * (h - l));
box->box_p[2] = box->box_p[0] + l - 1;
if (box->box_p[2] > width)
{
@ -215,6 +224,25 @@ extern "C"
*/
void image_nms_process(image_list_t *image_list, fptp_t nms_threshold, int same_area);
/**
* @brief
*
* @param dimage
* @param dw
* @param dh
* @param dc
* @param simage
* @param sw
* @param sc
*/
void image_zoom_in_twice(uint8_t *dimage,
int dw,
int dh,
int dc,
uint8_t *simage,
int sw,
int sc);
/**
* @brief
*

View File

@ -27,14 +27,7 @@
extern "C"
{
#endif
#include "dl_lib.h"
typedef enum
{
PNET = 0, /// P-Net
RNET = 1, /// R-Net
ONET = 2, /// O-Net
} net_type_en;
#include "dl_lib_matrix3d.h"
typedef struct
{
@ -45,22 +38,11 @@ extern "C"
typedef struct
{
net_type_en net_type; /// net type
char *file_name; /// net name
int w; /// net width
int h; /// net height
threshold_config_t threshold; /// threshold of net
} net_config_t;
typedef struct
{
float min_face; /// the minimum size of face can be detected
float pyramid; /// the pyramid scale
threshold_config_t p_threshold; /// score, nms and candidate threshold of pnet
threshold_config_t r_threshold; /// score, nms and candidate threshold of rnet
threshold_config_t o_threshold; /// score, nms and candidate threshold of onet
} mtmn_config_t;
typedef struct
{
dl_matrix3d_t *category;

View File

@ -0,0 +1,59 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __ESP_COEXIST_ADAPTER_H__
#define __ESP_COEXIST_ADAPTER_H__
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
#define COEX_ADAPTER_VERSION 0x00000001
#define COEX_ADAPTER_MAGIC 0xDEADBEAF
#define COEX_ADAPTER_FUNCS_TIME_BLOCKING 0xffffffff
typedef struct {
int32_t _version;
void *(* _spin_lock_create)(void);
void (* _spin_lock_delete)(void *lock);
uint32_t (*_int_disable)(void *mux);
void (*_int_enable)(void *mux, uint32_t tmp);
void (*_task_yield_from_isr)(void);
void *(*_semphr_create)(uint32_t max, uint32_t init);
void (*_semphr_delete)(void *semphr);
int32_t (*_semphr_take_from_isr)(void *semphr, void *hptw);
int32_t (*_semphr_give_from_isr)(void *semphr, void *hptw);
int32_t (*_semphr_take)(void *semphr, uint32_t block_time_tick);
int32_t (*_semphr_give)(void *semphr);
int32_t (* _is_in_isr)(void);
void * (* _malloc_internal)(size_t size);
void (* _free)(void *p);
void (* _timer_disarm)(void *timer);
void (* _timer_done)(void *ptimer);
void (* _timer_setfn)(void *ptimer, void *pfunction, void *parg);
void (* _timer_arm_us)(void *ptimer, uint32_t us, bool repeat);
int64_t (* _esp_timer_get_time)(void);
int32_t _magic;
} coex_adapter_funcs_t;
extern coex_adapter_funcs_t g_coex_adapter_funcs;
#ifdef __cplusplus
}
#endif
#endif /* __ESP_COEXIST_ADAPTER_H__ */

View File

@ -0,0 +1,163 @@
// Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __ESP_COEXIST_INTERNAL_H__
#define __ESP_COEXIST_INTERNAL_H__
#include <stdbool.h>
#include "esp_coexist_adapter.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
COEX_PREFER_WIFI = 0,
COEX_PREFER_BT,
COEX_PREFER_BALANCE,
COEX_PREFER_NUM,
} coex_prefer_t;
typedef void (* coex_func_cb_t)(uint32_t event, int sched_cnt);
/**
* @brief Init software coexist
* extern function for internal use.
*
* @return Init ok or failed.
*/
esp_err_t coex_init(void);
/**
* @brief De-init software coexist
* extern function for internal use.
*/
void coex_deinit(void);
/**
* @brief Pause software coexist
* extern function for internal use.
*/
void coex_pause(void);
/**
* @brief Resume software coexist
* extern function for internal use.
*/
void coex_resume(void);
/**
* @brief Get software coexist version string
* extern function for internal use.
* @return : version string
*/
const char *coex_version_get(void);
/**
* @brief Coexist performance preference set from libbt.a
* extern function for internal use.
*
* @param prefer : the prefer enumeration value
* @return : ESP_OK - success, other - failed
*/
esp_err_t coex_preference_set(coex_prefer_t prefer);
/**
* @brief Get software coexist status.
* @return : software coexist status
*/
uint32_t coex_status_get(void);
/**
* @brief WiFi requests coexistence.
*
* @param event : WiFi event
* @param latency : WiFi will request coexistence after latency
* @param duration : duration for WiFi to request coexistence
* @return : 0 - success, other - failed
*/
int coex_wifi_request(uint32_t event, uint32_t latency, uint32_t duration);
/**
* @brief WiFi release coexistence.
*
* @param event : WiFi event
* @return : 0 - success, other - failed
*/
int coex_wifi_release(uint32_t event);
/**
* @brief Blue tooth requests coexistence.
*
* @param event : blue tooth event
* @param latency : blue tooth will request coexistence after latency
* @param duration : duration for blue tooth to request coexistence
* @return : 0 - success, other - failed
*/
int coex_bt_request(uint32_t event, uint32_t latency, uint32_t duration);
/**
* @brief Blue tooth release coexistence.
*
* @param event : blue tooth event
* @return : 0 - success, other - failed
*/
int coex_bt_release(uint32_t event);
/**
* @brief Register callback function for blue tooth.
*
* @param cb : callback function
* @return : 0 - success, other - failed
*/
int coex_register_bt_cb(coex_func_cb_t cb);
/**
* @brief Lock before reset base band.
*
* @return : lock value
*/
uint32_t coex_bb_reset_lock(void);
/**
* @brief Unlock after reset base band.
*
* @param restore : lock value
*/
void coex_bb_reset_unlock(uint32_t restore);
/**
* @brief Register coexistence adapter functions.
*
* @param funcs : coexistence adapter functions
* @return : ESP_OK - success, other - failed
*/
esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs);
/**
* @brief Check the MD5 values of the coexistence adapter header files in IDF and WiFi library
*
* @attention 1. It is used for internal CI version check
*
* @return
* - ESP_OK : succeed
* - ESP_WIFI_INVALID_ARG : MD5 check fail
*/
esp_err_t esp_coex_adapter_funcs_md5_check(const char *md5);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_COEXIST_INTERNAL_H__ */

View File

@ -110,6 +110,7 @@ typedef struct {
int rx_ba_win; /**< WiFi Block Ack RX window size */
int wifi_task_core_id; /**< WiFi Task Core ID */
int beacon_max_len; /**< WiFi softAP maximum length of the beacon */
int mgmt_sbuf_num; /**< WiFi management short buffer number, the minimum value is 6, the maximum value is 32 */
int magic; /**< WiFi init magic number, it should be the last field */
} wifi_init_config_t;
@ -183,6 +184,12 @@ extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs;
#define WIFI_SOFTAP_BEACON_MAX_LEN 752
#endif
#ifdef CONFIG_ESP32_WIFI_MGMT_SBUF_NUM
#define WIFI_MGMT_SBUF_NUM CONFIG_ESP32_WIFI_MGMT_SBUF_NUM
#else
#define WIFI_MGMT_SBUF_NUM 32
#endif
#define WIFI_INIT_CONFIG_DEFAULT() { \
.event_handler = &esp_event_send, \
.osi_funcs = &g_wifi_osi_funcs, \
@ -201,6 +208,7 @@ extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs;
.rx_ba_win = WIFI_DEFAULT_RX_BA_WIN,\
.wifi_task_core_id = WIFI_TASK_CORE_ID,\
.beacon_max_len = WIFI_SOFTAP_BEACON_MAX_LEN, \
.mgmt_sbuf_num = WIFI_MGMT_SBUF_NUM, \
.magic = WIFI_INIT_CONFIG_MAGIC\
};
@ -1094,6 +1102,19 @@ esp_err_t esp_wifi_set_ant(const wifi_ant_config_t *config);
*/
esp_err_t esp_wifi_get_ant(wifi_ant_config_t *config);
/**
* @brief A general API to set/get WiFi internal configuration, it's for debug only
*
* @param cmd : ioctl command type
* @param cfg : configuration for the command
*
* @return
* - ESP_OK: succeed
* - others: failed
*/
esp_err_t esp_wifi_internal_ioctl(int cmd, wifi_ioctl_config_t *cfg);
#ifdef __cplusplus
}
#endif

View File

@ -215,6 +215,15 @@ void *wifi_realloc( void *ptr, size_t size );
*/
void *wifi_calloc( size_t n, size_t size );
/**
* @brief Update WiFi MAC time
*
* @param uint32_t time_delta : time duration since the WiFi/BT common clock is disabled
*
* @return Always returns ESP_OK
*/
typedef esp_err_t (* wifi_mac_time_update_cb_t)( uint32_t time_delta );
/**
* @brief Update WiFi MAC time
*

View File

@ -21,7 +21,7 @@
extern "C" {
#endif
#define ESP_WIFI_OS_ADAPTER_VERSION 0x00000001
#define ESP_WIFI_OS_ADAPTER_VERSION 0x00000002
#define ESP_WIFI_OS_ADAPTER_MAGIC 0xDEADBEAF
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
@ -39,12 +39,9 @@ typedef struct {
void (* _spin_lock_delete)(void *lock);
uint32_t (*_wifi_int_disable)(void *wifi_int_mux);
void (*_wifi_int_restore)(void *wifi_int_mux, uint32_t tmp);
void (*_task_yield)(void);
void (*_task_yield_from_isr)(void);
void *(*_semphr_create)(uint32_t max, uint32_t init);
void (*_semphr_delete)(void *semphr);
int32_t (*_semphr_take_from_isr)(void *semphr, void *hptw);
int32_t (*_semphr_give_from_isr)(void *semphr, void *hptw);
int32_t (*_semphr_take)(void *semphr, uint32_t block_time_tick);
int32_t (*_semphr_give)(void *semphr);
void *(*_mutex_create)(void);
@ -59,7 +56,6 @@ typedef struct {
int32_t (* _queue_send_to_back)(void *queue, void *item, uint32_t block_time_tick);
int32_t (* _queue_send_to_front)(void *queue, void *item, uint32_t block_time_tick);
int32_t (* _queue_recv)(void *queue, void *item, uint32_t block_time_tick);
int32_t (* _queue_recv_from_isr)(void *queue, void * const item, int32_t * const hptw);
uint32_t (* _queue_msg_waiting)(void *queue);
void *(* _event_group_create)(void);
void (* _event_group_delete)(void *event);
@ -73,19 +69,15 @@ typedef struct {
int32_t (* _task_ms_to_tick)(uint32_t ms);
void *(* _task_get_current_task)(void);
int32_t (* _task_get_max_priority)(void);
int32_t (* _is_in_isr)(void);
void *(* _malloc)(uint32_t size);
void (* _free)(void *p);
uint32_t (* _get_free_heap_size)(void);
uint32_t (* _rand)(void);
void (* _dport_access_stall_other_cpu_start_wrap)(void);
void (* _dport_access_stall_other_cpu_end_wrap)(void);
int32_t (* _phy_rf_init)(const void * init_data, uint32_t mode, void * calibration_data, uint32_t module);
int32_t (* _phy_rf_deinit)(uint32_t module);
void (* _phy_load_cal_and_init)(uint32_t module);
int32_t (* _read_mac)(uint8_t* mac, uint32_t type);
void (* _timer_init)(void);
void (* _timer_deinit)(void);
void (* _timer_arm)(void *timer, uint32_t tmout, bool repeat);
void (* _timer_disarm)(void *timer);
void (* _timer_done)(void *ptimer);
@ -127,6 +119,9 @@ typedef struct {
int32_t (* _modem_sleep_deregister)(uint32_t module);
void (* _sc_ack_send)(void *param);
void (* _sc_ack_send_stop)(void);
uint32_t (* _coex_status_get)(void);
int32_t (* _coex_wifi_request)(uint32_t event, uint32_t latency, uint32_t duration);
int32_t (* _coex_wifi_release)(uint32_t event);
int32_t _magic;
} wifi_osi_funcs_t;

View File

@ -93,6 +93,7 @@ typedef enum {
WIFI_REASON_AUTH_FAIL = 202,
WIFI_REASON_ASSOC_FAIL = 203,
WIFI_REASON_HANDSHAKE_TIMEOUT = 204,
WIFI_REASON_CONNECTION_FAIL = 205,
} wifi_err_reason_t;
typedef enum {
@ -491,6 +492,34 @@ typedef enum {
WIFI_PHY_RATE_MAX,
} wifi_phy_rate_t;
/**
* @brief WiFi ioctl command type
*
*/
typedef enum {
WIFI_IOCTL_SET_STA_HT2040_COEX = 1, /**< Set the configuration of STA's HT2040 coexist management */
WIFI_IOCTL_GET_STA_HT2040_COEX, /**< Get the configuration of STA's HT2040 coexist management */
WIFI_IOCTL_MAX,
} wifi_ioctl_cmd_t;
/**
* @brief Configuration for STA's HT2040 coexist management
*
*/
typedef struct {
int enable; /**< Indicate whether STA's HT2040 coexist management is enabled or not */
} wifi_ht2040_coex_t;
/**
* @brief Configuration for WiFi ioctl
*
*/
typedef struct {
union {
wifi_ht2040_coex_t ht2040_coex; /**< Configuration of STA's HT2040 coexist management */
} data; /**< Configuration of ioctl command */
} wifi_ioctl_config_t;
#ifdef __cplusplus
}
#endif

View File

@ -115,6 +115,7 @@ typedef struct {
int buffer_size; /*!< HTTP buffer size (both send and receive) */
void *user_data; /*!< HTTP user_data context */
bool is_async; /*!< Set asynchronous mode, only supported with HTTPS for now */
bool use_global_ca_store; /*!< Use a global ca_store for all the connections in which this bool is set. */
} esp_http_client_config_t;
@ -373,6 +374,18 @@ esp_err_t esp_http_client_cleanup(esp_http_client_handle_t client);
*/
esp_http_client_transport_t esp_http_client_get_transport_type(esp_http_client_handle_t client);
/**
* @brief Set redirection URL.
* When received the 30x code from the server, the client stores the redirect URL provided by the server.
* This function will set the current URL to redirect to enable client to execute the redirection request.
*
* @param[in] client The esp_http_client handle
*
* @return
* - ESP_OK
* - ESP_FAIL
*/
esp_err_t esp_http_client_set_redirection(esp_http_client_handle_t client);
#ifdef __cplusplus
}

View File

@ -30,3 +30,6 @@
// events dispatched per second by event loop library
#define IDF_PERFORMANCE_MIN_EVENT_DISPATCH 25000
#define IDF_PERFORMANCE_MIN_EVENT_DISPATCH_PSRAM 21000
// esp_sha() time to process 32KB of input data from RAM
#define IDF_PERFORMANCE_MAX_ESP32_TIME_SHA1_32KB 5000
#define IDF_PERFORMANCE_MAX_ESP32_TIME_SHA512_32KB 4500

View File

@ -1,4 +1,4 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -11,22 +11,38 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _ESP_PLATFORM_SYS_POLL_H_
#define _ESP_PLATFORM_SYS_POLL_H_
#define POLLIN 0x0001 /* any readable data available */
#define POLLOUT 0x0004 /* file descriptor is writeable */
#define POLLPRI 0x0002 /* OOB/Urgent readable data */
#define POLLERR 0x0008 /* some poll error occurred */
#define POLLHUP 0x0010 /* file descriptor was "hung up" */
#define POLLIN (1u << 0) /* data other than high-priority may be read without blocking */
#define POLLRDNORM (1u << 1) /* normal data may be read without blocking */
#define POLLRDBAND (1u << 2) /* priority data may be read without blocking */
#define POLLPRI (POLLRDBAND) /* high-priority data may be read without blocking */
// Note: POLLPRI is made equivalent to POLLRDBAND in order to fit all these events into one byte
#define POLLOUT (1u << 3) /* normal data may be written without blocking */
#define POLLWRNORM (POLLOUT) /* equivalent to POLLOUT */
#define POLLWRBAND (1u << 4) /* priority data my be written */
#define POLLERR (1u << 5) /* some poll error occurred */
#define POLLHUP (1u << 6) /* file descriptor was "hung up" */
#define POLLNVAL (1u << 7) /* the specified file descriptor is invalid */
#ifdef __cplusplus
extern "C" {
#endif
struct pollfd {
int fd; /* The descriptor. */
short events; /* The event(s) is/are specified here. */
short revents; /* Events found are returned here. */
int fd; /* The descriptor. */
short events; /* The event(s) is/are specified here. */
short revents; /* Events found are returned here. */
};
typedef unsigned int nfds_t;
int poll(struct pollfd *fds, nfds_t nfds, int timeout);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // _ESP_PLATFORM_SYS_POLL_H_

View File

@ -17,11 +17,11 @@
#include "soc.h"
#define EFUSE_BLK0_RDATA0_REG (DR_REG_EFUSE_BASE + 0x000)
/* EFUSE_RD_FLASH_CRYPT_CNT : RO ;bitpos:[27:20] ;default: 8'b0 ; */
/* EFUSE_RD_FLASH_CRYPT_CNT : RO ;bitpos:[26:20] ;default: 7'b0 ; */
/*description: read for flash_crypt_cnt*/
#define EFUSE_RD_FLASH_CRYPT_CNT 0x000000FF
#define EFUSE_RD_FLASH_CRYPT_CNT 0x0000007F
#define EFUSE_RD_FLASH_CRYPT_CNT_M ((EFUSE_RD_FLASH_CRYPT_CNT_V)<<(EFUSE_RD_FLASH_CRYPT_CNT_S))
#define EFUSE_RD_FLASH_CRYPT_CNT_V 0xFF
#define EFUSE_RD_FLASH_CRYPT_CNT_V 0x7F
#define EFUSE_RD_FLASH_CRYPT_CNT_S 20
/* EFUSE_RD_EFUSE_RD_DIS : RO ;bitpos:[19:16] ;default: 4'b0 ; */
/*description: read for efuse_rd_disable*/
@ -302,11 +302,11 @@
#define EFUSE_CODING_SCHEME_VAL_34 0x1
#define EFUSE_BLK0_WDATA0_REG (DR_REG_EFUSE_BASE + 0x01c)
/* EFUSE_FLASH_CRYPT_CNT : R/W ;bitpos:[27:20] ;default: 8'b0 ; */
/* EFUSE_FLASH_CRYPT_CNT : R/W ;bitpos:[26:20] ;default: 7'b0 ; */
/*description: program for flash_crypt_cnt*/
#define EFUSE_FLASH_CRYPT_CNT 0x000000FF
#define EFUSE_FLASH_CRYPT_CNT 0x0000007F
#define EFUSE_FLASH_CRYPT_CNT_M ((EFUSE_FLASH_CRYPT_CNT_V)<<(EFUSE_FLASH_CRYPT_CNT_S))
#define EFUSE_FLASH_CRYPT_CNT_V 0xFF
#define EFUSE_FLASH_CRYPT_CNT_V 0x7F
#define EFUSE_FLASH_CRYPT_CNT_S 20
/* EFUSE_RD_DIS : R/W ;bitpos:[19:16] ;default: 4'b0 ; */
/*description: program for efuse_rd_disable*/

View File

@ -40,6 +40,13 @@ esp_transport_handle_t esp_transport_ssl_init();
*/
void esp_transport_ssl_set_cert_data(esp_transport_handle_t t, const char *data, int len);
/**
* @brief Enable global CA store for SSL connection
*
* @param t ssl transport
*/
void esp_transport_ssl_enable_global_ca_store(esp_transport_handle_t t);
/**
* @brief Set SSL client certificate data for mutual authentication (as PEM format).
* Note that, this function stores the pointer to data, rather than making a copy.

View File

@ -1,4 +1,4 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -27,6 +27,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/termios.h>
#include <sys/poll.h>
#include <dirent.h>
#include <string.h>
#include "sdkconfig.h"
@ -379,6 +380,22 @@ void esp_vfs_select_triggered(SemaphoreHandle_t *signal_sem);
*/
void esp_vfs_select_triggered_isr(SemaphoreHandle_t *signal_sem, BaseType_t *woken);
/**
* @brief Implements the VFS layer for synchronous I/O multiplexing by poll()
*
* The implementation is based on esp_vfs_select. The parameters and return values are compatible with POSIX poll().
*
* @param fds Pointer to the array containing file descriptors and events poll() should consider.
* @param nfds Number of items in the array fds.
* @param timeout Poll() should wait at least timeout milliseconds. If the value is 0 then it should return
* immediately. If the value is -1 then it should wait (block) until the event occurs.
*
* @return A positive return value indicates the number of file descriptors that have been selected. The 0
* return value indicates a timed-out poll. -1 is return on failure and errno is set accordingly.
*
*/
int esp_vfs_poll(struct pollfd *fds, nfds_t nfds, int timeout);
#ifdef __cplusplus
} // extern "C"
#endif

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
tools/sdk/lib/libbtdm_app.a Executable file → Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More