diff --git a/Kconfig b/Kconfig.projbuild similarity index 82% rename from Kconfig rename to Kconfig.projbuild index 67f31c68aa7..25cbe107951 100644 --- a/Kconfig +++ b/Kconfig.projbuild @@ -78,6 +78,27 @@ config ARDUHAL_ESP_LOG endmenu +choice ARDUHAL_PARTITION_SCHEME + bool "Used partition scheme" + default ARDUHAL_PARTITION_SCHEME_DEFAULT + help + Specify which partition scheme to be used. + +config ARDUHAL_PARTITION_SCHEME_DEFAULT + bool "Default" +config ARDUHAL_PARTITION_SCHEME_MINIMAL + bool "Minimal (for 2MB FLASH)" +config ARDUHAL_PARTITION_SCHEME_NO_OTA + bool "No OTA (for large apps)" +endchoice + +config ARDUHAL_PARTITION_SCHEME + string + default "default" if ARDUHAL_PARTITION_SCHEME_DEFAULT + default "minimal" if ARDUHAL_PARTITION_SCHEME_MINIMAL + default "no_ota" if ARDUHAL_PARTITION_SCHEME_NO_OTA + + config AUTOCONNECT_WIFI bool "Autoconnect WiFi on boot" default "n" diff --git a/Makefile.projbuild b/Makefile.projbuild index 7aa9b39b4f4..e21d4c77b93 100644 --- a/Makefile.projbuild +++ b/Makefile.projbuild @@ -3,7 +3,7 @@ BOOT_APP_BIN_ROOT := $(call dequote,$(COMPONENT_PATH)) BOOT_APP_BIN_PATH := $(call dequote,$(abspath $(BOOT_APP_BIN_ROOT)/$(subst $(quote),,tools/partitions/boot_app0.bin))) ifndef CONFIG_PARTITION_TABLE_CUSTOM -PARTITION_TABLE_CSV_PATH = $(call dequote,$(abspath $(BOOT_APP_BIN_ROOT)/$(subst $(quote),,tools/partitions/default.csv))) +PARTITION_TABLE_CSV_PATH = $(call dequote,$(abspath $(BOOT_APP_BIN_ROOT)/$(subst $(quote),,tools/partitions/$(CONFIG_ARDUHAL_PARTITION_SCHEME).csv))) endif BOOT_APP_BIN_FLASH_CMD = $(ESPTOOLPY_SERIAL) write_flash $(BOOT_APP_BIN_OFFSET) $(BOOT_APP_BIN_PATH) diff --git a/boards.txt b/boards.txt index c0bd280613a..010d624b5b6 100644 --- a/boards.txt +++ b/boards.txt @@ -2,6 +2,7 @@ menu.UploadSpeed=Upload Speed menu.FlashFreq=Flash Frequency menu.FlashMode=Flash Mode menu.FlashSize=Flash Size +menu.PartitionScheme=Partition Scheme menu.DebugLevel=Core Debug Level ############################################################## @@ -28,6 +29,13 @@ esp32.build.flash_mode=dio esp32.build.boot=dio esp32.build.partitions=default +esp32.menu.PartitionScheme.default=Default +esp32.menu.PartitionScheme.default.build.partitions=default +esp32.menu.PartitionScheme.minimal=Minimal (2MB FLASH) +esp32.menu.PartitionScheme.minimal.build.partitions=minimal +esp32.menu.PartitionScheme.no_ota=No OTA (Large APP) +esp32.menu.PartitionScheme.no_ota.build.partitions=no_ota + esp32.menu.FlashMode.qio=QIO esp32.menu.FlashMode.qio.build.flash_mode=dio esp32.menu.FlashMode.qio.build.boot=qio diff --git a/libraries/BLE b/libraries/BLE index 6bad7b42a96..af865a91679 160000 --- a/libraries/BLE +++ b/libraries/BLE @@ -1 +1 @@ -Subproject commit 6bad7b42a96f0aa493323ef4821a8efb0e8815f2 +Subproject commit af865a916795289c8e7e09b091ff2140c33fc3fe diff --git a/libraries/BluetoothSerial/src/BluetoothSerial.cpp b/libraries/BluetoothSerial/src/BluetoothSerial.cpp index 6c7d9c3c350..321eb7318dd 100644 --- a/libraries/BluetoothSerial/src/BluetoothSerial.cpp +++ b/libraries/BluetoothSerial/src/BluetoothSerial.cpp @@ -13,6 +13,13 @@ // limitations under the License. #include "sdkconfig.h" +#include +#include +#include +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED) diff --git a/libraries/BluetoothSerial/src/BluetoothSerial.h b/libraries/BluetoothSerial/src/BluetoothSerial.h index 128bcfb3bc9..adf6df66e13 100644 --- a/libraries/BluetoothSerial/src/BluetoothSerial.h +++ b/libraries/BluetoothSerial/src/BluetoothSerial.h @@ -19,14 +19,6 @@ #if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED) -#include -#include -#include -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "esp_bt.h" - #include "Arduino.h" #include "Stream.h" diff --git a/package/package_esp32_index.template.json b/package/package_esp32_index.template.json index 526f0fe464c..d68918f1257 100644 --- a/package/package_esp32_index.template.json +++ b/package/package_esp32_index.template.json @@ -38,7 +38,7 @@ { "packager": "esp32", "name": "esptool", - "version": "4dab24e" + "version": "da31d9d" }, { "packager": "esp32", @@ -85,21 +85,21 @@ }, { "name": "esptool", - "version": "4dab24e", + "version": "da31d9d", "systems": [ { "host": "i686-mingw32", - "url": "https://dl.espressif.com/dl/esptool-4dab24e-windows.zip", - "archiveFileName": "esptool-4dab24e-windows.zip", - "checksum": "SHA-256:604014edbd79616470ecda20d623bac3a8d916b1147d37f7a66a83959eff066c", - "size": "3462819" + "url": "https://dl.espressif.com/dl/esptool-da31d9d-windows.zip", + "archiveFileName": "esptool-da31d9d-windows.zip", + "checksum": "SHA-256:6476f4d6e33a59167dea364e177d97167316253d2c9ac75f81b469ecb3ed3875", + "size": "3395925" }, { "host": "x86_64-apple-darwin", - "url": "https://dl.espressif.com/dl/esptool-4dab24e-macos.tar.gz", - "archiveFileName": "esptool-4dab24e-macos.tar.gz", - "checksum": "SHA-256:92fe2f0505ed93051681bd4d5d766664eacfa32745976dda695c728b529dcc8f", - "size": "3869525" + "url": "https://dl.espressif.com/dl/esptool-da31d9d-macos.tar.gz", + "archiveFileName": "esptool-da31d9d-macos.tar.gz", + "checksum": "SHA-256:76d53298366a294235356bb8d197a81b2afbfd62642851bfbaee252cc593faa9", + "size": "3810904" } ] }, diff --git a/platform.txt b/platform.txt index 9fd4407617b..974cabf6128 100644 --- a/platform.txt +++ b/platform.txt @@ -35,7 +35,7 @@ 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 -lhal -lnewlib -ldriver -lbootloader_support -lpp -lsmartconfig -ljsmn -lwpa -lethernet -lphy -lapp_trace -lconsole -lulp -lwpa_supplicant -lfreertos -lbt -lmicro-ecc -lcxx -lxtensa-debug-module -lmdns -lvfs -lsoc -lcore -lsdmmc -lcoap -ltcpip_adapter -lc_nano -lrtc -lspi_flash -lwpa2 -lesp32 -lapp_update -lnghttp -lspiffs -lespnow -lnvs_flash -lesp_adc_cal -llog -lexpat -lm -lc -lheap -lmbedtls -llwip -lnet80211 -lpthread -ljson -lstdc++ +compiler.c.elf.libs=-lgcc -lopenssl -lbtdm_app -lfatfs -lwps -lcoexist -lwear_levelling -lhal -lnewlib -ldriver -lbootloader_support -lpp -lmesh -lsmartconfig -ljsmn -lwpa -lethernet -lphy -lapp_trace -lconsole -lulp -lwpa_supplicant -lfreertos -lbt -lmicro-ecc -lcxx -lxtensa-debug-module -lmdns -lvfs -lsoc -lcore -lsdmmc -lcoap -ltcpip_adapter -lc_nano -lrtc -lspi_flash -lwpa2 -lesp32 -lapp_update -lnghttp -lspiffs -lespnow -lnvs_flash -lesp_adc_cal -llog -lexpat -lm -lc -lheap -lmbedtls -llwip -lnet80211 -lpthread -ljson -lstdc++ compiler.as.cmd=xtensa-esp32-elf-as diff --git a/tools/esptool.py b/tools/esptool.py index c65c6bfac1b..36f95002c77 100755 --- a/tools/esptool.py +++ b/tools/esptool.py @@ -16,31 +16,43 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 Franklin # Street, Fifth Floor, Boston, MA 02110-1301 USA. -from __future__ import print_function, division +from __future__ import division, print_function import argparse +import base64 +import copy import hashlib import inspect +import io import os -import serial +import shlex import struct import sys import time -import base64 import zlib -import shlex -import copy -import io -__version__ = "2.1" +import serial + +__version__ = "2.3.1" MAX_UINT32 = 0xffffffff MAX_UINT24 = 0xffffff -DEFAULT_TIMEOUT = 3 # timeout for most flash operations -START_FLASH_TIMEOUT = 20 # timeout for starting flash (may perform erase) -CHIP_ERASE_TIMEOUT = 120 # timeout for full chip erase -SYNC_TIMEOUT = 0.1 # timeout for syncing with bootloader +DEFAULT_TIMEOUT = 3 # timeout for most flash operations +START_FLASH_TIMEOUT = 20 # timeout for starting flash (may perform erase) +CHIP_ERASE_TIMEOUT = 120 # timeout for full chip erase +MAX_TIMEOUT = CHIP_ERASE_TIMEOUT * 2 # longest any command can run +SYNC_TIMEOUT = 0.1 # timeout for syncing with bootloader +MD5_TIMEOUT_PER_MB = 8 # timeout (per megabyte) for calculating md5sum +ERASE_REGION_TIMEOUT_PER_MB = 30 # timeout (per megabyte) for erasing a region + + +def timeout_per_mb(seconds_per_mb, size_bytes): + """ Scales timeouts which are size-specific """ + result = seconds_per_mb * (size_bytes / 1e6) + if result < DEFAULT_TIMEOUT: + return DEFAULT_TIMEOUT + return result DETECTED_FLASH_SIZES = {0x12: '256KB', 0x13: '512KB', 0x14: '1MB', @@ -87,6 +99,12 @@ def byte(bitstr, index): def byte(bitstr, index): return bitstr[index] +# Provide a 'basestring' class on Python 3 +try: + basestring +except NameError: + basestring = str + def esp8266_function_only(func): """ Attribute for a function only supported on ESP8266 """ @@ -159,7 +177,7 @@ class ESPLoader(object): # The number of bytes in the UART response that signify command status STATUS_BYTES_LENGTH = 2 - def __init__(self, port=DEFAULT_PORT, baud=ESP_ROM_BAUD): + def __init__(self, port=DEFAULT_PORT, baud=ESP_ROM_BAUD, trace_enabled=False): """Base constructor for ESPLoader bootloader interaction Don't call this constructor, either instantiate ESP8266ROM @@ -171,16 +189,17 @@ def __init__(self, port=DEFAULT_PORT, baud=ESP_ROM_BAUD): with ones which throw NotImplementedInROMError(). """ - if isinstance(port, serial.Serial): - self._port = port - else: + if isinstance(port, basestring): self._port = serial.serial_for_url(port) - self._slip_reader = slip_reader(self._port) + else: + self._port = port + self._slip_reader = slip_reader(self._port, self.trace) # setting baud rate in a separate step is a workaround for # CH341 driver on some Linux versions (this opens at 9600 then # sets), shouldn't matter for other platforms/drivers. See # https://github.com/espressif/esptool/issues/44#issuecomment-107094446 self._set_port_baudrate(baud) + self._trace_enabled = trace_enabled def _set_port_baudrate(self, baud): try: @@ -189,7 +208,7 @@ def _set_port_baudrate(self, baud): raise FatalError("Failed to set baud rate %d. The driver may not support this rate." % baud) @staticmethod - def detect_chip(port=DEFAULT_PORT, baud=ESP_ROM_BAUD, connect_mode='default_reset'): + def detect_chip(port=DEFAULT_PORT, baud=ESP_ROM_BAUD, connect_mode='default_reset', trace_enabled=False): """ Use serial access to detect the chip type. We use the UART's datecode register for this, it's mapped at @@ -200,7 +219,7 @@ def detect_chip(port=DEFAULT_PORT, baud=ESP_ROM_BAUD, connect_mode='default_rese This routine automatically performs ESPLoader.connect() (passing connect_mode parameter) as part of querying the chip. """ - detect_port = ESPLoader(port, baud) + detect_port = ESPLoader(port, baud, trace_enabled=trace_enabled) detect_port.connect(connect_mode) print('Detecting chip type...', end='') sys.stdout.flush() @@ -209,7 +228,7 @@ def detect_chip(port=DEFAULT_PORT, baud=ESP_ROM_BAUD, connect_mode='default_rese for cls in [ESP8266ROM, ESP32ROM]: if date_reg == cls.DATE_REG_VALUE: # don't connect a second time - inst = cls(detect_port._port, baud) + inst = cls(detect_port._port, baud, trace_enabled=trace_enabled) print(' %s' % inst.CHIP_NAME) return inst print('') @@ -224,8 +243,21 @@ def write(self, packet): buf = b'\xc0' \ + (packet.replace(b'\xdb',b'\xdb\xdd').replace(b'\xc0',b'\xdb\xdc')) \ + b'\xc0' + self.trace("Write %d bytes: %r", len(buf), buf) self._port.write(buf) + def trace(self, message, *format_args): + if self._trace_enabled: + now = time.time() + try: + + delta = now - self._last_trace + except AttributeError: + delta = 0.0 + self._last_trace = now + prefix = "TRACE +%.3f " % delta + print(prefix + (message % format_args)) + """ Calculate checksum of a blob, as it is defined by the ROM """ @staticmethod def checksum(data, state=ESP_CHECKSUM_MAGIC): @@ -238,39 +270,50 @@ def checksum(data, state=ESP_CHECKSUM_MAGIC): return state """ Send a request and read the response """ - def command(self, op=None, data=b"", chk=0, wait_response=True): - if op is not None: - pkt = struct.pack(b'> 12) & 0xF - pkg_version = (blk3 >> 9) & 0x07 + word3 = self.read_efuse(3) + chip_version = (word3 >> 12) & 0xF + pkg_version = (word3 >> 9) & 0x07 silicon_rev = { - 0: "0", - 8: "1" + 0x0: "0", + 0x8: "1", + 0xc: "1", # Silicon rev 1 w/ BLK3_PART_RESERVE bit set }.get(chip_version, "(unknown 0x%x)" % chip_version) chip_name = { 0: "ESP32D0WDQ6", 1: "ESP32D0WDQ5", 2: "ESP32D2WDQ5", + 5: "ESP32-PICO-D4", }.get(pkg_version, "unknown ESP32") return "%s (revision %s)" % (chip_name, silicon_rev) + def get_chip_features(self): + features = ["WiFi"] + word3 = self.read_efuse(3) + + if word3 & (1 << 1) == 0: # RD_CHIP_VER_DIS_BT + features += ["BT"] + + if word3 & (1 << 0): # RD_CHIP_VER_DIS_APP_CPU + features += ["Single Core"] + else: + features += ["Dual Core"] + + pkg_version = (word3 >> 9) & 0x07 + if pkg_version != 0: + features += ["Embedded Flash"] + + word4 = self.read_efuse(4) + vref = (word4 >> 8) & 0x1F + if vref != 0: + features += ["VRef calibration in efuse"] + + return features + def read_efuse(self, n): """ Read the nth word of the ESP3x EFUSE region. """ return self.read_reg(self.EFUSE_REG_BASE + (4 * n)) @@ -987,6 +1077,7 @@ class ESP32StubLoader(ESP32ROM): def __init__(self, rom_loader): self._port = rom_loader._port + self._trace_enabled = rom_loader._trace_enabled self.flush_input() # resets _slip_reader @@ -1546,7 +1637,7 @@ def read_data(offs,size): self.sections = prog_sections -def slip_reader(port): +def slip_reader(port, trace_function): """Generator to read SLIP packets from a serial port. Yields one full SLIP packet at a time, raises exception on timeout or invalid data. @@ -1559,9 +1650,11 @@ def slip_reader(port): waiting = port.inWaiting() read_bytes = port.read(1 if waiting == 0 else waiting) if read_bytes == b'': - raise FatalError("Timed out waiting for packet %s" % ("header" if partial_packet is None else "content")) + waiting_for = "header" if partial_packet is None else "content" + trace_function("Timed out waiting for packet %s", waiting_for) + raise FatalError("Timed out waiting for packet %s" % waiting_for) + trace_function("Read %d bytes: %r", len(read_bytes), read_bytes) for b in read_bytes: - if type(b) is int: b = bytes([b]) # python 2/3 compat @@ -1569,6 +1662,8 @@ def slip_reader(port): if b == b'\xc0': partial_packet = b"" else: + trace_function("Read invalid data: %r", read_bytes) + trace_function("Remaining data in serial buffer: %r", port.read(port.inWaiting())) raise FatalError('Invalid head of packet (%r)' % b) elif in_escape: # part-way through escape sequence in_escape = False @@ -1577,10 +1672,13 @@ def slip_reader(port): elif b == b'\xdd': partial_packet += b'\xdb' else: + trace_function("Read invalid data: %r", read_bytes) + trace_function("Remaining data in serial buffer: %r", port.read(port.inWaiting())) raise FatalError('Invalid SLIP escape (%r%r)' % (b'\xdb', b)) elif b == b'\xdb': # start of escape sequence in_escape = True elif b == b'\xc0': # end of packet + trace_function("Full packet: %r", partial_packet) yield partial_packet partial_packet = None else: # normal byte in packet @@ -1781,6 +1879,9 @@ def write_flash(esp, args): if args.no_stub: print('Erasing flash...') image = pad_to(argfile.read(), 4) + if len(image) == 0: + print('WARNING: File %s is empty' % argfile.name) + continue image = _update_image_flash_params(esp, address, args, image) calcmd5 = hashlib.md5(image).hexdigest() uncsize = len(image) @@ -1796,14 +1897,12 @@ def write_flash(esp, args): seq = 0 written = 0 t = time.time() - esp._port.timeout = min(DEFAULT_TIMEOUT * ratio, - CHIP_ERASE_TIMEOUT * 2) while len(image) > 0: print('\rWriting at 0x%08x... (%d %%)' % (address + seq * esp.FLASH_WRITE_SIZE, 100 * (seq + 1) // blocks), end='') sys.stdout.flush() block = image[0:esp.FLASH_WRITE_SIZE] if args.compress: - esp.flash_defl_block(block, seq) + esp.flash_defl_block(block, seq, timeout=DEFAULT_TIMEOUT * ratio) else: # Pad the last block block = block + b'\xff' * (esp.FLASH_WRITE_SIZE - len(block)) @@ -1832,7 +1931,6 @@ def write_flash(esp, args): print('Hash of data verified.') except NotImplementedInROMError: pass - esp._port.timeout = DEFAULT_TIMEOUT print('\nLeaving...') @@ -1892,7 +1990,7 @@ def elf2image(args): e = ELFFile(args.input) if args.chip == 'auto': # Default to ESP8266 for backwards compatibility print("Creating image for ESP8266...") - args.chip == 'esp8266' + args.chip = 'esp8266' if args.chip == 'esp32': image = ESP32FirmwareImage() @@ -2064,6 +2162,11 @@ def main(): help="Disable launching the flasher stub, only talk to ROM bootloader. Some features will not be available.", action='store_true') + parser.add_argument( + '--trace', '-t', + help="Enable trace-level output of esptool.py interactions.", + action='store_true') + subparsers = parser.add_subparsers( dest='operation', help='Run esptool {command} -h for additional help') @@ -2233,21 +2336,29 @@ def add_spi_flash_subparsers(parent, is_elf2image): sys.exit(1) operation_func = globals()[args.operation] - operation_args,_,_,_ = inspect.getargspec(operation_func) + + if PYTHON2: + # This function is depreciated in Python3 + operation_args = inspect.getargspec(operation_func).args + else: + operation_args = inspect.getfullargspec(operation_func).args + if operation_args[0] == 'esp': # operation function takes an ESPLoader connection object initial_baud = min(ESPLoader.ESP_ROM_BAUD, args.baud) # don't sync faster than the default baud rate if args.chip == 'auto': - esp = ESPLoader.detect_chip(args.port, initial_baud, args.before) + esp = ESPLoader.detect_chip(args.port, initial_baud, args.before, args.trace) else: chip_class = { 'esp8266': ESP8266ROM, 'esp32': ESP32ROM, }[args.chip] - esp = chip_class(args.port, initial_baud) + esp = chip_class(args.port, initial_baud, args.trace) esp.connect(args.before) print("Chip is %s" % (esp.get_chip_description())) + print("Features: %s" % ", ".join(esp.get_chip_features())) + if not args.no_stub: esp = esp.run_stub() @@ -2277,7 +2388,7 @@ def add_spi_flash_subparsers(parent, is_elf2image): # finish execution based on args.after if args.after == 'hard_reset': - print('Hard resetting...') + print('Hard resetting via RTS pin...') esp.hard_reset() elif args.after == 'soft_reset': print('Soft resetting...') @@ -2371,7 +2482,7 @@ def __call__(self, parser, namespace, value, option_string=None): value = (hd << 24) | (cs << 18) | (d << 12) | (q << 6) | clk else: raise argparse.ArgumentError(self, '%s is not a valid spi-connection value. ' + - 'Values are SPI, HSPI, or a sequence of 5 pin numbers CLK,Q,D,HD,CS).' % values) + 'Values are SPI, HSPI, or a sequence of 5 pin numbers CLK,Q,D,HD,CS).' % value) setattr(namespace, self.dest, value) @@ -2413,102 +2524,104 @@ def __call__(self, parser, namespace, values, option_string=None): # Binary stub code (see flasher_stub dir for source & details) ESP8266ROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" -eNrNPWtj00a2f8VSQkhMaDWSrEcIxXaCSSlsA5QUet020kiCsoVNjHdDWfrfr85rZiQ7BNrt3vsh1CONZs6cc+a8Z/rv68v63fL63qC8Pn9XZPN3Kpi/C4Jx+4+av2sa+JsdwqPuX9b+NfWdb48mX7ffxe1fCV3v\ -tG81N+o71C1zPivbniqHWcbUk16c9iZQ638rpw+B5gCkuzPRDD2o7UfjtcuZv8v1DV5HEcivdtrrbvd/0hqCqLfyXkM+LzvY6SBksOPA1iI/qxCMZw5AQBPzdQ6N2mnkBtGx8wY+VqUdugjmix4yMgPCfCk/j9t/\ -aqehQmcI7YBRBk5DNWYR++3jnAEKXFCBOEXlQBc40AWdl5rmMvOokYMi1aV5EDishg2ZvQTWEkJnmdMobOMZfjXefYD/CW7hf94dGfa4z7/K+Gv+pfUX/Eu1E9QhN6osx18vzbN2kEpmzFvAauTi8YMtAYmH9NrR\ -K1pU3n5ZKGJy+ES1v3XgFxs+EpAWHBYH7dOwmLbjh8UE5iva4ZqwuENbpU5pNG1QBFNE8FARKyICAT3t7yBxNxiAFH7jpyEwI8+a6aEH/Q/uEjkC1TYL3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diff --git a/tools/gen_esp32part.exe b/tools/gen_esp32part.exe index c4db89310bc..495e2185366 100644 Binary files a/tools/gen_esp32part.exe and b/tools/gen_esp32part.exe differ diff --git a/tools/gen_esp32part.py b/tools/gen_esp32part.py index 897e637d079..a8607f360cc 100755 --- a/tools/gen_esp32part.py +++ b/tools/gen_esp32part.py @@ -26,12 +26,16 @@ import re import struct import sys +import hashlib +import binascii MAX_PARTITION_LENGTH = 0xC00 # 3K for partition data (96 entries) leaves 1K in a 4K sector for signature +MD5_PARTITION_BEGIN = b"\xEB\xEB" + b"\xFF" * 14 # The first 2 bytes are like magic numbers for MD5 sum __version__ = '1.0' quiet = False +md5sum = True def status(msg): """ Print status message to stderr """ @@ -112,6 +116,7 @@ def verify(self): @classmethod def from_binary(cls, b): + md5 = hashlib.md5(); result = cls() for o in range(0,len(b),32): data = b[o:o+32] @@ -119,11 +124,20 @@ def from_binary(cls, b): raise InputError("Partition table length must be a multiple of 32 bytes") if data == b'\xFF'*32: return result # got end marker + if md5sum and data[:2] == MD5_PARTITION_BEGIN[:2]: #check only the magic number part + if data[16:] == md5.digest(): + continue # the next iteration will check for the end marker + else: + raise InputError("MD5 checksums don't match! (computed: 0x%s, parsed: 0x%s)" % (md5.hexdigest(), binascii.hexlify(data[16:]))) + else: + md5.update(data) result.append(PartitionDefinition.from_binary(data)) raise InputError("Partition table is missing an end-of-table marker") def to_binary(self): result = b"".join(e.to_binary() for e in self) + if md5sum: + result += MD5_PARTITION_BEGIN + hashlib.md5(result).digest() if len(result )>= MAX_PARTITION_LENGTH: raise InputError("Binary partition table length (%d) longer than max" % len(result)) result += b"\xFF" * (MAX_PARTITION_LENGTH - len(result)) # pad the sector, for signing @@ -333,8 +347,10 @@ def parse_int(v, keywords={}): def main(): global quiet + global md5sum parser = argparse.ArgumentParser(description='ESP32 partition table utility') + parser.add_argument('--disable-md5sum', help='Disable md5 checksum for the partition table', default=False, action='store_true') parser.add_argument('--verify', '-v', help='Verify partition table fields', default=True, action='store_false') parser.add_argument('--quiet', '-q', help="Don't print status messages to stderr", action='store_true') @@ -346,6 +362,7 @@ def main(): args = parser.parse_args() quiet = args.quiet + md5sum = not args.disable_md5sum input = args.input.read() input_is_binary = input[0:2] == PartitionDefinition.MAGIC_BYTES if input_is_binary: diff --git a/tools/partitions/no_ota.csv b/tools/partitions/no_ota.csv new file mode 100644 index 00000000000..8b86c231979 --- /dev/null +++ b/tools/partitions/no_ota.csv @@ -0,0 +1,6 @@ +# Name, Type, SubType, Offset, Size, Flags +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, diff --git a/tools/platformio-build.py b/tools/platformio-build.py index bd038a8d86e..3bc9ebb58bb 100644 --- a/tools/platformio-build.py +++ b/tools/platformio-build.py @@ -49,7 +49,8 @@ "-Wno-error=unused-function", "-Wno-unused-parameter", "-Wno-sign-compare", - "-fstack-protector" + "-fstack-protector", + "-fexceptions" ], CPPPATH=[ @@ -98,7 +99,7 @@ join(FRAMEWORK_DIR, "tools", "sdk", "ld") ], LIBS=[ - "gcc", "openssl", "btdm_app", "fatfs", "wps", "coexist", "wear_levelling", "hal", "newlib", "driver", "bootloader_support", "pp", "smartconfig", "jsmn", "wpa", "ethernet", "phy", "app_trace", "console", "ulp", "wpa_supplicant", "freertos", "bt", "micro-ecc", "cxx", "xtensa-debug-module", "mdns", "vfs", "soc", "core", "sdmmc", "coap", "tcpip_adapter", "c_nano", "rtc", "spi_flash", "wpa2", "esp32", "app_update", "nghttp", "spiffs", "espnow", "nvs_flash", "esp_adc_cal", "log", "expat", "m", "c", "heap", "mbedtls", "lwip", "net80211", "pthread", "json", "stdc++" + "gcc", "openssl", "btdm_app", "fatfs", "wps", "coexist", "wear_levelling", "hal", "newlib", "driver", "bootloader_support", "pp", "mesh", "smartconfig", "jsmn", "wpa", "ethernet", "phy", "app_trace", "console", "ulp", "wpa_supplicant", "freertos", "bt", "micro-ecc", "cxx", "xtensa-debug-module", "mdns", "vfs", "soc", "core", "sdmmc", "coap", "tcpip_adapter", "c_nano", "rtc", "spi_flash", "wpa2", "esp32", "app_update", "nghttp", "spiffs", "espnow", "nvs_flash", "esp_adc_cal", "log", "expat", "m", "c", "heap", "mbedtls", "lwip", "net80211", "pthread", "json", "stdc++" ], UPLOADERFLAGS=[ diff --git a/tools/sdk/bin/bootloader_dio_40m.bin b/tools/sdk/bin/bootloader_dio_40m.bin index e537abfdeca..e01d6293d5b 100644 Binary files a/tools/sdk/bin/bootloader_dio_40m.bin and b/tools/sdk/bin/bootloader_dio_40m.bin differ diff --git a/tools/sdk/bin/bootloader_dio_80m.bin b/tools/sdk/bin/bootloader_dio_80m.bin index 7c64bdb595c..839f1cbf62b 100644 Binary files a/tools/sdk/bin/bootloader_dio_80m.bin and b/tools/sdk/bin/bootloader_dio_80m.bin differ diff --git a/tools/sdk/bin/bootloader_dout_40m.bin b/tools/sdk/bin/bootloader_dout_40m.bin index a056c96a5b8..36e77645903 100644 Binary files a/tools/sdk/bin/bootloader_dout_40m.bin and b/tools/sdk/bin/bootloader_dout_40m.bin differ diff --git a/tools/sdk/bin/bootloader_dout_80m.bin b/tools/sdk/bin/bootloader_dout_80m.bin index f179cecc7d2..bb3935c0e70 100644 Binary files a/tools/sdk/bin/bootloader_dout_80m.bin and b/tools/sdk/bin/bootloader_dout_80m.bin differ diff --git a/tools/sdk/bin/bootloader_qio_40m.bin b/tools/sdk/bin/bootloader_qio_40m.bin index fccc9abe88a..d9a082e1e5c 100644 Binary files a/tools/sdk/bin/bootloader_qio_40m.bin and b/tools/sdk/bin/bootloader_qio_40m.bin differ diff --git a/tools/sdk/bin/bootloader_qio_80m.bin b/tools/sdk/bin/bootloader_qio_80m.bin index bd461f51a9a..2fa85e2b49d 100644 Binary files a/tools/sdk/bin/bootloader_qio_80m.bin and b/tools/sdk/bin/bootloader_qio_80m.bin differ diff --git a/tools/sdk/bin/bootloader_qout_40m.bin b/tools/sdk/bin/bootloader_qout_40m.bin index 2d5a747c842..eb86753a055 100644 Binary files a/tools/sdk/bin/bootloader_qout_40m.bin and b/tools/sdk/bin/bootloader_qout_40m.bin differ diff --git a/tools/sdk/bin/bootloader_qout_80m.bin b/tools/sdk/bin/bootloader_qout_80m.bin index 7c64bdb595c..2fa85e2b49d 100644 Binary files a/tools/sdk/bin/bootloader_qout_80m.bin and b/tools/sdk/bin/bootloader_qout_80m.bin differ diff --git a/tools/sdk/include/bluedroid/a2d_api.h b/tools/sdk/include/bluedroid/a2d_api.h index 1b999d5c4fe..eaf6b37f140 100644 --- a/tools/sdk/include/bluedroid/a2d_api.h +++ b/tools/sdk/include/bluedroid/a2d_api.h @@ -251,5 +251,6 @@ extern UINT8 A2D_BitsSet(UINT8 num); ** *******************************************************************************/ extern void A2D_Init(void); +extern void A2D_Deinit(void); #endif ///A2D_INCLUDED #endif /* A2D_API_H */ diff --git a/tools/sdk/include/bluedroid/allocator.h b/tools/sdk/include/bluedroid/allocator.h index b217cef9a41..707901f43fd 100644 --- a/tools/sdk/include/bluedroid/allocator.h +++ b/tools/sdk/include/bluedroid/allocator.h @@ -21,6 +21,7 @@ #include #include +#include "esp_heap_caps.h" #include "sdkconfig.h" typedef void *(*alloc_fn)(size_t size); @@ -48,11 +49,13 @@ void osi_mem_dbg_record(void *p, int size, const char *func, int line); void osi_mem_dbg_clean(void *p, const char *func, int line); void osi_mem_dbg_show(void); +#if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST #define osi_malloc(size) \ ({ \ void *p; \ - \ - p = malloc((size)); \ + p = heap_caps_malloc_prefer(size, 2, \ + MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \ + MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \ osi_mem_dbg_record(p, size, __func__, __LINE__); \ (void *)p; \ }) @@ -60,12 +63,64 @@ void osi_mem_dbg_show(void); #define osi_calloc(size) \ ({ \ void *p; \ - \ + p = heap_caps_calloc_prefer(1, size, 2, \ + MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \ + MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \ + osi_mem_dbg_record(p, size, __func__, __LINE__); \ + (void *)p; \ +}) + +#else + +#define osi_malloc(size) \ +({ \ + void *p; \ + p = malloc((size)); \ + osi_mem_dbg_record(p, size, __func__, __LINE__); \ + (void *)p; \ +}) + +#define osi_calloc(size) \ +({ \ + void *p; \ p = calloc(1, (size)); \ osi_mem_dbg_record(p, size, __func__, __LINE__); \ (void *)p; \ }) +#endif /* #if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST */ + + +#if 0 +#define osi_malloc(size) \ +do { \ + void *p; \ + \ +#if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST \ + p = heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \ +#else \ + p = malloc((size)); \ +#endif /* #if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST */ \ + osi_mem_dbg_record(p, size, __func__, __LINE__); \ + (void *)p; \ +}while(0) + +#define osi_calloc(size) \ +do { \ + void *p; \ + \ +#if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST \ + p = heap_caps_calloc_prefer(1, size, 2, \ + MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \ + MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \ +#else \ + p = calloc(1, (size)); \ +#endif /* #if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST */ \ + osi_mem_dbg_record(p, size, __func__, __LINE__); \ + (void *)p; \ +} while(0) +#endif + #define osi_free(ptr) \ do { \ void *tmp_point = (void *)(ptr); \ @@ -75,10 +130,24 @@ do { \ #else +#if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST +#define osi_malloc(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) +#define osi_calloc(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) +#else #define osi_malloc(size) malloc((size)) #define osi_calloc(size) calloc(1, (size)) +#endif /* #if CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST */ #define osi_free(p) free((p)) #endif /* CONFIG_BLUEDROID_MEM_DEBUG */ +#define FREE_AND_RESET(a) \ +do { \ + if (a) { \ + osi_free(a); \ + a = NULL; \ + } \ +}while (0) + + #endif /* _ALLOCATOR_H_ */ diff --git a/tools/sdk/include/bluedroid/avrc_api.h b/tools/sdk/include/bluedroid/avrc_api.h index 3ca3e2d76f9..2634c97fb72 100644 --- a/tools/sdk/include/bluedroid/avrc_api.h +++ b/tools/sdk/include/bluedroid/avrc_api.h @@ -554,6 +554,19 @@ extern UINT8 AVRC_SetTraceLevel (UINT8 new_level); *******************************************************************************/ extern void AVRC_Init(void); +/******************************************************************************* +** +** Function AVRC_Deinit +** +** Description This function is called at stack shotdown to free the +** control block (if using dynamic memory), and deinitializes the +** control block and tracing level. +** +** Returns void +** +*******************************************************************************/ +extern void AVRC_Deinit(void); + /******************************************************************************* ** ** Function AVRC_ParsCommand diff --git a/tools/sdk/include/bluedroid/blufi_int.h b/tools/sdk/include/bluedroid/blufi_int.h index 024e1de794c..eab51ad85c4 100644 --- a/tools/sdk/include/bluedroid/blufi_int.h +++ b/tools/sdk/include/bluedroid/blufi_int.h @@ -16,7 +16,7 @@ #define __BLUFI_INT_H__ #define BTC_BLUFI_GREAT_VER 0x01 //Version + Subversion -#define BTC_BLUFI_SUB_VER 0x01 //Version + Subversion +#define BTC_BLUFI_SUB_VER 0x02 //Version + Subversion #define BTC_BLUFI_VERSION ((BTC_BLUFI_GREAT_VER<<8)|BTC_BLUFI_SUB_VER) //Version + Subversion /* service engine control block */ @@ -114,6 +114,8 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t; #define BLUFI_TYPE_DATA_SUBTYPE_WIFI_REP 0x0f #define BLUFI_TYPE_DATA_SUBTYPE_REPLY_VERSION 0x10 #define BLUFI_TYPE_DATA_SUBTYPE_WIFI_LIST 0x11 +#define BLUFI_TYPE_DATA_SUBTYPE_ERROR_INFO 0x12 +#define BLUFI_TYPE_DATA_SUBTYPE_CUSTOM_DATA 0x13 #define BLUFI_TYPE_IS_CTRL(type) (BLUFI_GET_TYPE((type)) == BLUFI_TYPE_CTRL) #define BLUFI_TYPE_IS_DATA(type) (BLUFI_GET_TYPE((type)) == BLUFI_TYPE_DATA) @@ -142,6 +144,7 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t; #define BLUFI_TYPE_IS_DATA_SERVER_CERT(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_SERVER_CERT) #define BLUFI_TYPE_IS_DATA_CLIENT_PRIV_KEY(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_CLIENT_PRIV_KEY) #define BLUFI_TYPE_IS_DATA_SERVER_PRIV_KEY(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_SERVER_PRIV_KEY) +#define BLUFI_TYPE_IS_DATA_ERROR_INFO(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_ERROR_INFO) // packet frame control #define BLUFI_FC_ENC_MASK 0x01 diff --git a/tools/sdk/include/bluedroid/bt_types.h b/tools/sdk/include/bluedroid/bt_types.h index 1f3f60d8caa..ec44cb87198 100644 --- a/tools/sdk/include/bluedroid/bt_types.h +++ b/tools/sdk/include/bluedroid/bt_types.h @@ -499,6 +499,8 @@ typedef struct { #define BLE_ADDR_RANDOM 0x01 #define BLE_ADDR_PUBLIC_ID 0x02 #define BLE_ADDR_RANDOM_ID 0x03 +#define BLE_ADDR_TYPE_MAX BLE_ADDR_RANDOM_ID +#define BLE_ADDR_UNKNOWN_TYPE 0XFF typedef UINT8 tBLE_ADDR_TYPE; #define BLE_ADDR_TYPE_MASK (BLE_ADDR_RANDOM | BLE_ADDR_PUBLIC) diff --git a/tools/sdk/include/bluedroid/bta_api.h b/tools/sdk/include/bluedroid/bta_api.h index a5a7edd269f..a13c0822739 100644 --- a/tools/sdk/include/bluedroid/bta_api.h +++ b/tools/sdk/include/bluedroid/bta_api.h @@ -409,6 +409,8 @@ typedef tBTM_ADD_WHITELIST_CBACK tBTA_ADD_WHITELIST_CBACK; typedef tBTM_SET_PKT_DATA_LENGTH_CBACK tBTA_SET_PKT_DATA_LENGTH_CBACK; +typedef tBTM_SET_RAND_ADDR_CBACK tBTA_SET_RAND_ADDR_CBACK; + typedef tBTM_SET_LOCAL_PRIVACY_CBACK tBTA_SET_LOCAL_PRIVACY_CBACK; typedef tBTM_CMPL_CB tBTA_CMPL_CB; @@ -2060,7 +2062,7 @@ extern void BTA_DmBleScan(BOOLEAN start, UINT32 duration, extern void BTA_DmBleStopAdvertising(void); -extern void BTA_DmSetRandAddress(BD_ADDR rand_addr); +extern void BTA_DmSetRandAddress(BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback); #endif diff --git a/tools/sdk/include/bluedroid/bta_ar_int.h b/tools/sdk/include/bluedroid/bta_ar_int.h new file mode 100644 index 00000000000..e9997ec7880 --- /dev/null +++ b/tools/sdk/include/bluedroid/bta_ar_int.h @@ -0,0 +1,66 @@ +/****************************************************************************** + * + * Copyright (C) 2008-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the private interface file for the BTA audio/video registration + * module. + * + ******************************************************************************/ +#ifndef BTA_AR_INT_H +#define BTA_AR_INT_H + +#include "bta_av_api.h" + +#if (BTA_AR_INCLUDED == TRUE) + +#ifndef BTA_AR_DEBUG +#define BTA_AR_DEBUG FALSE +#endif + +#define BTA_AR_AV_MASK 0x01 +#define BTA_AR_AVK_MASK 0x02 + +/* data associated with BTA_AR */ +typedef struct { + tAVDT_CTRL_CBACK *p_av_conn_cback; /* av connection callback function */ + tAVDT_CTRL_CBACK *p_avk_conn_cback; /* avk connection callback function */ + UINT8 avdt_registered; + UINT8 avct_registered; + UINT32 sdp_tg_handle; + UINT32 sdp_ct_handle; + UINT16 ct_categories[2]; + UINT8 tg_registered; + tBTA_AV_HNDL hndl; /* Handle associated with the stream that rejected the connection. */ +} tBTA_AR_CB; + +/***************************************************************************** +** Global data +*****************************************************************************/ + +/* control block declaration */ +#if BTA_DYNAMIC_MEMORY == FALSE +extern tBTA_AR_CB bta_ar_cb; +#else +extern tBTA_AR_CB *bta_ar_cb_ptr; +#define bta_ar_cb (*bta_ar_cb_ptr) +#endif + +#endif ///BTA_AR_INCLUDED == TRUE + +#endif /* BTA_AR_INT_H */ diff --git a/tools/sdk/include/bluedroid/bta_av_int.h b/tools/sdk/include/bluedroid/bta_av_int.h new file mode 100644 index 00000000000..2409c3a4807 --- /dev/null +++ b/tools/sdk/include/bluedroid/bta_av_int.h @@ -0,0 +1,708 @@ +/****************************************************************************** + * + * Copyright (C) 2004-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the private interface file for the BTA advanced audio/video. + * + ******************************************************************************/ +#ifndef BTA_AV_INT_H +#define BTA_AV_INT_H + +#include "bta_sys.h" +#include "bta_api.h" +#include "bta_av_api.h" +#include "avdt_api.h" +#include "bta_av_co.h" +#include "list.h" + +#if (BTA_AV_INCLUDED == TRUE) + +#define BTA_AV_DEBUG TRUE +/***************************************************************************** +** Constants +*****************************************************************************/ + +enum { + /* these events are handled by the AV main state machine */ + BTA_AV_API_DISABLE_EVT = BTA_SYS_EVT_START(BTA_ID_AV), + BTA_AV_API_REMOTE_CMD_EVT, + BTA_AV_API_VENDOR_CMD_EVT, + BTA_AV_API_VENDOR_RSP_EVT, + BTA_AV_API_META_RSP_EVT, + BTA_AV_API_RC_CLOSE_EVT, + BTA_AV_AVRC_OPEN_EVT, + BTA_AV_AVRC_MSG_EVT, + BTA_AV_AVRC_NONE_EVT, + + /* these events are handled by the AV stream state machine */ + BTA_AV_API_OPEN_EVT, + BTA_AV_API_CLOSE_EVT, + BTA_AV_AP_START_EVT, /* the following 2 events must be in the same order as the *API_*EVT */ + BTA_AV_AP_STOP_EVT, + BTA_AV_API_RECONFIG_EVT, + BTA_AV_API_PROTECT_REQ_EVT, + BTA_AV_API_PROTECT_RSP_EVT, + BTA_AV_API_RC_OPEN_EVT, + BTA_AV_SRC_DATA_READY_EVT, + BTA_AV_CI_SETCONFIG_OK_EVT, + BTA_AV_CI_SETCONFIG_FAIL_EVT, + BTA_AV_SDP_DISC_OK_EVT, + BTA_AV_SDP_DISC_FAIL_EVT, + BTA_AV_STR_DISC_OK_EVT, + BTA_AV_STR_DISC_FAIL_EVT, + BTA_AV_STR_GETCAP_OK_EVT, + BTA_AV_STR_GETCAP_FAIL_EVT, + BTA_AV_STR_OPEN_OK_EVT, + BTA_AV_STR_OPEN_FAIL_EVT, + BTA_AV_STR_START_OK_EVT, + BTA_AV_STR_START_FAIL_EVT, + BTA_AV_STR_CLOSE_EVT, + BTA_AV_STR_CONFIG_IND_EVT, + BTA_AV_STR_SECURITY_IND_EVT, + BTA_AV_STR_SECURITY_CFM_EVT, + BTA_AV_STR_WRITE_CFM_EVT, + BTA_AV_STR_SUSPEND_CFM_EVT, + BTA_AV_STR_RECONFIG_CFM_EVT, + BTA_AV_AVRC_TIMER_EVT, + BTA_AV_AVDT_CONNECT_EVT, + BTA_AV_AVDT_DISCONNECT_EVT, + BTA_AV_ROLE_CHANGE_EVT, + BTA_AV_AVDT_DELAY_RPT_EVT, + BTA_AV_ACP_CONNECT_EVT, + + /* these events are handled outside of the state machine */ + BTA_AV_API_ENABLE_EVT, + BTA_AV_API_REGISTER_EVT, + BTA_AV_API_DEREGISTER_EVT, + BTA_AV_API_DISCONNECT_EVT, + BTA_AV_CI_SRC_DATA_READY_EVT, + BTA_AV_SIG_CHG_EVT, + BTA_AV_SIG_TIMER_EVT, + BTA_AV_SDP_AVRC_DISC_EVT, + BTA_AV_AVRC_CLOSE_EVT, + BTA_AV_CONN_CHG_EVT, + BTA_AV_DEREG_COMP_EVT, +#if (BTA_AV_SINK_INCLUDED == TRUE) + BTA_AV_API_SINK_ENABLE_EVT, +#endif +#if (AVDT_REPORTING == TRUE) + BTA_AV_AVDT_RPT_CONN_EVT, +#endif + BTA_AV_API_START_EVT, /* the following 2 events must be in the same order as the *AP_*EVT */ + BTA_AV_API_STOP_EVT +}; + +/* events for AV control block state machine */ +#define BTA_AV_FIRST_SM_EVT BTA_AV_API_DISABLE_EVT +#define BTA_AV_LAST_SM_EVT BTA_AV_AVRC_NONE_EVT + +/* events for AV stream control block state machine */ +#define BTA_AV_FIRST_SSM_EVT BTA_AV_API_OPEN_EVT + +/* events that do not go through state machine */ +#define BTA_AV_FIRST_NSM_EVT BTA_AV_API_ENABLE_EVT +#define BTA_AV_LAST_NSM_EVT BTA_AV_API_STOP_EVT + +/* API events passed to both SSMs (by bta_av_api_to_ssm) */ +#define BTA_AV_FIRST_A2S_API_EVT BTA_AV_API_START_EVT +#define BTA_AV_FIRST_A2S_SSM_EVT BTA_AV_AP_START_EVT + +#define BTA_AV_LAST_EVT BTA_AV_API_STOP_EVT + +/* maximum number of SEPS in stream discovery results */ +#define BTA_AV_NUM_SEPS 32 + +/* initialization value for AVRC handle */ +#define BTA_AV_RC_HANDLE_NONE 0xFF + +/* size of database for service discovery */ +#define BTA_AV_DISC_BUF_SIZE 1000 + +/* offset of media type in codec info byte array */ +#define BTA_AV_MEDIA_TYPE_IDX 1 + +/* maximum length of AVDTP security data */ +#define BTA_AV_SECURITY_MAX_LEN 400 + +/* check number of buffers queued at L2CAP when this amount of buffers are queued to L2CAP */ +#define BTA_AV_QUEUE_DATA_CHK_NUM L2CAP_HIGH_PRI_MIN_XMIT_QUOTA + +/* the number of ACL links with AVDT */ +#define BTA_AV_NUM_LINKS AVDT_NUM_LINKS + +#define BTA_AV_CO_ID_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); } +#define BTA_AV_BE_STREAM_TO_CO_ID(u32, p) {u32 = (((UINT32)(*((p) + 2))) + (((UINT32)(*((p) + 1))) << 8) + (((UINT32)(*(p))) << 16)); (p) += 3;} + +/* these bits are defined for bta_av_cb.multi_av */ +#define BTA_AV_MULTI_AV_SUPPORTED 0x01 +#define BTA_AV_MULTI_AV_IN_USE 0x02 + + +/***************************************************************************** +** Data types +*****************************************************************************/ +#if 0 +/* function types for call-out functions */ +typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info, + UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index); +typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps, + UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local); +typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid, + UINT8 *p_num_protect, UINT8 *p_protect_info); +typedef void (*tBTA_AV_CO_SETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, + UINT8 num_protect, UINT8 *p_protect_info, + UINT8 t_local_sep, UINT8 avdt_handle); +typedef void (*tBTA_AV_CO_OPEN) (tBTA_AV_HNDL hndl, + tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, + UINT16 mtu); +typedef void (*tBTA_AV_CO_CLOSE) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT16 mtu); +typedef void (*tBTA_AV_CO_START) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr); +typedef void (*tBTA_AV_CO_STOP) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type); +typedef void *(*tBTA_AV_CO_DATAPATH) (tBTA_AV_CODEC codec_type, + UINT32 *p_len, UINT32 *p_timestamp); +typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay); + +/* the call-out functions for one stream */ +typedef struct { + tBTA_AV_CO_INIT init; + tBTA_AV_CO_DISC_RES disc_res; + tBTA_AV_CO_GETCFG getcfg; + tBTA_AV_CO_SETCFG setcfg; + tBTA_AV_CO_OPEN open; + tBTA_AV_CO_CLOSE close; + tBTA_AV_CO_START start; + tBTA_AV_CO_STOP stop; + tBTA_AV_CO_DATAPATH data; + tBTA_AV_CO_DELAY delay; +} tBTA_AV_CO_FUNCTS; +#endif + +/* data type for BTA_AV_API_ENABLE_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_AV_CBACK *p_cback; + tBTA_AV_FEAT features; + tBTA_SEC sec_mask; +} tBTA_AV_API_ENABLE; + +/* data type for BTA_AV_API_REG_EVT */ +typedef struct { + BT_HDR hdr; + char p_service_name[BTA_SERVICE_NAME_LEN + 1]; + UINT8 app_id; + tBTA_AV_DATA_CBACK *p_app_data_cback; + tBTA_AV_CO_FUNCTS *bta_av_cos; +} tBTA_AV_API_REG; + + +enum { + BTA_AV_RS_NONE, /* straight API call */ + BTA_AV_RS_OK, /* the role switch result - successful */ + BTA_AV_RS_FAIL, /* the role switch result - failed */ + BTA_AV_RS_DONE /* the role switch is done - continue */ +}; +typedef UINT8 tBTA_AV_RS_RES; +/* data type for BTA_AV_API_OPEN_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + BOOLEAN use_rc; + tBTA_SEC sec_mask; + tBTA_AV_RS_RES switch_res; + UINT16 uuid; /* uuid of initiator */ +} tBTA_AV_API_OPEN; + +/* data type for BTA_AV_API_STOP_EVT */ +typedef struct { + BT_HDR hdr; + BOOLEAN suspend; + BOOLEAN flush; +} tBTA_AV_API_STOP; + +/* data type for BTA_AV_API_DISCONNECT_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; +} tBTA_AV_API_DISCNT; + +/* data type for BTA_AV_API_PROTECT_REQ_EVT */ +typedef struct { + BT_HDR hdr; + UINT8 *p_data; + UINT16 len; +} tBTA_AV_API_PROTECT_REQ; + +/* data type for BTA_AV_API_PROTECT_RSP_EVT */ +typedef struct { + BT_HDR hdr; + UINT8 *p_data; + UINT16 len; + UINT8 error_code; +} tBTA_AV_API_PROTECT_RSP; + +/* data type for BTA_AV_API_REMOTE_CMD_EVT */ +typedef struct { + BT_HDR hdr; + tAVRC_MSG_PASS msg; + UINT8 label; +} tBTA_AV_API_REMOTE_CMD; + +/* data type for BTA_AV_API_VENDOR_CMD_EVT and RSP */ +typedef struct { + BT_HDR hdr; + tAVRC_MSG_VENDOR msg; + UINT8 label; +} tBTA_AV_API_VENDOR; + +/* data type for BTA_AV_API_RC_OPEN_EVT */ +typedef struct { + BT_HDR hdr; +} tBTA_AV_API_OPEN_RC; + +/* data type for BTA_AV_API_RC_CLOSE_EVT */ +typedef struct { + BT_HDR hdr; +} tBTA_AV_API_CLOSE_RC; + +/* data type for BTA_AV_API_META_RSP_EVT */ +typedef struct { + BT_HDR hdr; + BOOLEAN is_rsp; + UINT8 label; + tBTA_AV_CODE rsp_code; + BT_HDR *p_pkt; +} tBTA_AV_API_META_RSP; + + +/* data type for BTA_AV_API_RECONFIG_EVT */ +typedef struct { + BT_HDR hdr; + UINT8 codec_info[AVDT_CODEC_SIZE]; /* codec configuration */ + UINT8 *p_protect_info; + UINT8 num_protect; + BOOLEAN suspend; + UINT8 sep_info_idx; +} tBTA_AV_API_RCFG; + +/* data type for BTA_AV_CI_SETCONFIG_OK_EVT and BTA_AV_CI_SETCONFIG_FAIL_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_AV_HNDL hndl; + UINT8 err_code; + UINT8 category; + UINT8 num_seid; + UINT8 *p_seid; + BOOLEAN recfg_needed; + UINT8 avdt_handle; /* local sep type for which this stream will be set up */ +} tBTA_AV_CI_SETCONFIG; + +/* data type for all stream events from AVDTP */ +typedef struct { + BT_HDR hdr; + tAVDT_CFG cfg; /* configuration/capabilities parameters */ + tAVDT_CTRL msg; /* AVDTP callback message parameters */ + BD_ADDR bd_addr; /* bd address */ + UINT8 handle; + UINT8 avdt_event; + BOOLEAN initiator; /* TRUE, if local device initiates the SUSPEND */ +} tBTA_AV_STR_MSG; + +/* data type for BTA_AV_AVRC_MSG_EVT */ +typedef struct { + BT_HDR hdr; + tAVRC_MSG msg; + UINT8 handle; + UINT8 label; + UINT8 opcode; +} tBTA_AV_RC_MSG; + +/* data type for BTA_AV_AVRC_OPEN_EVT, BTA_AV_AVRC_CLOSE_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR peer_addr; + UINT8 handle; +} tBTA_AV_RC_CONN_CHG; + +/* data type for BTA_AV_CONN_CHG_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR peer_addr; + BOOLEAN is_up; +} tBTA_AV_CONN_CHG; + +/* data type for BTA_AV_ROLE_CHANGE_EVT */ +typedef struct { + BT_HDR hdr; + UINT8 new_role; + UINT8 hci_status; +} tBTA_AV_ROLE_RES; + +/* data type for BTA_AV_SDP_DISC_OK_EVT */ +typedef struct { + BT_HDR hdr; + UINT16 avdt_version; /* AVDTP protocol version */ +} tBTA_AV_SDP_RES; + +/* type for SEP control block */ +typedef struct { + UINT8 av_handle; /* AVDTP handle */ + tBTA_AV_CODEC codec_type; /* codec type */ + UINT8 tsep; /* SEP type of local SEP */ + tBTA_AV_DATA_CBACK *p_app_data_cback; /* Application callback for media packets */ +} tBTA_AV_SEP; + + +/* initiator/acceptor role for adaption */ +#define BTA_AV_ROLE_AD_INT 0x00 /* initiator */ +#define BTA_AV_ROLE_AD_ACP 0x01 /* acceptor */ + +/* initiator/acceptor signaling roles */ +#define BTA_AV_ROLE_START_ACP 0x00 +#define BTA_AV_ROLE_START_INT 0x10 /* do not change this value */ + +#define BTA_AV_ROLE_SUSPEND 0x20 /* suspending on start */ +#define BTA_AV_ROLE_SUSPEND_OPT 0x40 /* Suspend on Start option is set */ + +/* union of all event datatypes */ +typedef union { + BT_HDR hdr; + tBTA_AV_API_ENABLE api_enable; + tBTA_AV_API_REG api_reg; + tBTA_AV_API_OPEN api_open; + tBTA_AV_API_STOP api_stop; + tBTA_AV_API_DISCNT api_discnt; + tBTA_AV_API_PROTECT_REQ api_protect_req; + tBTA_AV_API_PROTECT_RSP api_protect_rsp; + tBTA_AV_API_REMOTE_CMD api_remote_cmd; + tBTA_AV_API_VENDOR api_vendor; + tBTA_AV_API_RCFG api_reconfig; + tBTA_AV_CI_SETCONFIG ci_setconfig; + tBTA_AV_STR_MSG str_msg; + tBTA_AV_RC_MSG rc_msg; + tBTA_AV_RC_CONN_CHG rc_conn_chg; + tBTA_AV_CONN_CHG conn_chg; + tBTA_AV_ROLE_RES role_res; + tBTA_AV_SDP_RES sdp_res; + tBTA_AV_API_META_RSP api_meta_rsp; +} tBTA_AV_DATA; + +typedef void (tBTA_AV_VDP_DATA_ACT)(void *p_scb); + +typedef struct { + tBTA_AV_VDP_DATA_ACT *p_act; + UINT8 *p_frame; + UINT16 buf_size; + UINT32 len; + UINT32 offset; + UINT32 timestamp; +} tBTA_AV_VF_INFO; + +typedef union { + tBTA_AV_VF_INFO vdp; /* used for video channels only */ + tBTA_AV_API_OPEN open; /* used only before open and role switch + is needed on another AV channel */ +} tBTA_AV_Q_INFO; + +#define BTA_AV_Q_TAG_OPEN 0x01 /* after API_OPEN, before STR_OPENED */ +#define BTA_AV_Q_TAG_START 0x02 /* before start sending media packets */ +#define BTA_AV_Q_TAG_STREAM 0x03 /* during streaming */ + +#define BTA_AV_WAIT_ACP_CAPS_ON 0x01 /* retriving the peer capabilities */ +#define BTA_AV_WAIT_ACP_CAPS_STARTED 0x02 /* started while retriving peer capabilities */ +#define BTA_AV_WAIT_ROLE_SW_RES_OPEN 0x04 /* waiting for role switch result after API_OPEN, before STR_OPENED */ +#define BTA_AV_WAIT_ROLE_SW_RES_START 0x08 /* waiting for role switch result before streaming */ +#define BTA_AV_WAIT_ROLE_SW_STARTED 0x10 /* started while waiting for role switch result */ +#define BTA_AV_WAIT_ROLE_SW_RETRY 0x20 /* set when retry on timeout */ +#define BTA_AV_WAIT_CHECK_RC 0x40 /* set when the timer is used by role switch */ +#define BTA_AV_WAIT_ROLE_SW_FAILED 0x80 /* role switch failed */ + +#define BTA_AV_WAIT_ROLE_SW_BITS (BTA_AV_WAIT_ROLE_SW_RES_OPEN|BTA_AV_WAIT_ROLE_SW_RES_START|BTA_AV_WAIT_ROLE_SW_STARTED|BTA_AV_WAIT_ROLE_SW_RETRY) + +/* Bitmap for collision, coll_mask */ +#define BTA_AV_COLL_INC_TMR 0x01 /* Timer is running for incoming L2C connection */ +#define BTA_AV_COLL_API_CALLED 0x02 /* API open was called while incoming timer is running */ + +/* type for AV stream control block */ +typedef struct { + const tBTA_AV_ACT *p_act_tbl; /* the action table for stream state machine */ + const tBTA_AV_CO_FUNCTS *p_cos; /* the associated callout functions */ + tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */ + tBTA_AV_SEP seps[BTA_AV_MAX_SEPS]; + tAVDT_CFG *p_cap; /* buffer used for get capabilities */ + list_t *a2d_list; /* used for audio channels only */ + tBTA_AV_Q_INFO q_info; + tAVDT_SEP_INFO sep_info[BTA_AV_NUM_SEPS]; /* stream discovery results */ + tAVDT_CFG cfg; /* local SEP configuration */ + TIMER_LIST_ENT timer; /* delay timer for AVRC CT */ + BD_ADDR peer_addr; /* peer BD address */ + UINT16 l2c_cid; /* L2CAP channel ID */ + UINT16 stream_mtu; /* MTU of stream */ + UINT16 avdt_version; /* the avdt version of peer device */ + tBTA_SEC sec_mask; /* security mask */ + tBTA_AV_CODEC codec_type; /* codec type */ + UINT8 media_type; /* Media type */ + BOOLEAN cong; /* TRUE if AVDTP congested */ + tBTA_AV_STATUS open_status; /* open failure status */ + tBTA_AV_CHNL chnl; /* the channel: audio/video */ + tBTA_AV_HNDL hndl; /* the handle: ((hdi + 1)|chnl) */ + UINT16 cur_psc_mask; /* Protocol service capabilities mask for current connection */ + UINT8 avdt_handle; /* AVDTP handle */ + UINT8 hdi; /* the index to SCB[] */ + UINT8 num_seps; /* number of seps returned by stream discovery */ + UINT8 num_disc_snks; /* number of discovered snks */ + UINT8 num_disc_srcs; /* number of discovered srcs */ + UINT8 sep_info_idx; /* current index into sep_info */ + UINT8 sep_idx; /* current index into local seps[] */ + UINT8 rcfg_idx; /* reconfig requested index into sep_info */ + UINT8 state; /* state machine state */ + UINT8 avdt_label; /* AVDTP label */ + UINT8 app_id; /* application id */ + UINT8 num_recfg; /* number of reconfigure sent */ + UINT8 role; + UINT8 l2c_bufs; /* the number of buffers queued to L2CAP */ + UINT8 rc_handle; /* connected AVRCP handle */ + BOOLEAN use_rc; /* TRUE if AVRCP is allowed */ + BOOLEAN started; /* TRUE if stream started */ + UINT8 co_started; /* non-zero, if stream started from call-out perspective */ + BOOLEAN recfg_sup; /* TRUE if the first attempt to reconfigure the stream was successfull, else False if command fails */ + BOOLEAN suspend_sup; /* TRUE if Suspend stream is supported, else FALSE if suspend command fails */ + BOOLEAN deregistring; /* TRUE if deregistering */ + BOOLEAN sco_suspend; /* TRUE if SUSPEND is issued automatically for SCO */ + UINT8 coll_mask; /* Mask to check incoming and outgoing collision */ + tBTA_AV_API_OPEN open_api; /* Saved OPEN api message */ + UINT8 wait; /* set 0x1, when getting Caps as ACP, set 0x2, when started */ + UINT8 q_tag; /* identify the associated q_info union member */ + BOOLEAN no_rtp_hdr; /* TRUE if add no RTP header*/ + UINT8 disc_rsn; /* disconenction reason */ + UINT16 uuid_int; /*intended UUID of Initiator to connect to */ +} tBTA_AV_SCB; + +#define BTA_AV_RC_ROLE_MASK 0x10 +#define BTA_AV_RC_ROLE_INT 0x00 +#define BTA_AV_RC_ROLE_ACP 0x10 + +#define BTA_AV_RC_CONN_MASK 0x20 + +/* type for AV RCP control block */ +/* index to this control block is the rc handle */ +typedef struct { + UINT8 status; + UINT8 handle; + UINT8 shdl; /* stream handle (hdi + 1) */ + UINT8 lidx; /* (index+1) to LCB */ + tBTA_AV_FEAT peer_features; /* peer features mask */ +} tBTA_AV_RCB; +#define BTA_AV_NUM_RCB (BTA_AV_NUM_STRS + 2) + +enum { + BTA_AV_LCB_FREE, + BTA_AV_LCB_FIND +}; + +/* type for AV ACL Link control block */ +typedef struct { + BD_ADDR addr; /* peer BD address */ + UINT8 conn_msk; /* handle mask of connected stream handle */ + UINT8 lidx; /* index + 1 */ +} tBTA_AV_LCB; + +/* type for stream state machine action functions */ +typedef void (*tBTA_AV_SACT)(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); + + +/* type for AV control block */ +typedef struct { + tBTA_AV_SCB *p_scb[BTA_AV_NUM_STRS]; /* stream control block */ + tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */ + tBTA_AV_CBACK *p_cback; /* application callback function */ + tBTA_AV_RCB rcb[BTA_AV_NUM_RCB]; /* RCB control block */ + tBTA_AV_LCB lcb[BTA_AV_NUM_LINKS + 1]; /* link control block */ + TIMER_LIST_ENT sig_tmr; /* link timer */ + TIMER_LIST_ENT acp_sig_tmr; /* timer to monitor signalling when accepting */ + UINT32 sdp_a2d_handle; /* SDP record handle for audio src */ +#if (BTA_AV_SINK_INCLUDED == TRUE) + UINT32 sdp_a2d_snk_handle; /* SDP record handle for audio snk */ +#endif + UINT32 sdp_vdp_handle; /* SDP record handle for video src */ + tBTA_AV_FEAT features; /* features mask */ + tBTA_SEC sec_mask; /* security mask */ + tBTA_AV_HNDL handle; /* the handle for SDP activity */ + BOOLEAN disabling; /* TRUE if api disabled called */ + UINT8 disc; /* (hdi+1) or (rc_handle|BTA_AV_CHNL_MSK) if p_disc_db is in use */ + UINT8 state; /* state machine state */ + UINT8 conn_rc; /* handle mask of connected RCP channels */ + UINT8 conn_audio; /* handle mask of connected audio channels */ + UINT8 conn_video; /* handle mask of connected video channels */ + UINT8 conn_lcb; /* index mask of used LCBs */ + UINT8 audio_open_cnt; /* number of connected audio channels */ + UINT8 reg_audio; /* handle mask of registered audio channels */ + UINT8 reg_video; /* handle mask of registered video channels */ + UINT8 rc_acp_handle; + UINT8 rc_acp_idx; /* (index + 1) to RCB */ + UINT8 rs_idx; /* (index + 1) to SCB for the one waiting for RS on open */ + BOOLEAN sco_occupied; /* TRUE if SCO is being used or call is in progress */ + UINT8 audio_streams; /* handle mask of streaming audio channels */ + UINT8 video_streams; /* handle mask of streaming video channels */ +} tBTA_AV_CB; + + + +/***************************************************************************** +** Global data +*****************************************************************************/ + +/* control block declaration */ +#if BTA_DYNAMIC_MEMORY == FALSE +extern tBTA_AV_CB bta_av_cb; +#else +extern tBTA_AV_CB *bta_av_cb_ptr; +#define bta_av_cb (*bta_av_cb_ptr) +#endif + +/* config struct */ +extern tBTA_AV_CFG *p_bta_av_cfg; + +/* rc id config struct */ +extern UINT16 *p_bta_av_rc_id; +extern UINT16 *p_bta_av_rc_id_ac; + +extern const tBTA_AV_SACT bta_av_a2d_action[]; +// extern const tBTA_AV_CO_FUNCTS bta_av_a2d_cos; +extern const tBTA_AV_SACT bta_av_vdp_action[]; +extern tAVDT_CTRL_CBACK *const bta_av_dt_cback[]; +extern void bta_av_stream_data_cback(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_pt); + +/***************************************************************************** +** Function prototypes +*****************************************************************************/ +/* utility functions */ +extern tBTA_AV_SCB *bta_av_hndl_to_scb(UINT16 handle); +extern BOOLEAN bta_av_chk_start(tBTA_AV_SCB *p_scb); +extern void bta_av_restore_switch (void); +extern UINT16 bta_av_chk_mtu(tBTA_AV_SCB *p_scb, UINT16 mtu); +extern void bta_av_conn_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data); +extern UINT8 bta_av_rc_create(tBTA_AV_CB *p_cb, UINT8 role, UINT8 shdl, UINT8 lidx); +extern void bta_av_stream_chg(tBTA_AV_SCB *p_scb, BOOLEAN started); +extern BOOLEAN bta_av_is_scb_opening (tBTA_AV_SCB *p_scb); +extern BOOLEAN bta_av_is_scb_incoming (tBTA_AV_SCB *p_scb); +extern void bta_av_set_scb_sst_init (tBTA_AV_SCB *p_scb); +extern BOOLEAN bta_av_is_scb_init (tBTA_AV_SCB *p_scb); +extern void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb); +extern tBTA_AV_LCB *bta_av_find_lcb(BD_ADDR addr, UINT8 op); + + +/* main functions */ +extern void bta_av_api_deregister(tBTA_AV_DATA *p_data); +extern void bta_av_dup_audio_buf(tBTA_AV_SCB *p_scb, BT_HDR *p_buf); +extern void bta_av_sm_execute(tBTA_AV_CB *p_cb, UINT16 event, tBTA_AV_DATA *p_data); +extern void bta_av_ssm_execute(tBTA_AV_SCB *p_scb, UINT16 event, tBTA_AV_DATA *p_data); +extern BOOLEAN bta_av_hdl_event(BT_HDR *p_msg); +#if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE) +extern char *bta_av_evt_code(UINT16 evt_code); +#endif +extern BOOLEAN bta_av_switch_if_needed(tBTA_AV_SCB *p_scb); +extern BOOLEAN bta_av_link_role_ok(tBTA_AV_SCB *p_scb, UINT8 bits); +extern BOOLEAN bta_av_is_rcfg_sst(tBTA_AV_SCB *p_scb); + +/* nsm action functions */ +extern void bta_av_api_disconnect(tBTA_AV_DATA *p_data); +extern void bta_av_sig_chg(tBTA_AV_DATA *p_data); +extern void bta_av_sig_timer(tBTA_AV_DATA *p_data); +extern void bta_av_rc_disc_done(tBTA_AV_DATA *p_data); +extern void bta_av_rc_closed(tBTA_AV_DATA *p_data); +extern void bta_av_rc_disc(UINT8 disc); +extern void bta_av_conn_chg(tBTA_AV_DATA *p_data); +extern void bta_av_dereg_comp(tBTA_AV_DATA *p_data); + +/* sm action functions */ +extern void bta_av_disable (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); +extern void bta_av_rc_opened (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); +extern void bta_av_rc_remote_cmd (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); +extern void bta_av_rc_vendor_cmd (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); +extern void bta_av_rc_vendor_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); +extern void bta_av_rc_msg (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); +extern void bta_av_rc_close (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); +extern void bta_av_rc_meta_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); +extern void bta_av_rc_free_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); +extern void bta_av_rc_free_msg (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data); + +extern tBTA_AV_RCB *bta_av_get_rcb_by_shdl(UINT8 shdl); +extern void bta_av_del_rc(tBTA_AV_RCB *p_rcb); + +/* ssm action functions */ +extern void bta_av_do_disc_a2d (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_cleanup (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_free_sdb (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_config_ind (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_disconnect_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_security_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_security_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_setconfig_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_security_ind (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_security_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_do_close (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_connect_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_sdp_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_disc_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_disc_res_as_acp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_open_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_getcap_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_setconfig_rej (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_discover_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_conn_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_do_start (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_str_stopped (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_reconfig (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_data_path (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_start_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_start_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_str_closed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_clr_cong (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_suspend_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_rcfg_str_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_rcfg_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_rcfg_connect (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_rcfg_discntd (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_suspend_cont (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_rcfg_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_rcfg_open (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_security_rej (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_open_rc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_chk_2nd_start (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_save_caps (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_rej_conn (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_rej_conn (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_set_use_rc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_cco_close (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_switch_role (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_role_res (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_delay_co (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_open_at_inc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); + +/* ssm action functions - vdp specific */ +extern void bta_av_do_disc_vdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_vdp_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_reg_vdp (tAVDT_CS *p_cs, char *p_service_name, void *p_data); + +#endif ///BTA_AV_INCLUDED == TRUE + +#endif /* BTA_AV_INT_H */ diff --git a/tools/sdk/include/bluedroid/bta_dm_int.h b/tools/sdk/include/bluedroid/bta_dm_int.h new file mode 100644 index 00000000000..a95bb676ece --- /dev/null +++ b/tools/sdk/include/bluedroid/bta_dm_int.h @@ -0,0 +1,1257 @@ +/****************************************************************************** + * + * Copyright (C) 2003-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the private interface file for the BTA device manager. + * + ******************************************************************************/ +#ifndef BTA_DM_INT_H +#define BTA_DM_INT_H + +#include "bt_target.h" + +#if (BLE_INCLUDED == TRUE && (defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)) +#include "bta_gatt_api.h" +#endif + + + +/***************************************************************************** +** Constants and data types +*****************************************************************************/ + + +#define BTA_COPY_DEVICE_CLASS(coddst, codsrc) {((UINT8 *)(coddst))[0] = ((UINT8 *)(codsrc))[0]; \ + ((UINT8 *)(coddst))[1] = ((UINT8 *)(codsrc))[1]; \ + ((UINT8 *)(coddst))[2] = ((UINT8 *)(codsrc))[2];} + + +#define BTA_DM_MSG_LEN 50 + +#define BTA_SERVICE_ID_TO_SERVICE_MASK(id) (1 << (id)) + +/* DM events */ +enum { + /* device manager local device API events */ + BTA_DM_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_DM), + BTA_DM_API_DISABLE_EVT, + BTA_DM_API_SET_NAME_EVT, + BTA_DM_API_SET_VISIBILITY_EVT, + + BTA_DM_ACL_CHANGE_EVT, + BTA_DM_API_ADD_DEVICE_EVT, + BTA_DM_API_REMOVE_ACL_EVT, +#if (SMP_INCLUDED == TRUE) + /* security API events */ + BTA_DM_API_BOND_EVT, + BTA_DM_API_BOND_CANCEL_EVT, + BTA_DM_API_PIN_REPLY_EVT, +#endif ///SMP_INCLUDED == TRUE +#if (BTM_SSR_INCLUDED == TRUE) + /* power manger events */ + BTA_DM_PM_BTM_STATUS_EVT, + BTA_DM_PM_TIMER_EVT, +#endif ///BTM_SSR_INCLUDED == TRUE +#if (SMP_INCLUDED == TRUE) + /* simple pairing events */ + BTA_DM_API_CONFIRM_EVT, + + BTA_DM_API_SET_ENCRYPTION_EVT, +#endif ///SMP_INCLUDED == TRUE +#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE) + BTA_DM_API_LOC_OOB_EVT, + BTA_DM_CI_IO_REQ_EVT, + BTA_DM_CI_RMT_OOB_EVT, +#endif /* BTM_OOB_INCLUDED */ + + +#if BLE_INCLUDED == TRUE +#if SMP_INCLUDED == TRUE + BTA_DM_API_ADD_BLEKEY_EVT, + BTA_DM_API_ADD_BLEDEVICE_EVT, + BTA_DM_API_BLE_PASSKEY_REPLY_EVT, + BTA_DM_API_BLE_CONFIRM_REPLY_EVT, + BTA_DM_API_BLE_SEC_GRANT_EVT, +#endif ///SMP_INCLUDED == TRUE + BTA_DM_API_BLE_SET_BG_CONN_TYPE, + BTA_DM_API_BLE_CONN_PARAM_EVT, + BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT, + BTA_DM_API_BLE_SCAN_PARAM_EVT, + /*******This event added by Yulong at 2016/10/25 to + support the scan filter setting for the APP******/ + BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT, + BTA_DM_API_BLE_OBSERVE_EVT, + BTA_DM_API_BLE_SCAN_EVT, + BTA_DM_API_UPDATE_CONN_PARAM_EVT, + /*******This event added by Yulong at 2016/9/9 to + support the random address setting for the APP******/ + BTA_DM_API_SET_RAND_ADDR_EVT, + /*******This event added by Yulong at 2016/10/19 to + support stop the ble advertising setting by the APP******/ + BTA_DM_API_BLE_STOP_ADV_EVT, +#if BLE_PRIVACY_SPT == TRUE + BTA_DM_API_LOCAL_PRIVACY_EVT, +#endif + BTA_DM_API_BLE_ADV_PARAM_EVT, + + /*******This event added by Yulong at 2016/10/20 to + support setting the ble advertising param by the APP******/ + BTA_DM_API_BLE_ADV_PARAM_All_EVT, + BTA_DM_API_BLE_SET_ADV_CONFIG_EVT, + /* Add for set raw advertising data */ + BTA_DM_API_BLE_SET_ADV_CONFIG_RAW_EVT, + BTA_DM_API_BLE_SET_SCAN_RSP_EVT, + /* Add for set raw scan response data */ + BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT, + BTA_DM_API_BLE_BROADCAST_EVT, + BTA_DM_API_SET_DATA_LENGTH_EVT, + +#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE + BTA_DM_API_CFG_FILTER_COND_EVT, + BTA_DM_API_SCAN_FILTER_SETUP_EVT, + BTA_DM_API_SCAN_FILTER_ENABLE_EVT, +#endif + BTA_DM_API_BLE_MULTI_ADV_ENB_EVT, + BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT, + BTA_DM_API_BLE_MULTI_ADV_DATA_EVT, + BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT, + BTA_DM_API_BLE_SETUP_STORAGE_EVT, + BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT, + BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT, + BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT, + BTA_DM_API_BLE_TRACK_ADVERTISER_EVT, + BTA_DM_API_BLE_ENERGY_INFO_EVT, + BTA_DM_API_BLE_DISCONNECT_EVT, + +#endif + + BTA_DM_API_ENABLE_TEST_MODE_EVT, + BTA_DM_API_DISABLE_TEST_MODE_EVT, + BTA_DM_API_EXECUTE_CBACK_EVT, + BTA_DM_API_REMOVE_ALL_ACL_EVT, + BTA_DM_API_REMOVE_DEVICE_EVT, + BTA_DM_API_UPDATE_WHITE_LIST_EVT, + BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT, + BTA_DM_API_BLE_READ_RSSI_EVT, + BTA_DM_MAX_EVT +}; + + +/* DM search events */ +enum { + /* DM search API events */ + BTA_DM_API_SEARCH_EVT = BTA_SYS_EVT_START(BTA_ID_DM_SEARCH), + BTA_DM_API_SEARCH_CANCEL_EVT, + BTA_DM_API_DISCOVER_EVT, + BTA_DM_INQUIRY_CMPL_EVT, + BTA_DM_REMT_NAME_EVT, + BTA_DM_SDP_RESULT_EVT, + BTA_DM_SEARCH_CMPL_EVT, + BTA_DM_DISCOVERY_RESULT_EVT, + BTA_DM_API_DI_DISCOVER_EVT, + BTA_DM_DISC_CLOSE_TOUT_EVT, +}; + +/* data type for BTA_DM_API_ENABLE_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_DM_SEC_CBACK *p_sec_cback; +} tBTA_DM_API_ENABLE; + +/* data type for BTA_DM_API_SET_NAME_EVT */ +typedef struct { + BT_HDR hdr; + BD_NAME name; /* max 248 bytes name, plus must be Null terminated */ +} tBTA_DM_API_SET_NAME; + +typedef struct { + BT_HDR hdr; + BOOLEAN add_remove; + BD_ADDR remote_addr; + tBTA_ADD_WHITELIST_CBACK *add_wl_cb; +}tBTA_DM_API_UPDATE_WHITE_LIST; + +typedef struct { + BT_HDR hdr; + tBTA_CMPL_CB *read_tx_power_cb; +}tBTA_DM_API_READ_ADV_TX_POWER; + +typedef struct { + BT_HDR hdr; + BD_ADDR remote_addr; + tBTA_CMPL_CB *read_rssi_cb; +}tBTA_DM_API_READ_RSSI; + +/* data type for BTA_DM_API_SET_VISIBILITY_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_DM_DISC disc_mode; + tBTA_DM_CONN conn_mode; + UINT8 pair_mode; + UINT8 conn_paired_only; +} tBTA_DM_API_SET_VISIBILITY; + +enum { + BTA_DM_RS_NONE, /* straight API call */ + BTA_DM_RS_OK, /* the role switch result - successful */ + BTA_DM_RS_FAIL /* the role switch result - failed */ +}; +typedef UINT8 tBTA_DM_RS_RES; + +/* data type for BTA_DM_API_SEARCH_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_DM_INQ inq_params; + tBTA_SERVICE_MASK services; + tBTA_DM_SEARCH_CBACK *p_cback; + tBTA_DM_RS_RES rs_res; +#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE + UINT8 num_uuid; + tBT_UUID *p_uuid; +#endif +} tBTA_DM_API_SEARCH; + +#if (SDP_INCLUDED == TRUE) +/* data type for BTA_DM_API_DISCOVER_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + tBTA_SERVICE_MASK services; + tBTA_DM_SEARCH_CBACK *p_cback; + BOOLEAN sdp_search; + tBTA_TRANSPORT transport; +#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE + UINT8 num_uuid; + tBT_UUID *p_uuid; +#endif + tSDP_UUID uuid; +} tBTA_DM_API_DISCOVER; +#endif ///SDP_INCLUDED == TRUE + +/* data type for BTA_DM_API_DI_DISC_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; +#if (SDP_INCLUDED == TRUE) + tBTA_DISCOVERY_DB *p_sdp_db; +#endif ///SDP_INCLUDED == TRUE + UINT32 len; + tBTA_DM_SEARCH_CBACK *p_cback; +} tBTA_DM_API_DI_DISC; + +/* data type for BTA_DM_API_BOND_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + tBTA_TRANSPORT transport; +} tBTA_DM_API_BOND; + +/* data type for BTA_DM_API_BOND_CANCEL_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + tBTA_TRANSPORT transport; +} tBTA_DM_API_BOND_CANCEL; + +/* data type for BTA_DM_API_PIN_REPLY_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + BOOLEAN accept; + UINT8 pin_len; + UINT8 p_pin[PIN_CODE_LEN]; +} tBTA_DM_API_PIN_REPLY; + +/* data type for BTA_DM_API_LOC_OOB_EVT */ +typedef struct { + BT_HDR hdr; +} tBTA_DM_API_LOC_OOB; + +/* data type for BTA_DM_API_CONFIRM_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + BOOLEAN accept; +} tBTA_DM_API_CONFIRM; + +/* data type for BTA_DM_CI_IO_REQ_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + tBTA_IO_CAP io_cap; + tBTA_OOB_DATA oob_data; + tBTA_AUTH_REQ auth_req; +} tBTA_DM_CI_IO_REQ; + +/* data type for BTA_DM_CI_RMT_OOB_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + BT_OCTET16 c; + BT_OCTET16 r; + BOOLEAN accept; +} tBTA_DM_CI_RMT_OOB; + +/* data type for BTA_DM_REMT_NAME_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_DM_SEARCH result; +} tBTA_DM_REM_NAME; + +/* data type for tBTA_DM_DISC_RESULT */ +typedef struct { + BT_HDR hdr; + tBTA_DM_SEARCH result; +} tBTA_DM_DISC_RESULT; + + +/* data type for BTA_DM_INQUIRY_CMPL_EVT */ +typedef struct { + BT_HDR hdr; + UINT8 num; +} tBTA_DM_INQUIRY_CMPL; + +/* data type for BTA_DM_SDP_RESULT_EVT */ +typedef struct { + BT_HDR hdr; + UINT16 sdp_result; +} tBTA_DM_SDP_RESULT; + +/* data type for BTA_DM_ACL_CHANGE_EVT */ +typedef struct { + BT_HDR hdr; + tBTM_BL_EVENT event; + UINT8 busy_level; + UINT8 busy_level_flags; + BOOLEAN is_new; + UINT8 new_role; + BD_ADDR bd_addr; + UINT8 hci_status; +#if BLE_INCLUDED == TRUE + UINT16 handle; + tBT_TRANSPORT transport; +#endif +} tBTA_DM_ACL_CHANGE; + +/* data type for BTA_DM_PM_BTM_STATUS_EVT */ +typedef struct { + + BT_HDR hdr; + BD_ADDR bd_addr; + tBTM_PM_STATUS status; + UINT16 value; + UINT8 hci_status; + +} tBTA_DM_PM_BTM_STATUS; + +/* data type for BTA_DM_PM_TIMER_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + tBTA_DM_PM_ACTION pm_request; +} tBTA_DM_PM_TIMER; + + +/* data type for BTA_DM_API_ADD_DEVICE_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + DEV_CLASS dc; + LINK_KEY link_key; + tBTA_SERVICE_MASK tm; + BOOLEAN is_trusted; + UINT8 key_type; + tBTA_IO_CAP io_cap; + BOOLEAN link_key_known; + BOOLEAN dc_known; + BD_NAME bd_name; + UINT8 features[BTA_FEATURE_BYTES_PER_PAGE * (BTA_EXT_FEATURES_PAGE_MAX + 1)]; + UINT8 pin_length; +} tBTA_DM_API_ADD_DEVICE; + +/* data type for BTA_DM_API_REMOVE_ACL_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; +} tBTA_DM_API_REMOVE_DEVICE; + +/* data type for BTA_DM_API_EXECUTE_CBACK_EVT */ +typedef struct { + BT_HDR hdr; + void *p_param; + tBTA_DM_EXEC_CBACK *p_exec_cback; +} tBTA_DM_API_EXECUTE_CBACK; + +/* data type for tBTA_DM_API_SET_ENCRYPTION */ +typedef struct { + BT_HDR hdr; + tBTA_TRANSPORT transport; + tBTA_DM_ENCRYPT_CBACK *p_callback; + tBTA_DM_BLE_SEC_ACT sec_act; + BD_ADDR bd_addr; +} tBTA_DM_API_SET_ENCRYPTION; + +#if BLE_INCLUDED == TRUE +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + tBTA_LE_KEY_VALUE blekey; + tBTA_LE_KEY_TYPE key_type; + +} tBTA_DM_API_ADD_BLEKEY; + +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + tBT_DEVICE_TYPE dev_type ; + tBLE_ADDR_TYPE addr_type; + +} tBTA_DM_API_ADD_BLE_DEVICE; + +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + BOOLEAN accept; + UINT32 passkey; +} tBTA_DM_API_PASSKEY_REPLY; + +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + tBTA_DM_BLE_SEC_GRANT res; +} tBTA_DM_API_BLE_SEC_GRANT; + + +typedef struct { + BT_HDR hdr; + tBTA_DM_BLE_CONN_TYPE bg_conn_type; + tBTA_DM_BLE_SEL_CBACK *p_select_cback; +} tBTA_DM_API_BLE_SET_BG_CONN_TYPE; + +/* set prefered BLE connection parameters for a device */ +typedef struct { + BT_HDR hdr; + BD_ADDR peer_bda; + UINT16 conn_int_min; + UINT16 conn_int_max; + UINT16 supervision_tout; + UINT16 slave_latency; + +} tBTA_DM_API_BLE_CONN_PARAMS; + +typedef struct { + BT_HDR hdr; + BD_ADDR peer_bda; + BOOLEAN privacy_enable; + +} tBTA_DM_API_ENABLE_PRIVACY; + +typedef struct { + BT_HDR hdr; + BOOLEAN privacy_enable; + tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback; +} tBTA_DM_API_LOCAL_PRIVACY; + +/* set scan parameter for BLE connections */ +typedef struct { + BT_HDR hdr; + tBTA_GATTC_IF client_if; + UINT32 scan_int; + UINT32 scan_window; + tBLE_SCAN_MODE scan_mode; + tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback; +} tBTA_DM_API_BLE_SCAN_PARAMS; + +typedef struct { + BT_HDR hdr; + tBTA_GATTC_IF client_if; + UINT32 scan_int; + UINT32 scan_window; + tBLE_SCAN_MODE scan_mode; + UINT8 addr_type_own; + UINT8 scan_filter_policy; + tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback; +} tBTA_DM_API_BLE_SCAN_FILTER_PARAMS; + + +/* set scan parameter for BLE connections */ +typedef struct { + BT_HDR hdr; + UINT16 scan_int; + UINT16 scan_window; +} tBTA_DM_API_BLE_CONN_SCAN_PARAMS; + +/* Data type for start/stop observe */ +typedef struct { + BT_HDR hdr; + BOOLEAN start; + UINT32 duration; + tBTA_DM_SEARCH_CBACK *p_cback; + tBTA_START_STOP_SCAN_CMPL_CBACK *p_start_scan_cback; + tBTA_START_STOP_SCAN_CMPL_CBACK *p_stop_scan_cback; + tBTA_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback; +} tBTA_DM_API_BLE_OBSERVE; + +/* Data type for start/stop scan */ +typedef struct { + BT_HDR hdr; + BOOLEAN start; + UINT32 duration; + tBTA_DM_SEARCH_CBACK *p_cback; + tBTA_START_STOP_SCAN_CMPL_CBACK *p_start_scan_cback; + tBTA_START_STOP_SCAN_CMPL_CBACK *p_stop_scan_cback; + tBTA_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback; +} tBTA_DM_API_BLE_SCAN; + +typedef struct { + BT_HDR hdr; + BD_ADDR remote_bda; + UINT16 tx_data_length; + tBTA_SET_PKT_DATA_LENGTH_CBACK *p_set_pkt_data_cback; +} tBTA_DM_API_BLE_SET_DATA_LENGTH; + +/* set the address for BLE device + this type added by Yulong at 2016/9/9*/ +typedef struct { + BT_HDR hdr; + tBLE_ADDR_TYPE addr_type; + BD_ADDR address; + tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback; +} tBTA_DM_APT_SET_DEV_ADDR; + +/* set adv parameter for BLE advertising */ +typedef struct { + BT_HDR hdr; + UINT16 adv_int_min; + UINT16 adv_int_max; + tBLE_BD_ADDR *p_dir_bda; +} tBTA_DM_API_BLE_ADV_PARAMS; + +/* set adv parameter for BLE advertising */ +typedef struct { + BT_HDR hdr; + UINT16 adv_int_min; + UINT16 adv_int_max; + UINT8 adv_type; + tBLE_ADDR_TYPE addr_type_own; + tBTM_BLE_ADV_CHNL_MAP channel_map; + tBTM_BLE_AFP adv_filter_policy; + tBLE_BD_ADDR *p_dir_bda; + tBTA_START_ADV_CMPL_CBACK *p_start_adv_cback; +} tBTA_DM_API_BLE_ADV_PARAMS_ALL; + + +typedef struct { + BT_HDR hdr; + BOOLEAN enable; + +} tBTA_DM_API_BLE_FEATURE; + +/* multi adv data structure */ +typedef struct { + BT_HDR hdr; + tBTA_BLE_MULTI_ADV_CBACK *p_cback; + void *p_ref; + tBTA_BLE_ADV_PARAMS *p_params; +} tBTA_DM_API_BLE_MULTI_ADV_ENB; + +typedef struct { + BT_HDR hdr; + UINT8 inst_id; + tBTA_BLE_ADV_PARAMS *p_params; +} tBTA_DM_API_BLE_MULTI_ADV_PARAM; + +typedef struct { + BT_HDR hdr; + UINT8 inst_id; + BOOLEAN is_scan_rsp; + tBTA_BLE_AD_MASK data_mask; + tBTA_BLE_ADV_DATA *p_data; +} tBTA_DM_API_BLE_MULTI_ADV_DATA; + +typedef struct { + BT_HDR hdr; + UINT8 inst_id; +} tBTA_DM_API_BLE_MULTI_ADV_DISABLE; + +typedef struct { + BT_HDR hdr; + UINT32 data_mask; + tBTA_BLE_ADV_DATA *p_adv_cfg; + tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback; +} tBTA_DM_API_SET_ADV_CONFIG; + +/* raw scan response and raw advertising data use + the same structure */ +typedef struct { + BT_HDR hdr; + UINT8 *p_raw_adv; + UINT32 raw_adv_len; + tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback; +} tBTA_DM_API_SET_ADV_CONFIG_RAW; + +typedef struct { + BT_HDR hdr; + UINT8 batch_scan_full_max; + UINT8 batch_scan_trunc_max; + UINT8 batch_scan_notify_threshold; + tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback; + tBTA_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback; + tBTA_BLE_SCAN_REP_CBACK *p_read_rep_cback; + tBTA_DM_BLE_REF_VALUE ref_value; +} tBTA_DM_API_SET_STORAGE_CONFIG; + +typedef struct { + BT_HDR hdr; + tBTA_BLE_BATCH_SCAN_MODE scan_mode; + UINT32 scan_int; + UINT32 scan_window; + tBTA_BLE_DISCARD_RULE discard_rule; + tBLE_ADDR_TYPE addr_type; + tBTA_DM_BLE_REF_VALUE ref_value; +} tBTA_DM_API_ENABLE_SCAN; + +typedef struct { + BT_HDR hdr; + tBTA_DM_BLE_REF_VALUE ref_value; +} tBTA_DM_API_DISABLE_SCAN; + +typedef struct { + BT_HDR hdr; + tBTA_BLE_BATCH_SCAN_MODE scan_type; + tBTA_DM_BLE_REF_VALUE ref_value; +} tBTA_DM_API_READ_SCAN_REPORTS; + +typedef struct { + BT_HDR hdr; + tBTA_DM_BLE_REF_VALUE ref_value; + tBTA_BLE_TRACK_ADV_CBACK *p_track_adv_cback; +} tBTA_DM_API_TRACK_ADVERTISER; + +typedef struct { + BT_HDR hdr; + tBTA_BLE_ENERGY_INFO_CBACK *p_energy_info_cback; +} tBTA_DM_API_ENERGY_INFO; + +typedef struct { + BT_HDR hdr; + BD_ADDR remote_bda; +} tBTA_DM_API_BLE_DISCONNECT; + +#endif /* BLE_INCLUDED */ + +/* data type for BTA_DM_API_REMOVE_ACL_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + BOOLEAN remove_dev; + tBTA_TRANSPORT transport; + +} tBTA_DM_API_REMOVE_ACL; + +/* data type for BTA_DM_API_REMOVE_ALL_ACL_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_DM_LINK_TYPE link_type; + +} tBTA_DM_API_REMOVE_ALL_ACL; +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + UINT16 min_int; + UINT16 max_int; + UINT16 latency; + UINT16 timeout; +} tBTA_DM_API_UPDATE_CONN_PARAM; + +#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE +typedef struct { + BT_HDR hdr; + tBTA_DM_BLE_SCAN_COND_OP action; + tBTA_DM_BLE_PF_COND_TYPE cond_type; + tBTA_DM_BLE_PF_FILT_INDEX filt_index; + tBTA_DM_BLE_PF_COND_PARAM *p_cond_param; + tBTA_DM_BLE_PF_CFG_CBACK *p_filt_cfg_cback; + tBTA_DM_BLE_REF_VALUE ref_value; +} tBTA_DM_API_CFG_FILTER_COND; + +typedef struct { + BT_HDR hdr; + UINT8 action; + tBTA_DM_BLE_PF_STATUS_CBACK *p_filt_status_cback; + tBTA_DM_BLE_REF_VALUE ref_value; +} tBTA_DM_API_ENABLE_SCAN_FILTER; + +typedef struct { + BT_HDR hdr; + UINT8 action; + tBTA_DM_BLE_PF_FILT_INDEX filt_index; + tBTA_DM_BLE_PF_FILT_PARAMS filt_params; + tBLE_BD_ADDR *p_target; + tBTA_DM_BLE_PF_PARAM_CBACK *p_filt_param_cback; + tBTA_DM_BLE_REF_VALUE ref_value; +} tBTA_DM_API_SCAN_FILTER_PARAM_SETUP; +#endif + +/* union of all data types */ +typedef union { + /* event buffer header */ + BT_HDR hdr; + tBTA_DM_API_ENABLE enable; + + tBTA_DM_API_SET_NAME set_name; + + tBTA_DM_API_UPDATE_WHITE_LIST white_list; + tBTA_DM_API_READ_ADV_TX_POWER read_tx_power; + tBTA_DM_API_READ_RSSI rssi; + tBTA_DM_API_SET_VISIBILITY set_visibility; + + tBTA_DM_API_ADD_DEVICE add_dev; + + tBTA_DM_API_REMOVE_DEVICE remove_dev; + + tBTA_DM_API_SEARCH search; +#if (SDP_INCLUDED == TRUE) + tBTA_DM_API_DISCOVER discover; +#endif ///SDP_INCLUDED == TRUE + tBTA_DM_API_BOND bond; + + tBTA_DM_API_BOND_CANCEL bond_cancel; + + tBTA_DM_API_PIN_REPLY pin_reply; + + tBTA_DM_API_LOC_OOB loc_oob; + tBTA_DM_API_CONFIRM confirm; + tBTA_DM_CI_IO_REQ ci_io_req; + tBTA_DM_CI_RMT_OOB ci_rmt_oob; + + tBTA_DM_REM_NAME rem_name; + + tBTA_DM_DISC_RESULT disc_result; + + tBTA_DM_INQUIRY_CMPL inq_cmpl; + + tBTA_DM_SDP_RESULT sdp_event; + + tBTA_DM_ACL_CHANGE acl_change; + + tBTA_DM_PM_BTM_STATUS pm_status; + + tBTA_DM_PM_TIMER pm_timer; + + tBTA_DM_API_DI_DISC di_disc; + + tBTA_DM_API_EXECUTE_CBACK exec_cback; + + tBTA_DM_API_SET_ENCRYPTION set_encryption; + +#if BLE_INCLUDED == TRUE + tBTA_DM_API_ADD_BLEKEY add_ble_key; + tBTA_DM_API_ADD_BLE_DEVICE add_ble_device; + tBTA_DM_API_PASSKEY_REPLY ble_passkey_reply; + tBTA_DM_API_BLE_SEC_GRANT ble_sec_grant; + tBTA_DM_API_BLE_SET_BG_CONN_TYPE ble_set_bd_conn_type; + tBTA_DM_API_BLE_CONN_PARAMS ble_set_conn_params; + tBTA_DM_API_BLE_CONN_SCAN_PARAMS ble_set_conn_scan_params; + tBTA_DM_API_BLE_SCAN_PARAMS ble_set_scan_params; + tBTA_DM_API_BLE_SCAN_FILTER_PARAMS ble_set_scan_fil_params; + tBTA_DM_API_BLE_OBSERVE ble_observe; + tBTA_DM_API_BLE_SCAN ble_scan; + tBTA_DM_API_ENABLE_PRIVACY ble_remote_privacy; + tBTA_DM_API_LOCAL_PRIVACY ble_local_privacy; + tBTA_DM_API_BLE_ADV_PARAMS ble_set_adv_params; + tBTA_DM_API_BLE_ADV_PARAMS_ALL ble_set_adv_params_all; + tBTA_DM_API_SET_ADV_CONFIG ble_set_adv_data; + tBTA_DM_API_SET_ADV_CONFIG_RAW ble_set_adv_data_raw; +#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE + tBTA_DM_API_SCAN_FILTER_PARAM_SETUP ble_scan_filt_param_setup; + tBTA_DM_API_CFG_FILTER_COND ble_cfg_filter_cond; + tBTA_DM_API_ENABLE_SCAN_FILTER ble_enable_scan_filt; +#endif + tBTA_DM_API_UPDATE_CONN_PARAM ble_update_conn_params; + tBTA_DM_API_BLE_SET_DATA_LENGTH ble_set_data_length; + tBTA_DM_APT_SET_DEV_ADDR set_addr; + tBTA_DM_API_BLE_MULTI_ADV_ENB ble_multi_adv_enb; + tBTA_DM_API_BLE_MULTI_ADV_PARAM ble_multi_adv_param; + tBTA_DM_API_BLE_MULTI_ADV_DATA ble_multi_adv_data; + tBTA_DM_API_BLE_MULTI_ADV_DISABLE ble_multi_adv_disable; + + tBTA_DM_API_SET_STORAGE_CONFIG ble_set_storage; + tBTA_DM_API_ENABLE_SCAN ble_enable_scan; + tBTA_DM_API_READ_SCAN_REPORTS ble_read_reports; + tBTA_DM_API_DISABLE_SCAN ble_disable_scan; + tBTA_DM_API_TRACK_ADVERTISER ble_track_advert; + tBTA_DM_API_ENERGY_INFO ble_energy_info; + tBTA_DM_API_BLE_DISCONNECT ble_disconnect; +#endif + + tBTA_DM_API_REMOVE_ACL remove_acl; + tBTA_DM_API_REMOVE_ALL_ACL remove_all_acl; + +} tBTA_DM_MSG; + + +#define BTA_DM_NUM_PEER_DEVICE 7 + +#define BTA_DM_NOT_CONNECTED 0 +#define BTA_DM_CONNECTED 1 +#define BTA_DM_UNPAIRING 2 +typedef UINT8 tBTA_DM_CONN_STATE; + + +#define BTA_DM_DI_NONE 0x00 /* nothing special */ +#define BTA_DM_DI_USE_SSR 0x10 /* set this bit if ssr is supported for this link */ +#define BTA_DM_DI_AV_ACTIVE 0x20 /* set this bit if AV is active for this link */ +#define BTA_DM_DI_SET_SNIFF 0x01 /* set this bit if call BTM_SetPowerMode(sniff) */ +#define BTA_DM_DI_INT_SNIFF 0x02 /* set this bit if call BTM_SetPowerMode(sniff) & enter sniff mode */ +#define BTA_DM_DI_ACP_SNIFF 0x04 /* set this bit if peer init sniff */ +typedef UINT8 tBTA_DM_DEV_INFO; + +/* set power mode request type */ +#define BTA_DM_PM_RESTART 1 +#define BTA_DM_PM_NEW_REQ 2 +#define BTA_DM_PM_EXECUTE 3 +typedef UINT8 tBTA_DM_PM_REQ; + +typedef struct { + BD_ADDR peer_bdaddr; + UINT16 link_policy; + tBTA_DM_CONN_STATE conn_state; + tBTA_PREF_ROLES pref_role; + BOOLEAN in_use; + tBTA_DM_DEV_INFO info; + tBTA_DM_ENCRYPT_CBACK *p_encrypt_cback; +#if (BTM_SSR_INCLUDED == TRUE) + tBTM_PM_STATUS prev_low; /* previous low power mode used */ +#endif + tBTA_DM_PM_ACTION pm_mode_attempted; + tBTA_DM_PM_ACTION pm_mode_failed; + BOOLEAN remove_dev_pending; +#if BLE_INCLUDED == TRUE + UINT16 conn_handle; + tBT_TRANSPORT transport; +#endif +} tBTA_DM_PEER_DEVICE; + + + +/* structure to store list of + active connections */ +typedef struct { + tBTA_DM_PEER_DEVICE peer_device[BTA_DM_NUM_PEER_DEVICE]; + UINT8 count; +#if BLE_INCLUDED == TRUE + UINT8 le_count; +#endif +} tBTA_DM_ACTIVE_LINK; + + +typedef struct { + BD_ADDR peer_bdaddr; + tBTA_SYS_ID id; + UINT8 app_id; + tBTA_SYS_CONN_STATUS state; + BOOLEAN new_request; + +} tBTA_DM_SRVCS; + +#ifndef BTA_DM_NUM_CONN_SRVS +#define BTA_DM_NUM_CONN_SRVS 10 +#endif + +typedef struct { + + UINT8 count; + tBTA_DM_SRVCS conn_srvc[BTA_DM_NUM_CONN_SRVS]; + +} tBTA_DM_CONNECTED_SRVCS; + +typedef struct { +#define BTA_DM_PM_SNIFF_TIMER_IDX 0 +#define BTA_DM_PM_PARK_TIMER_IDX 1 +#define BTA_DM_PM_SUSPEND_TIMER_IDX 2 +#define BTA_DM_PM_MODE_TIMER_MAX 3 + /* + * Keep three different timers for PARK, SNIFF and SUSPEND if TBFC is + * supported. + */ + TIMER_LIST_ENT timer[BTA_DM_PM_MODE_TIMER_MAX]; + + UINT8 srvc_id[BTA_DM_PM_MODE_TIMER_MAX]; + UINT8 pm_action[BTA_DM_PM_MODE_TIMER_MAX]; + UINT8 active; /* number of active timer */ + + BD_ADDR peer_bdaddr; + BOOLEAN in_use; +} tBTA_PM_TIMER; + +extern tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs; + +#define BTA_DM_NUM_PM_TIMER 7 + +/* DM control block */ +typedef struct { + BOOLEAN is_bta_dm_active; + tBTA_DM_ACTIVE_LINK device_list; + tBTA_DM_SEC_CBACK *p_sec_cback; +#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) + tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback; + tBTA_DM_BLE_PF_CFG_CBACK *p_scan_filt_cfg_cback; + tBTA_DM_BLE_PF_STATUS_CBACK *p_scan_filt_status_cback; + tBTA_DM_BLE_PF_PARAM_CBACK *p_scan_filt_param_cback; + tBTA_BLE_MULTI_ADV_CBACK *p_multi_adv_cback; + tBTA_BLE_ENERGY_INFO_CBACK *p_energy_info_cback; +#endif + UINT16 state; + BOOLEAN disabling; + TIMER_LIST_ENT disable_timer; + UINT32 wbt_sdp_handle; /* WIDCOMM Extensions SDP record handle */ + UINT8 wbt_scn; /* WIDCOMM Extensions SCN */ + UINT8 num_master_only; +#if BTM_SSR_INCLUDED == TRUE + UINT8 pm_id; + tBTA_PM_TIMER pm_timer[BTA_DM_NUM_PM_TIMER]; +#endif ///BTM_SSR_INCLUDED == TRUE + UINT32 role_policy_mask; /* the bits set indicates the modules that wants to remove role switch from the default link policy */ + UINT16 cur_policy; /* current default link policy */ + UINT16 rs_event; /* the event waiting for role switch */ + UINT8 cur_av_count; /* current AV connecions */ + BOOLEAN disable_pair_mode; /* disable pair mode or not */ + BOOLEAN conn_paired_only; /* allow connectable to paired device only or not */ + tBTA_DM_API_SEARCH search_msg; + UINT16 page_scan_interval; + UINT16 page_scan_window; + UINT16 inquiry_scan_interval; + UINT16 inquiry_scan_window; + + /* Storage for pin code request parameters */ + BD_ADDR pin_bd_addr; + DEV_CLASS pin_dev_class; + tBTA_DM_SEC_EVT pin_evt; + UINT32 num_val; /* the numeric value for comparison. If just_works, do not show this number to UI */ + BOOLEAN just_works; /* TRUE, if "Just Works" association model */ +#if ( BTA_EIR_CANNED_UUID_LIST != TRUE ) + /* store UUID list for EIR */ + TIMER_LIST_ENT app_ready_timer; + UINT32 eir_uuid[BTM_EIR_SERVICE_ARRAY_SIZE]; +#if (BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0) + tBT_UUID custom_uuid[BTA_EIR_SERVER_NUM_CUSTOM_UUID]; +#endif + +#endif + + + tBTA_DM_ENCRYPT_CBACK *p_encrypt_cback; + TIMER_LIST_ENT switch_delay_timer; + +} tBTA_DM_CB; + +#ifndef BTA_DM_SDP_DB_SIZE +#define BTA_DM_SDP_DB_SIZE 250 +#endif + +/* DM search control block */ +typedef struct { + + tBTA_DM_SEARCH_CBACK *p_search_cback; + tBTM_INQ_INFO *p_btm_inq_info; + tBTA_SERVICE_MASK services; + tBTA_SERVICE_MASK services_to_search; + tBTA_SERVICE_MASK services_found; +#if (SDP_INCLUDED == TRUE) + tSDP_DISCOVERY_DB *p_sdp_db; +#endif ///SDP_INCLUDED == TRUE + UINT16 state; + BD_ADDR peer_bdaddr; + BOOLEAN name_discover_done; + BD_NAME peer_name; + TIMER_LIST_ENT search_timer; + UINT8 service_index; + tBTA_DM_MSG *p_search_queue; /* search or discover commands during search cancel stored here */ + BOOLEAN wait_disc; + BOOLEAN sdp_results; +#if (SDP_INCLUDED == TRUE) + tSDP_UUID uuid; +#endif ///SDP_INCLUDED == TRUE + UINT8 peer_scn; + BOOLEAN sdp_search; + BOOLEAN cancel_pending; /* inquiry cancel is pending */ + tBTA_TRANSPORT transport; +#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) + tBTA_DM_SEARCH_CBACK *p_scan_cback; +#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE) + tBTA_GATTC_IF client_if; + UINT8 num_uuid; + tBT_UUID *p_srvc_uuid; + UINT8 uuid_to_search; + BOOLEAN gatt_disc_active; + UINT16 conn_id; + UINT8 *p_ble_rawdata; + UINT32 ble_raw_size; + UINT32 ble_raw_used; + TIMER_LIST_ENT gatt_close_timer; /* GATT channel close delay timer */ + BD_ADDR pending_close_bda; /* pending GATT channel remote device address */ +#endif +#endif + + +} tBTA_DM_SEARCH_CB; + +/* DI control block */ +typedef struct { +#if (SDP_INCLUDED == TRUE) + tSDP_DISCOVERY_DB *p_di_db; /* pointer to the DI discovery database */ +#endif ///SDP_INCLUDED == TRUE + UINT8 di_num; /* total local DI record number */ + UINT32 di_handle[BTA_DI_NUM_MAX]; /* local DI record handle, the first one is primary record */ +} tBTA_DM_DI_CB; + +/* DM search state */ +enum { + + BTA_DM_SEARCH_IDLE, + BTA_DM_SEARCH_ACTIVE, + BTA_DM_SEARCH_CANCELLING, + BTA_DM_DISCOVER_ACTIVE + +}; + + + +typedef struct { + DEV_CLASS dev_class; /* local device class */ + UINT16 policy_settings; /* link policy setting hold, sniff, park, MS switch */ + UINT16 page_timeout; /* timeout for page in slots */ + UINT16 link_timeout; /* link supervision timeout in slots */ + BOOLEAN avoid_scatter; /* TRUE to avoid scatternet when av is streaming (be the master) */ + +} tBTA_DM_CFG; + +extern const UINT32 bta_service_id_to_btm_srv_id_lkup_tbl[]; + + +typedef struct { + UINT8 id; + UINT8 app_id; + UINT8 cfg; + +} tBTA_DM_RM ; + +extern tBTA_DM_CFG *p_bta_dm_cfg; +extern tBTA_DM_RM *p_bta_dm_rm_cfg; + +typedef struct { + + UINT8 id; + UINT8 app_id; + UINT8 spec_idx; /* index of spec table to use */ + +} tBTA_DM_PM_CFG; + + +typedef struct { + + tBTA_DM_PM_ACTION power_mode; + UINT16 timeout; + +} tBTA_DM_PM_ACTN; + +typedef struct { + + UINT8 allow_mask; /* mask of sniff/hold/park modes to allow */ +#if (BTM_SSR_INCLUDED == TRUE) + UINT8 ssr; /* set SSR on conn open/unpark */ +#endif + tBTA_DM_PM_ACTN actn_tbl [BTA_DM_PM_NUM_EVTS][2]; + +} tBTA_DM_PM_SPEC; + +typedef struct { + UINT16 max_lat; + UINT16 min_rmt_to; + UINT16 min_loc_to; +} tBTA_DM_SSR_SPEC; + +typedef struct { + UINT16 manufacturer; + UINT16 lmp_sub_version; + UINT8 lmp_version; +} tBTA_DM_LMP_VER_INFO; + +extern tBTA_DM_PM_CFG *p_bta_dm_pm_cfg; +extern tBTA_DM_PM_SPEC *p_bta_dm_pm_spec; +extern tBTM_PM_PWR_MD *p_bta_dm_pm_md; +#if (BTM_SSR_INCLUDED == TRUE) +extern tBTA_DM_SSR_SPEC *p_bta_dm_ssr_spec; +#endif + +/* update dynamic BRCM Aware EIR data */ +extern const tBTA_DM_EIR_CONF bta_dm_eir_cfg; +extern tBTA_DM_EIR_CONF *p_bta_dm_eir_cfg; + +/* DM control block */ +#if BTA_DYNAMIC_MEMORY == FALSE +extern tBTA_DM_CB bta_dm_cb; +#else +extern tBTA_DM_CB *bta_dm_cb_ptr; +#define bta_dm_cb (*bta_dm_cb_ptr) +#endif + +/* DM search control block */ +#if BTA_DYNAMIC_MEMORY == FALSE +extern tBTA_DM_SEARCH_CB bta_dm_search_cb; +#else +extern tBTA_DM_SEARCH_CB *bta_dm_search_cb_ptr; +#define bta_dm_search_cb (*bta_dm_search_cb_ptr) +#endif + +/* DI control block */ +#if BTA_DYNAMIC_MEMORY == FALSE +extern tBTA_DM_DI_CB bta_dm_di_cb; +#else +extern tBTA_DM_DI_CB *bta_dm_di_cb_ptr; +#define bta_dm_di_cb (*bta_dm_di_cb_ptr) +#endif + +extern BOOLEAN bta_dm_sm_execute(BT_HDR *p_msg); +extern void bta_dm_sm_disable( void ); +extern void bta_dm_sm_deinit(void); +extern BOOLEAN bta_dm_search_sm_execute(BT_HDR *p_msg); +extern void bta_dm_search_sm_disable( void ); + + +extern void bta_dm_enable (tBTA_DM_MSG *p_data); +extern void bta_dm_disable (tBTA_DM_MSG *p_data); +extern void bta_dm_set_dev_name (tBTA_DM_MSG *p_data); +extern void bta_dm_update_white_list(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data); +extern void bta_dm_set_visibility (tBTA_DM_MSG *p_data); + +extern void bta_dm_set_scan_config(tBTA_DM_MSG *p_data); +extern void bta_dm_vendor_spec_command(tBTA_DM_MSG *p_data); +extern void bta_dm_bond (tBTA_DM_MSG *p_data); +extern void bta_dm_bond_cancel (tBTA_DM_MSG *p_data); +extern void bta_dm_pin_reply (tBTA_DM_MSG *p_data); +extern void bta_dm_acl_change(tBTA_DM_MSG *p_data); +extern void bta_dm_add_device (tBTA_DM_MSG *p_data); +extern void bta_dm_remove_device (tBTA_DM_MSG *p_data); +extern void bta_dm_close_acl(tBTA_DM_MSG *p_data); + + +extern void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data); +extern void bta_dm_pm_timer(tBTA_DM_MSG *p_data); +extern void bta_dm_add_ampkey (tBTA_DM_MSG *p_data); + +#if BLE_INCLUDED == TRUE +extern void bta_dm_add_blekey (tBTA_DM_MSG *p_data); +extern void bta_dm_add_ble_device (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_passkey_reply (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_confirm_reply (tBTA_DM_MSG *p_data); +extern void bta_dm_security_grant (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_bg_conn_type (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_conn_params (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_scan_params(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_scan_fil_params(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_conn_scan_params (tBTA_DM_MSG *p_data); +#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE) +extern void bta_dm_close_gatt_conn(tBTA_DM_MSG *p_data); +#endif /* ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE) */ +extern void bta_dm_ble_observe (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_scan (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_update_conn_params (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_adv_params_all(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_adv_config_raw (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_scan_rsp_raw (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data); +extern void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data); + +#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE +extern void bta_dm_cfg_filter_cond (tBTA_DM_MSG *p_data); +extern void bta_dm_scan_filter_param_setup (tBTA_DM_MSG *p_data); +extern void bta_dm_enable_scan_filter(tBTA_DM_MSG *p_data); +#endif +extern void btm_dm_ble_multi_adv_disable(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_multi_adv_data(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_multi_adv_upd_param(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_multi_adv_enb(tBTA_DM_MSG *p_data); + +extern void bta_dm_ble_setup_storage(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_enable_batch_scan(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_disable_batch_scan(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_read_scan_reports(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_track_advertiser(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_get_energy_info(tBTA_DM_MSG *p_data); + +#endif +extern void bta_dm_set_encryption(tBTA_DM_MSG *p_data); +extern void bta_dm_confirm(tBTA_DM_MSG *p_data); +#if (BTM_OOB_INCLUDED == TRUE) +extern void bta_dm_loc_oob(tBTA_DM_MSG *p_data); +extern void bta_dm_ci_io_req_act(tBTA_DM_MSG *p_data); +extern void bta_dm_ci_rmt_oob_act(tBTA_DM_MSG *p_data); +#endif /* BTM_OOB_INCLUDED */ + +extern void bta_dm_init_pm(void); +extern void bta_dm_disable_pm(void); + +extern UINT8 bta_dm_get_av_count(void); +extern void bta_dm_search_start (tBTA_DM_MSG *p_data); +extern void bta_dm_search_cancel (tBTA_DM_MSG *p_data); +extern void bta_dm_discover (tBTA_DM_MSG *p_data); +#if (SDP_INCLUDED == TRUE) +extern void bta_dm_di_disc (tBTA_DM_MSG *p_data); +#endif ///SDP_INCLUDED == TRUE +extern void bta_dm_inq_cmpl (tBTA_DM_MSG *p_data); +extern void bta_dm_rmt_name (tBTA_DM_MSG *p_data); +#if (SDP_INCLUDED == TRUE) +extern void bta_dm_sdp_result (tBTA_DM_MSG *p_data); +#endif ///SDP_INCLUDED == TRUE +extern void bta_dm_search_cmpl (tBTA_DM_MSG *p_data); +extern void bta_dm_free_sdp_db (tBTA_DM_MSG *p_data); +extern void bta_dm_disc_result (tBTA_DM_MSG *p_data); +extern void bta_dm_search_result (tBTA_DM_MSG *p_data); +extern void bta_dm_discovery_cmpl (tBTA_DM_MSG *p_data); +extern void bta_dm_queue_search (tBTA_DM_MSG *p_data); +extern void bta_dm_queue_disc (tBTA_DM_MSG *p_data); +extern void bta_dm_search_clear_queue (tBTA_DM_MSG *p_data); +extern void bta_dm_search_cancel_cmpl (tBTA_DM_MSG *p_data); +extern void bta_dm_search_cancel_notify (tBTA_DM_MSG *p_data); +extern void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data); +extern void bta_dm_disc_rmt_name (tBTA_DM_MSG *p_data); +extern tBTA_DM_PEER_DEVICE *bta_dm_find_peer_device(BD_ADDR peer_addr); + +extern void bta_dm_pm_active(BD_ADDR peer_addr); + +void bta_dm_eir_update_uuid(UINT16 uuid16, BOOLEAN adding); + +extern void bta_dm_enable_test_mode(tBTA_DM_MSG *p_data); +extern void bta_dm_disable_test_mode(tBTA_DM_MSG *p_data); +extern void bta_dm_execute_callback(tBTA_DM_MSG *p_data); + + +extern void bta_dm_remove_all_acl(tBTA_DM_MSG *p_data); +#endif /* BTA_DM_INT_H */ diff --git a/tools/sdk/include/bluedroid/bta_gatt_api.h b/tools/sdk/include/bluedroid/bta_gatt_api.h index 95f68152164..3d36961b0bb 100644 --- a/tools/sdk/include/bluedroid/bta_gatt_api.h +++ b/tools/sdk/include/bluedroid/bta_gatt_api.h @@ -181,13 +181,15 @@ typedef UINT8 tBTA_GATT_STATUS; #define BTA_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */ #define BTA_GATTC_CONNECT_EVT 35 /* GATTC CONNECT event */ #define BTA_GATTC_DISCONNECT_EVT 36 /* GATTC DISCONNECT event */ -#define BTA_GATTC_READ_MUTIPLE_EVT 37 /* GATTC Read mutiple event */ +#define BTA_GATTC_READ_MULTIPLE_EVT 37 /* GATTC Read mutiple event */ #define BTA_GATTC_QUEUE_FULL_EVT 38 /* GATTC queue full event */ typedef UINT8 tBTA_GATTC_EVT; typedef tGATT_IF tBTA_GATTC_IF; +typedef UINT8 tBTA_ADDR_TYPE; + typedef struct { UINT16 unit; /* as UUIUD defined by SIG */ UINT16 descr; /* as UUID as defined by SIG */ @@ -387,27 +389,30 @@ typedef struct { BD_ADDR remote_bda; } tBTA_GATTC_DISCONNECT; - +typedef struct { + UINT16 conn_id; + BD_ADDR remote_bda; +} tBTA_GATTC_SERVICE_CHANGE; typedef union { tBTA_GATT_STATUS status; - tBTA_GATTC_SEARCH_CMPL search_cmpl; /* discovery complete */ - tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */ - tBTA_GATTC_REG reg_oper; /* registration data */ + tBTA_GATTC_SEARCH_CMPL search_cmpl; /* discovery complete */ + tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */ + tBTA_GATTC_REG reg_oper; /* registration data */ tBTA_GATTC_OPEN open; tBTA_GATTC_CONNECT connect; tBTA_GATTC_CLOSE close; tBTA_GATTC_DISCONNECT disconnect; - tBTA_GATTC_READ read; /* read attribute/descriptor data */ - tBTA_GATTC_WRITE write; /* write complete data */ - tBTA_GATTC_EXEC_CMPL exec_cmpl; /* execute complete */ - tBTA_GATTC_NOTIFY notify; /* notification/indication event data */ + tBTA_GATTC_READ read; /* read attribute/descriptor data */ + tBTA_GATTC_WRITE write; /* write complete data */ + tBTA_GATTC_EXEC_CMPL exec_cmpl; /* execute complete */ + tBTA_GATTC_NOTIFY notify; /* notification/indication event data */ tBTA_GATTC_ENC_CMPL_CB enc_cmpl; - BD_ADDR remote_bda; /* service change event */ tBTA_GATTC_CFG_MTU cfg_mtu; /* configure MTU operation */ tBTA_GATTC_CONGEST congest; tBTA_GATTC_QUEUE_FULL queue_full; + tBTA_GATTC_SERVICE_CHANGE srvc_chg; /* service change event */ } tBTA_GATTC; /* GATTC enable callback function */ @@ -737,13 +742,14 @@ extern void BTA_GATTC_AppDeregister (tBTA_GATTC_IF client_if); ** ** Parameters client_if: server interface. ** remote_bda: remote device BD address. +** remote_addr_type: remote device BD address type. ** is_direct: direct connection or background auto connection ** ** Returns void ** *******************************************************************************/ -extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, - BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport); +extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type, + BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport); /******************************************************************************* ** diff --git a/tools/sdk/include/bluedroid/bta_gattc_int.h b/tools/sdk/include/bluedroid/bta_gattc_int.h index 59810b223cf..8ce71871699 100644 --- a/tools/sdk/include/bluedroid/bta_gattc_int.h +++ b/tools/sdk/include/bluedroid/bta_gattc_int.h @@ -30,6 +30,7 @@ #include "bta_gattc_ci.h" #include "bta_gattc_co.h" #include "fixed_queue.h" +#include "mutex.h" /***************************************************************************** ** Constants and data types @@ -115,6 +116,7 @@ typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_INT_DEREG; typedef struct { BT_HDR hdr; BD_ADDR remote_bda; + tBTA_ADDR_TYPE remote_addr_type; tBTA_GATTC_IF client_if; BOOLEAN is_direct; tBTA_TRANSPORT transport; @@ -191,6 +193,7 @@ typedef struct { UINT8 role; tBT_TRANSPORT transport; tGATT_DISCONN_REASON reason; + BOOLEAN already_connect; } tBTA_GATTC_INT_CONN; typedef struct { @@ -324,7 +327,7 @@ typedef struct { UINT16 reason; } tBTA_GATTC_CLCB; -/* back ground connection tracking information */ +/* background connection tracking information */ #if GATT_MAX_APPS <= 8 typedef UINT8 tBTA_GATTC_CIF_MASK ; #elif GATT_MAX_APPS <= 16 @@ -357,8 +360,8 @@ enum { }; typedef struct { - UINT8 state; - + UINT8 state; + osi_mutex_t write_ccc_mutex; tBTA_GATTC_CONN conn_track[BTA_GATTC_CONN_MAX]; tBTA_GATTC_BG_TCK bg_track[BTA_GATTC_KNOWN_SR_MAX]; tBTA_GATTC_RCB cl_rcb[BTA_GATTC_CL_MAX]; @@ -514,5 +517,6 @@ extern BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda); extern bool bta_gattc_cache_load(tBTA_GATTC_CLCB *p_clcb); extern void bta_gattc_cache_reset(BD_ADDR server_bda); +extern void bta_gattc_deinit(void); #endif /* BTA_GATTC_INT_H */ diff --git a/tools/sdk/include/bluedroid/bta_gatts_int.h b/tools/sdk/include/bluedroid/bta_gatts_int.h index 211929f2075..9d04423f3d3 100644 --- a/tools/sdk/include/bluedroid/bta_gatts_int.h +++ b/tools/sdk/include/bluedroid/bta_gatts_int.h @@ -249,7 +249,7 @@ extern UINT8 bta_gatts_find_app_rcb_idx_by_app_if(tBTA_GATTS_CB *p_cb, tBTA_GATT extern UINT8 bta_gatts_alloc_srvc_cb(tBTA_GATTS_CB *p_cb, UINT8 rcb_idx); extern tBTA_GATTS_SRVC_CB *bta_gatts_find_srvc_cb_by_srvc_id(tBTA_GATTS_CB *p_cb, UINT16 service_id); extern tBTA_GATTS_SRVC_CB *bta_gatts_find_srvc_cb_by_attr_id(tBTA_GATTS_CB *p_cb, UINT16 attr_id); - +extern void bta_gatts_deinit(void); #endif /* BTA_GATTS_INT_H */ diff --git a/tools/sdk/include/bluedroid/bta_hh_int.h b/tools/sdk/include/bluedroid/bta_hh_int.h new file mode 100644 index 00000000000..e3d296ee766 --- /dev/null +++ b/tools/sdk/include/bluedroid/bta_hh_int.h @@ -0,0 +1,401 @@ +/****************************************************************************** + * + * Copyright (C) 2005-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This file contains BTA HID Host internal definitions + * + ******************************************************************************/ + +#ifndef BTA_HH_INT_H +#define BTA_HH_INT_H + +#include "bta_sys.h" +#include "utl.h" +#include "bta_hh_api.h" + +//#if BTA_HH_LE_INCLUDED == TRUE +#include "bta_gatt_api.h" +//#endif +#if defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE) + +/* can be moved to bta_api.h */ +#define BTA_HH_MAX_RPT_CHARS 8 + +#if (BTA_GATT_INCLUDED == FALSE || BLE_INCLUDED == FALSE) +#undef BTA_HH_LE_INCLUDED +#define BTA_HH_LE_INCLUDED FALSE +#endif + +/* state machine events, these events are handled by the state machine */ +enum { + BTA_HH_API_OPEN_EVT = BTA_SYS_EVT_START(BTA_ID_HH), + BTA_HH_API_CLOSE_EVT, + BTA_HH_INT_OPEN_EVT, + BTA_HH_INT_CLOSE_EVT, + BTA_HH_INT_DATA_EVT, + BTA_HH_INT_CTRL_DATA, + BTA_HH_INT_HANDSK_EVT, + BTA_HH_SDP_CMPL_EVT, + BTA_HH_API_WRITE_DEV_EVT, + BTA_HH_API_GET_DSCP_EVT, + BTA_HH_API_MAINT_DEV_EVT, + BTA_HH_OPEN_CMPL_EVT, +#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) + BTA_HH_GATT_CLOSE_EVT, + BTA_HH_GATT_OPEN_EVT, + BTA_HH_START_ENC_EVT, + BTA_HH_ENC_CMPL_EVT, + BTA_HH_GATT_READ_CHAR_CMPL_EVT, + BTA_HH_GATT_WRITE_CHAR_CMPL_EVT, + BTA_HH_GATT_READ_DESCR_CMPL_EVT, + BTA_HH_GATT_WRITE_DESCR_CMPL_EVT, + BTA_HH_API_SCPP_UPDATE_EVT, + BTA_HH_GATT_ENC_CMPL_EVT, +#endif + + /* not handled by execute state machine */ + BTA_HH_API_ENABLE_EVT, + BTA_HH_API_DISABLE_EVT, + BTA_HH_DISC_CMPL_EVT +}; +typedef UINT16 tBTA_HH_INT_EVT; /* HID host internal events */ + +#define BTA_HH_INVALID_EVT (BTA_HH_DISC_CMPL_EVT + 1) + +/* event used to map between BTE event and BTA event */ +#define BTA_HH_FST_TRANS_CB_EVT BTA_HH_GET_RPT_EVT +#define BTA_HH_FST_BTE_TRANS_EVT HID_TRANS_GET_REPORT + +/* sub event code used for device maintainence API call */ +#define BTA_HH_ADD_DEV 0 +#define BTA_HH_REMOVE_DEV 1 + +/* state machine states */ +enum { + BTA_HH_NULL_ST, + BTA_HH_IDLE_ST, + BTA_HH_W4_CONN_ST, + BTA_HH_CONN_ST +#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) + , BTA_HH_W4_SEC +#endif + , BTA_HH_INVALID_ST /* Used to check invalid states before executing SM function */ + +}; +typedef UINT8 tBTA_HH_STATE; + +/* data structure used to send a command/data to HID device */ +typedef struct { + BT_HDR hdr; + UINT8 t_type; + UINT8 param; + UINT8 rpt_id; +#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) + UINT8 srvc_id; +#endif + UINT16 data; + BT_HDR *p_data; +} tBTA_HH_CMD_DATA; + +/* data type for BTA_HH_API_ENABLE_EVT */ +typedef struct { + BT_HDR hdr; + UINT8 sec_mask; + UINT8 service_name[BTA_SERVICE_NAME_LEN + 1]; + tBTA_HH_CBACK *p_cback; +} tBTA_HH_API_ENABLE; + +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + UINT8 sec_mask; + tBTA_HH_PROTO_MODE mode; +} tBTA_HH_API_CONN; + +/* internal event data from BTE HID callback */ +typedef struct { + BT_HDR hdr; + BD_ADDR addr; + UINT32 data; + BT_HDR *p_data; +} tBTA_HH_CBACK_DATA; + +typedef struct { + BT_HDR hdr; + BD_ADDR bda; + UINT16 attr_mask; + UINT16 sub_event; + UINT8 sub_class; + UINT8 app_id; + tBTA_HH_DEV_DSCP_INFO dscp_info; +} tBTA_HH_MAINT_DEV; + +#if BTA_HH_LE_INCLUDED == TRUE +typedef struct { + BT_HDR hdr; + UINT16 conn_id; + tBTA_GATT_REASON reason; /* disconnect reason code, not useful when connect event is reported */ + +} tBTA_HH_LE_CLOSE; + +typedef struct { + BT_HDR hdr; + UINT16 scan_int; + UINT16 scan_win; +} tBTA_HH_SCPP_UPDATE; +#endif +/* union of all event data types */ +typedef union { + BT_HDR hdr; + tBTA_HH_API_ENABLE api_enable; + tBTA_HH_API_CONN api_conn; + tBTA_HH_CMD_DATA api_sndcmd; + tBTA_HH_CBACK_DATA hid_cback; + tBTA_HH_STATUS status; + tBTA_HH_MAINT_DEV api_maintdev; +#if BTA_HH_LE_INCLUDED == TRUE + tBTA_HH_LE_CLOSE le_close; + tBTA_GATTC_OPEN le_open; + tBTA_HH_SCPP_UPDATE le_scpp_update; + tBTA_GATTC_ENC_CMPL_CB le_enc_cmpl; +#endif +} tBTA_HH_DATA; + +#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) +typedef struct { + UINT8 index; + BOOLEAN in_use; + UINT8 inst_id; /* share service instance ID and report instance ID, as + hi 4 for service instance ID, low 4 as charatceristic instance ID */ + tBTA_HH_RPT_TYPE rpt_type; + UINT16 uuid; + UINT8 prop; + UINT8 rpt_id; + BOOLEAN client_cfg_exist; + UINT16 client_cfg_value; +} tBTA_HH_LE_RPT; + +#ifndef BTA_HH_LE_RPT_MAX +#define BTA_HH_LE_RPT_MAX 20 +#endif + +typedef struct { + BOOLEAN in_use; + tBTA_HH_LE_RPT report[BTA_HH_LE_RPT_MAX]; + +#define BTA_HH_LE_PROTO_MODE_BIT 0x01 +#define BTA_HH_LE_CP_BIT 0x02 + UINT8 option_char; /* control point char exisit or not */ + + BOOLEAN expl_incl_srvc; + UINT8 incl_srvc_inst; /* assuming only one included service : battery service */ + UINT8 cur_expl_char_idx; /* currently discovering service index */ + UINT8 *rpt_map; + UINT16 ext_rpt_ref; + tBTA_HH_DEV_DESCR descriptor; + +} tBTA_HH_LE_HID_SRVC; + +#ifndef BTA_HH_LE_HID_SRVC_MAX +#define BTA_HH_LE_HID_SRVC_MAX 1 +#endif + +/* convert a HID handle to the LE CB index */ +#define BTA_HH_GET_LE_CB_IDX(x) (((x) >> 4) - 1) +/* convert a GATT connection ID to HID device handle, it is the hi 4 bits of a UINT8 */ +#define BTA_HH_GET_LE_DEV_HDL(x) (UINT8)(((x) + 1) << 4) +/* check to see if th edevice handle is a LE device handle */ +#define BTA_HH_IS_LE_DEV_HDL(x) ((x) & 0xf0) +#define BTA_HH_IS_LE_DEV_HDL_VALID(x) (((x)>>4) <= BTA_HH_LE_MAX_KNOWN) +#endif + +/* device control block */ +typedef struct { + tBTA_HH_DEV_DSCP_INFO dscp_info; /* report descriptor and DI information */ + BD_ADDR addr; /* BD-Addr of the HID device */ + UINT16 attr_mask; /* attribute mask */ + UINT16 w4_evt; /* W4_handshake event name */ + UINT8 index; /* index number referenced to handle index */ + UINT8 sub_class; /* Cod sub class */ + UINT8 sec_mask; /* security mask */ + UINT8 app_id; /* application ID for this connection */ + UINT8 hid_handle; /* device handle : low 4 bits for regular HID: HID_HOST_MAX_DEVICES can not exceed 15; + high 4 bits for LE HID: GATT_MAX_PHY_CHANNEL can not exceed 15 */ + BOOLEAN vp; /* virtually unplug flag */ + BOOLEAN in_use; /* control block currently in use */ + BOOLEAN incoming_conn; /* is incoming connection? */ + UINT8 incoming_hid_handle; /* temporary handle for incoming connection? */ + BOOLEAN opened; /* TRUE if device successfully opened HID connection */ + tBTA_HH_PROTO_MODE mode; /* protocol mode */ + tBTA_HH_STATE state; /* CB state */ + +#if (BTA_HH_LE_INCLUDED == TRUE) +#define BTA_HH_LE_DISC_NONE 0x00 +#define BTA_HH_LE_DISC_HIDS 0x01 +#define BTA_HH_LE_DISC_DIS 0x02 +#define BTA_HH_LE_DISC_SCPS 0x04 + + UINT8 disc_active; + tBTA_HH_STATUS status; + tBTA_GATT_REASON reason; + BOOLEAN is_le_device; + tBTA_HH_LE_HID_SRVC hid_srvc[BTA_HH_LE_HID_SRVC_MAX]; + UINT16 conn_id; + BOOLEAN in_bg_conn; + UINT8 total_srvc; + UINT8 clt_cfg_idx; + UINT8 cur_srvc_index; /* currently discovering service index */ + BOOLEAN scps_supported; + +#define BTA_HH_LE_SCPS_NOTIFY_NONE 0 +#define BTA_HH_LE_SCPS_NOTIFY_SPT 0x01 +#define BTA_HH_LE_SCPS_NOTIFY_ENB 0x02 + UINT8 scps_notify; /* scan refresh supported/notification enabled */ +#endif + + BOOLEAN security_pending; +} tBTA_HH_DEV_CB; + +/* key board parsing control block */ +typedef struct { + BOOLEAN mod_key[4]; /* ctrl, shift(upper), Alt, GUI */ + BOOLEAN num_lock; + BOOLEAN caps_lock; + UINT8 last_report[BTA_HH_MAX_RPT_CHARS]; +} tBTA_HH_KB_CB; + +/****************************************************************************** +** Main Control Block +*******************************************************************************/ +typedef struct { + tBTA_HH_KB_CB kb_cb; /* key board control block, + suppose BTA will connect + to only one keyboard at + the same time */ + tBTA_HH_DEV_CB kdev[BTA_HH_MAX_DEVICE]; /* device control block */ + tBTA_HH_DEV_CB *p_cur; /* current device control + block idx, used in sdp */ + UINT8 cb_index[BTA_HH_MAX_KNOWN]; /* maintain a CB index + map to dev handle */ +#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) + UINT8 le_cb_index[BTA_HH_MAX_DEVICE]; /* maintain a CB index map to LE dev handle */ + tBTA_GATTC_IF gatt_if; +#endif + tBTA_HH_CBACK *p_cback; /* Application callbacks */ + tSDP_DISCOVERY_DB *p_disc_db; + UINT8 trace_level; /* tracing level */ + UINT8 cnt_num; /* connected device number */ + BOOLEAN w4_disable; /* w4 disable flag */ +} +tBTA_HH_CB; + +#if BTA_DYNAMIC_MEMORY == FALSE +extern tBTA_HH_CB bta_hh_cb; +#else +extern tBTA_HH_CB *bta_hh_cb_ptr; +#define bta_hh_cb (*bta_hh_cb_ptr) +#endif + +/* from bta_hh_cfg.c */ +extern tBTA_HH_CFG *p_bta_hh_cfg; + +/***************************************************************************** +** Function prototypes +*****************************************************************************/ +extern BOOLEAN bta_hh_hdl_event(BT_HDR *p_msg); +extern void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, + tBTA_HH_DATA *p_data); + +/* action functions */ +extern void bta_hh_api_disc_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_open_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_close_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_data_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_ctrl_dat_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_start_sdp(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_sdp_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_write_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_get_dscp_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_handsk_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_maint_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_open_cmpl_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_open_failure(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); + +/* utility functions */ +extern UINT8 bta_hh_find_cb(BD_ADDR bda); +extern void bta_hh_parse_keybd_rpt(tBTA_HH_BOOT_RPT *p_kb_data, + UINT8 *p_report, UINT16 report_len); +extern void bta_hh_parse_mice_rpt(tBTA_HH_BOOT_RPT *p_kb_data, + UINT8 *p_report, UINT16 report_len); +extern BOOLEAN bta_hh_tod_spt(tBTA_HH_DEV_CB *p_cb, UINT8 sub_class); +extern void bta_hh_clean_up_kdev(tBTA_HH_DEV_CB *p_cb); + +extern void bta_hh_add_device_to_list(tBTA_HH_DEV_CB *p_cb, UINT8 handle, + UINT16 attr_mask, + tHID_DEV_DSCP_INFO *p_dscp_info, + UINT8 sub_class, UINT16 max_latency, UINT16 min_tout, UINT8 app_id); +extern void bta_hh_update_di_info(tBTA_HH_DEV_CB *p_cb, UINT16 vendor_id, UINT16 product_id, + UINT16 version, UINT8 flag); +extern void bta_hh_cleanup_disable(tBTA_HH_STATUS status); + +extern UINT8 bta_hh_dev_handle_to_cb_idx(UINT8 dev_handle); + +/* action functions used outside state machine */ +extern void bta_hh_api_enable(tBTA_HH_DATA *p_data); +extern void bta_hh_api_disable(void); +extern void bta_hh_disc_cmpl(void); + +extern tBTA_HH_STATUS bta_hh_read_ssr_param(BD_ADDR bd_addr, UINT16 *p_max_ssr_lat, UINT16 *p_min_ssr_tout); + +/* functions for LE HID */ +extern void bta_hh_le_enable(void); +extern BOOLEAN bta_hh_le_is_hh_gatt_if(tBTA_GATTC_IF client_if); +extern void bta_hh_le_deregister(void); +extern BOOLEAN bta_hh_is_le_device(tBTA_HH_DEV_CB *p_cb, BD_ADDR remote_bda); +extern void bta_hh_le_open_conn(tBTA_HH_DEV_CB *p_cb, BD_ADDR remote_bda); +extern void bta_hh_le_api_disc_act(tBTA_HH_DEV_CB *p_cb); +extern void bta_hh_le_get_dscp_act(tBTA_HH_DEV_CB *p_cb); +extern void bta_hh_le_write_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern UINT8 bta_hh_le_add_device(tBTA_HH_DEV_CB *p_cb, tBTA_HH_MAINT_DEV *p_dev_info); +extern void bta_hh_le_remove_dev_bg_conn(tBTA_HH_DEV_CB *p_cb); +extern void bta_hh_le_open_fail(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_gatt_open(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_gatt_close(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_start_security(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); +extern void bta_hh_start_srvc_discovery(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); +extern void bta_hh_w4_le_read_char_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); +extern void bta_hh_le_read_char_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); +extern void bta_hh_w4_le_read_descr_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); +extern void bta_hh_le_read_descr_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); +extern void bta_hh_w4_le_write_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); +extern void bta_hh_le_write_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); +extern void bta_hh_le_write_char_descr_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); +extern void bta_hh_start_security(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); +extern void bta_hh_security_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); +extern void bta_hh_le_update_scpp(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); +extern void bta_hh_le_notify_enc_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data); +extern void bta_hh_ci_load_rpt (tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf); + +#if BTA_HH_DEBUG +extern void bta_hh_trace_dev_db(void); +#endif + +#endif ///defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE) +#endif + diff --git a/tools/sdk/include/bluedroid/bta_jv_int.h b/tools/sdk/include/bluedroid/bta_jv_int.h new file mode 100644 index 00000000000..2ef9ace3efb --- /dev/null +++ b/tools/sdk/include/bluedroid/bta_jv_int.h @@ -0,0 +1,429 @@ +/****************************************************************************** + * + * Copyright (C) 2006-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the private interface file for the BTA Java I/F + * + ******************************************************************************/ +#ifndef BTA_JV_INT_H +#define BTA_JV_INT_H + +#include "bta_sys.h" +#include "bta_api.h" +#include "bta_jv_api.h" +#include "rfcdefs.h" +#include "port_api.h" +#include "sdp_api.h" + +#include "bt_target.h" +#if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE) +/***************************************************************************** +** Constants +*****************************************************************************/ + +enum { + /* these events are handled by the state machine */ + BTA_JV_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_JV), + BTA_JV_API_DISABLE_EVT, + BTA_JV_API_GET_CHANNEL_EVT, + BTA_JV_API_FREE_SCN_EVT, + BTA_JV_API_START_DISCOVERY_EVT, + BTA_JV_API_CREATE_RECORD_EVT, + BTA_JV_API_DELETE_RECORD_EVT, + BTA_JV_API_L2CAP_CONNECT_EVT, + BTA_JV_API_L2CAP_CLOSE_EVT, + BTA_JV_API_L2CAP_START_SERVER_EVT, + BTA_JV_API_L2CAP_STOP_SERVER_EVT, + BTA_JV_API_L2CAP_READ_EVT, + BTA_JV_API_L2CAP_WRITE_EVT, + BTA_JV_API_RFCOMM_CONNECT_EVT, + BTA_JV_API_RFCOMM_CLOSE_EVT, + BTA_JV_API_RFCOMM_START_SERVER_EVT, + BTA_JV_API_RFCOMM_STOP_SERVER_EVT, + BTA_JV_API_RFCOMM_READ_EVT, + BTA_JV_API_RFCOMM_WRITE_EVT, + BTA_JV_API_SET_PM_PROFILE_EVT, + BTA_JV_API_PM_STATE_CHANGE_EVT, + BTA_JV_API_L2CAP_CONNECT_LE_EVT, + BTA_JV_API_L2CAP_START_SERVER_LE_EVT, + BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT, + BTA_JV_API_L2CAP_WRITE_FIXED_EVT, + BTA_JV_API_L2CAP_CLOSE_FIXED_EVT, + BTA_JV_MAX_INT_EVT +}; + +#ifndef BTA_JV_RFC_EV_MASK +#define BTA_JV_RFC_EV_MASK (PORT_EV_RXCHAR | PORT_EV_TXEMPTY | PORT_EV_FC | PORT_EV_FCS) +#endif + +/* data type for BTA_JV_API_ENABLE_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_JV_DM_CBACK *p_cback; +} tBTA_JV_API_ENABLE; + +/* data type for BTA_JV_API_START_DISCOVERY_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + UINT16 num_uuid; + tSDP_UUID uuid_list[BTA_JV_MAX_UUIDS]; + UINT16 num_attr; + UINT16 attr_list[BTA_JV_MAX_ATTRS]; + void *user_data; /* piggyback caller's private data*/ +} tBTA_JV_API_START_DISCOVERY; + +enum { + BTA_JV_PM_FREE_ST = 0, /* empty PM slot */ + BTA_JV_PM_IDLE_ST, + BTA_JV_PM_BUSY_ST +}; + +/* BTA JV PM control block */ +typedef struct { + UINT32 handle; /* The connection handle */ + UINT8 state; /* state: see above enum */ + tBTA_JV_PM_ID app_id; /* JV app specific id indicating power table to use */ + BD_ADDR peer_bd_addr; /* Peer BD address */ +} tBTA_JV_PM_CB; + +enum { + BTA_JV_ST_NONE = 0, + BTA_JV_ST_CL_OPENING, + BTA_JV_ST_CL_OPEN, + BTA_JV_ST_CL_CLOSING, + BTA_JV_ST_SR_LISTEN, + BTA_JV_ST_SR_OPEN, + BTA_JV_ST_SR_CLOSING +} ; +typedef UINT8 tBTA_JV_STATE; +#define BTA_JV_ST_CL_MAX BTA_JV_ST_CL_CLOSING +/* JV L2CAP control block */ +typedef struct { + tBTA_JV_L2CAP_CBACK *p_cback; /* the callback function */ + UINT16 psm; /* the psm used for this server connection */ + tBTA_JV_STATE state; /* the state of this control block */ + tBTA_SERVICE_ID sec_id; /* service id */ + UINT32 handle; /* the handle reported to java app (same as gap handle) */ + BOOLEAN cong; /* TRUE, if congested */ + tBTA_JV_PM_CB *p_pm_cb; /* ptr to pm control block, NULL: unused */ + void *user_data; /* user data for callback from higher layers */ +} tBTA_JV_L2C_CB; + +#define BTA_JV_RFC_HDL_MASK 0xFF +#define BTA_JV_RFCOMM_MASK 0x80 +#define BTA_JV_ALL_APP_ID 0xFF +#define BTA_JV_RFC_HDL_TO_SIDX(r) (((r)&0xFF00) >> 8) +#define BTA_JV_RFC_H_S_TO_HDL(h, s) ((h)|(s<<8)) + +/* port control block */ +typedef struct { + UINT32 handle; /* the rfcomm session handle at jv */ + UINT16 port_handle;/* port handle */ + tBTA_JV_STATE state; /* the state of this control block */ + UINT8 max_sess; /* max sessions */ + void *user_data; /* piggyback caller's private data*/ + BOOLEAN cong; /* TRUE, if congested */ + tBTA_JV_PM_CB *p_pm_cb; /* ptr to pm control block, NULL: unused */ +} tBTA_JV_PCB; + +/* JV RFCOMM control block */ +typedef struct { + tBTA_JV_RFCOMM_CBACK *p_cback; /* the callback function */ + UINT16 rfc_hdl[BTA_JV_MAX_RFC_SR_SESSION]; + tBTA_SERVICE_ID sec_id; /* service id */ + UINT8 handle; /* index: the handle reported to java app */ + UINT8 scn; /* the scn of the server */ + UINT8 max_sess; /* max sessions */ + int curr_sess; /* current sessions count*/ +} tBTA_JV_RFC_CB; + +/* data type for BTA_JV_API_L2CAP_CONNECT_EVT & BTA_JV_API_L2CAP_CONNECT_LE_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_SEC sec_mask; + tBTA_JV_ROLE role; + union { + UINT16 remote_psm; + UINT16 remote_chan; + }; + UINT16 rx_mtu; + BD_ADDR peer_bd_addr; + INT32 has_cfg; + tL2CAP_CFG_INFO cfg; + INT32 has_ertm_info; + tL2CAP_ERTM_INFO ertm_info; + tBTA_JV_L2CAP_CBACK *p_cback; + void *user_data; +} tBTA_JV_API_L2CAP_CONNECT; + +/* data type for BTA_JV_API_L2CAP_SERVER_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_SEC sec_mask; + tBTA_JV_ROLE role; + union { + UINT16 local_psm; + UINT16 local_chan; + }; + UINT16 rx_mtu; + INT32 has_cfg; + tL2CAP_CFG_INFO cfg; + INT32 has_ertm_info; + tL2CAP_ERTM_INFO ertm_info; + tBTA_JV_L2CAP_CBACK *p_cback; + void *user_data; +} tBTA_JV_API_L2CAP_SERVER; + +/* data type for BTA_JV_API_L2CAP_CLOSE_EVT */ +typedef struct { + BT_HDR hdr; + UINT32 handle; + tBTA_JV_L2C_CB *p_cb; +} tBTA_JV_API_L2CAP_CLOSE; + +/* data type for BTA_JV_API_L2CAP_READ_EVT */ +typedef struct { + BT_HDR hdr; + UINT32 handle; + UINT32 req_id; + tBTA_JV_L2CAP_CBACK *p_cback; + UINT8 *p_data; + UINT16 len; + void *user_data; +} tBTA_JV_API_L2CAP_READ; + +/* data type for BTA_JV_API_L2CAP_WRITE_EVT */ +typedef struct { + BT_HDR hdr; + UINT32 handle; + UINT32 req_id; + tBTA_JV_L2C_CB *p_cb; + UINT8 *p_data; + UINT16 len; + void *user_data; +} tBTA_JV_API_L2CAP_WRITE; + +/* data type for BTA_JV_API_L2CAP_WRITE_FIXED_EVT */ +typedef struct { + BT_HDR hdr; + UINT16 channel; + BD_ADDR addr; + UINT32 req_id; + tBTA_JV_L2CAP_CBACK *p_cback; + UINT8 *p_data; + UINT16 len; + void *user_data; +} tBTA_JV_API_L2CAP_WRITE_FIXED; + +/* data type for BTA_JV_API_RFCOMM_CONNECT_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_SEC sec_mask; + tBTA_JV_ROLE role; + UINT8 remote_scn; + BD_ADDR peer_bd_addr; + tBTA_JV_RFCOMM_CBACK *p_cback; + void *user_data; +} tBTA_JV_API_RFCOMM_CONNECT; + +/* data type for BTA_JV_API_RFCOMM_SERVER_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_SEC sec_mask; + tBTA_JV_ROLE role; + UINT8 local_scn; + UINT8 max_session; + UINT32 handle; + tBTA_JV_RFCOMM_CBACK *p_cback; + void *user_data; +} tBTA_JV_API_RFCOMM_SERVER; + +/* data type for BTA_JV_API_RFCOMM_READ_EVT */ +typedef struct { + BT_HDR hdr; + UINT32 handle; + UINT32 req_id; + UINT8 *p_data; + UINT16 len; + tBTA_JV_RFC_CB *p_cb; + tBTA_JV_PCB *p_pcb; +} tBTA_JV_API_RFCOMM_READ; + +/* data type for BTA_JV_API_SET_PM_PROFILE_EVT */ +typedef struct { + BT_HDR hdr; + UINT32 handle; + tBTA_JV_PM_ID app_id; + tBTA_JV_CONN_STATE init_st; +} tBTA_JV_API_SET_PM_PROFILE; + +/* data type for BTA_JV_API_PM_STATE_CHANGE_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_JV_PM_CB *p_cb; + tBTA_JV_CONN_STATE state; +} tBTA_JV_API_PM_STATE_CHANGE; + +/* data type for BTA_JV_API_RFCOMM_WRITE_EVT */ +typedef struct { + BT_HDR hdr; + UINT32 handle; + UINT32 req_id; + UINT8 *p_data; + int len; + tBTA_JV_RFC_CB *p_cb; + tBTA_JV_PCB *p_pcb; +} tBTA_JV_API_RFCOMM_WRITE; + +/* data type for BTA_JV_API_RFCOMM_CLOSE_EVT */ +typedef struct { + BT_HDR hdr; + UINT32 handle; + tBTA_JV_RFC_CB *p_cb; + tBTA_JV_PCB *p_pcb; + void *user_data; +} tBTA_JV_API_RFCOMM_CLOSE; + +/* data type for BTA_JV_API_CREATE_RECORD_EVT */ +typedef struct { + BT_HDR hdr; +#define ESP_SDP_SERVER_NAME_MAX (32) + char name[ESP_SDP_SERVER_NAME_MAX + 1]; + INT32 channel; + void *user_data; +} tBTA_JV_API_CREATE_RECORD; + +/* data type for BTA_JV_API_ADD_ATTRIBUTE_EVT */ +typedef struct { + BT_HDR hdr; + UINT32 handle; + UINT16 attr_id; + UINT8 *p_value; + INT32 value_size; +} tBTA_JV_API_ADD_ATTRIBUTE; + +/* data type for BTA_JV_API_FREE_SCN_EVT */ +typedef struct { + BT_HDR hdr; + INT32 type; /* One of BTA_JV_CONN_TYPE_ */ + UINT16 scn; +} tBTA_JV_API_FREE_CHANNEL; + +/* data type for BTA_JV_API_ALLOC_CHANNEL_EVT */ +typedef struct { + BT_HDR hdr; + INT32 type; /* One of BTA_JV_CONN_TYPE_ */ + INT32 channel; /* optionally request a specific channel */ + void *user_data; +} tBTA_JV_API_ALLOC_CHANNEL; +/* union of all data types */ +typedef union { + /* GKI event buffer header */ + BT_HDR hdr; + tBTA_JV_API_ENABLE enable; + tBTA_JV_API_START_DISCOVERY start_discovery; + tBTA_JV_API_ALLOC_CHANNEL alloc_channel; + tBTA_JV_API_FREE_CHANNEL free_channel; + tBTA_JV_API_CREATE_RECORD create_record; + tBTA_JV_API_ADD_ATTRIBUTE add_attr; + tBTA_JV_API_L2CAP_CONNECT l2cap_connect; + tBTA_JV_API_L2CAP_READ l2cap_read; + tBTA_JV_API_L2CAP_WRITE l2cap_write; + tBTA_JV_API_L2CAP_CLOSE l2cap_close; + tBTA_JV_API_L2CAP_SERVER l2cap_server; + tBTA_JV_API_RFCOMM_CONNECT rfcomm_connect; + tBTA_JV_API_RFCOMM_READ rfcomm_read; + tBTA_JV_API_RFCOMM_WRITE rfcomm_write; + tBTA_JV_API_SET_PM_PROFILE set_pm; + tBTA_JV_API_PM_STATE_CHANGE change_pm_state; + tBTA_JV_API_RFCOMM_CLOSE rfcomm_close; + tBTA_JV_API_RFCOMM_SERVER rfcomm_server; + tBTA_JV_API_L2CAP_WRITE_FIXED l2cap_write_fixed; +} tBTA_JV_MSG; + +/* JV control block */ +typedef struct { + /* the SDP handle reported to JV user is the (index + 1) to sdp_handle[]. + * if sdp_handle[i]==0, it's not used. + * otherwise sdp_handle[i] is the stack SDP handle. */ + UINT32 sdp_handle[BTA_JV_MAX_SDP_REC]; /* SDP records created */ + UINT8 *p_sel_raw_data;/* the raw data of last service select */ + tBTA_JV_DM_CBACK *p_dm_cback; + tBTA_JV_L2C_CB l2c_cb[BTA_JV_MAX_L2C_CONN]; /* index is GAP handle (index) */ + tBTA_JV_RFC_CB rfc_cb[BTA_JV_MAX_RFC_CONN]; + tBTA_JV_PCB port_cb[MAX_RFC_PORTS]; /* index of this array is + the port_handle, */ + UINT8 sec_id[BTA_JV_NUM_SERVICE_ID]; /* service ID */ + BOOLEAN scn[BTA_JV_MAX_SCN]; /* SCN allocated by java */ + UINT16 free_psm_list[BTA_JV_MAX_L2C_CONN]; /* PSMs freed by java + (can be reused) */ + UINT8 sdp_active; /* see BTA_JV_SDP_ACT_* */ + tSDP_UUID uuid; /* current uuid of sdp discovery*/ + tBTA_JV_PM_CB pm_cb[BTA_JV_PM_MAX_NUM]; /* PM on a per JV handle bases */ +} tBTA_JV_CB; + +enum { + BTA_JV_SDP_ACT_NONE = 0, + BTA_JV_SDP_ACT_YES, /* waiting for SDP result */ + BTA_JV_SDP_ACT_CANCEL /* waiting for cancel complete */ +}; + +/* JV control block */ +#if BTA_DYNAMIC_MEMORY == FALSE +extern tBTA_JV_CB bta_jv_cb; +#else +extern tBTA_JV_CB *bta_jv_cb_ptr; +#define bta_jv_cb (*bta_jv_cb_ptr) +#endif + +/* config struct */ +extern tBTA_JV_CFG *p_bta_jv_cfg; + +extern BOOLEAN bta_jv_sm_execute(BT_HDR *p_msg); + +extern void bta_jv_enable (tBTA_JV_MSG *p_data); +extern void bta_jv_disable (tBTA_JV_MSG *p_data); +extern void bta_jv_get_channel_id (tBTA_JV_MSG *p_data); +extern void bta_jv_free_scn (tBTA_JV_MSG *p_data); +extern void bta_jv_start_discovery (tBTA_JV_MSG *p_data); +extern void bta_jv_create_record (tBTA_JV_MSG *p_data); +extern void bta_jv_delete_record (tBTA_JV_MSG *p_data); +extern void bta_jv_l2cap_connect (tBTA_JV_MSG *p_data); +extern void bta_jv_l2cap_close (tBTA_JV_MSG *p_data); +extern void bta_jv_l2cap_start_server (tBTA_JV_MSG *p_data); +extern void bta_jv_l2cap_stop_server (tBTA_JV_MSG *p_data); +extern void bta_jv_l2cap_read (tBTA_JV_MSG *p_data); +extern void bta_jv_l2cap_write (tBTA_JV_MSG *p_data); +extern void bta_jv_rfcomm_connect (tBTA_JV_MSG *p_data); +extern void bta_jv_rfcomm_close (tBTA_JV_MSG *p_data); +extern void bta_jv_rfcomm_start_server (tBTA_JV_MSG *p_data); +extern void bta_jv_rfcomm_stop_server (tBTA_JV_MSG *p_data); +extern void bta_jv_rfcomm_read (tBTA_JV_MSG *p_data); +extern void bta_jv_rfcomm_write (tBTA_JV_MSG *p_data); +extern void bta_jv_set_pm_profile (tBTA_JV_MSG *p_data); +extern void bta_jv_change_pm_state(tBTA_JV_MSG *p_data); +extern void bta_jv_l2cap_connect_le (tBTA_JV_MSG *p_data); +extern void bta_jv_l2cap_start_server_le (tBTA_JV_MSG *p_data); +extern void bta_jv_l2cap_stop_server_le (tBTA_JV_MSG *p_data); +extern void bta_jv_l2cap_write_fixed (tBTA_JV_MSG *p_data); +extern void bta_jv_l2cap_close_fixed (tBTA_JV_MSG *p_data); + +#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE +#endif /* BTA_JV_INT_H */ diff --git a/tools/sdk/include/bluedroid/bta_sdp_int.h b/tools/sdk/include/bluedroid/bta_sdp_int.h new file mode 100644 index 00000000000..9dee3fc9631 --- /dev/null +++ b/tools/sdk/include/bluedroid/bta_sdp_int.h @@ -0,0 +1,112 @@ + + +/****************************************************************************** + * + * Copyright (C) 2014 The Android Open Source Project + * Copyright (C) 2003-2012 Broadcom Corporation + * + * 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. + * + ******************************************************************************/ + +/****************************************************************************** + * + * This is the private interface file for the BTA SDP I/F + * + ******************************************************************************/ +#ifndef BTA_SDP_INT_H +#define BTA_SDP_INT_H + +#include "bta_sys.h" +#include "bta_api.h" +#include "bta_sdp_api.h" + +#if (SDP_INCLUDED == TRUE) +/***************************************************************************** +** Constants +*****************************************************************************/ + +enum { + /* these events are handled by the state machine */ + BTA_SDP_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_SDP), + BTA_SDP_API_SEARCH_EVT, + BTA_SDP_API_CREATE_RECORD_USER_EVT, + BTA_SDP_API_REMOVE_RECORD_USER_EVT, + BTA_SDP_MAX_INT_EVT +}; + +enum { + BTA_SDP_ACTIVE_NONE = 0, + BTA_SDP_ACTIVE_YES /* waiting for SDP result */ +}; + + + +/* data type for BTA_SDP_API_ENABLE_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_SDP_DM_CBACK *p_cback; +} tBTA_SDP_API_ENABLE; + +/* data type for BTA_SDP_API_SEARCH_EVT */ +typedef struct { + BT_HDR hdr; + BD_ADDR bd_addr; + tSDP_UUID uuid; +} tBTA_SDP_API_SEARCH; + +/* data type for BTA_SDP_API_SEARCH_EVT */ +typedef struct { + BT_HDR hdr; + void *user_data; +} tBTA_SDP_API_RECORD_USER; + +/* union of all data types */ +typedef union { + /* event buffer header */ + BT_HDR hdr; + tBTA_SDP_API_ENABLE enable; + tBTA_SDP_API_SEARCH get_search; + tBTA_SDP_API_RECORD_USER record; +} tBTA_SDP_MSG; + +/* SDP control block */ +typedef struct { + UINT8 sdp_active; /* see BTA_SDP_SDP_ACT_* */ + BD_ADDR remote_addr; + tBTA_SDP_DM_CBACK *p_dm_cback; +} tBTA_SDP_CB; + + +/* SDP control block */ +#if BTA_DYNAMIC_MEMORY == FALSE +extern tBTA_SDP_CB bta_sdp_cb; +#else +extern tBTA_SDP_CB *bta_sdp_cb_ptr; +#define bta_sdp_cb (*bta_sdp_cb_ptr) +#endif + +/* config struct */ +extern tBTA_SDP_CFG *p_bta_sdp_cfg; + +extern BOOLEAN bta_sdp_sm_execute(BT_HDR *p_msg); + +extern void bta_sdp_enable (tBTA_SDP_MSG *p_data); +extern void bta_sdp_search (tBTA_SDP_MSG *p_data); +extern void bta_sdp_create_record(tBTA_SDP_MSG *p_data); +extern void bta_sdp_remove_record(tBTA_SDP_MSG *p_data); + +#endif ///SDP_INCLUDED == TRUE + +#endif /* BTA_SDP_INT_H */ + diff --git a/tools/sdk/include/bluedroid/bta_sys.h b/tools/sdk/include/bluedroid/bta_sys.h index 94ebd805086..01190086939 100644 --- a/tools/sdk/include/bluedroid/bta_sys.h +++ b/tools/sdk/include/bluedroid/bta_sys.h @@ -224,6 +224,7 @@ extern UINT16 bta_sys_get_sys_features(void); extern void bta_sys_sendmsg(void *p_msg); extern void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms); extern void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle); +extern void bta_sys_free_timer(TIMER_LIST_ENT *p_tle); extern void bta_sys_disable(tBTA_SYS_HW_MODULE module); extern UINT32 bta_sys_get_remaining_ticks(TIMER_LIST_ENT *p_target_tle); diff --git a/tools/sdk/include/bluedroid/btc_blufi_prf.h b/tools/sdk/include/bluedroid/btc_blufi_prf.h index 93fe6bf2e9e..06154673a89 100644 --- a/tools/sdk/include/bluedroid/btc_blufi_prf.h +++ b/tools/sdk/include/bluedroid/btc_blufi_prf.h @@ -24,6 +24,8 @@ typedef enum { BTC_BLUFI_ACT_DEINIT, BTC_BLUFI_ACT_SEND_CFG_REPORT, BTC_BLUFI_ACT_SEND_WIFI_LIST, + BTC_BLUFI_ACT_SEND_ERR_INFO, + BTC_BLUFI_ACT_SEND_CUSTOM_DATA, } btc_blufi_act_t; typedef union { @@ -41,6 +43,19 @@ typedef union { uint16_t apCount; esp_blufi_ap_record_t *list; } wifi_list; + /* + BTC_BLUFI_ACT_SEND_ERR_INFO + */ + struct blufi_error_infor { + esp_blufi_error_state_t state; + } blufi_err_infor; + /* + BTC_BLUFI_ACT_SEND_CUSTOM_DATA + */ + struct blufi_custom_data { + uint8_t *data; + uint32_t data_len; + } custom_data; } btc_blufi_args_t; void btc_blufi_cb_handler(btc_msg_t *msg); diff --git a/tools/sdk/include/bluedroid/btc_gap_ble.h b/tools/sdk/include/bluedroid/btc_gap_ble.h index 8074c1b9b42..ba744702b29 100644 --- a/tools/sdk/include/bluedroid/btc_gap_ble.h +++ b/tools/sdk/include/bluedroid/btc_gap_ble.h @@ -160,5 +160,6 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg); void btc_gap_ble_cb_deep_free(btc_msg_t *msg); void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); void btc_gap_callback_init(void); +void btc_gap_ble_deinit(void); #endif /* __BTC_GAP_BLE_H__ */ diff --git a/tools/sdk/include/bluedroid/btc_gatt_common.h b/tools/sdk/include/bluedroid/btc_gatt_common.h new file mode 100644 index 00000000000..41b0fee54ea --- /dev/null +++ b/tools/sdk/include/bluedroid/btc_gatt_common.h @@ -0,0 +1,37 @@ +// Copyright 2015-2016 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 __BTC_GATT_COMMON_H__ +#define __BTC_GATT_COMMON_H__ + +#include "future.h" +#include "bt_types.h" +#include "bta_api.h" +#include "btc_main.h" +#include "btc_task.h" + +typedef enum { + BTC_GATT_ACT_SET_LOCAL_MTU = 0, +} btc_gatt_com_act_t; + +/* btc_ble_gattc_args_t */ +typedef union { + //BTC_GATT_ACT_SET_LOCAL_MTU, + struct set_mtu_arg { + uint16_t mtu; + } set_mtu; +} btc_ble_gatt_com_args_t; + +void btc_gatt_com_call_handler(btc_msg_t *msg); +#endif /* __BTC_GATT_COMMON_H__ */ diff --git a/tools/sdk/include/bluedroid/btc_gattc.h b/tools/sdk/include/bluedroid/btc_gattc.h index 5087e5d2333..3391dd1c9f0 100644 --- a/tools/sdk/include/bluedroid/btc_gattc.h +++ b/tools/sdk/include/bluedroid/btc_gattc.h @@ -54,6 +54,7 @@ typedef union { struct open_arg { esp_gatt_if_t gattc_if; esp_bd_addr_t remote_bda; + esp_ble_addr_type_t remote_addr_type; bool is_direct; } open; //BTC_GATTC_ACT_CLOSE, diff --git a/tools/sdk/include/bluedroid/btc_main.h b/tools/sdk/include/bluedroid/btc_main.h index 523e1bb9829..b95ae0bbec2 100644 --- a/tools/sdk/include/bluedroid/btc_main.h +++ b/tools/sdk/include/bluedroid/btc_main.h @@ -26,7 +26,6 @@ typedef enum { BTC_MAIN_ACT_DEINIT, BTC_MAIN_ACT_ENABLE, BTC_MAIN_ACT_DISABLE, - BTC_GATT_ACT_SET_LOCAL_MTU, } btc_main_act_t; typedef enum { @@ -61,13 +60,5 @@ bt_status_t btc_init_bluetooth(future_t *future); void btc_deinit_bluetooth(future_t *future); #endif -/* btc_ble_gattc_args_t */ -typedef union { - //BTC_GATT_ACT_SET_LOCAL_MTU, - struct set_mtu_arg { - uint16_t mtu; - } set_mtu; -} btc_ble_main_args_t; - void btc_main_call_handler(btc_msg_t *msg); #endif /* __BTC_BT_MAIN_H__ */ diff --git a/tools/sdk/include/bluedroid/btc_task.h b/tools/sdk/include/bluedroid/btc_task.h index f19c266991a..16388c685bb 100644 --- a/tools/sdk/include/bluedroid/btc_task.h +++ b/tools/sdk/include/bluedroid/btc_task.h @@ -41,6 +41,7 @@ typedef enum { #if (GATTC_INCLUDED == TRUE) BTC_PID_GATTC, #endif ///GATTC_INCLUDED == TRUE + BTC_PID_GATT_COMMON, BTC_PID_GAP_BLE, BTC_PID_BLE_HID, BTC_PID_SPPLIKE, diff --git a/tools/sdk/include/bluedroid/btm_api.h b/tools/sdk/include/bluedroid/btm_api.h index ec27a59638e..b685cdb7783 100644 --- a/tools/sdk/include/bluedroid/btm_api.h +++ b/tools/sdk/include/bluedroid/btm_api.h @@ -72,6 +72,8 @@ enum { BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* 22 controller setting data length is unsupported*/ BTM_SET_PRIVACY_SUCCESS, /* 23 enable/disable local privacy success */ BTM_SET_PRIVACY_FAIL, /* 24 enable/disable local privacy failed*/ + BTM_SET_STATIC_RAND_ADDR_FAIL, /* 25 Command failed */ + BTM_INVALID_STATIC_RAND_ADDR, /* 26 invalid static rand addr */ }; typedef uint8_t tBTM_STATUS; @@ -182,6 +184,8 @@ typedef void (tBTM_UPDATE_CONN_PARAM_CBACK) (UINT8 status, BD_ADDR bd_addr, tBTM typedef void (tBTM_SET_PKT_DATA_LENGTH_CBACK) (UINT8 status, tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS *data_length_params); +typedef void (tBTM_SET_RAND_ADDR_CBACK) (UINT8 status); + typedef void (tBTM_ADD_WHITELIST_CBACK) (UINT8 status, tBTM_WL_OPERATION wl_opration); typedef void (tBTM_SET_LOCAL_PRIVACY_CBACK) (UINT8 status); diff --git a/tools/sdk/include/bluedroid/btm_ble_api.h b/tools/sdk/include/bluedroid/btm_ble_api.h index 0587b65be2d..43de28b4fd4 100644 --- a/tools/sdk/include/bluedroid/btm_ble_api.h +++ b/tools/sdk/include/bluedroid/btm_ble_api.h @@ -982,7 +982,7 @@ tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len); -BOOLEAN BTM_BleSetRandAddress(BD_ADDR rand_addr); +tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr); /******************************************************************************* @@ -1541,6 +1541,19 @@ void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback); //extern UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length); +/******************************************************************************* +** +** Function BTM_BleGetCurrentAddress +** +** Description This function is called to get local used BLE address. +** +** Parameters: None. +** +** Returns success or fail +** +*******************************************************************************/ +BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type); + /******************************************************************************* ** ** Function BTM__BLEReadDiscoverability diff --git a/tools/sdk/include/bluedroid/btm_ble_int.h b/tools/sdk/include/bluedroid/btm_ble_int.h index f5b6c90b152..e1f8f400d3a 100644 --- a/tools/sdk/include/bluedroid/btm_ble_int.h +++ b/tools/sdk/include/bluedroid/btm_ble_int.h @@ -104,6 +104,7 @@ typedef UINT8 tBTM_BLE_SEC_REQ_ACT; #define BTM_VSC_CHIP_CAPABILITY_M_VERSION 95 typedef enum { + BTM_BLE_IDLE, BTM_BLE_SCANNING, BTM_BLE_SCAN_PENDING, BTM_BLE_STOP_SCAN, @@ -150,6 +151,7 @@ typedef struct { tBTM_START_ADV_CMPL_CBACK *p_adv_cb; tBTM_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cb; tBLE_ADDR_TYPE adv_addr_type; + BOOLEAN adv_callback_twice; UINT8 evt_type; UINT8 adv_mode; tBLE_BD_ADDR direct_bda; diff --git a/tools/sdk/include/bluedroid/btm_int.h b/tools/sdk/include/bluedroid/btm_int.h index 1b4cd7259df..79a10cf7141 100644 --- a/tools/sdk/include/bluedroid/btm_int.h +++ b/tools/sdk/include/bluedroid/btm_int.h @@ -486,6 +486,11 @@ typedef struct { tBTM_LE_KEY_TYPE key_type; /* bit mask of valid key types in record */ tBTM_SEC_BLE_KEYS keys; /* LE device security info in slave rode */ #endif +#if (BLE_PRIVACY_SPT == TRUE) + tBLE_ADDR_TYPE current_addr_type; /* current adv addr type*/ + BD_ADDR current_addr; /* current adv addr*/ + bool current_addr_valid; /* current addr info is valid or not*/ +#endif } tBTM_SEC_BLE; diff --git a/tools/sdk/include/bluedroid/btu.h b/tools/sdk/include/bluedroid/btu.h index 0401e471c68..c59fb7f56d5 100644 --- a/tools/sdk/include/bluedroid/btu.h +++ b/tools/sdk/include/bluedroid/btu.h @@ -246,6 +246,7 @@ void btu_uipc_rx_cback(BT_HDR *p_msg); #if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0) void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout); void btu_stop_quick_timer (TIMER_LIST_ENT *p_tle); +void btu_free_quick_timer (TIMER_LIST_ENT *p_tle); void btu_process_quick_timer_evt (void); #endif diff --git a/tools/sdk/include/bluedroid/dyn_mem.h b/tools/sdk/include/bluedroid/dyn_mem.h index 2654316cba0..223ae9f9010 100644 --- a/tools/sdk/include/bluedroid/dyn_mem.h +++ b/tools/sdk/include/bluedroid/dyn_mem.h @@ -19,7 +19,40 @@ #define DYN_MEM_H #include "sdkconfig.h" -#if CONFIG_CLASSIC_BT_ENABLED +#if CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY +#define BTU_DYNAMIC_MEMORY TRUE +#define BTM_DYNAMIC_MEMORY TRUE +#define L2C_DYNAMIC_MEMORY TRUE +#define GATT_DYNAMIC_MEMORY TRUE +#define SMP_DYNAMIC_MEMORY TRUE +#define BTA_DYNAMIC_MEMORY TRUE +#define SDP_DYNAMIC_MEMORY TRUE +#define RFC_DYNAMIC_MEMORY TRUE +#define TCS_DYNAMIC_MEMORY TRUE +#define BNEP_DYNAMIC_MEMORY TRUE +#define AVDT_DYNAMIC_MEMORY TRUE +#define AVCT_DYNAMIC_MEMORY TRUE +#define MCA_DYNAMIC_MEMORY TRUE +#define A2D_DYNAMIC_MEMORY TRUE +#define VDP_DYNAMIC_MEMORY TRUE +#define AVRC_DYNAMIC_MEMORY TRUE +#define BIP_DYNAMIC_MEMORY TRUE +#define BPP_DYNAMIC_MEMORY TRUE +#define CTP_DYNAMIC_MEMORY TRUE +#define FTP_DYNAMIC_MEMORY TRUE +#define HCRP_DYNAMIC_MEMORY TRUE +#define HFP_DYNAMIC_MEMORY TRUE +#define HID_DYNAMIC_MEMORY TRUE +#define HSP2_DYNAMIC_MEMORY TRUE +#define ICP_DYNAMIC_MEMORY TRUE +#define OPP_DYNAMIC_MEMORY TRUE +#define PAN_DYNAMIC_MEMORY TRUE +#define SPP_DYNAMIC_MEMORY TRUE +#define SLIP_DYNAMIC_MEMORY TRUE +#define LLCP_DYNAMIC_MEMORY TRUE +#define BTC_SBC_DEC_DYNAMIC_MEMORY TRUE + +#else /* #if CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY */ #define SDP_DYNAMIC_MEMORY FALSE #define RFC_DYNAMIC_MEMORY FALSE @@ -45,35 +78,9 @@ #define SPP_DYNAMIC_MEMORY FALSE #define SLIP_DYNAMIC_MEMORY FALSE #define LLCP_DYNAMIC_MEMORY FALSE +#define BTC_SBC_DEC_DYNAMIC_MEMORY FALSE -#else /* #if CONFIG_CLASSIC_BT_ENABLED */ - -#define SDP_DYNAMIC_MEMORY TRUE -#define RFC_DYNAMIC_MEMORY TRUE -#define TCS_DYNAMIC_MEMORY TRUE -#define BNEP_DYNAMIC_MEMORY TRUE -#define AVDT_DYNAMIC_MEMORY TRUE -#define AVCT_DYNAMIC_MEMORY TRUE -#define MCA_DYNAMIC_MEMORY TRUE -#define A2D_DYNAMIC_MEMORY TRUE -#define VDP_DYNAMIC_MEMORY TRUE -#define AVRC_DYNAMIC_MEMORY TRUE -#define BIP_DYNAMIC_MEMORY TRUE -#define BPP_DYNAMIC_MEMORY TRUE -#define CTP_DYNAMIC_MEMORY TRUE -#define FTP_DYNAMIC_MEMORY TRUE -#define HCRP_DYNAMIC_MEMORY TRUE -#define HFP_DYNAMIC_MEMORY TRUE -#define HID_DYNAMIC_MEMORY TRUE -#define HSP2_DYNAMIC_MEMORY TRUE -#define ICP_DYNAMIC_MEMORY TRUE -#define OPP_DYNAMIC_MEMORY TRUE -#define PAN_DYNAMIC_MEMORY TRUE -#define SPP_DYNAMIC_MEMORY TRUE -#define SLIP_DYNAMIC_MEMORY TRUE -#define LLCP_DYNAMIC_MEMORY TRUE - -#endif /* #if CONFIG_CLASSIC_BT_ENABLED */ +#endif /* #if CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY */ /**************************************************************************** ** Define memory usage for each CORE component (if not defined in bdroid_buildcfg.h) ** The default for each component is to use static memory allocations. diff --git a/tools/sdk/include/bluedroid/esp_a2dp_api.h b/tools/sdk/include/bluedroid/esp_a2dp_api.h index ab118714671..8117d4c54c8 100644 --- a/tools/sdk/include/bluedroid/esp_a2dp_api.h +++ b/tools/sdk/include/bluedroid/esp_a2dp_api.h @@ -176,7 +176,8 @@ esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback); /** * @brief Register A2DP sink data output function; For now the output is PCM data stream decoded * from SBC format. This function should be called only after esp_bluedroid_enable() - * completes successfully, used only by A2DP sink. + * completes successfully, used only by A2DP sink. The callback is invoked in the context + * of A2DP sink task whose stack size is configurable through menuconfig * * @param[in] callback: A2DP sink data callback function * @@ -291,7 +292,8 @@ esp_err_t esp_a2d_source_deinit(void); /** * @brief Register A2DP source data input function; For now the input is PCM data stream. * This function should be called only after esp_bluedroid_enable() completes - * successfully + * successfully. The callback is invoked in the context of A2DP source task whose + * stack size is configurable through menuconfig * * @param[in] callback: A2DP source data callback function * diff --git a/tools/sdk/include/bluedroid/esp_blufi_api.h b/tools/sdk/include/bluedroid/esp_blufi_api.h index 575ae22c24b..6905187485b 100644 --- a/tools/sdk/include/bluedroid/esp_blufi_api.h +++ b/tools/sdk/include/bluedroid/esp_blufi_api.h @@ -51,6 +51,8 @@ typedef enum { ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY, /* #include "esp_err.h" @@ -181,3 +186,7 @@ const char *esp_console_get_hint(const char *buf, int *color, int *bold); * - ESP_ERR_INVALID_STATE, if esp_console_init wasn't called */ esp_err_t esp_console_register_help_command(); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/include/driver/driver/adc.h b/tools/sdk/include/driver/driver/adc.h index 9d26c539063..e6c6df1a403 100644 --- a/tools/sdk/include/driver/driver/adc.h +++ b/tools/sdk/include/driver/driver/adc.h @@ -147,11 +147,15 @@ esp_err_t adc1_config_width(adc_bits_width_t width_bit); esp_err_t adc_set_data_width(adc_unit_t adc_unit, adc_bits_width_t width_bit); /** - * @brief Configure the ADC1 channel, including setting attenuation. + * @brief Set the attenuation of a particular channel on ADC1, and configure its + * associated GPIO pin mux. * - * @note This function also configures the input GPIO pin mux to - * connect it to the ADC1 channel. It must be called before calling - * adc1_get_raw() for this channel. + * @note For any given channel, this function must be called before the first time + * adc1_get_raw() is called for that channel. + * + * @note This function can be called multiple times to configure multiple + * ADC channels simultaneously. adc1_get_raw() can then be called for any configured + * channel. * * The default ADC full-scale voltage is 1.1V. To read higher voltages (up to the pin maximum voltage, * usually 3.3V) requires setting >0dB signal attenuation for that ADC channel. @@ -168,6 +172,15 @@ esp_err_t adc_set_data_width(adc_unit_t adc_unit, adc_bits_width_t width_bit); * * @note At 11dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage. * + * Due to ADC characteristics, most accurate results are obtained within the following approximate voltage ranges: + * + * - 0dB attenuaton (ADC_ATTEN_DB_0) between 100 and 950mV + * - 2.5dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250mV + * - 6dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750mV + * - 11dB attenuation (ADC_ATTEN_DB_11) between 150 to 2450mV + * + * For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges. + * * @param channel ADC1 channel to configure * @param atten Attenuation level * @@ -178,13 +191,14 @@ esp_err_t adc_set_data_width(adc_unit_t adc_unit, adc_bits_width_t width_bit); esp_err_t adc1_config_channel_atten(adc1_channel_t channel, adc_atten_t atten); /** - * @brief Take an ADC1 reading on a single channel + * @brief Take an ADC1 reading from a single channel. * * @note Call adc1_config_width() before the first time this * function is called. * - * @note For a given channel, adc1_config_channel_atten(channel) - * must be called before the first time this function is called. + * @note For any given channel, adc1_config_channel_atten(channel) + * must be called before the first time this function is called. Configuring + * a new channel does not prevent a previously configured channel from being read. * * @param channel ADC1 channel to read * @@ -204,12 +218,13 @@ int adc1_get_voltage(adc1_channel_t channel) __attribute__((deprecated)); /** @endcond */ /** - * @brief Power on SAR ADC + * @brief Enable ADC power */ void adc_power_on(); /** * @brief Power off SAR ADC + * This function will force power down for ADC */ void adc_power_off(); diff --git a/tools/sdk/include/driver/driver/gpio.h b/tools/sdk/include/driver/driver/gpio.h index 8cc65054b9f..8246c415ef3 100644 --- a/tools/sdk/include/driver/driver/gpio.h +++ b/tools/sdk/include/driver/driver/gpio.h @@ -73,41 +73,41 @@ extern "C" { #define GPIO_SEL_38 ((uint64_t)(((uint64_t)1)<<38)) /*!< Pin 38 selected */ #define GPIO_SEL_39 ((uint64_t)(((uint64_t)1)<<39)) /*!< Pin 39 selected */ -#define GPIO_PIN_REG_0 PERIPHS_IO_MUX_GPIO0_U -#define GPIO_PIN_REG_1 PERIPHS_IO_MUX_U0TXD_U -#define GPIO_PIN_REG_2 PERIPHS_IO_MUX_GPIO2_U -#define GPIO_PIN_REG_3 PERIPHS_IO_MUX_U0RXD_U -#define GPIO_PIN_REG_4 PERIPHS_IO_MUX_GPIO4_U -#define GPIO_PIN_REG_5 PERIPHS_IO_MUX_GPIO5_U -#define GPIO_PIN_REG_6 PERIPHS_IO_MUX_SD_CLK_U -#define GPIO_PIN_REG_7 PERIPHS_IO_MUX_SD_DATA0_U -#define GPIO_PIN_REG_8 PERIPHS_IO_MUX_SD_DATA1_U -#define GPIO_PIN_REG_9 PERIPHS_IO_MUX_SD_DATA2_U -#define GPIO_PIN_REG_10 PERIPHS_IO_MUX_SD_DATA3_U -#define GPIO_PIN_REG_11 PERIPHS_IO_MUX_SD_CMD_U -#define GPIO_PIN_REG_12 PERIPHS_IO_MUX_MTDI_U -#define GPIO_PIN_REG_13 PERIPHS_IO_MUX_MTCK_U -#define GPIO_PIN_REG_14 PERIPHS_IO_MUX_MTMS_U -#define GPIO_PIN_REG_15 PERIPHS_IO_MUX_MTDO_U -#define GPIO_PIN_REG_16 PERIPHS_IO_MUX_GPIO16_U -#define GPIO_PIN_REG_17 PERIPHS_IO_MUX_GPIO17_U -#define GPIO_PIN_REG_18 PERIPHS_IO_MUX_GPIO18_U -#define GPIO_PIN_REG_19 PERIPHS_IO_MUX_GPIO19_U -#define GPIO_PIN_REG_20 PERIPHS_IO_MUX_GPIO20_U -#define GPIO_PIN_REG_21 PERIPHS_IO_MUX_GPIO21_U -#define GPIO_PIN_REG_22 PERIPHS_IO_MUX_GPIO22_U -#define GPIO_PIN_REG_23 PERIPHS_IO_MUX_GPIO23_U -#define GPIO_PIN_REG_25 PERIPHS_IO_MUX_GPIO25_U -#define GPIO_PIN_REG_26 PERIPHS_IO_MUX_GPIO26_U -#define GPIO_PIN_REG_27 PERIPHS_IO_MUX_GPIO27_U -#define GPIO_PIN_REG_32 PERIPHS_IO_MUX_GPIO32_U -#define GPIO_PIN_REG_33 PERIPHS_IO_MUX_GPIO33_U -#define GPIO_PIN_REG_34 PERIPHS_IO_MUX_GPIO34_U -#define GPIO_PIN_REG_35 PERIPHS_IO_MUX_GPIO35_U -#define GPIO_PIN_REG_36 PERIPHS_IO_MUX_GPIO36_U -#define GPIO_PIN_REG_37 PERIPHS_IO_MUX_GPIO37_U -#define GPIO_PIN_REG_38 PERIPHS_IO_MUX_GPIO38_U -#define GPIO_PIN_REG_39 PERIPHS_IO_MUX_GPIO39_U +#define GPIO_PIN_REG_0 IO_MUX_GPIO0_REG +#define GPIO_PIN_REG_1 IO_MUX_GPIO1_REG +#define GPIO_PIN_REG_2 IO_MUX_GPIO2_REG +#define GPIO_PIN_REG_3 IO_MUX_GPIO3_REG +#define GPIO_PIN_REG_4 IO_MUX_GPIO4_REG +#define GPIO_PIN_REG_5 IO_MUX_GPIO5_REG +#define GPIO_PIN_REG_6 IO_MUX_GPIO6_REG +#define GPIO_PIN_REG_7 IO_MUX_GPIO7_REG +#define GPIO_PIN_REG_8 IO_MUX_GPIO8_REG +#define GPIO_PIN_REG_9 IO_MUX_GPIO9_REG +#define GPIO_PIN_REG_10 IO_MUX_GPIO10_REG +#define GPIO_PIN_REG_11 IO_MUX_GPIO11_REG +#define GPIO_PIN_REG_12 IO_MUX_GPIO12_REG +#define GPIO_PIN_REG_13 IO_MUX_GPIO13_REG +#define GPIO_PIN_REG_14 IO_MUX_GPIO14_REG +#define GPIO_PIN_REG_15 IO_MUX_GPIO15_REG +#define GPIO_PIN_REG_16 IO_MUX_GPIO16_REG +#define GPIO_PIN_REG_17 IO_MUX_GPIO17_REG +#define GPIO_PIN_REG_18 IO_MUX_GPIO18_REG +#define GPIO_PIN_REG_19 IO_MUX_GPIO19_REG +#define GPIO_PIN_REG_20 IO_MUX_GPIO20_REG +#define GPIO_PIN_REG_21 IO_MUX_GPIO21_REG +#define GPIO_PIN_REG_22 IO_MUX_GPIO22_REG +#define GPIO_PIN_REG_23 IO_MUX_GPIO23_REG +#define GPIO_PIN_REG_25 IO_MUX_GPIO25_REG +#define GPIO_PIN_REG_26 IO_MUX_GPIO26_REG +#define GPIO_PIN_REG_27 IO_MUX_GPIO27_REG +#define GPIO_PIN_REG_32 IO_MUX_GPIO32_REG +#define GPIO_PIN_REG_33 IO_MUX_GPIO33_REG +#define GPIO_PIN_REG_34 IO_MUX_GPIO34_REG +#define GPIO_PIN_REG_35 IO_MUX_GPIO35_REG +#define GPIO_PIN_REG_36 IO_MUX_GPIO36_REG +#define GPIO_PIN_REG_37 IO_MUX_GPIO37_REG +#define GPIO_PIN_REG_38 IO_MUX_GPIO38_REG +#define GPIO_PIN_REG_39 IO_MUX_GPIO39_REG #define GPIO_APP_CPU_INTR_ENA (BIT(0)) #define GPIO_APP_CPU_NMI_INTR_ENA (BIT(1)) @@ -302,6 +302,8 @@ esp_err_t gpio_set_level(gpio_num_t gpio_num, uint32_t level); /** * @brief GPIO get input level * + * @warning If the pad is not configured for input (or input and output) the returned value is always 0. + * * @param gpio_num GPIO number. If you want to get the logic level of e.g. pin GPIO16, gpio_num should be GPIO_NUM_16 (16); * * @return diff --git a/tools/sdk/include/driver/driver/i2s.h b/tools/sdk/include/driver/driver/i2s.h old mode 100644 new mode 100755 index 3644a831f99..338e6ca3786 --- a/tools/sdk/include/driver/driver/i2s.h +++ b/tools/sdk/include/driver/driver/i2s.h @@ -138,7 +138,8 @@ typedef struct { int intr_alloc_flags; /*!< Flags used to allocate the interrupt. One or multiple (ORred) ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info */ int dma_buf_count; /*!< I2S DMA Buffer Count */ int dma_buf_len; /*!< I2S DMA Buffer Length */ - int use_apll; /*!< I2S using APLL as main I2S clock, enable it to get accurate clock */ + bool use_apll; /*!< I2S using APLL as main I2S clock, enable it to get accurate clock */ + int fixed_mclk; /*!< I2S using fixed MCLK output. If use_apll = true and fixed_mclk > 0, then the clock output for i2s is fixed and equal to the fixed_mclk value.*/ } i2s_config_t; /** @@ -207,8 +208,9 @@ typedef intr_handle_t i2s_isr_handle_t; * if you don't want this to happen and you want to initialize only one of the DAC channels, you can call i2s_set_dac_mode instead. * * @return - * - ESP_OK Success - * - ESP_FAIL Parameter error + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error + * - ESP_FAIL IO error */ esp_err_t i2s_set_pin(i2s_port_t i2s_num, const i2s_pin_config_t *pin); @@ -222,7 +224,7 @@ esp_err_t i2s_set_pin(i2s_port_t i2s_num, const i2s_pin_config_t *pin); * be used as RTC DAC function at the same time. * * @return - * - ESP_OK Success + * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_set_dac_mode(i2s_dac_mode_t dac_mode); @@ -241,8 +243,9 @@ esp_err_t i2s_set_dac_mode(i2s_dac_mode_t dac_mode); * This function must be called before any I2S driver read/write operations. * * @return - * - ESP_OK Success - * - ESP_FAIL Parameter error + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error + * - ESP_ERR_NO_MEM Out of memory */ esp_err_t i2s_driver_install(i2s_port_t i2s_num, const i2s_config_t *i2s_config, int queue_size, void* i2s_queue); @@ -252,8 +255,8 @@ esp_err_t i2s_driver_install(i2s_port_t i2s_num, const i2s_config_t *i2s_config, * @param i2s_num I2S_NUM_0, I2S_NUM_1 * * @return - * - ESP_OK Success - * - ESP_FAIL Parameter error + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_driver_uninstall(i2s_port_t i2s_num); @@ -276,10 +279,41 @@ esp_err_t i2s_driver_uninstall(i2s_port_t i2s_num); * Format of the data in source buffer is determined by the I2S * configuration (see i2s_config_t). * - * @return Number of bytes written, or ESP_FAIL (-1) for parameter error. If a timeout occurred, bytes written will be less than total size. + * @return + * - Number of bytes written, if timeout occurred, bytes written will be less than the size passed. + * - ESP_FAIL Parameter error. */ int i2s_write_bytes(i2s_port_t i2s_num, const char *src, size_t size, TickType_t ticks_to_wait); +/** + * @brief Write data to I2S DMA transmit buffer while expanding the number of bits per sample. For example, expanding 16-bit PCM to 32-bit PCM. + * + * @param i2s_num I2S_NUM_0, I2S_NUM_1 + * + * @param src Source address to write from + * + * @param size Size of data in bytes + * + * @param src_bits Source audio bit + * + * @param aim_bits Bit wanted, no more than 32, and must be greater than src_bits + * + * @param ticks_to_wait TX buffer wait timeout in RTOS ticks. If this + * many ticks pass without space becoming available in the DMA + * transmit buffer, then the function will return (note that if the + * data is written to the DMA buffer in pieces, the overall operation + * may still take longer than this timeout.) Pass portMAX_DELAY for no + * timeout. + * + * Format of the data in source buffer is determined by the I2S + * configuration (see i2s_config_t). + * + * @return + * - Number of bytes written, if timeout occurred, bytes written will be less than the size passed. + * - ESP_FAIL Parameter error. + */ +int i2s_write_expand(i2s_port_t i2s_num, const char *src, int size, int src_bits, int aim_bits, TickType_t ticks_to_wait); + /** * @brief Read data from I2S DMA receive buffer * @@ -293,8 +327,12 @@ int i2s_write_bytes(i2s_port_t i2s_num, const char *src, size_t size, TickType_t * * Format of the data in source buffer is determined by the I2S * configuration (see i2s_config_t). + * @note If the built-in ADC mode is enabled, we should call i2s_adc_start and i2s_adc_stop around the whole reading process, + * to prevent the data getting corrupted. * - * @return Number of bytes read, or ESP_FAIL (-1) for parameter error. If a timeout occurred, bytes read will be less than total size. + * @return + * - Number of bytes read, if timeout occurred, bytes written will be less than the size passed. + * - ESP_FAIL Parameter error. */ int i2s_read_bytes(i2s_port_t i2s_num, char* dest, size_t size, TickType_t ticks_to_wait); @@ -309,7 +347,9 @@ int i2s_read_bytes(i2s_port_t i2s_num, char* dest, size_t size, TickType_t ticks * * @param ticks_to_wait Push timeout in RTOS ticks. If space is not available in the DMA TX buffer within this period, no data is written and function returns 0. * - * @return Number of bytes successfully pushed to DMA buffer, or ESP_FAIL (-1) for parameter error. Will be either zero or the size of configured sample buffer. + * @return + * - Number of bytes successfully pushed to DMA buffer, will be either zero or the size of configured sample buffer. + * - ESP_FAIL Parameter error. */ int i2s_push_sample(i2s_port_t i2s_num, const char *sample, TickType_t ticks_to_wait); @@ -324,8 +364,9 @@ int i2s_push_sample(i2s_port_t i2s_num, const char *sample, TickType_t ticks_to_ * * @param ticks_to_wait Pop timeout in RTOS ticks. If a sample is not available in the DMA buffer within this period, no data is read and function returns zero. * - * @return Number of bytes successfully read from DMA buffer, or ESP_FAIL (-1) for parameter error. Byte count will be either zero or the size of the configured sample buffer. - + * @return + * - Number of bytes successfully read from DMA buffer, will be either zero or the size of configured sample buffer. + * - ESP_FAIL Parameter error. */ int i2s_pop_sample(i2s_port_t i2s_num, char *sample, TickType_t ticks_to_wait); @@ -342,8 +383,10 @@ int i2s_pop_sample(i2s_port_t i2s_num, char *sample, TickType_t ticks_to_wait); * @param rate I2S sample rate (ex: 8000, 44100...) * * @return - * - ESP_OK Success - * - ESP_FAIL Parameter error + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error + * - ESP_FAIL I2s is not initialized + * - ESP_ERR_NO_MEM Out of memory */ esp_err_t i2s_set_sample_rates(i2s_port_t i2s_num, uint32_t rate); @@ -355,8 +398,8 @@ esp_err_t i2s_set_sample_rates(i2s_port_t i2s_num, uint32_t rate); * @param i2s_num I2S_NUM_0, I2S_NUM_1 * * @return - * - ESP_OK Success - * - ESP_FAIL Parameter error + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_stop(i2s_port_t i2s_num); @@ -369,8 +412,8 @@ esp_err_t i2s_stop(i2s_port_t i2s_num); * @param i2s_num I2S_NUM_0, I2S_NUM_1 * * @return - * - ESP_OK Success - * - ESP_FAIL Parameter error + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_start(i2s_port_t i2s_num); @@ -382,14 +425,14 @@ esp_err_t i2s_start(i2s_port_t i2s_num); * @param i2s_num I2S_NUM_0, I2S_NUM_1 * * @return - * - ESP_OK Success - * - ESP_FAIL Parameter error + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_zero_dma_buffer(i2s_port_t i2s_num); /** * @brief Set clock & bit width used for I2S RX and TX. - * + * * Similar to i2s_set_sample_rates(), but also sets bit width. * * @param i2s_num I2S_NUM_0, I2S_NUM_1 @@ -399,10 +442,12 @@ esp_err_t i2s_zero_dma_buffer(i2s_port_t i2s_num); * @param bits I2S bit width (I2S_BITS_PER_SAMPLE_16BIT, I2S_BITS_PER_SAMPLE_24BIT, I2S_BITS_PER_SAMPLE_32BIT) * * @param ch I2S channel, (I2S_CHANNEL_MONO, I2S_CHANNEL_STEREO) - * + * * @return - * - ESP_OK Success - * - ESP_FAIL Parameter error + * - ESP_OK Success + * - ESP_FAIL Not initialized + * - ESP_ERR_INVALID_ARG Parameter error + * - ESP_ERR_NO_MEM Out of memory */ esp_err_t i2s_set_clk(i2s_port_t i2s_num, uint32_t rate, i2s_bits_per_sample_t bits, i2s_channel_t ch); @@ -412,11 +457,36 @@ esp_err_t i2s_set_clk(i2s_port_t i2s_num, uint32_t rate, i2s_bits_per_sample_t b * @param adc_unit SAR ADC unit index * @param adc_channel ADC channel index * @return - * - ESP_OK Success - * - ESP_FAIL Parameter error + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error */ esp_err_t i2s_set_adc_mode(adc_unit_t adc_unit, adc1_channel_t adc_channel); +/** + * @brief Start to use I2S built-in ADC mode + * @note This function would acquire the lock of ADC to prevent the data getting corrupted + * during the I2S peripheral is being used to do fully continuous ADC sampling. + * + * @param i2s_num i2s port index + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error + * - ESP_ERR_INVALID_STATE driver state error + * - ESP_FAIL Internal driver error + */ +esp_err_t i2s_adc_enable(i2s_port_t i2s_num); + +/** + * @brief Stop to use I2S built-in ADC mode + * @param i2s_num i2s port index + * @note This function would release the lock of ADC so that other tasks can use ADC. + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error + * - ESP_ERR_INVALID_STATE driver state error + */ +esp_err_t i2s_adc_disable(i2s_port_t i2s_num); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/driver/driver/rtc_io.h b/tools/sdk/include/driver/driver/rtc_io.h index c7219d3eb3f..522a9f9b6e2 100644 --- a/tools/sdk/include/driver/driver/rtc_io.h +++ b/tools/sdk/include/driver/driver/rtc_io.h @@ -224,6 +224,24 @@ esp_err_t rtc_gpio_hold_en(gpio_num_t gpio_num); */ esp_err_t rtc_gpio_hold_dis(gpio_num_t gpio_num); +/** + * @brief Helper function to disconnect internal circuits from an RTC IO + * This function disables input, output, pullup, pulldown, and enables + * hold feature for an RTC IO. + * Use this function if an RTC IO needs to be disconnected from internal + * circuits in deep sleep, to minimize leakage current. + * + * In particular, for ESP32-WROVER module, call + * rtc_gpio_isolate(GPIO_NUM_12) before entering deep sleep, to reduce + * deep sleep current. + * + * @param gpio_num GPIO number (e.g. GPIO_NUM_12). + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if GPIO is not an RTC IO + */ +esp_err_t rtc_gpio_isolate(gpio_num_t gpio_num); + /** * @brief Disable force hold signal for all RTC IOs * diff --git a/tools/sdk/include/driver/driver/sdmmc_defs.h b/tools/sdk/include/driver/driver/sdmmc_defs.h index c13df6d1aaf..96e0743d5fd 100644 --- a/tools/sdk/include/driver/driver/sdmmc_defs.h +++ b/tools/sdk/include/driver/driver/sdmmc_defs.h @@ -86,7 +86,13 @@ /* SPI mode R1 response type bits */ #define SD_SPI_R1_IDLE_STATE (1<<0) +#define SD_SPI_R1_ERASE_RST (1<<1) +#define SD_SPI_R1_ILLEGAL_CMD (1<<2) #define SD_SPI_R1_CMD_CRC_ERR (1<<3) +#define SD_SPI_R1_ERASE_SEQ_ERR (1<<4) +#define SD_SPI_R1_ADDR_ERR (1<<5) +#define SD_SPI_R1_PARAM_ERR (1<<6) +#define SD_SPI_R1_NO_RESPONSE (1<<7) /* 48-bit response decoding (32 bits w/o CRC) */ #define MMC_R1(resp) ((resp)[0]) diff --git a/tools/sdk/include/driver/driver/sdmmc_host.h b/tools/sdk/include/driver/driver/sdmmc_host.h index 63023e90302..c298889ed3c 100644 --- a/tools/sdk/include/driver/driver/sdmmc_host.h +++ b/tools/sdk/include/driver/driver/sdmmc_host.h @@ -39,6 +39,7 @@ extern "C" { .io_voltage = 3.3f, \ .init = &sdmmc_host_init, \ .set_bus_width = &sdmmc_host_set_bus_width, \ + .get_bus_width = &sdmmc_host_get_slot_width, \ .set_card_clk = &sdmmc_host_set_card_clk, \ .do_transaction = &sdmmc_host_do_transaction, \ .deinit = &sdmmc_host_deinit, \ @@ -115,6 +116,14 @@ esp_err_t sdmmc_host_init_slot(int slot, const sdmmc_slot_config_t* slot_config) */ esp_err_t sdmmc_host_set_bus_width(int slot, size_t width); +/** + * @brief Get bus width configured in ``sdmmc_host_init_slot`` to be used for data transfer + * + * @param slot slot number (SDMMC_HOST_SLOT_0 or SDMMC_HOST_SLOT_1) + * @return configured bus width of the specified slot. + */ +size_t sdmmc_host_get_slot_width(int slot); + /** * @brief Set card clock frequency * diff --git a/tools/sdk/include/driver/driver/sdmmc_types.h b/tools/sdk/include/driver/driver/sdmmc_types.h index 835eaa3fb71..cece4174ef7 100644 --- a/tools/sdk/include/driver/driver/sdmmc_types.h +++ b/tools/sdk/include/driver/driver/sdmmc_types.h @@ -125,6 +125,7 @@ typedef struct { float io_voltage; /*!< I/O voltage used by the controller (voltage switching is not supported) */ esp_err_t (*init)(void); /*!< Host function to initialize the driver */ esp_err_t (*set_bus_width)(int slot, size_t width); /*!< host function to set bus width */ + size_t (*get_bus_width)(int slot); /*!< host function to get bus width */ esp_err_t (*set_card_clk)(int slot, uint32_t freq_khz); /*!< host function to set card clock frequency */ esp_err_t (*do_transaction)(int slot, sdmmc_command_t* cmdinfo); /*!< host function to do a transaction */ esp_err_t (*deinit)(void); /*!< host function to deinitialize the driver */ diff --git a/tools/sdk/include/driver/driver/spi_master.h b/tools/sdk/include/driver/driver/spi_master.h index 2e17e85696d..613b8cf7412 100644 --- a/tools/sdk/include/driver/driver/spi_master.h +++ b/tools/sdk/include/driver/driver/spi_master.h @@ -30,11 +30,17 @@ extern "C" #define SPI_DEVICE_TXBIT_LSBFIRST (1<<0) ///< Transmit command/address/data LSB first instead of the default MSB first #define SPI_DEVICE_RXBIT_LSBFIRST (1<<1) ///< Receive data LSB first instead of the default MSB first -#define SPI_DEVICE_BIT_LSBFIRST (SPI_DEVICE_TXBIT_LSBFIRST|SPI_DEVICE_RXBIT_LSBFIRST); ///< Transmit and receive LSB first +#define SPI_DEVICE_BIT_LSBFIRST (SPI_DEVICE_TXBIT_LSBFIRST|SPI_DEVICE_RXBIT_LSBFIRST) ///< Transmit and receive LSB first #define SPI_DEVICE_3WIRE (1<<2) ///< Use MOSI (=spid) for both sending and receiving data #define SPI_DEVICE_POSITIVE_CS (1<<3) ///< Make CS positive during a transaction instead of negative #define SPI_DEVICE_HALFDUPLEX (1<<4) ///< Transmit data before receiving it, instead of simultaneously #define SPI_DEVICE_CLK_AS_CS (1<<5) ///< Output clock on CS line if CS is active +/** There are timing issue when reading at high frequency (the frequency is related to whether native pins are used, valid time after slave sees the clock). + * In half-duplex mode, the driver automatically inserts dummy bits before reading phase to fix the timing issue. Set this flag to disable this feature. + * However in full-duplex mode, dummy bits are not allowed to use and no way to prevent reading data from being corrupted. + * Set this flag to confirm that you're going to work with output only, or read without dummy bits at your own risk. + */ +#define SPI_DEVICE_NO_DUMMY (1<<6) typedef struct spi_transaction_t spi_transaction_t; @@ -62,11 +68,11 @@ typedef struct { #define SPI_TRANS_MODE_DIO (1<<0) ///< Transmit/receive data in 2-bit mode #define SPI_TRANS_MODE_QIO (1<<1) ///< Transmit/receive data in 4-bit mode -#define SPI_TRANS_MODE_DIOQIO_ADDR (1<<4) ///< Also transmit address in mode selected by SPI_MODE_DIO/SPI_MODE_QIO #define SPI_TRANS_USE_RXDATA (1<<2) ///< Receive into rx_data member of spi_transaction_t instead into memory at rx_buffer. #define SPI_TRANS_USE_TXDATA (1<<3) ///< Transmit tx_data member of spi_transaction_t instead of data at tx_buffer. Do not set tx_buffer when using this. -#define SPI_TRANS_VARIABLE_CMD (1<<4) ///< Use the ``command_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. -#define SPI_TRANS_VARIABLE_ADDR (1<<5) ///< Use the ``address_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. +#define SPI_TRANS_MODE_DIOQIO_ADDR (1<<4) ///< Also transmit address in mode selected by SPI_MODE_DIO/SPI_MODE_QIO +#define SPI_TRANS_VARIABLE_CMD (1<<5) ///< Use the ``command_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. +#define SPI_TRANS_VARIABLE_ADDR (1<<6) ///< Use the ``address_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. /** * This structure describes one SPI transaction. The descriptor should not be modified until the transaction finishes. @@ -160,7 +166,7 @@ esp_err_t spi_bus_free(spi_host_device_t host); * - ESP_ERR_NO_MEM if out of memory * - ESP_OK on success */ -esp_err_t spi_bus_add_device(spi_host_device_t host, spi_device_interface_config_t *dev_config, spi_device_handle_t *handle); +esp_err_t spi_bus_add_device(spi_host_device_t host, const spi_device_interface_config_t *dev_config, spi_device_handle_t *handle); /** diff --git a/tools/sdk/include/driver/driver/spi_slave.h b/tools/sdk/include/driver/driver/spi_slave.h index ed12cb62df7..1d5ea340292 100644 --- a/tools/sdk/include/driver/driver/spi_slave.h +++ b/tools/sdk/include/driver/driver/spi_slave.h @@ -30,7 +30,7 @@ extern "C" #define SPI_SLAVE_TXBIT_LSBFIRST (1<<0) ///< Transmit command/address/data LSB first instead of the default MSB first #define SPI_SLAVE_RXBIT_LSBFIRST (1<<1) ///< Receive data LSB first instead of the default MSB first -#define SPI_SLAVE_BIT_LSBFIRST (SPI_TXBIT_LSBFIRST|SPI_RXBIT_LSBFIRST); ///< Transmit and receive LSB first +#define SPI_SLAVE_BIT_LSBFIRST (SPI_SLAVE_TXBIT_LSBFIRST|SPI_SLAVE_RXBIT_LSBFIRST) ///< Transmit and receive LSB first typedef struct spi_slave_transaction_t spi_slave_transaction_t; @@ -163,4 +163,4 @@ esp_err_t spi_slave_transmit(spi_host_device_t host, spi_slave_transaction_t *tr } #endif -#endif \ No newline at end of file +#endif diff --git a/tools/sdk/include/driver/driver/timer.h b/tools/sdk/include/driver/driver/timer.h index 6b43eb4704e..48e2b98908d 100644 --- a/tools/sdk/include/driver/driver/timer.h +++ b/tools/sdk/include/driver/driver/timer.h @@ -238,7 +238,7 @@ esp_err_t timer_set_alarm_value(timer_group_t group_num, timer_idx_t timer_num, esp_err_t timer_get_alarm_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t* alarm_value); /** - * @brief Get timer alarm value. + * @brief Enable or disable generation of timer alarm events. * * @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1 * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1] diff --git a/tools/sdk/include/driver/driver/uart.h b/tools/sdk/include/driver/driver/uart.h index 49e058740b3..273b7869f45 100644 --- a/tools/sdk/include/driver/driver/uart.h +++ b/tools/sdk/include/driver/driver/uart.h @@ -618,8 +618,10 @@ int uart_write_bytes_with_break(uart_port_t uart_num, const char* src, size_t si int uart_read_bytes(uart_port_t uart_num, uint8_t* buf, uint32_t length, TickType_t ticks_to_wait); /** - * @brief UART ring buffer flush. This will discard all data in the UART RX buffer. - * + * @brief Alias of uart_flush_input. + * UART ring buffer flush. This will discard all data in the UART RX buffer. + * @note Instead of waiting the data sent out, this function will clear UART rx buffer. + * In order to send all the data in tx FIFO, we can use uart_wait_tx_done function. * @param uart_num UART_NUM_0, UART_NUM_1 or UART_NUM_2 * * @return @@ -629,8 +631,18 @@ int uart_read_bytes(uart_port_t uart_num, uint8_t* buf, uint32_t length, TickTyp esp_err_t uart_flush(uart_port_t uart_num); /** - * @brief UART get RX ring buffer cached data length + * @brief Clear input buffer, discard all the data is in the ring-buffer. + * @note In order to send all the data in tx FIFO, we can use uart_wait_tx_done function. + * @param uart_num UART_NUM_0, UART_NUM_1 or UART_NUM_2 * + * @return + * - ESP_OK Success + * - ESP_FAIL Parameter error + */ +esp_err_t uart_flush_input(uart_port_t uart_num); + +/** + * @brief UART get RX ring buffer cached data length * @param uart_num UART port number. * @param size Pointer of size_t to accept cached data length * @@ -671,6 +683,39 @@ esp_err_t uart_disable_pattern_det_intr(uart_port_t uart_num); */ esp_err_t uart_enable_pattern_det_intr(uart_port_t uart_num, char pattern_chr, uint8_t chr_num, int chr_tout, int post_idle, int pre_idle); +/** + * @brief Return the nearest detected pattern position in buffer. + * The positions of the detected pattern are saved in a queue, + * this function will dequeue the first pattern position and move the pointer to next pattern position. + * @note If the RX buffer is full and flow control is not enabled, + * the detected pattern may not be found in the rx buffer due to overflow. + * + * The following APIs will modify the pattern position info: + * uart_flush_input, uart_read_bytes, uart_driver_delete, uart_pop_pattern_pos + * It is the application's responsibility to ensure atomic access to the pattern queue and the rx data buffer + * when using pattern detect feature. + * + * @param uart_num UART port number + * @return + * - (-1) No pattern found for current index or parameter error + * - others the pattern position in rx buffer. + */ +int uart_pattern_pop_pos(uart_port_t uart_num); + +/** + * @brief Allocate a new memory with the given length to save record the detected pattern position in rx buffer. + * @param uart_num UART port number + * @param queue_length Max queue length for the detected pattern. + * If the queue length is not large enough, some pattern positions might be lost. + * Set this value to the maximum number of patterns that could be saved in data buffer at the same time. + * @return + * - ESP_ERR_NO_MEM No enough memory + * - ESP_ERR_INVALID_STATE Driver not installed + * - ESP_FAIL Parameter error + * - ESP_OK Success + */ +esp_err_t uart_pattern_queue_reset(uart_port_t uart_num, int queue_length); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/esp32/esp_attr.h b/tools/sdk/include/esp32/esp_attr.h index 911201aace4..a9c3f9a7a33 100644 --- a/tools/sdk/include/esp32/esp_attr.h +++ b/tools/sdk/include/esp32/esp_attr.h @@ -26,6 +26,12 @@ // Forces data into DRAM instead of flash #define DRAM_ATTR __attribute__((section(".dram1"))) +// Forces data to be 4 bytes aligned +#define WORD_ALIGNED_ATTR __attribute__((aligned(4))) + +// Forces data to be placed to DMA-capable places +#define DMA_ATTR WORD_ALIGNED_ATTR DRAM_ATTR + // Forces a string into DRAM instead of flash // Use as ets_printf(DRAM_STR("Hello world!\n")); #define DRAM_STR(str) (__extension__({static const DRAM_ATTR char __c[] = (str); (const char *)&__c;})) diff --git a/tools/sdk/include/esp32/esp_coexist.h b/tools/sdk/include/esp32/esp_coexist.h index 872b5e5ab71..c9b241d3dc6 100644 --- a/tools/sdk/include/esp32/esp_coexist.h +++ b/tools/sdk/include/esp32/esp_coexist.h @@ -1,4 +1,4 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// Copyright 2015-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. @@ -12,40 +12,48 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifndef __ESP_COEXIST_H__ +#define __ESP_COEXIST_H__ + #include +#include "esp_err.h" #ifdef __cplusplus extern "C" { #endif /** - * @brief Init software coexist - * - * @return Init ok or failed. - */ -esp_err_t coex_init(void); - -/** - * @brief De-init software coexist + * @brief coex prefer value */ -void coex_deinit(void); +typedef enum { + ESP_COEX_PREFER_WIFI = 0, /*!< Prefer to WiFi, WiFi will have more opportunity to use RF */ + ESP_COEX_PREFER_BT, /*!< Prefer to bluetooth, bluetooth will have more opportunity to use RF */ + ESP_COEX_PREFER_BALANCE, /*!< Do balance of WiFi and bluetooth */ + ESP_COEX_PREFER_NUM, /*!< Prefer value numbers */ +} esp_coex_prefer_t; /** - * @brief Get software coexist enable or not + * @brief Get software coexist version string * - * @return software coexist enable status. + * @return : version string */ -bool coexist_get_enable(void); +const char *esp_coex_version_get(void); /** - * @brief Set software coexist enable or not - * - * @param enable software coexist or disable it + * @brief Set coexist preference of performance + * For example, if prefer to bluetooth, then it will make A2DP(play audio via classic bt) + * more smooth while wifi is runnning something. + * If prefer to wifi, it will do similar things as prefer to bluetooth. + * Default, it prefer to balance. * - * @return Void. + * @param prefer : the prefer enumeration value + * @return : ESP_OK - success, other - failed */ -void coexist_set_enable(bool enable); +esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer); #ifdef __cplusplus } #endif + + +#endif /* __ESP_COEXIST_H__ */ diff --git a/tools/sdk/include/esp32/esp_err.h b/tools/sdk/include/esp32/esp_err.h index 5486b141052..b38a723bc30 100644 --- a/tools/sdk/include/esp32/esp_err.h +++ b/tools/sdk/include/esp32/esp_err.h @@ -41,6 +41,40 @@ typedef int32_t esp_err_t; #define ESP_ERR_INVALID_MAC 0x10B #define ESP_ERR_WIFI_BASE 0x3000 /*!< Starting number of WiFi error codes */ +#define ESP_ERR_MESH_BASE 0x4000 /*!< Starting number of MESH error codes */ + +/** + * @brief Returns string for esp_err_t error codes + * + * This function finds the error code in a pre-generated lookup-table and + * returns its string representation. + * + * The function is generated by the Python script + * tools/gen_esp_err_to_name.py which should be run each time an esp_err_t + * error is modified, created or removed from the IDF project. + * + * @param code esp_err_t error code + * @return string error message + */ +const char *esp_err_to_name(esp_err_t code); + +/** + * @brief Returns string for esp_err_t and system error codes + * + * This function finds the error code in a pre-generated lookup-table of + * esp_err_t errors and returns its string representation. If the error code + * is not found then it is attempted to be found among system errors. + * + * The function is generated by the Python script + * tools/gen_esp_err_to_name.py which should be run each time an esp_err_t + * error is modified, created or removed from the IDF project. + * + * @param code esp_err_t error code + * @param[out] buf buffer where the error message should be written + * @param buflen Size of buffer buf. At most buflen bytes are written into the buf buffer (including the terminating null byte). + * @return buf containing the string error message + */ +const char *esp_err_to_name_r(esp_err_t code, char *buf, size_t buflen); void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) __attribute__((noreturn)); diff --git a/tools/sdk/include/esp32/esp_flash_data_types.h b/tools/sdk/include/esp32/esp_flash_data_types.h index cb6dfc3a1f0..3e44b2639dc 100644 --- a/tools/sdk/include/esp32/esp_flash_data_types.h +++ b/tools/sdk/include/esp32/esp_flash_data_types.h @@ -23,6 +23,7 @@ extern "C" #define ESP_PARTITION_TABLE_ADDR 0x8000 #define ESP_PARTITION_MAGIC 0x50AA +#define ESP_PARTITION_MAGIC_MD5 0xEBEB /* OTA selection structure (two copies in the OTA data partition.) Size of 32 bytes is friendly to flash encryption */ diff --git a/tools/sdk/include/esp32/esp_int_wdt.h b/tools/sdk/include/esp32/esp_int_wdt.h index b32d0219fb1..f581d939ad8 100644 --- a/tools/sdk/include/esp32/esp_int_wdt.h +++ b/tools/sdk/include/esp32/esp_int_wdt.h @@ -1,4 +1,4 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// Copyright 2015-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. @@ -29,7 +29,7 @@ interrupts for too long, or code within interrupt handlers taking too long. It does this by setting up a watchdog which gets fed from the FreeRTOS task switch interrupt. When this watchdog times out, initially it will call a high-level interrupt routine that will panic FreeRTOS in order to allow -for forensic examination of the state of the CPU. When this interrupt +for forensic examination of the state of the both CPUs. When this interrupt handler is not called and the watchdog times out a second time, it will reset the SoC. @@ -38,12 +38,22 @@ This uses the TIMERG1 WDT. /** - * @brief Initialize the interrupt watchdog. This is called in the init code if - * the interrupt watchdog is enabled in menuconfig. + * @brief Initialize the non-CPU-specific parts of interrupt watchdog. + * This is called in the init code if the interrupt watchdog + * is enabled in menuconfig. * */ void esp_int_wdt_init(); +/** + * @brief Enable the interrupt watchdog on the current CPU. This is called + * in the init code by both CPUs if the interrupt watchdog is enabled + * in menuconfig. + * + */ +void esp_int_wdt_cpu_init(); + + /** * @} @@ -54,4 +64,4 @@ void esp_int_wdt_init(); } #endif -#endif \ No newline at end of file +#endif diff --git a/tools/sdk/include/esp32/esp_mesh.h b/tools/sdk/include/esp32/esp_mesh.h new file mode 100644 index 00000000000..12e2d55d8f3 --- /dev/null +++ b/tools/sdk/include/esp32/esp_mesh.h @@ -0,0 +1,1201 @@ +// Copyright 2017-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. + +/* + * Software Stack demonstrated: + * |------------------------------------------------------------------------------| + * | | | + * | | Application | + * | |-----------------------------------------------------------------| + * | | | Protocols: | | | | | + * | | Mesh Stack | HTTP, DNS, | | | Other | | + * | RTOS: | (Networking, | DHCP, ... | | | Components | | + * | (freeRTOS) | self-healing, |------------| | | | | + * | | flow control, | Network Stack: | | | | + * | | ...) | (LwIP) | | | | + * | |-----------------------------------| |---------------| | + * | | | | + * | | WiFi Driver | | + * | |--------------------------------------------------| | + * | | | + * | | Platform HAL | + * |------------------------------------------------------------------------------| + * + * System Events delivery: + * + * |---------------| + * | | default handler + * | WiFi stack | events |---------------------| + * | | -------------> | | + * |---------------| | | + * | event task | + * |---------------| events | | + * | | -------------> | | + * | LwIP stack | |---------------------| + * | |--------| + * |---------------| | + * | mesh event callback handler + * | |----------------------------| + * |-----> | | + * |---------------| | application | + * | | events | task | + * | mesh stack | -------------> | | + * | | |----------------------------| + * |---------------| + * + * + * Mesh Stack + * + * Mesh event defines almost all system events applications tasks need. + * Mesh event contains WiFi connection states on station interface, children connection states on softAP interface and etc.. + * Applications need to register a mesh event callback handler by API esp_mesh_set_config() firstly. + * This handler is to receive events posted from mesh stack and LwIP stack. + * Applications could add relative handler for each event. + * Examples: + * (1)Applications could use WiFi station connect states to decide when to send data to its parent, to root or to external IP network; + * (2)Applications could use WiFi softAP states to decide when to send data to its children. + * + * In present implementation, applications are able to access mesh stack directly without having to go through LwIP stack. + * Applications use esp_mesh_send() and esp_mesh_recv() to send and receive messages over the mesh network. + * In mesh stack design, normal nodes don't require LwIP stack. But since IDF hasn't supported system without initializing LwIP stack yet, + * applications still need to do LwIP initialization and two more things are required to be done + * (1)stop DHCP server on softAP interface by default + * (2)stop DHCP client on station interface by default. + * Examples: + * tcpip_adapter_init(); + * tcpip_adapter_dhcps_stop(TCPIP_ADAPTER_IF_AP)ï¼› + * tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA)ï¼› + * + * Over the mesh network, only root is able to access external IP network. + * In application mesh event handler, once a node becomes a root, start DHCP client immediately if DHCP is chosen. + */ + +#ifndef __ESP_MESH_H__ +#define __ESP_MESH_H__ + +#include "esp_err.h" +#include "esp_wifi.h" +#include "esp_wifi_types.h" +#include "esp_mesh_internal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************* + * Constants + *******************************************************/ +#define MESH_ROOT_LAYER (1) /**< root layer value */ +#define MESH_MTU (1500) /**< max transmit unit(in bytes) */ +#define MESH_MPS (1472) /**< max payload size(in bytes) */ +/** + * @brief mesh error code definition + */ +#define ESP_ERR_MESH_WIFI_NOT_START (ESP_ERR_MESH_BASE + 1) /**< WiFi isn't started */ +#define ESP_ERR_MESH_NOT_INIT (ESP_ERR_MESH_BASE + 2) /**< mesh isn't initialized */ +#define ESP_ERR_MESH_NOT_CONFIG (ESP_ERR_MESH_BASE + 3) /**< mesh isn't configured */ +#define ESP_ERR_MESH_NOT_START (ESP_ERR_MESH_BASE + 4) /**< mesh isn't started */ +#define ESP_ERR_MESH_NOT_SUPPORT (ESP_ERR_MESH_BASE + 5) /**< not supported yet */ +#define ESP_ERR_MESH_NOT_ALLOWED (ESP_ERR_MESH_BASE + 6) /**< operation is not allowed */ +#define ESP_ERR_MESH_NO_MEMORY (ESP_ERR_MESH_BASE + 7) /**< out of memory */ +#define ESP_ERR_MESH_ARGUMENT (ESP_ERR_MESH_BASE + 8) /**< illegal argument */ +#define ESP_ERR_MESH_EXCEED_MTU (ESP_ERR_MESH_BASE + 9) /**< packet size exceeds MTU */ +#define ESP_ERR_MESH_TIMEOUT (ESP_ERR_MESH_BASE + 10) /**< timeout */ +#define ESP_ERR_MESH_DISCONNECTED (ESP_ERR_MESH_BASE + 11) /**< disconnected with parent on station interface */ +#define ESP_ERR_MESH_QUEUE_FAIL (ESP_ERR_MESH_BASE + 12) /**< queue fail */ +#define ESP_ERR_MESH_QUEUE_FULL (ESP_ERR_MESH_BASE + 13) /**< queue full */ +#define ESP_ERR_MESH_NO_PARENT_FOUND (ESP_ERR_MESH_BASE + 14) /**< no parent found to join the mesh network */ +#define ESP_ERR_MESH_NO_ROUTE_FOUND (ESP_ERR_MESH_BASE + 15) /**< no route found to forward the packet */ +#define ESP_ERR_MESH_OPTION_NULL (ESP_ERR_MESH_BASE + 16) /**< no option found */ +#define ESP_ERR_MESH_OPTION_UNKNOWN (ESP_ERR_MESH_BASE + 17) /**< unknown option */ +#define ESP_ERR_MESH_XON_NO_WINDOW (ESP_ERR_MESH_BASE + 18) /**< no window for software flow control on upstream */ +#define ESP_ERR_MESH_INTERFACE (ESP_ERR_MESH_BASE + 19) /**< low-level WiFi interface error */ +#define ESP_ERR_MESH_DISCARD_DUPLICATE (ESP_ERR_MESH_BASE + 20) /**< discard the packet due to the duplicate sequence number */ +#define ESP_ERR_MESH_DISCARD (ESP_ERR_MESH_BASE + 21) /**< discard the packet */ + +/** + * @brief flags used with esp_mesh_send() and esp_mesh_recv() + */ +#define MESH_DATA_ENC (0x01) /**< data encrypted(Unimplemented) */ +#define MESH_DATA_P2P (0x02) /**< point-to-point delivery over the mesh network */ +#define MESH_DATA_FROMDS (0x04) /**< receive from external IP network */ +#define MESH_DATA_TODS (0x08) /**< identify this packet is target to external IP network */ +#define MESH_DATA_NONBLOCK (0x10) /**< esp_mesh_send() non-block */ +#define MESH_DATA_DROP (0x20) /**< in the situation of root having been changed, identify this packet can be dropped by new root */ +#define MESH_DATA_GROUP (0x40) /**< identify this packet is target to a group address */ + +/** + * @brief option definitions for esp_mesh_send() and esp_mesh_recv() + */ +#define MESH_OPT_SEND_GROUP (7) /**< data transmission by group; used with esp_mesh_send() and must have payload */ +#define MESH_OPT_RECV_DS_ADDR (8) /**< return a remote IP address; used with esp_mesh_send() and esp_mesh_recv() */ + +/******************************************************* + * Enumerations + *******************************************************/ +/** + * @brief enumerated list of mesh event id + */ +typedef enum { + MESH_EVENT_STARTED, /**< mesh is started */ + MESH_EVENT_STOPPED, /**< mesh is stopped */ + MESH_EVENT_CHANNEL_SWITCH, /**< channel switch */ + MESH_EVENT_CHILD_CONNECTED, /**< a child is connected on softAP interface */ + MESH_EVENT_CHILD_DISCONNECTED, /**< a child is disconnected on softAP interface */ + MESH_EVENT_ROUTING_TABLE_ADD, /**< routing table is changed by adding newly joined children */ + MESH_EVENT_ROUTING_TABLE_REMOVE, /**< routing table is changed by removing leave children */ + MESH_EVENT_PARENT_CONNECTED, /**< parent is connected on station interface */ + MESH_EVENT_PARENT_DISCONNECTED, /**< parent is disconnected on station interface */ + MESH_EVENT_NO_PARNET_FOUND, /**< no parent found */ + MESH_EVENT_LAYER_CHANGE, /**< layer changes over the mesh network */ + MESH_EVENT_TODS_STATE, /**< state represents if root is able to access external IP network */ + MESH_EVENT_VOTE_STARTED, /**< the process of voting a new root is started either by children or by root */ + MESH_EVENT_VOTE_STOPPED, /**< the process of voting a new root is stopped */ + MESH_EVENT_ROOT_ADDRESS, /**< the root address is obtained. It is posted by mesh stack automatically. */ + MESH_EVENT_ROOT_SWITCH_REQ, /**< root switch request sent from a new voted root candidate */ + MESH_EVENT_ROOT_SWITCH_ACK, /**< root switch acknowledgment responds the above request sent from current root */ + MESH_EVENT_ROOT_GOT_IP, /**< root obtains the IP address. It is posted by LwIP stack automatically */ + MESH_EVENT_ROOT_LOST_IP, /**< root loses the IP address. It is posted by LwIP stack automatically */ + MESH_EVENT_ROOT_ASKED_YIELD, /**< root is asked yield by a more powerful existing root. If self organized is disabled + and this device is specified to be a root by users, users should set a new parent + for this device. if self organized is enabled, this device will find a new parent + by itself, users could ignore this event. */ + MESH_EVENT_MAX, +} mesh_event_id_t; + +/** + * @brief node type + */ +typedef enum { + MESH_IDLE, /**< hasn't joined the mesh network yet */ + MESH_ROOT, /**< the only sink of the mesh network. Has the ability to access external IP network */ + MESH_NODE, /**< intermediate node. Has the ability to forward packets over the mesh network */ + MESH_LEAF, /**< has no forwarding ability */ +} mesh_type_t; + +/** + * @brief protocol of transmitted application data + */ +typedef enum { + MESH_PROTO_BIN, /**< binary */ + MESH_PROTO_HTTP, /**< HTTP protocol */ + MESH_PROTO_JSON, /**< JSON format */ + MESH_PROTO_MQTT, /**< MQTT protocol */ +} mesh_proto_t; + +/** + * @brief for reliable transmission, mesh stack provides three type of services + */ +typedef enum { + MESH_TOS_P2P, /**< provide P2P(point-to-point) retransmission on mesh stack by default */ + MESH_TOS_E2E, /**< provide E2E(end-to-end) retransmission on mesh stack (Unimplemented) */ + MESH_TOS_DEF, /**< no retransmission on mesh stack */ +} mesh_tos_t; + +/** + * @brief vote reason + */ +typedef enum { + MESH_VOTE_REASON_ROOT_INITIATED = 1, /**< vote is initiated by root */ + MESH_VOTE_REASON_CHILD_INITIATED, /**< vote is initiated by children */ +} mesh_vote_reason_t; + +/** + * @brief mesh disconnect reason code + */ +typedef enum { + MESH_REASON_CYCLIC = 100, /**< cyclic is detected */ + MESH_REASON_PARENT_IDLE, /**< parent is idle */ + MESH_REASON_LEAF, /**< the connected node is changed to a leaf */ + MESH_REASON_DIFF_ID, /**< in different mesh ID */ + MESH_REASON_ROOTS, /**< root conflict is detected */ + MESH_REASON_PARENT_STOPPED, /**< parent has stopped the mesh */ + MESH_REASON_SCAN_FAIL, /**< scan fail */ +} mesh_disconnect_reason_t; + +/******************************************************* + * Structures + *******************************************************/ +/** + * @brief IP address and port + */ +typedef struct { + ip4_addr_t ip4; /**< IP address */ + uint16_t port; /**< port */ +} __attribute__((packed)) mip_t; + +/** + * @brief mesh address + */ +typedef union { + uint8_t addr[6]; /**< mac address */ + mip_t mip; /**< mip address */ +} mesh_addr_t; + +/** + * @brief channel switch information + */ +typedef struct { + uint8_t channel; /**< new channel */ +} mesh_event_channel_switch_t; + +/** + * @brief parent connected information + */ +typedef struct { + system_event_sta_connected_t connected; /**< parent information, same as WiFi event SYSTEM_EVENT_STA_CONNECTED does */ + uint8_t self_layer; /**< layer */ +} mesh_event_connected_t; + +/** + * @brief no parent found information + */ +typedef struct { + int scan_times; /**< scan times being through */ +} mesh_event_no_parent_found_t; + +/** + * @brief layer change information + */ +typedef struct { + uint8_t new_layer; /**< new layer */ +} mesh_event_layer_change_t; + +/** + * @brief the reachability of root to a DS(distribute system) + */ +typedef enum { + MESH_TODS_UNREACHABLE, /**< root isn't able to access external IP network */ + MESH_TODS_REACHABLE, /**< root is able to access external IP network */ +} mesh_event_toDS_state_t; + +/** + * @brief vote started information + */ +typedef struct { + int reason; /**< vote reason, vote could be initiated by children or by root itself */ + int attempts; /**< max vote attempts before stopped */ + mesh_addr_t rc_addr; /**< root address specified by users via API esp_mesh_waive_root() */ +} mesh_event_vote_started_t; + +/** + * @brief IP settings from LwIP stack + */ +typedef system_event_sta_got_ip_t mesh_event_root_got_ip_t; + +/** + * @brief root address + */ +typedef mesh_addr_t mesh_event_root_address_t; + +/** + * @brief parent disconnected information + */ +typedef system_event_sta_disconnected_t mesh_event_disconnected_t; + +/** + * @brief child connected information + */ +typedef system_event_ap_staconnected_t mesh_event_child_connected_t; + +/** + * @brief child disconnected information + */ +typedef system_event_ap_stadisconnected_t mesh_event_child_disconnected_t; + +/** + * @brief root switch request information + */ +typedef struct { + int reason; /**< root switch reason, generally root switch is initialized by users via API esp_mesh_waive_root() */ + mesh_addr_t rc_addr; /**< the address of root switch requester */ +} mesh_event_root_switch_req_t; + +/** + * @brief other powerful root address + */ +typedef struct { + int8_t rssi; /**< rssi with router */ + uint16_t capacity; /**< the number of nodes in its network */ + uint8_t addr[6]; /**< other powerful root address */ +} mesh_event_root_conflict_t; + +/** + * @brief routing table change + */ +typedef struct { + uint16_t rt_size_new; /**< the new value */ + uint16_t rt_size_change; /**< the changed value */ +} mesh_event_routing_table_change_t; + +/** + * @brief mesh event information + */ +typedef union { + mesh_event_channel_switch_t channel_switch; /**< channel switch */ + mesh_event_child_connected_t child_connected; /**< child connected */ + mesh_event_child_disconnected_t child_disconnected; /**< child disconnected */ + mesh_event_routing_table_change_t routing_table; /**< routing table change */ + mesh_event_connected_t connected; /**< parent connected */ + mesh_event_disconnected_t disconnected; /**< parent disconnected */ + mesh_event_no_parent_found_t no_parent; /**< no parent found */ + mesh_event_layer_change_t layer_change; /**< layer change */ + mesh_event_toDS_state_t toDS_state; /**< toDS state, nodes should check this state firstly before trying to send packets to + external IP network. This state indicates right now if root is capable + of sending packets out. If not, nodes had better to wait until this state changes + to be MESH_TODS_REACHABLE. */ + mesh_event_vote_started_t vote_started; /**< vote started */ + mesh_event_root_got_ip_t got_ip; /**< root obtains IP address */ + mesh_event_root_address_t root_addr; /**< root address */ + mesh_event_root_switch_req_t switch_req; /**< root switch request */ + mesh_event_root_conflict_t root_conflict; /**< other powerful root */ +} mesh_event_info_t; + +/** + * @brief mesh event + */ +typedef struct { + mesh_event_id_t id; /**< mesh event id */ + mesh_event_info_t info; /**< mesh event info */ +} mesh_event_t; + +/** + * @brief mesh event callback handler prototype definition + * + * @param event mesh_event_t + */ +typedef void (*mesh_event_cb_t)(mesh_event_t event); + +/** + * @brief mesh option + */ +typedef struct { + uint8_t type; /**< option type */ + uint16_t len; /**< option length */ + uint8_t *val; /**< option value */ +} __attribute__((packed)) mesh_opt_t; + +/** + * @brief mesh data for esp_mesh_send() and esp_mesh_recv() + */ +typedef struct { + uint8_t *data; /**< data */ + uint16_t size; /**< data size */ + mesh_proto_t proto; /**< data protocol */ + mesh_tos_t tos; /**< data type of service */ +} mesh_data_t; + +/** + * @brief router configuration + */ +typedef struct { + uint8_t ssid[32]; /**< SSID */ + uint8_t ssid_len; /**< length of SSID */ + uint8_t bssid[6]; /**< BSSID, if router is hidden, this value is mandatory */ + uint8_t password[64]; /**< password */ +} mesh_router_t; + +/** + * @brief mesh softAP configuration + */ +typedef struct { + uint8_t password[64]; /**< mesh softAP password */ + uint8_t max_connection; /**< max number of stations allowed to connect in, max 10 */ +} mesh_ap_cfg_t; + +/** + * @brief mesh initialization configuration + */ +typedef struct { + uint8_t channel; /**< channel, the mesh network on */ + mesh_event_cb_t event_cb; /**< mesh event callback */ + mesh_addr_t mesh_id; /**< mesh network identification */ + mesh_router_t router; /**< router configuration */ + mesh_ap_cfg_t mesh_ap; /**< mesh softAP configuration */ + const mesh_crypto_funcs_t *crypto_funcs; /**< crypto functions */ +} mesh_cfg_t; + +/** + * @brief vote + */ +typedef union { + int attempts; /**< max vote attempts */ + mesh_addr_t rc_addr; /**< root address specified by users for API esp_mesh_waive_root() */ +} mesh_vote_t; + +/** + * @brief the number of packets pending in the queue waiting to be sent by the mesh stack + */ +typedef struct { + int to_parent; /**< to parent queue */ + int to_parent_p2p; /**< to parent(P2P) queue */ + int to_child; /**< to child queue */ + int to_child_p2p; /**< to child(P2P) queue */ + int mgmt; /**< management queue */ + int broadcast; /**< broadcast and multicast queue */ +} mesh_tx_pending_t; + +/** + * @brief the number of packets available in the queue waiting to be received by applications + */ +typedef struct { + int toDS; /**< to external DS */ + int toSelf; /**< to self */ +} mesh_rx_pending_t; + +/******************************************************* + * Variable Declaration + *******************************************************/ +/* mesh vendor IE crypto callback function */ +extern const mesh_crypto_funcs_t g_wifi_default_mesh_crypto_funcs; + +/* mesh event callback handler */ +extern mesh_event_cb_t g_mesh_event_cb; + +#define MESH_INIT_CONFIG_DEFAULT() { \ + .crypto_funcs = &g_wifi_default_mesh_crypto_funcs, \ +} + +/******************************************************* + * Function Definitions + *******************************************************/ +/** + * @brief mesh initialization + * Check if WiFi is started. + * Initialize mesh global variables with default values. + * + * @attention This API should be called after WiFi is started. + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_init(void); + +/** + * @brief mesh de-initialization + * Release resources and stop the mesh + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_deinit(void); + +/** + * @brief start mesh + * Initialize mesh vendor IE + * Start mesh network management service + * Create TX and RX queues according to the configuration + * Register mesh packets receive callback + * + * @attention This API should be called after esp_mesh_init() and esp_mesh_set_config(). + * + * @return + * - ESP_OK + * - ESP_FAIL + * - ESP_ERR_MESH_NOT_INIT + * - ESP_ERR_MESH_NOT_CONFIG + * - ESP_ERR_MESH_NO_MEMORY + */ +esp_err_t esp_mesh_start(void); + +/** + * @brief stop mesh + * Deinitialize mesh vendor IE + * Disconnect with current parent + * Disassociate all currently associated children + * Stop mesh network management service + * Unregister mesh packets receive callback + * Delete TX and RX queues + * Release resources + * Restore WiFi softAP to default settings if WiFi dual mode is enabled + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_stop(void); + +/** + * @brief send a packet over the mesh network + * Send a packet to any node in the mesh network. + * Send a packet to external IP network. + * + * @attention This API is not reentrant. + * + * @param to the address of the final destination of the packet + * (1)if the packet is to root, just set "to" to NULL and set flag to zero. + * (2)if the packet is outgoing to external IP network such as an IP server address, translate IPv4:PORT known as "to". + * This packet will be delivered to root firstly, then root will forward this packet to the final IP server address. + * @param data pointer to a sending mesh packet + * Should specify the data protocol applications used, binary by default. + * Should specify the transmission tos(type of service), P2P reliable by default. + * @param flag + * (1)used to speed up the route selection + * if the packet is target to an internal node, MESH_DATA_P2P should be set. + * if the packet is outgoing to root or to external IP network, MESH_DATA_TODS should be set. + * if the packet is from root to an internal node, MESH_DATA_FROMDS should be set. + * (2)specify if this API is block or non-block, block by default + * if needs non-block, MESH_DATA_NONBLOCK should be set. + * (3)in the situation of root having been changed, MESH_DATA_DROP identifies this packet can be dropped by new root + * for upstream data to external IP network, we try our best to avoid data loss caused by root having been changed, but + * there is a risk that new root is running out of memory because most of memory is occupied by the pending data which + * isn't read out in time by esp_mesh_recv_toDS(). + * Generally, we suggest esp_mesh_recv_toDS() is called after a connection with IP network is created. Thus data outgoing + * to external IP network via socket is just from reading esp_mesh_recv_toDS() which avoids unnecessary memory copy. + * + * @param opt options + * (1)in case of sending a packet to a specified group, MESH_OPT_SEND_GROUP is a good choice. + * In this option, the value field should specify the target receiver addresses in this group. + * (2)root sends a packet to an internal node, this packet is from external IP network in case the receiver node responds + * this packet, MESH_OPT_RECV_DS_ADDR is required to attach the target DS address. + * @param opt_count option count + * Currently, this API only takes one option, so opt_count is only supported to be 1. + * + * @return + * - ESP_OK + * - ESP_FAIL + * - ESP_ERR_MESH_ARGUMENT + * - ESP_ERR_MESH_NOT_START + * - ESP_ERR_MESH_DISCONNECTED + * - ESP_ERR_MESH_OPT_UNKNOWN + * - ESP_ERR_MESH_EXCEED_MTU + * - ESP_ERR_MESH_NO_MEMORY + * - ESP_ERR_MESH_TIMEOUT + * - ESP_ERR_MESH_QUEUE_FULL + * - ESP_ERR_MESH_NO_ROUTE_FOUND + * - ESP_ERR_MESH_DISCARD + */ +esp_err_t esp_mesh_send(const mesh_addr_t *to, const mesh_data_t *data, + const int flag, const mesh_opt_t opt[], const int opt_count); + +/** + * @brief receive a packet targeted to self over the mesh network + * Use esp_mesh_get_rx_pending() to check the number of packets available in the queue waiting + * to be received by applications in case of running out of memory. + * + * @param from the address of the original source of the packet + * @param data pointer to the received mesh packet + * Contain the protocol and applications should follow it to parse the data. + * @param timeout_ms wait time if a packet isn't immediately available(0:no wait, portMAX_DELAY:wait forever) + * @param flag + * MESH_DATA_FROMDS represents data from external IP network + * MESH_DATA_TODS represents data directed upward within the mesh network + * @param opt options desired to receive + * MESH_OPT_RECV_DS_ADDR attaches the DS address + * @param opt_count option count desired to receive + * Currently, this API only takes one option, so opt_count is only supported to be 1. + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT + * - ESP_ERR_MESH_NOT_START + * - ESP_ERR_MESH_TIMEOUT + * - ESP_ERR_MESH_DISCARD + */ +esp_err_t esp_mesh_recv(mesh_addr_t *from, mesh_data_t *data, int timeout_ms, + int *flag, mesh_opt_t opt[], int opt_count); + +/** + * @brief receive a packet targeted to external IP network + * root uses this API to receive packets destined to external IP network + * root forwards the received packets to the final destination via socket. + * if no socket connection is ready to send out the received packets and this esp_mesh_recv_toDS() + * hasn't been called by applications, packets from the whole mesh network will be pending in toDS queue. + * Use esp_mesh_get_rx_pending() to check the number of packets available in the queue waiting + * to be received by applications in case of running out of memory in root. + * Use esp_mesh_set_xon_qsize() could configure the RX queue size, default:72. If this size is too large, + * and esp_mesh_recv_toDS() isn't called in time, there is a risk that a great deal of memory is occupied + * by the pending packets. If this size is too small, it will impact the efficiency on upstream. How to + * decide this value depends on the specific application scenarios. + * + * @attention This API is only called by root. + * + * @param from the address of the original source of the packet + * @param to the address contains remote IP address and port(IPv4:PORT) + * @param data pointer to the received packet + * Contain the protocol and applications should follow it to parse the data. + * @param timeout_ms wait time if a packet isn't immediately available(0:no wait, portMAX_DELAY:wait forever) + * @param flag + * MESH_DATA_TODS represents data to external IP network + * @param opt options desired to receive + * @param opt_count option count desired to receive + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT + * - ESP_ERR_MESH_NOT_START + * - ESP_ERR_MESH_TIMEOUT + * - ESP_ERR_MESH_DISCARD + */ +esp_err_t esp_mesh_recv_toDS(mesh_addr_t *from, mesh_addr_t *to, + mesh_data_t *data, int timeout_ms, int *flag, mesh_opt_t opt[], + int opt_count); + +/** + * @brief set mesh stack configuration + * Use MESH_INIT_CONFIG_DEFAULT() to initialize the default values, mesh vendor IE is encrypted by default. + * mesh network is established on a fixed channel(1-14). + * mesh event callback is mandatory. + * mesh ID is an identifier of an MBSS. Nodes with the same mesh ID can communicate with each other. + * Regarding to the router configuration, if the router is hidden, BSSID field is mandatory. + * If BSSID field isn't set and there exists more than one router with same SSID, there is a risk that more + * roots than one connected with different BSSID will appear. It means more than one mesh network is established + * with the same mesh ID. + * Root conflict function could eliminate redundant roots connected with the same BSSID, but couldn't handle roots + * connected with different BSSID. Because users might have such requirements of setting up routers with same SSID + * for the future replacement. But in that case, if the above situations happen, please make sure applications + * implement forward functions on root to guarantee nodes in different mesh network could communicate with each other. + * max_connection of mesh softAP is limited by the max number of WiFi softAP supported(max:10). + * + * @attention This API should be called between esp_mesh_init() and esp_mesh_start(). + * + * @param config pointer to mesh stack configuration + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT + * - ESP_ERR_MESH_NOT_ALLOWED + */ +esp_err_t esp_mesh_set_config(const mesh_cfg_t *config); + +/** + * @brief get mesh stack configuration + * + * @param config pointer to mesh stack configuration + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT + */ +esp_err_t esp_mesh_get_config(mesh_cfg_t *config); + +/** + * @brief set router configuration + * + * @attention This API should be called between esp_mesh_init() and esp_mesh_start(). + * + * @param router pointer to router configuration + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT + */ +esp_err_t esp_mesh_set_router(const mesh_router_t *router); + +/** + * @brief get router configuration + * + * @param router pointer to router configuration + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT + */ +esp_err_t esp_mesh_get_router(mesh_router_t *router); + +/** + * @brief set mesh network ID + * + * @attention This API should be called between esp_mesh_init() and esp_mesh_start(). + * + * @param id pointer to mesh network ID + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT: invalid argument + */ +esp_err_t esp_mesh_set_id(const mesh_addr_t *id); + +/** + * @brief get mesh network ID + * + * @param id pointer to mesh network ID + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT + */ +esp_err_t esp_mesh_get_id(mesh_addr_t *id); + +/** + * @brief set node type over the mesh network(Unimplemented) + * + * @param type node type + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_NOT_ALLOWED + */ +esp_err_t esp_mesh_set_type(const mesh_type_t type); + +/** + * @brief get node type over mesh network + * + * @attention This API should be called after having received the event MESH_EVENT_PARENT_CONNECTED. + * + * @return mesh type + * + */ +mesh_type_t esp_mesh_get_type(void); + +/** + * @brief set max layer configuration(max:15, default:15) + * + * @attention This API should be called before esp_mesh_start(). + * + * @param max_layer max layer value + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT + * - ESP_ERR_MESH_NOT_ALLOWED + */ +esp_err_t esp_mesh_set_max_layer(const int max_layer); + +/** + * @brief get max layer configuration + * + * @return max layer value + */ +int esp_mesh_get_max_layer(void); + +/** + * @brief set mesh softAP password + * + * @attention This API should be called before esp_mesh_start(). + * + * @param pwd pointer to the password + * @param len password length + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT + * - ESP_ERR_MESH_NOT_ALLOWED + */ +esp_err_t esp_mesh_set_ap_password(const uint8_t *pwd, const int len); + +/** + * @brief set mesh softAP authentication mode value + * + * @attention This API should be called before esp_mesh_start(). + * + * @param authmode authentication mode + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT + * - ESP_ERR_MESH_NOT_ALLOWED + */ +esp_err_t esp_mesh_set_ap_authmode(const wifi_auth_mode_t authmode); + +/** + * @brief get mesh softAP authentication mode + * + * @return authentication mode + * + */ +wifi_auth_mode_t esp_mesh_get_ap_authmode(void); + +/** + * @brief set mesh softAP max connection value + * + * @attention This API should be called before esp_mesh_start(). + * + * @param connections the number of max connections + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT + */ +esp_err_t esp_mesh_set_ap_connections(const int connections); + +/** + * @brief get mesh softAP max connection configuration + * + * @return the number of max connections + * + */ +int esp_mesh_get_ap_connections(void); + +/** + * @brief get current layer value over the mesh network + * + * @attention This API should be called after having received the event MESH_EVENT_PARENT_CONNECTED. + * + * @return layer value + * + */ +int esp_mesh_get_layer(void); + +/** + * @brief get parent BSSID + * + * @attention This API should be called after having received the event MESH_EVENT_PARENT_CONNECTED. + * + * @param bssid pointer to parent BSSID + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_get_parent_bssid(mesh_addr_t *bssid); + +/** + * @brief return if the node is root + * + * @return true/false + * + */ +bool esp_mesh_is_root(void); + +/** + * @brief enable/disable mesh networking self-organized, self-organized by default + * if self-organized is disabled, users should set a parent for this node via + * esp_mesh_set_parent()(Unimplemented); + * + * @param enable + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_set_self_organized(const bool enable); + +/** + * @brief return if mesh networking is self-organized or not + * + * @return true/false + * + */ +bool esp_mesh_get_self_organized(void); + +/** + * @brief root waive itself + * A node is elected to be a root during the networking mostly because it has a strong RSSI with router. + * If such superior conditions change, users could call this API to perform a root switch. + * + * In this API, users could specify a desired root address to replace itself or specify an attempts value + * to ask current root to initiate a new round of voting. During the voting, a better root candidate would + * be expected to find to replace the current one. + * If no desired root candidate, the vote will try a specified attempts(at least 10 times), if no better + * root candidate is found, keep the current one. If a better candidate is found, the new better one will + * send a root switch request to the current root, current root will respond with a root switch acknowledgement. + * After that, the new candidate will connect to the router to be a new root, the previous root will disconnect + * with the router and choose another parent instead. + * So far, root switch is completed with minimal disruption to the whole mesh network. + * + * @attention This API is only called by root. + * + * @param vote vote configuration + * Specify a desired root address(Unimplemented) + * Attempts should be at least 10 times. + * if "vote" is set NULL, the vote will perform the default 10 times. + * @param reason only accept MESH_VOTE_REASON_ROOT_INITIATED for now + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_waive_root(const mesh_vote_t *vote, const int reason); + +/** + * @brief set vote percentage threshold for approval of being a root + * During the networking, only obtaining vote percentage reaches this threshold, + * the node could be a root. + * + * @attention This API should be called before esp_mesh_start(). + * + * @param percentage vote percentage threshold + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_set_vote_percentage(const float percentage); + +/** + * @brief get vote percentage threshold for approval of being a root + * + * @return percentage threshold + */ +float esp_mesh_get_vote_percentage(void); + +/** + * @brief set mesh softAP associate expired time + * If mesh softAP hasn't received any data from an associated child within this time, + * mesh softAP will take this child inactive and disassociate it. + * + * @param seconds + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_set_ap_assoc_expire(const int seconds); + +/** + * @brief get mesh softAP associate expired time + * + * @return seconds + */ +int esp_mesh_get_ap_assoc_expire(void); + +/** + * @brief get total number of nodes over the mesh network(including root) + * + * @attention The returned value might be incorrect when the network is changing. + ** + * @return total number of nodes(including root) + */ +int esp_mesh_get_total_node_num(void); + +/** + * @brief get the number of nodes in routing table(including self) + * + * @return the number of nodes in routing table(including self) + */ +int esp_mesh_get_routing_table_size(void); + +/** + * @brief get routing table(including itself) + * + * @param mac pointer to routing table + * @param len routing table size(in bytes) + * @param size pointer to the number of nodes in routing table(including itself) + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_ARGUMENT + */ +esp_err_t esp_mesh_get_routing_table(mesh_addr_t *mac, int len, int *size); + +/** + * @brief post the toDS state to the mesh stack + * + * @attention This API is only for root. + * + * @param reachable this state represents if root is able to access external IP network + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_post_toDS_state(const bool reachable); + +/** + * @brief return the number of packets pending in the queue waiting to be sent by the mesh stack + * + * @param pending pointer to the TX pending + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_get_tx_pending(mesh_tx_pending_t *pending); + +/** + * @brief return the number of packets available in the queue waiting to be received by applications + * + * @param pending pointer to the RX pending + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_get_rx_pending(mesh_rx_pending_t *pending); + +/** + * @brief return the number of packets could be accepted from the specified address + * + * @param addr self address or an associate children address + * @param xseqno_in sequence number of the last received packet from the specified address + * + * @return the number of upQ for a specified address + */ +int esp_mesh_available_txupQ_num(const mesh_addr_t *addr, uint32_t *xseqno_in); + +/** + * @brief set queue size + * + * @attention This API should be called before esp_mesh_start(). + * + * @param qsize default:72(min:36, max:105) + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_set_xon_qsize(int qsize); + +/** + * @brief get queue size + * + * @return qsize + */ +int esp_mesh_get_xon_qsize(void); + +/** + * @brief set if allow more than one root existing in one network + * + * @param allowed allow or not + * + * @return + * - ESP_OK + * - ESP_WIFI_ERR_NOT_INIT + * - ESP_WIFI_ERR_NOT_START + */ +esp_err_t esp_mesh_allow_root_conflicts(const bool allowed); + +/** + * @brief set group ID addresses + * + * @param addr pointer to new addresses + * @param num number of addresses + * + * @return + * - ESP_OK + * - ESP_MESH_ERR_ARGUMENT + */ +esp_err_t esp_mesh_set_group_id(const mesh_addr_t *addr, const int num); + +/** + * @brief delete group ID addresses + * + * @param addr pointer to deleted address + * @param num number of addresses + * + * @return + * - ESP_OK + * - ESP_MESH_ERR_ARGUMENT + */ +esp_err_t esp_mesh_delete_group_id(const mesh_addr_t *addr, const int num); + +/** + * @brief get the number of group ID addresses + * + * @return the number of group ID addresses + */ +int esp_mesh_get_group_num(void); + +/** + * @brief get group ID addresses + * + * @param addr pointer to group address + * @param num number of addresses + * + * @return + * - ESP_OK + * - ESP_MESH_ERR_ARGUMENT + */ +esp_err_t esp_mesh_get_group_list(mesh_addr_t *addr, const int num); + +/** + * @brief check if the specified group address is my group + * + * @return true/false + */ +bool esp_mesh_is_my_group(const mesh_addr_t *addr); + +/** + * @brief set mesh network capacity + * + * @attention This API should be called before esp_mesh_start(). + * + * @param num mesh network capacity + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_NOT_ALLOWED + * - ESP_MESH_ERR_ARGUMENT + */ +esp_err_t esp_mesh_set_capacity_num(int num); + +/** + * @brief get mesh network capacity + * + * @return mesh network capacity + */ +int esp_mesh_get_capacity_num(void); + +/** + * @brief set mesh ie crypto functions + * + * @param crypto_funcs crypto functions for mesh ie + * + * @return + * - ESP_OK + */ +esp_err_t esp_mesh_set_ie_crypto_funcs(const mesh_crypto_funcs_t *crypto_funcs); + +/** + * @brief set mesh ie crypto key + * + * @attention This API should be called before esp_mesh_start(). + * + * @param key crypto key + * @param len the present implementation only supports 32 + * + * @return + * - ESP_OK + * - ESP_ERR_MESH_NOT_ALLOWED + * - ESP_MESH_ERR_ARGUMENT + */ +esp_err_t esp_mesh_set_ie_crypto_key(const uint8_t *key, int len); + +/** + * @brief get mesh ie crypto key + * + * @param key crypto key + * @param len the present implementation only supports 32 + * + * @return + * - ESP_OK + * - ESP_MESH_ERR_ARGUMENT + */ +esp_err_t esp_mesh_get_ie_crypto_key(uint8_t *key, int len); + +/** + * @brief set delay time before starting root healing + * + * @param delay_ms delay time in milliseconds + * + * @return + * - ESP_OK + */ +esp_err_t esp_mesh_set_root_healing_delay(int delay_ms); + +/** + * @brief get delay time before starting root healing + * + * @return delay time in milliseconds + */ +int esp_mesh_get_root_healing_delay(void); + +/** + * @brief set mesh event callback + * + * @param event_cb mesh event call back + * + * @return + * - ESP_OK + */ +esp_err_t esp_mesh_set_event_cb(const mesh_event_cb_t event_cb); + + +#ifdef __cplusplus +} +#endif +#endif /* __ESP_MESH_H__ */ diff --git a/tools/sdk/include/esp32/esp_mesh_internal.h b/tools/sdk/include/esp32/esp_mesh_internal.h new file mode 100644 index 00000000000..19273ba06da --- /dev/null +++ b/tools/sdk/include/esp32/esp_mesh_internal.h @@ -0,0 +1,162 @@ +// Copyright 2017-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_MESH_INTERNAL_H__ +#define __ESP_MESH_INTERNAL_H__ + +#include "esp_err.h" +#include "esp_wifi.h" +#include "esp_wifi_types.h" +#include "esp_wifi_internal.h" +#include "esp_wifi_crypto_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************* + * Constants + *******************************************************/ + +/******************************************************* + * Structures + *******************************************************/ +typedef struct { + int scan; /**< minimum scan times before being a root, default:10 */ + int vote; /**< max vote times in self-healing, default:10000 */ + int fail; /**< parent selection fail times, if the scan times reach this value, + will disconnect with associated children and join self-healing. default:60 */ + int monitor_ie; /**< acceptable times of parent ie change before update self ie, default:3 */ +} mesh_attempts_t; + +typedef struct { + int duration_ms; /* parent weak RSSI monitor duration, if the RSSI continues to be weak during this duration_ms, + will switch to a better parent */ + int cnx_rssi; /* RSSI threshold for keeping a good connection with parent */ + int select_rssi; /* RSSI threshold for parent selection, should be a value greater than switch_rssi */ + int switch_rssi; /* RSSI threshold for action to reselect a better parent */ + int backoff_rssi; /* RSSI threshold for connecting to the root */ +} mesh_switch_parent_t; + +/******************************************************* + * Function Definitions + *******************************************************/ +/** + * @brief set mesh softAP beacon interval + * + * @param interval beacon interval(ms) (100ms ~ 60000ms) + * + * @return + * - ESP_OK + * - ESP_FAIL + * - ESP_ERR_WIFI_ARG + */ +esp_err_t esp_mesh_set_beacon_interval(int interval_ms); + +/** + * @brief get mesh softAP beacon interval + * + * @param interval beacon interval(ms) + * + * @return + * - ESP_OK + */ +esp_err_t esp_mesh_get_beacon_interval(int *interval_ms); + +/** + * @brief set attempts for mesh self-organized networking + * + * @param attempts + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_set_attempts(mesh_attempts_t *attempts); + +/** + * @brief get attempts for mesh self-organized networking + * + * @param attempts + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_get_attempts(mesh_attempts_t *attempts); + +/** + * @brief set parameters for parent switch + * + * @param paras parameters for parent switch + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_set_switch_parent_paras(mesh_switch_parent_t *paras); + +/** + * @brief get parameters for parent switch + * + * @param paras parameters for parent switch + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_get_switch_parent_paras(mesh_switch_parent_t *paras); + +/** + * @brief print the number of txQ waiting + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_print_txQ_waiting(void); + +/** + * @brief print the number of rxQ waiting + * + * @return + * - ESP_OK + * - ESP_FAIL + */ +esp_err_t esp_mesh_print_rxQ_waiting(void); + +/** + * @brief set passive scan time + * + * @param interval_ms passive scan time(ms) + * + * @return + * - ESP_OK + * - ESP_FAIL + * - ESP_ERR_ARGUMENT + */ +esp_err_t esp_mesh_set_passive_scan_time(int time_ms); + +/** + * @brief get passive scan time + * + * @return interval_ms passive scan time(ms) + */ +int esp_mesh_get_passive_scan_time(void); + + +#ifdef __cplusplus +} +#endif +#endif /* __ESP_MESH_INTERNAL_H__ */ diff --git a/tools/sdk/include/esp32/esp_now.h b/tools/sdk/include/esp32/esp_now.h index 4a0a4be7d61..981c9001e49 100644 --- a/tools/sdk/include/esp32/esp_now.h +++ b/tools/sdk/include/esp32/esp_now.h @@ -40,15 +40,15 @@ extern "C" { * @{ */ -#define ESP_ERR_ESPNOW_BASE (ESP_ERR_WIFI_BASE + 101) /*!< ESPNOW error number base. */ -#define ESP_ERR_ESPNOW_NOT_INIT (ESP_ERR_ESPNOW_BASE) /*!< ESPNOW is not initialized. */ -#define ESP_ERR_ESPNOW_ARG (ESP_ERR_ESPNOW_BASE + 1) /*!< Invalid argument */ -#define ESP_ERR_ESPNOW_NO_MEM (ESP_ERR_ESPNOW_BASE + 2) /*!< Out of memory */ -#define ESP_ERR_ESPNOW_FULL (ESP_ERR_ESPNOW_BASE + 3) /*!< ESPNOW peer list is full */ -#define ESP_ERR_ESPNOW_NOT_FOUND (ESP_ERR_ESPNOW_BASE + 4) /*!< ESPNOW peer is not found */ -#define ESP_ERR_ESPNOW_INTERNAL (ESP_ERR_ESPNOW_BASE + 5) /*!< Internal error */ -#define ESP_ERR_ESPNOW_EXIST (ESP_ERR_ESPNOW_BASE + 6) /*!< ESPNOW peer has existed */ -#define ESP_ERR_ESPNOW_IF (ESP_ERR_ESPNOW_BASE + 7) /*!< Interface error */ +#define ESP_ERR_ESPNOW_BASE (ESP_ERR_WIFI_BASE + 100) /*!< ESPNOW error number base. */ +#define ESP_ERR_ESPNOW_NOT_INIT (ESP_ERR_ESPNOW_BASE + 1) /*!< ESPNOW is not initialized. */ +#define ESP_ERR_ESPNOW_ARG (ESP_ERR_ESPNOW_BASE + 2) /*!< Invalid argument */ +#define ESP_ERR_ESPNOW_NO_MEM (ESP_ERR_ESPNOW_BASE + 3) /*!< Out of memory */ +#define ESP_ERR_ESPNOW_FULL (ESP_ERR_ESPNOW_BASE + 4) /*!< ESPNOW peer list is full */ +#define ESP_ERR_ESPNOW_NOT_FOUND (ESP_ERR_ESPNOW_BASE + 5) /*!< ESPNOW peer is not found */ +#define ESP_ERR_ESPNOW_INTERNAL (ESP_ERR_ESPNOW_BASE + 6) /*!< Internal error */ +#define ESP_ERR_ESPNOW_EXIST (ESP_ERR_ESPNOW_BASE + 7) /*!< ESPNOW peer has existed */ +#define ESP_ERR_ESPNOW_IF (ESP_ERR_ESPNOW_BASE + 8) /*!< Interface error */ #define ESP_NOW_ETH_ALEN 6 /*!< Length of ESPNOW peer MAC address */ #define ESP_NOW_KEY_LEN 16 /*!< Length of ESPNOW peer local master key */ diff --git a/tools/sdk/include/esp32/esp_phy_init.h b/tools/sdk/include/esp32/esp_phy_init.h index 1184c4e8dcc..75cb8fb58e7 100644 --- a/tools/sdk/include/esp32/esp_phy_init.h +++ b/tools/sdk/include/esp32/esp_phy_init.h @@ -46,6 +46,43 @@ typedef enum { PHY_RF_CAL_FULL = 0x00000002 /*!< Do full RF calibration. Produces best results, but also consumes a lot of time and current. Suggested to be used once. */ } esp_phy_calibration_mode_t; + +/** + * @brief Modules for modem sleep + */ +typedef enum{ + MODEM_BLE_MODULE, //!< BLE controller used + MODEM_CLASSIC_BT_MODULE, //!< Classic BT controller used + MODEM_WIFI_STATION_MODULE, //!< Wi-Fi Station used + MODEM_WIFI_SOFTAP_MODULE, //!< Wi-Fi SoftAP used + MODEM_WIFI_SNIFFER_MODULE, //!< Wi-Fi Sniffer used + MODEM_USER_MODULE, //!< User used + MODEM_MODULE_COUNT //!< Number of items +}modem_sleep_module_t; + +/** + * @brief Module WIFI mask for medem sleep + */ +#define MODEM_BT_MASK ((1<= 128) - * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail) + * - ESP_OK: succeed + * - ESP_ERR_INVALID_ARG: fail(len <= 0 or len >= 128) + * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) */ esp_err_t esp_wifi_sta_wpa2_ent_set_identity(const unsigned char *identity, int len); @@ -84,9 +84,9 @@ void esp_wifi_sta_wpa2_ent_clear_identity(void); * @param len: length of username, limited to 1~127 * * @return - * - ESP_ERR_WIFI_OK: succeed - * - ESP_ERR_WIFI_ARG: fail(len <= 0 or len >= 128) - * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail) + * - ESP_OK: succeed + * - ESP_ERR_INVALID_ARG: fail(len <= 0 or len >= 128) + * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) */ esp_err_t esp_wifi_sta_wpa2_ent_set_username(const unsigned char *username, int len); @@ -104,9 +104,9 @@ void esp_wifi_sta_wpa2_ent_clear_username(void); * @param len: length of password(len > 0) * * @return - * - ESP_ERR_WIFI_OK: succeed - * - ESP_ERR_WIFI_ARG: fail(len <= 0) - * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail) + * - ESP_OK: succeed + * - ESP_ERR_INVALID_ARG: fail(len <= 0) + * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) */ esp_err_t esp_wifi_sta_wpa2_ent_set_password(const unsigned char *password, int len); @@ -125,9 +125,9 @@ void esp_wifi_sta_wpa2_ent_clear_password(void); * @param len: length of password * * @return - * - ESP_ERR_WIFI_OK: succeed - * - ESP_ERR_WIFI_ARG: fail(len <= 0) - * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail) + * - ESP_OK: succeed + * - ESP_ERR_INVALID_ARG: fail(len <= 0) + * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) */ esp_err_t esp_wifi_sta_wpa2_ent_set_new_password(const unsigned char *password, int len); @@ -147,7 +147,7 @@ void esp_wifi_sta_wpa2_ent_clear_new_password(void); * @param len: length of ca_cert * * @return - * - ESP_ERR_WIFI_OK: succeed + * - ESP_OK: succeed */ esp_err_t esp_wifi_sta_wpa2_ent_set_ca_cert(const unsigned char *ca_cert, int len); @@ -170,7 +170,7 @@ void esp_wifi_sta_wpa2_ent_clear_ca_cert(void); * @param private_key_password_len: length of private key password; * * @return - * - ESP_ERR_WIFI_OK: succeed + * - ESP_OK: succeed */ esp_err_t esp_wifi_sta_wpa2_ent_set_cert_key(const unsigned char *client_cert, int client_cert_len, const unsigned char *private_key, int private_key_len, const unsigned char *private_key_passwd, int private_key_passwd_len); diff --git a/tools/sdk/include/esp32/esp_wps.h b/tools/sdk/include/esp32/esp_wps.h index bfbb215370d..efe37bd028d 100644 --- a/tools/sdk/include/esp32/esp_wps.h +++ b/tools/sdk/include/esp32/esp_wps.h @@ -77,7 +77,7 @@ typedef struct { * - ESP_OK : succeed * - ESP_ERR_WIFI_WPS_TYPE : wps type is invalid * - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on - * - ESP_ERR_WIFI_FAIL : wps initialization fails + * - ESP_FAIL : wps initialization fails */ esp_err_t esp_wifi_wps_enable(const esp_wps_config_t *config); @@ -106,7 +106,7 @@ esp_err_t esp_wifi_wps_disable(void); * - ESP_ERR_WIFI_WPS_TYPE : wps type is invalid * - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on * - ESP_ERR_WIFI_WPS_SM : wps state machine is not initialized - * - ESP_ERR_WIFI_FAIL : wps initialization fails + * - ESP_FAIL : wps initialization fails */ esp_err_t esp_wifi_wps_start(int timeout_ms); diff --git a/tools/sdk/include/esp_adc_cal/esp_adc_cal.h b/tools/sdk/include/esp_adc_cal/esp_adc_cal.h index adb6598496c..af611357b49 100644 --- a/tools/sdk/include/esp_adc_cal/esp_adc_cal.h +++ b/tools/sdk/include/esp_adc_cal/esp_adc_cal.h @@ -20,131 +20,130 @@ extern "C" { #endif #include +#include "esp_err.h" #include "driver/adc.h" -/** @cond */ -#define ADC_CAL_GAIN_SCALE 16 -#define ADC_CAL_OFFSET_SCALE 10 - -#define ADC_CAL_IDEAL_V_REF 1100 //In mV -#define ADC_CAL_LOW_V_REF 1000 -#define ADC_CAL_HIGH_V_REF 1200 -#define ADC_CAL_MIN 0 -#define ADC_CAL_MAX 4095 -/** @endcond */ +/** + * @brief Type of calibration value used in characterization + */ +typedef enum { + ESP_ADC_CAL_VAL_EFUSE_VREF = 0, /**< Characterization based on reference voltage stored in eFuse*/ + ESP_ADC_CAL_VAL_EFUSE_TP = 1, /**< Characterization based on Two Point values stored in eFuse*/ + ESP_ADC_CAL_VAL_DEFAULT_VREF = 2, /**< Characterization based on default reference voltage*/ +} esp_adc_cal_value_t; /** - * @brief Structure storing Lookup Table - * - * The Lookup Tables (LUT) of a given attenuation contains 33 equally spaced - * points. The Gain and Offset curves are used to find the appopriate gain and - * offset factor given a reference voltage v_ref. + * @brief Structure storing characteristics of an ADC * - * @note A seperate LUT is provided for each attenuation and are defined in - * esp_adc_cal_lookup_tables.c + * @note Call esp_adc_cal_characterize() to initialize the structure */ typedef struct { - uint32_t gain_m; /**= 1 with LFN enabled, string I/O functions, f_gets(), / f_putc(), f_puts and f_printf() convert the character encoding in it. / This option selects assumption of character encoding ON THE FILE to be diff --git a/tools/sdk/include/fatfs/vfs_fat_internal.h b/tools/sdk/include/fatfs/vfs_fat_internal.h new file mode 100644 index 00000000000..dc3bae271ca --- /dev/null +++ b/tools/sdk/include/fatfs/vfs_fat_internal.h @@ -0,0 +1,30 @@ +// Copyright 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. + +#pragma once + +#include "esp_vfs_fat.h" +#include +#include + +static inline size_t esp_vfs_fat_get_allocation_unit_size( + size_t sector_size, size_t requested_size) +{ + size_t alloc_unit_size = requested_size; + const size_t max_sectors_per_cylinder = 128; + const size_t max_size = sector_size * max_sectors_per_cylinder; + alloc_unit_size = MAX(alloc_unit_size, sector_size); + alloc_unit_size = MIN(alloc_unit_size, max_size); + return alloc_unit_size; +} diff --git a/tools/sdk/include/freertos/freertos/portable.h b/tools/sdk/include/freertos/freertos/portable.h index b0fe405f7bf..9fe74b60c0a 100644 --- a/tools/sdk/include/freertos/freertos/portable.h +++ b/tools/sdk/include/freertos/freertos/portable.h @@ -183,6 +183,12 @@ void vPortSetStackWatchpoint( void* pxStackStart ); */ BaseType_t xPortInIsrContext(); +/* + * This function will be called in High prio ISRs. Returns true if the current core was in ISR context + * before calling into high prio ISR context. + */ +BaseType_t xPortInterruptedFromISRContext(); + /* * The structures and methods of manipulating the MPU are contained within the * port layer. @@ -213,5 +219,7 @@ uint32_t xPortGetTickRateHz(void); } #endif +void uxPortCompareSetExtram(volatile uint32_t *addr, uint32_t compare, uint32_t *set); + #endif /* PORTABLE_H */ diff --git a/tools/sdk/include/freertos/freertos/task.h b/tools/sdk/include/freertos/freertos/task.h index ab45f1c43e7..5af62c69c66 100644 --- a/tools/sdk/include/freertos/freertos/task.h +++ b/tools/sdk/include/freertos/freertos/task.h @@ -380,6 +380,9 @@ is used in assert() statements. */ * @return pdPASS if the task was successfully created and added to a ready * list, otherwise an error code defined in the file projdefs.h * + * @note If program uses thread local variables (ones specified with "__thread" keyword) + * then storage for them will be allocated on the task's stack. + * * Example usage: * @code{c} * // Task to be created. @@ -530,6 +533,9 @@ is used in assert() statements. */ * are NULL then the task will not be created and * errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY is returned. * + * @note If program uses thread local variables (ones specified with "__thread" keyword) + * then storage for them will be allocated on the task's stack. + * * Example usage: * @code{c} * diff --git a/tools/sdk/include/heap/esp_heap_task_info.h b/tools/sdk/include/heap/esp_heap_task_info.h new file mode 100644 index 00000000000..fca9a43ba66 --- /dev/null +++ b/tools/sdk/include/heap/esp_heap_task_info.h @@ -0,0 +1,98 @@ +// Copyright 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. +#pragma once + +#ifdef CONFIG_HEAP_TASK_TRACKING + +#ifdef __cplusplus +extern "C" { +#endif + +// This macro controls how much space is provided for partitioning the per-task +// heap allocation info according to one or more sets of heap capabilities. +#define NUM_HEAP_TASK_CAPS 4 + +/** @brief Structure to collect per-task heap allocation totals partitioned by selected caps */ +typedef struct { + TaskHandle_t task; ///< Task to which these totals belong + size_t size[NUM_HEAP_TASK_CAPS]; ///< Total allocations partitioned by selected caps + size_t count[NUM_HEAP_TASK_CAPS]; ///< Number of blocks partitioned by selected caps +} heap_task_totals_t; + +/** @brief Structure providing details about a block allocated by a task */ +typedef struct { + TaskHandle_t task; ///< Task that allocated the block + void *address; ///< User address of allocated block + uint32_t size; ///< Size of the allocated block +} heap_task_block_t; + +/** @brief Structure to provide parameters to heap_caps_get_per_task_info + * + * The 'caps' and 'mask' arrays allow partitioning the per-task heap allocation + * totals by selected sets of heap region capabilities so that totals for + * multiple regions can be accumulated in one scan. The capabilities flags for + * each region ANDed with mask[i] are compared to caps[i] in order; the + * allocations in that region are added to totals->size[i] and totals->count[i] + * for the first i that matches. To collect the totals without any + * partitioning, set mask[0] and caps[0] both to zero. The allocation totals + * are returned in the 'totals' array of heap_task_totals_t structs. To allow + * easily comparing the totals array between consecutive calls, that array can + * be left populated from one call to the next so the order of tasks is the + * same even if some tasks have freed their blocks or have been deleted. The + * number of blocks prepopulated is given by num_totals, which is updated upon + * return. If there are more tasks with allocations than the capacity of the + * totals array (given by max_totals), information for the excess tasks will be + * not be collected. The totals array pointer can be NULL if the totals are + * not desired. + * + * The 'tasks' array holds a list of handles for tasks whose block details are + * to be returned in the 'blocks' array of heap_task_block_t structs. If the + * tasks array pointer is NULL, block details for all tasks will be returned up + * to the capacity of the buffer array, given by max_blocks. The function + * return value tells the number of blocks filled into the array. The blocks + * array pointer can be NULL if block details are not desired, or max_blocks + * can be set to zero. + */ +typedef struct { + int32_t caps[NUM_HEAP_TASK_CAPS]; ///< Array of caps for partitioning task totals + int32_t mask[NUM_HEAP_TASK_CAPS]; ///< Array of masks under which caps must match + TaskHandle_t *tasks; ///< Array of tasks whose block info is returned + size_t num_tasks; ///< Length of tasks array + heap_task_totals_t *totals; ///< Array of structs to collect task totals + size_t *num_totals; ///< Number of task structs currently in array + size_t max_totals; ///< Capacity of array of task totals structs + heap_task_block_t *blocks; ///< Array of task block details structs + size_t max_blocks; ///< Capacity of array of task block info structs +} heap_task_info_params_t; + +/** + * @brief Return per-task heap allocation totals and lists of blocks. + * + * For each task that has allocated memory from the heap, return totals for + * allocations within regions matching one or more sets of capabilities. + * + * Optionally also return an array of structs providing details about each + * block allocated by one or more requested tasks, or by all tasks. + * + * @param params Structure to hold all the parameters for the function + * (@see heap_task_info_params_t). + * @return Number of block detail structs returned (@see heap_task_block_t). + */ +extern size_t heap_caps_get_per_task_info(heap_task_info_params_t *params); + +#ifdef __cplusplus +} +#endif + +#endif // CONFIG_HEAP_TASK_TRACKING diff --git a/tools/sdk/include/json/cJSON.h b/tools/sdk/include/json/cJSON.h index 7c4f8e7cdbe..52101e11793 100644 --- a/tools/sdk/include/json/cJSON.h +++ b/tools/sdk/include/json/cJSON.h @@ -30,8 +30,8 @@ extern "C" /* project version */ #define CJSON_VERSION_MAJOR 1 -#define CJSON_VERSION_MINOR 6 -#define CJSON_VERSION_PATCH 0 +#define CJSON_VERSION_MINOR 7 +#define CJSON_VERSION_PATCH 1 #include @@ -165,6 +165,9 @@ CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *st /* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void); +/* Check if the item is a string and return its valuestring */ +CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item); + /* These functions check the type of an item */ CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item); CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item); @@ -189,6 +192,14 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw); CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void); CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void); +/* Create a string where valuestring references a string so + * it will not be freed by cJSON_Delete */ +CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string); +/* Create an object/arrray that only references it's elements so + * they will not be freed by cJSON_Delete */ +CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child); +CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child); + /* These utilities create an Array of count items. */ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count); CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count); @@ -234,14 +245,17 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons CJSON_PUBLIC(void) cJSON_Minify(char *json); -/* Macros for creating things quickly. */ -#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull()) -#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue()) -#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse()) -#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b)) -#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n)) -#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s)) -#define cJSON_AddRawToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateRaw(s)) +/* Helper functions for creating and adding items to an object at the same time. + * They return the added item or NULL on failure. */ +CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name); +CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name); +CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name); +CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean); +CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number); +CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string); +CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw); +CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name); +CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name); /* When assigning an integer value, it needs to be propagated to valuedouble too. */ #define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number)) diff --git a/tools/sdk/include/log/esp_log.h b/tools/sdk/include/log/esp_log.h index 2f251c6b869..c13a3f22719 100644 --- a/tools/sdk/include/log/esp_log.h +++ b/tools/sdk/include/log/esp_log.h @@ -120,8 +120,12 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, . * @param level level of the log * */ -#define ESP_LOG_BUFFER_HEX_LEVEL( tag, buffer, buff_len, level ) do {\ - if ( LOG_LOCAL_LEVEL >= level ) esp_log_buffer_hex_internal( tag, buffer, buff_len, level ); } while(0) +#define ESP_LOG_BUFFER_HEX_LEVEL( tag, buffer, buff_len, level ) \ + do {\ + if ( LOG_LOCAL_LEVEL >= (level) ) { \ + esp_log_buffer_hex_internal( tag, buffer, buff_len, level ); \ + } \ + } while(0) /** * @brief Log a buffer of characters at specified level, separated into 16 bytes each line. Buffer should contain only printable characters. @@ -135,8 +139,12 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, . * @param level level of the log * */ -#define ESP_LOG_BUFFER_CHAR_LEVEL( tag, buffer, buff_len, level ) do {\ - if ( LOG_LOCAL_LEVEL >= level ) esp_log_buffer_char_internal( tag, buffer, buff_len, level ); } while(0) +#define ESP_LOG_BUFFER_CHAR_LEVEL( tag, buffer, buff_len, level ) \ + do {\ + if ( LOG_LOCAL_LEVEL >= (level) ) { \ + esp_log_buffer_char_internal( tag, buffer, buff_len, level ); \ + } \ + } while(0) /** * @brief Dump a buffer to the log at specified level. @@ -157,11 +165,13 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, . * * @param level level of the log */ -#define ESP_LOG_BUFFER_HEXDUMP( tag, buffer, buff_len, level ) do {\ - if ( LOG_LOCAL_LEVEL >= level ) esp_log_buffer_hexdump_internal( tag, buffer, buff_len, level); } while(0) +#define ESP_LOG_BUFFER_HEXDUMP( tag, buffer, buff_len, level ) \ + do { \ + if ( LOG_LOCAL_LEVEL >= (level) ) { \ + esp_log_buffer_hexdump_internal( tag, buffer, buff_len, level); \ + } \ + } while(0) - -#if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) /** * @brief Log a buffer of hex bytes at Info level * @@ -174,7 +184,12 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, . * @see ``esp_log_buffer_hex_level`` * */ -#define ESP_LOG_BUFFER_HEX(tag, buffer, buff_len) ESP_LOG_BUFFER_HEX_LEVEL( tag, buffer, buff_len, ESP_LOG_INFO ) +#define ESP_LOG_BUFFER_HEX(tag, buffer, buff_len) \ + do { \ + if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { \ + ESP_LOG_BUFFER_HEX_LEVEL( tag, buffer, buff_len, ESP_LOG_INFO ); \ + }\ + } while(0) /** * @brief Log a buffer of characters at Info level. Buffer should contain only printable characters. @@ -188,12 +203,13 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, . * @see ``esp_log_buffer_char_level`` * */ -#define ESP_LOG_BUFFER_CHAR(tag, buffer, buff_len) ESP_LOG_BUFFER_CHAR_LEVEL( tag, buffer, buff_len, ESP_LOG_INFO ) +#define ESP_LOG_BUFFER_CHAR(tag, buffer, buff_len) \ + do { \ + if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { \ + ESP_LOG_BUFFER_CHAR_LEVEL( tag, buffer, buff_len, ESP_LOG_INFO ); \ + }\ + } while(0) -#else -#define ESP_LOG_BUFFER_HEX(tag, buffer, buff_len) {} -#define ESP_LOG_BUFFER_CHAR(tag, buffer, buff_len) {} -#endif //to be back compatible #define esp_log_buffer_hex ESP_LOG_BUFFER_HEX diff --git a/tools/sdk/include/lwip/lwip/sockets.h b/tools/sdk/include/lwip/lwip/sockets.h index 4dd013bcfcd..d8e4c7ffbeb 100755 --- a/tools/sdk/include/lwip/lwip/sockets.h +++ b/tools/sdk/include/lwip/lwip/sockets.h @@ -39,6 +39,7 @@ #if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ #include /* for size_t */ +#include /* for FD_ZERO */ #include "lwip/ip_addr.h" #include "lwip/err.h" diff --git a/tools/sdk/include/lwip/lwipopts.h b/tools/sdk/include/lwip/lwipopts.h index 4652c6d4a86..3e8d26ee3b8 100644 --- a/tools/sdk/include/lwip/lwipopts.h +++ b/tools/sdk/include/lwip/lwipopts.h @@ -727,6 +727,12 @@ #define ESP_LWIP_LOGI(...) ESP_LOGI("lwip", __VA_ARGS__) #define ESP_PING 1 +#if CONFIG_LWIP_IRAM_OPTIMIZATION +#define ESP_IRAM_ATTR IRAM_ATTR +#else +#define ESP_IRAM_ATTR +#endif + #define TCP_WND_DEFAULT CONFIG_TCP_WND_DEFAULT #define TCP_SND_BUF_DEFAULT CONFIG_TCP_SND_BUF_DEFAULT diff --git a/tools/sdk/include/openssl/internal/ssl_types.h b/tools/sdk/include/openssl/internal/ssl_types.h index b08c4d0e2a9..21ba69f4c7f 100644 --- a/tools/sdk/include/openssl/internal/ssl_types.h +++ b/tools/sdk/include/openssl/internal/ssl_types.h @@ -29,7 +29,6 @@ typedef void X509_STORE; typedef void RSA; typedef void STACK; -typedef void BIO; #define ossl_inline inline @@ -84,6 +83,9 @@ typedef struct pkey_method_st PKEY_METHOD; struct ssl_alpn_st; typedef struct ssl_alpn_st SSL_ALPN; +struct bio_st; +typedef struct bio_st BIO; + struct stack_st { char **data; @@ -106,6 +108,8 @@ struct x509_st { void *x509_pm; const X509_METHOD *method; + + int ref_counter; }; struct cert_st { @@ -147,6 +151,11 @@ struct X509_VERIFY_PARAM_st { }; +struct bio_st { + const unsigned char * data; + int dlen; +}; + typedef enum { ALPN_INIT, ALPN_ENABLE, ALPN_DISABLE, ALPN_ERROR } ALPN_STATUS; struct ssl_alpn_st { ALPN_STATUS alpn_status; diff --git a/tools/sdk/include/openssl/internal/ssl_x509.h b/tools/sdk/include/openssl/internal/ssl_x509.h index 840fbf1ec10..877c4fbb775 100644 --- a/tools/sdk/include/openssl/internal/ssl_x509.h +++ b/tools/sdk/include/openssl/internal/ssl_x509.h @@ -101,6 +101,73 @@ int SSL_add_client_CA(SSL *ssl, X509 *x); */ int SSL_use_certificate_ASN1(SSL *ssl, int len, const unsigned char *d); + +/** + * @brief set SSL context client CA certification + * + * @param store - pointer to X509_STORE + * @param x - pointer to X509 certification point + * + * @return result + * 0 : failed + * 1 : OK + */ +int X509_STORE_add_cert(X509_STORE *store, X509 *x); + +/** + * @brief load data in BIO + * + * Normally BIO_write should append data but that doesn't happen here, and + * 'data' cannot be freed after the function is called, it should remain valid + * until BIO object is in use. + * + * @param b - pointer to BIO + * @param data - pointer to data + * @param dlen - data bytes + * + * @return result + * 0 : failed + * 1 : OK + */ +int BIO_write(BIO *b, const void *data, int dlen); + +/** + * @brief load a character certification context into system context. + * + * If '*cert' is pointed to the certification, then load certification + * into it, or create a new X509 certification object. + * + * @param bp - pointer to BIO + * @param buffer - pointer to the certification context memory + * @param cb - pointer to a callback which queries pass phrase used + for encrypted PEM structure + * @param u - pointer to arbitary data passed by application to callback + * + * @return X509 certification object point + */ +X509 * PEM_read_bio_X509(BIO *bp, X509 **x, void *cb, void *u); + +/** + * @brief create a BIO object + * + * @param method - pointer to BIO_METHOD + * + * @return pointer to BIO object + */ +BIO *BIO_new(void * method); + +/** + * @brief get the memory BIO method function + */ +void *BIO_s_mem(); + +/** + * @brief free a BIO object + * + * @param x - pointer to BIO object + */ +void BIO_free(BIO *b); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/soc/soc/efuse_reg.h b/tools/sdk/include/soc/soc/efuse_reg.h index affcfa878d6..0be58c46514 100644 --- a/tools/sdk/include/soc/soc/efuse_reg.h +++ b/tools/sdk/include/soc/soc/efuse_reg.h @@ -79,21 +79,33 @@ #define EFUSE_RD_WIFI_MAC_CRC_HIGH_S 0 #define EFUSE_BLK0_RDATA3_REG (DR_REG_EFUSE_BASE + 0x00c) -/* EFUSE_RD_CHIP_VER_REV1 : R/W ;bitpos:[16] ;default: 1'b0 ; */ +/* EFUSE_RD_CHIP_VER_REV1 : R/W ;bitpos:[15] ;default: 1'b0 ; */ /*description: bit is set to 1 for rev1 silicon*/ #define EFUSE_RD_CHIP_VER_REV1 (BIT(15)) #define EFUSE_RD_CHIP_VER_REV1_M ((EFUSE_RD_CHIP_VER_REV1_V)<<(EFUSE_RD_CHIP_VER_REV1_S)) #define EFUSE_RD_CHIP_VER_REV1_V 0x1 #define EFUSE_RD_CHIP_VER_REV1_S 15 -/* EFUSE_RD_CHIP_VER_RESERVE : R/W ;bitpos:[15:12] ;default: 3'b0 ; */ -/*description: */ -#define EFUSE_RD_CHIP_VER_RESERVE 0x00000007 -#define EFUSE_RD_CHIP_VER_RESERVE_M ((EFUSE_RD_CHIP_VER_RESERVE_V)<<(EFUSE_RD_CHIP_VER_RESERVE_S)) -#define EFUSE_RD_CHIP_VER_RESERVE_V 0x7 -#define EFUSE_RD_CHIP_VER_RESERVE_S 12 -/* EFUSE_RD_CHIP_VER : R/W ;bitpos:[11:9] ;default: 3'b0 ; */ +/* EFUSE_RD_BLK3_PART_RESERVE : R/W ; bitpos:[14] ; default: 1'b0; */ +/*description: If set, this bit indicates that BLOCK3[143:96] is reserved for internal use*/ +#define EFUSE_RD_BLK3_PART_RESERVE (BIT(14)) +#define EFUSE_RD_BLK3_PART_RESERVE_M ((EFUSE_RD_BLK3_PART_RESERVE_V)<<(EFUSE_RD_BLK3_PART_RESERVE_S)) +#define EFUSE_RD_BLK3_PART_RESERVE_V 0x1 +#define EFUSE_RD_BLK3_PART_RESERVE_S 14 +/* EFUSE_RD_CHIP_CPU_FREQ_RATED : R/W ;bitpos:[13] ;default: 1'b0 ; */ +/*description: If set, the ESP32's maximum CPU frequency has been rated*/ +#define EFUSE_RD_CHIP_CPU_FREQ_RATED (BIT(13)) +#define EFUSE_RD_CHIP_CPU_FREQ_RATED_M ((EFUSE_RD_CHIP_CPU_FREQ_RATED_V)<<(EFUSE_RD_CHIP_CPU_FREQ_RATED_S)) +#define EFUSE_RD_CHIP_CPU_FREQ_RATED_V 0x1 +#define EFUSE_RD_CHIP_CPU_FREQ_RATED_S 13 +/* EFUSE_RD_CHIP_CPU_FREQ_LOW : R/W ;bitpos:[12] ;default: 1'b0 ; */ +/*description: If set alongside EFUSE_RD_CHIP_CPU_FREQ_RATED, the ESP32's max CPU frequency is rated for 160MHz. 240MHz otherwise*/ +#define EFUSE_RD_CHIP_CPU_FREQ_LOW (BIT(12)) +#define EFUSE_RD_CHIP_CPU_FREQ_LOW_M ((EFUSE_RD_CHIP_CPU_FREQ_LOW_V)<<(EFUSE_RD_CHIP_CPU_FREQ_LOW_S)) +#define EFUSE_RD_CHIP_CPU_FREQ_LOW_V 0x1 +#define EFUSE_RD_CHIP_CPU_FREQ_LOW_S 12 +/* EFUSE_RD_CHIP_VER_PKG : R/W ;bitpos:[11:9] ;default: 3'b0 ; */ /*description: chip package */ -#define EFUSE_RD_CHIP_VER 0x00000007 +#define EFUSE_RD_CHIP_VER_PKG 0x00000007 #define EFUSE_RD_CHIP_VER_PKG_M ((EFUSE_RD_CHIP_VER_PKG_V)<<(EFUSE_RD_CHIP_VER_PKG_S)) #define EFUSE_RD_CHIP_VER_PKG_V 0x7 #define EFUSE_RD_CHIP_VER_PKG_S 9 @@ -152,6 +164,15 @@ #define EFUSE_RD_XPD_SDIO_REG_M (BIT(14)) #define EFUSE_RD_XPD_SDIO_REG_V 0x1 #define EFUSE_RD_XPD_SDIO_REG_S 14 +/* EFUSE_RD_ADC_VREF : R/W ;bitpos:[12:8] ;default: 5'b0 ; */ +/*description: True ADC reference voltage */ +#define EFUSE_RD_ADC_VREF 0x0000001F +#define EFUSE_RD_ADC_VREF_M ((EFUSE_RD_ADC_VREF_V)<<(EFUSE_RD_ADC_VREF_S)) +#define EFUSE_RD_ADC_VREF_V 0x1F +#define EFUSE_RD_ADC_VREF_S 8 +/* Note: EFUSE_ADC_VREF and SDIO_DREFH/M/L share the same address space. Newer + * versions of ESP32 come with EFUSE_ADC_VREF already burned, therefore + * SDIO_DREFH/M/L is only available in older versions of ESP32 */ /* EFUSE_RD_SDIO_DREFL : RO ;bitpos:[13:12] ;default: 2'b0 ; */ /*description: */ #define EFUSE_RD_SDIO_DREFL 0x00000003 @@ -314,24 +335,41 @@ #define EFUSE_WIFI_MAC_CRC_HIGH_S 0 #define EFUSE_BLK0_WDATA3_REG (DR_REG_EFUSE_BASE + 0x028) -/* EFUSE_CHIP_VER_REV1 : R/W ;bitpos:[16] ;default: 1'b0 ; */ +/* EFUSE_CHIP_VER_REV1 : R/W ;bitpos:[15] ;default: 1'b0 ; */ /*description: */ #define EFUSE_CHIP_VER_REV1 (BIT(15)) #define EFUSE_CHIP_VER_REV1_M ((EFUSE_CHIP_VER_REV1_V)<<(EFUSE_CHIP_VER_REV1_S)) #define EFUSE_CHIP_VER_REV1_V 0x1 #define EFUSE_CHIP_VER_REV1_S 15 -/* EFUSE_CHIP_VER_RESERVE : R/W ;bitpos:[15:12] ;default: 3'b0 ; */ -/*description: */ -#define EFUSE_CHIP_VER_RESERVE 0x00000007 -#define EFUSE_CHIP_VER_RESERVE_M ((EFUSE_CHIP_VER_RESERVE_V)<<(EFUSE_CHIP_VER_RESERVE_S)) -#define EFUSE_CHIP_VER_RESERVE_V 0x7 -#define EFUSE_CHIP_VER_RESERVE_S 12 -/* EFUSE_CHIP_VER : R/W ;bitpos:[11:9] ;default: 3'b0 ; */ +/* EFUSE_BLK3_PART_RESERVE : R/W ; bitpos:[14] ; default: 1'b0; */ +/*description: If set, this bit indicates that BLOCK3[143:96] is reserved for internal use*/ +#define EFUSE_BLK3_PART_RESERVE (BIT(14)) +#define EFUSE_BLK3_PART_RESERVE_M ((EFUSE_BLK3_PART_RESERVE_V)<<(EFUSE_BLK3_PART_RESERVE_S)) +#define EFUSE_BLK3_PART_RESERVE_V 0x1 +#define EFUSE_BLK3_PART_RESERVE_S 14 +/* EFUSE_CHIP_CPU_FREQ_RATED : R/W ;bitpos:[13] ;default: 1'b0 ; */ +/*description: If set, the ESP32's maximum CPU frequency has been rated*/ +#define EFUSE_CHIP_CPU_FREQ_RATED (BIT(13)) +#define EFUSE_CHIP_CPU_FREQ_RATED_M ((EFUSE_CHIP_CPU_FREQ_RATED_V)<<(EFUSE_CHIP_CPU_FREQ_RATED_S)) +#define EFUSE_CHIP_CPU_FREQ_RATED_V 0x1 +#define EFUSE_CHIP_CPU_FREQ_RATED_S 13 +/* EFUSE_CHIP_CPU_FREQ_LOW : R/W ;bitpos:[12] ;default: 1'b0 ; */ +/*description: If set alongside EFUSE_CHIP_CPU_FREQ_RATED, the ESP32's max CPU frequency is rated for 160MHz. 240MHz otherwise*/ +#define EFUSE_CHIP_CPU_FREQ_LOW (BIT(12)) +#define EFUSE_CHIP_CPU_FREQ_LOW_M ((EFUSE_CHIP_CPU_FREQ_LOW_V)<<(EFUSE_CHIP_CPU_FREQ_LOW_S)) +#define EFUSE_CHIP_CPU_FREQ_LOW_V 0x1 +#define EFUSE_CHIP_CPU_FREQ_LOW_S 12 +/* EFUSE_CHIP_VER_PKG : R/W ;bitpos:[11:9] ;default: 3'b0 ; */ /*description: */ #define EFUSE_CHIP_VER_PKG 0x00000007 #define EFUSE_CHIP_VER_PKG_M ((EFUSE_CHIP_VER_PKG_V)<<(EFUSE_CHIP_VER_PKG_S)) #define EFUSE_CHIP_VER_PKG_V 0x7 #define EFUSE_CHIP_VER_PKG_S 9 +#define EFUSE_CHIP_VER_PKG_ESP32D0WDQ6 0 +#define EFUSE_CHIP_VER_PKG_ESP32D0WDQ5 1 +#define EFUSE_CHIP_VER_PKG_ESP32D2WDQ5 2 +#define EFUSE_CHIP_VER_PKG_ESP32PICOD2 4 +#define EFUSE_CHIP_VER_PKG_ESP32PICOD4 5 /* EFUSE_SPI_PAD_CONFIG_HD : R/W ;bitpos:[8:4] ;default: 5'b0 ; */ /*description: program for SPI_pad_config_hd*/ #define EFUSE_SPI_PAD_CONFIG_HD 0x0000001F @@ -382,6 +420,15 @@ #define EFUSE_XPD_SDIO_REG_M (BIT(14)) #define EFUSE_XPD_SDIO_REG_V 0x1 #define EFUSE_XPD_SDIO_REG_S 14 +/* EFUSE_ADC_VREF : R/W ;bitpos:[12:8] ;default: 5'b0 ; */ +/*description: True ADC reference voltage */ +#define EFUSE_ADC_VREF 0x0000001F +#define EFUSE_ADC_VREF_M ((EFUSE_ADC_VREF_V)<<(EFUSE_ADC_VREF_S)) +#define EFUSE_ADC_VREF_V 0x1F +#define EFUSE_ADC_VREF_S 8 +/* Note: EFUSE_ADC_VREF and SDIO_DREFH/M/L share the same address space. Newer + * versions of ESP32 come with EFUSE_ADC_VREF already burned, therefore + * SDIO_DREFH/M/L is only available in older versions of ESP32 */ /* EFUSE_SDIO_DREFL : R/W ;bitpos:[13:12] ;default: 2'b0 ; */ /*description: */ #define EFUSE_SDIO_DREFL 0x00000003 @@ -659,6 +706,8 @@ #define EFUSE_BLK3_DOUT2_V 0xFFFFFFFF #define EFUSE_BLK3_DOUT2_S 0 +/* Note: Newer ESP32s utilize BLK3_DATA3 and parts of BLK3_DATA4 for calibration + * purposes. This usage is indicated by the EFUSE_RD_BLK3_PART_RESERVE bit.*/ #define EFUSE_BLK3_RDATA3_REG (DR_REG_EFUSE_BASE + 0x084) /* EFUSE_BLK3_DOUT3 : RO ;bitpos:[31:0] ;default: 32'h0 ; */ /*description: read for BLOCK3*/ @@ -666,6 +715,30 @@ #define EFUSE_BLK3_DOUT3_M ((EFUSE_BLK3_DOUT3_V)<<(EFUSE_BLK3_DOUT3_S)) #define EFUSE_BLK3_DOUT3_V 0xFFFFFFFF #define EFUSE_BLK3_DOUT3_S 0 +/* EFUSE_RD_ADC2_TP_HIGH : R/W ;bitpos:[31:23] ;default: 9'b0 ; */ +/*description: ADC2 Two Point calibration high point. Only valid if EFUSE_RD_BLK3_PART_RESERVE */ +#define EFUSE_RD_ADC2_TP_HIGH 0x1FF +#define EFUSE_RD_ADC2_TP_HIGH_M ((EFUSE_RD_ADC2_TP_HIGH_V)<<(EFUSE_RD_ADC2_TP_HIGH_S)) +#define EFUSE_RD_ADC2_TP_HIGH_V 0x1FF +#define EFUSE_RD_ADC2_TP_HIGH_S 23 +/* EFUSE_RD_ADC2_TP_LOW : R/W ;bitpos:[22:16] ;default: 7'b0 ; */ +/*description: ADC2 Two Point calibration low point. Only valid if EFUSE_RD_BLK3_PART_RESERVE */ +#define EFUSE_RD_ADC2_TP_LOW 0x7F +#define EFUSE_RD_ADC2_TP_LOW_M ((EFUSE_RD_ADC2_TP_LOW_V)<<(EFUSE_RD_ADC2_TP_LOW_S)) +#define EFUSE_RD_ADC2_TP_LOW_V 0x7F +#define EFUSE_RD_ADC2_TP_LOW_S 16 +/* EFUSE_RD_ADC1_TP_HIGH : R/W ;bitpos:[15:7] ;default: 9'b0 ; */ +/*description: ADC1 Two Point calibration high point. Only valid if EFUSE_RD_BLK3_PART_RESERVE */ +#define EFUSE_RD_ADC1_TP_HIGH 0x1FF +#define EFUSE_RD_ADC1_TP_HIGH_M ((EFUSE_RD_ADC1_TP_HIGH_V)<<(EFUSE_RD_ADC1_TP_HIGH_S)) +#define EFUSE_RD_ADC1_TP_HIGH_V 0x1FF +#define EFUSE_RD_ADC1_TP_HIGH_S 7 +/* EFUSE_RD_ADC1_TP_LOW : R/W ;bitpos:[6:0] ;default: 7'b0 ; */ +/*description: ADC1 Two Point calibration low point. Only valid if EFUSE_RD_BLK3_PART_RESERVE */ +#define EFUSE_RD_ADC1_TP_LOW 0x7F +#define EFUSE_RD_ADC1_TP_LOW_M ((EFUSE_RD_ADC1_TP_LOW_V)<<(EFUSE_RD_ADC1_TP_LOW_S)) +#define EFUSE_RD_ADC1_TP_LOW_V 0x7F +#define EFUSE_RD_ADC1_TP_LOW_S 0 #define EFUSE_BLK3_RDATA4_REG (DR_REG_EFUSE_BASE + 0x088) /* EFUSE_BLK3_DOUT4 : RO ;bitpos:[31:0] ;default: 32'h0 ; */ @@ -674,6 +747,12 @@ #define EFUSE_BLK3_DOUT4_M ((EFUSE_BLK3_DOUT4_V)<<(EFUSE_BLK3_DOUT4_S)) #define EFUSE_BLK3_DOUT4_V 0xFFFFFFFF #define EFUSE_BLK3_DOUT4_S 0 +/* EFUSE_RD_CAL_RESERVED: R/W ; bitpos:[0:15] ; default : 16'h0 ; */ +/*description: Reserved for future calibration use. Indicated by EFUSE_RD_BLK3_PART_RESERVE */ +#define EFUSE_RD_CAL_RESERVED 0x0000FFFF +#define EFUSE_RD_CAL_RESERVED_M ((EFUSE_RD_CAL_RESERVED_V)<<(EFUSE_RD_CAL_RESERVED_S)) +#define EFUSE_RD_CAL_RESERVED_V 0xFFFF +#define EFUSE_RD_CAL_RESERVED_S 0 #define EFUSE_BLK3_RDATA5_REG (DR_REG_EFUSE_BASE + 0x08c) /* EFUSE_BLK3_DOUT5 : RO ;bitpos:[31:0] ;default: 32'h0 ; */ @@ -851,6 +930,8 @@ #define EFUSE_BLK3_DIN2_V 0xFFFFFFFF #define EFUSE_BLK3_DIN2_S 0 +/* Note: Newer ESP32s utilize BLK3_DATA3 and parts of BLK3_DATA4 for calibration + * purposes. This usage is indicated by the EFUSE_RD_BLK3_PART_RESERVE bit.*/ #define EFUSE_BLK3_WDATA3_REG (DR_REG_EFUSE_BASE + 0x0e4) /* EFUSE_BLK3_DIN3 : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ /*description: program for BLOCK3*/ @@ -858,6 +939,30 @@ #define EFUSE_BLK3_DIN3_M ((EFUSE_BLK3_DIN3_V)<<(EFUSE_BLK3_DIN3_S)) #define EFUSE_BLK3_DIN3_V 0xFFFFFFFF #define EFUSE_BLK3_DIN3_S 0 +/* EFUSE_ADC2_TP_HIGH : R/W ;bitpos:[31:23] ;default: 9'b0 ; */ +/*description: ADC2 Two Point calibration high point. Only valid if EFUSE_RD_BLK3_PART_RESERVE */ +#define EFUSE_ADC2_TP_HIGH 0x1FF +#define EFUSE_ADC2_TP_HIGH_M ((EFUSE_ADC2_TP_HIGH_V)<<(EFUSE_ADC2_TP_HIGH_S)) +#define EFUSE_ADC2_TP_HIGH_V 0x1FF +#define EFUSE_ADC2_TP_HIGH_S 23 +/* EFUSE_ADC2_TP_LOW : R/W ;bitpos:[22:16] ;default: 7'b0 ; */ +/*description: ADC2 Two Point calibration low point. Only valid if EFUSE_RD_BLK3_PART_RESERVE */ +#define EFUSE_ADC2_TP_LOW 0x7F +#define EFUSE_ADC2_TP_LOW_M ((EFUSE_ADC2_TP_LOW_V)<<(EFUSE_ADC2_TP_LOW_S)) +#define EFUSE_ADC2_TP_LOW_V 0x7F +#define EFUSE_ADC2_TP_LOW_S 16 +/* EFUSE_ADC1_TP_HIGH : R/W ;bitpos:[15:7] ;default: 9'b0 ; */ +/*description: ADC1 Two Point calibration high point. Only valid if EFUSE_RD_BLK3_PART_RESERVE */ +#define EFUSE_ADC1_TP_HIGH 0x1FF +#define EFUSE_ADC1_TP_HIGH_M ((EFUSE_ADC1_TP_HIGH_V)<<(EFUSE_ADC1_TP_HIGH_S)) +#define EFUSE_ADC1_TP_HIGH_V 0x1FF +#define EFUSE_ADC1_TP_HIGH_S 7 +/* EFUSE_ADC1_TP_LOW : R/W ;bitpos:[6:0] ;default: 7'b0 ; */ +/*description: ADC1 Two Point calibration low point. Only valid if EFUSE_RD_BLK3_PART_RESERVE */ +#define EFUSE_ADC1_TP_LOW 0x7F +#define EFUSE_ADC1_TP_LOW_M ((EFUSE_ADC1_TP_LOW_V)<<(EFUSE_ADC1_TP_LOW_S)) +#define EFUSE_ADC1_TP_LOW_V 0x7F +#define EFUSE_ADC1_TP_LOW_S 0 #define EFUSE_BLK3_WDATA4_REG (DR_REG_EFUSE_BASE + 0x0e8) /* EFUSE_BLK3_DIN4 : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ @@ -866,6 +971,12 @@ #define EFUSE_BLK3_DIN4_M ((EFUSE_BLK3_DIN4_V)<<(EFUSE_BLK3_DIN4_S)) #define EFUSE_BLK3_DIN4_V 0xFFFFFFFF #define EFUSE_BLK3_DIN4_S 0 +/* EFUSE_CAL_RESERVED: R/W ; bitpos:[0:15] ; default : 16'h0 ; */ +/*description: Reserved for future calibration use. Indicated by EFUSE_BLK3_PART_RESERVE */ +#define EFUSE_CAL_RESERVED 0x0000FFFF +#define EFUSE_CAL_RESERVED_M ((EFUSE_CAL_RESERVED_V)<<(EFUSE_CAL_RESERVED_S)) +#define EFUSE_CAL_RESERVED_V 0xFFFF +#define EFUSE_CAL_RESERVED_S 0 #define EFUSE_BLK3_WDATA5_REG (DR_REG_EFUSE_BASE + 0x0ec) /* EFUSE_BLK3_DIN5 : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ diff --git a/tools/sdk/include/soc/soc/io_mux_reg.h b/tools/sdk/include/soc/soc/io_mux_reg.h index 2598989d096..5516e59834c 100644 --- a/tools/sdk/include/soc/soc/io_mux_reg.h +++ b/tools/sdk/include/soc/soc/io_mux_reg.h @@ -124,18 +124,21 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define CLK_OUT1_S 0 #define PERIPHS_IO_MUX_GPIO0_U (DR_REG_IO_MUX_BASE +0x44) +#define IO_MUX_GPIO0_REG PERIPHS_IO_MUX_GPIO0_U #define FUNC_GPIO0_EMAC_TX_CLK 5 #define FUNC_GPIO0_GPIO0 2 #define FUNC_GPIO0_CLK_OUT1 1 #define FUNC_GPIO0_GPIO0_0 0 #define PERIPHS_IO_MUX_U0TXD_U (DR_REG_IO_MUX_BASE +0x88) +#define IO_MUX_GPIO1_REG PERIPHS_IO_MUX_U0TXD_U #define FUNC_U0TXD_EMAC_RXD2 5 #define FUNC_U0TXD_GPIO1 2 #define FUNC_U0TXD_CLK_OUT3 1 #define FUNC_U0TXD_U0TXD 0 #define PERIPHS_IO_MUX_GPIO2_U (DR_REG_IO_MUX_BASE +0x40) +#define IO_MUX_GPIO2_REG PERIPHS_IO_MUX_GPIO2_U #define FUNC_GPIO2_SD_DATA0 4 #define FUNC_GPIO2_HS2_DATA0 3 #define FUNC_GPIO2_GPIO2 2 @@ -143,11 +146,13 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_GPIO2_GPIO2_0 0 #define PERIPHS_IO_MUX_U0RXD_U (DR_REG_IO_MUX_BASE +0x84) +#define IO_MUX_GPIO3_REG PERIPHS_IO_MUX_U0RXD_U #define FUNC_U0RXD_GPIO3 2 #define FUNC_U0RXD_CLK_OUT2 1 #define FUNC_U0RXD_U0RXD 0 #define PERIPHS_IO_MUX_GPIO4_U (DR_REG_IO_MUX_BASE +0x48) +#define IO_MUX_GPIO4_REG PERIPHS_IO_MUX_GPIO4_U #define FUNC_GPIO4_EMAC_TX_ER 5 #define FUNC_GPIO4_SD_DATA1 4 #define FUNC_GPIO4_HS2_DATA1 3 @@ -156,6 +161,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_GPIO4_GPIO4_0 0 #define PERIPHS_IO_MUX_GPIO5_U (DR_REG_IO_MUX_BASE +0x6c) +#define IO_MUX_GPIO5_REG PERIPHS_IO_MUX_GPIO5_U #define FUNC_GPIO5_EMAC_RX_CLK 5 #define FUNC_GPIO5_HS1_DATA6 3 #define FUNC_GPIO5_GPIO5 2 @@ -163,6 +169,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_GPIO5_GPIO5_0 0 #define PERIPHS_IO_MUX_SD_CLK_U (DR_REG_IO_MUX_BASE +0x60) +#define IO_MUX_GPIO6_REG PERIPHS_IO_MUX_SD_CLK_U #define FUNC_SD_CLK_U1CTS 4 #define FUNC_SD_CLK_HS1_CLK 3 #define FUNC_SD_CLK_GPIO6 2 @@ -170,6 +177,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_SD_CLK_SD_CLK 0 #define PERIPHS_IO_MUX_SD_DATA0_U (DR_REG_IO_MUX_BASE +0x64) +#define IO_MUX_GPIO7_REG PERIPHS_IO_MUX_SD_DATA0_U #define FUNC_SD_DATA0_U2RTS 4 #define FUNC_SD_DATA0_HS1_DATA0 3 #define FUNC_SD_DATA0_GPIO7 2 @@ -177,6 +185,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_SD_DATA0_SD_DATA0 0 #define PERIPHS_IO_MUX_SD_DATA1_U (DR_REG_IO_MUX_BASE +0x68) +#define IO_MUX_GPIO8_REG PERIPHS_IO_MUX_SD_DATA1_U #define FUNC_SD_DATA1_U2CTS 4 #define FUNC_SD_DATA1_HS1_DATA1 3 #define FUNC_SD_DATA1_GPIO8 2 @@ -184,6 +193,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_SD_DATA1_SD_DATA1 0 #define PERIPHS_IO_MUX_SD_DATA2_U (DR_REG_IO_MUX_BASE +0x54) +#define IO_MUX_GPIO9_REG PERIPHS_IO_MUX_SD_DATA2_U #define FUNC_SD_DATA2_U1RXD 4 #define FUNC_SD_DATA2_HS1_DATA2 3 #define FUNC_SD_DATA2_GPIO9 2 @@ -191,6 +201,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_SD_DATA2_SD_DATA2 0 #define PERIPHS_IO_MUX_SD_DATA3_U (DR_REG_IO_MUX_BASE +0x58) +#define IO_MUX_GPIO10_REG PERIPHS_IO_MUX_SD_DATA3_U #define FUNC_SD_DATA3_U1TXD 4 #define FUNC_SD_DATA3_HS1_DATA3 3 #define FUNC_SD_DATA3_GPIO10 2 @@ -198,6 +209,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_SD_DATA3_SD_DATA3 0 #define PERIPHS_IO_MUX_SD_CMD_U (DR_REG_IO_MUX_BASE +0x5c) +#define IO_MUX_GPIO11_REG PERIPHS_IO_MUX_SD_CMD_U #define FUNC_SD_CMD_U1RTS 4 #define FUNC_SD_CMD_HS1_CMD 3 #define FUNC_SD_CMD_GPIO11 2 @@ -205,6 +217,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_SD_CMD_SD_CMD 0 #define PERIPHS_IO_MUX_MTDI_U (DR_REG_IO_MUX_BASE +0x34) +#define IO_MUX_GPIO12_REG PERIPHS_IO_MUX_MTDI_U #define FUNC_MTDI_EMAC_TXD3 5 #define FUNC_MTDI_SD_DATA2 4 #define FUNC_MTDI_HS2_DATA2 3 @@ -213,6 +226,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_MTDI_MTDI 0 #define PERIPHS_IO_MUX_MTCK_U (DR_REG_IO_MUX_BASE +0x38) +#define IO_MUX_GPIO13_REG PERIPHS_IO_MUX_MTCK_U #define FUNC_MTCK_EMAC_RX_ER 5 #define FUNC_MTCK_SD_DATA3 4 #define FUNC_MTCK_HS2_DATA3 3 @@ -221,6 +235,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_MTCK_MTCK 0 #define PERIPHS_IO_MUX_MTMS_U (DR_REG_IO_MUX_BASE +0x30) +#define IO_MUX_GPIO14_REG PERIPHS_IO_MUX_MTMS_U #define FUNC_MTMS_EMAC_TXD2 5 #define FUNC_MTMS_SD_CLK 4 #define FUNC_MTMS_HS2_CLK 3 @@ -229,6 +244,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_MTMS_MTMS 0 #define PERIPHS_IO_MUX_MTDO_U (DR_REG_IO_MUX_BASE +0x3c) +#define IO_MUX_GPIO15_REG PERIPHS_IO_MUX_MTDO_U #define FUNC_MTDO_EMAC_RXD3 5 #define FUNC_MTDO_SD_CMD 4 #define FUNC_MTDO_HS2_CMD 3 @@ -237,6 +253,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_MTDO_MTDO 0 #define PERIPHS_IO_MUX_GPIO16_U (DR_REG_IO_MUX_BASE +0x4c) +#define IO_MUX_GPIO16_REG PERIPHS_IO_MUX_GPIO16_U #define FUNC_GPIO16_EMAC_CLK_OUT 5 #define FUNC_GPIO16_U2RXD 4 #define FUNC_GPIO16_HS1_DATA4 3 @@ -244,6 +261,7 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_GPIO16_GPIO16_0 0 #define PERIPHS_IO_MUX_GPIO17_U (DR_REG_IO_MUX_BASE +0x50) +#define IO_MUX_GPIO17_REG PERIPHS_IO_MUX_GPIO17_U #define FUNC_GPIO17_EMAC_CLK_OUT_180 5 #define FUNC_GPIO17_U2TXD 4 #define FUNC_GPIO17_HS1_DATA5 3 @@ -251,12 +269,14 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_GPIO17_GPIO17_0 0 #define PERIPHS_IO_MUX_GPIO18_U (DR_REG_IO_MUX_BASE +0x70) +#define IO_MUX_GPIO18_REG PERIPHS_IO_MUX_GPIO18_U #define FUNC_GPIO18_HS1_DATA7 3 #define FUNC_GPIO18_GPIO18 2 #define FUNC_GPIO18_VSPICLK 1 #define FUNC_GPIO18_GPIO18_0 0 #define PERIPHS_IO_MUX_GPIO19_U (DR_REG_IO_MUX_BASE +0x74) +#define IO_MUX_GPIO19_REG PERIPHS_IO_MUX_GPIO19_U #define FUNC_GPIO19_EMAC_TXD0 5 #define FUNC_GPIO19_U0CTS 3 #define FUNC_GPIO19_GPIO19 2 @@ -264,16 +284,19 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_GPIO19_GPIO19_0 0 #define PERIPHS_IO_MUX_GPIO20_U (DR_REG_IO_MUX_BASE +0x78) +#define IO_MUX_GPIO20_REG PERIPHS_IO_MUX_GPIO20_U #define FUNC_GPIO20_GPIO20 2 #define FUNC_GPIO20_GPIO20_0 0 #define PERIPHS_IO_MUX_GPIO21_U (DR_REG_IO_MUX_BASE +0x7c) +#define IO_MUX_GPIO21_REG PERIPHS_IO_MUX_GPIO21_U #define FUNC_GPIO21_EMAC_TX_EN 5 #define FUNC_GPIO21_GPIO21 2 #define FUNC_GPIO21_VSPIHD 1 #define FUNC_GPIO21_GPIO21_0 0 #define PERIPHS_IO_MUX_GPIO22_U (DR_REG_IO_MUX_BASE +0x80) +#define IO_MUX_GPIO22_REG PERIPHS_IO_MUX_GPIO22_U #define FUNC_GPIO22_EMAC_TXD1 5 #define FUNC_GPIO22_U0RTS 3 #define FUNC_GPIO22_GPIO22 2 @@ -281,59 +304,72 @@ static inline void __attribute__ ((deprecated)) PIN_PULLDWN_EN(uint32_t PIN_NAME #define FUNC_GPIO22_GPIO22_0 0 #define PERIPHS_IO_MUX_GPIO23_U (DR_REG_IO_MUX_BASE +0x8c) +#define IO_MUX_GPIO23_REG PERIPHS_IO_MUX_GPIO23_U #define FUNC_GPIO23_HS1_STROBE 3 #define FUNC_GPIO23_GPIO23 2 #define FUNC_GPIO23_VSPID 1 #define FUNC_GPIO23_GPIO23_0 0 #define PERIPHS_IO_MUX_GPIO24_U (DR_REG_IO_MUX_BASE +0x90) +#define IO_MUX_GPIO24_REG PERIPHS_IO_MUX_GPIO24_U #define FUNC_GPIO24_GPIO24 2 #define FUNC_GPIO24_GPIO24_0 0 #define PERIPHS_IO_MUX_GPIO25_U (DR_REG_IO_MUX_BASE +0x24) +#define IO_MUX_GPIO25_REG PERIPHS_IO_MUX_GPIO25_U #define FUNC_GPIO25_EMAC_RXD0 5 #define FUNC_GPIO25_GPIO25 2 #define FUNC_GPIO25_GPIO25_0 0 #define PERIPHS_IO_MUX_GPIO26_U (DR_REG_IO_MUX_BASE +0x28) +#define IO_MUX_GPIO26_REG PERIPHS_IO_MUX_GPIO26_U #define FUNC_GPIO26_EMAC_RXD1 5 #define FUNC_GPIO26_GPIO26 2 #define FUNC_GPIO26_GPIO26_0 0 #define PERIPHS_IO_MUX_GPIO27_U (DR_REG_IO_MUX_BASE +0x2c) +#define IO_MUX_GPIO27_REG PERIPHS_IO_MUX_GPIO27_U #define FUNC_GPIO27_EMAC_RX_DV 5 #define FUNC_GPIO27_GPIO27 2 #define FUNC_GPIO27_GPIO27_0 0 #define PERIPHS_IO_MUX_GPIO32_U (DR_REG_IO_MUX_BASE +0x1c) +#define IO_MUX_GPIO32_REG PERIPHS_IO_MUX_GPIO32_U #define FUNC_GPIO32_GPIO32 2 #define FUNC_GPIO32_GPIO32_0 0 #define PERIPHS_IO_MUX_GPIO33_U (DR_REG_IO_MUX_BASE +0x20) +#define IO_MUX_GPIO33_REG PERIPHS_IO_MUX_GPIO33_U #define FUNC_GPIO33_GPIO33 2 #define FUNC_GPIO33_GPIO33_0 0 #define PERIPHS_IO_MUX_GPIO34_U (DR_REG_IO_MUX_BASE +0x14) +#define IO_MUX_GPIO34_REG PERIPHS_IO_MUX_GPIO34_U #define FUNC_GPIO34_GPIO34 2 #define FUNC_GPIO34_GPIO34_0 0 #define PERIPHS_IO_MUX_GPIO35_U (DR_REG_IO_MUX_BASE +0x18) +#define IO_MUX_GPIO35_REG PERIPHS_IO_MUX_GPIO35_U #define FUNC_GPIO35_GPIO35 2 #define FUNC_GPIO35_GPIO35_0 0 #define PERIPHS_IO_MUX_GPIO36_U (DR_REG_IO_MUX_BASE +0x04) +#define IO_MUX_GPIO36_REG PERIPHS_IO_MUX_GPIO36_U #define FUNC_GPIO36_GPIO36 2 #define FUNC_GPIO36_GPIO36_0 0 #define PERIPHS_IO_MUX_GPIO37_U (DR_REG_IO_MUX_BASE +0x08) +#define IO_MUX_GPIO37_REG PERIPHS_IO_MUX_GPIO37_U #define FUNC_GPIO37_GPIO37 2 #define FUNC_GPIO37_GPIO37_0 0 #define PERIPHS_IO_MUX_GPIO38_U (DR_REG_IO_MUX_BASE +0x0c) +#define IO_MUX_GPIO38_REG PERIPHS_IO_MUX_GPIO38_U #define FUNC_GPIO38_GPIO38 2 #define FUNC_GPIO38_GPIO38_0 0 #define PERIPHS_IO_MUX_GPIO39_U (DR_REG_IO_MUX_BASE +0x10) +#define IO_MUX_GPIO39_REG PERIPHS_IO_MUX_GPIO39_U #define FUNC_GPIO39_GPIO39 2 #define FUNC_GPIO39_GPIO39_0 0 diff --git a/tools/sdk/include/soc/soc/rtc.h b/tools/sdk/include/soc/soc/rtc.h index fa34caaa8f1..ec9935fd57d 100644 --- a/tools/sdk/include/soc/soc/rtc.h +++ b/tools/sdk/include/soc/soc/rtc.h @@ -185,8 +185,11 @@ bool rtc_clk_32k_enabled(); * must be called one the 32k XTAL oscillator has started up. This function * will initially disable the 32k XTAL oscillator, so it should not be called * when the system is using 32k XTAL as RTC_SLOW_CLK. + * + * @param cycle Number of 32kHz cycles to bootstrap external crystal. + * If 0, no square wave will be used to bootstrap crystal oscillation. */ -void rtc_clk_32k_bootstrap(); +void rtc_clk_32k_bootstrap(uint32_t cycle); /** * @brief Enable or disable 8 MHz internal oscillator @@ -604,7 +607,6 @@ rtc_vddsdio_config_t rtc_vddsdio_get_config(); */ void rtc_vddsdio_set_config(rtc_vddsdio_config_t config); - #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/soc/soc/sens_reg.h b/tools/sdk/include/soc/soc/sens_reg.h index adc9719056f..34834376e89 100644 --- a/tools/sdk/include/soc/soc/sens_reg.h +++ b/tools/sdk/include/soc/soc/sens_reg.h @@ -96,6 +96,7 @@ #define SENS_FORCE_XPD_SAR_M ((SENS_FORCE_XPD_SAR_V)<<(SENS_FORCE_XPD_SAR_S)) #define SENS_FORCE_XPD_SAR_V 0x3 #define SENS_FORCE_XPD_SAR_S 18 +#define SENS_FORCE_XPD_SAR_SW_M (BIT1) #define SENS_FORCE_XPD_SAR_FSM 0 // Use FSM to control power down #define SENS_FORCE_XPD_SAR_PD 2 // Force power down #define SENS_FORCE_XPD_SAR_PU 3 // Force power up diff --git a/tools/sdk/include/soc/soc/sens_struct.h b/tools/sdk/include/soc/soc/sens_struct.h index 825c85b17e7..37069a94560 100644 --- a/tools/sdk/include/soc/soc/sens_struct.h +++ b/tools/sdk/include/soc/soc/sens_struct.h @@ -26,7 +26,7 @@ typedef volatile struct { uint32_t sar1_sample_bit: 2; uint32_t sar1_clk_gated: 1; uint32_t sar1_sample_num: 8; - uint32_t sar1_dig_force: 1; + uint32_t sar1_dig_force: 1; /*1: ADC1 is controlled by the digital controller 0: RTC controller*/ uint32_t sar1_data_inv: 1; uint32_t reserved29: 3; }; @@ -162,9 +162,9 @@ typedef volatile struct { uint32_t meas1_data_sar: 16; uint32_t meas1_done_sar: 1; uint32_t meas1_start_sar: 1; - uint32_t meas1_start_force: 1; + uint32_t meas1_start_force: 1; /*1: ADC1 is controlled by the digital or RTC controller 0: Ulp coprocessor*/ uint32_t sar1_en_pad: 12; - uint32_t sar1_en_pad_force: 1; + uint32_t sar1_en_pad_force: 1; /*1: Data ports are controlled by the digital or RTC controller 0: Ulp coprocessor*/ }; uint32_t val; } sar_meas_start1; @@ -174,8 +174,8 @@ typedef volatile struct { uint32_t touch_xpd_wait: 8; uint32_t touch_out_sel: 1; uint32_t touch_out_1en: 1; - uint32_t xpd_hall_force: 1; - uint32_t hall_phase_force: 1; + uint32_t xpd_hall_force: 1; /*1: Power of hall sensor is controlled by the digital or RTC controller 0: Ulp coprocessor*/ + uint32_t hall_phase_force: 1; /*1: Phase of hall sensor is controlled by the digital or RTC controller 0: Ulp coprocessor*/ uint32_t reserved28: 4; }; uint32_t val; @@ -224,8 +224,8 @@ typedef volatile struct { uint32_t sar2_sample_bit: 2; uint32_t sar2_clk_gated: 1; uint32_t sar2_sample_num: 8; - uint32_t sar2_pwdet_force: 1; - uint32_t sar2_dig_force: 1; + uint32_t sar2_pwdet_force: 1; /*1: ADC2 is controlled by PWDET 0: digital or RTC controller*/ + uint32_t sar2_dig_force: 1; /*1: ADC2 is controlled by the digital controller 0: RTC controller*/ uint32_t sar2_data_inv: 1; uint32_t reserved30: 2; }; @@ -236,9 +236,9 @@ typedef volatile struct { uint32_t meas2_data_sar: 16; uint32_t meas2_done_sar: 1; uint32_t meas2_start_sar: 1; - uint32_t meas2_start_force: 1; + uint32_t meas2_start_force: 1; /*1: ADC2 is controlled by the digital or RTC controller 0: Ulp coprocessor*/ uint32_t sar2_en_pad: 12; - uint32_t sar2_en_pad_force: 1; + uint32_t sar2_en_pad_force: 1; /*1: Data ports are controlled by the digital or RTC controller 0: Ulp coprocessor*/ }; uint32_t val; } sar_meas_start2; diff --git a/tools/sdk/include/soc/soc/soc.h b/tools/sdk/include/soc/soc/soc.h index 7c7517d463a..660abbdb3fc 100644 --- a/tools/sdk/include/soc/soc/soc.h +++ b/tools/sdk/include/soc/soc/soc.h @@ -308,7 +308,6 @@ #define SOC_MEM_INTERNAL_LOW 0x3FF90000 #define SOC_MEM_INTERNAL_HIGH 0x400C2000 - //Interrupt hardware source table //This table is decided by hardware, don't touch this. #define ETS_WIFI_MAC_INTR_SOURCE 0/**< interrupt of WiFi MAC, level*/ diff --git a/tools/sdk/include/soc/soc/soc_memory_layout.h b/tools/sdk/include/soc/soc/soc_memory_layout.h index 1c1415e3dc3..6273b1dbc32 100644 --- a/tools/sdk/include/soc/soc/soc_memory_layout.h +++ b/tools/sdk/include/soc/soc/soc_memory_layout.h @@ -89,3 +89,8 @@ inline static bool IRAM_ATTR esp_ptr_internal(const void *p) { r |= ((intptr_t)p >= SOC_RTC_DATA_LOW && (intptr_t)p < SOC_RTC_DATA_HIGH); return r; } + + +inline static bool IRAM_ATTR esp_ptr_external_ram(const void *p) { + return ((intptr_t)p >= SOC_EXTRAM_DATA_LOW && (intptr_t)p < SOC_EXTRAM_DATA_HIGH); +} diff --git a/tools/sdk/include/spi_flash/esp_spi_flash.h b/tools/sdk/include/spi_flash/esp_spi_flash.h index 8dee9d341ea..9caa47e4085 100644 --- a/tools/sdk/include/spi_flash/esp_spi_flash.h +++ b/tools/sdk/include/spi_flash/esp_spi_flash.h @@ -77,12 +77,16 @@ esp_err_t spi_flash_erase_range(size_t start_address, size_t size); /** * @brief Write data to Flash. * - * @note If source address is in DROM, this function will return - * ESP_ERR_INVALID_ARG. + * @note For fastest write performance, write a 4 byte aligned size at a + * 4 byte aligned offset in flash from a source buffer in DRAM. Varying any of + * these parameters will still work, but will be slower due to buffering. * - * @param dest_addr destination address in Flash. Must be a multiple of 4 bytes. - * @param src pointer to the source buffer. - * @param size length of data, in bytes. Must be a multiple of 4 bytes. + * @note Writing more than 8KB at a time will be split into multiple + * write operations to avoid disrupting other tasks in the system. + * + * @param dest_addr Destination address in Flash. + * @param src Pointer to the source buffer. + * @param size Length of data, in bytes. * * @return esp_err_t */ @@ -103,9 +107,9 @@ esp_err_t spi_flash_write(size_t dest_addr, const void *src, size_t size); * absolute best performance, both dest_addr and size arguments should * be multiples of 32 bytes. * - * @param dest_addr destination address in Flash. Must be a multiple of 16 bytes. - * @param src pointer to the source buffer. - * @param size length of data, in bytes. Must be a multiple of 16 bytes. + * @param dest_addr Destination address in Flash. Must be a multiple of 16 bytes. + * @param src Pointer to the source buffer. + * @param size Length of data, in bytes. Must be a multiple of 16 bytes. * * @return esp_err_t */ @@ -114,10 +118,22 @@ esp_err_t spi_flash_write_encrypted(size_t dest_addr, const void *src, size_t si /** * @brief Read data from Flash. * + * @note For fastest read performance, all parameters should be + * 4 byte aligned. If source address and read size are not 4 byte + * aligned, read may be split into multiple flash operations. If + * destination buffer is not 4 byte aligned, a temporary buffer will + * be allocated on the stack. + * + * @note Reading more than 16KB of data at a time will be split + * into multiple reads to avoid disruption to other tasks in the + * system. Consider using spi_flash_mmap() to read large amounts + * of data. + * * @param src_addr source address of the data in Flash. * @param dest pointer to the destination buffer * @param size length of data * + * * @return esp_err_t */ esp_err_t spi_flash_read(size_t src_addr, void *dest, size_t size); @@ -155,19 +171,20 @@ typedef uint32_t spi_flash_mmap_handle_t; /** * @brief Map region of flash memory into data or instruction address space * - * This function allocates sufficient number of 64k MMU pages and configures - * them to map request region of flash memory into data address space or into - * instruction address space. It may reuse MMU pages which already provide - * required mapping. As with any allocator, there is possibility of fragmentation - * of address space if mmap/munmap are heavily used. To troubleshoot issues with - * page allocation, use spi_flash_mmap_dump function. + * This function allocates sufficient number of 64kB MMU pages and configures + * them to map the requested region of flash memory into the address space. + * It may reuse MMU pages which already provide the required mapping. + * + * As with any allocator, if mmap/munmap are heavily used then the address space + * may become fragmented. To troubleshoot issues with page allocation, use + * spi_flash_mmap_dump() function. * * @param src_addr Physical address in flash where requested region starts. * This address *must* be aligned to 64kB boundary - * (SPI_FLASH_MMU_PAGE_SIZE). - * @param size Size of region which has to be mapped. This size will be rounded - * up to a 64k boundary. - * @param memory Memory space where the region should be mapped + * (SPI_FLASH_MMU_PAGE_SIZE) + * @param size Size of region to be mapped. This size will be rounded + * up to a 64kB boundary + * @param memory Address space where the region should be mapped (data or instruction) * @param out_ptr Output, pointer to the mapped memory region * @param out_handle Output, handle which should be used for spi_flash_munmap call * @@ -179,17 +196,16 @@ esp_err_t spi_flash_mmap(size_t src_addr, size_t size, spi_flash_mmap_memory_t m /** * @brief Map sequences of pages of flash memory into data or instruction address space * - * This function allocates sufficient number of 64k MMU pages and configures - * them to map the indicated pages of flash memory contiguously into data address - * space or into instruction address space. In this respect, it works in a similar - * way as spi_flash_mmap but it allows mapping a (maybe non-contiguous) set of pages - * into a contiguous region of memory. + * This function allocates sufficient number of 64kB MMU pages and configures + * them to map the indicated pages of flash memory contiguously into address space. + * In this respect, it works in a similar way as spi_flash_mmap() but it allows mapping + * a (maybe non-contiguous) set of pages into a contiguous region of memory. * - * @param pages An array of numbers indicating the 64K pages in flash to be mapped - * contiguously into memory. These indicate the indexes of the 64K pages, + * @param pages An array of numbers indicating the 64kB pages in flash to be mapped + * contiguously into memory. These indicate the indexes of the 64kB pages, * not the byte-size addresses as used in other functions. - * @param pagecount Size of the pages array - * @param memory Memory space where the region should be mapped + * @param pagecount Number of entries in the pages array + * @param memory Address space where the region should be mapped (instruction or data) * @param out_ptr Output, pointer to the mapped memory region * @param out_handle Output, handle which should be used for spi_flash_munmap call * @@ -220,13 +236,28 @@ void spi_flash_munmap(spi_flash_mmap_handle_t handle); */ void spi_flash_mmap_dump(); +/** + * @brief get free pages number which can be mmap + * + * This function will return free page number of the mmu table which can mmap, + * when you want to call spi_flash_mmap to mmap an ranger of flash data to Dcache or Icache + * memmory region, maybe the size of MMU table will exceed,so if you are not sure the + * size need mmap is ok, can call the interface and watch how many MMU table page can be + * mmaped. + * + * @param memory memmory type of MMU table free page + * + * @return number of free pages which can be mmaped + */ +uint32_t spi_flash_mmap_get_free_pages(spi_flash_mmap_memory_t memory); + #define SPI_FLASH_CACHE2PHYS_FAIL UINT32_MAX /*drom0_0_seg .flash.text : diff --git a/tools/sdk/lib/libapp_trace.a b/tools/sdk/lib/libapp_trace.a index 4e0a660214d..8c43cda6262 100644 Binary files a/tools/sdk/lib/libapp_trace.a and b/tools/sdk/lib/libapp_trace.a differ diff --git a/tools/sdk/lib/libapp_update.a b/tools/sdk/lib/libapp_update.a index f46914f2bcb..d632804c487 100644 Binary files a/tools/sdk/lib/libapp_update.a and b/tools/sdk/lib/libapp_update.a differ diff --git a/tools/sdk/lib/libbootloader_support.a b/tools/sdk/lib/libbootloader_support.a index 4ba1836e837..c8bba3b6e5e 100644 Binary files a/tools/sdk/lib/libbootloader_support.a and b/tools/sdk/lib/libbootloader_support.a differ diff --git a/tools/sdk/lib/libbt.a b/tools/sdk/lib/libbt.a index 47aa93398a9..e322bcd3870 100644 Binary files a/tools/sdk/lib/libbt.a and b/tools/sdk/lib/libbt.a differ diff --git a/tools/sdk/lib/libbtdm_app.a b/tools/sdk/lib/libbtdm_app.a index dcd39cf7864..10b2a07b5ee 100755 Binary files a/tools/sdk/lib/libbtdm_app.a and b/tools/sdk/lib/libbtdm_app.a differ diff --git a/tools/sdk/lib/libcoap.a b/tools/sdk/lib/libcoap.a index fe7c3c1954b..f5c70b96a2f 100644 Binary files a/tools/sdk/lib/libcoap.a and b/tools/sdk/lib/libcoap.a differ diff --git a/tools/sdk/lib/libcoexist.a b/tools/sdk/lib/libcoexist.a index ae6dd2e007c..79f982b753f 100644 Binary files a/tools/sdk/lib/libcoexist.a and b/tools/sdk/lib/libcoexist.a differ diff --git a/tools/sdk/lib/libconsole.a b/tools/sdk/lib/libconsole.a index db306970315..aca2c9708e8 100644 Binary files a/tools/sdk/lib/libconsole.a and b/tools/sdk/lib/libconsole.a differ diff --git a/tools/sdk/lib/libcore.a b/tools/sdk/lib/libcore.a index eb422ca05cc..a53bda08875 100644 Binary files a/tools/sdk/lib/libcore.a and b/tools/sdk/lib/libcore.a differ diff --git a/tools/sdk/lib/libcxx.a b/tools/sdk/lib/libcxx.a index 47f2e8b06d9..3c891c89cd0 100644 Binary files a/tools/sdk/lib/libcxx.a and b/tools/sdk/lib/libcxx.a differ diff --git a/tools/sdk/lib/libdriver.a b/tools/sdk/lib/libdriver.a index c5a92ccf2c1..20f78957237 100644 Binary files a/tools/sdk/lib/libdriver.a and b/tools/sdk/lib/libdriver.a differ diff --git a/tools/sdk/lib/libesp32.a b/tools/sdk/lib/libesp32.a index 85489a5a622..f153efa5c5f 100644 Binary files a/tools/sdk/lib/libesp32.a and b/tools/sdk/lib/libesp32.a differ diff --git a/tools/sdk/lib/libesp_adc_cal.a b/tools/sdk/lib/libesp_adc_cal.a index c2a90f3f362..de02653cf4d 100644 Binary files a/tools/sdk/lib/libesp_adc_cal.a and b/tools/sdk/lib/libesp_adc_cal.a differ diff --git a/tools/sdk/lib/libespnow.a b/tools/sdk/lib/libespnow.a index e493e8ff87c..63159396934 100644 Binary files a/tools/sdk/lib/libespnow.a and b/tools/sdk/lib/libespnow.a differ diff --git a/tools/sdk/lib/libethernet.a b/tools/sdk/lib/libethernet.a index 6fe908d5db9..93a62f75589 100644 Binary files a/tools/sdk/lib/libethernet.a and b/tools/sdk/lib/libethernet.a differ diff --git a/tools/sdk/lib/libexpat.a b/tools/sdk/lib/libexpat.a index 891639bc2d5..9fdb077ab79 100644 Binary files a/tools/sdk/lib/libexpat.a and b/tools/sdk/lib/libexpat.a differ diff --git a/tools/sdk/lib/libfatfs.a b/tools/sdk/lib/libfatfs.a index 9cf48b25a38..83d05ceecab 100644 Binary files a/tools/sdk/lib/libfatfs.a and b/tools/sdk/lib/libfatfs.a differ diff --git a/tools/sdk/lib/libfreertos.a b/tools/sdk/lib/libfreertos.a index e164855a755..d3776131751 100644 Binary files a/tools/sdk/lib/libfreertos.a and b/tools/sdk/lib/libfreertos.a differ diff --git a/tools/sdk/lib/libheap.a b/tools/sdk/lib/libheap.a index a1d55f831ce..0a08bfc242c 100644 Binary files a/tools/sdk/lib/libheap.a and b/tools/sdk/lib/libheap.a differ diff --git a/tools/sdk/lib/libjsmn.a b/tools/sdk/lib/libjsmn.a index 3f2c9cbd27b..73063f97f2f 100644 Binary files a/tools/sdk/lib/libjsmn.a and b/tools/sdk/lib/libjsmn.a differ diff --git a/tools/sdk/lib/libjson.a b/tools/sdk/lib/libjson.a index 2e2ab6718d4..b12648d8c28 100644 Binary files a/tools/sdk/lib/libjson.a and b/tools/sdk/lib/libjson.a differ diff --git a/tools/sdk/lib/liblog.a b/tools/sdk/lib/liblog.a index 25372e128d1..fe3b04dc91e 100644 Binary files a/tools/sdk/lib/liblog.a and b/tools/sdk/lib/liblog.a differ diff --git a/tools/sdk/lib/liblwip.a b/tools/sdk/lib/liblwip.a index 3c5a76557ca..82d25a51ee3 100644 Binary files a/tools/sdk/lib/liblwip.a and b/tools/sdk/lib/liblwip.a differ diff --git a/tools/sdk/lib/libmbedtls.a b/tools/sdk/lib/libmbedtls.a index dbb6941f551..267b744fa1d 100644 Binary files a/tools/sdk/lib/libmbedtls.a and b/tools/sdk/lib/libmbedtls.a differ diff --git a/tools/sdk/lib/libmdns.a b/tools/sdk/lib/libmdns.a index 9366fba3f88..8ee4b2aea1b 100644 Binary files a/tools/sdk/lib/libmdns.a and b/tools/sdk/lib/libmdns.a differ diff --git a/tools/sdk/lib/libmesh.a b/tools/sdk/lib/libmesh.a new file mode 100644 index 00000000000..4025450f1a2 Binary files /dev/null and b/tools/sdk/lib/libmesh.a differ diff --git a/tools/sdk/lib/libmicro-ecc.a b/tools/sdk/lib/libmicro-ecc.a index 5cf419baf1b..9971df7edb0 100644 Binary files a/tools/sdk/lib/libmicro-ecc.a and b/tools/sdk/lib/libmicro-ecc.a differ diff --git a/tools/sdk/lib/libnet80211.a b/tools/sdk/lib/libnet80211.a index bbe5fa2f0ec..9c5b41c2533 100644 Binary files a/tools/sdk/lib/libnet80211.a and b/tools/sdk/lib/libnet80211.a differ diff --git a/tools/sdk/lib/libnewlib.a b/tools/sdk/lib/libnewlib.a index 87859426055..f8b8fb20a73 100644 Binary files a/tools/sdk/lib/libnewlib.a and b/tools/sdk/lib/libnewlib.a differ diff --git a/tools/sdk/lib/libnghttp.a b/tools/sdk/lib/libnghttp.a index 0400061e483..4e35ba2f0ce 100644 Binary files a/tools/sdk/lib/libnghttp.a and b/tools/sdk/lib/libnghttp.a differ diff --git a/tools/sdk/lib/libnvs_flash.a b/tools/sdk/lib/libnvs_flash.a index eb94e5f1279..a872304a439 100644 Binary files a/tools/sdk/lib/libnvs_flash.a and b/tools/sdk/lib/libnvs_flash.a differ diff --git a/tools/sdk/lib/libopenssl.a b/tools/sdk/lib/libopenssl.a index 4b2409c94d9..d4acb357df5 100644 Binary files a/tools/sdk/lib/libopenssl.a and b/tools/sdk/lib/libopenssl.a differ diff --git a/tools/sdk/lib/libphy.a b/tools/sdk/lib/libphy.a index a81ce42a2c3..df8225423fb 100644 Binary files a/tools/sdk/lib/libphy.a and b/tools/sdk/lib/libphy.a differ diff --git a/tools/sdk/lib/libpp.a b/tools/sdk/lib/libpp.a index 8b7783c9e90..f0d59497fd6 100644 Binary files a/tools/sdk/lib/libpp.a and b/tools/sdk/lib/libpp.a differ diff --git a/tools/sdk/lib/libpthread.a b/tools/sdk/lib/libpthread.a index 8e7e3f55574..9aa172a4397 100644 Binary files a/tools/sdk/lib/libpthread.a and b/tools/sdk/lib/libpthread.a differ diff --git a/tools/sdk/lib/librtc.a b/tools/sdk/lib/librtc.a old mode 100644 new mode 100755 index b1c0a7454db..3f019f58f6d Binary files a/tools/sdk/lib/librtc.a and b/tools/sdk/lib/librtc.a differ diff --git a/tools/sdk/lib/libsdmmc.a b/tools/sdk/lib/libsdmmc.a index a483ffc649f..e6be972d9b9 100644 Binary files a/tools/sdk/lib/libsdmmc.a and b/tools/sdk/lib/libsdmmc.a differ diff --git a/tools/sdk/lib/libsmartconfig.a b/tools/sdk/lib/libsmartconfig.a index 1d9be7eb536..67aec8d4836 100644 Binary files a/tools/sdk/lib/libsmartconfig.a and b/tools/sdk/lib/libsmartconfig.a differ diff --git a/tools/sdk/lib/libsoc.a b/tools/sdk/lib/libsoc.a index f0fcdde8d2a..68128b52867 100644 Binary files a/tools/sdk/lib/libsoc.a and b/tools/sdk/lib/libsoc.a differ diff --git a/tools/sdk/lib/libspi_flash.a b/tools/sdk/lib/libspi_flash.a index 9c663b1f49b..a2e04471d75 100644 Binary files a/tools/sdk/lib/libspi_flash.a and b/tools/sdk/lib/libspi_flash.a differ diff --git a/tools/sdk/lib/libspiffs.a b/tools/sdk/lib/libspiffs.a index ff0bb884452..e4397309a78 100644 Binary files a/tools/sdk/lib/libspiffs.a and b/tools/sdk/lib/libspiffs.a differ diff --git a/tools/sdk/lib/libtcpip_adapter.a b/tools/sdk/lib/libtcpip_adapter.a index eef9a4dd49a..0208c985688 100644 Binary files a/tools/sdk/lib/libtcpip_adapter.a and b/tools/sdk/lib/libtcpip_adapter.a differ diff --git a/tools/sdk/lib/libulp.a b/tools/sdk/lib/libulp.a index 7221e560fda..96705189db7 100644 Binary files a/tools/sdk/lib/libulp.a and b/tools/sdk/lib/libulp.a differ diff --git a/tools/sdk/lib/libvfs.a b/tools/sdk/lib/libvfs.a index ad6aa5518f5..53b6c12d42c 100644 Binary files a/tools/sdk/lib/libvfs.a and b/tools/sdk/lib/libvfs.a differ diff --git a/tools/sdk/lib/libwear_levelling.a b/tools/sdk/lib/libwear_levelling.a index 1d88fafffed..6953e4fbec4 100644 Binary files a/tools/sdk/lib/libwear_levelling.a and b/tools/sdk/lib/libwear_levelling.a differ diff --git a/tools/sdk/lib/libwpa.a b/tools/sdk/lib/libwpa.a index 6379272d1b4..7fa1105c077 100644 Binary files a/tools/sdk/lib/libwpa.a and b/tools/sdk/lib/libwpa.a differ diff --git a/tools/sdk/lib/libwpa2.a b/tools/sdk/lib/libwpa2.a index 04aa7e937bf..29e9277d9a1 100644 Binary files a/tools/sdk/lib/libwpa2.a and b/tools/sdk/lib/libwpa2.a differ diff --git a/tools/sdk/lib/libwpa_supplicant.a b/tools/sdk/lib/libwpa_supplicant.a index b850776e712..d61cebc9ad8 100644 Binary files a/tools/sdk/lib/libwpa_supplicant.a and b/tools/sdk/lib/libwpa_supplicant.a differ diff --git a/tools/sdk/lib/libwps.a b/tools/sdk/lib/libwps.a index 6a3f9aa9c56..4d153055242 100644 Binary files a/tools/sdk/lib/libwps.a and b/tools/sdk/lib/libwps.a differ diff --git a/tools/sdk/lib/libxtensa-debug-module.a b/tools/sdk/lib/libxtensa-debug-module.a index b7fa7aa6ceb..aac19ab1ae9 100644 Binary files a/tools/sdk/lib/libxtensa-debug-module.a and b/tools/sdk/lib/libxtensa-debug-module.a differ diff --git a/tools/sdk/sdkconfig b/tools/sdk/sdkconfig index 8f879fa8c3d..b2ca2f61adb 100644 --- a/tools/sdk/sdkconfig +++ b/tools/sdk/sdkconfig @@ -20,7 +20,8 @@ CONFIG_LOG_BOOTLOADER_LEVEL_INFO= CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG= CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE= CONFIG_LOG_BOOTLOADER_LEVEL=0 -CONFIG_BOOTLOADER_VDDSDIO_BOOST=y +CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V= +CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y # # Security features @@ -83,6 +84,7 @@ CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET=0x10000 CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" CONFIG_APP_OFFSET=0x10000 +CONFIG_PARTITION_TABLE_MD5=y # # Compiler options @@ -153,15 +155,28 @@ CONFIG_BLUEDROID_PINNED_TO_CORE_1= CONFIG_BLUEDROID_PINNED_TO_CORE=0 CONFIG_BTC_TASK_STACK_SIZE=8192 CONFIG_BLUEDROID_MEM_DEBUG= -CONFIG_CLASSIC_BT_ENABLED= +CONFIG_CLASSIC_BT_ENABLED=y +CONFIG_A2DP_ENABLE=y +CONFIG_A2DP_SINK_ENABLE=y +CONFIG_A2DP_SRC_ENABLE= +CONFIG_A2DP_SINK_TASK_STACK_SIZE=2048 +CONFIG_BT_SPP_ENABLED=y CONFIG_GATTS_ENABLE=y CONFIG_GATTC_ENABLE=y CONFIG_BLE_SMP_ENABLE=y CONFIG_BT_STACK_NO_LOG= CONFIG_BT_ACL_CONNECTIONS=4 +CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST= +CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=y CONFIG_SMP_ENABLE=y CONFIG_BT_RESERVE_DRAM=0x10000 +# +# ADC configuration +# +CONFIG_ADC_FORCE_XPD_FSM= +CONFIG_ADC2_DISABLE_DAC=y + # # ESP32-specific # @@ -169,7 +184,6 @@ CONFIG_ESP32_DEFAULT_CPU_FREQ_80= CONFIG_ESP32_DEFAULT_CPU_FREQ_160= CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240 -CONFIG_MEMMAP_SMP=y CONFIG_SPIRAM_SUPPORT= CONFIG_MEMMAP_TRACEMEM= CONFIG_MEMMAP_TRACEMEM_TWOBANKS= @@ -231,6 +245,7 @@ CONFIG_ESP32_TIME_SYSCALL_USE_NONE= CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL= CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 +CONFIG_ESP32_RTC_XTAL_BOOTSTRAP_CYCLES=100 CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 CONFIG_ESP32_XTAL_FREQ_40= CONFIG_ESP32_XTAL_FREQ_26= @@ -239,11 +254,16 @@ CONFIG_ESP32_XTAL_FREQ=0 CONFIG_DISABLE_BASIC_ROM_CONSOLE= CONFIG_ESP_TIMER_PROFILING= CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS= +CONFIG_ESP_ERR_TO_NAME_LOOKUP=y # # Wi-Fi # CONFIG_SW_COEXIST_ENABLE=y +CONFIG_SW_COEXIST_PREFERENCE_WIFI= +CONFIG_SW_COEXIST_PREFERENCE_BT= +CONFIG_SW_COEXIST_PREFERENCE_BALANCE=y +CONFIG_SW_COEXIST_PREFERENCE_VALUE=2 CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=0 CONFIG_ESP32_WIFI_STATIC_TX_BUFFER= @@ -252,8 +272,6 @@ CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y CONFIG_ESP32_WIFI_TX_BA_WIN=6 -CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y -CONFIG_ESP32_WIFI_RX_BA_WIN=6 CONFIG_ESP32_WIFI_NVS_ENABLED=y # @@ -269,6 +287,13 @@ CONFIG_ESP32_PHY_MAX_TX_POWER=20 # CONFIG_PM_ENABLE= +# +# ADC-Calibration +# +CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y +CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y +CONFIG_ADC_CAL_LUT_ENABLE=y + # # Ethernet # @@ -307,6 +332,9 @@ CONFIG_FATFS_LFN_NONE= CONFIG_FATFS_LFN_HEAP= CONFIG_FATFS_LFN_STACK=y CONFIG_FATFS_MAX_LFN=255 +CONFIG_FATFS_API_ENCODING_ANSI_OEM=y +CONFIG_FATFS_API_ENCODING_UTF_16= +CONFIG_FATFS_API_ENCODING_UTF_8= CONFIG_FATFS_FS_LOCK=0 CONFIG_FATFS_TIMEOUT_MS=10000 CONFIG_FATFS_PER_FILE_CACHE=y @@ -348,6 +376,7 @@ CONFIG_HEAP_POISONING_DISABLED= CONFIG_HEAP_POISONING_LIGHT=y CONFIG_HEAP_POISONING_COMPREHENSIVE= CONFIG_HEAP_TRACING= +CONFIG_HEAP_TASK_TRACKING= # # libsodium @@ -370,6 +399,7 @@ CONFIG_LOG_COLORS= # LWIP # CONFIG_L2_TO_L3_COPY= +CONFIG_LWIP_IRAM_OPTIMIZATION= CONFIG_LWIP_MAX_SOCKETS=10 CONFIG_LWIP_SO_REUSE=y CONFIG_LWIP_SO_REUSE_RXTOALL=y @@ -541,6 +571,7 @@ CONFIG_SPIFFS_CACHE_STATS= CONFIG_SPIFFS_PAGE_CHECK=y CONFIG_SPIFFS_GC_MAX_RUNS=10 CONFIG_SPIFFS_GC_STATS= +CONFIG_SPIFFS_PAGE_SIZE=256 CONFIG_SPIFFS_OBJ_NAME_LEN=32 CONFIG_SPIFFS_USE_MAGIC=y CONFIG_SPIFFS_USE_MAGIC_LENGTH=y