Update IDF, fix SS definition, add custom partitions and debug level selection (#174)
* Add build time partitions compilation * Fix wrong definition of SS pin * Add support for core debug level selection * update idf libs
This commit is contained in:
parent
ee8149e207
commit
d02c1c786e
66
boards.txt
66
boards.txt
@ -1,7 +1,9 @@
|
||||
menu.UploadSpeed=Upload Speed
|
||||
menu.FlashFreq=Flash Frequency
|
||||
menu.DebugLevel=Core Debug Level
|
||||
|
||||
##############################################################
|
||||
|
||||
esp32.name=ESP32 Dev Module
|
||||
|
||||
esp32.upload.tool=esptool
|
||||
@ -41,7 +43,62 @@ esp32.menu.UploadSpeed.460800.upload.speed=460800
|
||||
esp32.menu.UploadSpeed.512000.windows=512000
|
||||
esp32.menu.UploadSpeed.512000.upload.speed=512000
|
||||
|
||||
esp32.menu.DebugLevel.none=None
|
||||
esp32.menu.DebugLevel.none.build.code_debug=0
|
||||
esp32.menu.DebugLevel.error=Error
|
||||
esp32.menu.DebugLevel.error.build.code_debug=1
|
||||
esp32.menu.DebugLevel.warn=Warn
|
||||
esp32.menu.DebugLevel.warn.build.code_debug=2
|
||||
esp32.menu.DebugLevel.info=Info
|
||||
esp32.menu.DebugLevel.info.build.code_debug=3
|
||||
esp32.menu.DebugLevel.debug=Debug
|
||||
esp32.menu.DebugLevel.debug.build.code_debug=4
|
||||
esp32.menu.DebugLevel.verbose=Verbose
|
||||
esp32.menu.DebugLevel.verbose.build.code_debug=5
|
||||
|
||||
##############################################################
|
||||
|
||||
esp32thing.name=SparkFun ESP32 Thing
|
||||
|
||||
esp32thing.upload.tool=esptool
|
||||
esp32thing.upload.maximum_size=1044464
|
||||
esp32thing.upload.maximum_data_size=294912
|
||||
esp32thing.upload.wait_for_upload_port=true
|
||||
|
||||
esp32thing.serial.disableDTR=true
|
||||
esp32thing.serial.disableRTS=true
|
||||
|
||||
esp32thing.build.mcu=esp32
|
||||
esp32thing.build.core=esp32
|
||||
esp32thing.build.variant=esp32thing
|
||||
esp32thing.build.board=ESP32_THING
|
||||
|
||||
esp32thing.build.f_cpu=240000000L
|
||||
esp32thing.build.flash_mode=dio
|
||||
esp32thing.build.flash_size=4MB
|
||||
|
||||
esp32thing.menu.FlashFreq.80=80MHz
|
||||
esp32thing.menu.FlashFreq.80.build.flash_freq=80m
|
||||
esp32thing.menu.FlashFreq.40=40MHz
|
||||
esp32thing.menu.FlashFreq.40.build.flash_freq=40m
|
||||
|
||||
esp32thing.menu.UploadSpeed.921600=921600
|
||||
esp32thing.menu.UploadSpeed.921600.upload.speed=921600
|
||||
esp32thing.menu.UploadSpeed.115200=115200
|
||||
esp32thing.menu.UploadSpeed.115200.upload.speed=115200
|
||||
esp32thing.menu.UploadSpeed.256000.windows=256000
|
||||
esp32thing.menu.UploadSpeed.256000.upload.speed=256000
|
||||
esp32thing.menu.UploadSpeed.230400.windows.upload.speed=256000
|
||||
esp32thing.menu.UploadSpeed.230400=230400
|
||||
esp32thing.menu.UploadSpeed.230400.upload.speed=230400
|
||||
esp32thing.menu.UploadSpeed.460800.linux=460800
|
||||
esp32thing.menu.UploadSpeed.460800.macosx=460800
|
||||
esp32thing.menu.UploadSpeed.460800.upload.speed=460800
|
||||
esp32thing.menu.UploadSpeed.512000.windows=512000
|
||||
esp32thing.menu.UploadSpeed.512000.upload.speed=512000
|
||||
|
||||
##############################################################
|
||||
|
||||
esp320.name=Electronic SweetPeas - ESP320
|
||||
|
||||
esp320.upload.tool=esptool
|
||||
@ -82,6 +139,7 @@ esp320.menu.UploadSpeed.512000.windows=512000
|
||||
esp320.menu.UploadSpeed.512000.upload.speed=512000
|
||||
|
||||
##############################################################
|
||||
|
||||
nano32.name=Nano32
|
||||
|
||||
nano32.upload.tool=esptool
|
||||
@ -122,6 +180,7 @@ nano32.menu.UploadSpeed.512000.windows=512000
|
||||
nano32.menu.UploadSpeed.512000.upload.speed=512000
|
||||
|
||||
##############################################################
|
||||
|
||||
lolin32.name=WEMOS LoLin32
|
||||
|
||||
lolin32.upload.tool=esptool
|
||||
@ -162,6 +221,7 @@ lolin32.menu.UploadSpeed.512000.windows=512000
|
||||
lolin32.menu.UploadSpeed.512000.upload.speed=512000
|
||||
|
||||
##############################################################
|
||||
|
||||
espea32.name=ESPea32
|
||||
|
||||
espea32.upload.tool=esptool
|
||||
@ -202,6 +262,7 @@ espea32.menu.UploadSpeed.512000.windows=512000
|
||||
espea32.menu.UploadSpeed.512000.upload.speed=512000
|
||||
|
||||
##############################################################
|
||||
|
||||
quantum.name=Noduino Quantum
|
||||
|
||||
quantum.upload.tool=esptool
|
||||
@ -242,6 +303,7 @@ quantum.menu.UploadSpeed.512000.windows=512000
|
||||
quantum.menu.UploadSpeed.512000.upload.speed=512000
|
||||
|
||||
##############################################################
|
||||
|
||||
node32s.name=Node32s
|
||||
|
||||
node32s.upload.tool=esptool
|
||||
@ -280,7 +342,9 @@ node32s.menu.UploadSpeed.460800.macosx=460800
|
||||
node32s.menu.UploadSpeed.460800.upload.speed=460800
|
||||
node32s.menu.UploadSpeed.512000.windows=512000
|
||||
node32s.menu.UploadSpeed.512000.upload.speed=512000
|
||||
|
||||
##############################################################
|
||||
|
||||
hornbill32dev.name=Hornbill ESP32 Dev
|
||||
|
||||
hornbill32dev.upload.tool=esptool
|
||||
@ -318,7 +382,9 @@ hornbill32dev.menu.UploadSpeed.460800.macosx=460800
|
||||
hornbill32dev.menu.UploadSpeed.460800.upload.speed=460800
|
||||
hornbill32dev.menu.UploadSpeed.512000.windows=512000
|
||||
hornbill32dev.menu.UploadSpeed.512000.upload.speed=512000
|
||||
|
||||
##############################################################
|
||||
|
||||
hornbill32minima.name=Hornbill ESP32 Minima
|
||||
|
||||
hornbill32minima.upload.tool=esptool
|
||||
|
@ -32,6 +32,12 @@ extern "C"
|
||||
#define CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL ARDUHAL_LOG_LEVEL_NONE
|
||||
#endif
|
||||
|
||||
#ifndef CORE_DEBUG_LEVEL
|
||||
#define ARDUHAL_LOG_LEVEL CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL
|
||||
#else
|
||||
#define ARDUHAL_LOG_LEVEL CORE_DEBUG_LEVEL
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ARDUHAL_LOG_COLORS
|
||||
#define CONFIG_ARDUHAL_LOG_COLORS 0
|
||||
#endif
|
||||
@ -71,31 +77,31 @@ int log_printf(const char *fmt, ...);
|
||||
#define ARDUHAL_SHORT_LOG_FORMAT(letter, format) ARDUHAL_LOG_COLOR_ ## letter format ARDUHAL_LOG_RESET_COLOR "\r\n"
|
||||
#define ARDUHAL_LOG_FORMAT(letter, format) ARDUHAL_LOG_COLOR_ ## letter "[" #letter "][%s:%u] %s(): " format ARDUHAL_LOG_RESET_COLOR "\r\n", pathToFileName(__FILE__), __LINE__, __FUNCTION__
|
||||
|
||||
#if CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE
|
||||
#define log_v(format, ...) log_printf(ARDUHAL_LOG_FORMAT(V, format), ##__VA_ARGS__)
|
||||
#else
|
||||
#define log_v(format, ...)
|
||||
#endif
|
||||
|
||||
#if CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
||||
#define log_d(format, ...) log_printf(ARDUHAL_LOG_FORMAT(D, format), ##__VA_ARGS__)
|
||||
#else
|
||||
#define log_d(format, ...)
|
||||
#endif
|
||||
|
||||
#if CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
||||
#define log_i(format, ...) log_printf(ARDUHAL_LOG_FORMAT(I, format), ##__VA_ARGS__)
|
||||
#else
|
||||
#define log_i(format, ...)
|
||||
#endif
|
||||
|
||||
#if CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL >= ARDUHAL_LOG_LEVEL_WARN
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_WARN
|
||||
#define log_w(format, ...) log_printf(ARDUHAL_LOG_FORMAT(W, format), ##__VA_ARGS__)
|
||||
#else
|
||||
#define log_w(format, ...)
|
||||
#endif
|
||||
|
||||
#if CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL >= ARDUHAL_LOG_LEVEL_ERROR
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_ERROR
|
||||
#define log_e(format, ...) log_printf(ARDUHAL_LOG_FORMAT(E, format), ##__VA_ARGS__)
|
||||
#else
|
||||
#define log_e(format, ...)
|
||||
|
@ -166,7 +166,7 @@ void WiFiGenericClass::removeEvent(WiFiEventCb cbEvent, system_event_id_t event)
|
||||
* callback for WiFi events
|
||||
* @param arg
|
||||
*/
|
||||
#if CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
||||
const char * system_event_names[] = { "WIFI_READY", "SCAN_DONE", "STA_START", "STA_STOP", "STA_CONNECTED", "STA_DISCONNECTED", "STA_AUTHMODE_CHANGE", "STA_GOT_IP", "STA_WPS_ER_SUCCESS", "STA_WPS_ER_FAILED", "STA_WPS_ER_TIMEOUT", "STA_WPS_ER_PIN", "AP_START", "AP_STOP", "AP_STACONNECTED", "AP_STADISCONNECTED", "AP_PROBEREQRECVED", "AP_STA_GOT_IP6", "ETH_START", "ETH_STOP", "ETH_CONNECTED", "ETH_DISCONNECTED", "ETH_GOT_IP", "MAX"};
|
||||
const char * system_event_reasons[] = { "UNSPECIFIED", "AUTH_EXPIRE", "AUTH_LEAVE", "ASSOC_EXPIRE", "ASSOC_TOOMANY", "NOT_AUTHED", "NOT_ASSOCED", "ASSOC_LEAVE", "ASSOC_NOT_AUTHED", "DISASSOC_PWRCAP_BAD", "DISASSOC_SUPCHAN_BAD", "IE_INVALID", "MIC_FAILURE", "4WAY_HANDSHAKE_TIMEOUT", "GROUP_KEY_UPDATE_TIMEOUT", "IE_IN_4WAY_DIFFERS", "GROUP_CIPHER_INVALID", "PAIRWISE_CIPHER_INVALID", "AKMP_INVALID", "UNSUPP_RSN_IE_VERSION", "INVALID_RSN_IE_CAP", "802_1X_AUTH_FAILED", "CIPHER_SUITE_REJECTED", "BEACON_TIMEOUT", "NO_AP_FOUND", "AUTH_FAIL", "ASSOC_FAIL", "HANDSHAKE_TIMEOUT" };
|
||||
#define reason2str(r) ((r>174)?system_event_reasons[r-174]:system_event_reasons[r-1])
|
||||
|
14
platform.txt
14
platform.txt
@ -6,6 +6,9 @@ runtime.tools.xtensa-esp32-elf-gcc.path={runtime.platform.path}/tools/xtensa-esp
|
||||
tools.esptool.cmd="{runtime.platform.path}/tools/esptool"
|
||||
tools.esptool.cmd.windows="{runtime.platform.path}/tools/esptool.exe"
|
||||
|
||||
tools.gen_esp32part.cmd=python "{runtime.platform.path}/tools/gen_esp32part.py"
|
||||
tools.gen_esp32part.cmd.windows="{runtime.platform.path}/tools/gen_esp32part.exe"
|
||||
|
||||
compiler.warning_flags=-w
|
||||
compiler.warning_flags.none=-w
|
||||
compiler.warning_flags.default=
|
||||
@ -14,7 +17,7 @@ compiler.warning_flags.all=-Wall -Werror=all -Wextra
|
||||
|
||||
compiler.path={runtime.tools.xtensa-esp32-elf-gcc.path}/bin/
|
||||
compiler.sdk.path={runtime.platform.path}/tools/sdk
|
||||
compiler.cpreprocessor.flags=-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"' -DHAVE_CONFIG_H "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/bt" "-I{compiler.sdk.path}/include/driver" "-I{compiler.sdk.path}/include/esp32" "-I{compiler.sdk.path}/include/ethernet" "-I{compiler.sdk.path}/include/fatfs" "-I{compiler.sdk.path}/include/freertos" "-I{compiler.sdk.path}/include/log" "-I{compiler.sdk.path}/include/mdns" "-I{compiler.sdk.path}/include/vfs" "-I{compiler.sdk.path}/include/ulp" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nvs_flash" "-I{compiler.sdk.path}/include/spi_flash" "-I{compiler.sdk.path}/include/sdmmc" "-I{compiler.sdk.path}/include/openssl" "-I{compiler.sdk.path}/include/app_update" "-I{compiler.sdk.path}/include/tcpip_adapter" "-I{compiler.sdk.path}/include/xtensa-debug-module" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/coap" "-I{compiler.sdk.path}/include/wpa_supplicant" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/mbedtls" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/lwip"
|
||||
compiler.cpreprocessor.flags=-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DHAVE_CONFIG_H "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/bluedroid" "-I{compiler.sdk.path}/include/bt" "-I{compiler.sdk.path}/include/driver" "-I{compiler.sdk.path}/include/esp32" "-I{compiler.sdk.path}/include/ethernet" "-I{compiler.sdk.path}/include/fatfs" "-I{compiler.sdk.path}/include/freertos" "-I{compiler.sdk.path}/include/log" "-I{compiler.sdk.path}/include/mdns" "-I{compiler.sdk.path}/include/mbedtls" "-I{compiler.sdk.path}/include/mbedtls_port" "-I{compiler.sdk.path}/include/vfs" "-I{compiler.sdk.path}/include/ulp" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nvs_flash" "-I{compiler.sdk.path}/include/spi_flash" "-I{compiler.sdk.path}/include/sdmmc" "-I{compiler.sdk.path}/include/openssl" "-I{compiler.sdk.path}/include/app_update" "-I{compiler.sdk.path}/include/tcpip_adapter" "-I{compiler.sdk.path}/include/xtensa-debug-module" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/coap" "-I{compiler.sdk.path}/include/wpa_supplicant" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/lwip"
|
||||
|
||||
compiler.c.cmd=xtensa-esp32-elf-gcc
|
||||
compiler.c.flags=-std=gnu99 -Os -g3 -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wpointer-arith {compiler.warning_flags} -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -Wno-old-style-declaration -MMD -c
|
||||
@ -27,7 +30,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 -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority
|
||||
compiler.c.elf.libs=-lapp_update -lbootloader_support -lbt -lbtdm_app -lc -lc_nano -lcoap -lcoexist -lcore -lcxx -ldriver -lesp32 -lethernet -lexpat -lfatfs -lfreertos -lhal -ljson -llog -llwip -lm -lmbedtls -lmdns -lmicro-ecc -lnet80211 -lnewlib -lnghttp -lnvs_flash -lopenssl -lphy -lpp -lrtc -lsdmmc -lsmartconfig -lspi_flash -ltcpip_adapter -lulp -lvfs -lwpa -lwpa2 -lwpa_supplicant -lwps -lxtensa-debug-module -lgcc -lstdc++
|
||||
compiler.c.elf.libs=-lgcc -lstdc++ -lapp_update -lbootloader_support -lbt -lbtdm_app -lc -lc_nano -lcoap -lcoexist -lcore -lcxx -ldriver -lesp32 -lethernet -lexpat -lfatfs -lfreertos -lhal -ljson -llog -llwip -lm -lmbedtls -lmdns -lmicro-ecc -lnet80211 -lnewlib -lnghttp -lnvs_flash -lopenssl -lphy -lpp -lrtc -lsdmmc -lsmartconfig -lspi_flash -ltcpip_adapter -lulp -lvfs -lwpa -lwpa2 -lwpa_supplicant -lwps -lxtensa-debug-module
|
||||
|
||||
compiler.as.cmd=xtensa-esp32-elf-as
|
||||
|
||||
@ -37,7 +40,8 @@ compiler.ar.flags=cru
|
||||
compiler.size.cmd=xtensa-esp32-elf-size
|
||||
|
||||
# This can be overriden in boards.txt
|
||||
build.extra_flags=-DESP32
|
||||
build.code_debug=0
|
||||
build.extra_flags=-DESP32 -DCORE_DEBUG_LEVEL={build.code_debug}
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
compiler.c.extra_flags=
|
||||
@ -64,7 +68,7 @@ recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compil
|
||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -Wl,--start-group {object_files} "{build.path}/arduino.ar" {compiler.c.elf.libs} -Wl,--end-group -Wl,-EL -o "{build.path}/{build.project_name}.elf"
|
||||
|
||||
## Create eeprom
|
||||
recipe.objcopy.eep.pattern=
|
||||
recipe.objcopy.eep.pattern={tools.gen_esp32part.cmd} -q "{runtime.platform.path}/tools/partitions/default.csv" "{build.path}/{build.project_name}.partitions.bin"
|
||||
|
||||
## Create hex
|
||||
recipe.objcopy.hex.pattern={tools.esptool.cmd} --chip esp32 elf2image --flash_mode "{build.flash_mode}" --flash_freq "{build.flash_freq}" --flash_size "{build.flash_size}" -o "{build.path}/{build.project_name}.bin" "{build.path}/{build.project_name}.elf"
|
||||
@ -83,4 +87,4 @@ recipe.size.regex.data=^(?:\.dram0\.data|\.dram0\.bss)\s+([0-9]+).*
|
||||
tools.esptool.upload.protocol=esp32
|
||||
tools.esptool.upload.params.verbose=
|
||||
tools.esptool.upload.params.quiet=
|
||||
tools.esptool.upload.pattern={cmd} --chip esp32 --port "{serial.port}" --baud {upload.speed} write_flash -z --flash_freq {build.flash_freq} --flash_mode {build.flash_mode} --flash_size {build.flash_size} 0x1000 "{runtime.platform.path}/tools/sdk/bin/bootloader.bin" 0x8000 "{runtime.platform.path}/tools/sdk/bin/partitions_singleapp.bin" 0x10000 "{build.path}/{build.project_name}.bin"
|
||||
tools.esptool.upload.pattern={cmd} --chip esp32 --port "{serial.port}" --baud {upload.speed} --before default_reset --after hard_reset write_flash -z --flash_freq {build.flash_freq} --flash_mode {build.flash_mode} --flash_size {build.flash_size} 0x1000 "{runtime.platform.path}/tools/sdk/bin/bootloader.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin" 0x10000 "{build.path}/{build.project_name}.bin"
|
||||
|
654
tools/esptool.py
654
tools/esptool.py
File diff suppressed because it is too large
Load Diff
BIN
tools/gen_esp32part.exe
Normal file
BIN
tools/gen_esp32part.exe
Normal file
Binary file not shown.
350
tools/gen_esp32part.py
Executable file
350
tools/gen_esp32part.py
Executable file
@ -0,0 +1,350 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# ESP32 partition table generation tool
|
||||
#
|
||||
# Converts partition tables to/from CSV and binary formats.
|
||||
#
|
||||
# See the sdkng README.md file for details about how to use this tool.
|
||||
import struct
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
MAX_PARTITION_LENGTH = 0xC00 # 3K for partition data (96 entries) leaves 1K in a 4K sector for signature
|
||||
|
||||
__version__ = '1.0'
|
||||
|
||||
quiet = False
|
||||
|
||||
def status(msg):
|
||||
""" Print status message to stderr """
|
||||
if not quiet:
|
||||
critical(msg)
|
||||
|
||||
def critical(msg):
|
||||
""" Print critical message to stderr """
|
||||
if not quiet:
|
||||
sys.stderr.write(msg)
|
||||
sys.stderr.write('\n')
|
||||
|
||||
class PartitionTable(list):
|
||||
def __init__(self):
|
||||
super(PartitionTable, self).__init__(self)
|
||||
|
||||
@classmethod
|
||||
def from_csv(cls, csv_contents):
|
||||
res = PartitionTable()
|
||||
lines = csv_contents.split("\n")
|
||||
for line_no in range(len(lines)):
|
||||
line = lines[line_no].strip()
|
||||
if line.startswith("#") or len(line) == 0:
|
||||
continue
|
||||
try:
|
||||
res.append(PartitionDefinition.from_csv(line))
|
||||
except InputError as e:
|
||||
raise InputError("Error at line %d: %s" % (line_no+1, e))
|
||||
except Exception:
|
||||
critical("Unexpected error parsing line %d: %s" % (line_no+1, line))
|
||||
raise
|
||||
|
||||
# fix up missing offsets & negative sizes
|
||||
last_end = 0x5000 # first offset after partition table
|
||||
for e in res:
|
||||
if e.offset is None:
|
||||
pad_to = 0x10000 if e.type == PartitionDefinition.APP_TYPE else 4
|
||||
if last_end % pad_to != 0:
|
||||
last_end += pad_to - (last_end % pad_to)
|
||||
e.offset = last_end
|
||||
if e.size < 0:
|
||||
e.size = -e.size - e.offset
|
||||
last_end = e.offset + e.size
|
||||
|
||||
return res
|
||||
|
||||
def __getitem__(self, item):
|
||||
""" Allow partition table access via name as well as by
|
||||
numeric index. """
|
||||
if isinstance(item, str):
|
||||
for x in self:
|
||||
if x.name == item:
|
||||
return x
|
||||
raise ValueError("No partition entry named '%s'" % item)
|
||||
else:
|
||||
return super(PartitionTable, self).__getitem__(item)
|
||||
|
||||
def verify(self):
|
||||
# verify each partition individually
|
||||
for p in self:
|
||||
p.verify()
|
||||
# check for overlaps
|
||||
last = None
|
||||
for p in sorted(self):
|
||||
if p.offset < 0x5000:
|
||||
raise InputError("Partition offset 0x%x is below 0x5000" % p.offset)
|
||||
if last is not None and p.offset < last.offset + last.size:
|
||||
raise InputError("Partition at 0x%x overlaps 0x%x-0x%x" % (p.offset, last.offset, last.offset+last.size-1))
|
||||
last = p
|
||||
|
||||
@classmethod
|
||||
def from_binary(cls, b):
|
||||
result = cls()
|
||||
for o in range(0,len(b),32):
|
||||
data = b[o:o+32]
|
||||
if len(data) != 32:
|
||||
raise InputError("Partition table length must be a multiple of 32 bytes")
|
||||
if data == '\xFF'*32:
|
||||
return result # got end marker
|
||||
result.append(PartitionDefinition.from_binary(data))
|
||||
raise InputError("Partition table is missing an end-of-table marker")
|
||||
|
||||
def to_binary(self):
|
||||
result = "".join(e.to_binary() for e in self)
|
||||
if len(result )>= MAX_PARTITION_LENGTH:
|
||||
raise InputError("Binary partition table length (%d) longer than max" % len(result))
|
||||
result += "\xFF" * (MAX_PARTITION_LENGTH - len(result)) # pad the sector, for signing
|
||||
return result
|
||||
|
||||
def to_csv(self, simple_formatting=False):
|
||||
rows = [ "# Espressif ESP32 Partition Table",
|
||||
"# Name, Type, SubType, Offset, Size, Flags" ]
|
||||
rows += [ x.to_csv(simple_formatting) for x in self ]
|
||||
return "\n".join(rows) + "\n"
|
||||
|
||||
class PartitionDefinition(object):
|
||||
APP_TYPE = 0x00
|
||||
DATA_TYPE = 0x01
|
||||
TYPES = {
|
||||
"app" : APP_TYPE,
|
||||
"data" : DATA_TYPE,
|
||||
}
|
||||
|
||||
# Keep this map in sync with esp_partition_subtype_t enum in esp_partition.h
|
||||
SUBTYPES = {
|
||||
APP_TYPE : {
|
||||
"factory" : 0x00,
|
||||
"test" : 0x20,
|
||||
},
|
||||
DATA_TYPE : {
|
||||
"ota" : 0x00,
|
||||
"phy" : 0x01,
|
||||
"nvs" : 0x02,
|
||||
"coredump" : 0x03,
|
||||
"esphttpd" : 0x80,
|
||||
"fat" : 0x81,
|
||||
"spiffs" : 0x82,
|
||||
},
|
||||
}
|
||||
|
||||
MAGIC_BYTES = "\xAA\x50"
|
||||
|
||||
ALIGNMENT = {
|
||||
APP_TYPE : 0x1000,
|
||||
DATA_TYPE : 0x04,
|
||||
}
|
||||
|
||||
# dictionary maps flag name (as used in CSV flags list, property name)
|
||||
# to bit set in flags words in binary format
|
||||
FLAGS = {
|
||||
"encrypted" : 0
|
||||
}
|
||||
|
||||
# add subtypes for the 16 OTA slot values ("ota_XXX, etc.")
|
||||
for ota_slot in range(16):
|
||||
SUBTYPES[TYPES["app"]]["ota_%d" % ota_slot] = 0x10 + ota_slot
|
||||
|
||||
def __init__(self):
|
||||
self.name = ""
|
||||
self.type = None
|
||||
self.subtype = None
|
||||
self.offset = None
|
||||
self.size = None
|
||||
self.encrypted = False
|
||||
|
||||
@classmethod
|
||||
def from_csv(cls, line):
|
||||
""" Parse a line from the CSV """
|
||||
line_w_defaults = line + ",,,," # lazy way to support default fields
|
||||
fields = [ f.strip() for f in line_w_defaults.split(",") ]
|
||||
|
||||
res = PartitionDefinition()
|
||||
res.name = fields[0]
|
||||
res.type = res.parse_type(fields[1])
|
||||
res.subtype = res.parse_subtype(fields[2])
|
||||
res.offset = res.parse_address(fields[3])
|
||||
res.size = res.parse_address(fields[4])
|
||||
if res.size is None:
|
||||
raise InputError("Size field can't be empty")
|
||||
|
||||
flags = fields[5].split(":")
|
||||
for flag in flags:
|
||||
if flag in cls.FLAGS:
|
||||
setattr(res, flag, True)
|
||||
elif len(flag) > 0:
|
||||
raise InputError("CSV flag column contains unknown flag '%s'" % (flag))
|
||||
|
||||
return res
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.name == other.name and self.type == other.type \
|
||||
and self.subtype == other.subtype and self.offset == other.offset \
|
||||
and self.size == other.size
|
||||
|
||||
def __repr__(self):
|
||||
def maybe_hex(x):
|
||||
return "0x%x" % x if x is not None else "None"
|
||||
return "PartitionDefinition('%s', 0x%x, 0x%x, %s, %s)" % (self.name, self.type, self.subtype or 0,
|
||||
maybe_hex(self.offset), maybe_hex(self.size))
|
||||
|
||||
def __str__(self):
|
||||
return "Part '%s' %d/%d @ 0x%x size 0x%x" % (self.name, self.type, self.subtype, self.offset or -1, self.size or -1)
|
||||
|
||||
def __cmp__(self, other):
|
||||
return self.offset - other.offset
|
||||
|
||||
def parse_type(self, strval):
|
||||
if strval == "":
|
||||
raise InputError("Field 'type' can't be left empty.")
|
||||
return parse_int(strval, self.TYPES)
|
||||
|
||||
def parse_subtype(self, strval):
|
||||
if strval == "":
|
||||
return 0 # default
|
||||
return parse_int(strval, self.SUBTYPES.get(self.type, {}))
|
||||
|
||||
def parse_address(self, strval):
|
||||
if strval == "":
|
||||
return None # PartitionTable will fill in default
|
||||
return parse_int(strval)
|
||||
|
||||
def verify(self):
|
||||
if self.type is None:
|
||||
raise ValidationError("Type field is not set")
|
||||
if self.subtype is None:
|
||||
raise ValidationError("Subtype field is not set")
|
||||
if self.offset is None:
|
||||
raise ValidationError("Offset field is not set")
|
||||
align = self.ALIGNMENT.get(self.type, 4)
|
||||
if self.offset % align:
|
||||
raise ValidationError("%s offset 0x%x is not aligned to 0x%x" % (self.name, self.offset, align))
|
||||
if self.size is None:
|
||||
raise ValidationError("Size field is not set")
|
||||
|
||||
STRUCT_FORMAT = "<2sBBLL16sL"
|
||||
|
||||
@classmethod
|
||||
def from_binary(cls, b):
|
||||
if len(b) != 32:
|
||||
raise InputError("Partition definition length must be exactly 32 bytes. Got %d bytes." % len(b))
|
||||
res = cls()
|
||||
(magic, res.type, res.subtype, res.offset,
|
||||
res.size, res.name, flags) = struct.unpack(cls.STRUCT_FORMAT, b)
|
||||
if "\x00" in res.name: # strip null byte padding from name string
|
||||
res.name = res.name[:res.name.index("\x00")]
|
||||
if magic != cls.MAGIC_BYTES:
|
||||
raise InputError("Invalid magic bytes (%r) for partition definition" % magic)
|
||||
for flag,bit in cls.FLAGS.items():
|
||||
if flags & (1<<bit):
|
||||
setattr(res, flag, True)
|
||||
flags &= ~(1<<bit)
|
||||
if flags != 0:
|
||||
critical("WARNING: Partition definition had unknown flag(s) 0x%08x. Newer binary format?" % flags)
|
||||
return res
|
||||
|
||||
def get_flags_list(self):
|
||||
return [ flag for flag in self.FLAGS.keys() if getattr(self, flag) ]
|
||||
|
||||
def to_binary(self):
|
||||
flags = sum((1 << self.FLAGS[flag]) for flag in self.get_flags_list())
|
||||
return struct.pack(self.STRUCT_FORMAT,
|
||||
self.MAGIC_BYTES,
|
||||
self.type, self.subtype,
|
||||
self.offset, self.size,
|
||||
self.name,
|
||||
flags)
|
||||
|
||||
def to_csv(self, simple_formatting=False):
|
||||
def addr_format(a, include_sizes):
|
||||
if not simple_formatting and include_sizes:
|
||||
for (val, suffix) in [ (0x100000, "M"), (0x400, "K") ]:
|
||||
if a % val == 0:
|
||||
return "%d%s" % (a / val, suffix)
|
||||
return "0x%x" % a
|
||||
|
||||
def lookup_keyword(t, keywords):
|
||||
for k,v in keywords.items():
|
||||
if simple_formatting == False and t == v:
|
||||
return k
|
||||
return "%d" % t
|
||||
|
||||
def generate_text_flags():
|
||||
""" colon-delimited list of flags """
|
||||
return ":".join(self.get_flags_list())
|
||||
|
||||
return ",".join([ self.name,
|
||||
lookup_keyword(self.type, self.TYPES),
|
||||
lookup_keyword(self.subtype, self.SUBTYPES.get(self.type, {})),
|
||||
addr_format(self.offset, False),
|
||||
addr_format(self.size, True),
|
||||
generate_text_flags()])
|
||||
|
||||
class InputError(RuntimeError):
|
||||
def __init__(self, e):
|
||||
super(InputError, self).__init__(e)
|
||||
|
||||
def parse_int(v, keywords={}):
|
||||
"""Generic parser for integer fields - int(x,0) with provision for
|
||||
k/m/K/M suffixes and 'keyword' value lookup.
|
||||
"""
|
||||
try:
|
||||
for letter, multiplier in [ ("k",1024), ("m",1024*1024) ]:
|
||||
if v.lower().endswith(letter):
|
||||
return parse_int(v[:-1], keywords) * multiplier
|
||||
return int(v, 0)
|
||||
except ValueError:
|
||||
if len(keywords) == 0:
|
||||
raise InputError("Invalid field value %s" % v)
|
||||
try:
|
||||
return keywords[v.lower()]
|
||||
except KeyError:
|
||||
raise InputError("Value '%s' is not valid. Known keywords: %s" % (v, ", ".join(keywords)))
|
||||
|
||||
def main():
|
||||
global quiet
|
||||
parser = argparse.ArgumentParser(description='ESP32 partition table utility')
|
||||
|
||||
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')
|
||||
|
||||
parser.add_argument('input', help='Path to CSV or binary file to parse. Will use stdin if omitted.', type=argparse.FileType('r'), default=sys.stdin)
|
||||
parser.add_argument('output', help='Path to output converted binary or CSV file. Will use stdout if omitted, unless the --display argument is also passed (in which case only the summary is printed.)',
|
||||
nargs='?',
|
||||
default='-')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
quiet = args.quiet
|
||||
input = args.input.read()
|
||||
input_is_binary = input[0:2] == PartitionDefinition.MAGIC_BYTES
|
||||
if input_is_binary:
|
||||
status("Parsing binary partition input...")
|
||||
table = PartitionTable.from_binary(input)
|
||||
else:
|
||||
status("Parsing CSV input...")
|
||||
table = PartitionTable.from_csv(input)
|
||||
|
||||
if args.verify:
|
||||
status("Verifying table...")
|
||||
table.verify()
|
||||
|
||||
if input_is_binary:
|
||||
output = table.to_csv()
|
||||
else:
|
||||
output = table.to_binary()
|
||||
with sys.stdout if args.output == '-' else open(args.output, 'w') as f:
|
||||
f.write(output)
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except InputError as e:
|
||||
print(e)
|
||||
sys.exit(2)
|
4
tools/partitions/default.csv
Normal file
4
tools/partitions/default.csv
Normal file
@ -0,0 +1,4 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
nvs, data, nvs, 0x9000, 0x6000,
|
||||
phy_init, data, phy, 0xf000, 0x1000,
|
||||
factory, app, factory, 0x10000, 1M,
|
|
@ -50,6 +50,7 @@ env.Prepend(
|
||||
|
||||
CPPPATH=[
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "config"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "bluedroid"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "bt"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "driver"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp32"),
|
||||
@ -58,6 +59,8 @@ env.Prepend(
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "freertos"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "log"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "mdns"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "mbedtls"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "mbedtls_port"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "vfs"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "ulp"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "newlib"),
|
||||
@ -68,27 +71,21 @@ env.Prepend(
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "app_update"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "tcpip_adapter"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "xtensa-debug-module"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "newlib"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "coap"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wpa_supplicant"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "expat"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "json"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "mbedtls"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "nghttp"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "lwip"),
|
||||
join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core"))
|
||||
],
|
||||
LIBPATH=[
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "lib"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "ld"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "ld")
|
||||
],
|
||||
LIBS=[
|
||||
"app_update", "bootloader_support", "bt", "btdm_app", "c",
|
||||
"c_nano", "coap", "coexist", "core", "cxx", "driver", "esp32",
|
||||
"ethernet", "expat", "fatfs", "freertos", "hal", "json", "log",
|
||||
"lwip", "m", "mbedtls", "mdns", "micro-ecc", "net80211", "newlib",
|
||||
"nghttp", "nvs_flash", "openssl", "phy", "pp", "rtc", "sdmmc",
|
||||
"smartconfig", "spi_flash", "tcpip_adapter", "ulp", "vfs", "wpa",
|
||||
"wpa2", "wpa_supplicant", "wps", "xtensa-debug-module", "gcc", "stdc++"
|
||||
"gcc", "stdc++", "app_update", "bootloader_support", "bt", "btdm_app", "c", "c_nano", "coap", "coexist", "core", "cxx", "driver", "esp32", "ethernet", "expat", "fatfs", "freertos", "hal", "json", "log", "lwip", "m", "mbedtls", "mdns", "micro-ecc", "net80211", "newlib", "nghttp", "nvs_flash", "openssl", "phy", "pp", "rtc", "sdmmc", "smartconfig", "spi_flash", "tcpip_adapter", "ulp", "vfs", "wpa", "wpa2", "wpa_supplicant", "wps", "xtensa-debug-module"
|
||||
]
|
||||
)
|
||||
|
||||
|
162
tools/sdk/include/bluedroid/aes.h
Normal file
162
tools/sdk/include/bluedroid/aes.h
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
LICENSE TERMS
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
1. source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
2. binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation;
|
||||
|
||||
3. the name of the copyright holder is not used to endorse products
|
||||
built using this software without specific written permission.
|
||||
|
||||
DISCLAIMER
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its properties, including, but not limited to, correctness
|
||||
and/or fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue 09/09/2006
|
||||
|
||||
This is an AES implementation that uses only 8-bit byte operations on the
|
||||
cipher state.
|
||||
*/
|
||||
|
||||
#ifndef AES_H
|
||||
#define AES_H
|
||||
|
||||
#if 1
|
||||
# define AES_ENC_PREKEYED /* AES encryption with a precomputed key schedule */
|
||||
#endif
|
||||
#if 1
|
||||
# define AES_DEC_PREKEYED /* AES decryption with a precomputed key schedule */
|
||||
#endif
|
||||
#if 1
|
||||
# define AES_ENC_128_OTFK /* AES encryption with 'on the fly' 128 bit keying */
|
||||
#endif
|
||||
#if 1
|
||||
# define AES_DEC_128_OTFK /* AES decryption with 'on the fly' 128 bit keying */
|
||||
#endif
|
||||
#if 1
|
||||
# define AES_ENC_256_OTFK /* AES encryption with 'on the fly' 256 bit keying */
|
||||
#endif
|
||||
#if 1
|
||||
# define AES_DEC_256_OTFK /* AES decryption with 'on the fly' 256 bit keying */
|
||||
#endif
|
||||
|
||||
#define N_ROW 4
|
||||
#define N_COL 4
|
||||
#define N_BLOCK (N_ROW * N_COL)
|
||||
#define N_MAX_ROUNDS 14
|
||||
|
||||
typedef unsigned char uint_8t;
|
||||
|
||||
typedef uint_8t return_type;
|
||||
|
||||
/* Warning: The key length for 256 bit keys overflows a byte
|
||||
(see comment below)
|
||||
*/
|
||||
|
||||
typedef uint_8t length_type;
|
||||
|
||||
typedef struct {
|
||||
uint_8t ksch[(N_MAX_ROUNDS + 1) * N_BLOCK];
|
||||
uint_8t rnd;
|
||||
} aes_context;
|
||||
|
||||
/* The following calls are for a precomputed key schedule
|
||||
|
||||
NOTE: If the length_type used for the key length is an
|
||||
unsigned 8-bit character, a key length of 256 bits must
|
||||
be entered as a length in bytes (valid inputs are hence
|
||||
128, 192, 16, 24 and 32).
|
||||
*/
|
||||
|
||||
#if defined( AES_ENC_PREKEYED ) || defined( AES_DEC_PREKEYED )
|
||||
|
||||
return_type aes_set_key( const unsigned char key[],
|
||||
length_type keylen,
|
||||
aes_context ctx[1] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_ENC_PREKEYED )
|
||||
|
||||
return_type bluedroid_aes_encrypt( const unsigned char in[N_BLOCK],
|
||||
unsigned char out[N_BLOCK],
|
||||
const aes_context ctx[1] );
|
||||
|
||||
return_type aes_cbc_encrypt( const unsigned char *in,
|
||||
unsigned char *out,
|
||||
int n_block,
|
||||
unsigned char iv[N_BLOCK],
|
||||
const aes_context ctx[1] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_DEC_PREKEYED )
|
||||
|
||||
return_type bluedroid_aes_decrypt( const unsigned char in[N_BLOCK],
|
||||
unsigned char out[N_BLOCK],
|
||||
const aes_context ctx[1] );
|
||||
|
||||
return_type aes_cbc_decrypt( const unsigned char *in,
|
||||
unsigned char *out,
|
||||
int n_block,
|
||||
unsigned char iv[N_BLOCK],
|
||||
const aes_context ctx[1] );
|
||||
#endif
|
||||
|
||||
/* The following calls are for 'on the fly' keying. In this case the
|
||||
encryption and decryption keys are different.
|
||||
|
||||
The encryption subroutines take a key in an array of bytes in
|
||||
key[L] where L is 16, 24 or 32 bytes for key lengths of 128,
|
||||
192, and 256 bits respectively. They then encrypts the input
|
||||
data, in[] with this key and put the reult in the output array
|
||||
out[]. In addition, the second key array, o_key[L], is used
|
||||
to output the key that is needed by the decryption subroutine
|
||||
to reverse the encryption operation. The two key arrays can
|
||||
be the same array but in this case the original key will be
|
||||
overwritten.
|
||||
|
||||
In the same way, the decryption subroutines output keys that
|
||||
can be used to reverse their effect when used for encryption.
|
||||
|
||||
Only 128 and 256 bit keys are supported in these 'on the fly'
|
||||
modes.
|
||||
*/
|
||||
|
||||
#if defined( AES_ENC_128_OTFK )
|
||||
void bluedroid_aes_encrypt_128( const unsigned char in[N_BLOCK],
|
||||
unsigned char out[N_BLOCK],
|
||||
const unsigned char key[N_BLOCK],
|
||||
uint_8t o_key[N_BLOCK] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_DEC_128_OTFK )
|
||||
void bluedroid_aes_decrypt_128( const unsigned char in[N_BLOCK],
|
||||
unsigned char out[N_BLOCK],
|
||||
const unsigned char key[N_BLOCK],
|
||||
unsigned char o_key[N_BLOCK] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_ENC_256_OTFK )
|
||||
void bluedroid_aes_encrypt_256( const unsigned char in[N_BLOCK],
|
||||
unsigned char out[N_BLOCK],
|
||||
const unsigned char key[2 * N_BLOCK],
|
||||
unsigned char o_key[2 * N_BLOCK] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_DEC_256_OTFK )
|
||||
void bluedroid_aes_decrypt_256( const unsigned char in[N_BLOCK],
|
||||
unsigned char out[N_BLOCK],
|
||||
const unsigned char key[2 * N_BLOCK],
|
||||
unsigned char o_key[2 * N_BLOCK] );
|
||||
#endif
|
||||
|
||||
#endif
|
76
tools/sdk/include/bluedroid/alarm.h
Normal file
76
tools/sdk/include/bluedroid/alarm.h
Normal file
@ -0,0 +1,76 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _ALARM_H_
|
||||
#define _ALARM_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/timers.h>
|
||||
|
||||
typedef uint32_t period_ms_t;
|
||||
typedef void (*osi_alarm_callback_t)(void *data);
|
||||
|
||||
#define ALARM_CBS_NUM 20
|
||||
#define ALARM_ID_BASE 1000
|
||||
typedef struct alarm_t {
|
||||
/* timer id point to here */
|
||||
TimerHandle_t alarm_hdl;
|
||||
osi_alarm_callback_t cb;
|
||||
void *cb_data;
|
||||
} osi_alarm_t;
|
||||
|
||||
void osi_alarm_init(void);
|
||||
|
||||
// Creates a new alarm object. The returned object must be freed by calling
|
||||
// |alarm_free|. Returns NULL on failure.
|
||||
osi_alarm_t *osi_alarm_new(char *alarm_name, osi_alarm_callback_t callback, void *data, period_ms_t timer_expire);
|
||||
|
||||
// Frees an alarm object created by |alarm_new|. |alarm| may be NULL. If the
|
||||
// alarm is pending, it will be cancelled. It is not safe to call |alarm_free|
|
||||
// from inside the callback of |alarm|.
|
||||
int osi_alarm_free(osi_alarm_t *alarm);
|
||||
|
||||
// Sets an alarm to fire |cb| after the given |deadline|. Note that |deadline| is the
|
||||
// number of milliseconds relative to the current time. |data| is a context variable
|
||||
// for the callback and may be NULL. |cb| will be called back in the context of an
|
||||
// unspecified thread (i.e. it will not be called back in the same thread as the caller).
|
||||
// |alarm| and |cb| may not be NULL.
|
||||
int osi_alarm_set(osi_alarm_t *alarm, period_ms_t timeout);
|
||||
|
||||
// This function cancels the |alarm| if it was previously set. When this call
|
||||
// returns, the caller has a guarantee that the callback is not in progress and
|
||||
// will not be called if it hasn't already been called. This function is idempotent.
|
||||
// |alarm| may not be NULL.
|
||||
int osi_alarm_cancel(osi_alarm_t *alarm);
|
||||
|
||||
period_ms_t osi_alarm_now(void);
|
||||
|
||||
// Figure out how much time until next expiration.
|
||||
// Returns 0 if not armed. |alarm| may not be NULL.
|
||||
// TODO: Remove this function once PM timers can be re-factored
|
||||
period_ms_t osi_alarm_get_remaining_ms(const osi_alarm_t *alarm);
|
||||
|
||||
// Alarm-related state cleanup
|
||||
//void alarm_cleanup(void);
|
||||
|
||||
// Compute time difference (t1-t2) considering tick counter wrap
|
||||
// t1 and t2 should be no greater than the time of MAX ticks
|
||||
period_ms_t osi_alarm_time_diff(period_ms_t t1, period_ms_t t2);
|
||||
|
||||
#endif /*_ALARM_H_*/
|
82
tools/sdk/include/bluedroid/allocator.h
Normal file
82
tools/sdk/include/bluedroid/allocator.h
Normal file
@ -0,0 +1,82 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _ALLOCATOR_H_
|
||||
#define _ALLOCATOR_H_
|
||||
|
||||
#include <stddef.h>
|
||||
//#include <stdlib.h>
|
||||
|
||||
typedef void *(*alloc_fn)(size_t size);
|
||||
typedef void (*free_fn)(void *ptr);
|
||||
|
||||
typedef struct {
|
||||
alloc_fn alloc;
|
||||
free_fn free;
|
||||
} allocator_t;
|
||||
|
||||
// allocator_t abstractions for the osi_*alloc and osi_free functions
|
||||
extern const allocator_t allocator_malloc;
|
||||
extern const allocator_t allocator_calloc;
|
||||
|
||||
char *osi_strdup(const char *str);
|
||||
|
||||
void *osi_malloc_func(size_t size);
|
||||
void *osi_calloc_func(size_t size);
|
||||
void osi_free_func(void *ptr);
|
||||
|
||||
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
|
||||
|
||||
void osi_mem_dbg_init(void);
|
||||
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);
|
||||
|
||||
#define osi_malloc(size) \
|
||||
({ \
|
||||
void *p; \
|
||||
\
|
||||
p = calloc(1, (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; \
|
||||
})
|
||||
|
||||
#define osi_free(ptr) \
|
||||
({ \
|
||||
osi_mem_dbg_clean(ptr, __func__, __LINE__); \
|
||||
free((ptr)); \
|
||||
})
|
||||
|
||||
#else
|
||||
|
||||
#define osi_malloc(size) calloc(1, (size))
|
||||
#define osi_calloc(size) calloc(1, (size))
|
||||
#define osi_free(p) free((p))
|
||||
|
||||
#endif /* CONFIG_BLUEDROID_MEM_DEBUG */
|
||||
|
||||
#endif /* _ALLOCATOR_H_ */
|
279
tools/sdk/include/bluedroid/avct_api.h
Executable file
279
tools/sdk/include/bluedroid/avct_api.h
Executable file
@ -0,0 +1,279 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 interface file contains the interface to the Audio Video Control
|
||||
* Transport Protocol (AVCTP).
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef AVCT_API_H
|
||||
#define AVCT_API_H
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* API function return value result codes. */
|
||||
#define AVCT_SUCCESS 0 /* Function successful */
|
||||
#define AVCT_NO_RESOURCES 1 /* Not enough resources */
|
||||
#define AVCT_BAD_HANDLE 2 /* Bad handle */
|
||||
#define AVCT_PID_IN_USE 3 /* PID already in use */
|
||||
#define AVCT_NOT_OPEN 4 /* Connection not open */
|
||||
|
||||
/* PSM for AVCT. */
|
||||
#define AVCT_PSM 0x0017
|
||||
#define AVCT_BR_PSM 0x001B
|
||||
|
||||
/* Protocol revision numbers */
|
||||
#define AVCT_REV_1_0 0x0100
|
||||
#define AVCT_REV_1_2 0x0102
|
||||
#define AVCT_REV_1_3 0x0103
|
||||
#define AVCT_REV_1_4 0x0104
|
||||
|
||||
/* the layer_specific settings */
|
||||
#define AVCT_DATA_CTRL 0x0001 /* for the control channel */
|
||||
#define AVCT_DATA_BROWSE 0x0002 /* for the browsing channel */
|
||||
#define AVCT_DATA_PARTIAL 0x0100 /* Only have room for a partial message */
|
||||
|
||||
#define AVCT_MIN_CONTROL_MTU 48 /* Per the AVRC spec, minimum MTU for the control channel */
|
||||
#define AVCT_MIN_BROWSE_MTU 335 /* Per the AVRC spec, minimum MTU for the browsing channel */
|
||||
|
||||
/* Message offset. The number of bytes needed by the protocol stack for the
|
||||
** protocol headers of an AVCTP message packet.
|
||||
*/
|
||||
#define AVCT_MSG_OFFSET 15
|
||||
#define AVCT_BROWSE_OFFSET 17 /* the default offset for browsing channel */
|
||||
|
||||
/* Connection role. */
|
||||
#define AVCT_INT 0 /* Initiator connection */
|
||||
#define AVCT_ACP 1 /* Acceptor connection */
|
||||
|
||||
/* Control role. */
|
||||
#define AVCT_TARGET 1 /* target */
|
||||
#define AVCT_CONTROL 2 /* controller */
|
||||
#define AVCT_PASSIVE 4 /* If conflict, allow the other side to succeed */
|
||||
|
||||
/* Command/Response indicator. */
|
||||
#define AVCT_CMD 0 /* Command message */
|
||||
#define AVCT_RSP 2 /* Response message */
|
||||
#define AVCT_REJ 3 /* Message rejected */
|
||||
|
||||
/* Control callback events. */
|
||||
#define AVCT_CONNECT_CFM_EVT 0 /* Connection confirm */
|
||||
#define AVCT_CONNECT_IND_EVT 1 /* Connection indication */
|
||||
#define AVCT_DISCONNECT_CFM_EVT 2 /* Disconnect confirm */
|
||||
#define AVCT_DISCONNECT_IND_EVT 3 /* Disconnect indication */
|
||||
#define AVCT_CONG_IND_EVT 4 /* Congestion indication */
|
||||
#define AVCT_UNCONG_IND_EVT 5 /* Uncongestion indication */
|
||||
#define AVCT_BROWSE_CONN_CFM_EVT 6 /* Browse Connection confirm */
|
||||
#define AVCT_BROWSE_CONN_IND_EVT 7 /* Browse Connection indication */
|
||||
#define AVCT_BROWSE_DISCONN_CFM_EVT 8 /* Browse Disconnect confirm */
|
||||
#define AVCT_BROWSE_DISCONN_IND_EVT 9 /* Browse Disconnect indication */
|
||||
#define AVCT_BROWSE_CONG_IND_EVT 10 /* Congestion indication */
|
||||
#define AVCT_BROWSE_UNCONG_IND_EVT 11 /* Uncongestion indication */
|
||||
|
||||
|
||||
/* General purpose failure result code for callback events. */
|
||||
#define AVCT_RESULT_FAIL 5
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
/* Control callback function. */
|
||||
typedef void (tAVCT_CTRL_CBACK)(UINT8 handle, UINT8 event, UINT16 result,
|
||||
BD_ADDR peer_addr);
|
||||
|
||||
/* Message callback function */
|
||||
/* p_pkt->layer_specific is AVCT_DATA_CTRL or AVCT_DATA_BROWSE */
|
||||
typedef void (tAVCT_MSG_CBACK)(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
BT_HDR *p_pkt);
|
||||
|
||||
/* Structure used by AVCT_CreateConn. */
|
||||
typedef struct {
|
||||
tAVCT_CTRL_CBACK *p_ctrl_cback; /* Control callback */
|
||||
tAVCT_MSG_CBACK *p_msg_cback; /* Message callback */
|
||||
UINT16 pid; /* Profile ID */
|
||||
UINT8 role; /* Initiator/acceptor role */
|
||||
UINT8 control; /* Control role (Control/Target) */
|
||||
} tAVCT_CC;
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_Register
|
||||
**
|
||||
** Description This is the system level registration function for the
|
||||
** AVCTP protocol. This function initializes AVCTP and
|
||||
** prepares the protocol stack for its use. This function
|
||||
** must be called once by the system or platform using AVCTP
|
||||
** before the other functions of the API an be used.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVCT_Register(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_Deregister
|
||||
**
|
||||
** Description This function is called to deregister use AVCTP protocol.
|
||||
** It is called when AVCTP is no longer being used by any
|
||||
** application in the system. Before this function can be
|
||||
** called, all connections must be removed with
|
||||
** AVCT_RemoveConn().
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVCT_Deregister(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_CreateConn
|
||||
**
|
||||
** Description Create an AVCTP connection. There are two types of
|
||||
** connections, initiator and acceptor, as determined by
|
||||
** the p_cc->role parameter. When this function is called to
|
||||
** create an initiator connection, an AVCTP connection to
|
||||
** the peer device is initiated if one does not already exist.
|
||||
** If an acceptor connection is created, the connection waits
|
||||
** passively for an incoming AVCTP connection from a peer device.
|
||||
**
|
||||
**
|
||||
** Returns AVCT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_CreateConn(UINT8 *p_handle, tAVCT_CC *p_cc,
|
||||
BD_ADDR peer_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_RemoveConn
|
||||
**
|
||||
** Description Remove an AVCTP connection. This function is called when
|
||||
** the application is no longer using a connection. If this
|
||||
** is the last connection to a peer the L2CAP channel for AVCTP
|
||||
** will be closed.
|
||||
**
|
||||
**
|
||||
** Returns AVCT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_RemoveConn(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_CreateBrowse
|
||||
**
|
||||
** Description Create an AVCTP connection. There are two types of
|
||||
** connections, initiator and acceptor, as determined by
|
||||
** the p_cc->role parameter. When this function is called to
|
||||
** create an initiator connection, an AVCTP connection to
|
||||
** the peer device is initiated if one does not already exist.
|
||||
** If an acceptor connection is created, the connection waits
|
||||
** passively for an incoming AVCTP connection from a peer device.
|
||||
**
|
||||
**
|
||||
** Returns AVCT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_CreateBrowse(UINT8 handle, UINT8 role);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_RemoveBrowse
|
||||
**
|
||||
** Description Remove an AVCTP connection. This function is called when
|
||||
** the application is no longer using a connection. If this
|
||||
** is the last connection to a peer the L2CAP channel for AVCTP
|
||||
** will be closed.
|
||||
**
|
||||
**
|
||||
** Returns AVCT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_RemoveBrowse(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_GetBrowseMtu
|
||||
**
|
||||
** Description Get the peer_mtu for the AVCTP Browse channel of the given
|
||||
** connection.
|
||||
**
|
||||
** Returns the peer browsing channel MTU.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_GetBrowseMtu (UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_GetPeerMtu
|
||||
**
|
||||
** Description Get the peer_mtu for the AVCTP channel of the given
|
||||
** connection.
|
||||
**
|
||||
** Returns the peer MTU size.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_GetPeerMtu (UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVCT_MsgReq
|
||||
**
|
||||
** Description Send an AVCTP message to a peer device. In calling
|
||||
** AVCT_MsgReq(), the application should keep track of the
|
||||
** congestion state of AVCTP as communicated with events
|
||||
** AVCT_CONG_IND_EVT and AVCT_UNCONG_IND_EVT. If the
|
||||
** application calls AVCT_MsgReq() when AVCTP is congested
|
||||
** the message may be discarded. The application may make its
|
||||
** first call to AVCT_MsgReq() after it receives an
|
||||
** AVCT_CONNECT_CFM_EVT or AVCT_CONNECT_IND_EVT on control channel or
|
||||
** AVCT_BROWSE_CONN_CFM_EVT or AVCT_BROWSE_CONN_IND_EVT on browsing channel.
|
||||
**
|
||||
** p_msg->layer_specific must be set to
|
||||
** AVCT_DATA_CTRL for control channel traffic;
|
||||
** AVCT_DATA_BROWSE for for browse channel traffic.
|
||||
**
|
||||
** Returns AVCT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* AVCT_API_H */
|
985
tools/sdk/include/bluedroid/avdt_api.h
Normal file
985
tools/sdk/include/bluedroid/avdt_api.h
Normal file
@ -0,0 +1,985 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-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 interface file contains the interface to the Audio Video
|
||||
* Distribution Transport Protocol (AVDTP).
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef AVDT_API_H
|
||||
#define AVDT_API_H
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
#ifndef AVDT_VERSION
|
||||
#define AVDT_VERSION 0x0102
|
||||
#endif
|
||||
#define AVDT_VERSION_SYNC 0x0103
|
||||
|
||||
/* API function return value result codes. */
|
||||
#define AVDT_SUCCESS 0 /* Function successful */
|
||||
#define AVDT_BAD_PARAMS 1 /* Invalid parameters */
|
||||
#define AVDT_NO_RESOURCES 2 /* Not enough resources */
|
||||
#define AVDT_BAD_HANDLE 3 /* Bad handle */
|
||||
#define AVDT_BUSY 4 /* A procedure is already in progress */
|
||||
#define AVDT_WRITE_FAIL 5 /* Write failed */
|
||||
|
||||
/* The index to access the codec type in codec_info[]. */
|
||||
#define AVDT_CODEC_TYPE_INDEX 2
|
||||
|
||||
/* The size in bytes of a Adaptation Layer header. */
|
||||
#define AVDT_AL_HDR_SIZE 3
|
||||
|
||||
/* The size in bytes of a media packet header. */
|
||||
#define AVDT_MEDIA_HDR_SIZE 12
|
||||
|
||||
/* AVDTP 7.5.3 Adaptation Layer Fragmentation
|
||||
* original length of the un-fragmented transport packet should be specified by
|
||||
* two bytes length field of Adaptation Layer Header */
|
||||
#define AVDT_MAX_MEDIA_SIZE (0xFFFF - AVDT_MEDIA_HDR_SIZE)
|
||||
|
||||
/* The handle is used when reporting MULTI_AV specific events */
|
||||
#define AVDT_MULTI_AV_HANDLE 0xFF
|
||||
|
||||
/* The number of bytes needed by the protocol stack for the protocol headers
|
||||
** of a media packet. This is the size of the media packet header, the
|
||||
** L2CAP packet header and HCI header.
|
||||
*/
|
||||
#define AVDT_MEDIA_OFFSET 23
|
||||
|
||||
/* The marker bit is used by the application to mark significant events such
|
||||
** as frame boundaries in the data stream. This constant is used to check or
|
||||
** set the marker bit in the m_pt parameter of an AVDT_WriteReq()
|
||||
** or AVDT_DATA_IND_EVT.
|
||||
*/
|
||||
#define AVDT_MARKER_SET 0x80
|
||||
|
||||
/* SEP Type. This indicates the stream endpoint type. */
|
||||
#define AVDT_TSEP_SRC 0 /* Source SEP */
|
||||
#define AVDT_TSEP_SNK 1 /* Sink SEP */
|
||||
|
||||
/* initiator/acceptor role for adaption */
|
||||
#define AVDT_INT 0 /* initiator */
|
||||
#define AVDT_ACP 1 /* acceptor */
|
||||
|
||||
/* Media Type. This indicates the media type of the stream endpoint. */
|
||||
#define AVDT_MEDIA_AUDIO 0 /* Audio SEP */
|
||||
#define AVDT_MEDIA_VIDEO 1 /* Video SEP */
|
||||
#define AVDT_MEDIA_MULTI 2 /* Multimedia SEP */
|
||||
|
||||
/* for reporting packets */
|
||||
#define AVDT_RTCP_PT_SR 200 /* the packet type - SR (Sender Report) */
|
||||
#define AVDT_RTCP_PT_RR 201 /* the packet type - RR (Receiver Report) */
|
||||
#define AVDT_RTCP_PT_SDES 202 /* the packet type - SDES (Source Description) */
|
||||
typedef UINT8 AVDT_REPORT_TYPE;
|
||||
|
||||
#define AVDT_RTCP_SDES_CNAME 1 /* SDES item CNAME */
|
||||
#ifndef AVDT_MAX_CNAME_SIZE
|
||||
#define AVDT_MAX_CNAME_SIZE 28
|
||||
#endif
|
||||
|
||||
/* Protocol service capabilities. This indicates the protocol service
|
||||
** capabilities of a stream endpoint. This value is a mask.
|
||||
** Multiple values can be combined with a bitwise OR.
|
||||
*/
|
||||
#define AVDT_PSC_TRANS (1<<1) /* Media transport */
|
||||
#define AVDT_PSC_REPORT (1<<2) /* Reporting */
|
||||
#define AVDT_PSC_RECOV (1<<3) /* Recovery */
|
||||
#define AVDT_PSC_HDRCMP (1<<5) /* Header compression */
|
||||
#define AVDT_PSC_MUX (1<<6) /* Multiplexing */
|
||||
#define AVDT_PSC_DELAY_RPT (1<<8) /* Delay Report */
|
||||
|
||||
/* Recovery type. This indicates the recovery type. */
|
||||
#define AVDT_RECOV_RFC2733 1 /* RFC2733 recovery */
|
||||
|
||||
/* Header compression capabilities. This indicates the header compression
|
||||
** capabilities. This value is a mask. Multiple values can be combined
|
||||
** with a bitwise OR.
|
||||
*/
|
||||
#define AVDT_HDRCMP_MEDIA (1<<5) /* Available for media packets */
|
||||
#define AVDT_HDRCMP_RECOV (1<<6) /* Available for recovery packets */
|
||||
#define AVDT_HDRCMP_BACKCH (1<<7) /* Back channel supported */
|
||||
|
||||
/* Multiplexing capabilities mask. */
|
||||
#define AVDT_MUX_FRAG (1<<7) /* Allow Adaptation Layer Fragmentation */
|
||||
|
||||
/* Application service category. This indicates the application
|
||||
** service category.
|
||||
*/
|
||||
#define AVDT_ASC_PROTECT 4 /* Content protection */
|
||||
#define AVDT_ASC_CODEC 7 /* Codec */
|
||||
|
||||
/* Error codes. The following are error codes defined in the AVDTP and GAVDP
|
||||
** specifications. These error codes communicate protocol errors between
|
||||
** AVDTP and the application. More detailed descriptions of the error codes
|
||||
** and their appropriate use can be found in the AVDTP and GAVDP specifications.
|
||||
** These error codes are unrelated to the result values returned by the
|
||||
** AVDTP API functions.
|
||||
*/
|
||||
#define AVDT_ERR_HEADER 0x01 /* Bad packet header format */
|
||||
#define AVDT_ERR_LENGTH 0x11 /* Bad packet length */
|
||||
#define AVDT_ERR_SEID 0x12 /* Invalid SEID */
|
||||
#define AVDT_ERR_IN_USE 0x13 /* The SEP is in use */
|
||||
#define AVDT_ERR_NOT_IN_USE 0x14 /* The SEP is not in use */
|
||||
#define AVDT_ERR_CATEGORY 0x17 /* Bad service category */
|
||||
#define AVDT_ERR_PAYLOAD 0x18 /* Bad payload format */
|
||||
#define AVDT_ERR_NSC 0x19 /* Requested command not supported */
|
||||
#define AVDT_ERR_INVALID_CAP 0x1A /* Reconfigure attempted invalid capabilities */
|
||||
#define AVDT_ERR_RECOV_TYPE 0x22 /* Requested recovery type not defined */
|
||||
#define AVDT_ERR_MEDIA_TRANS 0x23 /* Media transport capability not correct */
|
||||
#define AVDT_ERR_RECOV_FMT 0x25 /* Recovery service capability not correct */
|
||||
#define AVDT_ERR_ROHC_FMT 0x26 /* Header compression service capability not correct */
|
||||
#define AVDT_ERR_CP_FMT 0x27 /* Content protection service capability not correct */
|
||||
#define AVDT_ERR_MUX_FMT 0x28 /* Multiplexing service capability not correct */
|
||||
#define AVDT_ERR_UNSUP_CFG 0x29 /* Configuration not supported */
|
||||
#define AVDT_ERR_BAD_STATE 0x31 /* Message cannot be processed in this state */
|
||||
#define AVDT_ERR_REPORT_FMT 0x65 /* Report service capability not correct */
|
||||
#define AVDT_ERR_SERVICE 0x80 /* Invalid service category */
|
||||
#define AVDT_ERR_RESOURCE 0x81 /* Insufficient resources */
|
||||
#define AVDT_ERR_INVALID_MCT 0xC1 /* Invalid Media Codec Type */
|
||||
#define AVDT_ERR_UNSUP_MCT 0xC2 /* Unsupported Media Codec Type */
|
||||
#define AVDT_ERR_INVALID_LEVEL 0xC3 /* Invalid Level */
|
||||
#define AVDT_ERR_UNSUP_LEVEL 0xC4 /* Unsupported Level */
|
||||
#define AVDT_ERR_INVALID_CP 0xE0 /* Invalid Content Protection Type */
|
||||
#define AVDT_ERR_INVALID_FORMAT 0xE1 /* Invalid Content Protection format */
|
||||
|
||||
/* Additional error codes. This indicates error codes used by AVDTP
|
||||
** in addition to the ones defined in the specifications.
|
||||
*/
|
||||
#define AVDT_ERR_CONNECT 0x07 /* Connection failed. */
|
||||
#define AVDT_ERR_TIMEOUT 0x08 /* Response timeout. */
|
||||
|
||||
/* Control callback events. */
|
||||
#define AVDT_DISCOVER_CFM_EVT 0 /* Discover confirm */
|
||||
#define AVDT_GETCAP_CFM_EVT 1 /* Get capabilities confirm */
|
||||
#define AVDT_OPEN_CFM_EVT 2 /* Open confirm */
|
||||
#define AVDT_OPEN_IND_EVT 3 /* Open indication */
|
||||
#define AVDT_CONFIG_IND_EVT 4 /* Configuration indication */
|
||||
#define AVDT_START_CFM_EVT 5 /* Start confirm */
|
||||
#define AVDT_START_IND_EVT 6 /* Start indication */
|
||||
#define AVDT_SUSPEND_CFM_EVT 7 /* Suspend confirm */
|
||||
#define AVDT_SUSPEND_IND_EVT 8 /* Suspend indication */
|
||||
#define AVDT_CLOSE_CFM_EVT 9 /* Close confirm */
|
||||
#define AVDT_CLOSE_IND_EVT 10 /* Close indication */
|
||||
#define AVDT_RECONFIG_CFM_EVT 11 /* Reconfiguration confirm */
|
||||
#define AVDT_RECONFIG_IND_EVT 12 /* Reconfiguration indication */
|
||||
#define AVDT_SECURITY_CFM_EVT 13 /* Security confirm */
|
||||
#define AVDT_SECURITY_IND_EVT 14 /* Security indication */
|
||||
#define AVDT_WRITE_CFM_EVT 15 /* Write confirm */
|
||||
#define AVDT_CONNECT_IND_EVT 16 /* Signaling channel connected */
|
||||
#define AVDT_DISCONNECT_IND_EVT 17 /* Signaling channel disconnected */
|
||||
#define AVDT_REPORT_CONN_EVT 18 /* Reporting channel connected */
|
||||
#define AVDT_REPORT_DISCONN_EVT 19 /* Reporting channel disconnected */
|
||||
#define AVDT_DELAY_REPORT_EVT 20 /* Delay report received */
|
||||
#define AVDT_DELAY_REPORT_CFM_EVT 21 /* Delay report response received */
|
||||
|
||||
#define AVDT_MAX_EVT (AVDT_DELAY_REPORT_CFM_EVT)
|
||||
|
||||
/* PSM for AVDT */
|
||||
#define AVDT_PSM 0x0019
|
||||
|
||||
/* Nonsupported protocol command messages. This value is used in tAVDT_CS */
|
||||
#define AVDT_NSC_SUSPEND 0x01 /* Suspend command not supported */
|
||||
#define AVDT_NSC_RECONFIG 0x02 /* Reconfigure command not supported */
|
||||
#define AVDT_NSC_SECURITY 0x04 /* Security command not supported */
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
UINT32 ntp_sec; /* NTP time: seconds relative to 0h UTC on 1 January 1900 */
|
||||
UINT32 ntp_frac; /* NTP time: the fractional part */
|
||||
UINT32 rtp_time; /* timestamp in RTP header */
|
||||
UINT32 pkt_count; /* sender's packet count: since starting transmission
|
||||
* up until the time this SR packet was generated. */
|
||||
UINT32 octet_count; /* sender's octet count: same comment */
|
||||
} tAVDT_SENDER_INFO;
|
||||
|
||||
typedef struct {
|
||||
UINT8 frag_lost; /* fraction lost since last RR */
|
||||
UINT32 packet_lost; /* cumulative number of packets lost since the beginning */
|
||||
UINT32 seq_num_rcvd; /* extended highest sequence number received */
|
||||
UINT32 jitter; /* interarrival jitter */
|
||||
UINT32 lsr; /* last SR timestamp */
|
||||
UINT32 dlsr; /* delay since last SR */
|
||||
} tAVDT_REPORT_BLK;
|
||||
|
||||
typedef union {
|
||||
tAVDT_SENDER_INFO sr;
|
||||
tAVDT_REPORT_BLK rr;
|
||||
UINT8 cname[AVDT_MAX_CNAME_SIZE + 1];
|
||||
} tAVDT_REPORT_DATA;
|
||||
|
||||
/* This structure contains parameters which are set at registration. */
|
||||
typedef struct {
|
||||
UINT16 ctrl_mtu; /* L2CAP MTU of the AVDTP signaling channel */
|
||||
UINT8 ret_tout; /* AVDTP signaling retransmission timeout */
|
||||
UINT8 sig_tout; /* AVDTP signaling message timeout */
|
||||
UINT8 idle_tout; /* AVDTP idle signaling channel timeout */
|
||||
UINT8 sec_mask; /* Security mask for BTM_SetSecurityLevel() */
|
||||
} tAVDT_REG;
|
||||
|
||||
/* This structure contains the SEP information. This information is
|
||||
** transferred during the discovery procedure.
|
||||
*/
|
||||
typedef struct {
|
||||
BOOLEAN in_use; /* TRUE if stream is currently in use */
|
||||
UINT8 seid; /* Stream endpoint identifier */
|
||||
UINT8 media_type; /* Media type */
|
||||
UINT8 tsep; /* SEP type */
|
||||
} tAVDT_SEP_INFO;
|
||||
|
||||
/* This structure contains the SEP configuration. */
|
||||
typedef struct {
|
||||
UINT8 codec_info[AVDT_CODEC_SIZE]; /* Codec capabilities array */
|
||||
UINT8 protect_info[AVDT_PROTECT_SIZE]; /* Content protection capabilities */
|
||||
UINT8 num_codec; /* Number of media codec information elements */
|
||||
UINT8 num_protect; /* Number of content protection information elements */
|
||||
UINT16 psc_mask; /* Protocol service capabilities mask */
|
||||
UINT8 recov_type; /* Recovery type */
|
||||
UINT8 recov_mrws; /* Maximum recovery window size */
|
||||
UINT8 recov_mnmp; /* Recovery maximum number of media packets */
|
||||
UINT8 hdrcmp_mask; /* Header compression capabilities */
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
UINT8 mux_mask; /* Multiplexing capabilities. AVDT_MUX_XXX bits can be combined with a bitwise OR */
|
||||
UINT8 mux_tsid_media; /* TSID for media transport session */
|
||||
UINT8 mux_tcid_media; /* TCID for media transport session */
|
||||
UINT8 mux_tsid_report; /* TSID for reporting transport session */
|
||||
UINT8 mux_tcid_report; /* TCID for reporting transport session */
|
||||
UINT8 mux_tsid_recov; /* TSID for recovery transport session */
|
||||
UINT8 mux_tcid_recov; /* TCID for recovery transport session */
|
||||
#endif
|
||||
} tAVDT_CFG;
|
||||
|
||||
/* Header structure for callback event parameters. */
|
||||
typedef struct {
|
||||
UINT8 err_code; /* Zero if operation succeeded; nonzero if operation failed */
|
||||
UINT8 err_param; /* Error parameter included for some events */
|
||||
UINT8 label; /* Transaction label */
|
||||
UINT8 seid; /* For internal use only */
|
||||
UINT8 sig_id; /* For internal use only */
|
||||
UINT8 ccb_idx; /* For internal use only */
|
||||
} tAVDT_EVT_HDR;
|
||||
|
||||
/* This data structure is associated with the AVDT_GETCAP_CFM_EVT,
|
||||
** AVDT_RECONFIG_IND_EVT, and AVDT_RECONFIG_CFM_EVT.
|
||||
*/
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
tAVDT_CFG *p_cfg; /* Pointer to configuration for this SEP */
|
||||
} tAVDT_CONFIG;
|
||||
|
||||
/* This data structure is associated with the AVDT_CONFIG_IND_EVT. */
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
tAVDT_CFG *p_cfg; /* Pointer to configuration for this SEP */
|
||||
UINT8 int_seid; /* Stream endpoint ID of stream initiating the operation */
|
||||
} tAVDT_SETCONFIG;
|
||||
|
||||
/* This data structure is associated with the AVDT_OPEN_IND_EVT and AVDT_OPEN_CFM_EVT. */
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
UINT16 peer_mtu; /* Transport channel L2CAP MTU of the peer */
|
||||
UINT16 lcid; /* L2CAP LCID for media channel */
|
||||
} tAVDT_OPEN;
|
||||
|
||||
/* This data structure is associated with the AVDT_SECURITY_IND_EVT
|
||||
** and AVDT_SECURITY_CFM_EVT.
|
||||
*/
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
UINT8 *p_data; /* Pointer to security data */
|
||||
UINT16 len; /* Length in bytes of the security data */
|
||||
} tAVDT_SECURITY;
|
||||
|
||||
/* This data structure is associated with the AVDT_DISCOVER_CFM_EVT. */
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
tAVDT_SEP_INFO *p_sep_info; /* Pointer to SEP information */
|
||||
UINT8 num_seps; /* Number of stream endpoints */
|
||||
} tAVDT_DISCOVER;
|
||||
|
||||
/* This data structure is associated with the AVDT_DELAY_REPORT_EVT. */
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
UINT16 delay; /* Delay value */
|
||||
} tAVDT_DELAY_RPT;
|
||||
|
||||
/* Union of all control callback event data structures */
|
||||
typedef union {
|
||||
tAVDT_EVT_HDR hdr;
|
||||
tAVDT_DISCOVER discover_cfm;
|
||||
tAVDT_CONFIG getcap_cfm;
|
||||
tAVDT_OPEN open_cfm;
|
||||
tAVDT_OPEN open_ind;
|
||||
tAVDT_SETCONFIG config_ind;
|
||||
tAVDT_EVT_HDR start_cfm;
|
||||
tAVDT_EVT_HDR suspend_cfm;
|
||||
tAVDT_EVT_HDR close_cfm;
|
||||
tAVDT_CONFIG reconfig_cfm;
|
||||
tAVDT_CONFIG reconfig_ind;
|
||||
tAVDT_SECURITY security_cfm;
|
||||
tAVDT_SECURITY security_ind;
|
||||
tAVDT_EVT_HDR connect_ind;
|
||||
tAVDT_EVT_HDR disconnect_ind;
|
||||
tAVDT_EVT_HDR report_conn;
|
||||
tAVDT_DELAY_RPT delay_rpt_cmd;
|
||||
} tAVDT_CTRL;
|
||||
|
||||
/* This is the control callback function. This function passes control events
|
||||
** to the application. This function is required for all registered stream
|
||||
** endpoints and for the AVDT_DiscoverReq() and AVDT_GetCapReq() functions.
|
||||
**
|
||||
*/
|
||||
typedef void (tAVDT_CTRL_CBACK)(UINT8 handle, BD_ADDR bd_addr, UINT8 event,
|
||||
tAVDT_CTRL *p_data);
|
||||
|
||||
/* This is the data callback function. It is executed when AVDTP has a media
|
||||
** packet ready for the application. This function is required for SNK
|
||||
** endpoints and not applicable for SRC endpoints.
|
||||
*/
|
||||
typedef void (tAVDT_DATA_CBACK)(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
|
||||
UINT8 m_pt);
|
||||
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
/* This is the second version of the data callback function. This version uses
|
||||
** application buffer assigned by AVDT_SetMediaBuf. Caller can assign different
|
||||
** buffer during callback or can leave the current buffer for further using.
|
||||
** This callback is called when AVDTP has a media packet ready for the application.
|
||||
** This function is required for SNK endpoints and not applicable for SRC endpoints.
|
||||
*/
|
||||
typedef void (tAVDT_MEDIA_CBACK)(UINT8 handle, UINT8 *p_payload, UINT32 payload_len,
|
||||
UINT32 time_stamp, UINT16 seq_num, UINT8 m_pt, UINT8 marker);
|
||||
#endif
|
||||
|
||||
#if AVDT_REPORTING == TRUE
|
||||
/* This is the report callback function. It is executed when AVDTP has a reporting
|
||||
** packet ready for the application. This function is required for streams
|
||||
** created with AVDT_PSC_REPORT.
|
||||
*/
|
||||
typedef void (tAVDT_REPORT_CBACK)(UINT8 handle, AVDT_REPORT_TYPE type,
|
||||
tAVDT_REPORT_DATA *p_data);
|
||||
#endif
|
||||
|
||||
typedef UINT16 (tAVDT_GETCAP_REQ) (BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
/* This structure contains information required when a stream is created.
|
||||
** It is passed to the AVDT_CreateStream() function.
|
||||
*/
|
||||
typedef struct {
|
||||
tAVDT_CFG cfg; /* SEP configuration */
|
||||
tAVDT_CTRL_CBACK *p_ctrl_cback; /* Control callback function */
|
||||
tAVDT_DATA_CBACK *p_data_cback; /* Data callback function */
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
tAVDT_MEDIA_CBACK *p_media_cback; /* Media callback function. It will be called only if p_data_cback is NULL */
|
||||
#endif
|
||||
#if AVDT_REPORTING == TRUE
|
||||
tAVDT_REPORT_CBACK *p_report_cback;/* Report callback function. */
|
||||
#endif
|
||||
UINT16 mtu; /* The L2CAP MTU of the transport channel */
|
||||
UINT16 flush_to; /* The L2CAP flush timeout of the transport channel */
|
||||
UINT8 tsep; /* SEP type */
|
||||
UINT8 media_type; /* Media type */
|
||||
UINT16 nsc_mask; /* Nonsupported protocol command messages */
|
||||
} tAVDT_CS;
|
||||
|
||||
/* AVDT data option mask is used in the write request */
|
||||
#define AVDT_DATA_OPT_NONE 0x00 /* No option still add RTP header */
|
||||
#define AVDT_DATA_OPT_NO_RTP (0x01 << 0) /* Skip adding RTP header */
|
||||
|
||||
typedef UINT8 tAVDT_DATA_OPT_MASK;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_Register
|
||||
**
|
||||
** Description This is the system level registration function for the
|
||||
** AVDTP protocol. This function initializes AVDTP and
|
||||
** prepares the protocol stack for its use. This function
|
||||
** must be called once by the system or platform using AVDTP
|
||||
** before the other functions of the API an be used.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDT_Register(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_Deregister
|
||||
**
|
||||
** Description This function is called to deregister use AVDTP protocol.
|
||||
** It is called when AVDTP is no longer being used by any
|
||||
** application in the system. Before this function can be
|
||||
** called, all streams must be removed with AVDT_RemoveStream().
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDT_Deregister(void);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SINK_Activate
|
||||
**
|
||||
** Description Activate SEP of A2DP Sink. In Use parameter is adjusted.
|
||||
** In Use will be made false in case of activation. A2DP SRC
|
||||
** will receive in_use as false and can open A2DP Sink
|
||||
** connection
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDT_SINK_Activate(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SINK_Deactivate
|
||||
**
|
||||
** Description Deactivate SEP of A2DP Sink. In Use parameter is adjusted.
|
||||
** In Use will be made TRUE in case of activation. A2DP SRC
|
||||
** will receive in_use as true and will not open A2DP Sink
|
||||
** connection
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDT_SINK_Deactivate(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_AbortReq
|
||||
**
|
||||
** Description Trigger Abort request to pass AVDTP Abort related mandatory
|
||||
** PTS Test case.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDT_AbortReq(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_CreateStream
|
||||
**
|
||||
** Description Create a stream endpoint. After a stream endpoint is
|
||||
** created an application can initiate a connection between
|
||||
** this endpoint and an endpoint on a peer device. In
|
||||
** addition, a peer device can discover, get the capabilities,
|
||||
** and connect to this endpoint.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_CreateStream(UINT8 *p_handle, tAVDT_CS *p_cs);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_RemoveStream
|
||||
**
|
||||
** Description Remove a stream endpoint. This function is called when
|
||||
** the application is no longer using a stream endpoint.
|
||||
** If this function is called when the endpoint is connected
|
||||
** the connection is closed and then the stream endpoint
|
||||
** is removed.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_RemoveStream(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_DiscoverReq
|
||||
**
|
||||
** Description This function initiates a connection to the AVDTP service
|
||||
** on the peer device, if not already present, and discovers
|
||||
** the stream endpoints on the peer device. (Please note
|
||||
** that AVDTP discovery is unrelated to SDP discovery).
|
||||
** This function can be called at any time regardless of whether
|
||||
** there is an AVDTP connection to the peer device.
|
||||
**
|
||||
** When discovery is complete, an AVDT_DISCOVER_CFM_EVT
|
||||
** is sent to the application via its callback function.
|
||||
** The application must not call AVDT_GetCapReq() or
|
||||
** AVDT_DiscoverReq() again to the same device until
|
||||
** discovery is complete.
|
||||
**
|
||||
** The memory addressed by sep_info is allocated by the
|
||||
** application. This memory is written to by AVDTP as part
|
||||
** of the discovery procedure. This memory must remain
|
||||
** accessible until the application receives the
|
||||
** AVDT_DISCOVER_CFM_EVT.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_DiscoverReq(BD_ADDR bd_addr, tAVDT_SEP_INFO *p_sep_info,
|
||||
UINT8 max_seps, tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_GetCapReq
|
||||
**
|
||||
** Description This function initiates a connection to the AVDTP service
|
||||
** on the peer device, if not already present, and gets the
|
||||
** capabilities of a stream endpoint on the peer device.
|
||||
** This function can be called at any time regardless of
|
||||
** whether there is an AVDTP connection to the peer device.
|
||||
**
|
||||
** When the procedure is complete, an AVDT_GETCAP_CFM_EVT is
|
||||
** sent to the application via its callback function. The
|
||||
** application must not call AVDT_GetCapReq() or
|
||||
** AVDT_DiscoverReq() again until the procedure is complete.
|
||||
**
|
||||
** The memory pointed to by p_cfg is allocated by the
|
||||
** application. This memory is written to by AVDTP as part
|
||||
** of the get capabilities procedure. This memory must
|
||||
** remain accessible until the application receives
|
||||
** the AVDT_GETCAP_CFM_EVT.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_GetCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg,
|
||||
tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_GetAllCapReq
|
||||
**
|
||||
** Description This function initiates a connection to the AVDTP service
|
||||
** on the peer device, if not already present, and gets the
|
||||
** capabilities of a stream endpoint on the peer device.
|
||||
** This function can be called at any time regardless of
|
||||
** whether there is an AVDTP connection to the peer device.
|
||||
**
|
||||
** When the procedure is complete, an AVDT_GETCAP_CFM_EVT is
|
||||
** sent to the application via its callback function. The
|
||||
** application must not call AVDT_GetCapReq() or
|
||||
** AVDT_DiscoverReq() again until the procedure is complete.
|
||||
**
|
||||
** The memory pointed to by p_cfg is allocated by the
|
||||
** application. This memory is written to by AVDTP as part
|
||||
** of the get capabilities procedure. This memory must
|
||||
** remain accessible until the application receives
|
||||
** the AVDT_GETCAP_CFM_EVT.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_GetAllCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg,
|
||||
tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_DelayReport
|
||||
**
|
||||
** Description This functions sends a Delay Report to the peer device
|
||||
** that is associated with a particular SEID.
|
||||
** This function is called by SNK device.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_DelayReport(UINT8 handle, UINT8 seid, UINT16 delay);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_OpenReq
|
||||
**
|
||||
** Description This function initiates a connection to the AVDTP service
|
||||
** on the peer device, if not already present, and connects
|
||||
** to a stream endpoint on a peer device. When the connection
|
||||
** is completed, an AVDT_OPEN_CFM_EVT is sent to the
|
||||
** application via the control callback function for this handle.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_OpenReq(UINT8 handle, BD_ADDR bd_addr, UINT8 seid,
|
||||
tAVDT_CFG *p_cfg);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_ConfigRsp
|
||||
**
|
||||
** Description Respond to a configure request from the peer device. This
|
||||
** function must be called if the application receives an
|
||||
** AVDT_CONFIG_IND_EVT through its control callback.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_ConfigRsp(UINT8 handle, UINT8 label, UINT8 error_code,
|
||||
UINT8 category);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_StartReq
|
||||
**
|
||||
** Description Start one or more stream endpoints. This initiates the
|
||||
** transfer of media packets for the streams. All stream
|
||||
** endpoints must previously be opened. When the streams
|
||||
** are started, an AVDT_START_CFM_EVT is sent to the
|
||||
** application via the control callback function for each stream.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_StartReq(UINT8 *p_handles, UINT8 num_handles);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SuspendReq
|
||||
**
|
||||
** Description Suspend one or more stream endpoints. This suspends the
|
||||
** transfer of media packets for the streams. All stream
|
||||
** endpoints must previously be open and started. When the
|
||||
** streams are suspended, an AVDT_SUSPEND_CFM_EVT is sent to
|
||||
** the application via the control callback function for
|
||||
** each stream.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_SuspendReq(UINT8 *p_handles, UINT8 num_handles);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_CloseReq
|
||||
**
|
||||
** Description Close a stream endpoint. This stops the transfer of media
|
||||
** packets and closes the transport channel associated with
|
||||
** this stream endpoint. When the stream is closed, an
|
||||
** AVDT_CLOSE_CFM_EVT is sent to the application via the
|
||||
** control callback function for this handle.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_CloseReq(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_ReconfigReq
|
||||
**
|
||||
** Description Reconfigure a stream endpoint. This allows the application
|
||||
** to change the codec or content protection capabilities of
|
||||
** a stream endpoint after it has been opened. This function
|
||||
** can only be called if the stream is opened but not started
|
||||
** or if the stream has been suspended. When the procedure
|
||||
** is completed, an AVDT_RECONFIG_CFM_EVT is sent to the
|
||||
** application via the control callback function for this handle.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_ReconfigReq(UINT8 handle, tAVDT_CFG *p_cfg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_ReconfigRsp
|
||||
**
|
||||
** Description Respond to a reconfigure request from the peer device.
|
||||
** This function must be called if the application receives
|
||||
** an AVDT_RECONFIG_IND_EVT through its control callback.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_ReconfigRsp(UINT8 handle, UINT8 label, UINT8 error_code,
|
||||
UINT8 category);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SecurityReq
|
||||
**
|
||||
** Description Send a security request to the peer device. When the
|
||||
** security procedure is completed, an AVDT_SECURITY_CFM_EVT
|
||||
** is sent to the application via the control callback function
|
||||
** for this handle. (Please note that AVDTP security procedures
|
||||
** are unrelated to Bluetooth link level security.)
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_SecurityReq(UINT8 handle, UINT8 *p_data, UINT16 len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SecurityRsp
|
||||
**
|
||||
** Description Respond to a security request from the peer device.
|
||||
** This function must be called if the application receives
|
||||
** an AVDT_SECURITY_IND_EVT through its control callback.
|
||||
** (Please note that AVDTP security procedures are unrelated
|
||||
** to Bluetooth link level security.)
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_SecurityRsp(UINT8 handle, UINT8 label, UINT8 error_code,
|
||||
UINT8 *p_data, UINT16 len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_WriteReq
|
||||
**
|
||||
** Description Send a media packet to the peer device. The stream must
|
||||
** be started before this function is called. Also, this
|
||||
** function can only be called if the stream is a SRC.
|
||||
**
|
||||
** When AVDTP has sent the media packet and is ready for the
|
||||
** next packet, an AVDT_WRITE_CFM_EVT is sent to the
|
||||
** application via the control callback. The application must
|
||||
** wait for the AVDT_WRITE_CFM_EVT before it makes the next
|
||||
** call to AVDT_WriteReq(). If the applications calls
|
||||
** AVDT_WriteReq() before it receives the event the packet
|
||||
** will not be sent. The application may make its first call
|
||||
** to AVDT_WriteReq() after it receives an AVDT_START_CFM_EVT
|
||||
** or AVDT_START_IND_EVT.
|
||||
**
|
||||
** The application passes the packet using the BT_HDR structure.
|
||||
** This structure is described in section 2.1. The offset
|
||||
** field must be equal to or greater than AVDT_MEDIA_OFFSET.
|
||||
** This allows enough space in the buffer for the L2CAP and
|
||||
** AVDTP headers.
|
||||
**
|
||||
** The memory pointed to by p_pkt must be a GKI buffer
|
||||
** allocated by the application. This buffer will be freed
|
||||
** by the protocol stack; the application must not free
|
||||
** this buffer.
|
||||
**
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_WriteReq(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
|
||||
UINT8 m_pt);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_WriteReqOpt
|
||||
**
|
||||
** Description Send a media packet to the peer device. The stream must
|
||||
** be started before this function is called. Also, this
|
||||
** function can only be called if the stream is a SRC
|
||||
**
|
||||
** When AVDTP has sent the media packet and is ready for the
|
||||
** next packet, an AVDT_WRITE_CFM_EVT is sent to the
|
||||
** application via the control callback. The application must
|
||||
** wait for the AVDT_WRITE_CFM_EVT before it makes the next
|
||||
** call to AVDT_WriteReq(). If the applications calls
|
||||
** AVDT_WriteReq() before it receives the event the packet
|
||||
** will not be sent. The application may make its first call
|
||||
** to AVDT_WriteReq() after it receives an AVDT_START_CFM_EVT
|
||||
** or AVDT_START_IND_EVT.
|
||||
**
|
||||
** The application passes the packet using the BT_HDR structure
|
||||
** This structure is described in section 2.1. The offset
|
||||
** field must be equal to or greater than AVDT_MEDIA_OFFSET
|
||||
** (if NO_RTP is specified, L2CAP_MIN_OFFSET can be used)
|
||||
** This allows enough space in the buffer for the L2CAP and
|
||||
** AVDTP headers.
|
||||
**
|
||||
** The memory pointed to by p_pkt must be a GKI buffer
|
||||
** allocated by the application. This buffer will be freed
|
||||
** by the protocol stack; the application must not free
|
||||
** this buffer.
|
||||
**
|
||||
** The opt parameter allows passing specific options like:
|
||||
** - NO_RTP : do not add the RTP header to buffer
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
|
||||
UINT8 m_pt, tAVDT_DATA_OPT_MASK opt);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_ConnectReq
|
||||
**
|
||||
** Description This function initiates an AVDTP signaling connection
|
||||
** to the peer device. When the connection is completed, an
|
||||
** AVDT_CONNECT_IND_EVT is sent to the application via its
|
||||
** control callback function. If the connection attempt fails
|
||||
** an AVDT_DISCONNECT_IND_EVT is sent. The security mask
|
||||
** parameter overrides the outgoing security mask set in
|
||||
** AVDT_Register().
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_ConnectReq(BD_ADDR bd_addr, UINT8 sec_mask,
|
||||
tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_DisconnectReq
|
||||
**
|
||||
** Description This function disconnect an AVDTP signaling connection
|
||||
** to the peer device. When disconnected an
|
||||
** AVDT_DISCONNECT_IND_EVT is sent to the application via its
|
||||
** control callback function.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_DisconnectReq(BD_ADDR bd_addr, tAVDT_CTRL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_GetL2CapChannel
|
||||
**
|
||||
** Description Get the L2CAP CID used by the handle.
|
||||
**
|
||||
** Returns CID if successful, otherwise 0.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_GetL2CapChannel(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_GetSignalChannel
|
||||
**
|
||||
** Description Get the L2CAP CID used by the signal channel of the given handle.
|
||||
**
|
||||
** Returns CID if successful, otherwise 0.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_WriteDataReq
|
||||
**
|
||||
** Description Send a media packet to the peer device. The stream must
|
||||
** be started before this function is called. Also, this
|
||||
** function can only be called if the stream is a SRC.
|
||||
**
|
||||
** When AVDTP has sent the media packet and is ready for the
|
||||
** next packet, an AVDT_WRITE_CFM_EVT is sent to the
|
||||
** application via the control callback. The application must
|
||||
** wait for the AVDT_WRITE_CFM_EVT before it makes the next
|
||||
** call to AVDT_WriteDataReq(). If the applications calls
|
||||
** AVDT_WriteDataReq() before it receives the event the packet
|
||||
** will not be sent. The application may make its first call
|
||||
** to AVDT_WriteDataReq() after it receives an
|
||||
** AVDT_START_CFM_EVT or AVDT_START_IND_EVT.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len,
|
||||
UINT32 time_stamp, UINT8 m_pt, UINT8 marker);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SetMediaBuf
|
||||
**
|
||||
** Description Assigns buffer for media packets or forbids using of assigned
|
||||
** buffer if argument p_buf is NULL. This function can only
|
||||
** be called if the stream is a SNK.
|
||||
**
|
||||
** AVDTP uses this buffer to reassemble fragmented media packets.
|
||||
** When AVDTP receives a complete media packet, it calls the
|
||||
** p_media_cback assigned by AVDT_CreateStream().
|
||||
** This function can be called during callback to assign a
|
||||
** different buffer for next media packet or can leave the current
|
||||
** buffer for next packet.
|
||||
**
|
||||
** Returns AVDT_SUCCESS if successful, otherwise error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDT_SendReport
|
||||
**
|
||||
** Description
|
||||
**
|
||||
**
|
||||
**
|
||||
** Returns
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
|
||||
tAVDT_REPORT_DATA *p_data);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVDT_SetTraceLevel
|
||||
**
|
||||
** Description Sets the trace level for AVDT. If 0xff is passed, the
|
||||
** current trace level is returned.
|
||||
**
|
||||
** Input Parameters:
|
||||
** new_level: The level to set the AVDT tracing to:
|
||||
** 0xff-returns the current setting.
|
||||
** 0-turns off tracing.
|
||||
** >= 1-Errors.
|
||||
** >= 2-Warnings.
|
||||
** >= 3-APIs.
|
||||
** >= 4-Events.
|
||||
** >= 5-Debug.
|
||||
**
|
||||
** Returns The new trace level or current trace level if
|
||||
** the input parameter is 0xff.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT8 AVDT_SetTraceLevel (UINT8 new_level);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* AVDT_API_H */
|
203
tools/sdk/include/bluedroid/avdt_defs.h
Executable file
203
tools/sdk/include/bluedroid/avdt_defs.h
Executable file
@ -0,0 +1,203 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-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 contains constants definitions and other information from the AVDTP
|
||||
* specification. This file is intended for use internal to AVDT only.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef AVDT_DEFS_H
|
||||
#define AVDT_DEFS_H
|
||||
|
||||
/*****************************************************************************
|
||||
** constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* signalling packet type */
|
||||
#define AVDT_PKT_TYPE_SINGLE 0 /* single packet */
|
||||
#define AVDT_PKT_TYPE_START 1 /* start packet */
|
||||
#define AVDT_PKT_TYPE_CONT 2 /* continue packet */
|
||||
#define AVDT_PKT_TYPE_END 3 /* end packet */
|
||||
|
||||
/* signalling message type */
|
||||
#define AVDT_MSG_TYPE_CMD 0 /* command */
|
||||
#define AVDT_MSG_TYPE_GRJ 1 /* general reject */
|
||||
#define AVDT_MSG_TYPE_RSP 2 /* response accept */
|
||||
#define AVDT_MSG_TYPE_REJ 3 /* response reject */
|
||||
|
||||
/* signalling messages */
|
||||
#define AVDT_SIG_DISCOVER 1 /* discover */
|
||||
#define AVDT_SIG_GETCAP 2 /* get capabilities */
|
||||
#define AVDT_SIG_SETCONFIG 3 /* set configuration */
|
||||
#define AVDT_SIG_GETCONFIG 4 /* get configuration */
|
||||
#define AVDT_SIG_RECONFIG 5 /* reconfigure */
|
||||
#define AVDT_SIG_OPEN 6 /* open */
|
||||
#define AVDT_SIG_START 7 /* start */
|
||||
#define AVDT_SIG_CLOSE 8 /* close */
|
||||
#define AVDT_SIG_SUSPEND 9 /* suspend */
|
||||
#define AVDT_SIG_ABORT 10 /* abort */
|
||||
#define AVDT_SIG_SECURITY 11 /* security control */
|
||||
#define AVDT_SIG_GET_ALLCAP 12 /* get all capabilities */
|
||||
#define AVDT_SIG_DELAY_RPT 13 /* delay report */
|
||||
|
||||
/* maximum signal value */
|
||||
#define AVDT_SIG_MAX AVDT_SIG_DELAY_RPT
|
||||
|
||||
/* used for general reject */
|
||||
#define AVDT_SIG_NONE 0
|
||||
|
||||
/* some maximum and minimum sizes of signalling messages */
|
||||
#define AVDT_DISCOVER_REQ_MIN 1
|
||||
#define AVDT_DISCOVER_REQ_MAX 124
|
||||
|
||||
/* service category information element field values */
|
||||
#define AVDT_CAT_TRANS 1 /* Media Transport */
|
||||
#define AVDT_CAT_REPORT 2 /* Reporting */
|
||||
#define AVDT_CAT_RECOV 3 /* Recovery */
|
||||
#define AVDT_CAT_PROTECT 4 /* Content Protection */
|
||||
#define AVDT_CAT_HDRCMP 5 /* Header Compression */
|
||||
#define AVDT_CAT_MUX 6 /* Multiplexing */
|
||||
#define AVDT_CAT_CODEC 7 /* Media Codec */
|
||||
#define AVDT_CAT_DELAY_RPT 8 /* Delay Reporting */
|
||||
#define AVDT_CAT_MAX_CUR AVDT_CAT_DELAY_RPT
|
||||
|
||||
/* min/max lengths of service category information elements */
|
||||
#define AVDT_LEN_TRANS_MIN 0
|
||||
#define AVDT_LEN_REPORT_MIN 0
|
||||
#define AVDT_LEN_RECOV_MIN 3
|
||||
#define AVDT_LEN_PROTECT_MIN 2
|
||||
#define AVDT_LEN_HDRCMP_MIN 1
|
||||
#define AVDT_LEN_MUX_MIN 3
|
||||
#define AVDT_LEN_CODEC_MIN 2
|
||||
#define AVDT_LEN_DELAY_RPT_MIN 0
|
||||
|
||||
#define AVDT_LEN_TRANS_MAX 0
|
||||
#define AVDT_LEN_REPORT_MAX 0
|
||||
#define AVDT_LEN_RECOV_MAX 3
|
||||
#define AVDT_LEN_PROTECT_MAX 255
|
||||
#define AVDT_LEN_HDRCMP_MAX 1
|
||||
#define AVDT_LEN_MUX_MAX 7
|
||||
#define AVDT_LEN_CODEC_MAX 255
|
||||
#define AVDT_LEN_DELAY_RPT_MAX 0
|
||||
|
||||
/* minimum possible size of configuration or capabilities data */
|
||||
#define AVDT_LEN_CFG_MIN 2
|
||||
|
||||
/* minimum and maximum lengths for different message types */
|
||||
#define AVDT_LEN_SINGLE 1
|
||||
#define AVDT_LEN_SETCONFIG_MIN 2
|
||||
#define AVDT_LEN_RECONFIG_MIN 1
|
||||
#define AVDT_LEN_MULTI_MIN 1
|
||||
#define AVDT_LEN_SECURITY_MIN 1
|
||||
#define AVDT_LEN_DELAY_RPT 3
|
||||
|
||||
/* header lengths for different packet types */
|
||||
#define AVDT_LEN_TYPE_SINGLE 2 /* single packet */
|
||||
#define AVDT_LEN_TYPE_START 3 /* start packet */
|
||||
#define AVDT_LEN_TYPE_CONT 1 /* continue packet */
|
||||
#define AVDT_LEN_TYPE_END 1 /* end packet */
|
||||
|
||||
/* length of general reject message */
|
||||
#define AVDT_LEN_GEN_REJ 2
|
||||
|
||||
/* recovery service capabilities information elements */
|
||||
#define AVDT_RECOV_MRWS_MIN 0x01 /* min value for maximum recovery window */
|
||||
#define AVDT_RECOV_MRWS_MAX 0x18 /* max value for maximum recovery window */
|
||||
#define AVDT_RECOV_MNMP_MIN 0x01 /* min value for maximum number of media packets */
|
||||
#define AVDT_RECOV_MNMP_MAX 0x18 /* max value for maximum number of media packets */
|
||||
|
||||
/* SEID value range */
|
||||
#define AVDT_SEID_MIN 0x01
|
||||
#define AVDT_SEID_MAX 0x3E
|
||||
|
||||
/* first byte of media packet header */
|
||||
#define AVDT_MEDIA_OCTET1 0x80
|
||||
|
||||
/* for adaptation layer header */
|
||||
#define AVDT_ALH_LCODE_MASK 0x03 /* coding of length field */
|
||||
#define AVDT_ALH_LCODE_NONE 0x00 /* No length field present. Take length from l2cap */
|
||||
#define AVDT_ALH_LCODE_16BIT 0x01 /* 16bit length field */
|
||||
#define AVDT_ALH_LCODE_9BITM0 0x02 /* 9 bit length field, MSB = 0, 8 LSBs in 1 octet following */
|
||||
#define AVDT_ALH_LCODE_9BITM1 0x03 /* 9 bit length field, MSB = 1, 8 LSBs in 1 octet following */
|
||||
|
||||
#define AVDT_ALH_FRAG_MASK 0x04 /* set this for continuation packet */
|
||||
|
||||
/*****************************************************************************
|
||||
** message parsing and building macros
|
||||
*****************************************************************************/
|
||||
|
||||
#define AVDT_MSG_PRS_HDR(p, lbl, pkt, msg) \
|
||||
lbl = *(p) >> 4; \
|
||||
pkt = (*(p) >> 2) & 0x03; \
|
||||
msg = *(p)++ & 0x03;
|
||||
|
||||
#define AVDT_MSG_PRS_DISC(p, seid, in_use, type, tsep) \
|
||||
seid = *(p) >> 2; \
|
||||
in_use = (*(p)++ >> 1) & 0x01; \
|
||||
type = *(p) >> 4; \
|
||||
tsep = (*(p)++ >> 3) & 0x01;
|
||||
|
||||
#define AVDT_MSG_PRS_SIG(p, sig) \
|
||||
sig = *(p)++ & 0x3F;
|
||||
|
||||
#define AVDT_MSG_PRS_SEID(p, seid) \
|
||||
seid = *(p)++ >> 2;
|
||||
|
||||
#define AVDT_MSG_PRS_PKT_TYPE(p, pkt) \
|
||||
pkt = (*(p) >> 2) & 0x03;
|
||||
|
||||
#define AVDT_MSG_PRS_OCTET1(p, o_v, o_p, o_x, o_cc) \
|
||||
o_v = *(p) >> 6; \
|
||||
o_p = (*(p) >> 5) & 0x01; \
|
||||
o_x = (*(p) >> 4) & 0x01; \
|
||||
o_cc = *(p)++ & 0x0F;
|
||||
|
||||
#define AVDT_MSG_PRS_RPT_OCTET1(p, o_v, o_p, o_cc) \
|
||||
o_v = *(p) >> 6; \
|
||||
o_p = (*(p) >> 5) & 0x01; \
|
||||
o_cc = *(p)++ & 0x1F;
|
||||
|
||||
#define AVDT_MSG_PRS_M_PT(p, m_pt, marker) \
|
||||
marker = *(p) >> 7; \
|
||||
m_pt = *(p)++ & 0x7F;
|
||||
|
||||
#define AVDT_MSG_BLD_HDR(p, lbl, pkt, msg) \
|
||||
*(p)++ = (UINT8) ((lbl) << 4) | ((pkt) << 2) | (msg);
|
||||
|
||||
#define AVDT_MSG_BLD_DISC(p, seid, in_use, type, tsep) \
|
||||
*(p)++ = (UINT8) (((seid) << 2) | ((in_use) << 1)); \
|
||||
*(p)++ = (UINT8) (((type) << 4) | ((tsep) << 3));
|
||||
|
||||
#define AVDT_MSG_BLD_SIG(p, sig) \
|
||||
*(p)++ = (UINT8) (sig);
|
||||
|
||||
#define AVDT_MSG_BLD_SEID(p, seid) \
|
||||
*(p)++ = (UINT8) ((seid) << 2);
|
||||
|
||||
#define AVDT_MSG_BLD_ERR(p, err) \
|
||||
*(p)++ = (UINT8) (err);
|
||||
|
||||
#define AVDT_MSG_BLD_PARAM(p, param) \
|
||||
*(p)++ = (UINT8) (param);
|
||||
|
||||
#define AVDT_MSG_BLD_NOSP(p, nosp) \
|
||||
*(p)++ = (UINT8) (nosp);
|
||||
|
||||
#endif /* AVDT_DEFS_H */
|
||||
|
230
tools/sdk/include/bluedroid/avdtc_api.h
Executable file
230
tools/sdk/include/bluedroid/avdtc_api.h
Executable file
@ -0,0 +1,230 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-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 interface file contains the interface AVDTP conformance API. These
|
||||
* additional API functions and callback events are provided for
|
||||
* conformance testing purposes only. They are not intended to be used by
|
||||
* an application.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef AVDT_CAPI_H
|
||||
#define AVDT_CAPI_H
|
||||
|
||||
#include "avdt_api.h"
|
||||
|
||||
/* start AVDTC events here to distinguish from AVDT events */
|
||||
#define AVDTC_EVT_BEGIN 0x80
|
||||
|
||||
#define AVDTC_DISCOVER_IND_EVT (0 + AVDTC_EVT_BEGIN) /* Discover indication */
|
||||
#define AVDTC_GETCAP_IND_EVT (1 + AVDTC_EVT_BEGIN) /* Get capabilities indication */
|
||||
#define AVDTC_SETCONFIG_CFM_EVT (2 + AVDTC_EVT_BEGIN) /* Set configuration confirm */
|
||||
#define AVDTC_GETCONFIG_IND_EVT (3 + AVDTC_EVT_BEGIN) /* Get configuration indication */
|
||||
#define AVDTC_GETCONFIG_CFM_EVT (4 + AVDTC_EVT_BEGIN) /* Get configuration confirm */
|
||||
#define AVDTC_OPEN_IND_EVT (5 + AVDTC_EVT_BEGIN) /* Open indication */
|
||||
#define AVDTC_START_IND_EVT (6 + AVDTC_EVT_BEGIN) /* Start indication */
|
||||
#define AVDTC_CLOSE_IND_EVT (7 + AVDTC_EVT_BEGIN) /* Close indication */
|
||||
#define AVDTC_SUSPEND_IND_EVT (8 + AVDTC_EVT_BEGIN) /* Suspend indication */
|
||||
#define AVDTC_ABORT_IND_EVT (9 + AVDTC_EVT_BEGIN) /* Abort indication */
|
||||
#define AVDTC_ABORT_CFM_EVT (10 + AVDTC_EVT_BEGIN) /* Abort confirm */
|
||||
|
||||
typedef struct {
|
||||
tAVDT_EVT_HDR hdr; /* Event header */
|
||||
UINT8 seid_list[AVDT_NUM_SEPS]; /* Array of SEID values */
|
||||
UINT8 num_seps; /* Number of values in array */
|
||||
} tAVDT_MULTI;
|
||||
|
||||
/* Union of all control callback event data structures */
|
||||
typedef union {
|
||||
tAVDT_EVT_HDR hdr;
|
||||
tAVDT_CONFIG getconfig_cfm;
|
||||
tAVDT_MULTI start_ind;
|
||||
tAVDT_MULTI suspend_ind;
|
||||
} tAVDTC_CTRL;
|
||||
|
||||
typedef void tAVDTC_CTRL_CBACK(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDTC_CTRL *p_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_Init
|
||||
**
|
||||
** Description This function is called to begin using the conformance API.
|
||||
** It must be called after AVDT_Register() and before any
|
||||
** other API or conformance API functions are called.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_Init(tAVDTC_CTRL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_DiscoverRsp
|
||||
**
|
||||
** Description Send a discover response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_DiscoverRsp(BD_ADDR bd_addr, UINT8 label,
|
||||
tAVDT_SEP_INFO sep_info[], UINT8 num_seps);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_GetCapRsp
|
||||
**
|
||||
** Description Send a get capabilities response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_GetCapRsp(BD_ADDR bd_addr, UINT8 label, tAVDT_CFG *p_cap);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_GetAllCapRsp
|
||||
**
|
||||
** Description Send a get all capabilities response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_GetAllCapRsp(BD_ADDR bd_addr, UINT8 label, tAVDT_CFG *p_cap);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_GetConfigReq
|
||||
**
|
||||
** Description Send a get configuration request.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_GetConfigReq(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_GetConfigRsp
|
||||
**
|
||||
** Description Send a get configuration response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_GetConfigRsp(UINT8 handle, UINT8 label, tAVDT_CFG *p_cfg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_OpenReq
|
||||
**
|
||||
** Description Send an open request.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_OpenReq(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_OpenRsp
|
||||
**
|
||||
** Description Send an open response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_OpenRsp(UINT8 handle, UINT8 label);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_StartRsp
|
||||
**
|
||||
** Description Send a start response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_StartRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 label);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_CloseRsp
|
||||
**
|
||||
** Description Send a close response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_CloseRsp(UINT8 handle, UINT8 label);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_SuspendRsp
|
||||
**
|
||||
** Description Send a suspend response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_SuspendRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 label);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_AbortReq
|
||||
**
|
||||
** Description Send an abort request.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_AbortReq(UINT8 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_AbortRsp
|
||||
**
|
||||
** Description Send an abort response.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_AbortRsp(UINT8 handle, UINT8 label);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVDTC_Rej
|
||||
**
|
||||
** Description Send a reject message.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVDTC_Rej(UINT8 handle, BD_ADDR bd_addr, UINT8 cmd, UINT8 label,
|
||||
UINT8 err_code, UINT8 err_param);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AVDT_CAPI_H */
|
637
tools/sdk/include/bluedroid/avrc_api.h
Normal file
637
tools/sdk/include/bluedroid/avrc_api.h
Normal file
@ -0,0 +1,637 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* nterface to AVRCP Application Programming Interface
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef AVRC_API_H
|
||||
#define AVRC_API_H
|
||||
#include "bt_target.h"
|
||||
#include "avct_api.h"
|
||||
#include "sdp_api.h"
|
||||
#include "avrc_defs.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* API function return value result codes. */
|
||||
#define AVRC_SUCCESS AVCT_SUCCESS /* 0 Function successful */
|
||||
#define AVRC_NO_RESOURCES AVCT_NO_RESOURCES /* 1 Not enough resources */
|
||||
#define AVRC_BAD_HANDLE AVCT_BAD_HANDLE /* 2 Bad handle */
|
||||
#define AVRC_PID_IN_USE AVCT_PID_IN_USE /* 3 PID already in use */
|
||||
#define AVRC_NOT_OPEN AVCT_NOT_OPEN /* 4 Connection not open */
|
||||
#define AVRC_MSG_TOO_BIG 5 /* 5 the message length exceed the MTU of the browsing channel */
|
||||
#define AVRC_FAIL 0x10 /* 0x10 generic failure */
|
||||
#define AVRC_BAD_PARAM 0x11 /* 0x11 bad parameter */
|
||||
|
||||
/* Control role - same as AVCT_TARGET/AVCT_CONTROL */
|
||||
#define AVRC_CT_TARGET 1 /* target */
|
||||
#define AVRC_CT_CONTROL 2 /* controller */
|
||||
#define AVRC_CT_PASSIVE 4 /* If conflict, allow the other side to succeed */
|
||||
|
||||
/* Connection role */
|
||||
#define AVRC_CONN_INT AVCT_INT /* initiator */
|
||||
#define AVRC_CONN_ACP AVCT_ACP /* Acceptor */
|
||||
|
||||
|
||||
/* AVRC CTRL events */
|
||||
/* AVRC_OPEN_IND_EVT event is sent when the connection is successfully opened.
|
||||
* This eventis sent in response to an AVRC_Open(). */
|
||||
#define AVRC_OPEN_IND_EVT 0
|
||||
|
||||
/* AVRC_CLOSE_IND_EVT event is sent when a connection is closed.
|
||||
* This event can result from a call to AVRC_Close() or when the peer closes
|
||||
* the connection. It is also sent when a connection attempted through
|
||||
* AVRC_Open() fails. */
|
||||
#define AVRC_CLOSE_IND_EVT 1
|
||||
|
||||
/* AVRC_CONG_IND_EVT event indicates that AVCTP is congested and cannot send
|
||||
* any more messages. */
|
||||
#define AVRC_CONG_IND_EVT 2
|
||||
|
||||
/* AVRC_UNCONG_IND_EVT event indicates that AVCTP is uncongested and ready to
|
||||
* send messages. */
|
||||
#define AVRC_UNCONG_IND_EVT 3
|
||||
|
||||
/* AVRC_BROWSE_OPEN_IND_EVT event is sent when the browse channel is successfully opened.
|
||||
* This eventis sent in response to an AVRC_Open() or AVRC_OpenBrowse() . */
|
||||
#define AVRC_BROWSE_OPEN_IND_EVT 4
|
||||
|
||||
/* AVRC_BROWSE_CLOSE_IND_EVT event is sent when a browse channel is closed.
|
||||
* This event can result from a call to AVRC_Close(), AVRC_CloseBrowse() or when the peer closes
|
||||
* the connection. It is also sent when a connection attempted through
|
||||
* AVRC_OpenBrowse() fails. */
|
||||
#define AVRC_BROWSE_CLOSE_IND_EVT 5
|
||||
|
||||
/* AVRC_BROWSE_CONG_IND_EVT event indicates that AVCTP browse channel is congested and cannot send
|
||||
* any more messages. */
|
||||
#define AVRC_BROWSE_CONG_IND_EVT 6
|
||||
|
||||
/* AVRC_BROWSE_UNCONG_IND_EVT event indicates that AVCTP browse channel is uncongested and ready to
|
||||
* send messages. */
|
||||
#define AVRC_BROWSE_UNCONG_IND_EVT 7
|
||||
|
||||
/* AVRC_CMD_TIMEOUT_EVT event indicates timeout waiting for AVRC command response from the peer */
|
||||
#define AVRC_CMD_TIMEOUT_EVT 8
|
||||
|
||||
/* Supported categories */
|
||||
#define AVRC_SUPF_CT_CAT1 0x0001 /* Category 1 */
|
||||
#define AVRC_SUPF_CT_CAT2 0x0002 /* Category 2 */
|
||||
#define AVRC_SUPF_CT_CAT3 0x0004 /* Category 3 */
|
||||
#define AVRC_SUPF_CT_CAT4 0x0008 /* Category 4 */
|
||||
#define AVRC_SUPF_CT_BROWSE 0x0040 /* Browsing */
|
||||
|
||||
#define AVRC_SUPF_TG_CAT1 0x0001 /* Category 1 */
|
||||
#define AVRC_SUPF_TG_CAT2 0x0002 /* Category 2 */
|
||||
#define AVRC_SUPF_TG_CAT3 0x0004 /* Category 3 */
|
||||
#define AVRC_SUPF_TG_CAT4 0x0008 /* Category 4 */
|
||||
#define AVRC_SUPF_TG_APP_SETTINGS 0x0010 /* Player Application Settings */
|
||||
#define AVRC_SUPF_TG_GROUP_NAVI 0x0020 /* Group Navigation */
|
||||
#define AVRC_SUPF_TG_BROWSE 0x0040 /* Browsing */
|
||||
#define AVRC_SUPF_TG_MULTI_PLAYER 0x0080 /* Muliple Media Player */
|
||||
|
||||
#define AVRC_META_SUCCESS AVRC_SUCCESS
|
||||
#define AVRC_META_FAIL AVRC_FAIL
|
||||
#define AVRC_METADATA_CMD 0x0000
|
||||
#define AVRC_METADATA_RESP 0x0001
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** data type definitions
|
||||
*****************************************************************************/
|
||||
|
||||
/* This data type is used in AVRC_FindService() to initialize the SDP database
|
||||
* to hold the result service search. */
|
||||
typedef struct {
|
||||
UINT32 db_len; /* Length, in bytes, of the discovery database */
|
||||
tSDP_DISCOVERY_DB *p_db; /* Pointer to the discovery database */
|
||||
UINT16 num_attr;/* The number of attributes in p_attrs */
|
||||
UINT16 *p_attrs; /* The attributes filter. If NULL, AVRCP API sets the attribute filter
|
||||
* to be ATTR_ID_SERVICE_CLASS_ID_LIST, ATTR_ID_BT_PROFILE_DESC_LIST,
|
||||
* ATTR_ID_SUPPORTED_FEATURES, ATTR_ID_SERVICE_NAME and ATTR_ID_PROVIDER_NAME.
|
||||
* If not NULL, the input is taken as the filter. */
|
||||
} tAVRC_SDP_DB_PARAMS;
|
||||
|
||||
/* This callback function returns service discovery information to the
|
||||
* application after the AVRC_FindService() API function is called. The
|
||||
* implementation of this callback function must copy the p_service_name
|
||||
* and p_provider_name parameters passed to it as they are not guaranteed
|
||||
* to remain after the callback function exits. */
|
||||
typedef void (tAVRC_FIND_CBACK) (UINT16 status);
|
||||
|
||||
|
||||
/* This is the control callback function. This function passes events
|
||||
* listed in Table 20 to the application. */
|
||||
typedef void (tAVRC_CTRL_CBACK) (UINT8 handle, UINT8 event, UINT16 result,
|
||||
BD_ADDR peer_addr);
|
||||
|
||||
|
||||
/* This is the message callback function. It is executed when AVCTP has
|
||||
* a message packet ready for the application. The implementation of this
|
||||
* callback function must copy the tAVRC_MSG structure passed to it as it
|
||||
* is not guaranteed to remain after the callback function exits. */
|
||||
typedef void (tAVRC_MSG_CBACK) (UINT8 handle, UINT8 label, UINT8 opcode,
|
||||
tAVRC_MSG *p_msg);
|
||||
|
||||
typedef struct {
|
||||
tAVRC_CTRL_CBACK *p_ctrl_cback; /* pointer to application control callback */
|
||||
tAVRC_MSG_CBACK *p_msg_cback; /* pointer to application message callback */
|
||||
UINT32 company_id; /* the company ID */
|
||||
UINT8 conn; /* Connection role (Initiator/acceptor) */
|
||||
UINT8 control; /* Control role (Control/Target) */
|
||||
} tAVRC_CONN_CB;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** external function declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_AddRecord
|
||||
**
|
||||
** Description This function is called to build an AVRCP SDP record.
|
||||
** Prior to calling this function the application must
|
||||
** call SDP_CreateRecord() to create an SDP record.
|
||||
**
|
||||
** Input Parameters:
|
||||
** service_uuid: Indicates TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET)
|
||||
** or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL)
|
||||
**
|
||||
** p_service_name: Pointer to a null-terminated character
|
||||
** string containing the service name.
|
||||
** If service name is not used set this to NULL.
|
||||
**
|
||||
** p_provider_name: Pointer to a null-terminated character
|
||||
** string containing the provider name.
|
||||
** If provider name is not used set this to NULL.
|
||||
**
|
||||
** categories: Supported categories.
|
||||
**
|
||||
** sdp_handle: SDP handle returned by SDP_CreateRecord().
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_NO_RESOURCES if not enough resources to build the SDP record.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name,
|
||||
char *p_provider_name, UINT16 categories, UINT32 sdp_handle);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_FindService
|
||||
**
|
||||
** Description This function is called by the application to perform service
|
||||
** discovery and retrieve AVRCP SDP record information from a
|
||||
** peer device. Information is returned for the first service
|
||||
** record found on the server that matches the service UUID.
|
||||
** The callback function will be executed when service discovery
|
||||
** is complete. There can only be one outstanding call to
|
||||
** AVRC_FindService() at a time; the application must wait for
|
||||
** the callback before it makes another call to the function.
|
||||
** The application is responsible for allocating memory for the
|
||||
** discovery database. It is recommended that the size of the
|
||||
** discovery database be at least 300 bytes. The application
|
||||
** can deallocate the memory after the callback function has
|
||||
** executed.
|
||||
**
|
||||
** Input Parameters:
|
||||
** service_uuid: Indicates TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET)
|
||||
** or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL)
|
||||
**
|
||||
** bd_addr: BD address of the peer device.
|
||||
**
|
||||
** p_db: SDP discovery database parameters.
|
||||
**
|
||||
** p_cback: Pointer to the callback function.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_PARAMS if discovery database parameters are invalid.
|
||||
** AVRC_NO_RESOURCES if there are not enough resources to
|
||||
** perform the service search.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
|
||||
tAVRC_SDP_DB_PARAMS *p_db, tAVRC_FIND_CBACK *p_cback);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_Open
|
||||
**
|
||||
** Description This function is called to open a connection to AVCTP.
|
||||
** The connection can be either an initiator or acceptor, as
|
||||
** determined by the p_ccb->stream parameter.
|
||||
** The connection can be a target, a controller or for both role,
|
||||
** as determined by the p_ccb->control parameter.
|
||||
** By definition, a target connection is an acceptor connection
|
||||
** that waits for an incoming AVCTP connection from the peer.
|
||||
** The connection remains available to the application until
|
||||
** the application closes it by calling AVRC_Close(). The
|
||||
** application does not need to reopen the connection after an
|
||||
** AVRC_CLOSE_IND_EVT is received.
|
||||
**
|
||||
** Input Parameters:
|
||||
** p_ccb->company_id: Company Identifier.
|
||||
**
|
||||
** p_ccb->p_ctrl_cback: Pointer to control callback function.
|
||||
**
|
||||
** p_ccb->p_msg_cback: Pointer to message callback function.
|
||||
**
|
||||
** p_ccb->conn: AVCTP connection role. This is set to
|
||||
** AVCTP_INT for initiator connections and AVCTP_ACP
|
||||
** for acceptor connections.
|
||||
**
|
||||
** p_ccb->control: Control role. This is set to
|
||||
** AVRC_CT_TARGET for target connections, AVRC_CT_CONTROL
|
||||
** for control connections or (AVRC_CT_TARGET|AVRC_CT_CONTROL)
|
||||
** for connections that support both roles.
|
||||
**
|
||||
** peer_addr: BD address of peer device. This value is
|
||||
** only used for initiator connections; for acceptor
|
||||
** connections it can be set to NULL.
|
||||
**
|
||||
** Output Parameters:
|
||||
** p_handle: Pointer to handle. This parameter is only
|
||||
** valid if AVRC_SUCCESS is returned.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_NO_RESOURCES if there are not enough resources to open
|
||||
** the connection.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_Open(UINT8 *p_handle, tAVRC_CONN_CB *p_ccb,
|
||||
BD_ADDR_PTR peer_addr);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_Close
|
||||
**
|
||||
** Description Close a connection opened with AVRC_Open().
|
||||
** This function is called when the
|
||||
** application is no longer using a connection.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_Close(UINT8 handle);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_OpenBrowse
|
||||
**
|
||||
** Description This function is called to open a browsing connection to AVCTP.
|
||||
** The connection can be either an initiator or acceptor, as
|
||||
** determined by the conn_role.
|
||||
** The handle is returned by a previous call to AVRC_Open.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_NO_RESOURCES if there are not enough resources to open
|
||||
** the connection.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_OpenBrowse(UINT8 handle, UINT8 conn_role);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_CloseBrowse
|
||||
**
|
||||
** Description Close a connection opened with AVRC_OpenBrowse().
|
||||
** This function is called when the
|
||||
** application is no longer using a connection.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_CloseBrowse(UINT8 handle);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_MsgReq
|
||||
**
|
||||
** Description This function is used to send the AVRCP byte stream in p_pkt
|
||||
** down to AVCTP.
|
||||
**
|
||||
** It is expected that p_pkt->offset is at least AVCT_MSG_OFFSET
|
||||
** p_pkt->layer_specific is AVCT_DATA_CTRL or AVCT_DATA_BROWSE
|
||||
** p_pkt->event is AVRC_OP_VENDOR, AVRC_OP_PASS_THRU or AVRC_OP_BROWSING
|
||||
** The above BT_HDR settings are set by the AVRC_Bld* functions.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_UnitCmd
|
||||
**
|
||||
** Description Send a UNIT INFO command to the peer device. This
|
||||
** function can only be called for controller role connections.
|
||||
** Any response message from the peer is passed back through
|
||||
** the tAVRC_MSG_CBACK callback function.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** label: Transaction label.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_UnitCmd(UINT8 handle, UINT8 label);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_SubCmd
|
||||
**
|
||||
** Description Send a SUBUNIT INFO command to the peer device. This
|
||||
** function can only be called for controller role connections.
|
||||
** Any response message from the peer is passed back through
|
||||
** the tAVRC_MSG_CBACK callback function.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** label: Transaction label.
|
||||
**
|
||||
** page: Specifies which part of the subunit type table
|
||||
** is requested. For AVRCP it is typically zero.
|
||||
** Value range is 0-7.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_SubCmd(UINT8 handle, UINT8 label, UINT8 page);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_PassCmd
|
||||
**
|
||||
** Description Send a PASS THROUGH command to the peer device. This
|
||||
** function can only be called for controller role connections.
|
||||
** Any response message from the peer is passed back through
|
||||
** the tAVRC_MSG_CBACK callback function.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** label: Transaction label.
|
||||
**
|
||||
** p_msg: Pointer to PASS THROUGH message structure.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_PassCmd(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_PassRsp
|
||||
**
|
||||
** Description Send a PASS THROUGH response to the peer device. This
|
||||
** function can only be called for target role connections.
|
||||
** This function must be called when a PASS THROUGH command
|
||||
** message is received from the peer through the
|
||||
** tAVRC_MSG_CBACK callback function.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** label: Transaction label. Must be the same value as
|
||||
** passed with the command message in the callback function.
|
||||
**
|
||||
** p_msg: Pointer to PASS THROUGH message structure.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_PassRsp(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_VendorCmd
|
||||
**
|
||||
** Description Send a VENDOR DEPENDENT command to the peer device. This
|
||||
** function can only be called for controller role connections.
|
||||
** Any response message from the peer is passed back through
|
||||
** the tAVRC_MSG_CBACK callback function.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** label: Transaction label.
|
||||
**
|
||||
** p_msg: Pointer to VENDOR DEPENDENT message structure.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_VendorCmd(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_VendorRsp
|
||||
**
|
||||
** Description Send a VENDOR DEPENDENT response to the peer device. This
|
||||
** function can only be called for target role connections.
|
||||
** This function must be called when a VENDOR DEPENDENT
|
||||
** command message is received from the peer through the
|
||||
** tAVRC_MSG_CBACK callback function.
|
||||
**
|
||||
** Input Parameters:
|
||||
** handle: Handle of this connection.
|
||||
**
|
||||
** label: Transaction label. Must be the same value as
|
||||
** passed with the command message in the callback function.
|
||||
**
|
||||
** p_msg: Pointer to VENDOR DEPENDENT message structure.
|
||||
**
|
||||
** Output Parameters:
|
||||
** None.
|
||||
**
|
||||
** Returns AVRC_SUCCESS if successful.
|
||||
** AVRC_BAD_HANDLE if handle is invalid.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_VendorRsp(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function AVRC_SetTraceLevel
|
||||
**
|
||||
** Description Sets the trace level for AVRC. If 0xff is passed, the
|
||||
** current trace level is returned.
|
||||
**
|
||||
** Input Parameters:
|
||||
** new_level: The level to set the AVRC tracing to:
|
||||
** 0xff-returns the current setting.
|
||||
** 0-turns off tracing.
|
||||
** >= 1-Errors.
|
||||
** >= 2-Warnings.
|
||||
** >= 3-APIs.
|
||||
** >= 4-Events.
|
||||
** >= 5-Debug.
|
||||
**
|
||||
** Returns The new trace level or current trace level if
|
||||
** the input parameter is 0xff.
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT8 AVRC_SetTraceLevel (UINT8 new_level);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVRC_Init
|
||||
**
|
||||
** Description This function is called at stack startup to allocate the
|
||||
** control block (if using dynamic memory), and initializes the
|
||||
** control block and tracing level.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void AVRC_Init(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVRC_ParsCommand
|
||||
**
|
||||
** Description This function is used to parse the received command.
|
||||
**
|
||||
** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
|
||||
** Otherwise, the error code defined by AVRCP 1.4
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tAVRC_STS AVRC_ParsCommand (tAVRC_MSG *p_msg, tAVRC_COMMAND *p_result,
|
||||
UINT8 *p_buf, UINT16 buf_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVRC_ParsResponse
|
||||
**
|
||||
** Description This function is used to parse the received response.
|
||||
**
|
||||
** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
|
||||
** Otherwise, the error code defined by AVRCP 1.4
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tAVRC_STS AVRC_ParsResponse (tAVRC_MSG *p_msg, tAVRC_RESPONSE *p_result,
|
||||
UINT8 *p_buf, UINT16 buf_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVRC_BldCommand
|
||||
**
|
||||
** Description This function builds the given AVRCP command to the given
|
||||
** GKI buffer
|
||||
**
|
||||
** Returns AVRC_STS_NO_ERROR, if the command is built successfully
|
||||
** Otherwise, the error code.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVRC_BldResponse
|
||||
**
|
||||
** Description This function builds the given AVRCP response to the given
|
||||
** GKI buffer
|
||||
**
|
||||
** Returns AVRC_STS_NO_ERROR, if the response is built successfully
|
||||
** Otherwise, the error code.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt);
|
||||
|
||||
/**************************************************************************
|
||||
**
|
||||
** Function AVRC_IsValidAvcType
|
||||
**
|
||||
** Description Check if correct AVC type is specified
|
||||
**
|
||||
** Returns returns TRUE if it is valid
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function AVRC_IsValidPlayerAttr
|
||||
**
|
||||
** Description Check if the given attrib value is a valid one
|
||||
**
|
||||
**
|
||||
** Returns returns TRUE if it is valid
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN AVRC_IsValidPlayerAttr(UINT8 attr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AVRC_API_H */
|
1360
tools/sdk/include/bluedroid/avrc_defs.h
Normal file
1360
tools/sdk/include/bluedroid/avrc_defs.h
Normal file
File diff suppressed because it is too large
Load Diff
63
tools/sdk/include/bluedroid/bdaddr.h
Executable file
63
tools/sdk/include/bluedroid/bdaddr.h
Executable file
@ -0,0 +1,63 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _BDADDR_H_
|
||||
#define _BDADDR_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "bt_defs.h"
|
||||
#include "hash_map.h"
|
||||
|
||||
// Note: the string representation of a bdaddr is expected to have the format
|
||||
// xx:xx:xx:xx:xx:xx
|
||||
// where each 'x' is a hex digit. The API presented in this header will accept
|
||||
// both uppercase and lowercase digits but will only ever produce lowercase
|
||||
// digits.
|
||||
|
||||
// Returns true if |addr| is the empty address (00:00:00:00:00:00).
|
||||
// |addr| may not be NULL.
|
||||
bool bdaddr_is_empty(const bt_bdaddr_t *addr);
|
||||
|
||||
// Returns true if |first| and |second| refer to the same address. Neither
|
||||
// may be NULL.
|
||||
bool bdaddr_equals(const bt_bdaddr_t *first, const bt_bdaddr_t *second);
|
||||
|
||||
// Returns destination bdaddr |dest| after copying |src| to |dest|.
|
||||
// |dest| and |src| must not be NULL.
|
||||
bt_bdaddr_t *bdaddr_copy(bt_bdaddr_t *dest, const bt_bdaddr_t *src);
|
||||
|
||||
// Makes a string representation of |addr| and places it into |string|. |size|
|
||||
// refers to the size of |string|'s buffer and must be >= 18. On success, this
|
||||
// function returns |string|, otherwise it returns NULL. Neither |addr| nor |string|
|
||||
// may be NULL.
|
||||
const char *bdaddr_to_string(const bt_bdaddr_t *addr, char *string, size_t size);
|
||||
|
||||
// Returns true if |string| represents a Bluetooth address. |string| may not be NULL.
|
||||
bool string_is_bdaddr(const char *string);
|
||||
|
||||
// Converts |string| to bt_bdaddr_t and places it in |addr|. If |string| does not
|
||||
// represent a Bluetooth address, |addr| is not modified and this function returns
|
||||
// false. Otherwise, it returns true. Neither |string| nor |addr| may be NULL.
|
||||
bool string_to_bdaddr(const char *string, bt_bdaddr_t *addr);
|
||||
|
||||
// A hash function tailored for bdaddrs.
|
||||
hash_index_t hash_function_bdaddr(const void *key);
|
||||
|
||||
#endif
|
176
tools/sdk/include/bluedroid/blufi_int.h
Normal file
176
tools/sdk/include/bluedroid/blufi_int.h
Normal file
@ -0,0 +1,176 @@
|
||||
// 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 __BLUFI_INT_H__
|
||||
#define __BLUFI_INT_H__
|
||||
|
||||
#define BTC_BLUFI_GREAT_VER 0x01 //Version + Subversion
|
||||
#define BTC_BLUFI_SUB_VER 0x00 //Version + Subversion
|
||||
#define BTC_BLUFI_VERSION ((BTC_BLUFI_GREAT_VER<<8)|BTC_BLUFI_SUB_VER) //Version + Subversion
|
||||
|
||||
/* service engine control block */
|
||||
typedef struct {
|
||||
/* Protocol reference */
|
||||
tGATT_IF gatt_if;
|
||||
UINT8 srvc_inst;
|
||||
UINT16 handle_srvc;
|
||||
UINT16 handle_char_p2e;
|
||||
UINT16 handle_char_e2p;
|
||||
UINT16 handle_descr_e2p;
|
||||
UINT16 conn_id;
|
||||
BOOLEAN is_connected;
|
||||
BD_ADDR remote_bda;
|
||||
UINT32 trans_id;
|
||||
UINT8 congest;
|
||||
#define BLUFI_PREPAIR_BUF_MAX_SIZE 1024
|
||||
uint8_t *prepare_buf;
|
||||
int prepare_len;
|
||||
/* Control reference */
|
||||
esp_blufi_callbacks_t *cbs;
|
||||
BOOLEAN enabled;
|
||||
uint8_t send_seq;
|
||||
uint8_t recv_seq;
|
||||
uint8_t sec_mode;
|
||||
uint8_t *aggr_buf;
|
||||
uint16_t total_len;
|
||||
uint16_t offset;
|
||||
} tBLUFI_ENV;
|
||||
|
||||
/* BLUFI protocol */
|
||||
struct blufi_hdr{
|
||||
uint8_t type;
|
||||
uint8_t fc;
|
||||
uint8_t seq;
|
||||
uint8_t data_len;
|
||||
uint8_t data[0];
|
||||
};
|
||||
typedef struct blufi_hdr blufi_hd_t;
|
||||
|
||||
struct blufi_frag_hdr {
|
||||
uint8_t type;
|
||||
uint8_t fc;
|
||||
uint8_t seq;
|
||||
uint8_t data_len;
|
||||
uint16_t total_len;
|
||||
uint8_t content[0];
|
||||
};
|
||||
typedef struct blufi_frag_hdr blufi_frag_hdr_t;
|
||||
|
||||
#define BLUFI_DATA_SEC_MODE_CHECK_MASK 0x01
|
||||
#define BLUFI_DATA_SEC_MODE_ENC_MASK 0x02
|
||||
#define BLUFI_CTRL_SEC_MODE_CHECK_MASK 0x10
|
||||
#define BLUFI_CTRL_SEC_MODE_ENC_MASK 0x20
|
||||
|
||||
// packet type
|
||||
#define BLUFI_TYPE_MASK 0x03
|
||||
#define BLUFI_TYPE_SHIFT 0
|
||||
#define BLUFI_SUBTYPE_MASK 0xFC
|
||||
#define BLUFI_SUBTYPE_SHIFT 2
|
||||
|
||||
#define BLUFI_GET_TYPE(type) ((type) & BLUFI_TYPE_MASK)
|
||||
#define BLUFI_GET_SUBTYPE(type) (((type) & BLUFI_SUBTYPE_MASK) >>BLUFI_SUBTYPE_SHIFT)
|
||||
#define BLUFI_BUILD_TYPE(type, subtype) (((type) & BLUFI_TYPE_MASK) | ((subtype)<<BLUFI_SUBTYPE_SHIFT))
|
||||
|
||||
#define BLUFI_TYPE_CTRL 0x0
|
||||
#define BLUFI_TYPE_CTRL_SUBTYPE_ACK 0x00
|
||||
#define BLUFI_TYPE_CTRL_SUBTYPE_SET_SEC_MODE 0x01
|
||||
#define BLUFI_TYPE_CTRL_SUBTYPE_SET_WIFI_OPMODE 0x02
|
||||
#define BLUFI_TYPE_CTRL_SUBTYPE_CONN_TO_AP 0x03
|
||||
#define BLUFI_TYPE_CTRL_SUBTYPE_DISCONN_FROM_AP 0x04
|
||||
#define BLUFI_TYPE_CTRL_SUBTYPE_GET_WIFI_STATUS 0x05
|
||||
#define BLUFI_TYPE_CTRL_SUBTYPE_DEAUTHENTICATE_STA 0x06
|
||||
#define BLUFI_TYPE_CTRL_SUBTYPE_GET_VERSION 0x07
|
||||
|
||||
#define BLUFI_TYPE_DATA 0x1
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_NEG 0x00
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_STA_BSSID 0x01
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_STA_SSID 0x02
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_STA_PASSWD 0x03
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_SOFTAP_SSID 0x04
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_SOFTAP_PASSWD 0x05
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_SOFTAP_MAX_CONN_NUM 0x06
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_SOFTAP_AUTH_MODE 0x07
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_SOFTAP_CHANNEL 0x08
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_USERNAME 0x09
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_CA 0x0a
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_CLIENT_CERT 0x0b
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_SERVER_CERT 0x0c
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_CLIENT_PRIV_KEY 0x0d
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_SERVER_PRIV_KEY 0x0e
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_WIFI_REP 0x0f
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_REPLY_VERSION 0x10
|
||||
#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)
|
||||
|
||||
#define BLUFI_TYPE_IS_CTRL_ACK(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_ACK)
|
||||
#define BLUFI_TYPE_IS_CTRL_START_NEG(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_START_NEG)
|
||||
#define BLUFI_TYPE_IS_CTRL_STOP_NEG(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_STOP_NEG)
|
||||
#define BLUFI_TYPE_IS_CTRL_SET_WIFI_OPMODE(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_SET_WIFI_OPMODE)
|
||||
#define BLUFI_TYPE_IS_CTRL_CONN_WIFI(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_CONN_TO_AP)
|
||||
#define BLUFI_TYPE_IS_CTRL_DISCONN_WIFI(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_DISCONN_FROM_AP)
|
||||
#define BLUFI_TYPE_IS_CTRL_GET_WIFI_STATUS(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_GET_WIFI_STATUS)
|
||||
#define BLUFI_TYPE_IS_CTRL_DEAUTHENTICATE_STA(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_DEAUTHENTICATE_STA)
|
||||
#define BLUFI_TYPE_IS_CTRL_GET_VERSION(type) (BLUFI_TYPE_IS_CTRL((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_CTRL_SUBTYPE_GET_VERSION)
|
||||
|
||||
#define BLUFI_TYPE_IS_DATA_NEG(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_NEG)
|
||||
#define BLUFI_TYPE_IS_DATA_STA_BSSID(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_STA_BSSID)
|
||||
#define BLUFI_TYPE_IS_DATA_STA_SSID(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_STA_SSID)
|
||||
#define BLUFI_TYPE_IS_DATA_STA_PASSWD(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_STA_PASSWD)
|
||||
#define BLUFI_TYPE_IS_DATA_SOFTAP_SSID(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_SOFTAP_SSID)
|
||||
#define BLUFI_TYPE_IS_DATA_SOFTAP_PASSWD(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_SOFTAP_PASSWD)
|
||||
#define BLUFI_TYPE_IS_DATA_SOFTAP_MAX_CONN_NUM(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_SOFTAP_MAX_CONN_NUM)
|
||||
#define BLUFI_TYPE_IS_DATA_SOFTAP_AUTH_MODE(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_SOFTAP_AUTH_MODE)
|
||||
#define BLUFI_TYPE_IS_DATA_SOFTAP_CHANNEL(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_SOFTAP_CHANNEL)
|
||||
#define BLUFI_TYPE_IS_DATA_USERNAME(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_USERNAME)
|
||||
#define BLUFI_TYPE_IS_DATA_CA(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_CA)
|
||||
#define BLUFI_TYPE_IS_DATA_CLEINT_CERT(type) (BLUFI_TYPE_IS_DATA((type)) && BLUFI_GET_SUBTYPE((type)) == BLUFI_TYPE_DATA_SUBTYPE_CLIENT_CERT)
|
||||
#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)
|
||||
|
||||
// packet frame control
|
||||
#define BLUFI_FC_ENC_MASK 0x01
|
||||
#define BLUFI_FC_CHECK_MASK 0x02
|
||||
#define BLUFI_FC_DIR_MASK 0x04
|
||||
#define BLUFI_FC_REQ_ACK_MASK 0x08
|
||||
#define BLUFI_FC_FRAG_MASK 0x10
|
||||
|
||||
#define BLUFI_FC_ENC 0x01
|
||||
#define BLUFI_FC_CHECK 0x02
|
||||
#define BLUFI_FC_DIR_P2E 0x00
|
||||
#define BLUFI_FC_DIR_E2P 0x04
|
||||
#define BLUFI_FC_REQ_ACK 0x08
|
||||
#define BLUFI_FC_FRAG 0x10
|
||||
|
||||
#define BLUFI_FC_IS_ENC(fc) ((fc) & BLUFI_FC_ENC_MASK)
|
||||
#define BLUFI_FC_IS_CHECK(fc) ((fc) & BLUFI_FC_CHECK_MASK)
|
||||
#define BLUFI_FC_IS_DIR_P2E(fc) ((fc) & BLUFI_FC_DIR_P2E_MASK)
|
||||
#define BLUFI_FC_IS_DIR_E2P(fc) (!((fc) & BLUFI_DIR_P2E_MASK))
|
||||
#define BLUFI_FC_IS_REQ_ACK(fc) ((fc) & BLUFI_FC_REQ_ACK_MASK)
|
||||
#define BLUFI_FC_IS_FRAG(fc) ((fc) & BLUFI_FC_FRAG_MASK)
|
||||
|
||||
#define BLUFI_FRAG_DATA_MAX_LEN 50
|
||||
|
||||
//function declare
|
||||
void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len);
|
||||
|
||||
void btc_blufi_send_encap(uint8_t type, uint8_t *data, int data_len);
|
||||
|
||||
void btc_blufi_set_callbacks(esp_blufi_callbacks_t *callbacks);
|
||||
|
||||
void btc_blufi_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_blufi_cb_deep_free(btc_msg_t *msg);
|
||||
|
||||
#endif /* __BLUFI_INT_H__ */
|
43
tools/sdk/include/bluedroid/bt_common_types.h
Executable file
43
tools/sdk/include/bluedroid/bt_common_types.h
Executable file
@ -0,0 +1,43 @@
|
||||
// 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 _BT_COMMON_TYPES_H_
|
||||
#define _BT_COMMON_TYPES_H_
|
||||
|
||||
#include "bt_defs.h"
|
||||
#include "thread.h"
|
||||
|
||||
typedef void (* bluedroid_init_done_cb_t)(void);
|
||||
|
||||
typedef struct {
|
||||
uint8_t client_if;
|
||||
uint8_t filt_index;
|
||||
uint8_t advertiser_state;
|
||||
uint8_t advertiser_info_present;
|
||||
uint8_t addr_type;
|
||||
uint8_t tx_power;
|
||||
int8_t rssi_value;
|
||||
uint16_t time_stamp;
|
||||
bt_bdaddr_t bd_addr;
|
||||
uint8_t adv_pkt_len;
|
||||
uint8_t *p_adv_pkt_data;
|
||||
uint8_t scan_rsp_len;
|
||||
uint8_t *p_scan_rsp_data;
|
||||
} btgatt_track_adv_info_t;
|
||||
|
||||
#endif
|
155
tools/sdk/include/bluedroid/bt_defs.h
Normal file
155
tools/sdk/include/bluedroid/bt_defs.h
Normal file
@ -0,0 +1,155 @@
|
||||
// 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.
|
||||
|
||||
/**
|
||||
* bt_defs.h Defines useful API for whole Bluedroid
|
||||
*
|
||||
*/
|
||||
#ifndef _BT_DEFS_H_
|
||||
#define _BT_DEFS_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "bt_trace.h"
|
||||
|
||||
#include "osi_arch.h"
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX 254
|
||||
#endif
|
||||
/*Timer Related Defination*/
|
||||
|
||||
#define alarm_timer_t uint32_t
|
||||
#define alarm_timer_setfn(timer, cb, data) \
|
||||
do { \
|
||||
} while (0)
|
||||
#define alarm_timer_arm(timer, to, periodic) \
|
||||
do { \
|
||||
} while (0)
|
||||
#define alarm_timer_disarm(timer) \
|
||||
do { \
|
||||
} while (0)
|
||||
#define alarm_timer_now() (0)
|
||||
|
||||
|
||||
/*Thread and locker related defination*/
|
||||
#define RTOS_SUPPORT
|
||||
#ifdef RTOS_SUPPORT
|
||||
#define pthread_mutex_t osi_mutex_t
|
||||
#define pthread_mutex_init(mutex, a) osi_mutex_new(mutex)
|
||||
#define pthread_mutex_destroy(mutex) osi_mutex_free(mutex)
|
||||
#define pthread_mutex_lock osi_mutex_lock
|
||||
#define pthread_mutex_unlock osi_mutex_unlock
|
||||
#else
|
||||
#define pthread_mutex_t uint8_t
|
||||
#define pthread_mutex_init(x1, x2)
|
||||
#define pthread_mutex_destroy(mutex)
|
||||
#define pthread_mutex_lock(mutex)
|
||||
#define pthread_mutex_unlock(mutex)
|
||||
#endif
|
||||
|
||||
|
||||
/*Bluetooth Address*/
|
||||
typedef struct {
|
||||
uint8_t address[6];
|
||||
} __attribute__ ((__packed__)) bt_bdaddr_t;
|
||||
|
||||
/** Bluetooth 128-bit UUID */
|
||||
typedef struct {
|
||||
uint8_t uu[16];
|
||||
} bt_uuid_t;
|
||||
|
||||
/** Bluetooth Error Status */
|
||||
/** We need to build on this */
|
||||
|
||||
typedef enum {
|
||||
BT_STATUS_SUCCESS,
|
||||
BT_STATUS_FAIL,
|
||||
BT_STATUS_NOT_READY,
|
||||
BT_STATUS_NOMEM,
|
||||
BT_STATUS_BUSY,
|
||||
BT_STATUS_DONE, /* request already completed */
|
||||
BT_STATUS_UNSUPPORTED,
|
||||
BT_STATUS_PARM_INVALID,
|
||||
BT_STATUS_UNHANDLED,
|
||||
BT_STATUS_AUTH_FAILURE,
|
||||
BT_STATUS_RMT_DEV_DOWN,
|
||||
BT_STATUS_AUTH_REJECTED
|
||||
} bt_status_t;
|
||||
|
||||
#ifndef CPU_LITTLE_ENDIAN
|
||||
#define CPU_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
inline uint16_t swap_byte_16(uint16_t x)
|
||||
{
|
||||
return (((x & 0x00ffU) << 8) |
|
||||
((x & 0xff00U) >> 8));
|
||||
}
|
||||
|
||||
inline uint32_t swap_byte_32(uint32_t x)
|
||||
{
|
||||
return (((x & 0x000000ffUL) << 24) |
|
||||
((x & 0x0000ff00UL) << 8) |
|
||||
((x & 0x00ff0000UL) >> 8) |
|
||||
((x & 0xff000000UL) >> 24));
|
||||
}
|
||||
|
||||
#ifndef ntohs
|
||||
inline uint16_t ntohs(uint16_t x)
|
||||
{
|
||||
#ifdef CPU_LITTLE_ENDIAN
|
||||
return swap_byte_16(x);
|
||||
#else
|
||||
return x;
|
||||
#endif
|
||||
}
|
||||
#endif /* #ifndef ntohs */
|
||||
|
||||
#ifndef htons
|
||||
inline uint16_t htons(uint16_t x)
|
||||
{
|
||||
#ifdef CPU_LITTLE_ENDIAN
|
||||
return swap_byte_16(x);
|
||||
#else
|
||||
return x;
|
||||
#endif
|
||||
}
|
||||
#endif /* #ifndef htons */
|
||||
|
||||
#ifndef ntohl
|
||||
inline uint32_t ntohl(uint32_t x)
|
||||
{
|
||||
#ifdef CPU_LITTLE_ENDIAN
|
||||
return swap_byte_32(x);
|
||||
#else
|
||||
return x;
|
||||
#endif
|
||||
}
|
||||
#endif /* #ifndef ntohl*/
|
||||
|
||||
#ifndef htonl
|
||||
inline uint32_t htonl(uint32_t x)
|
||||
{
|
||||
#ifdef CPU_LITTLE_ENDIAN
|
||||
return swap_byte_32(x);
|
||||
#else
|
||||
return x;
|
||||
#endif
|
||||
}
|
||||
#endif /* #ifndef htonl*/
|
||||
|
||||
#endif /* _BT_DEFS_H_ */
|
111
tools/sdk/include/bluedroid/bt_sdp.h
Executable file
111
tools/sdk/include/bluedroid/bt_sdp.h
Executable file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* 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 __BT_SDP_H__
|
||||
#define __BT_SDP_H__
|
||||
|
||||
#include <stdint.h>
|
||||
// #include "bluetooth.h"
|
||||
#include "bt_defs.h"
|
||||
|
||||
#define SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH 15
|
||||
|
||||
/**
|
||||
* These events are handled by the state machine
|
||||
*/
|
||||
typedef enum {
|
||||
SDP_TYPE_RAW, // Used to carry raw SDP search data for unknown UUIDs
|
||||
SDP_TYPE_MAP_MAS, // Message Access Profile - Server
|
||||
SDP_TYPE_MAP_MNS, // Message Access Profile - Client (Notification Server)
|
||||
SDP_TYPE_PBAP_PSE, // Phone Book Profile - Server
|
||||
SDP_TYPE_PBAP_PCE, // Phone Book Profile - Client
|
||||
SDP_TYPE_OPP_SERVER, // Object Push Profile
|
||||
SDP_TYPE_SAP_SERVER // SIM Access Profile
|
||||
} bluetooth_sdp_types;
|
||||
|
||||
typedef struct _bluetooth_sdp_hdr {
|
||||
bluetooth_sdp_types type;
|
||||
bt_uuid_t uuid;
|
||||
uint32_t service_name_length;
|
||||
char *service_name;
|
||||
int32_t rfcomm_channel_number;
|
||||
int32_t l2cap_psm;
|
||||
int32_t profile_version;
|
||||
} bluetooth_sdp_hdr;
|
||||
|
||||
/**
|
||||
* Some signals need additional pointers, hence we introduce a
|
||||
* generic way to handle these pointers.
|
||||
*/
|
||||
typedef struct _bluetooth_sdp_hdr_overlay {
|
||||
bluetooth_sdp_types type;
|
||||
bt_uuid_t uuid;
|
||||
uint32_t service_name_length;
|
||||
char *service_name;
|
||||
int32_t rfcomm_channel_number;
|
||||
int32_t l2cap_psm;
|
||||
int32_t profile_version;
|
||||
|
||||
// User pointers, only used for some signals - see bluetooth_sdp_ops_record
|
||||
int user1_ptr_len;
|
||||
uint8_t *user1_ptr;
|
||||
int user2_ptr_len;
|
||||
uint8_t *user2_ptr;
|
||||
} bluetooth_sdp_hdr_overlay;
|
||||
|
||||
typedef struct _bluetooth_sdp_mas_record {
|
||||
bluetooth_sdp_hdr_overlay hdr;
|
||||
uint32_t mas_instance_id;
|
||||
uint32_t supported_features;
|
||||
uint32_t supported_message_types;
|
||||
} bluetooth_sdp_mas_record;
|
||||
|
||||
typedef struct _bluetooth_sdp_mns_record {
|
||||
bluetooth_sdp_hdr_overlay hdr;
|
||||
uint32_t supported_features;
|
||||
} bluetooth_sdp_mns_record;
|
||||
|
||||
typedef struct _bluetooth_sdp_pse_record {
|
||||
bluetooth_sdp_hdr_overlay hdr;
|
||||
uint32_t supported_features;
|
||||
uint32_t supported_repositories;
|
||||
} bluetooth_sdp_pse_record;
|
||||
|
||||
typedef struct _bluetooth_sdp_pce_record {
|
||||
bluetooth_sdp_hdr_overlay hdr;
|
||||
} bluetooth_sdp_pce_record;
|
||||
|
||||
typedef struct _bluetooth_sdp_ops_record {
|
||||
bluetooth_sdp_hdr_overlay hdr;
|
||||
int supported_formats_list_len;
|
||||
uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH];
|
||||
} bluetooth_sdp_ops_record;
|
||||
|
||||
typedef struct _bluetooth_sdp_sap_record {
|
||||
bluetooth_sdp_hdr_overlay hdr;
|
||||
} bluetooth_sdp_sap_record;
|
||||
|
||||
typedef union {
|
||||
bluetooth_sdp_hdr_overlay hdr;
|
||||
bluetooth_sdp_mas_record mas;
|
||||
bluetooth_sdp_mns_record mns;
|
||||
bluetooth_sdp_pse_record pse;
|
||||
bluetooth_sdp_pce_record pce;
|
||||
bluetooth_sdp_ops_record ops;
|
||||
bluetooth_sdp_sap_record sap;
|
||||
} bluetooth_sdp_record;
|
||||
|
||||
#endif /* __BT_SDP_H__ */
|
1801
tools/sdk/include/bluedroid/bt_target.h
Normal file
1801
tools/sdk/include/bluedroid/bt_target.h
Normal file
File diff suppressed because it is too large
Load Diff
470
tools/sdk/include/bluedroid/bt_trace.h
Normal file
470
tools/sdk/include/bluedroid/bt_trace.h
Normal file
@ -0,0 +1,470 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _BT_TRACE_H_
|
||||
#define _BT_TRACE_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include "bt_types.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
|
||||
#define TAG "BT"
|
||||
|
||||
#define BT_PRINTF(fmt, ...) ESP_LOGE(TAG, fmt, ##__VA_ARGS__)
|
||||
|
||||
#ifndef assert
|
||||
#define assert(x) do { if (!(x)) BT_PRINTF("bt host error %s %u\n", __FILE__, __LINE__); } while (0)
|
||||
#endif
|
||||
|
||||
inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
if (!data || !len) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (prefix) {
|
||||
BT_PRINTF("%s: len %d\n", prefix, len);
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i+=16) {
|
||||
BT_PRINTF("%02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x\n",
|
||||
*(data + i), *(data + i + 1), *(data + i + 2), *(data + i + 3), *(data + i + 4), *(data + i + 5), *(data + i + 6), *(data + i + 7),
|
||||
*(data + i + 8), *(data + i + 9), *(data + i + 10), *(data + i + 11), *(data + i + 12), *(data + i + 13), *(data + i + 14), *(data + i + 15));
|
||||
}
|
||||
BT_PRINTF("\n");
|
||||
}
|
||||
|
||||
#ifdef BTTRC_DUMP_BUFFER
|
||||
#define BTTRC_DUMP_BUFFER(_prefix, _data, _len) trc_dump_buffer(_data, _len)
|
||||
#else
|
||||
#define BTTRC_DUMP_BUFFER(_prefix, _data, _len)
|
||||
#endif
|
||||
|
||||
//static const char BTE_LOGMSG_MODULE[] = "bte_logmsg_module";
|
||||
|
||||
/* BTrgs);E tracing IDs for debug purposes */
|
||||
/* LayerIDs for stack */
|
||||
#define BTTRC_ID_STK_GKI 1
|
||||
#define BTTRC_ID_STK_BTU 2
|
||||
#define BTTRC_ID_STK_HCI 3
|
||||
#define BTTRC_ID_STK_L2CAP 4
|
||||
#define BTTRC_ID_STK_RFCM_MX 5
|
||||
#define BTTRC_ID_STK_RFCM_PRT 6
|
||||
#define BTTRC_ID_STK_OBEX_C 7
|
||||
#define BTTRC_ID_STK_OBEX_S 8
|
||||
#define BTTRC_ID_STK_AVCT 9
|
||||
#define BTTRC_ID_STK_AVDT 10
|
||||
#define BTTRC_ID_STK_AVRC 11
|
||||
#define BTTRC_ID_STK_BIC 12
|
||||
#define BTTRC_ID_STK_BIS 13
|
||||
#define BTTRC_ID_STK_BNEP 14
|
||||
#define BTTRC_ID_STK_BPP 15
|
||||
#define BTTRC_ID_STK_BTM_ACL 16
|
||||
#define BTTRC_ID_STK_BTM_PM 17
|
||||
#define BTTRC_ID_STK_BTM_DEV_CTRL 18
|
||||
#define BTTRC_ID_STK_BTM_SVC_DSC 19
|
||||
#define BTTRC_ID_STK_BTM_INQ 20
|
||||
#define BTTRC_ID_STK_BTM_SCO 21
|
||||
#define BTTRC_ID_STK_BTM_SEC 22
|
||||
#define BTTRC_ID_STK_HID 24
|
||||
#define BTTRC_ID_STK_HSP2 25
|
||||
#define BTTRC_ID_STK_CTP 26
|
||||
#define BTTRC_ID_STK_FTC 27
|
||||
#define BTTRC_ID_STK_FTS 28
|
||||
#define BTTRC_ID_STK_GAP 29
|
||||
#define BTTRC_ID_STK_HCRP 31
|
||||
#define BTTRC_ID_STK_ICP 32
|
||||
#define BTTRC_ID_STK_OPC 33
|
||||
#define BTTRC_ID_STK_OPS 34
|
||||
#define BTTRC_ID_STK_PAN 35
|
||||
#define BTTRC_ID_STK_SAP 36
|
||||
#define BTTRC_ID_STK_SDP 37
|
||||
#define BTTRC_ID_STK_SLIP 38
|
||||
#define BTTRC_ID_STK_SPP 39
|
||||
#define BTTRC_ID_STK_TCS 40
|
||||
#define BTTRC_ID_STK_VDP 41
|
||||
#define BTTRC_ID_STK_MCAP 42
|
||||
#define BTTRC_ID_STK_GATT 43
|
||||
#define BTTRC_ID_STK_SMP 44
|
||||
#define BTTRC_ID_STK_NFC 45
|
||||
#define BTTRC_ID_STK_NCI 46
|
||||
#define BTTRC_ID_STK_IDEP 47
|
||||
#define BTTRC_ID_STK_NDEP 48
|
||||
#define BTTRC_ID_STK_LLCP 49
|
||||
#define BTTRC_ID_STK_RW 50
|
||||
#define BTTRC_ID_STK_CE 51
|
||||
#define BTTRC_ID_STK_SNEP 52
|
||||
#define BTTRC_ID_STK_NDEF 53
|
||||
|
||||
/* LayerIDs for BTA */
|
||||
#define BTTRC_ID_BTA_ACC 55 /* Advanced Camera Client */
|
||||
#define BTTRC_ID_BTA_AG 56 /* audio gateway */
|
||||
#define BTTRC_ID_BTA_AV 57 /* Advanced audio */
|
||||
#define BTTRC_ID_BTA_BIC 58 /* Basic Imaging Client */
|
||||
#define BTTRC_ID_BTA_BIS 59 /* Basic Imaging Server */
|
||||
#define BTTRC_ID_BTA_BP 60 /* Basic Printing Client */
|
||||
#define BTTRC_ID_BTA_CG 61
|
||||
#define BTTRC_ID_BTA_CT 62 /* cordless telephony terminal */
|
||||
#define BTTRC_ID_BTA_DG 63 /* data gateway */
|
||||
#define BTTRC_ID_BTA_DM 64 /* device manager */
|
||||
#define BTTRC_ID_BTA_DM_SRCH 65 /* device manager search */
|
||||
#define BTTRC_ID_BTA_DM_SEC 66 /* device manager security */
|
||||
#define BTTRC_ID_BTA_FM 67
|
||||
#define BTTRC_ID_BTA_FTC 68 /* file transfer client */
|
||||
#define BTTRC_ID_BTA_FTS 69 /* file transfer server */
|
||||
#define BTTRC_ID_BTA_HIDH 70
|
||||
#define BTTRC_ID_BTA_HIDD 71
|
||||
#define BTTRC_ID_BTA_JV 72
|
||||
#define BTTRC_ID_BTA_OPC 73 /* object push client */
|
||||
#define BTTRC_ID_BTA_OPS 74 /* object push server */
|
||||
#define BTTRC_ID_BTA_PAN 75 /* Personal Area Networking */
|
||||
#define BTTRC_ID_BTA_PR 76 /* Printer client */
|
||||
#define BTTRC_ID_BTA_SC 77 /* SIM Card Access server */
|
||||
#define BTTRC_ID_BTA_SS 78 /* synchronization server */
|
||||
#define BTTRC_ID_BTA_SYS 79 /* system manager */
|
||||
#define BTTRC_ID_AVDT_SCB 80 /* avdt scb */
|
||||
#define BTTRC_ID_AVDT_CCB 81 /* avdt ccb */
|
||||
|
||||
// btla-specific ++
|
||||
/* LayerIDs added for BTL-A. Probably should modify bte_logmsg.c in future. */
|
||||
#define BTTRC_ID_STK_RFCOMM 82
|
||||
#define BTTRC_ID_STK_RFCOMM_DATA 83
|
||||
#define BTTRC_ID_STK_OBEX 84
|
||||
#define BTTRC_ID_STK_A2D 85
|
||||
#define BTTRC_ID_STK_BIP 86
|
||||
|
||||
/* LayerIDs for BT APP */
|
||||
#define BTTRC_ID_BTAPP 87
|
||||
#define BTTRC_ID_BT_PROTOCOL 88 /* this is a temporary solution to allow dynamic
|
||||
enable/disable of BT_PROTOCOL_TRACE */
|
||||
#define BTTRC_ID_MAX_ID BTTRC_ID_BT_PROTOCOL
|
||||
// btla-specific --
|
||||
#define BTTRC_ID_ALL_LAYERS 0xFF /* all trace layers */
|
||||
/* Parameter datatypes used in Trace APIs */
|
||||
#define BTTRC_PARAM_UINT8 1
|
||||
#define BTTRC_PARAM_UINT16 2
|
||||
#define BTTRC_PARAM_UINT32 3
|
||||
|
||||
/* Enables or disables verbose trace information. */
|
||||
#ifndef BT_TRACE_VERBOSE
|
||||
#define BT_TRACE_VERBOSE FALSE
|
||||
#endif
|
||||
|
||||
/* Enables or disables all trace messages. */
|
||||
#ifndef BT_USE_TRACES
|
||||
#define BT_USE_TRACES TRUE
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Trace Levels
|
||||
**
|
||||
** The following values may be used for different levels:
|
||||
** BT_TRACE_LEVEL_NONE 0 * No trace messages to be generated
|
||||
** BT_TRACE_LEVEL_ERROR 1 * Error condition trace messages
|
||||
** BT_TRACE_LEVEL_WARNING 2 * Warning condition trace messages
|
||||
** BT_TRACE_LEVEL_API 3 * API traces
|
||||
** BT_TRACE_LEVEL_EVENT 4 * Debug messages for events
|
||||
** BT_TRACE_LEVEL_DEBUG 5 * Debug messages (general)
|
||||
******************************************************************************/
|
||||
|
||||
// btla-specific ++
|
||||
/* Core Stack default trace levels */
|
||||
#ifndef HCI_INITIAL_TRACE_LEVEL
|
||||
#define HCI_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef BTM_INITIAL_TRACE_LEVEL
|
||||
#define BTM_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef L2CAP_INITIAL_TRACE_LEVEL
|
||||
#define L2CAP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef RFCOMM_INITIAL_TRACE_LEVEL
|
||||
#define RFCOMM_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef SDP_INITIAL_TRACE_LEVEL
|
||||
#define SDP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef GAP_INITIAL_TRACE_LEVEL
|
||||
#define GAP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef BNEP_INITIAL_TRACE_LEVEL
|
||||
#define BNEP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef PAN_INITIAL_TRACE_LEVEL
|
||||
#define PAN_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef A2D_INITIAL_TRACE_LEVEL
|
||||
#define A2D_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef AVDT_INITIAL_TRACE_LEVEL
|
||||
#define AVDT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef AVCT_INITIAL_TRACE_LEVEL
|
||||
#define AVCT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef AVRC_INITIAL_TRACE_LEVEL
|
||||
#define AVRC_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef MCA_INITIAL_TRACE_LEVEL
|
||||
#define MCA_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef HID_INITIAL_TRACE_LEVEL
|
||||
#define HID_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef APPL_INITIAL_TRACE_LEVEL
|
||||
#define APPL_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef BT_TRACE_APPL
|
||||
#define BT_TRACE_APPL BT_USE_TRACES
|
||||
#endif
|
||||
|
||||
#ifndef GATT_INITIAL_TRACE_LEVEL
|
||||
#define GATT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
|
||||
#ifndef SMP_INITIAL_TRACE_LEVEL
|
||||
#define SMP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
|
||||
#endif
|
||||
// btla-specific --
|
||||
|
||||
/* Define common tracing for all */
|
||||
#define LOG_LEVEL_ERROR 1
|
||||
#define LOG_LEVEL_WARN 2
|
||||
#define LOG_LEVEL_INFO 3
|
||||
#define LOG_LEVEL_DEBUG 4
|
||||
#define LOG_LEVEL_VERBOSE 5
|
||||
#ifndef LOG_LEVEL
|
||||
#define LOG_LEVEL LOG_LEVEL_INFO
|
||||
#endif
|
||||
#define LOG_ERROR(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_ERROR) BT_PRINTF(fmt,## args);} while(0)
|
||||
#define LOG_WARN(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_WARN) BT_PRINTF(fmt,## args);} while(0)
|
||||
#define LOG_INFO(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_INFO) BT_PRINTF(fmt,## args);} while(0)
|
||||
#define LOG_DEBUG(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_DEBUG) BT_PRINTF(fmt,## args);} while(0)
|
||||
#define LOG_VERBOSE(fmt, args...) do {if (LOG_LEVEL >= LOG_LEVEL_VERBOSE) BT_PRINTF(fmt,## args);} while(0)
|
||||
|
||||
/* Define tracing for the HCI unit
|
||||
*/
|
||||
#define HCI_TRACE_ERROR(fmt, args...) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt,## args);}
|
||||
#define HCI_TRACE_WARNING(fmt, args...) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt,## args);}
|
||||
#define HCI_TRACE_EVENT(fmt, args...) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt,## args);}
|
||||
#define HCI_TRACE_DEBUG(fmt, args...) {if (btu_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt,## args);}
|
||||
|
||||
/* Define tracing for BTM
|
||||
*/
|
||||
#define BTM_TRACE_ERROR(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define BTM_TRACE_WARNING(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define BTM_TRACE_API(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
#define BTM_TRACE_EVENT(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define BTM_TRACE_DEBUG(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* Define tracing for the L2CAP unit
|
||||
*/
|
||||
#define L2CAP_TRACE_ERROR(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define L2CAP_TRACE_WARNING(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define L2CAP_TRACE_API(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
#define L2CAP_TRACE_EVENT(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define L2CAP_TRACE_DEBUG(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* Define tracing for the SDP unit
|
||||
*/
|
||||
#define SDP_TRACE_ERROR(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define SDP_TRACE_WARNING(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define SDP_TRACE_API(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
#define SDP_TRACE_EVENT(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define SDP_TRACE_DEBUG(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* Define tracing for the RFCOMM unit
|
||||
*/
|
||||
#define RFCOMM_TRACE_ERROR(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define RFCOMM_TRACE_WARNING(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define RFCOMM_TRACE_API(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
#define RFCOMM_TRACE_EVENT(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define RFCOMM_TRACE_DEBUG(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* Generic Access Profile traces */
|
||||
#define GAP_TRACE_ERROR(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define GAP_TRACE_EVENT(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define GAP_TRACE_API(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
#define GAP_TRACE_WARNING(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* define traces for HID Host */
|
||||
#define HIDH_TRACE_ERROR(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define HIDH_TRACE_WARNING(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define HIDH_TRACE_API(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
#define HIDH_TRACE_EVENT(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define HIDH_TRACE_DEBUG(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* define traces for BNEP */
|
||||
|
||||
#define BNEP_TRACE_ERROR(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define BNEP_TRACE_WARNING(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define BNEP_TRACE_API(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
#define BNEP_TRACE_EVENT(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define BNEP_TRACE_DEBUG(fmt, args...) {if (bnep_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* define traces for PAN */
|
||||
|
||||
#define PAN_TRACE_ERROR(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define PAN_TRACE_WARNING(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define PAN_TRACE_API(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
#define PAN_TRACE_EVENT(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define PAN_TRACE_DEBUG(fmt, args...) {if (pan_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* Define tracing for the A2DP profile
|
||||
*/
|
||||
#define A2D_TRACE_ERROR(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define A2D_TRACE_WARNING(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define A2D_TRACE_EVENT(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define A2D_TRACE_DEBUG(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
#define A2D_TRACE_API(fmt, args...) {if (a2d_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* AVDTP
|
||||
*/
|
||||
#define AVDT_TRACE_ERROR(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define AVDT_TRACE_WARNING(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define AVDT_TRACE_EVENT(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define AVDT_TRACE_DEBUG(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
#define AVDT_TRACE_API(fmt, args...) {if (avdt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* Define tracing for the AVCTP protocol
|
||||
*/
|
||||
#define AVCT_TRACE_ERROR(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define AVCT_TRACE_WARNING(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define AVCT_TRACE_EVENT(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define AVCT_TRACE_DEBUG(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
#define AVCT_TRACE_API(fmt, args...) {if (avct_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* Define tracing for the AVRCP profile
|
||||
*/
|
||||
#define AVRC_TRACE_ERROR(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define AVRC_TRACE_WARNING(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define AVRC_TRACE_EVENT(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define AVRC_TRACE_DEBUG(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
#define AVRC_TRACE_API(fmt, args...) {if (avrc_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* MCAP
|
||||
*/
|
||||
#define MCA_TRACE_ERROR(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define MCA_TRACE_WARNING(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define MCA_TRACE_EVENT(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define MCA_TRACE_DEBUG(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
#define MCA_TRACE_API(fmt, args...) {if (mca_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* Define tracing for the ATT/GATT unit
|
||||
*/
|
||||
#define GATT_TRACE_ERROR(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define GATT_TRACE_WARNING(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define GATT_TRACE_API(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
#define GATT_TRACE_EVENT(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define GATT_TRACE_DEBUG(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* Define tracing for the SMP unit
|
||||
*/
|
||||
#define SMP_TRACE_ERROR(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define SMP_TRACE_WARNING(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define SMP_TRACE_API(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
#define SMP_TRACE_EVENT(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define SMP_TRACE_DEBUG(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
extern UINT8 btif_trace_level;
|
||||
|
||||
// define traces for application
|
||||
#define BTIF_TRACE_ERROR(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define BTIF_TRACE_WARNING(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define BTIF_TRACE_API(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
#define BTIF_TRACE_EVENT(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define BTIF_TRACE_DEBUG(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
#define BTIF_TRACE_VERBOSE(fmt, args...) {if (btif_trace_level >= BT_TRACE_LEVEL_VERBOSE)BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* define traces for application */
|
||||
|
||||
#define APPL_TRACE_ERROR(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_ERROR) BT_PRINTF(fmt, ## args);}
|
||||
#define APPL_TRACE_WARNING(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_WARNING) BT_PRINTF(fmt, ## args);}
|
||||
#define APPL_TRACE_API(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_API) BT_PRINTF(fmt, ## args);}
|
||||
#define APPL_TRACE_EVENT(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_EVENT) BT_PRINTF(fmt, ## args);}
|
||||
#define APPL_TRACE_DEBUG(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG) BT_PRINTF(fmt, ## args);}
|
||||
#define APPL_TRACE_VERBOSE(fmt, args...) {if (appl_trace_level >= BT_TRACE_LEVEL_VERBOSE) BT_PRINTF(fmt, ## args);}
|
||||
|
||||
/* Simplified Trace Helper Macro
|
||||
*/
|
||||
#define bdld(fmt, args...) \
|
||||
do{\
|
||||
if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
|
||||
BT_PRINTF(fmt, ## args); \
|
||||
}while(0)
|
||||
|
||||
#define bdlw(fmt, args...) \
|
||||
do{\
|
||||
if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
|
||||
BT_PRINTF(fmt, ## args); \
|
||||
}while(0)
|
||||
|
||||
#define bdle(fmt, args...) \
|
||||
do{\
|
||||
if((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_DEBUG) \
|
||||
BT_PRINTF(fmt, ## args); \
|
||||
}while(0)
|
||||
|
||||
#define bdla(assert_if) \
|
||||
do{\
|
||||
if(((MY_LOG_LEVEL) >= BT_TRACE_LEVEL_ERROR) && !(assert_if)) \
|
||||
BT_PRINTF("%s: assert failed\n", #assert_if); \
|
||||
}while(0)
|
||||
|
||||
typedef UINT8 tBTTRC_PARAM_TYPE;
|
||||
typedef UINT8 tBTTRC_LAYER_ID;
|
||||
typedef UINT8 tBTTRC_TYPE;
|
||||
|
||||
typedef struct {
|
||||
tBTTRC_LAYER_ID layer_id;
|
||||
tBTTRC_TYPE type; /* TODO: use tBTTRC_TYPE instead of "classical level 0-5" */
|
||||
} tBTTRC_LEVEL;
|
||||
|
||||
typedef UINT8 (tBTTRC_SET_TRACE_LEVEL)( UINT8 );
|
||||
|
||||
typedef struct {
|
||||
const tBTTRC_LAYER_ID layer_id_start;
|
||||
const tBTTRC_LAYER_ID layer_id_end;
|
||||
tBTTRC_SET_TRACE_LEVEL *p_f;
|
||||
const char *trc_name;
|
||||
UINT8 trace_level;
|
||||
} tBTTRC_FUNC_MAP;
|
||||
|
||||
/* External declaration for appl_trace_level here to avoid to add the declaration in all the files using APPL_TRACExxx macros */
|
||||
extern UINT8 appl_trace_level;
|
||||
|
||||
#endif /*_BT_TRACE_H_*/
|
789
tools/sdk/include/bluedroid/bt_types.h
Normal file
789
tools/sdk/include/bluedroid/bt_types.h
Normal file
@ -0,0 +1,789 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BT_TYPES_H
|
||||
#define BT_TYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE false
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE true
|
||||
#endif
|
||||
|
||||
typedef uint8_t UINT8;
|
||||
typedef uint16_t UINT16;
|
||||
typedef uint32_t UINT32;
|
||||
typedef uint64_t UINT64;
|
||||
|
||||
typedef int8_t INT8;
|
||||
typedef int16_t INT16;
|
||||
typedef int32_t INT32;
|
||||
typedef bool BOOLEAN;
|
||||
|
||||
#define PACKED __packed
|
||||
#define INLINE __inline
|
||||
|
||||
#define BCM_STRCPY_S(x1,x2,x3) strcpy((x1),(x3))
|
||||
#define BCM_STRNCPY_S(x1,x2,x3,x4) strncpy((x1),(x3),(x4))
|
||||
|
||||
/* READ WELL !!
|
||||
**
|
||||
** This section defines global events. These are events that cross layers.
|
||||
** Any event that passes between layers MUST be one of these events. Tasks
|
||||
** can use their own events internally, but a FUNDAMENTAL design issue is
|
||||
** that global events MUST be one of these events defined below.
|
||||
**
|
||||
** The convention used is the the event name contains the layer that the
|
||||
** event is going to.
|
||||
*/
|
||||
#define BT_EVT_MASK 0xFF00
|
||||
#define BT_SUB_EVT_MASK 0x00FF
|
||||
/* To Bluetooth Upper Layers */
|
||||
/************************************/
|
||||
#define BT_EVT_TO_BTU_L2C_EVT 0x0900 /* L2CAP event */
|
||||
#define BT_EVT_TO_BTU_HCI_EVT 0x1000 /* HCI Event */
|
||||
#define BT_EVT_TO_BTU_HCI_BR_EDR_EVT (0x0000 | BT_EVT_TO_BTU_HCI_EVT) /* event from BR/EDR controller */
|
||||
#define BT_EVT_TO_BTU_HCI_AMP1_EVT (0x0001 | BT_EVT_TO_BTU_HCI_EVT) /* event from local AMP 1 controller */
|
||||
#define BT_EVT_TO_BTU_HCI_AMP2_EVT (0x0002 | BT_EVT_TO_BTU_HCI_EVT) /* event from local AMP 2 controller */
|
||||
#define BT_EVT_TO_BTU_HCI_AMP3_EVT (0x0003 | BT_EVT_TO_BTU_HCI_EVT) /* event from local AMP 3 controller */
|
||||
|
||||
#define BT_EVT_TO_BTU_HCI_ACL 0x1100 /* ACL Data from HCI */
|
||||
#define BT_EVT_TO_BTU_HCI_SCO 0x1200 /* SCO Data from HCI */
|
||||
#define BT_EVT_TO_BTU_HCIT_ERR 0x1300 /* HCI Transport Error */
|
||||
|
||||
#define BT_EVT_TO_BTU_SP_EVT 0x1400 /* Serial Port Event */
|
||||
#define BT_EVT_TO_BTU_SP_DATA 0x1500 /* Serial Port Data */
|
||||
|
||||
#define BT_EVT_TO_BTU_HCI_CMD 0x1600 /* HCI command from upper layer */
|
||||
|
||||
|
||||
#define BT_EVT_TO_BTU_L2C_SEG_XMIT 0x1900 /* L2CAP segment(s) transmitted */
|
||||
|
||||
#define BT_EVT_PROXY_INCOMING_MSG 0x1A00 /* BlueStackTester event: incoming message from target */
|
||||
|
||||
#define BT_EVT_BTSIM 0x1B00 /* Insight BTSIM event */
|
||||
#define BT_EVT_BTISE 0x1C00 /* Insight Script Engine event */
|
||||
|
||||
/* To LM */
|
||||
/************************************/
|
||||
#define BT_EVT_TO_LM_HCI_CMD 0x2000 /* HCI Command */
|
||||
#define BT_EVT_TO_LM_HCI_ACL 0x2100 /* HCI ACL Data */
|
||||
#define BT_EVT_TO_LM_HCI_SCO 0x2200 /* HCI SCO Data */
|
||||
#define BT_EVT_TO_LM_HCIT_ERR 0x2300 /* HCI Transport Error */
|
||||
#define BT_EVT_TO_LM_LC_EVT 0x2400 /* LC event */
|
||||
#define BT_EVT_TO_LM_LC_LMP 0x2500 /* LC Received LMP command frame */
|
||||
#define BT_EVT_TO_LM_LC_ACL 0x2600 /* LC Received ACL data */
|
||||
#define BT_EVT_TO_LM_LC_SCO 0x2700 /* LC Received SCO data (not used) */
|
||||
#define BT_EVT_TO_LM_LC_ACL_TX 0x2800 /* LMP data transmit complete */
|
||||
#define BT_EVT_TO_LM_LC_LMPC_TX 0x2900 /* LMP Command transmit complete */
|
||||
#define BT_EVT_TO_LM_LOCAL_ACL_LB 0x2a00 /* Data to be locally loopbacked */
|
||||
#define BT_EVT_TO_LM_HCI_ACL_ACK 0x2b00 /* HCI ACL Data ack (not used) */
|
||||
#define BT_EVT_TO_LM_DIAG 0x2c00 /* LM Diagnostics commands */
|
||||
|
||||
|
||||
#define BT_EVT_TO_BTM_CMDS 0x2f00
|
||||
#define BT_EVT_TO_BTM_PM_MDCHG_EVT (0x0001 | BT_EVT_TO_BTM_CMDS)
|
||||
|
||||
#define BT_EVT_TO_TCS_CMDS 0x3000
|
||||
|
||||
#define BT_EVT_TO_CTP_CMDS 0x3300
|
||||
|
||||
/* ftp events */
|
||||
#define BT_EVT_TO_FTP_SRVR_CMDS 0x3600
|
||||
#define BT_EVT_TO_FTP_CLNT_CMDS 0x3700
|
||||
|
||||
#define BT_EVT_TO_BTU_SAP 0x3800 /* SIM Access Profile events */
|
||||
|
||||
/* opp events */
|
||||
#define BT_EVT_TO_OPP_SRVR_CMDS 0x3900
|
||||
#define BT_EVT_TO_OPP_CLNT_CMDS 0x3a00
|
||||
|
||||
/* gap events */
|
||||
#define BT_EVT_TO_GAP_MSG 0x3b00
|
||||
|
||||
/* for NFC */
|
||||
/************************************/
|
||||
#define BT_EVT_TO_NFC_NCI 0x4000 /* NCI Command, Notification or Data*/
|
||||
#define BT_EVT_TO_NFC_INIT 0x4100 /* Initialization message */
|
||||
#define BT_EVT_TO_NCI_LP 0x4200 /* Low power */
|
||||
#define BT_EVT_TO_NFC_ERR 0x4300 /* Error notification to NFC Task */
|
||||
|
||||
#define BT_EVT_TO_NFCCSIM_NCI 0x4a00 /* events to NFCC simulation (NCI packets) */
|
||||
|
||||
/* HCISU Events */
|
||||
|
||||
#define BT_EVT_HCISU 0x5000
|
||||
|
||||
// btla-specific ++
|
||||
#define BT_EVT_TO_HCISU_RECONFIG_EVT (0x0001 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_UPDATE_BAUDRATE_EVT (0x0002 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_LP_ENABLE_EVT (0x0003 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_LP_DISABLE_EVT (0x0004 | BT_EVT_HCISU)
|
||||
// btla-specific --
|
||||
#define BT_EVT_TO_HCISU_LP_APP_SLEEPING_EVT (0x0005 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_LP_ALLOW_BT_SLEEP_EVT (0x0006 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_LP_WAKEUP_HOST_EVT (0x0007 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_LP_RCV_H4IBSS_EVT (0x0008 | BT_EVT_HCISU)
|
||||
#define BT_EVT_TO_HCISU_H5_RESET_EVT (0x0009 | BT_EVT_HCISU)
|
||||
#define BT_EVT_HCISU_START_QUICK_TIMER (0x000a | BT_EVT_HCISU)
|
||||
|
||||
#define BT_EVT_DATA_TO_AMP_1 0x5100
|
||||
#define BT_EVT_DATA_TO_AMP_15 0x5f00
|
||||
|
||||
/* HSP Events */
|
||||
|
||||
#define BT_EVT_BTU_HSP2 0x6000
|
||||
|
||||
#define BT_EVT_TO_BTU_HSP2_EVT (0x0001 | BT_EVT_BTU_HSP2)
|
||||
|
||||
/* BPP Events */
|
||||
#define BT_EVT_TO_BPP_PR_CMDS 0x6100 /* Printer Events */
|
||||
#define BT_EVT_TO_BPP_SND_CMDS 0x6200 /* BPP Sender Events */
|
||||
|
||||
/* BIP Events */
|
||||
#define BT_EVT_TO_BIP_CMDS 0x6300
|
||||
|
||||
/* HCRP Events */
|
||||
|
||||
#define BT_EVT_BTU_HCRP 0x7000
|
||||
|
||||
#define BT_EVT_TO_BTU_HCRP_EVT (0x0001 | BT_EVT_BTU_HCRP)
|
||||
#define BT_EVT_TO_BTU_HCRPM_EVT (0x0002 | BT_EVT_BTU_HCRP)
|
||||
|
||||
|
||||
#define BT_EVT_BTU_HFP 0x8000
|
||||
#define BT_EVT_TO_BTU_HFP_EVT (0x0001 | BT_EVT_BTU_HFP)
|
||||
|
||||
#define BT_EVT_BTU_IPC_EVT 0x9000
|
||||
#define BT_EVT_BTU_IPC_LOGMSG_EVT (0x0000 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_ACL_EVT (0x0001 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_BTU_EVT (0x0002 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_L2C_EVT (0x0003 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_L2C_MSG_EVT (0x0004 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_BTM_EVT (0x0005 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_AVDT_EVT (0x0006 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_SLIP_EVT (0x0007 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_MGMT_EVT (0x0008 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_BTTRC_EVT (0x0009 | BT_EVT_BTU_IPC_EVT)
|
||||
#define BT_EVT_BTU_IPC_BURST_EVT (0x000A | BT_EVT_BTU_IPC_EVT)
|
||||
|
||||
|
||||
/* BTIF Events */
|
||||
#define BT_EVT_BTIF 0xA000
|
||||
#define BT_EVT_CONTEXT_SWITCH_EVT (0x0001 | BT_EVT_BTIF)
|
||||
|
||||
/* Define the header of each buffer used in the Bluetooth stack.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t event;
|
||||
uint16_t len;
|
||||
uint16_t offset;
|
||||
uint16_t layer_specific;
|
||||
uint8_t data[];
|
||||
} BT_HDR;
|
||||
|
||||
#define BT_HDR_SIZE (sizeof (BT_HDR))
|
||||
|
||||
#define BT_PSM_SDP 0x0001
|
||||
#define BT_PSM_RFCOMM 0x0003
|
||||
#define BT_PSM_TCS 0x0005
|
||||
#define BT_PSM_CTP 0x0007
|
||||
#define BT_PSM_BNEP 0x000F
|
||||
#define BT_PSM_HIDC 0x0011
|
||||
#define BT_PSM_HIDI 0x0013
|
||||
#define BT_PSM_UPNP 0x0015
|
||||
#define BT_PSM_AVCTP 0x0017
|
||||
#define BT_PSM_AVDTP 0x0019
|
||||
#define BT_PSM_AVCTP_13 0x001B /* Advanced Control - Browsing */
|
||||
#define BT_PSM_UDI_CP 0x001D /* Unrestricted Digital Information Profile C-Plane */
|
||||
#define BT_PSM_ATT 0x001F /* Attribute Protocol */
|
||||
|
||||
|
||||
/* These macros extract the HCI opcodes from a buffer
|
||||
*/
|
||||
#define HCI_GET_CMD_HDR_OPCODE(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset) + \
|
||||
(*((UINT8 *)((p) + 1) + p->offset + 1) << 8)))
|
||||
#define HCI_GET_CMD_HDR_PARAM_LEN(p) (UINT8) (*((UINT8 *)((p) + 1) + p->offset + 2))
|
||||
|
||||
#define HCI_GET_EVT_HDR_OPCODE(p) (UINT8)(*((UINT8 *)((p) + 1) + p->offset))
|
||||
#define HCI_GET_EVT_HDR_PARAM_LEN(p) (UINT8) (*((UINT8 *)((p) + 1) + p->offset + 1))
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
** Macros to get and put bytes to and from a stream (Little Endian format).
|
||||
*/
|
||||
#define UINT32_TO_STREAM(p, u32) {*(p)++ = (UINT8)(u32); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 24);}
|
||||
#define UINT24_TO_STREAM(p, u24) {*(p)++ = (UINT8)(u24); *(p)++ = (UINT8)((u24) >> 8); *(p)++ = (UINT8)((u24) >> 16);}
|
||||
#define UINT16_TO_STREAM(p, u16) {*(p)++ = (UINT8)(u16); *(p)++ = (UINT8)((u16) >> 8);}
|
||||
#define UINT8_TO_STREAM(p, u8) {*(p)++ = (UINT8)(u8);}
|
||||
#define INT8_TO_STREAM(p, u8) {*(p)++ = (INT8)(u8);}
|
||||
#define ARRAY32_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 32; ijk++) *(p)++ = (UINT8) a[31 - ijk];}
|
||||
#define ARRAY16_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 16; ijk++) *(p)++ = (UINT8) a[15 - ijk];}
|
||||
#define ARRAY8_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 8; ijk++) *(p)++ = (UINT8) a[7 - ijk];}
|
||||
#define BDADDR_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *(p)++ = (UINT8) a[BD_ADDR_LEN - 1 - ijk];}
|
||||
#define LAP_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < LAP_LEN; ijk++) *(p)++ = (UINT8) a[LAP_LEN - 1 - ijk];}
|
||||
#define DEVCLASS_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < DEV_CLASS_LEN;ijk++) *(p)++ = (UINT8) a[DEV_CLASS_LEN - 1 - ijk];}
|
||||
#define ARRAY_TO_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[ijk];}
|
||||
#define REVERSE_ARRAY_TO_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[len - 1 - ijk];}
|
||||
|
||||
#define STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
|
||||
#define STREAM_TO_UINT16(u16, p) {u16 = ((UINT16)(*(p)) + (((UINT16)(*((p) + 1))) << 8)); (p) += 2;}
|
||||
#define STREAM_TO_UINT24(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) ); (p) += 3;}
|
||||
#define STREAM_TO_UINT32(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) + ((((UINT32)(*((p) + 3)))) << 24)); (p) += 4;}
|
||||
#define STREAM_TO_BDADDR(a, p) {register int ijk; register UINT8 *pbda = (UINT8 *)a + BD_ADDR_LEN - 1; for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *pbda-- = *p++;}
|
||||
#define STREAM_TO_ARRAY32(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 31; for (ijk = 0; ijk < 32; ijk++) *_pa-- = *p++;}
|
||||
#define STREAM_TO_ARRAY16(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 15; for (ijk = 0; ijk < 16; ijk++) *_pa-- = *p++;}
|
||||
#define STREAM_TO_ARRAY8(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 7; for (ijk = 0; ijk < 8; ijk++) *_pa-- = *p++;}
|
||||
#define STREAM_TO_DEVCLASS(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + DEV_CLASS_LEN - 1; for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++) *_pa-- = *p++;}
|
||||
#define STREAM_TO_LAP(a, p) {register int ijk; register UINT8 *plap = (UINT8 *)a + LAP_LEN - 1; for (ijk = 0; ijk < LAP_LEN; ijk++) *plap-- = *p++;}
|
||||
#define STREAM_TO_ARRAY(a, p, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) ((UINT8 *) a)[ijk] = *p++;}
|
||||
#define REVERSE_STREAM_TO_ARRAY(a, p, len) {register int ijk; register UINT8 *_pa = (UINT8 *)a + len - 1; for (ijk = 0; ijk < len; ijk++) *_pa-- = *p++;}
|
||||
|
||||
#define STREAM_SKIP_UINT8(p) do { (p) += 1; } while (0)
|
||||
#define STREAM_SKIP_UINT16(p) do { (p) += 2; } while (0)
|
||||
|
||||
/********************************************************************************
|
||||
** Macros to get and put bytes to and from a field (Little Endian format).
|
||||
** These are the same as to stream, except the pointer is not incremented.
|
||||
*/
|
||||
#define UINT32_TO_FIELD(p, u32) {*(UINT8 *)(p) = (UINT8)(u32); *((UINT8 *)(p)+1) = (UINT8)((u32) >> 8); *((UINT8 *)(p)+2) = (UINT8)((u32) >> 16); *((UINT8 *)(p)+3) = (UINT8)((u32) >> 24);}
|
||||
#define UINT24_TO_FIELD(p, u24) {*(UINT8 *)(p) = (UINT8)(u24); *((UINT8 *)(p)+1) = (UINT8)((u24) >> 8); *((UINT8 *)(p)+2) = (UINT8)((u24) >> 16);}
|
||||
#define UINT16_TO_FIELD(p, u16) {*(UINT8 *)(p) = (UINT8)(u16); *((UINT8 *)(p)+1) = (UINT8)((u16) >> 8);}
|
||||
#define UINT8_TO_FIELD(p, u8) {*(UINT8 *)(p) = (UINT8)(u8);}
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
** Macros to get and put bytes to and from a stream (Big Endian format)
|
||||
*/
|
||||
#define UINT32_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 24); *(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); }
|
||||
#define UINT24_TO_BE_STREAM(p, u24) {*(p)++ = (UINT8)((u24) >> 16); *(p)++ = (UINT8)((u24) >> 8); *(p)++ = (UINT8)(u24);}
|
||||
#define UINT16_TO_BE_STREAM(p, u16) {*(p)++ = (UINT8)((u16) >> 8); *(p)++ = (UINT8)(u16);}
|
||||
#define UINT8_TO_BE_STREAM(p, u8) {*(p)++ = (UINT8)(u8);}
|
||||
#define ARRAY_TO_BE_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[ijk];}
|
||||
#define ARRAY_TO_BE_STREAM_REVERSE(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[len - ijk - 1];}
|
||||
|
||||
#define BE_STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
|
||||
#define BE_STREAM_TO_UINT16(u16, p) {u16 = (UINT16)(((UINT16)(*(p)) << 8) + (UINT16)(*((p) + 1))); (p) += 2;}
|
||||
#define BE_STREAM_TO_UINT24(u32, p) {u32 = (((UINT32)(*((p) + 2))) + ((UINT32)(*((p) + 1)) << 8) + ((UINT32)(*(p)) << 16)); (p) += 3;}
|
||||
#define BE_STREAM_TO_UINT32(u32, p) {u32 = ((UINT32)(*((p) + 3)) + ((UINT32)(*((p) + 2)) << 8) + ((UINT32)(*((p) + 1)) << 16) + ((UINT32)(*(p)) << 24)); (p) += 4;}
|
||||
#define BE_STREAM_TO_ARRAY(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) ((UINT8 *) a)[ijk] = *p++;}
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
** Macros to get and put bytes to and from a field (Big Endian format).
|
||||
** These are the same as to stream, except the pointer is not incremented.
|
||||
*/
|
||||
#define UINT32_TO_BE_FIELD(p, u32) {*(UINT8 *)(p) = (UINT8)((u32) >> 24); *((UINT8 *)(p)+1) = (UINT8)((u32) >> 16); *((UINT8 *)(p)+2) = (UINT8)((u32) >> 8); *((UINT8 *)(p)+3) = (UINT8)(u32); }
|
||||
#define UINT24_TO_BE_FIELD(p, u24) {*(UINT8 *)(p) = (UINT8)((u24) >> 16); *((UINT8 *)(p)+1) = (UINT8)((u24) >> 8); *((UINT8 *)(p)+2) = (UINT8)(u24);}
|
||||
#define UINT16_TO_BE_FIELD(p, u16) {*(UINT8 *)(p) = (UINT8)((u16) >> 8); *((UINT8 *)(p)+1) = (UINT8)(u16);}
|
||||
#define UINT8_TO_BE_FIELD(p, u8) {*(UINT8 *)(p) = (UINT8)(u8);}
|
||||
|
||||
|
||||
/* Common Bluetooth field definitions */
|
||||
#define BD_ADDR_LEN 6 /* Device address length */
|
||||
typedef UINT8 BD_ADDR[BD_ADDR_LEN]; /* Device address */
|
||||
typedef UINT8 *BD_ADDR_PTR; /* Pointer to Device Address */
|
||||
|
||||
#define AMP_KEY_TYPE_GAMP 0
|
||||
#define AMP_KEY_TYPE_WIFI 1
|
||||
#define AMP_KEY_TYPE_UWB 2
|
||||
typedef UINT8 tAMP_KEY_TYPE;
|
||||
|
||||
#define BT_OCTET8_LEN 8
|
||||
typedef UINT8 BT_OCTET8[BT_OCTET8_LEN]; /* octet array: size 16 */
|
||||
|
||||
#define LINK_KEY_LEN 16
|
||||
typedef UINT8 LINK_KEY[LINK_KEY_LEN]; /* Link Key */
|
||||
|
||||
#define AMP_LINK_KEY_LEN 32
|
||||
typedef UINT8 AMP_LINK_KEY[AMP_LINK_KEY_LEN]; /* Dedicated AMP and GAMP Link Keys */
|
||||
|
||||
#define BT_OCTET16_LEN 16
|
||||
typedef UINT8 BT_OCTET16[BT_OCTET16_LEN]; /* octet array: size 16 */
|
||||
|
||||
#define PIN_CODE_LEN 16
|
||||
typedef UINT8 PIN_CODE[PIN_CODE_LEN]; /* Pin Code (upto 128 bits) MSB is 0 */
|
||||
typedef UINT8 *PIN_CODE_PTR; /* Pointer to Pin Code */
|
||||
|
||||
#define BT_OCTET32_LEN 32
|
||||
typedef UINT8 BT_OCTET32[BT_OCTET32_LEN]; /* octet array: size 32 */
|
||||
|
||||
#define DEV_CLASS_LEN 3
|
||||
typedef UINT8 DEV_CLASS[DEV_CLASS_LEN]; /* Device class */
|
||||
typedef UINT8 *DEV_CLASS_PTR; /* Pointer to Device class */
|
||||
|
||||
#define EXT_INQ_RESP_LEN 3
|
||||
typedef UINT8 EXT_INQ_RESP[EXT_INQ_RESP_LEN];/* Extended Inquiry Response */
|
||||
typedef UINT8 *EXT_INQ_RESP_PTR; /* Pointer to Extended Inquiry Response */
|
||||
|
||||
#define BD_NAME_LEN 248
|
||||
typedef UINT8 BD_NAME[BD_NAME_LEN + 1]; /* Device name */
|
||||
typedef UINT8 *BD_NAME_PTR; /* Pointer to Device name */
|
||||
|
||||
#define BD_FEATURES_LEN 8
|
||||
typedef UINT8 BD_FEATURES[BD_FEATURES_LEN]; /* LMP features supported by device */
|
||||
|
||||
#define BT_EVENT_MASK_LEN 8
|
||||
typedef UINT8 BT_EVENT_MASK[BT_EVENT_MASK_LEN]; /* Event Mask */
|
||||
|
||||
#define LAP_LEN 3
|
||||
typedef UINT8 LAP[LAP_LEN]; /* IAC as passed to Inquiry (LAP) */
|
||||
typedef UINT8 INQ_LAP[LAP_LEN]; /* IAC as passed to Inquiry (LAP) */
|
||||
|
||||
#define RAND_NUM_LEN 16
|
||||
typedef UINT8 RAND_NUM[RAND_NUM_LEN];
|
||||
|
||||
#define ACO_LEN 12
|
||||
typedef UINT8 ACO[ACO_LEN]; /* Authenticated ciphering offset */
|
||||
|
||||
#define COF_LEN 12
|
||||
typedef UINT8 COF[COF_LEN]; /* ciphering offset number */
|
||||
|
||||
typedef struct {
|
||||
UINT8 qos_flags; /* TBD */
|
||||
UINT8 service_type; /* see below */
|
||||
UINT32 token_rate; /* bytes/second */
|
||||
UINT32 token_bucket_size; /* bytes */
|
||||
UINT32 peak_bandwidth; /* bytes/second */
|
||||
UINT32 latency; /* microseconds */
|
||||
UINT32 delay_variation; /* microseconds */
|
||||
} FLOW_SPEC;
|
||||
|
||||
/* Values for service_type */
|
||||
#define NO_TRAFFIC 0
|
||||
#define BEST_EFFORT 1
|
||||
#define GUARANTEED 2
|
||||
|
||||
/* Service class of the CoD */
|
||||
#define SERV_CLASS_NETWORKING (1 << 1)
|
||||
#define SERV_CLASS_RENDERING (1 << 2)
|
||||
#define SERV_CLASS_CAPTURING (1 << 3)
|
||||
#define SERV_CLASS_OBJECT_TRANSFER (1 << 4)
|
||||
#define SERV_CLASS_OBJECT_AUDIO (1 << 5)
|
||||
#define SERV_CLASS_OBJECT_TELEPHONY (1 << 6)
|
||||
#define SERV_CLASS_OBJECT_INFORMATION (1 << 7)
|
||||
|
||||
/* Second byte */
|
||||
#define SERV_CLASS_LIMITED_DISC_MODE (0x20)
|
||||
|
||||
/* Field size definitions. Note that byte lengths are rounded up. */
|
||||
#define ACCESS_CODE_BIT_LEN 72
|
||||
#define ACCESS_CODE_BYTE_LEN 9
|
||||
#define SHORTENED_ACCESS_CODE_BIT_LEN 68
|
||||
|
||||
typedef UINT8 ACCESS_CODE[ACCESS_CODE_BYTE_LEN];
|
||||
|
||||
#define SYNTH_TX 1 /* want synth code to TRANSMIT at this freq */
|
||||
#define SYNTH_RX 2 /* want synth code to RECEIVE at this freq */
|
||||
|
||||
#define SYNC_REPS 1 /* repeats of sync word transmitted to start of burst */
|
||||
|
||||
/* Bluetooth CLK27 */
|
||||
#define BT_CLK27 (2 << 26)
|
||||
|
||||
/* Bluetooth CLK12 is 1.28 sec */
|
||||
#define BT_CLK12_TO_MS(x) ((x) * 1280)
|
||||
#define BT_MS_TO_CLK12(x) ((x) / 1280)
|
||||
#define BT_CLK12_TO_SLOTS(x) ((x) << 11)
|
||||
|
||||
/* Bluetooth CLK is 0.625 msec */
|
||||
#define BT_CLK_TO_MS(x) (((x) * 5 + 3) / 8)
|
||||
#define BT_MS_TO_CLK(x) (((x) * 8 + 2) / 5)
|
||||
|
||||
#define BT_CLK_TO_MICROSECS(x) (((x) * 5000 + 3) / 8)
|
||||
#define BT_MICROSECS_TO_CLK(x) (((x) * 8 + 2499) / 5000)
|
||||
|
||||
/* Maximum UUID size - 16 bytes, and structure to hold any type of UUID. */
|
||||
#define MAX_UUID_SIZE 16
|
||||
typedef struct {
|
||||
#define LEN_UUID_16 2
|
||||
#define LEN_UUID_32 4
|
||||
#define LEN_UUID_128 16
|
||||
|
||||
UINT16 len;
|
||||
|
||||
union {
|
||||
UINT16 uuid16;
|
||||
UINT32 uuid32;
|
||||
UINT8 uuid128[MAX_UUID_SIZE];
|
||||
} uu;
|
||||
|
||||
} tBT_UUID;
|
||||
|
||||
#define BT_EIR_FLAGS_TYPE 0x01
|
||||
#define BT_EIR_MORE_16BITS_UUID_TYPE 0x02
|
||||
#define BT_EIR_COMPLETE_16BITS_UUID_TYPE 0x03
|
||||
#define BT_EIR_MORE_32BITS_UUID_TYPE 0x04
|
||||
#define BT_EIR_COMPLETE_32BITS_UUID_TYPE 0x05
|
||||
#define BT_EIR_MORE_128BITS_UUID_TYPE 0x06
|
||||
#define BT_EIR_COMPLETE_128BITS_UUID_TYPE 0x07
|
||||
#define BT_EIR_SHORTENED_LOCAL_NAME_TYPE 0x08
|
||||
#define BT_EIR_COMPLETE_LOCAL_NAME_TYPE 0x09
|
||||
#define BT_EIR_TX_POWER_LEVEL_TYPE 0x0A
|
||||
#define BT_EIR_OOB_BD_ADDR_TYPE 0x0C
|
||||
#define BT_EIR_OOB_COD_TYPE 0x0D
|
||||
#define BT_EIR_OOB_SSP_HASH_C_TYPE 0x0E
|
||||
#define BT_EIR_OOB_SSP_RAND_R_TYPE 0x0F
|
||||
#define BT_EIR_MANUFACTURER_SPECIFIC_TYPE 0xFF
|
||||
|
||||
#define BT_OOB_COD_SIZE 3
|
||||
#define BT_OOB_HASH_C_SIZE 16
|
||||
#define BT_OOB_RAND_R_SIZE 16
|
||||
|
||||
/* Broadcom proprietary UUIDs and reserved PSMs
|
||||
**
|
||||
** The lowest 4 bytes byte of the UUID or GUID depends on the feature. Typically,
|
||||
** the value of those bytes will be the PSM or SCN, but it is up to the features.
|
||||
*/
|
||||
#define BRCM_PROPRIETARY_UUID_BASE 0xDA, 0x23, 0x41, 0x02, 0xA3, 0xBB, 0xC1, 0x71, 0xBA, 0x09, 0x6f, 0x21
|
||||
#define BRCM_PROPRIETARY_GUID_BASE 0xda23, 0x4102, 0xa3, 0xbb, 0xc1, 0x71, 0xba, 0x09, 0x6f, 0x21
|
||||
|
||||
/* We will not allocate a PSM in the reserved range to 3rd party apps
|
||||
*/
|
||||
#define BRCM_RESERVED_PSM_START 0x5AE1
|
||||
#define BRCM_RESERVED_PSM_END 0x5AFF
|
||||
|
||||
#define BRCM_UTILITY_SERVICE_PSM 0x5AE1
|
||||
#define BRCM_MATCHER_PSM 0x5AE3
|
||||
|
||||
/* Connection statistics
|
||||
*/
|
||||
|
||||
/* Structure to hold connection stats */
|
||||
#ifndef BT_CONN_STATS_DEFINED
|
||||
#define BT_CONN_STATS_DEFINED
|
||||
|
||||
/* These bits are used in the bIsConnected field */
|
||||
#define BT_CONNECTED_USING_BREDR 1
|
||||
#define BT_CONNECTED_USING_AMP 2
|
||||
|
||||
typedef struct {
|
||||
UINT32 is_connected;
|
||||
INT32 rssi;
|
||||
UINT32 bytes_sent;
|
||||
UINT32 bytes_rcvd;
|
||||
UINT32 duration;
|
||||
} tBT_CONN_STATS;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Low Energy definitions
|
||||
**
|
||||
** Address types
|
||||
*/
|
||||
#define BLE_ADDR_PUBLIC 0x00
|
||||
#define BLE_ADDR_RANDOM 0x01
|
||||
#define BLE_ADDR_PUBLIC_ID 0x02
|
||||
#define BLE_ADDR_RANDOM_ID 0x03
|
||||
typedef UINT8 tBLE_ADDR_TYPE;
|
||||
#define BLE_ADDR_TYPE_MASK (BLE_ADDR_RANDOM | BLE_ADDR_PUBLIC)
|
||||
|
||||
#define BT_TRANSPORT_INVALID 0
|
||||
#define BT_TRANSPORT_BR_EDR 1
|
||||
#define BT_TRANSPORT_LE 2
|
||||
typedef UINT8 tBT_TRANSPORT;
|
||||
|
||||
#define BLE_ADDR_IS_STATIC(x) ((x[0] & 0xC0) == 0xC0)
|
||||
|
||||
typedef struct {
|
||||
tBLE_ADDR_TYPE type;
|
||||
BD_ADDR bda;
|
||||
} tBLE_BD_ADDR;
|
||||
|
||||
/* Device Types
|
||||
*/
|
||||
#define BT_DEVICE_TYPE_BREDR 0x01
|
||||
#define BT_DEVICE_TYPE_BLE 0x02
|
||||
#define BT_DEVICE_TYPE_DUMO 0x03
|
||||
typedef UINT8 tBT_DEVICE_TYPE;
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/* Define trace levels */
|
||||
#define BT_TRACE_LEVEL_NONE 0 /* No trace messages to be generated */
|
||||
#define BT_TRACE_LEVEL_ERROR 1 /* Error condition trace messages */
|
||||
#define BT_TRACE_LEVEL_WARNING 2 /* Warning condition trace messages */
|
||||
#define BT_TRACE_LEVEL_API 3 /* API traces */
|
||||
#define BT_TRACE_LEVEL_EVENT 4 /* Debug messages for events */
|
||||
#define BT_TRACE_LEVEL_DEBUG 5 /* Full debug messages */
|
||||
#define BT_TRACE_LEVEL_VERBOSE 6 /* Verbose debug messages */
|
||||
|
||||
#define MAX_TRACE_LEVEL 6
|
||||
|
||||
|
||||
/* Define New Trace Type Definition */
|
||||
/* TRACE_CTRL_TYPE 0x^^000000*/
|
||||
#define TRACE_CTRL_MASK 0xff000000
|
||||
#define TRACE_GET_CTRL(x) ((((UINT32)(x)) & TRACE_CTRL_MASK) >> 24)
|
||||
|
||||
#define TRACE_CTRL_GENERAL 0x00000000
|
||||
#define TRACE_CTRL_STR_RESOURCE 0x01000000
|
||||
#define TRACE_CTRL_SEQ_FLOW 0x02000000
|
||||
#define TRACE_CTRL_MAX_NUM 3
|
||||
|
||||
/* LAYER SPECIFIC 0x00^^0000*/
|
||||
#define TRACE_LAYER_MASK 0x00ff0000
|
||||
#define TRACE_GET_LAYER(x) ((((UINT32)(x)) & TRACE_LAYER_MASK) >> 16)
|
||||
|
||||
#define TRACE_LAYER_NONE 0x00000000
|
||||
#define TRACE_LAYER_USB 0x00010000
|
||||
#define TRACE_LAYER_SERIAL 0x00020000
|
||||
#define TRACE_LAYER_SOCKET 0x00030000
|
||||
#define TRACE_LAYER_RS232 0x00040000
|
||||
#define TRACE_LAYER_TRANS_MAX_NUM 5
|
||||
#define TRACE_LAYER_TRANS_ALL 0x007f0000
|
||||
#define TRACE_LAYER_LC 0x00050000
|
||||
#define TRACE_LAYER_LM 0x00060000
|
||||
#define TRACE_LAYER_HCI 0x00070000
|
||||
#define TRACE_LAYER_L2CAP 0x00080000
|
||||
#define TRACE_LAYER_RFCOMM 0x00090000
|
||||
#define TRACE_LAYER_SDP 0x000a0000
|
||||
#define TRACE_LAYER_TCS 0x000b0000
|
||||
#define TRACE_LAYER_OBEX 0x000c0000
|
||||
#define TRACE_LAYER_BTM 0x000d0000
|
||||
#define TRACE_LAYER_GAP 0x000e0000
|
||||
#define TRACE_LAYER_ICP 0x00110000
|
||||
#define TRACE_LAYER_HSP2 0x00120000
|
||||
#define TRACE_LAYER_SPP 0x00130000
|
||||
#define TRACE_LAYER_CTP 0x00140000
|
||||
#define TRACE_LAYER_BPP 0x00150000
|
||||
#define TRACE_LAYER_HCRP 0x00160000
|
||||
#define TRACE_LAYER_FTP 0x00170000
|
||||
#define TRACE_LAYER_OPP 0x00180000
|
||||
#define TRACE_LAYER_BTU 0x00190000
|
||||
#define TRACE_LAYER_GKI 0x001a0000
|
||||
#define TRACE_LAYER_BNEP 0x001b0000
|
||||
#define TRACE_LAYER_PAN 0x001c0000
|
||||
#define TRACE_LAYER_HFP 0x001d0000
|
||||
#define TRACE_LAYER_HID 0x001e0000
|
||||
#define TRACE_LAYER_BIP 0x001f0000
|
||||
#define TRACE_LAYER_AVP 0x00200000
|
||||
#define TRACE_LAYER_A2D 0x00210000
|
||||
#define TRACE_LAYER_SAP 0x00220000
|
||||
#define TRACE_LAYER_AMP 0x00230000
|
||||
#define TRACE_LAYER_MCA 0x00240000
|
||||
#define TRACE_LAYER_ATT 0x00250000
|
||||
#define TRACE_LAYER_SMP 0x00260000
|
||||
#define TRACE_LAYER_NFC 0x00270000
|
||||
#define TRACE_LAYER_NCI 0x00280000
|
||||
#define TRACE_LAYER_LLCP 0x00290000
|
||||
#define TRACE_LAYER_NDEF 0x002a0000
|
||||
#define TRACE_LAYER_RW 0x002b0000
|
||||
#define TRACE_LAYER_CE 0x002c0000
|
||||
#define TRACE_LAYER_P2P 0x002d0000
|
||||
#define TRACE_LAYER_SNEP 0x002e0000
|
||||
#define TRACE_LAYER_CHO 0x002f0000
|
||||
#define TRACE_LAYER_NFA 0x00300000
|
||||
|
||||
#define TRACE_LAYER_MAX_NUM 0x0031
|
||||
|
||||
|
||||
/* TRACE_ORIGINATOR 0x0000^^00*/
|
||||
#define TRACE_ORG_MASK 0x0000ff00
|
||||
#define TRACE_GET_ORG(x) ((((UINT32)(x)) & TRACE_ORG_MASK) >> 8)
|
||||
|
||||
#define TRACE_ORG_STACK 0x00000000
|
||||
#define TRACE_ORG_HCI_TRANS 0x00000100
|
||||
#define TRACE_ORG_PROTO_DISP 0x00000200
|
||||
#define TRACE_ORG_RPC 0x00000300
|
||||
#define TRACE_ORG_GKI 0x00000400
|
||||
#define TRACE_ORG_APPL 0x00000500
|
||||
#define TRACE_ORG_SCR_WRAPPER 0x00000600
|
||||
#define TRACE_ORG_SCR_ENGINE 0x00000700
|
||||
#define TRACE_ORG_USER_SCR 0x00000800
|
||||
#define TRACE_ORG_TESTER 0x00000900
|
||||
#define TRACE_ORG_MAX_NUM 10 /* 32-bit mask; must be < 32 */
|
||||
#define TRACE_LITE_ORG_MAX_NUM 6
|
||||
#define TRACE_ORG_ALL 0x03ff
|
||||
#define TRACE_ORG_RPC_TRANS 0x04
|
||||
|
||||
#define TRACE_ORG_REG 0x00000909
|
||||
#define TRACE_ORG_REG_SUCCESS 0x0000090a
|
||||
|
||||
/* TRACE_TYPE 0x000000^^*/
|
||||
#define TRACE_TYPE_MASK 0x000000ff
|
||||
#define TRACE_GET_TYPE(x) (((UINT32)(x)) & TRACE_TYPE_MASK)
|
||||
|
||||
#define TRACE_TYPE_ERROR 0x00000000
|
||||
#define TRACE_TYPE_WARNING 0x00000001
|
||||
#define TRACE_TYPE_API 0x00000002
|
||||
#define TRACE_TYPE_EVENT 0x00000003
|
||||
#define TRACE_TYPE_DEBUG 0x00000004
|
||||
#define TRACE_TYPE_STACK_ONLY_MAX TRACE_TYPE_DEBUG
|
||||
#define TRACE_TYPE_TX 0x00000005
|
||||
#define TRACE_TYPE_RX 0x00000006
|
||||
#define TRACE_TYPE_DEBUG_ASSERT 0x00000007
|
||||
#define TRACE_TYPE_GENERIC 0x00000008
|
||||
#define TRACE_TYPE_REG 0x00000009
|
||||
#define TRACE_TYPE_REG_SUCCESS 0x0000000a
|
||||
#define TRACE_TYPE_CMD_TX 0x0000000b
|
||||
#define TRACE_TYPE_EVT_TX 0x0000000c
|
||||
#define TRACE_TYPE_ACL_TX 0x0000000d
|
||||
#define TRACE_TYPE_CMD_RX 0x0000000e
|
||||
#define TRACE_TYPE_EVT_RX 0x0000000f
|
||||
#define TRACE_TYPE_ACL_RX 0x00000010
|
||||
#define TRACE_TYPE_TARGET_TRACE 0x00000011
|
||||
#define TRACE_TYPE_SCO_TX 0x00000012
|
||||
#define TRACE_TYPE_SCO_RX 0x00000013
|
||||
|
||||
|
||||
#define TRACE_TYPE_MAX_NUM 20
|
||||
#define TRACE_TYPE_ALL 0xffff
|
||||
|
||||
/* Define color for script type */
|
||||
#define SCR_COLOR_DEFAULT 0
|
||||
#define SCR_COLOR_TYPE_COMMENT 1
|
||||
#define SCR_COLOR_TYPE_COMMAND 2
|
||||
#define SCR_COLOR_TYPE_EVENT 3
|
||||
#define SCR_COLOR_TYPE_SELECT 4
|
||||
|
||||
/* Define protocol trace flag values */
|
||||
#define SCR_PROTO_TRACE_HCI_SUMMARY 0x00000001
|
||||
#define SCR_PROTO_TRACE_HCI_DATA 0x00000002
|
||||
#define SCR_PROTO_TRACE_L2CAP 0x00000004
|
||||
#define SCR_PROTO_TRACE_RFCOMM 0x00000008
|
||||
#define SCR_PROTO_TRACE_SDP 0x00000010
|
||||
#define SCR_PROTO_TRACE_TCS 0x00000020
|
||||
#define SCR_PROTO_TRACE_OBEX 0x00000040
|
||||
#define SCR_PROTO_TRACE_OAPP 0x00000080 /* OBEX Application Profile */
|
||||
#define SCR_PROTO_TRACE_AMP 0x00000100
|
||||
#define SCR_PROTO_TRACE_BNEP 0x00000200
|
||||
#define SCR_PROTO_TRACE_AVP 0x00000400
|
||||
#define SCR_PROTO_TRACE_MCA 0x00000800
|
||||
#define SCR_PROTO_TRACE_ATT 0x00001000
|
||||
#define SCR_PROTO_TRACE_SMP 0x00002000
|
||||
#define SCR_PROTO_TRACE_NCI 0x00004000
|
||||
#define SCR_PROTO_TRACE_LLCP 0x00008000
|
||||
#define SCR_PROTO_TRACE_NDEF 0x00010000
|
||||
#define SCR_PROTO_TRACE_RW 0x00020000
|
||||
#define SCR_PROTO_TRACE_CE 0x00040000
|
||||
#define SCR_PROTO_TRACE_SNEP 0x00080000
|
||||
#define SCR_PROTO_TRACE_CHO 0x00100000
|
||||
#define SCR_PROTO_TRACE_ALL 0x001fffff
|
||||
#define SCR_PROTO_TRACE_HCI_LOGGING_VSE 0x0800 /* Brcm vs event for logmsg and protocol traces */
|
||||
|
||||
#define MAX_SCRIPT_TYPE 5
|
||||
|
||||
#define TCS_PSM_INTERCOM 5
|
||||
#define TCS_PSM_CORDLESS 7
|
||||
#define BT_PSM_BNEP 0x000F
|
||||
/* Define PSMs HID uses */
|
||||
#define HID_PSM_CONTROL 0x0011
|
||||
#define HID_PSM_INTERRUPT 0x0013
|
||||
|
||||
/* Define a function for logging */
|
||||
typedef void (BT_LOG_FUNC) (int trace_type, const char *fmt_str, ...);
|
||||
|
||||
/* bd addr length and type */
|
||||
#ifndef BD_ADDR_LEN
|
||||
#define BD_ADDR_LEN 6
|
||||
typedef uint8_t BD_ADDR[BD_ADDR_LEN];
|
||||
#endif
|
||||
|
||||
// From bd.c
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* global constant for "any" bd addr */
|
||||
static const BD_ADDR bd_addr_any = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
static const BD_ADDR bd_addr_null = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
/*****************************************************************************
|
||||
** Functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bdcpy
|
||||
**
|
||||
** Description Copy bd addr b to a.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static inline void bdcpy(BD_ADDR a, const BD_ADDR b)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = BD_ADDR_LEN; i != 0; i--) {
|
||||
*a++ = *b++;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bdcmp
|
||||
**
|
||||
** Description Compare bd addr b to a.
|
||||
**
|
||||
**
|
||||
** Returns Zero if b==a, nonzero otherwise (like memcmp).
|
||||
**
|
||||
*******************************************************************************/
|
||||
static inline int bdcmp(const BD_ADDR a, const BD_ADDR b)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = BD_ADDR_LEN; i != 0; i--) {
|
||||
if (*a++ != *b++) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bdcmpany
|
||||
**
|
||||
** Description Compare bd addr to "any" bd addr.
|
||||
**
|
||||
**
|
||||
** Returns Zero if a equals bd_addr_any.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static inline int bdcmpany(const BD_ADDR a)
|
||||
{
|
||||
return bdcmp(a, bd_addr_any);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bdsetany
|
||||
**
|
||||
** Description Set bd addr to "any" bd addr.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static inline void bdsetany(BD_ADDR a)
|
||||
{
|
||||
bdcpy(a, bd_addr_any);
|
||||
}
|
||||
#endif
|
362
tools/sdk/include/bluedroid/bt_vendor_lib.h
Normal file
362
tools/sdk/include/bluedroid/bt_vendor_lib.h
Normal file
@ -0,0 +1,362 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BT_VENDOR_LIB_H
|
||||
#define BT_VENDOR_LIB_H
|
||||
|
||||
#include <stdint.h>
|
||||
//#include <sys/cdefs.h>
|
||||
//#include <sys/types.h>
|
||||
|
||||
/** Struct types */
|
||||
|
||||
|
||||
/** Typedefs and defines */
|
||||
|
||||
/** Vendor specific operations OPCODE */
|
||||
typedef enum {
|
||||
/* [operation]
|
||||
* Power on or off the BT Controller.
|
||||
* [input param]
|
||||
* A pointer to int type with content of bt_vendor_power_state_t.
|
||||
* Typecasting conversion: (int *) param.
|
||||
* [return]
|
||||
* 0 - default, don't care.
|
||||
* [callback]
|
||||
* None.
|
||||
*/
|
||||
BT_VND_OP_POWER_CTRL,
|
||||
|
||||
/* [operation]
|
||||
* Perform any vendor specific initialization or configuration
|
||||
* on the BT Controller. This is called before stack initialization.
|
||||
* [input param]
|
||||
* None.
|
||||
* [return]
|
||||
* 0 - default, don't care.
|
||||
* [callback]
|
||||
* Must call fwcfg_cb to notify the stack of the completion of vendor
|
||||
* specific initialization once it has been done.
|
||||
*/
|
||||
BT_VND_OP_FW_CFG,
|
||||
|
||||
/* [operation]
|
||||
* Perform any vendor specific SCO/PCM configuration on the BT Controller.
|
||||
* This is called after stack initialization.
|
||||
* [input param]
|
||||
* None.
|
||||
* [return]
|
||||
* 0 - default, don't care.
|
||||
* [callback]
|
||||
* Must call scocfg_cb to notify the stack of the completion of vendor
|
||||
* specific SCO configuration once it has been done.
|
||||
*/
|
||||
BT_VND_OP_SCO_CFG,
|
||||
|
||||
/* [operation]
|
||||
* Open UART port on where the BT Controller is attached.
|
||||
* This is called before stack initialization.
|
||||
* [input param]
|
||||
* A pointer to int array type for open file descriptors.
|
||||
* The mapping of HCI channel to fd slot in the int array is given in
|
||||
* bt_vendor_hci_channels_t.
|
||||
* And, it requires the vendor lib to fill up the content before returning
|
||||
* the call.
|
||||
* Typecasting conversion: (int (*)[]) param.
|
||||
* [return]
|
||||
* Numbers of opened file descriptors.
|
||||
* Valid number:
|
||||
* 1 - CMD/EVT/ACL-In/ACL-Out via the same fd (e.g. UART)
|
||||
* 2 - CMD/EVT on one fd, and ACL-In/ACL-Out on the other fd
|
||||
* 4 - CMD, EVT, ACL-In, ACL-Out are on their individual fd
|
||||
* [callback]
|
||||
* None.
|
||||
*/
|
||||
BT_VND_OP_USERIAL_OPEN,
|
||||
|
||||
/* [operation]
|
||||
* Close the previously opened UART port.
|
||||
* [input param]
|
||||
* None.
|
||||
* [return]
|
||||
* 0 - default, don't care.
|
||||
* [callback]
|
||||
* None.
|
||||
*/
|
||||
BT_VND_OP_USERIAL_CLOSE,
|
||||
|
||||
/* [operation]
|
||||
* Get the LPM idle timeout in milliseconds.
|
||||
* The stack uses this information to launch a timer delay before it
|
||||
* attempts to de-assert LPM WAKE signal once downstream HCI packet
|
||||
* has been delivered.
|
||||
* [input param]
|
||||
* A pointer to uint32_t type which is passed in by the stack. And, it
|
||||
* requires the vendor lib to fill up the content before returning
|
||||
* the call.
|
||||
* Typecasting conversion: (uint32_t *) param.
|
||||
* [return]
|
||||
* 0 - default, don't care.
|
||||
* [callback]
|
||||
* None.
|
||||
*/
|
||||
BT_VND_OP_GET_LPM_IDLE_TIMEOUT,
|
||||
|
||||
/* [operation]
|
||||
* Enable or disable LPM mode on BT Controller.
|
||||
* [input param]
|
||||
* A pointer to uint8_t type with content of bt_vendor_lpm_mode_t.
|
||||
* Typecasting conversion: (uint8_t *) param.
|
||||
* [return]
|
||||
* 0 - default, don't care.
|
||||
* [callback]
|
||||
* Must call lpm_cb to notify the stack of the completion of LPM
|
||||
* disable/enable process once it has been done.
|
||||
*/
|
||||
BT_VND_OP_LPM_SET_MODE,
|
||||
|
||||
/* [operation]
|
||||
* Assert or Deassert LPM WAKE on BT Controller.
|
||||
* [input param]
|
||||
* A pointer to uint8_t type with content of bt_vendor_lpm_wake_state_t.
|
||||
* Typecasting conversion: (uint8_t *) param.
|
||||
* [return]
|
||||
* 0 - default, don't care.
|
||||
* [callback]
|
||||
* None.
|
||||
*/
|
||||
BT_VND_OP_LPM_WAKE_SET_STATE,
|
||||
|
||||
/* [operation]
|
||||
* Perform any vendor specific commands related to audio state changes.
|
||||
* [input param]
|
||||
* a pointer to bt_vendor_op_audio_state_t indicating what audio state is
|
||||
* set.
|
||||
* [return]
|
||||
* 0 - default, don't care.
|
||||
* [callback]
|
||||
* None.
|
||||
*/
|
||||
BT_VND_OP_SET_AUDIO_STATE,
|
||||
|
||||
/* [operation]
|
||||
* The epilog call to the vendor module so that it can perform any
|
||||
* vendor-specific processes (e.g. send a HCI_RESET to BT Controller)
|
||||
* before the caller calls for cleanup().
|
||||
* [input param]
|
||||
* None.
|
||||
* [return]
|
||||
* 0 - default, don't care.
|
||||
* [callback]
|
||||
* Must call epilog_cb to notify the stack of the completion of vendor
|
||||
* specific epilog process once it has been done.
|
||||
*/
|
||||
BT_VND_OP_EPILOG,
|
||||
} bt_vendor_opcode_t;
|
||||
|
||||
/** Power on/off control states */
|
||||
typedef enum {
|
||||
BT_VND_PWR_OFF,
|
||||
BT_VND_PWR_ON,
|
||||
} bt_vendor_power_state_t;
|
||||
|
||||
/** Define HCI channel identifier in the file descriptors array
|
||||
used in BT_VND_OP_USERIAL_OPEN operation.
|
||||
*/
|
||||
typedef enum {
|
||||
CH_CMD, // HCI Command channel
|
||||
CH_EVT, // HCI Event channel
|
||||
CH_ACL_OUT, // HCI ACL downstream channel
|
||||
CH_ACL_IN, // HCI ACL upstream channel
|
||||
|
||||
CH_MAX // Total channels
|
||||
} bt_vendor_hci_channels_t;
|
||||
|
||||
/** LPM disable/enable request */
|
||||
typedef enum {
|
||||
BT_VND_LPM_DISABLE,
|
||||
BT_VND_LPM_ENABLE,
|
||||
} bt_vendor_lpm_mode_t;
|
||||
|
||||
/** LPM WAKE set state request */
|
||||
typedef enum {
|
||||
BT_VND_LPM_WAKE_ASSERT,
|
||||
BT_VND_LPM_WAKE_DEASSERT,
|
||||
} bt_vendor_lpm_wake_state_t;
|
||||
|
||||
/** Callback result values */
|
||||
typedef enum {
|
||||
BT_VND_OP_RESULT_SUCCESS,
|
||||
BT_VND_OP_RESULT_FAIL,
|
||||
} bt_vendor_op_result_t;
|
||||
|
||||
/** audio (SCO) state changes triggering VS commands for configuration */
|
||||
typedef struct {
|
||||
uint16_t handle;
|
||||
uint16_t peer_codec;
|
||||
uint16_t state;
|
||||
} bt_vendor_op_audio_state_t;
|
||||
|
||||
/*
|
||||
* Bluetooth Host/Controller Vendor callback structure.
|
||||
*/
|
||||
|
||||
/* vendor initialization/configuration callback */
|
||||
typedef void (*cfg_result_cb)(bt_vendor_op_result_t result);
|
||||
|
||||
/* datapath buffer allocation callback (callout)
|
||||
*
|
||||
* Vendor lib needs to request a buffer through the alloc callout function
|
||||
* from HCI lib if the buffer is for constructing a HCI Command packet which
|
||||
* will be sent through xmit_cb to BT Controller.
|
||||
*
|
||||
* For each buffer allocation, the requested size needs to be big enough to
|
||||
* accommodate the below header plus a complete HCI packet --
|
||||
* typedef struct
|
||||
* {
|
||||
* uint16_t event;
|
||||
* uint16_t len;
|
||||
* uint16_t offset;
|
||||
* uint16_t layer_specific;
|
||||
* } HC_BT_HDR;
|
||||
*
|
||||
* HCI lib returns a pointer to the buffer where Vendor lib should use to
|
||||
* construct a HCI command packet as below format:
|
||||
*
|
||||
* --------------------------------------------
|
||||
* | HC_BT_HDR | HCI command |
|
||||
* --------------------------------------------
|
||||
* where
|
||||
* HC_BT_HDR.event = 0x2000;
|
||||
* HC_BT_HDR.len = Length of HCI command;
|
||||
* HC_BT_HDR.offset = 0;
|
||||
* HC_BT_HDR.layer_specific = 0;
|
||||
*
|
||||
* For example, a HCI_RESET Command will be formed as
|
||||
* ------------------------
|
||||
* | HC_BT_HDR |03|0c|00|
|
||||
* ------------------------
|
||||
* with
|
||||
* HC_BT_HDR.event = 0x2000;
|
||||
* HC_BT_HDR.len = 3;
|
||||
* HC_BT_HDR.offset = 0;
|
||||
* HC_BT_HDR.layer_specific = 0;
|
||||
*/
|
||||
typedef void *(*malloc_cb)(int size);
|
||||
|
||||
/* datapath buffer deallocation callback (callout) */
|
||||
typedef void (*mdealloc_cb)(void *p_buf);
|
||||
|
||||
/* define callback of the cmd_xmit_cb
|
||||
*
|
||||
* The callback function which HCI lib will call with the return of command
|
||||
* complete packet. Vendor lib is responsible for releasing the buffer passed
|
||||
* in at the p_mem parameter by calling dealloc callout function.
|
||||
*/
|
||||
typedef void (*tINT_CMD_CBACK)(void *p_mem);
|
||||
|
||||
/* hci command packet transmit callback (callout)
|
||||
*
|
||||
* Vendor lib calls xmit_cb callout function in order to send a HCI Command
|
||||
* packet to BT Controller. The buffer carrying HCI Command packet content
|
||||
* needs to be first allocated through the alloc callout function.
|
||||
* HCI lib will release the buffer for Vendor lib once it has delivered the
|
||||
* packet content to BT Controller.
|
||||
*
|
||||
* Vendor lib needs also provide a callback function (p_cback) which HCI lib
|
||||
* will call with the return of command complete packet.
|
||||
*
|
||||
* The opcode parameter gives the HCI OpCode (combination of OGF and OCF) of
|
||||
* HCI Command packet. For example, opcode = 0x0c03 for the HCI_RESET command
|
||||
* packet.
|
||||
*/
|
||||
typedef uint8_t (*cmd_xmit_cb)(uint16_t opcode, void *p_buf, tINT_CMD_CBACK p_cback);
|
||||
|
||||
typedef struct {
|
||||
/** set to sizeof(bt_vendor_callbacks_t) */
|
||||
size_t size;
|
||||
|
||||
/*
|
||||
* Callback and callout functions have implemented in HCI libray
|
||||
* (libbt-hci.so).
|
||||
*/
|
||||
|
||||
/* notifies caller result of firmware configuration request */
|
||||
cfg_result_cb fwcfg_cb;
|
||||
|
||||
/* notifies caller result of sco configuration request */
|
||||
cfg_result_cb scocfg_cb;
|
||||
|
||||
/* notifies caller result of lpm enable/disable */
|
||||
cfg_result_cb lpm_cb;
|
||||
|
||||
/* notifies the result of codec setting */
|
||||
cfg_result_cb audio_state_cb;
|
||||
|
||||
/* buffer allocation request */
|
||||
malloc_cb alloc;
|
||||
|
||||
/* buffer deallocation request */
|
||||
mdealloc_cb dealloc;
|
||||
|
||||
/* hci command packet transmit request */
|
||||
cmd_xmit_cb xmit_cb;
|
||||
|
||||
/* notifies caller completion of epilog process */
|
||||
cfg_result_cb epilog_cb;
|
||||
} bt_vendor_callbacks_t;
|
||||
|
||||
/*
|
||||
* Bluetooth Host/Controller VENDOR Interface
|
||||
*/
|
||||
typedef struct {
|
||||
/** Set to sizeof(bt_vndor_interface_t) */
|
||||
size_t size;
|
||||
|
||||
/*
|
||||
* Functions need to be implemented in Vendor libray (libbt-vendor.so).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Caller will open the interface and pass in the callback routines
|
||||
* to the implemenation of this interface.
|
||||
*/
|
||||
int (*init)(const bt_vendor_callbacks_t *p_cb, unsigned char *local_bdaddr);
|
||||
|
||||
/** Vendor specific operations */
|
||||
int (*op)(bt_vendor_opcode_t opcode, void *param);
|
||||
|
||||
/** Closes the interface */
|
||||
void (*cleanup)(void);
|
||||
} bt_vendor_interface_t;
|
||||
|
||||
|
||||
/*
|
||||
* External shared lib functions/data
|
||||
*/
|
||||
|
||||
/* Entry point of DLib --
|
||||
* Vendor library needs to implement the body of bt_vendor_interface_t
|
||||
* structure and uses the below name as the variable name. HCI library
|
||||
* will use this symbol name to get address of the object through the
|
||||
* dlsym call.
|
||||
*/
|
||||
//extern const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE;
|
||||
|
||||
#endif /* BT_VENDOR_LIB_H */
|
||||
|
2399
tools/sdk/include/bluedroid/bta_api.h
Normal file
2399
tools/sdk/include/bluedroid/bta_api.h
Normal file
File diff suppressed because it is too large
Load Diff
80
tools/sdk/include/bluedroid/bta_dm_ci.h
Normal file
80
tools/sdk/include/bluedroid/bta_dm_ci.h
Normal file
@ -0,0 +1,80 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 interface file for device mananger call-in functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_DM_CI_H
|
||||
#define BTA_DM_CI_H
|
||||
|
||||
#include "bta_api.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ci_io_req
|
||||
**
|
||||
** Description This function must be called in response to function
|
||||
** bta_dm_co_io_req(), if *p_oob_data is set to BTA_OOB_UNKNOWN
|
||||
** by bta_dm_co_io_req().
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_ci_io_req(BD_ADDR bd_addr, tBTA_IO_CAP io_cap,
|
||||
tBTA_OOB_DATA oob_data, tBTA_AUTH_REQ auth_req);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ci_rmt_oob
|
||||
**
|
||||
** Description This function must be called in response to function
|
||||
** bta_dm_co_rmt_oob() to provide the OOB data associated
|
||||
** with the remote device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_ci_rmt_oob(BOOLEAN accept, BD_ADDR bd_addr,
|
||||
BT_OCTET16 c, BT_OCTET16 r);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_ci_data_ready
|
||||
**
|
||||
** Description This function sends an event to indicating that the phone
|
||||
** has SCO data ready..
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_sco_ci_data_ready(UINT16 event, UINT16 sco_handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
273
tools/sdk/include/bluedroid/bta_dm_co.h
Normal file
273
tools/sdk/include/bluedroid/bta_dm_co.h
Normal file
@ -0,0 +1,273 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 interface file for device mananger callout functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_DM_CO_H
|
||||
#define BTA_DM_CO_H
|
||||
|
||||
#include "bta_sys.h"
|
||||
|
||||
|
||||
#ifndef BTA_SCO_OUT_PKT_SIZE
|
||||
#define BTA_SCO_OUT_PKT_SIZE BTM_SCO_DATA_SIZE_MAX
|
||||
#endif
|
||||
|
||||
#define BTA_SCO_CODEC_PCM 0 /* used for regular SCO */
|
||||
#define BTA_SCO_CODEC_SBC 1 /* used for WBS */
|
||||
typedef UINT8 tBTA_SCO_CODEC_TYPE;
|
||||
|
||||
#define BTA_DM_SCO_SAMP_RATE_8K 8000
|
||||
#define BTA_DM_SCO_SAMP_RATE_16K 16000
|
||||
|
||||
/* SCO codec information */
|
||||
typedef struct {
|
||||
tBTA_SCO_CODEC_TYPE codec_type;
|
||||
} tBTA_CODEC_INFO;
|
||||
|
||||
#define BTA_DM_SCO_ROUTE_PCM BTM_SCO_ROUTE_PCM
|
||||
#define BTA_DM_SCO_ROUTE_HCI BTM_SCO_ROUTE_HCI
|
||||
|
||||
typedef tBTM_SCO_ROUTE_TYPE tBTA_DM_SCO_ROUTE_TYPE;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Function Declarations
|
||||
*****************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_io_req
|
||||
**
|
||||
** Description This callout function is executed by DM to get IO capabilities
|
||||
** of the local device for the Simple Pairing process
|
||||
**
|
||||
** Parameters bd_addr - The peer device
|
||||
** *p_io_cap - The local Input/Output capabilities
|
||||
** *p_oob_data - TRUE, if OOB data is available for the peer device.
|
||||
** *p_auth_req - TRUE, if MITM protection is required.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_co_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
|
||||
tBTA_OOB_DATA *p_oob_data, tBTA_AUTH_REQ *p_auth_req,
|
||||
BOOLEAN is_orig);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_io_rsp
|
||||
**
|
||||
** Description This callout function is executed by DM to report IO capabilities
|
||||
** of the peer device for the Simple Pairing process
|
||||
**
|
||||
** Parameters bd_addr - The peer device
|
||||
** io_cap - The remote Input/Output capabilities
|
||||
** oob_data - TRUE, if OOB data is available for the peer device.
|
||||
** auth_req - TRUE, if MITM protection is required.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_co_io_rsp(BD_ADDR bd_addr, tBTA_IO_CAP io_cap,
|
||||
tBTA_OOB_DATA oob_data, tBTA_AUTH_REQ auth_req);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_lk_upgrade
|
||||
**
|
||||
** Description This callout function is executed by DM to check if the
|
||||
** platform wants allow link key upgrade
|
||||
**
|
||||
** Parameters bd_addr - The peer device
|
||||
** *p_upgrade - TRUE, if link key upgrade is desired.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_co_lk_upgrade(BD_ADDR bd_addr, BOOLEAN *p_upgrade );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_loc_oob
|
||||
**
|
||||
** Description This callout function is executed by DM to report the OOB
|
||||
** data of the local device for the Simple Pairing process
|
||||
**
|
||||
** Parameters valid - TRUE, if the local OOB data is retrieved from LM
|
||||
** c - Simple Pairing Hash C
|
||||
** r - Simple Pairing Randomnizer R
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_co_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_rmt_oob
|
||||
**
|
||||
** Description This callout function is executed by DM to request the OOB
|
||||
** data for the remote device for the Simple Pairing process
|
||||
**
|
||||
** Parameters bd_addr - The peer device
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_co_rmt_oob(BD_ADDR bd_addr);
|
||||
|
||||
/*****************************************************************************
|
||||
** SCO over HCI Function Declarations
|
||||
*****************************************************************************/
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_init
|
||||
**
|
||||
** Description This function can be used by the phone to initialize audio
|
||||
** codec or for other initialization purposes before SCO connection
|
||||
** is opened.
|
||||
**
|
||||
**
|
||||
** Returns Void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_DM_SCO_ROUTE_TYPE bta_dm_sco_co_init(UINT32 rx_bw, UINT32 tx_bw,
|
||||
tBTA_CODEC_INFO *p_codec_info, UINT8 app_id);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_open
|
||||
**
|
||||
** Description This function is executed when a SCO connection is open.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_sco_co_open(UINT16 handle, UINT8 pkt_size, UINT16 event);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_close
|
||||
**
|
||||
** Description This function is called when a SCO connection is closed
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_sco_co_close(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_out_data
|
||||
**
|
||||
** Description This function is called to send SCO data over HCI.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_sco_co_out_data(BT_HDR **p_buf);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_in_data
|
||||
**
|
||||
** Description This function is called to send incoming SCO data to application.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_sco_co_in_data(BT_HDR *p_buf, tBTM_SCO_DATA_FLAG status);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_ble_io_req
|
||||
**
|
||||
** Description This callout function is executed by DM to get BLE IO capabilities
|
||||
** before SMP pairing gets going.
|
||||
**
|
||||
** Parameters bd_addr - The peer device
|
||||
** *p_io_cap - The local Input/Output capabilities
|
||||
** *p_oob_data - TRUE, if OOB data is available for the peer device.
|
||||
** *p_auth_req - Auth request setting (Bonding and MITM required or not)
|
||||
** *p_max_key_size - max key size local device supported.
|
||||
** *p_init_key - initiator keys.
|
||||
** *p_resp_key - responder keys.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
|
||||
tBTA_OOB_DATA *p_oob_data,
|
||||
tBTA_LE_AUTH_REQ *p_auth_req,
|
||||
UINT8 *p_max_key_size,
|
||||
tBTA_LE_KEY_TYPE *p_init_key,
|
||||
tBTA_LE_KEY_TYPE *p_resp_key );
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_ble_local_key_reload
|
||||
**
|
||||
** Description This callout function is to load the local BLE keys if available
|
||||
** on the device.
|
||||
**
|
||||
** Parameters none
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_co_ble_load_local_keys (tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er,
|
||||
tBTA_BLE_LOCAL_ID_KEYS *p_id_keys);
|
||||
|
||||
// btla-specific ++
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_ble_io_req
|
||||
**
|
||||
** Description This callout function is executed by DM to get BLE IO capabilities
|
||||
** before SMP pairing gets going.
|
||||
**
|
||||
** Parameters bd_addr - The peer device
|
||||
** *p_io_cap - The local Input/Output capabilities
|
||||
** *p_oob_data - TRUE, if OOB data is available for the peer device.
|
||||
** *p_auth_req - Auth request setting (Bonding and MITM required or not)
|
||||
** *p_max_key_size - max key size local device supported.
|
||||
** *p_init_key - initiator keys.
|
||||
** *p_resp_key - responder keys.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
|
||||
tBTA_OOB_DATA *p_oob_data,
|
||||
tBTA_LE_AUTH_REQ *p_auth_req,
|
||||
UINT8 *p_max_key_size,
|
||||
tBTA_LE_KEY_TYPE *p_init_key,
|
||||
tBTA_LE_KEY_TYPE *p_resp_key );
|
||||
// btla-specific --
|
||||
|
||||
#endif
|
1416
tools/sdk/include/bluedroid/bta_gatt_api.h
Normal file
1416
tools/sdk/include/bluedroid/bta_gatt_api.h
Normal file
File diff suppressed because it is too large
Load Diff
117
tools/sdk/include/bluedroid/bta_gattc_ci.h
Normal file
117
tools/sdk/include/bluedroid/bta_gattc_ci.h
Normal file
@ -0,0 +1,117 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 interface file for GATT call-in functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_GATTC_CI_H
|
||||
#define BTA_GATTC_CI_H
|
||||
|
||||
#include "bta_gatt_api.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
|
||||
/* Open Complete Event */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_STATUS status;
|
||||
} tBTA_GATTC_CI_EVT;
|
||||
|
||||
#define BTA_GATTC_NV_LOAD_MAX 10
|
||||
|
||||
/* Read Ready Event */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_STATUS status;
|
||||
UINT16 num_attr;
|
||||
tBTA_GATTC_NV_ATTR attr[BTA_GATTC_NV_LOAD_MAX];
|
||||
} tBTA_GATTC_CI_LOAD;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_ci_cache_open
|
||||
**
|
||||
** Description This function sends an event to indicate server cache open
|
||||
** completed.
|
||||
**
|
||||
** Parameters server_bda - server BDA of this cache.
|
||||
** status - BTA_GATT_OK if full buffer of data,
|
||||
** BTA_GATT_FAIL if an error has occurred.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_gattc_ci_cache_open(BD_ADDR server_bda, UINT16 evt,
|
||||
tBTA_GATT_STATUS status, UINT16 conn_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_ci_cache_load
|
||||
**
|
||||
** Description This function sends an event to BTA indicating the phone has
|
||||
** load the servere cache and ready to send it to the stack.
|
||||
**
|
||||
** Parameters server_bda - server BDA of this cache.
|
||||
** num_bytes_read - number of bytes read into the buffer
|
||||
** specified in the read callout-function.
|
||||
** status - BTA_GATT_OK if full buffer of data,
|
||||
** BTA_GATT_FAIL if an error has occurred.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_gattc_ci_cache_load(BD_ADDR server_bda, UINT16 evt,
|
||||
UINT16 num_attr, tBTA_GATTC_NV_ATTR *p_atrr,
|
||||
tBTA_GATT_STATUS status, UINT16 conn_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_ci_save
|
||||
**
|
||||
** Description This function sends an event to BTA indicating the phone has
|
||||
** save the server cache.
|
||||
**
|
||||
** Parameters server_bda - server BDA of this cache.
|
||||
** status - BTA_GATT_OK if full buffer of data,
|
||||
** BTA_GATT_FAIL if an error has occurred.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_gattc_ci_cache_save(BD_ADDR server_bda, UINT16 evt,
|
||||
tBTA_GATT_STATUS status, UINT16 conn_id);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BTA_GATTC_CI_H */
|
114
tools/sdk/include/bluedroid/bta_gattc_co.h
Normal file
114
tools/sdk/include/bluedroid/bta_gattc_co.h
Normal file
@ -0,0 +1,114 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2013 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 interface file for BTA GATT client call-out functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_GATTC_CO_H
|
||||
#define BTA_GATTC_CO_H
|
||||
|
||||
#include "bta_gatt_api.h"
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_co_cache_open
|
||||
**
|
||||
** Description This callout function is executed by GATTC when a GATT server
|
||||
** cache is ready to be sent.
|
||||
**
|
||||
** Parameter server_bda: server bd address of this cache belongs to
|
||||
** evt: call in event to be passed in when cache open is done.
|
||||
** conn_id: connection ID of this cache operation attach to.
|
||||
** to_save: open cache to save or to load.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_gattc_co_cache_open(BD_ADDR server_bda, UINT16 evt,
|
||||
UINT16 conn_id, BOOLEAN to_save);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_co_cache_close
|
||||
**
|
||||
** Description This callout function is executed by GATTC when a GATT server
|
||||
** cache is written completely.
|
||||
**
|
||||
** Parameter server_bda: server bd address of this cache belongs to
|
||||
** conn_id: connection ID of this cache operation attach to.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_gattc_co_cache_close(BD_ADDR server_bda, UINT16 conn_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_co_cache_save
|
||||
**
|
||||
** Description This callout function is executed by GATT when a server cache
|
||||
** is available to save.
|
||||
**
|
||||
** Parameter server_bda: server bd address of this cache belongs to
|
||||
** evt: call in event to be passed in when cache save is done.
|
||||
** num_attr: number of attribute to be save.
|
||||
** p_attr: pointer to the list of attributes to save.
|
||||
** attr_index: starting attribute index of the save operation.
|
||||
** conn_id: connection ID of this cache operation attach to.
|
||||
** Returns
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_gattc_co_cache_save(BD_ADDR server_bda, UINT16 evt,
|
||||
UINT16 num_attr, tBTA_GATTC_NV_ATTR *p_attr,
|
||||
UINT16 attr_index, UINT16 conn_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_co_cache_load
|
||||
**
|
||||
** Description This callout function is executed by GATT when server cache
|
||||
** is required to load.
|
||||
**
|
||||
** Parameter server_bda: server bd address of this cache belongs to
|
||||
** evt: call in event to be passed in when cache save is done.
|
||||
** num_attr: number of attribute to be save.
|
||||
** attr_index: starting attribute index of the save operation.
|
||||
** conn_id: connection ID of this cache operation attach to.
|
||||
** Returns
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_gattc_co_cache_load(BD_ADDR server_bda, UINT16 evt,
|
||||
UINT16 start_index, UINT16 conn_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_co_cache_reset
|
||||
**
|
||||
** Description This callout function is executed by GATTC to reset cache in
|
||||
** application
|
||||
**
|
||||
** Parameter server_bda: server bd address of this cache belongs to
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_gattc_co_cache_reset(BD_ADDR server_bda);
|
||||
|
||||
#endif /* BTA_GATT_CO_H */
|
525
tools/sdk/include/bluedroid/bta_gattc_int.h
Normal file
525
tools/sdk/include/bluedroid/bta_gattc_int.h
Normal file
@ -0,0 +1,525 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 file for the file transfer client (FTC).
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_GATTC_INT_H
|
||||
#define BTA_GATTC_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#include "bta_gattc_ci.h"
|
||||
#include "bta_gattc_co.h"
|
||||
|
||||
#include "gki.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
enum {
|
||||
BTA_GATTC_API_OPEN_EVT = BTA_SYS_EVT_START(BTA_ID_GATTC),
|
||||
BTA_GATTC_INT_OPEN_FAIL_EVT,
|
||||
BTA_GATTC_API_CANCEL_OPEN_EVT,
|
||||
BTA_GATTC_INT_CANCEL_OPEN_OK_EVT,
|
||||
|
||||
BTA_GATTC_API_READ_EVT,
|
||||
BTA_GATTC_API_WRITE_EVT,
|
||||
BTA_GATTC_API_EXEC_EVT,
|
||||
BTA_GATTC_API_CFG_MTU_EVT,
|
||||
|
||||
BTA_GATTC_API_CLOSE_EVT,
|
||||
|
||||
BTA_GATTC_API_SEARCH_EVT,
|
||||
BTA_GATTC_API_CONFIRM_EVT,
|
||||
BTA_GATTC_API_READ_MULTI_EVT,
|
||||
BTA_GATTC_API_REFRESH_EVT,
|
||||
|
||||
BTA_GATTC_INT_CONN_EVT,
|
||||
BTA_GATTC_INT_DISCOVER_EVT,
|
||||
BTA_GATTC_DISCOVER_CMPL_EVT,
|
||||
BTA_GATTC_OP_CMPL_EVT,
|
||||
BTA_GATTC_INT_DISCONN_EVT,
|
||||
|
||||
/* for cache loading/saving */
|
||||
BTA_GATTC_START_CACHE_EVT,
|
||||
BTA_GATTC_CI_CACHE_OPEN_EVT,
|
||||
BTA_GATTC_CI_CACHE_LOAD_EVT,
|
||||
BTA_GATTC_CI_CACHE_SAVE_EVT,
|
||||
|
||||
BTA_GATTC_INT_START_IF_EVT,
|
||||
BTA_GATTC_API_REG_EVT,
|
||||
BTA_GATTC_API_DEREG_EVT,
|
||||
BTA_GATTC_API_LISTEN_EVT,
|
||||
BTA_GATTC_API_BROADCAST_EVT,
|
||||
BTA_GATTC_API_DISABLE_EVT,
|
||||
BTA_GATTC_ENC_CMPL_EVT
|
||||
};
|
||||
typedef UINT16 tBTA_GATTC_INT_EVT;
|
||||
|
||||
/* max client application GATTC can support */
|
||||
#ifndef BTA_GATTC_CL_MAX
|
||||
#define BTA_GATTC_CL_MAX 3 // 32
|
||||
#endif
|
||||
|
||||
/* max known devices GATTC can support */
|
||||
#ifndef BTA_GATTC_KNOWN_SR_MAX
|
||||
#define BTA_GATTC_KNOWN_SR_MAX 3 // 10
|
||||
#endif
|
||||
|
||||
#define BTA_GATTC_CONN_MAX GATT_MAX_PHY_CHANNEL
|
||||
|
||||
#ifndef BTA_GATTC_CLCB_MAX
|
||||
#define BTA_GATTC_CLCB_MAX GATT_CL_MAX_LCB
|
||||
#endif
|
||||
|
||||
#define BTA_GATTC_WRITE_PREPARE GATT_WRITE_PREPARE
|
||||
|
||||
|
||||
/* internal strucutre for GATTC register API */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBT_UUID app_uuid;
|
||||
tBTA_GATTC_CBACK *p_cback;
|
||||
} tBTA_GATTC_API_REG;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATTC_IF client_if;
|
||||
} tBTA_GATTC_INT_START_IF;
|
||||
|
||||
typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_API_DEREG;
|
||||
typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_INT_DEREG;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTC_IF client_if;
|
||||
BOOLEAN is_direct;
|
||||
tBTA_TRANSPORT transport;
|
||||
} tBTA_GATTC_API_OPEN;
|
||||
|
||||
typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_AUTH_REQ auth_req;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
tBTA_GATT_ID *p_descr_type;
|
||||
} tBTA_GATTC_API_READ;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_AUTH_REQ auth_req;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
tBTA_GATT_ID *p_descr_type;
|
||||
tBTA_GATTC_WRITE_TYPE write_type;
|
||||
UINT16 offset;
|
||||
UINT16 len;
|
||||
UINT8 *p_value;
|
||||
} tBTA_GATTC_API_WRITE;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN is_execute;
|
||||
} tBTA_GATTC_API_EXEC;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
} tBTA_GATTC_API_CONFIRM;
|
||||
|
||||
typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 op_code;
|
||||
tGATT_STATUS status;
|
||||
tBTA_GATTC_CMPL *p_cmpl;
|
||||
} tBTA_GATTC_OP_CMPL;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBT_UUID *p_srvc_uuid;
|
||||
} tBTA_GATTC_API_SEARCH;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_AUTH_REQ auth_req;
|
||||
UINT8 num_attr;
|
||||
tBTA_GATTC_ATTR_ID *p_id_list;
|
||||
} tBTA_GATTC_API_READ_MULTI;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR_PTR remote_bda;
|
||||
tBTA_GATTC_IF client_if;
|
||||
BOOLEAN start;
|
||||
} tBTA_GATTC_API_LISTEN;
|
||||
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 mtu;
|
||||
} tBTA_GATTC_API_CFG_MTU;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTC_IF client_if;
|
||||
UINT8 role;
|
||||
tBT_TRANSPORT transport;
|
||||
tGATT_DISCONN_REASON reason;
|
||||
} tBTA_GATTC_INT_CONN;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTC_IF client_if;
|
||||
} tBTA_GATTC_ENC_CMPL;
|
||||
|
||||
typedef union {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATTC_API_REG api_reg;
|
||||
tBTA_GATTC_API_DEREG api_dereg;
|
||||
tBTA_GATTC_API_OPEN api_conn;
|
||||
tBTA_GATTC_API_CANCEL_OPEN api_cancel_conn;
|
||||
tBTA_GATTC_API_READ api_read;
|
||||
tBTA_GATTC_API_SEARCH api_search;
|
||||
tBTA_GATTC_API_WRITE api_write;
|
||||
tBTA_GATTC_API_CONFIRM api_confirm;
|
||||
tBTA_GATTC_API_EXEC api_exec;
|
||||
tBTA_GATTC_API_READ_MULTI api_read_multi;
|
||||
tBTA_GATTC_API_CFG_MTU api_mtu;
|
||||
tBTA_GATTC_OP_CMPL op_cmpl;
|
||||
tBTA_GATTC_CI_EVT ci_open;
|
||||
tBTA_GATTC_CI_EVT ci_save;
|
||||
tBTA_GATTC_CI_LOAD ci_load;
|
||||
tBTA_GATTC_INT_CONN int_conn;
|
||||
tBTA_GATTC_ENC_CMPL enc_cmpl;
|
||||
|
||||
tBTA_GATTC_INT_START_IF int_start_if;
|
||||
tBTA_GATTC_INT_DEREG int_dereg;
|
||||
/* if peripheral role is supported */
|
||||
tBTA_GATTC_API_LISTEN api_listen;
|
||||
|
||||
} tBTA_GATTC_DATA;
|
||||
|
||||
|
||||
/* GATT server cache on the client */
|
||||
typedef union {
|
||||
UINT8 uuid128[LEN_UUID_128];
|
||||
UINT16 uuid16;
|
||||
} tBTA_GATTC_UUID;
|
||||
|
||||
typedef struct gattc_attr_cache {
|
||||
tBTA_GATTC_UUID *p_uuid;
|
||||
struct gattc_attr_cache *p_next;
|
||||
UINT16 uuid_len;
|
||||
UINT16 attr_handle;
|
||||
UINT8 inst_id;
|
||||
tBTA_GATT_CHAR_PROP property; /* if characteristic, it is char property;
|
||||
if included service, flag primary,
|
||||
if descriptor, not used */
|
||||
tBTA_GATTC_ATTR_TYPE attr_type;
|
||||
// btla-specific ++
|
||||
} __attribute__((packed)) tBTA_GATTC_CACHE_ATTR;
|
||||
// btla-specific --
|
||||
|
||||
typedef struct gattc_svc_cache {
|
||||
tBTA_GATT_SRVC_ID service_uuid;
|
||||
tBTA_GATTC_CACHE_ATTR *p_attr;
|
||||
tBTA_GATTC_CACHE_ATTR *p_last_attr;
|
||||
UINT16 s_handle;
|
||||
UINT16 e_handle;
|
||||
struct gattc_svc_cache *p_next;
|
||||
tBTA_GATTC_CACHE_ATTR *p_cur_char;
|
||||
// btla-specific ++
|
||||
} __attribute__((packed)) tBTA_GATTC_CACHE;
|
||||
// btla-specific --
|
||||
|
||||
typedef struct {
|
||||
tBT_UUID uuid;
|
||||
UINT16 s_handle;
|
||||
UINT16 e_handle;
|
||||
BOOLEAN is_primary;
|
||||
UINT8 srvc_inst_id;
|
||||
tBTA_GATT_CHAR_PROP property;
|
||||
} tBTA_GATTC_ATTR_REC;
|
||||
|
||||
|
||||
#define BTA_GATTC_MAX_CACHE_CHAR 40
|
||||
#define BTA_GATTC_ATTR_LIST_SIZE (BTA_GATTC_MAX_CACHE_CHAR * sizeof(tBTA_GATTC_ATTR_REC))
|
||||
|
||||
#ifndef BTA_GATTC_CACHE_SRVR_SIZE
|
||||
#define BTA_GATTC_CACHE_SRVR_SIZE 600
|
||||
#endif
|
||||
|
||||
enum {
|
||||
BTA_GATTC_IDLE_ST = 0, /* Idle */
|
||||
BTA_GATTC_W4_CONN_ST, /* Wait for connection - (optional) */
|
||||
BTA_GATTC_CONN_ST, /* connected state */
|
||||
BTA_GATTC_DISCOVER_ST /* discover is in progress */
|
||||
};
|
||||
typedef UINT8 tBTA_GATTC_STATE;
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BD_ADDR server_bda;
|
||||
BOOLEAN connected;
|
||||
|
||||
#define BTA_GATTC_SERV_IDLE 0
|
||||
#define BTA_GATTC_SERV_LOAD 1
|
||||
#define BTA_GATTC_SERV_SAVE 2
|
||||
#define BTA_GATTC_SERV_DISC 3
|
||||
#define BTA_GATTC_SERV_DISC_ACT 4
|
||||
|
||||
UINT8 state;
|
||||
|
||||
tBTA_GATTC_CACHE *p_srvc_cache;
|
||||
tBTA_GATTC_CACHE *p_cur_srvc;
|
||||
BUFFER_Q cache_buffer; /* buffer queue used for storing the cache data */
|
||||
UINT8 *p_free; /* starting point to next available byte */
|
||||
UINT16 free_byte; /* number of available bytes in server cache buffer */
|
||||
UINT8 update_count; /* indication received */
|
||||
UINT8 num_clcb; /* number of associated CLCB */
|
||||
|
||||
|
||||
tBTA_GATTC_ATTR_REC *p_srvc_list;
|
||||
UINT8 cur_srvc_idx;
|
||||
UINT8 cur_char_idx;
|
||||
UINT8 next_avail_idx;
|
||||
UINT8 total_srvc;
|
||||
UINT8 total_char;
|
||||
|
||||
UINT8 srvc_hdl_chg; /* service handle change indication pending */
|
||||
UINT16 attr_index; /* cahce NV saving/loading attribute index */
|
||||
|
||||
UINT16 mtu;
|
||||
} tBTA_GATTC_SERV;
|
||||
|
||||
#ifndef BTA_GATTC_NOTIF_REG_MAX
|
||||
#define BTA_GATTC_NOTIF_REG_MAX 15
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTC_CHAR_ID char_id;
|
||||
} tBTA_GATTC_NOTIF_REG;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATTC_CBACK *p_cback;
|
||||
BOOLEAN in_use;
|
||||
tBTA_GATTC_IF client_if; /* client interface with BTE stack for this application */
|
||||
UINT8 num_clcb; /* number of associated CLCB */
|
||||
BOOLEAN dereg_pending;
|
||||
tBT_UUID app_uuid;
|
||||
tBTA_GATTC_NOTIF_REG notif_reg[BTA_GATTC_NOTIF_REG_MAX];
|
||||
} tBTA_GATTC_RCB;
|
||||
|
||||
/* client channel is a mapping between a BTA client(cl_id) and a remote BD address */
|
||||
typedef struct {
|
||||
UINT16 bta_conn_id; /* client channel ID, unique for clcb */
|
||||
BD_ADDR bda;
|
||||
tBTA_TRANSPORT transport; /* channel transport */
|
||||
tBTA_GATTC_RCB *p_rcb; /* pointer to the registration CB */
|
||||
tBTA_GATTC_SERV *p_srcb; /* server cache CB */
|
||||
tBTA_GATTC_DATA *p_q_cmd; /* command in queue waiting for execution */
|
||||
|
||||
#define BTA_GATTC_NO_SCHEDULE 0
|
||||
#define BTA_GATTC_DISC_WAITING 0x01
|
||||
#define BTA_GATTC_REQ_WAITING 0x10
|
||||
|
||||
UINT8 auto_update; /* auto update is waiting */
|
||||
BOOLEAN disc_active;
|
||||
BOOLEAN in_use;
|
||||
tBTA_GATTC_STATE state;
|
||||
tBTA_GATT_STATUS status;
|
||||
UINT16 reason;
|
||||
} tBTA_GATTC_CLCB;
|
||||
|
||||
/* back ground connection tracking information */
|
||||
#if GATT_MAX_APPS <= 8
|
||||
typedef UINT8 tBTA_GATTC_CIF_MASK ;
|
||||
#elif GATT_MAX_APPS <= 16
|
||||
typedef UINT16 tBTA_GATTC_CIF_MASK;
|
||||
#elif GATT_MAX_APPS <= 32
|
||||
typedef UINT32 tBTA_GATTC_CIF_MASK;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTC_CIF_MASK cif_mask;
|
||||
tBTA_GATTC_CIF_MASK cif_adv_mask;
|
||||
|
||||
} tBTA_GATTC_BG_TCK;
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BD_ADDR remote_bda;
|
||||
} tBTA_GATTC_CONN;
|
||||
|
||||
enum {
|
||||
BTA_GATTC_STATE_DISABLED,
|
||||
BTA_GATTC_STATE_ENABLING,
|
||||
BTA_GATTC_STATE_ENABLED,
|
||||
BTA_GATTC_STATE_DISABLING
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
UINT8 state;
|
||||
|
||||
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];
|
||||
|
||||
tBTA_GATTC_CLCB clcb[BTA_GATTC_CLCB_MAX];
|
||||
tBTA_GATTC_SERV known_server[BTA_GATTC_KNOWN_SR_MAX];
|
||||
|
||||
tSDP_DISCOVERY_DB *p_sdp_db;
|
||||
UINT16 sdp_conn_id;
|
||||
} tBTA_GATTC_CB;
|
||||
|
||||
/*****************************************************************************
|
||||
** Global data
|
||||
*****************************************************************************/
|
||||
|
||||
/* GATTC control block */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
extern tBTA_GATTC_CB bta_gattc_cb;
|
||||
#else
|
||||
extern tBTA_GATTC_CB *bta_gattc_cb_ptr;
|
||||
#define bta_gattc_cb (*bta_gattc_cb_ptr)
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
** Function prototypes
|
||||
*****************************************************************************/
|
||||
extern BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg);
|
||||
extern BOOLEAN bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_DATA *p_data);
|
||||
|
||||
/* function processed outside SM */
|
||||
extern void bta_gattc_disable(tBTA_GATTC_CB *p_cb);
|
||||
extern void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_start_if(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
extern void bta_gattc_process_api_open_cancel (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
extern void bta_gattc_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_RCB *p_clreg);
|
||||
extern void bta_gattc_process_enc_cmpl(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
|
||||
/* function within state machine */
|
||||
extern void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_open_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
|
||||
extern void bta_gattc_cancel_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_cancel_open_ok(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_cancel_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
|
||||
extern void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
|
||||
extern void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_close_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_disc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
|
||||
extern void bta_gattc_start_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_q_cmd(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_search(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_ci_load(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_ci_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_restart_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_msg);
|
||||
extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg);
|
||||
extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data);
|
||||
extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
|
||||
BD_ADDR remote_bda, UINT16 conn_id, tBTA_TRANSPORT transport, UINT16 mtu);
|
||||
extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
#if BLE_INCLUDED == TRUE
|
||||
extern void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
extern void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
#endif
|
||||
/* utility functions */
|
||||
extern tBTA_GATTC_CLCB *bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
|
||||
extern tBTA_GATTC_CLCB *bta_gattc_find_clcb_by_conn_id (UINT16 conn_id);
|
||||
extern tBTA_GATTC_CLCB *bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
|
||||
extern void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb);
|
||||
extern tBTA_GATTC_CLCB *bta_gattc_find_alloc_clcb(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
|
||||
extern tBTA_GATTC_RCB *bta_gattc_cl_get_regcb(UINT8 client_if);
|
||||
extern tBTA_GATTC_SERV *bta_gattc_find_srcb(BD_ADDR bda);
|
||||
extern tBTA_GATTC_SERV *bta_gattc_srcb_alloc(BD_ADDR bda);
|
||||
extern tBTA_GATTC_SERV *bta_gattc_find_scb_by_cid (UINT16 conn_id);
|
||||
extern tBTA_GATTC_CLCB *bta_gattc_find_int_conn_clcb(tBTA_GATTC_DATA *p_msg);
|
||||
extern tBTA_GATTC_CLCB *bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg);
|
||||
|
||||
extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
|
||||
extern UINT16 bta_gattc_id2handle(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_SRVC_ID *p_service_id, tBTA_GATT_ID *p_char_id, tBTA_GATT_ID *p_descr_uuid);
|
||||
extern BOOLEAN bta_gattc_handle2id(tBTA_GATTC_SERV *p_srcb, UINT16 handle, tBTA_GATT_SRVC_ID *service_id, tBTA_GATT_ID *char_id, tBTA_GATT_ID *p_type);
|
||||
extern BOOLEAN bta_gattc_uuid_compare (tBT_UUID *p_src, tBT_UUID *p_tar, BOOLEAN is_precise);
|
||||
extern void bta_gattc_pack_attr_uuid(tBTA_GATTC_CACHE_ATTR *p_attr, tBT_UUID *p_uuid);
|
||||
extern BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY *p_notify);
|
||||
extern tBTA_GATT_STATUS bta_gattc_pack_read_cb_data(tBTA_GATTC_SERV *p_srcb, tBT_UUID *p_descr_uuid, tGATT_VALUE *p_attr, tBTA_GATT_READ_VAL *p_value);
|
||||
extern BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR remote_bda, BOOLEAN add, BOOLEAN is_listen);
|
||||
extern BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR remote_bda, UINT8 role);
|
||||
extern UINT8 bta_gattc_num_reg_app(void);
|
||||
extern void bta_gattc_clear_notif_registration(UINT16 conn_id);
|
||||
extern tBTA_GATTC_SERV *bta_gattc_find_srvr_cache(BD_ADDR bda);
|
||||
extern BOOLEAN bta_gattc_charid_compare(tBTA_GATTC_CHAR_ID *p_src, tBTA_GATTC_CHAR_ID *p_tar);
|
||||
extern BOOLEAN bta_gattc_srvcid_compare(tBTA_GATT_SRVC_ID *p_src, tBTA_GATT_SRVC_ID *p_tar);
|
||||
extern void bta_gattc_cpygattid(tBTA_GATT_ID *p_des, tBTA_GATT_ID *p_src);
|
||||
|
||||
/* discovery functions */
|
||||
extern void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_DISC_RES *p_data);
|
||||
extern void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_STATUS status);
|
||||
extern tBTA_GATT_STATUS bta_gattc_discover_procedure(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
|
||||
extern tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
|
||||
extern void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid);
|
||||
extern tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id, UINT8 query_type, tBTA_GATT_SRVC_ID *p_srvc_id,
|
||||
tBTA_GATT_ID *p_start_rec, tBT_UUID *p_uuid_cond,
|
||||
tBTA_GATT_ID *p_output, void *p_param);
|
||||
extern tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb);
|
||||
extern void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srcv, UINT16 num_attr, tBTA_GATTC_NV_ATTR *p_attr, UINT16 attr_index);
|
||||
extern BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id);
|
||||
|
||||
|
||||
extern tBTA_GATTC_CONN *bta_gattc_conn_alloc(BD_ADDR remote_bda);
|
||||
extern tBTA_GATTC_CONN *bta_gattc_conn_find(BD_ADDR remote_bda);
|
||||
extern tBTA_GATTC_CONN *bta_gattc_conn_find_alloc(BD_ADDR remote_bda);
|
||||
extern BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda);
|
||||
|
||||
#endif /* BTA_GATTC_INT_H */
|
81
tools/sdk/include/bluedroid/bta_gatts_co.h
Normal file
81
tools/sdk/include/bluedroid/bta_gatts_co.h
Normal file
@ -0,0 +1,81 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2010-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 interface file for BTA GATT server call-out functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_GATTS_CO_H
|
||||
#define BTA_GATTS_CO_H
|
||||
|
||||
#include "bta_gatt_api.h"
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gatts_co_update_handle_range
|
||||
**
|
||||
** Description This callout function is executed by GATTS when a GATT server
|
||||
** handle range ios to be added or removed.
|
||||
**
|
||||
** Parameter is_add: true is to add a handle range; otherwise is to delete.
|
||||
** p_hndl_range: handle range.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_gatts_co_update_handle_range(BOOLEAN is_add, tBTA_GATTS_HNDL_RANGE *p_hndl_range);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gatts_co_srv_chg
|
||||
**
|
||||
** Description This call-out is to read/write/remove service change related
|
||||
** informaiton. The request consists of the cmd and p_req and the
|
||||
** response is returned in p_rsp
|
||||
**
|
||||
** Parameter cmd - request command
|
||||
** p_req - request paramters
|
||||
** p_rsp - response data for the request
|
||||
**
|
||||
** Returns TRUE - if the request is processed successfully and
|
||||
** the response is returned in p_rsp.
|
||||
** FASLE - if the request can not be processed
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN bta_gatts_co_srv_chg(tBTA_GATTS_SRV_CHG_CMD cmd,
|
||||
tBTA_GATTS_SRV_CHG_REQ *p_req,
|
||||
tBTA_GATTS_SRV_CHG_RSP *p_rsp);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gatts_co_load_handle_range
|
||||
**
|
||||
** Description This callout function is executed by GATTS when a GATT server
|
||||
** handle range is requested to be loaded from NV.
|
||||
**
|
||||
** Parameter
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN bta_gatts_co_load_handle_range(UINT8 index,
|
||||
tBTA_GATTS_HNDL_RANGE *p_handle);
|
||||
|
||||
|
||||
#endif /* BTA_GATTS_CO_H */
|
256
tools/sdk/include/bluedroid/bta_gatts_int.h
Normal file
256
tools/sdk/include/bluedroid/bta_gatts_int.h
Normal file
@ -0,0 +1,256 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 file for the BTA GATT server.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_GATTS_INT_H
|
||||
#define BTA_GATTS_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#include "gatt_api.h"
|
||||
|
||||
#include "gki.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
enum {
|
||||
BTA_GATTS_API_REG_EVT = BTA_SYS_EVT_START(BTA_ID_GATTS),
|
||||
BTA_GATTS_INT_START_IF_EVT,
|
||||
BTA_GATTS_API_DEREG_EVT,
|
||||
BTA_GATTS_API_CREATE_SRVC_EVT,
|
||||
BTA_GATTS_API_INDICATION_EVT,
|
||||
|
||||
BTA_GATTS_API_ADD_INCL_SRVC_EVT,
|
||||
BTA_GATTS_API_ADD_CHAR_EVT,
|
||||
BTA_GATTS_API_ADD_DESCR_EVT,
|
||||
BTA_GATTS_API_DEL_SRVC_EVT,
|
||||
BTA_GATTS_API_START_SRVC_EVT,
|
||||
BTA_GATTS_API_STOP_SRVC_EVT,
|
||||
BTA_GATTS_API_RSP_EVT,
|
||||
BTA_GATTS_API_SET_ATTR_VAL_EVT,
|
||||
BTA_GATTS_API_OPEN_EVT,
|
||||
BTA_GATTS_API_CANCEL_OPEN_EVT,
|
||||
BTA_GATTS_API_CLOSE_EVT,
|
||||
BTA_GATTS_API_LISTEN_EVT,
|
||||
BTA_GATTS_API_DISABLE_EVT
|
||||
};
|
||||
typedef UINT16 tBTA_GATTS_INT_EVT;
|
||||
|
||||
/* max number of application allowed on device */
|
||||
#define BTA_GATTS_MAX_APP_NUM GATT_MAX_SR_PROFILES
|
||||
|
||||
/* max number of services allowed in the device */
|
||||
#define BTA_GATTS_MAX_SRVC_NUM GATT_MAX_SR_PROFILES
|
||||
|
||||
/* internal strucutre for GATTC register API */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBT_UUID app_uuid;
|
||||
tBTA_GATTS_CBACK *p_cback;
|
||||
} tBTA_GATTS_API_REG;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATTS_IF server_if;
|
||||
} tBTA_GATTS_INT_START_IF;
|
||||
|
||||
typedef tBTA_GATTS_INT_START_IF tBTA_GATTS_API_DEREG;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATTS_IF server_if;
|
||||
tBT_UUID service_uuid;
|
||||
UINT16 num_handle;
|
||||
UINT8 inst;
|
||||
BOOLEAN is_pri;
|
||||
|
||||
} tBTA_GATTS_API_CREATE_SRVC;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBT_UUID char_uuid;
|
||||
tBTA_GATT_PERM perm;
|
||||
tBTA_GATT_CHAR_PROP property;
|
||||
tBTA_GATTS_ATTR_CONTROL control;
|
||||
tBTA_GATT_ATTR_VAL attr_val;
|
||||
} tBTA_GATTS_API_ADD_CHAR;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 included_service_id;
|
||||
} tBTA_GATTS_API_ADD_INCL_SRVC;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBT_UUID descr_uuid;
|
||||
tBTA_GATT_PERM perm;
|
||||
tBTA_GATTS_ATTR_CONTROL control;
|
||||
tBTA_GATT_ATTR_VAL attr_val;
|
||||
} tBTA_GATTS_API_ADD_DESCR;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 attr_id;
|
||||
UINT16 len;
|
||||
BOOLEAN need_confirm;
|
||||
UINT8 value[BTA_GATT_MAX_ATTR_LEN];
|
||||
} tBTA_GATTS_API_INDICATION;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT32 trans_id;
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTS_RSP *p_rsp;
|
||||
} tBTA_GATTS_API_RSP;
|
||||
|
||||
typedef struct{
|
||||
BT_HDR hdr;
|
||||
UINT16 length;
|
||||
UINT8 *value;
|
||||
}tBTA_GATTS_API_SET_ATTR_VAL;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_TRANSPORT transport;
|
||||
} tBTA_GATTS_API_START;
|
||||
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTS_IF server_if;
|
||||
BOOLEAN is_direct;
|
||||
tBTA_GATT_TRANSPORT transport;
|
||||
|
||||
} tBTA_GATTS_API_OPEN;
|
||||
|
||||
typedef tBTA_GATTS_API_OPEN tBTA_GATTS_API_CANCEL_OPEN;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR_PTR remote_bda;
|
||||
tBTA_GATTS_IF server_if;
|
||||
BOOLEAN start;
|
||||
} tBTA_GATTS_API_LISTEN;
|
||||
|
||||
typedef union {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATTS_API_REG api_reg;
|
||||
tBTA_GATTS_API_DEREG api_dereg;
|
||||
tBTA_GATTS_API_CREATE_SRVC api_create_svc;
|
||||
tBTA_GATTS_API_ADD_INCL_SRVC api_add_incl_srvc;
|
||||
tBTA_GATTS_API_ADD_CHAR api_add_char;
|
||||
tBTA_GATTS_API_ADD_DESCR api_add_char_descr;
|
||||
tBTA_GATTS_API_START api_start;
|
||||
tBTA_GATTS_API_INDICATION api_indicate;
|
||||
tBTA_GATTS_API_RSP api_rsp;
|
||||
tBTA_GATTS_API_SET_ATTR_VAL api_set_val;
|
||||
tBTA_GATTS_API_OPEN api_open;
|
||||
tBTA_GATTS_API_CANCEL_OPEN api_cancel_open;
|
||||
|
||||
tBTA_GATTS_INT_START_IF int_start_if;
|
||||
/* if peripheral role is supported */
|
||||
tBTA_GATTS_API_LISTEN api_listen;
|
||||
} tBTA_GATTS_DATA;
|
||||
|
||||
/* application registration control block */
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
tBT_UUID app_uuid;
|
||||
tBTA_GATTS_CBACK *p_cback;
|
||||
tBTA_GATTS_IF gatt_if;
|
||||
} tBTA_GATTS_RCB;
|
||||
|
||||
/* service registration control block */
|
||||
typedef struct {
|
||||
tBT_UUID service_uuid; /* service UUID */
|
||||
UINT16 service_id; /* service handle */
|
||||
UINT8 inst_num; /* instance ID */
|
||||
UINT8 rcb_idx;
|
||||
UINT8 idx; /* self index of serviec CB */
|
||||
BOOLEAN in_use;
|
||||
|
||||
} tBTA_GATTS_SRVC_CB;
|
||||
|
||||
|
||||
/* GATT server control block */
|
||||
typedef struct {
|
||||
BOOLEAN enabled;
|
||||
tBTA_GATTS_RCB rcb[BTA_GATTS_MAX_APP_NUM];
|
||||
tBTA_GATTS_SRVC_CB srvc_cb[BTA_GATTS_MAX_SRVC_NUM];
|
||||
} tBTA_GATTS_CB;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Global data
|
||||
*****************************************************************************/
|
||||
|
||||
/* GATTC control block */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
extern tBTA_GATTS_CB bta_gatts_cb;
|
||||
#else
|
||||
extern tBTA_GATTS_CB *bta_gatts_cb_ptr;
|
||||
#define bta_gatts_cb (*bta_gatts_cb_ptr)
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
** Function prototypes
|
||||
*****************************************************************************/
|
||||
extern BOOLEAN bta_gatts_hdl_event(BT_HDR *p_msg);
|
||||
|
||||
extern void bta_gatts_api_disable(tBTA_GATTS_CB *p_cb);
|
||||
extern void bta_gatts_api_enable(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_data);
|
||||
extern void bta_gatts_register(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_start_if(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_deregister(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_add_include_srvc(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_set_attr_value(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_get_attr_value(UINT16 attr_handle, UINT16 *length, UINT8 **value);
|
||||
extern void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_start_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
|
||||
extern void bta_gatts_send_rsp(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
|
||||
|
||||
extern void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_cancel_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_listen(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
|
||||
extern BOOLEAN bta_gatts_uuid_compare(tBT_UUID tar, tBT_UUID src);
|
||||
extern tBTA_GATTS_RCB *bta_gatts_find_app_rcb_by_app_if(tBTA_GATTS_IF server_if);
|
||||
extern UINT8 bta_gatts_find_app_rcb_idx_by_app_if(tBTA_GATTS_CB *p_cb, tBTA_GATTS_IF server_if);
|
||||
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);
|
||||
|
||||
|
||||
#endif /* BTA_GATTS_INT_H */
|
||||
|
541
tools/sdk/include/bluedroid/bta_hh_api.h
Normal file
541
tools/sdk/include/bluedroid/bta_hh_api.h
Normal file
@ -0,0 +1,541 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_HH_API_H
|
||||
#define BTA_HH_API_H
|
||||
|
||||
#include "bta_api.h"
|
||||
#include "hidh_api.h"
|
||||
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
#include "gatt_api.h"
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and Type Definitions
|
||||
*****************************************************************************/
|
||||
#ifndef BTA_HH_DEBUG
|
||||
#define BTA_HH_DEBUG TRUE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_HH_SSR_MAX_LATENCY_DEF
|
||||
#define BTA_HH_SSR_MAX_LATENCY_DEF 800 /* 500 ms*/
|
||||
#endif
|
||||
|
||||
#ifndef BTA_HH_SSR_MIN_TOUT_DEF
|
||||
#define BTA_HH_SSR_MIN_TOUT_DEF 2
|
||||
#endif
|
||||
|
||||
/* BTA HID Host callback events */
|
||||
#define BTA_HH_ENABLE_EVT 0 /* HH enabled */
|
||||
#define BTA_HH_DISABLE_EVT 1 /* HH disabled */
|
||||
#define BTA_HH_OPEN_EVT 2 /* connection opened */
|
||||
#define BTA_HH_CLOSE_EVT 3 /* connection closed */
|
||||
#define BTA_HH_GET_RPT_EVT 4 /* BTA_HhGetReport callback */
|
||||
#define BTA_HH_SET_RPT_EVT 5 /* BTA_HhSetReport callback */
|
||||
#define BTA_HH_GET_PROTO_EVT 6 /* BTA_GetProtoMode callback */
|
||||
#define BTA_HH_SET_PROTO_EVT 7 /* BTA_HhSetProtoMode callback */
|
||||
#define BTA_HH_GET_IDLE_EVT 8 /* BTA_HhGetIdle comes callback */
|
||||
#define BTA_HH_SET_IDLE_EVT 9 /* BTA_HhSetIdle finish callback */
|
||||
#define BTA_HH_GET_DSCP_EVT 10 /* Get report descriptor */
|
||||
#define BTA_HH_ADD_DEV_EVT 11 /* Add Device callback */
|
||||
#define BTA_HH_RMV_DEV_EVT 12 /* remove device finished */
|
||||
#define BTA_HH_VC_UNPLUG_EVT 13 /* virtually unplugged */
|
||||
#define BTA_HH_DATA_EVT 15
|
||||
#define BTA_HH_API_ERR_EVT 16 /* API error is caught */
|
||||
#define BTA_HH_UPDATE_SCPP_EVT 17 /* update scan paramter complete */
|
||||
|
||||
typedef UINT16 tBTA_HH_EVT;
|
||||
|
||||
/* application ID(none-zero) for each type of device */
|
||||
#define BTA_HH_APP_ID_MI 1
|
||||
#define BTA_HH_APP_ID_KB 2
|
||||
#define BTA_HH_APP_ID_RMC 3
|
||||
#define BTA_HH_APP_ID_3DSG 4
|
||||
#define BTA_HH_APP_ID_JOY 5
|
||||
#define BTA_HH_APP_ID_GPAD 6
|
||||
#define BTA_HH_APP_ID_LE 0xff
|
||||
|
||||
/* defined the minimum offset */
|
||||
#define BTA_HH_MIN_OFFSET L2CAP_MIN_OFFSET+1
|
||||
|
||||
/* HID_HOST_MAX_DEVICES can not exceed 15 for th design of BTA HH */
|
||||
#define BTA_HH_IDX_INVALID 0xff
|
||||
#define BTA_HH_MAX_KNOWN HID_HOST_MAX_DEVICES
|
||||
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
/* GATT_MAX_PHY_CHANNEL can not exceed 14 for the design of BTA HH */
|
||||
#define BTA_HH_LE_MAX_KNOWN GATT_MAX_PHY_CHANNEL
|
||||
#define BTA_HH_MAX_DEVICE (HID_HOST_MAX_DEVICES + GATT_MAX_PHY_CHANNEL)
|
||||
#else
|
||||
#define BTA_HH_MAX_DEVICE HID_HOST_MAX_DEVICES
|
||||
#endif
|
||||
/* invalid device handle */
|
||||
#define BTA_HH_INVALID_HANDLE 0xff
|
||||
|
||||
/* type of protocol mode */
|
||||
#define BTA_HH_PROTO_RPT_MODE (0x00)
|
||||
#define BTA_HH_PROTO_BOOT_MODE (0x01)
|
||||
#define BTA_HH_PROTO_UNKNOWN (0xff)
|
||||
typedef UINT8 tBTA_HH_PROTO_MODE;
|
||||
|
||||
enum {
|
||||
BTA_HH_KEYBD_RPT_ID = 1,
|
||||
BTA_HH_MOUSE_RPT_ID
|
||||
};
|
||||
typedef UINT8 tBTA_HH_BOOT_RPT_ID;
|
||||
|
||||
/* type of devices, bit mask */
|
||||
#define BTA_HH_DEVT_UNKNOWN 0x00
|
||||
#define BTA_HH_DEVT_JOS 0x01 /* joy stick */
|
||||
#define BTA_HH_DEVT_GPD 0x02 /* game pad */
|
||||
#define BTA_HH_DEVT_RMC 0x03 /* remote control */
|
||||
#define BTA_HH_DEVT_SED 0x04 /* sensing device */
|
||||
#define BTA_HH_DEVT_DGT 0x05 /* Digitizer tablet */
|
||||
#define BTA_HH_DEVT_CDR 0x06 /* card reader */
|
||||
#define BTA_HH_DEVT_KBD 0x10 /* keyboard */
|
||||
#define BTA_HH_DEVT_MIC 0x20 /* pointing device */
|
||||
#define BTA_HH_DEVT_COM 0x30 /* Combo keyboard/pointing */
|
||||
#define BTA_HH_DEVT_OTHER 0x80
|
||||
typedef UINT8 tBTA_HH_DEVT;
|
||||
|
||||
enum {
|
||||
BTA_HH_OK,
|
||||
BTA_HH_HS_HID_NOT_READY, /* handshake error : device not ready */
|
||||
BTA_HH_HS_INVALID_RPT_ID, /* handshake error : invalid report ID */
|
||||
BTA_HH_HS_TRANS_NOT_SPT, /* handshake error : transaction not spt */
|
||||
BTA_HH_HS_INVALID_PARAM, /* handshake error : invalid paremter */
|
||||
BTA_HH_HS_ERROR, /* handshake error : unspecified HS error */
|
||||
BTA_HH_ERR, /* general BTA HH error */
|
||||
BTA_HH_ERR_SDP, /* SDP error */
|
||||
BTA_HH_ERR_PROTO, /* SET_Protocol error,
|
||||
only used in BTA_HH_OPEN_EVT callback */
|
||||
|
||||
BTA_HH_ERR_DB_FULL, /* device database full error, used in
|
||||
BTA_HH_OPEN_EVT/BTA_HH_ADD_DEV_EVT */
|
||||
BTA_HH_ERR_TOD_UNSPT, /* type of device not supported */
|
||||
BTA_HH_ERR_NO_RES, /* out of system resources */
|
||||
BTA_HH_ERR_AUTH_FAILED, /* authentication fail */
|
||||
BTA_HH_ERR_HDL,
|
||||
BTA_HH_ERR_SEC
|
||||
};
|
||||
typedef UINT8 tBTA_HH_STATUS;
|
||||
|
||||
|
||||
#define BTA_HH_VIRTUAL_CABLE HID_VIRTUAL_CABLE
|
||||
#define BTA_HH_NORMALLY_CONNECTABLE HID_NORMALLY_CONNECTABLE
|
||||
#define BTA_HH_RECONN_INIT HID_RECONN_INIT
|
||||
#define BTA_HH_SDP_DISABLE HID_SDP_DISABLE
|
||||
#define BTA_HH_BATTERY_POWER HID_BATTERY_POWER
|
||||
#define BTA_HH_REMOTE_WAKE HID_REMOTE_WAKE
|
||||
#define BTA_HH_SUP_TOUT_AVLBL HID_SUP_TOUT_AVLBL
|
||||
#define BTA_HH_SEC_REQUIRED HID_SEC_REQUIRED
|
||||
typedef UINT16 tBTA_HH_ATTR_MASK;
|
||||
|
||||
/* supported type of device and corresponding application ID */
|
||||
typedef struct {
|
||||
tBTA_HH_DEVT tod; /* type of device */
|
||||
UINT8 app_id; /* corresponding application ID */
|
||||
} tBTA_HH_SPT_TOD;
|
||||
|
||||
/* configuration struct */
|
||||
typedef struct {
|
||||
UINT8 max_devt_spt; /* max number of types of devices spt */
|
||||
tBTA_HH_SPT_TOD *p_devt_list; /* supported types of device list */
|
||||
UINT16 sdp_db_size;
|
||||
} tBTA_HH_CFG;
|
||||
|
||||
enum {
|
||||
BTA_HH_RPTT_RESRV, /* reserved */
|
||||
BTA_HH_RPTT_INPUT, /* input report */
|
||||
BTA_HH_RPTT_OUTPUT, /* output report */
|
||||
BTA_HH_RPTT_FEATURE /* feature report */
|
||||
};
|
||||
typedef UINT8 tBTA_HH_RPT_TYPE;
|
||||
|
||||
/* HID_CONTROL operation code used in BTA_HhSendCtrl()
|
||||
*/
|
||||
enum {
|
||||
BTA_HH_CTRL_NOP = 0 + HID_PAR_CONTROL_NOP ,/* mapping from BTE */
|
||||
BTA_HH_CTRL_HARD_RESET, /* hard reset */
|
||||
BTA_HH_CTRL_SOFT_RESET, /* soft reset */
|
||||
BTA_HH_CTRL_SUSPEND, /* enter suspend */
|
||||
BTA_HH_CTRL_EXIT_SUSPEND, /* exit suspend */
|
||||
BTA_HH_CTRL_VIRTUAL_CABLE_UNPLUG /* virtual unplug */
|
||||
};
|
||||
typedef UINT8 tBTA_HH_TRANS_CTRL_TYPE;
|
||||
|
||||
typedef tHID_DEV_DSCP_INFO tBTA_HH_DEV_DESCR;
|
||||
|
||||
#define BTA_HH_SSR_PARAM_INVALID HID_SSR_PARAM_INVALID
|
||||
|
||||
/* id DI is not existing in remote device, vendor_id in tBTA_HH_DEV_DSCP_INFO will be set to 0xffff */
|
||||
#define BTA_HH_VENDOR_ID_INVALID 0xffff
|
||||
|
||||
|
||||
/* report descriptor information */
|
||||
typedef struct {
|
||||
UINT16 vendor_id; /* vendor ID */
|
||||
UINT16 product_id; /* product ID */
|
||||
UINT16 version; /* version */
|
||||
UINT16 ssr_max_latency; /* SSR max latency, BTA_HH_SSR_PARAM_INVALID if unknown */
|
||||
UINT16 ssr_min_tout; /* SSR min timeout, BTA_HH_SSR_PARAM_INVALID if unknown */
|
||||
UINT8 ctry_code; /*Country Code.*/
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
#define BTA_HH_LE_REMOTE_WAKE 0x01
|
||||
#define BTA_HH_LE_NORMAL_CONN 0x02
|
||||
|
||||
UINT8 flag;
|
||||
#endif
|
||||
tBTA_HH_DEV_DESCR descriptor;
|
||||
} tBTA_HH_DEV_DSCP_INFO;
|
||||
|
||||
/* callback event data for BTA_HH_OPEN_EVT */
|
||||
typedef struct {
|
||||
BD_ADDR bda; /* HID device bd address */
|
||||
tBTA_HH_STATUS status; /* operation status */
|
||||
UINT8 handle; /* device handle */
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
BOOLEAN le_hid; /* is LE devices? */
|
||||
BOOLEAN scps_supported; /* scan parameter service supported */
|
||||
#endif
|
||||
|
||||
} tBTA_HH_CONN;
|
||||
|
||||
typedef tBTA_HH_CONN tBTA_HH_DEV_INFO;
|
||||
|
||||
/* callback event data */
|
||||
typedef struct {
|
||||
tBTA_HH_STATUS status; /* operation status */
|
||||
UINT8 handle; /* device handle */
|
||||
} tBTA_HH_CBDATA;
|
||||
|
||||
enum {
|
||||
BTA_HH_MOD_CTRL_KEY,
|
||||
BTA_HH_MOD_SHFT_KEY,
|
||||
BTA_HH_MOD_ALT_KEY,
|
||||
BTA_HH_MOD_GUI_KEY,
|
||||
BTA_HH_MOD_MAX_KEY
|
||||
};
|
||||
|
||||
/* parsed boot mode keyboard report */
|
||||
typedef struct {
|
||||
UINT8 this_char[6]; /* virtual key code */
|
||||
BOOLEAN mod_key[BTA_HH_MOD_MAX_KEY];
|
||||
/* ctrl, shift, Alt, GUI */
|
||||
/* modifier key: is Shift key pressed */
|
||||
/* modifier key: is Ctrl key pressed */
|
||||
/* modifier key: is Alt key pressed */
|
||||
/* modifier key: GUI up/down */
|
||||
BOOLEAN caps_lock; /* is caps locked */
|
||||
BOOLEAN num_lock; /* is Num key pressed */
|
||||
} tBTA_HH_KEYBD_RPT;
|
||||
|
||||
/* parsed boot mode mouse report */
|
||||
typedef struct {
|
||||
UINT8 mouse_button; /* mouse button is clicked */
|
||||
INT8 delta_x; /* displacement x */
|
||||
INT8 delta_y; /* displacement y */
|
||||
} tBTA_HH_MICE_RPT;
|
||||
|
||||
/* parsed Boot report */
|
||||
typedef struct {
|
||||
tBTA_HH_BOOT_RPT_ID dev_type; /* type of device report */
|
||||
union {
|
||||
tBTA_HH_KEYBD_RPT keybd_rpt; /* keyboard report */
|
||||
tBTA_HH_MICE_RPT mice_rpt; /* mouse report */
|
||||
} data_rpt;
|
||||
} tBTA_HH_BOOT_RPT;
|
||||
|
||||
/* handshake data */
|
||||
typedef struct {
|
||||
tBTA_HH_STATUS status; /* handshake status */
|
||||
UINT8 handle; /* device handle */
|
||||
union {
|
||||
tBTA_HH_PROTO_MODE proto_mode; /* GET_PROTO_EVT :protocol mode */
|
||||
BT_HDR *p_rpt_data; /* GET_RPT_EVT : report data */
|
||||
UINT8 idle_rate; /* GET_IDLE_EVT : idle rate */
|
||||
} rsp_data;
|
||||
|
||||
} tBTA_HH_HSDATA;
|
||||
|
||||
/* union of data associated with HD callback */
|
||||
typedef union {
|
||||
tBTA_HH_DEV_INFO dev_info; /* BTA_HH_ADD_DEV_EVT, BTA_HH_RMV_DEV_EVT */
|
||||
tBTA_HH_CONN conn; /* BTA_HH_OPEN_EVT */
|
||||
tBTA_HH_CBDATA dev_status; /* BTA_HH_CLOSE_EVT,
|
||||
BTA_HH_SET_PROTO_EVT
|
||||
BTA_HH_SET_RPT_EVT
|
||||
BTA_HH_SET_IDLE_EVT
|
||||
BTA_HH_UPDATE_SCPP_EVT */
|
||||
|
||||
tBTA_HH_STATUS status; /* BTA_HH_ENABLE_EVT */
|
||||
tBTA_HH_DEV_DSCP_INFO dscp_info; /* BTA_HH_GET_DSCP_EVT */
|
||||
tBTA_HH_HSDATA hs_data; /* GET_ transaction callback
|
||||
BTA_HH_GET_RPT_EVT
|
||||
BTA_HH_GET_PROTO_EVT
|
||||
BTA_HH_GET_IDLE_EVT */
|
||||
} tBTA_HH;
|
||||
|
||||
/* BTA HH callback function */
|
||||
typedef void (tBTA_HH_CBACK) (tBTA_HH_EVT event, tBTA_HH *p_data);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhRegister
|
||||
**
|
||||
** Description This function enable HID host and registers HID-Host with
|
||||
** lower layers.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhEnable(tBTA_SEC sec_mask, tBTA_HH_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhDeregister
|
||||
**
|
||||
** Description This function is called when the host is about power down.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhDisable(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhOpen
|
||||
**
|
||||
** Description This function is called to start an inquiry and read SDP
|
||||
** record of responding devices; connect to a device if only
|
||||
** one active HID device is found.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhOpen (BD_ADDR dev_bda, tBTA_HH_PROTO_MODE mode,
|
||||
tBTA_SEC sec_mask);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhClose
|
||||
**
|
||||
** Description This function disconnects the device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhClose(UINT8 dev_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhSetProtoMode
|
||||
**
|
||||
** Description This function set the protocol mode at specified HID handle
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhSetProtoMode(UINT8 handle, tBTA_HH_PROTO_MODE t_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhGetProtoMode
|
||||
**
|
||||
** Description This function get the protocol mode of a specified HID device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhGetProtoMode(UINT8 dev_handle);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhSetReport
|
||||
**
|
||||
** Description send SET_REPORT to device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhSetReport(UINT8 dev_handle, tBTA_HH_RPT_TYPE r_type,
|
||||
BT_HDR *p_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhGetReport
|
||||
**
|
||||
** Description Send a GET_REPORT to HID device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhGetReport(UINT8 dev_handle, tBTA_HH_RPT_TYPE r_type,
|
||||
UINT8 rpt_id, UINT16 buf_size);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhSetIdle
|
||||
**
|
||||
** Description send SET_IDLE to device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhSetIdle(UINT8 dev_handle, UINT16 idle_rate);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhGetIdle
|
||||
**
|
||||
** Description Send a GET_IDLE to HID device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhGetIdle(UINT8 dev_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhSendCtrl
|
||||
**
|
||||
** Description Send HID_CONTROL request to a HID device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhSendCtrl(UINT8 dev_handle,
|
||||
tBTA_HH_TRANS_CTRL_TYPE c_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhSetIdle
|
||||
**
|
||||
** Description send SET_IDLE to device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhSetIdle(UINT8 dev_handle, UINT16 idle_rate);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhGetIdle
|
||||
**
|
||||
** Description Send a GET_IDLE from HID device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhGetIdle(UINT8 dev_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhSendData
|
||||
**
|
||||
** Description Send DATA transaction to a HID device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhSendData(UINT8 dev_handle, BD_ADDR dev_bda, BT_HDR *p_buf);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhGetDscpInfo
|
||||
**
|
||||
** Description Get report descriptor of the device
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhGetDscpInfo(UINT8 dev_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
** Function BTA_HhAddDev
|
||||
**
|
||||
** Description Add a virtually cabled device into HID-Host device list
|
||||
** to manage and assign a device handle for future API call,
|
||||
** host applciation call this API at start-up to initialize its
|
||||
** virtually cabled devices.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhAddDev(BD_ADDR bda, tBTA_HH_ATTR_MASK attr_mask,
|
||||
UINT8 sub_class, UINT8 app_id,
|
||||
tBTA_HH_DEV_DSCP_INFO dscp_info);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhRemoveDev
|
||||
**
|
||||
** Description Remove a device from the HID host devices list.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhRemoveDev(UINT8 dev_handle );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Parsing Utility Functions
|
||||
**
|
||||
*******************************************************************************/
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhParseBootRpt
|
||||
**
|
||||
** Description This utility function parse a boot mode report.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhParseBootRpt(tBTA_HH_BOOT_RPT *p_data, UINT8 *p_report,
|
||||
UINT16 report_len);
|
||||
|
||||
#if BTA_HH_LE_INCLUDED == TRUE
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HhUpdateLeScanParam
|
||||
**
|
||||
** Description Update the scan paramteters if connected to a LE hid device as
|
||||
** report host.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_HhUpdateLeScanParam(UINT8 dev_handle, UINT16 scan_int, UINT16 scan_win);
|
||||
#endif
|
||||
/* test commands */
|
||||
extern void bta_hh_le_hid_read_rpt_clt_cfg(BD_ADDR bd_addr, UINT8 rpt_id);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BTA_HH_API_H */
|
132
tools/sdk/include/bluedroid/bta_hh_co.h
Normal file
132
tools/sdk/include/bluedroid/bta_hh_co.h
Normal file
@ -0,0 +1,132 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 is the interface file for hid host call-out functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_HH_CO_H
|
||||
#define BTA_HH_CO_H
|
||||
|
||||
#include "bta_hh_api.h"
|
||||
|
||||
typedef struct {
|
||||
UINT16 rpt_uuid;
|
||||
UINT8 rpt_id;
|
||||
tBTA_HH_RPT_TYPE rpt_type;
|
||||
UINT8 inst_id;
|
||||
UINT8 prop;
|
||||
} tBTA_HH_RPT_CACHE_ENTRY;
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hh_co_data
|
||||
**
|
||||
** Description This callout function is executed by HH when data is received
|
||||
** in interupt channel.
|
||||
**
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_hh_co_data(UINT8 dev_handle, UINT8 *p_rpt, UINT16 len,
|
||||
tBTA_HH_PROTO_MODE mode, UINT8 sub_class,
|
||||
UINT8 ctry_code, BD_ADDR peer_addr, UINT8 app_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hh_co_open
|
||||
**
|
||||
** Description This callout function is executed by HH when connection is
|
||||
** opened, and application may do some device specific
|
||||
** initialization.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_hh_co_open(UINT8 dev_handle, UINT8 sub_class,
|
||||
UINT16 attr_mask, UINT8 app_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hh_co_close
|
||||
**
|
||||
** Description This callout function is executed by HH when connection is
|
||||
** closed, and device specific finalizatio nmay be needed.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_hh_co_close(UINT8 dev_handle, UINT8 app_id);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && BTA_HH_LE_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hh_le_co_rpt_info
|
||||
**
|
||||
** Description This callout function is to convey the report information on
|
||||
** a HOGP device to the application. Application can save this
|
||||
** information in NV if device is bonded and load it back when
|
||||
** stack reboot.
|
||||
**
|
||||
** Parameters remote_bda - remote device address
|
||||
** p_entry - report entry pointer
|
||||
** app_id - application id
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_hh_le_co_rpt_info(BD_ADDR remote_bda,
|
||||
tBTA_HH_RPT_CACHE_ENTRY *p_entry,
|
||||
UINT8 app_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hh_le_co_cache_load
|
||||
**
|
||||
** Description This callout function is to request the application to load the
|
||||
** cached HOGP report if there is any. When cache reading is completed,
|
||||
** bta_hh_le_ci_cache_load() is called by the application.
|
||||
**
|
||||
** Parameters remote_bda - remote device address
|
||||
** p_num_rpt: number of cached report
|
||||
** app_id - application id
|
||||
**
|
||||
** Returns the acched report array
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_HH_RPT_CACHE_ENTRY *bta_hh_le_co_cache_load (BD_ADDR remote_bda,
|
||||
UINT8 *p_num_rpt,
|
||||
UINT8 app_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hh_le_co_reset_rpt_cache
|
||||
**
|
||||
** Description This callout function is to reset the HOGP device cache.
|
||||
**
|
||||
** Parameters remote_bda - remote device address
|
||||
**
|
||||
** Returns none
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_hh_le_co_reset_rpt_cache (BD_ADDR remote_bda, UINT8 app_id);
|
||||
|
||||
#endif /* #if (BLE_INCLUDED == TRUE && BTA_HH_LE_INCLUDED == TRUE) */
|
||||
#endif /* BTA_HH_CO_H */
|
142
tools/sdk/include/bluedroid/bta_sdp_api.h
Normal file
142
tools/sdk/include/bluedroid/bta_sdp_api.h
Normal file
@ -0,0 +1,142 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* 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 public interface file for the BTA SDP I/F
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_SDP_API_H
|
||||
#define BTA_SDP_API_H
|
||||
|
||||
#include "bt_sdp.h"
|
||||
#include "bt_target.h"
|
||||
#include "bt_types.h"
|
||||
#include "bta_api.h"
|
||||
#include "btm_api.h"
|
||||
|
||||
/* status values */
|
||||
#define BTA_SDP_SUCCESS 0 /* Successful operation. */
|
||||
#define BTA_SDP_FAILURE 1 /* Generic failure. */
|
||||
#define BTA_SDP_BUSY 2 /* Temporarily can not handle this request. */
|
||||
|
||||
typedef UINT8 tBTA_SDP_STATUS;
|
||||
|
||||
/* SDP I/F callback events */
|
||||
/* events received by tBTA_SDP_DM_CBACK */
|
||||
#define BTA_SDP_ENABLE_EVT 0 /* SDP service i/f enabled*/
|
||||
#define BTA_SDP_SEARCH_EVT 1 /* SDP Service started */
|
||||
#define BTA_SDP_SEARCH_COMP_EVT 2 /* SDP search complete */
|
||||
#define BTA_SDP_CREATE_RECORD_USER_EVT 3 /* SDP search complete */
|
||||
#define BTA_SDP_REMOVE_RECORD_USER_EVT 4 /* SDP search complete */
|
||||
#define BTA_SDP_MAX_EVT 5 /* max number of SDP events */
|
||||
|
||||
#define BTA_SDP_MAX_RECORDS 15
|
||||
|
||||
typedef UINT16 tBTA_SDP_EVT;
|
||||
|
||||
/* data associated with BTA_SDP_DISCOVERY_COMP_EVT */
|
||||
typedef struct {
|
||||
tBTA_SDP_STATUS status;
|
||||
BD_ADDR remote_addr;
|
||||
tBT_UUID uuid;
|
||||
int record_count;
|
||||
bluetooth_sdp_record records[BTA_SDP_MAX_RECORDS];
|
||||
} tBTA_SDP_SEARCH_COMP;
|
||||
|
||||
typedef union {
|
||||
tBTA_SDP_STATUS status; /* BTA_SDP_SEARCH_EVT */
|
||||
tBTA_SDP_SEARCH_COMP sdp_search_comp; /* BTA_SDP_SEARCH_COMP_EVT */
|
||||
} tBTA_SDP;
|
||||
|
||||
/* SDP DM Interface callback */
|
||||
typedef void (tBTA_SDP_DM_CBACK)(tBTA_SDP_EVT event, tBTA_SDP *p_data, void *user_data);
|
||||
|
||||
/* MCE configuration structure */
|
||||
typedef struct {
|
||||
UINT16 sdp_db_size; /* The size of p_sdp_db */
|
||||
tSDP_DISCOVERY_DB *p_sdp_db; /* The data buffer to keep SDP database */
|
||||
} tBTA_SDP_CFG;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_SdpEnable
|
||||
**
|
||||
** Description Enable the SDP I/F service. When the enable
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_SDP_ENABLE_EVT. This function must
|
||||
** be called before other functions in the MCE API are
|
||||
** called.
|
||||
**
|
||||
** Returns BTA_SDP_SUCCESS if successful.
|
||||
** BTA_SDP_FAIL if internal failure.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_SdpSearch
|
||||
**
|
||||
** Description Start a search for sdp records for a specific BD_ADDR with a
|
||||
** specific profile uuid.
|
||||
** When the search operation is completed, the callback function
|
||||
** will be called with a BTA_SDP_SEARCH_EVT.
|
||||
** Returns BTA_SDP_SUCCESS if successful.
|
||||
** BTA_SDP_FAIL if internal failure.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_SDP_STATUS BTA_SdpSearch(BD_ADDR bd_addr, tSDP_UUID *uuid);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_SdpCreateRecordByUser
|
||||
**
|
||||
** Description This function is used to request a callback to create a SDP
|
||||
** record. The registered callback will be called with event
|
||||
** BTA_SDP_CREATE_RECORD_USER_EVT.
|
||||
**
|
||||
** Returns BTA_SDP_SUCCESS, if the request is being processed.
|
||||
** BTA_SDP_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_SdpRemoveRecordByUser
|
||||
**
|
||||
** Description This function is used to request a callback to remove a SDP
|
||||
** record. The registered callback will be called with event
|
||||
** BTA_SDP_REMOVE_RECORD_USER_EVT.
|
||||
**
|
||||
** Returns BTA_SDP_SUCCESS, if the request is being processed.
|
||||
** BTA_SDP_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void *user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BTA_SDP_API_H */
|
282
tools/sdk/include/bluedroid/bta_sys.h
Normal file
282
tools/sdk/include/bluedroid/bta_sys.h
Normal file
@ -0,0 +1,282 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 public interface file for the BTA system manager.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_SYS_H
|
||||
#define BTA_SYS_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
|
||||
/* vendor specific event handler function type */
|
||||
typedef BOOLEAN (tBTA_SYS_VS_EVT_HDLR)(UINT16 evt, void *p);
|
||||
|
||||
/* event handler function type */
|
||||
typedef BOOLEAN (tBTA_SYS_EVT_HDLR)(BT_HDR *p_msg);
|
||||
|
||||
/* disable function type */
|
||||
typedef void (tBTA_SYS_DISABLE)(void);
|
||||
|
||||
|
||||
/* HW modules */
|
||||
enum {
|
||||
BTA_SYS_HW_BLUETOOTH,
|
||||
BTA_SYS_HW_RT,
|
||||
|
||||
BTA_SYS_MAX_HW_MODULES
|
||||
};
|
||||
|
||||
typedef UINT16 tBTA_SYS_HW_MODULE;
|
||||
|
||||
#ifndef BTA_DM_NUM_JV_ID
|
||||
#define BTA_DM_NUM_JV_ID 2
|
||||
#endif
|
||||
|
||||
/* SW sub-systems */
|
||||
#define BTA_ID_SYS 0 /* system manager */
|
||||
/* BLUETOOTH PART - from 0 to BTA_ID_BLUETOOTH_MAX */
|
||||
#define BTA_ID_DM 1 /* device manager */
|
||||
#define BTA_ID_DM_SEARCH 2 /* device manager search */
|
||||
#define BTA_ID_DM_SEC 3 /* device manager security */
|
||||
#define BTA_ID_DG 4 /* data gateway */
|
||||
#define BTA_ID_AG 5 /* audio gateway */
|
||||
#define BTA_ID_OPC 6 /* object push client */
|
||||
#define BTA_ID_OPS 7 /* object push server */
|
||||
#define BTA_ID_FTS 8 /* file transfer server */
|
||||
#define BTA_ID_CT 9 /* cordless telephony terminal */
|
||||
#define BTA_ID_FTC 10 /* file transfer client */
|
||||
#define BTA_ID_SS 11 /* synchronization server */
|
||||
#define BTA_ID_PR 12 /* Printer client */
|
||||
#define BTA_ID_BIC 13 /* Basic Imaging Client */
|
||||
#define BTA_ID_PAN 14 /* Personal Area Networking */
|
||||
#define BTA_ID_BIS 15 /* Basic Imaging Server */
|
||||
#define BTA_ID_ACC 16 /* Advanced Camera Client */
|
||||
#define BTA_ID_SC 17 /* SIM Card Access server */
|
||||
#define BTA_ID_AV 18 /* Advanced audio/video */
|
||||
#define BTA_ID_AVK 19 /* Audio/video sink */
|
||||
#define BTA_ID_HD 20 /* HID Device */
|
||||
#define BTA_ID_CG 21 /* Cordless Gateway */
|
||||
#define BTA_ID_BP 22 /* Basic Printing Client */
|
||||
#define BTA_ID_HH 23 /* Human Interface Device Host */
|
||||
#define BTA_ID_PBS 24 /* Phone Book Access Server */
|
||||
#define BTA_ID_PBC 25 /* Phone Book Access Client */
|
||||
#define BTA_ID_JV 26 /* Java */
|
||||
#define BTA_ID_HS 27 /* Headset */
|
||||
#define BTA_ID_MSE 28 /* Message Server Equipment */
|
||||
#define BTA_ID_MCE 29 /* Message Client Equipment */
|
||||
#define BTA_ID_HL 30 /* Health Device Profile*/
|
||||
#define BTA_ID_GATTC 31 /* GATT Client */
|
||||
#define BTA_ID_GATTS 32 /* GATT Client */
|
||||
#define BTA_ID_SDP 33 /* SDP Client */
|
||||
#define BTA_ID_BLUETOOTH_MAX 34 /* last BT profile */
|
||||
|
||||
/* GENERIC */
|
||||
#define BTA_ID_PRM 38
|
||||
#define BTA_ID_SYSTEM 39 /* platform-specific */
|
||||
#define BTA_ID_SWRAP 40 /* Insight script wrapper */
|
||||
#define BTA_ID_MIP 41 /* Multicase Individual Polling */
|
||||
#define BTA_ID_RT 42 /* Audio Routing module: This module is always on. */
|
||||
|
||||
|
||||
/* JV */
|
||||
#define BTA_ID_JV1 44 /* JV1 */
|
||||
#define BTA_ID_JV2 45 /* JV2 */
|
||||
|
||||
#define BTA_ID_MAX (44 + BTA_DM_NUM_JV_ID)
|
||||
|
||||
typedef UINT8 tBTA_SYS_ID;
|
||||
|
||||
|
||||
#define BTA_SYS_CONN_OPEN 0x00
|
||||
#define BTA_SYS_CONN_CLOSE 0x01
|
||||
#define BTA_SYS_APP_OPEN 0x02
|
||||
#define BTA_SYS_APP_CLOSE 0x03
|
||||
#define BTA_SYS_SCO_OPEN 0x04
|
||||
#define BTA_SYS_SCO_CLOSE 0x05
|
||||
#define BTA_SYS_CONN_IDLE 0x06
|
||||
#define BTA_SYS_CONN_BUSY 0x07
|
||||
|
||||
/* for link policy */
|
||||
#define BTA_SYS_PLCY_SET 0x10 /* set the link policy to the given addr */
|
||||
#define BTA_SYS_PLCY_CLR 0x11 /* clear the link policy to the given addr */
|
||||
#define BTA_SYS_PLCY_DEF_SET 0x12 /* set the default link policy */
|
||||
#define BTA_SYS_PLCY_DEF_CLR 0x13 /* clear the default link policy */
|
||||
#define BTA_SYS_ROLE_CHANGE 0x14 /* role change */
|
||||
|
||||
typedef UINT8 tBTA_SYS_CONN_STATUS;
|
||||
|
||||
/* Bitmask of sys features */
|
||||
#define BTA_SYS_FEAT_PCM2 0x0001
|
||||
#define BTA_SYS_FEAT_PCM2_MASTER 0x0002
|
||||
|
||||
/* tBTA_PREF_ROLES */
|
||||
typedef UINT8 tBTA_SYS_PREF_ROLES;
|
||||
|
||||
/* conn callback for role / low power manager*/
|
||||
typedef void (tBTA_SYS_CONN_CBACK)(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
|
||||
/* conn callback for role / low power manager*/
|
||||
typedef void (tBTA_SYS_SSR_CFG_CBACK)(UINT8 id, UINT8 app_id, UINT16 latency, UINT16 tout);
|
||||
|
||||
#if (BTA_EIR_CANNED_UUID_LIST != TRUE)
|
||||
/* eir callback for adding/removeing UUID */
|
||||
typedef void (tBTA_SYS_EIR_CBACK)(UINT16 uuid16, BOOLEAN adding);
|
||||
#endif
|
||||
|
||||
/* registration structure */
|
||||
typedef struct {
|
||||
tBTA_SYS_EVT_HDLR *evt_hdlr;
|
||||
tBTA_SYS_DISABLE *disable;
|
||||
} tBTA_SYS_REG;
|
||||
|
||||
/* data type to send events to BTA SYS HW manager */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_SYS_HW_MODULE hw_module;
|
||||
} tBTA_SYS_HW_MSG;
|
||||
|
||||
/*****************************************************************************
|
||||
** Global data
|
||||
*****************************************************************************/
|
||||
|
||||
/* trace level */
|
||||
extern UINT8 appl_trace_level;
|
||||
|
||||
/*****************************************************************************
|
||||
** Macros
|
||||
*****************************************************************************/
|
||||
|
||||
/* Calculate start of event enumeration; id is top 8 bits of event */
|
||||
#define BTA_SYS_EVT_START(id) ((id) << 8)
|
||||
|
||||
/*****************************************************************************
|
||||
** events for BTA SYS HW manager
|
||||
*****************************************************************************/
|
||||
|
||||
/* events sent to SYS HW manager - must be kept synchronized with tables in bta_sys_main.c */
|
||||
enum {
|
||||
/* device manager local device API events */
|
||||
BTA_SYS_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_SYS),
|
||||
BTA_SYS_EVT_ENABLED_EVT,
|
||||
BTA_SYS_EVT_STACK_ENABLED_EVT,
|
||||
BTA_SYS_API_DISABLE_EVT,
|
||||
BTA_SYS_EVT_DISABLED_EVT,
|
||||
BTA_SYS_ERROR_EVT,
|
||||
|
||||
BTA_SYS_MAX_EVT
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* SYS HW status events - returned by SYS HW manager to other modules. */
|
||||
enum {
|
||||
BTA_SYS_HW_OFF_EVT,
|
||||
BTA_SYS_HW_ON_EVT,
|
||||
BTA_SYS_HW_STARTING_EVT,
|
||||
BTA_SYS_HW_STOPPING_EVT,
|
||||
BTA_SYS_HW_ERROR_EVT
|
||||
|
||||
};
|
||||
typedef UINT8 tBTA_SYS_HW_EVT;
|
||||
|
||||
/* HW enable callback type */
|
||||
typedef void (tBTA_SYS_HW_CBACK)(tBTA_SYS_HW_EVT status);
|
||||
|
||||
/*****************************************************************************
|
||||
** Function declarations
|
||||
*****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void bta_sys_init(void);
|
||||
extern void bta_sys_free(void);
|
||||
extern void bta_sys_event(BT_HDR *p_msg);
|
||||
extern void bta_sys_set_trace_level(UINT8 level);
|
||||
extern void bta_sys_register(UINT8 id, const tBTA_SYS_REG *p_reg);
|
||||
extern void bta_sys_deregister(UINT8 id);
|
||||
extern BOOLEAN bta_sys_is_register(UINT8 id);
|
||||
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_disable(tBTA_SYS_HW_MODULE module);
|
||||
extern UINT32 bta_sys_get_remaining_ticks(TIMER_LIST_ENT *p_target_tle);
|
||||
|
||||
extern void bta_sys_hw_register( tBTA_SYS_HW_MODULE module, tBTA_SYS_HW_CBACK *cback);
|
||||
extern void bta_sys_hw_unregister( tBTA_SYS_HW_MODULE module );
|
||||
|
||||
|
||||
extern void bta_sys_rm_register(tBTA_SYS_CONN_CBACK *p_cback);
|
||||
extern void bta_sys_pm_register(tBTA_SYS_CONN_CBACK *p_cback);
|
||||
|
||||
extern void bta_sys_policy_register(tBTA_SYS_CONN_CBACK *p_cback);
|
||||
extern void bta_sys_sco_register(tBTA_SYS_CONN_CBACK *p_cback);
|
||||
|
||||
|
||||
extern void bta_sys_conn_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bta_sys_conn_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bta_sys_app_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bta_sys_app_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bta_sys_sco_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bta_sys_sco_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bta_sys_sco_use(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bta_sys_sco_unuse(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bta_sys_idle(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bta_sys_busy(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
extern void bta_sys_ssr_cfg_register(tBTA_SYS_SSR_CFG_CBACK *p_cback);
|
||||
extern void bta_sys_chg_ssr_config (UINT8 id, UINT8 app_id, UINT16 max_latency, UINT16 min_tout);
|
||||
#endif
|
||||
|
||||
extern void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK *p_cback);
|
||||
extern void bta_sys_notify_role_chg(BD_ADDR_PTR p_bda, UINT8 new_role, UINT8 hci_status);
|
||||
extern void bta_sys_collision_register(UINT8 bta_id, tBTA_SYS_CONN_CBACK *p_cback);
|
||||
extern void bta_sys_notify_collision (BD_ADDR_PTR p_bda);
|
||||
|
||||
#if (BTA_EIR_CANNED_UUID_LIST != TRUE)
|
||||
extern void bta_sys_eir_register(tBTA_SYS_EIR_CBACK *p_cback);
|
||||
extern void bta_sys_add_uuid(UINT16 uuid16);
|
||||
extern void bta_sys_remove_uuid(UINT16 uuid16);
|
||||
#else
|
||||
#define bta_sys_eir_register(ut)
|
||||
#define bta_sys_add_uuid(ut)
|
||||
#define bta_sys_remove_uuid(ut)
|
||||
#endif
|
||||
|
||||
extern void bta_sys_set_policy (UINT8 id, UINT8 policy, BD_ADDR peer_addr);
|
||||
extern void bta_sys_clear_policy (UINT8 id, UINT8 policy, BD_ADDR peer_addr);
|
||||
extern void bta_sys_set_default_policy (UINT8 id, UINT8 policy);
|
||||
extern void bta_sys_clear_default_policy (UINT8 id, UINT8 policy);
|
||||
extern BOOLEAN bta_sys_vs_hdl(UINT16 evt, void *p);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BTA_SYS_H */
|
101
tools/sdk/include/bluedroid/bta_sys_int.h
Normal file
101
tools/sdk/include/bluedroid/bta_sys_int.h
Normal file
@ -0,0 +1,101 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 system manager.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_SYS_INT_H
|
||||
#define BTA_SYS_INT_H
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
** state table
|
||||
*****************************************************************************/
|
||||
|
||||
/* SYS HW state */
|
||||
enum {
|
||||
BTA_SYS_HW_OFF,
|
||||
BTA_SYS_HW_STARTING,
|
||||
BTA_SYS_HW_ON,
|
||||
BTA_SYS_HW_STOPPING
|
||||
};
|
||||
typedef UINT8 tBTA_SYS_HW_STATE;
|
||||
|
||||
/* Collision callback */
|
||||
#define MAX_COLLISION_REG 5
|
||||
|
||||
typedef struct {
|
||||
UINT8 id[MAX_COLLISION_REG];
|
||||
tBTA_SYS_CONN_CBACK *p_coll_cback[MAX_COLLISION_REG];
|
||||
} tBTA_SYS_COLLISION;
|
||||
|
||||
/* system manager control block */
|
||||
typedef struct {
|
||||
tBTA_SYS_REG *reg[BTA_ID_MAX]; /* registration structures */
|
||||
BOOLEAN is_reg[BTA_ID_MAX]; /* registration structures */
|
||||
tBTA_SYS_HW_STATE state;
|
||||
tBTA_SYS_HW_CBACK *sys_hw_cback[BTA_SYS_MAX_HW_MODULES]; /* enable callback for each HW modules */
|
||||
UINT32 sys_hw_module_active; /* bitmask of all active modules */
|
||||
UINT16 sys_features; /* Bitmask of sys features */
|
||||
|
||||
tBTA_SYS_CONN_CBACK *prm_cb; /* role management callback registered by DM */
|
||||
tBTA_SYS_CONN_CBACK *ppm_cb; /* low power management callback registered by DM */
|
||||
tBTA_SYS_CONN_CBACK *p_policy_cb; /* link policy change callback registered by DM */
|
||||
tBTA_SYS_CONN_CBACK *p_sco_cb; /* SCO connection change callback registered by AV */
|
||||
tBTA_SYS_CONN_CBACK *p_role_cb; /* role change callback registered by AV */
|
||||
tBTA_SYS_COLLISION colli_reg; /* collision handling module */
|
||||
#if (BTA_EIR_CANNED_UUID_LIST != TRUE)
|
||||
tBTA_SYS_EIR_CBACK *eir_cb; /* add/remove UUID into EIR */
|
||||
#endif
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
tBTA_SYS_SSR_CFG_CBACK *p_ssr_cb;
|
||||
#endif
|
||||
/* VS event handler */
|
||||
tBTA_SYS_VS_EVT_HDLR *p_vs_evt_hdlr;
|
||||
|
||||
} tBTA_SYS_CB;
|
||||
|
||||
/*****************************************************************************
|
||||
** Global variables
|
||||
*****************************************************************************/
|
||||
|
||||
/* system manager control block */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
extern tBTA_SYS_CB bta_sys_cb;
|
||||
#else
|
||||
extern tBTA_SYS_CB *bta_sys_cb_ptr;
|
||||
#define bta_sys_cb (*bta_sys_cb_ptr)
|
||||
#endif
|
||||
|
||||
/* functions used for BTA SYS HW state machine */
|
||||
void bta_sys_hw_btm_cback( tBTM_DEV_STATUS status );
|
||||
void bta_sys_hw_error(tBTA_SYS_HW_MSG *p_sys_hw_msg);
|
||||
void bta_sys_hw_api_enable( tBTA_SYS_HW_MSG *p_sys_hw_msg );
|
||||
void bta_sys_hw_api_disable(tBTA_SYS_HW_MSG *p_sys_hw_msg);
|
||||
void bta_sys_hw_evt_enabled(tBTA_SYS_HW_MSG *p_sys_hw_msg);
|
||||
void bta_sys_hw_evt_disabled(tBTA_SYS_HW_MSG *p_sys_hw_msg);
|
||||
void bta_sys_hw_evt_stack_enabled(tBTA_SYS_HW_MSG *p_sys_hw_msg);
|
||||
|
||||
BOOLEAN bta_sys_sm_execute(BT_HDR *p_msg);
|
||||
|
||||
#endif /* BTA_SYS_INT_H */
|
47
tools/sdk/include/bluedroid/btc_blufi_prf.h
Normal file
47
tools/sdk/include/bluedroid/btc_blufi_prf.h
Normal file
@ -0,0 +1,47 @@
|
||||
// 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_BLUFI_PRF_H__
|
||||
#define __BTC_BLUFI_PRF_H__
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "btc_task.h"
|
||||
#include "esp_blufi_api.h"
|
||||
|
||||
typedef enum {
|
||||
BTC_BLUFI_ACT_INIT = 0,
|
||||
BTC_BLUFI_ACT_DEINIT,
|
||||
BTC_BLUFI_ACT_SEND_CFG_REPORT,
|
||||
} btc_blufi_act_t;
|
||||
|
||||
typedef union {
|
||||
struct blufi_cfg_report {
|
||||
wifi_mode_t opmode;
|
||||
esp_blufi_sta_conn_state_t sta_conn_state;
|
||||
uint8_t softap_conn_num;
|
||||
esp_blufi_extra_info_t *extra_info;
|
||||
int extra_info_len;
|
||||
} wifi_conn_report;
|
||||
} btc_blufi_args_t;
|
||||
|
||||
void btc_blufi_cb_handler(btc_msg_t *msg);
|
||||
void btc_blufi_call_handler(btc_msg_t *msg);
|
||||
void btc_blufi_set_callbacks(esp_blufi_callbacks_t *callbacks);
|
||||
|
||||
void btc_blufi_call_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_blufi_call_deep_free(btc_msg_t *msg);
|
||||
|
||||
uint16_t btc_blufi_get_version(void);
|
||||
|
||||
#endif /* __BTC_BLUFI_PRF_H__ */
|
98
tools/sdk/include/bluedroid/btc_gap_ble.h
Normal file
98
tools/sdk/include/bluedroid/btc_gap_ble.h
Normal file
@ -0,0 +1,98 @@
|
||||
// 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_GAP_BLE_H__
|
||||
#define __BTC_GAP_BLE_H__
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_gap_ble_api.h"
|
||||
|
||||
#define BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == ESP_BLE_CONN_PARAM_UNDEF))
|
||||
|
||||
typedef enum {
|
||||
BTC_GAP_BLE_ACT_CFG_ADV_DATA = 0,
|
||||
BTC_GAP_BLE_ACT_SET_SCAN_PARAM,
|
||||
BTC_GAP_BLE_ACT_START_SCAN,
|
||||
BTC_GAP_BLE_ACT_STOP_SCAN,
|
||||
BTC_GAP_BLE_ACT_START_ADV,
|
||||
BTC_GAP_BLE_ACT_STOP_ADV,
|
||||
BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM,
|
||||
BTC_GAP_BLE_ACT_SET_PKT_DATA_LEN,
|
||||
BTC_GAP_BLE_ACT_SET_RAND_ADDRESS,
|
||||
BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY,
|
||||
BTC_GAP_BLE_ACT_SET_DEV_NAME,
|
||||
BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
|
||||
BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW,
|
||||
} btc_gap_ble_act_t;
|
||||
|
||||
/* btc_ble_gap_args_t */
|
||||
typedef union {
|
||||
//BTC_GAP_BLE_ACT_CFG_ADV_DATA = 0,
|
||||
struct config_adv_data_args {
|
||||
esp_ble_adv_data_t adv_data;
|
||||
} cfg_adv_data;
|
||||
//BTC_GAP_BLE_ACT_SET_SCAN_PARAM,
|
||||
struct set_scan_params_args {
|
||||
esp_ble_scan_params_t scan_params;
|
||||
} set_scan_param;
|
||||
//BTC_GAP_BLE_ACT_START_SCAN,
|
||||
struct start_scan_args {
|
||||
uint32_t duration;
|
||||
} start_scan;
|
||||
//BTC_GAP_BLE_ACT_STOP_SCAN, no args
|
||||
//BTC_GAP_BLE_ACT_START_ADV,
|
||||
struct start_adv_args {
|
||||
esp_ble_adv_params_t adv_params;
|
||||
} start_adv;
|
||||
//BTC_GAP_BLE_ACT_STOP_ADV, no args
|
||||
//BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM,
|
||||
struct conn_update_params_args {
|
||||
esp_ble_conn_update_params_t conn_params;
|
||||
} conn_update_params;
|
||||
//BTC_GAP_BLE_ACT_SET_PKT_DATA_LEN
|
||||
struct set_pkt_data_len_args {
|
||||
esp_bd_addr_t remote_device;
|
||||
uint16_t tx_data_length;
|
||||
} set_pkt_data_len;
|
||||
//BTC_GAP_BLE_ACT_SET_RAND_ADDRESS,
|
||||
struct set_rand_addr_args {
|
||||
esp_bd_addr_t rand_addr;
|
||||
} set_rand_addr;
|
||||
//BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY,
|
||||
struct cfg_local_privacy_args {
|
||||
bool privacy_enable;
|
||||
} cfg_local_privacy;
|
||||
//BTC_GAP_BLE_ACT_SET_DEV_NAME,
|
||||
struct set_dev_name_args {
|
||||
#define ESP_GAP_DEVICE_NAME_MAX (32)
|
||||
char device_name[ESP_GAP_DEVICE_NAME_MAX + 1];
|
||||
} set_dev_name;
|
||||
//BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
|
||||
struct config_adv_data_raw_args {
|
||||
uint8_t *raw_adv;
|
||||
uint32_t raw_adv_len;
|
||||
} cfg_adv_data_raw;
|
||||
//BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW,
|
||||
struct config_scan_rsp_data_raw_args {
|
||||
uint8_t *raw_scan_rsp;
|
||||
uint32_t raw_scan_rsp_len;
|
||||
} cfg_scan_rsp_data_raw;
|
||||
} btc_ble_gap_args_t;
|
||||
|
||||
void btc_gap_ble_call_handler(btc_msg_t *msg);
|
||||
void btc_gap_ble_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
#endif /* __BTC_GAP_BLE_H__ */
|
22
tools/sdk/include/bluedroid/btc_gap_bt.h
Normal file
22
tools/sdk/include/bluedroid/btc_gap_bt.h
Normal file
@ -0,0 +1,22 @@
|
||||
// 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_GAP_BT_H__
|
||||
#define __BTC_GAP_BT_H__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define /* __BTC_GAP_BT_H__ */
|
40
tools/sdk/include/bluedroid/btc_gatt_util.h
Normal file
40
tools/sdk/include/bluedroid/btc_gatt_util.h
Normal file
@ -0,0 +1,40 @@
|
||||
// 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_UTIL_H__
|
||||
#define __BTC_GATT_UTIL_H__
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_gatt_defs.h"
|
||||
#include "esp_gattc_api.h"
|
||||
|
||||
#define BTC_GATT_CREATE_CONN_ID(gatt_if, conn_id) ((uint16_t) ((((uint8_t)(conn_id)) << 8) | ((uint8_t)(gatt_if))))
|
||||
#define BTC_GATT_GET_CONN_ID(conn_id) (((uint16_t)(conn_id)) >> 8)
|
||||
#define BTC_GATT_GET_GATT_IF(conn_id) ((uint8_t)(conn_id))
|
||||
|
||||
void btc128_to_bta_uuid(tBT_UUID *p_dest, uint8_t *p_src);
|
||||
void btc_to_bta_uuid(tBT_UUID *p_dest, esp_bt_uuid_t *p_src);
|
||||
void btc_to_bta_gatt_id(tBTA_GATT_ID *p_dest, esp_gatt_id_t *p_src);
|
||||
void btc_to_bta_srvc_id(tBTA_GATT_SRVC_ID *p_dest, esp_gatt_srvc_id_t *p_src);
|
||||
void btc_to_bta_response(tBTA_GATTS_RSP *rsp_struct, esp_gatt_rsp_t *p_rsp);
|
||||
|
||||
void bta_to_btc_uuid(esp_bt_uuid_t *p_dest, tBT_UUID *p_src);
|
||||
void bta_to_btc_gatt_id(esp_gatt_id_t *p_dest, tBTA_GATT_ID *p_src);
|
||||
void bta_to_btc_srvc_id(esp_gatt_srvc_id_t *p_dest, tBTA_GATT_SRVC_ID *p_src);
|
||||
|
||||
uint16_t set_read_value(uint8_t *gattc_if, esp_ble_gattc_cb_param_t *p_dest, tBTA_GATTC_READ *p_src);
|
||||
|
||||
#endif /* __BTC_GATT_UTIL_H__*/
|
183
tools/sdk/include/bluedroid/btc_gattc.h
Normal file
183
tools/sdk/include/bluedroid/btc_gattc.h
Normal file
@ -0,0 +1,183 @@
|
||||
// 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_GATTC_H__
|
||||
#define __BTC_GATTC_H__
|
||||
|
||||
#include "btc_task.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_gatt_defs.h"
|
||||
#include "esp_gattc_api.h"
|
||||
|
||||
typedef enum {
|
||||
BTC_GATTC_ACT_APP_REGISTER = 0,
|
||||
BTC_GATTC_ACT_APP_UNREGISTER,
|
||||
BTC_GATTC_ACT_OPEN,
|
||||
BTC_GATTC_ACT_CLOSE,
|
||||
BTC_GATTC_ACT_CFG_MTU,
|
||||
BTC_GATTC_ACT_SEARCH_SERVICE,
|
||||
BTC_GATTC_ACT_GET_FIRST_CHAR,
|
||||
BTC_GATTC_ACT_GET_NEXT_CHAR,
|
||||
BTC_GATTC_ACT_GET_FIRST_DESCR,
|
||||
BTC_GATTC_ACT_GET_NEXT_DESCR,
|
||||
BTC_GATTC_ACT_GET_FIRST_INCL_SERVICE,
|
||||
BTC_GATTC_ACT_GET_NEXT_INCL_SERVICE,
|
||||
BTC_GATTC_ACT_READ_CHAR,
|
||||
BTC_GATTC_ACT_READ_CHAR_DESCR,
|
||||
BTC_GATTC_ACT_WRITE_CHAR,
|
||||
BTC_GATTC_ACT_WRITE_CHAR_DESCR,
|
||||
BTC_GATTC_ACT_PREPARE_WRITE,
|
||||
BTC_GATTC_ACT_EXECUTE_WRITE,
|
||||
BTC_GATTC_ACT_REG_FOR_NOTIFY,
|
||||
BTC_GATTC_ACT_UNREG_FOR_NOTIFY
|
||||
} btc_gattc_act_t;
|
||||
|
||||
/* btc_ble_gattc_args_t */
|
||||
typedef union {
|
||||
//BTC_GATTC_ACT_APP_REGISTER,
|
||||
struct app_reg_arg {
|
||||
uint16_t app_id;
|
||||
} app_reg;
|
||||
//BTC_GATTC_ACT_APP_UNREGISTER,
|
||||
struct app_unreg_arg {
|
||||
esp_gatt_if_t gattc_if;
|
||||
} app_unreg;
|
||||
//BTC_GATTC_ACT_OPEN,
|
||||
struct open_arg {
|
||||
esp_gatt_if_t gattc_if;
|
||||
esp_bd_addr_t remote_bda;
|
||||
bool is_direct;
|
||||
} open;
|
||||
//BTC_GATTC_ACT_CLOSE,
|
||||
struct close_arg {
|
||||
uint16_t conn_id;
|
||||
} close;
|
||||
//BTC_GATTC_ACT_CFG_MTU,
|
||||
struct cfg_mtu_arg {
|
||||
uint16_t conn_id;
|
||||
uint16_t mtu;
|
||||
} cfg_mtu;
|
||||
//BTC_GATTC_ACT_SEARCH_SERVICE,
|
||||
struct search_srvc_arg {
|
||||
uint16_t conn_id;
|
||||
bool filter_uuid_enable;
|
||||
esp_bt_uuid_t filter_uuid;
|
||||
} search_srvc;
|
||||
//BTC_GATTC_ACT_GET_FIRST_CHAR,
|
||||
struct get_first_char_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
} get_first_char;
|
||||
//BTC_GATTC_ACT_GET_NEXT_CHAR,
|
||||
struct get_next_char_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
} get_next_char;
|
||||
//BTC_GATTC_ACT_GET_FIRST_DESCR,
|
||||
struct get_first_descr_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
} get_first_descr;
|
||||
//BTC_GATTC_ACT_GET_NEXT_DESCR,
|
||||
struct get_next_descr_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
esp_gatt_id_t descr_id;
|
||||
} get_next_descr;
|
||||
//BTC_GATTC_ACT_GET_FIRST_INCL_SERVICE,
|
||||
struct get_first_incl_srvc_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
} get_first_incl_srvc;
|
||||
//BTC_GATTC_ACT_GET_NEXT_INCL_SERVICE,
|
||||
struct get_next_incl_srvc_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_srvc_id_t start_service_id;
|
||||
} get_next_incl_srvc;
|
||||
//BTC_GATTC_ACT_READ_CHAR,
|
||||
struct read_char_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
} read_char;
|
||||
//BTC_GATTC_ACT_READ_CHAR_DESCR,
|
||||
struct read_descr_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
esp_gatt_id_t descr_id;
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
} read_descr;
|
||||
//BTC_GATTC_ACT_WRITE_CHAR,
|
||||
struct write_char_arg {
|
||||
uint16_t conn_id;
|
||||
uint16_t value_len;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
uint8_t *value;
|
||||
esp_gatt_write_type_t write_type;
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
} write_char;
|
||||
//BTC_GATTC_ACT_WRITE_CHAR_DESCR,
|
||||
struct write_descr_arg {
|
||||
uint16_t conn_id;
|
||||
uint16_t value_len;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
esp_gatt_id_t descr_id;
|
||||
uint8_t *value;
|
||||
esp_gatt_write_type_t write_type;
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
} write_descr;
|
||||
//BTC_GATTC_ACT_PREPARE_WRITE,
|
||||
struct prep_write_arg {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
uint16_t offset;
|
||||
uint16_t value_len;
|
||||
uint8_t *value;
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
} prep_write;
|
||||
//BTC_GATTC_ACT_EXECUTE_WRITE,
|
||||
struct exec_write_arg {
|
||||
uint16_t conn_id;
|
||||
bool is_execute;
|
||||
} exec_write;
|
||||
//BTC_GATTC_ACT_REG_FOR_NOTIFY,
|
||||
struct reg_for_notify_arg {
|
||||
esp_gatt_if_t gattc_if;
|
||||
esp_bd_addr_t remote_bda;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
} reg_for_notify;
|
||||
//BTC_GATTC_ACT_UNREG_FOR_NOTIFY
|
||||
struct unreg_for_notify_arg {
|
||||
esp_gatt_if_t gattc_if;
|
||||
esp_bd_addr_t remote_bda;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
esp_gatt_id_t char_id;
|
||||
} unreg_for_notify;
|
||||
} btc_ble_gattc_args_t;
|
||||
|
||||
void btc_gattc_call_handler(btc_msg_t *msg);
|
||||
void btc_gattc_cb_handler(btc_msg_t *msg);
|
||||
void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
#endif /* __BTC_GATTC_H__ */
|
152
tools/sdk/include/bluedroid/btc_gatts.h
Normal file
152
tools/sdk/include/bluedroid/btc_gatts.h
Normal file
@ -0,0 +1,152 @@
|
||||
// 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_GATTS_H__
|
||||
#define __BTC_GATTS_H__
|
||||
|
||||
#include "btc_task.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_gatt_defs.h"
|
||||
#include "esp_gatts_api.h"
|
||||
|
||||
typedef enum {
|
||||
BTC_GATTS_ACT_APP_REGISTER = 0,
|
||||
BTC_GATTS_ACT_APP_UNREGISTER,
|
||||
BTC_GATTS_ACT_CREATE_SERVICE,
|
||||
BTC_GATTS_ACT_CREATE_ATTR_TAB,
|
||||
BTC_GATTS_ACT_DELETE_SERVICE,
|
||||
BTC_GATTS_ACT_START_SERVICE,
|
||||
BTC_GATTS_ACT_STOP_SERVICE,
|
||||
BTC_GATTS_ACT_ADD_INCLUDE_SERVICE,
|
||||
BTC_GATTS_ACT_ADD_CHAR,
|
||||
BTC_GATTS_ACT_ADD_CHAR_DESCR,
|
||||
BTC_GATTS_ACT_SEND_INDICATE,
|
||||
BTC_GATTS_ACT_SEND_RESPONSE,
|
||||
BTC_GATTS_ACT_SET_ATTR_VALUE,
|
||||
BTC_GATTS_ACT_OPEN,
|
||||
BTC_GATTS_ACT_CLOSE,
|
||||
} btc_gatts_act_t;
|
||||
|
||||
/* btc_ble_gatts_args_t */
|
||||
typedef union {
|
||||
//BTC_GATTS_ACT_APP_REGISTER = 0,
|
||||
struct app_reg_args {
|
||||
uint16_t app_id;
|
||||
} app_reg;
|
||||
|
||||
//BTC_GATTS_ACT_APP_UNREGISTER,
|
||||
struct app_unreg_args {
|
||||
esp_gatt_if_t gatts_if;
|
||||
} app_unreg;
|
||||
|
||||
//BTC_GATTS_ACT_CREATE_SERVICE,
|
||||
struct create_srvc_args {
|
||||
esp_gatt_if_t gatts_if;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
uint16_t num_handle;
|
||||
} create_srvc;
|
||||
|
||||
//BTC_GATTS_ACT_CREATE_ATTR_TAB
|
||||
struct create_attr_tab_args{
|
||||
esp_gatt_if_t gatts_if;
|
||||
uint8_t srvc_inst_id;
|
||||
uint8_t max_nb_attr;
|
||||
esp_gatts_attr_db_t *gatts_attr_db;
|
||||
}create_attr_tab;
|
||||
|
||||
//BTC_GATTS_ACT_DELETE_SERVICE,
|
||||
struct delete_srvc_args {
|
||||
uint16_t service_handle;
|
||||
} delete_srvc;
|
||||
|
||||
//BTC_GATTS_ACT_START_SERVICE,
|
||||
struct start_srvc_args {
|
||||
uint16_t service_handle;
|
||||
} start_srvc;
|
||||
|
||||
//BTC_GATTS_ACT_STOP_SERVICE,
|
||||
struct stop_srvc_args {
|
||||
uint16_t service_handle;
|
||||
} stop_srvc;
|
||||
|
||||
//BTC_GATTS_ACT_ADD_INCLUDE_SERVICE,
|
||||
struct add_incl_srvc_args {
|
||||
uint16_t service_handle;
|
||||
uint16_t included_service_handle;
|
||||
} add_incl_srvc;
|
||||
|
||||
//BTC_GATTS_ACT_ADD_CHAR,
|
||||
struct add_char_args {
|
||||
uint16_t service_handle;
|
||||
esp_bt_uuid_t char_uuid;
|
||||
esp_gatt_perm_t perm;
|
||||
esp_gatt_char_prop_t property;
|
||||
esp_attr_control_t attr_control;
|
||||
esp_attr_value_t char_val;
|
||||
} add_char;
|
||||
|
||||
//BTC_GATTS_ACT_ADD_CHAR_DESCR,
|
||||
struct add_descr_args {
|
||||
uint16_t service_handle;
|
||||
esp_bt_uuid_t descr_uuid;
|
||||
esp_gatt_perm_t perm;
|
||||
esp_attr_control_t attr_control;
|
||||
esp_attr_value_t descr_val;
|
||||
} add_descr;
|
||||
|
||||
//BTC_GATTS_ACT_SEND_INDICATE,
|
||||
struct send_indicate_args {
|
||||
uint16_t conn_id;
|
||||
uint16_t attr_handle;
|
||||
bool need_confirm;
|
||||
uint16_t value_len;
|
||||
uint8_t *value;
|
||||
} send_ind;
|
||||
|
||||
//BTC_GATTS_ACT_SEND_RESPONSE,
|
||||
struct send_rsp_args {
|
||||
uint16_t conn_id;
|
||||
uint32_t trans_id;
|
||||
esp_gatt_status_t status;
|
||||
esp_gatt_rsp_t *rsp;
|
||||
} send_rsp;
|
||||
|
||||
//BTC_GATTS_SET_ATTR_VALUE
|
||||
struct set_attr_val_args{
|
||||
uint16_t length;
|
||||
uint8_t *value;
|
||||
} set_attr_val;
|
||||
|
||||
//BTC_GATTS_ACT_OPEN,
|
||||
struct open_args {
|
||||
esp_gatt_if_t gatts_if;
|
||||
esp_bd_addr_t remote_bda;
|
||||
bool is_direct;
|
||||
} open;
|
||||
|
||||
//BTC_GATTS_ACT_CLOSE,
|
||||
struct close_args {
|
||||
uint16_t conn_id;
|
||||
} close;
|
||||
|
||||
} btc_ble_gatts_args_t;
|
||||
|
||||
|
||||
void btc_gatts_call_handler(btc_msg_t *msg);
|
||||
void btc_gatts_cb_handler(btc_msg_t *msg);
|
||||
void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, uint8_t **value);
|
||||
|
||||
|
||||
#endif /* __BTC_GATTS_H__ */
|
64
tools/sdk/include/bluedroid/btc_main.h
Normal file
64
tools/sdk/include/bluedroid/btc_main.h
Normal file
@ -0,0 +1,64 @@
|
||||
// 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_BT_MAIN_H__
|
||||
#define __BTC_BT_MAIN_H__
|
||||
|
||||
#include "future.h"
|
||||
#include "bt_types.h"
|
||||
#include "bta_api.h"
|
||||
#include "btc_main.h"
|
||||
#include "btc_task.h"
|
||||
|
||||
typedef enum {
|
||||
BTC_MAIN_ACT_INIT = 0,
|
||||
BTC_MAIN_ACT_DEINIT,
|
||||
BTC_MAIN_ACT_ENABLE,
|
||||
BTC_MAIN_ACT_DISABLE,
|
||||
} btc_main_act_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_MAIN_INIT_FUTURE = 0,
|
||||
BTC_MAIN_DEINIT_FUTURE,
|
||||
BTC_MAIN_ENABLE_FUTURE,
|
||||
BTC_MAIN_DISABLE_FUTURE,
|
||||
BTC_MAIN_FUTURE_NUM,
|
||||
} btc_main_future_type_t;
|
||||
|
||||
future_t **btc_main_get_future_p(btc_main_future_type_t type);
|
||||
|
||||
#if 0
|
||||
typedef union {
|
||||
struct btc_main_init_args {
|
||||
future_t *future;
|
||||
} init;
|
||||
struct btc_main_deinit_args {
|
||||
future_t *future;
|
||||
} deinit;
|
||||
struct btc_main_init_args {
|
||||
future_t *future;
|
||||
} enable;
|
||||
struct btc_main_init_args {
|
||||
future_t *future;
|
||||
} disable;
|
||||
} btc_main_args_t;
|
||||
|
||||
bt_status_t btc_enable_bluetooth(future_t *future);
|
||||
void btc_disable_bluetooth(future_t *future);
|
||||
bt_status_t btc_init_bluetooth(future_t *future);
|
||||
void btc_deinit_bluetooth(future_t *future);
|
||||
#endif
|
||||
|
||||
void btc_main_call_handler(btc_msg_t *msg);
|
||||
#endif /* __BTC_BT_MAIN_H__ */
|
28
tools/sdk/include/bluedroid/btc_manage.h
Normal file
28
tools/sdk/include/bluedroid/btc_manage.h
Normal file
@ -0,0 +1,28 @@
|
||||
// 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_MANAGE_H__
|
||||
#define __BTC_MANAGE_H__
|
||||
|
||||
#include "bta_api.h"
|
||||
#include "btc_task.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
/* reset gatt callback table */
|
||||
void esp_profile_cb_reset(void);
|
||||
|
||||
int btc_profile_cb_set(btc_pid_t profile_id, void *cb);
|
||||
void *btc_profile_cb_get(btc_pid_t profile_id);
|
||||
|
||||
#endif /* __BTC_MANAGE_H__ */
|
129
tools/sdk/include/bluedroid/btc_sdp.h
Normal file
129
tools/sdk/include/bluedroid/btc_sdp.h
Normal file
@ -0,0 +1,129 @@
|
||||
// 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 __ESP_SDP_API_H__
|
||||
#define __ESP_SDP_API_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_common.h"
|
||||
#include "bta_sdp_api.h"
|
||||
#include "bt_sdp.h"
|
||||
|
||||
#define BT_SDP_STAT_SUCCESS BTA_SDP_SUCCESS
|
||||
#define BT_SDP_STAT_FAILURE BTA_SDP_FAILURE
|
||||
#define BT_SDP_STAT_BUSY BTA_SDP_BUSY
|
||||
|
||||
#define BT_SDP_ENABLE_EVT BTA_SDP_ENABLE_EVT
|
||||
#define BT_SDP_SEARCH_EVT BTA_SDP_SEARCH_EVT
|
||||
#define BT_SDP_SEARCH_COMP_EVT BTA_SDP_SEARCH_COMP_EVT
|
||||
#define BT_SDP_CREATE_RECORD_USER_EVT BTA_SDP_CREATE_RECORD_USER_EVT
|
||||
#define BT_SDP_REMOVE_RECORD_USER_EVT BTA_SDP_REMOVE_RECORD_USER_EVT
|
||||
#define BT_SDP_MAX_EVT BTA_SDP_MAX_EVT
|
||||
|
||||
#define BT_SDP_MAX_RECORDS BTA_SDP_MAX_RECORDS
|
||||
|
||||
typedef tBTA_SDP_STATUS bt_sdp_status_t;
|
||||
|
||||
typedef tBTA_SDP_EVT bt_sdp_evt_t;
|
||||
|
||||
typedef bluetooth_sdp_record bt_sdp_record_t;
|
||||
|
||||
/* tBTA_SEARCH_COMP, bta_sdp_api.h */
|
||||
typedef struct {
|
||||
bt_sdp_status_t status;
|
||||
esp_bd_addr_t remote_addr;
|
||||
esp_bt_uuid_t uuid;
|
||||
int record_count;
|
||||
bt_sdp_record_t records[BT_SDP_MAX_RECORDS];
|
||||
} bt_sdp_search_comp_t;
|
||||
|
||||
/* tBTA_SDP, bta_sdp_api.h */
|
||||
typedef union {
|
||||
bt_sdp_status_t status;
|
||||
bt_sdp_search_comp_t sdp_search_comp;
|
||||
} bt_sdp_t;
|
||||
|
||||
typedef void (bt_sdp_cb_t)(bt_sdp_evt_t event, bt_sdp_t *p_data, void *user_data);
|
||||
|
||||
esp_err_t esp_bt_sdp_enable(bt_sdp_cb_t *cback);
|
||||
|
||||
esp_err_t esp_bt_sdp_search(esp_bd_addr_t bd_addr, esp_bt_uuid_t *uuid);
|
||||
|
||||
esp_err_t esp_bt_sdp_create_record_by_user(void *user_data);
|
||||
|
||||
esp_err_t esp_bt_sdp_remove_record_by_user(void *user_data);
|
||||
|
||||
|
||||
/**********************************************************************************************/
|
||||
/**********************************************************************************************/
|
||||
/* API into SDP for local service database updates
|
||||
* these APIs are indended to be called in callback function in the context of stack task,
|
||||
* to handle BT_SDP_CREATE_RECORD_USER_EVT and BT_SDP_REMOVE_RECORD_USER_EVT
|
||||
*/
|
||||
|
||||
/* This structure is used to add protocol lists and find protocol elements */
|
||||
#define ESP_BT_SDP_MAX_PROTOCOL_PARAMS SDP_MAX_PROTOCOL_PARAMS // bt_target.h
|
||||
typedef struct {
|
||||
uint16_t protocol_uuid;
|
||||
uint16_t num_params;
|
||||
uint16_t params[ESP_BT_SDP_MAX_PROTOCOL_PARAMS];
|
||||
} sdp_proto_elem_t; // tSDP_PROTOCOL_ELEM, sdp_api.h
|
||||
|
||||
#define ESP_BT_SDP_MAX_LIST_ELEMS SDP_MAX_LIST_ELEMS // sdp_api.h
|
||||
typedef struct {
|
||||
uint16_t num_elems;
|
||||
sdp_proto_elem_t list_elem[ESP_BT_SDP_MAX_LIST_ELEMS];
|
||||
} sdp_proto_list_elem_t; // tSDP_PROTO_LIST_ELEM, sdp_api.h
|
||||
|
||||
|
||||
uint32_t esp_bt_sdp_create_record(void);
|
||||
|
||||
bool esp_bt_sdp_delete_record(uint32_t handle);
|
||||
|
||||
int32_t esp_bt_sdp_read_record(uint32_t handle, uint8_t *data, int32_t *data_len);
|
||||
|
||||
bool esp_bt_sdp_add_attribute (uint32_t handle, uint16_t attr_id,
|
||||
uint8_t attr_type, uint32_t attr_len,
|
||||
uint8_t *p_val);
|
||||
|
||||
bool esp_bt_sdp_add_sequence (uint32_t handle, uint16_t attr_id,
|
||||
uint16_t num_elem, uint8_t type[],
|
||||
uint8_t len[], uint8_t *p_val[]);
|
||||
|
||||
bool esp_bt_sdp_add_uuid_sequence (uint32_t handle, uint16_t attr_id,
|
||||
uint16_t num_uuids, uint16_t *p_uuids);
|
||||
|
||||
|
||||
bool esp_bt_sdp_add_protocol_list (uint32_t handle, uint16_t num_elem,
|
||||
sdp_proto_elem_t *p_elem_list);
|
||||
|
||||
bool esp_bt_sdp_add_addition_protocol_lists(uint32_t handle, uint16_t num_elem,
|
||||
sdp_proto_list_elem_t *p_proto_list);
|
||||
|
||||
bool esp_bt_sdp_add_profile_dscp_list (uint32_t handle,
|
||||
uint16_t profile_uuid,
|
||||
uint16_t version);
|
||||
|
||||
bool esp_bt_sdp_add_lang_base_attr_id_list(uint32_t handle,
|
||||
uint16_t lang, uint16_t char_enc,
|
||||
uint16_t base_id);
|
||||
|
||||
bool esp_bt_sdp_add_service_class_id_list(uint32_t handle,
|
||||
uint16_t num_services,
|
||||
uint16_t *p_service_uuids);
|
||||
|
||||
bool esp_bt_sdp_delete_attribute(uint32_t handle, uint16_t attr_id);
|
||||
|
||||
#endif /* __ESP_SDP_API_H__ */
|
63
tools/sdk/include/bluedroid/btc_task.h
Normal file
63
tools/sdk/include/bluedroid/btc_task.h
Normal file
@ -0,0 +1,63 @@
|
||||
// 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_TASK_H__
|
||||
#define __BTC_TASK_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "bt_defs.h"
|
||||
#include "thread.h"
|
||||
|
||||
typedef struct btc_msg {
|
||||
uint8_t sig; //event signal
|
||||
uint8_t aid; //application id
|
||||
uint8_t pid; //profile id
|
||||
uint8_t act; //profile action, defined in seprerate header files
|
||||
void *arg; //param for btc function or function param
|
||||
} btc_msg_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_SIG_API_CALL = 0, // APP TO STACK
|
||||
BTC_SIG_API_CB, // STACK TO APP
|
||||
BTC_SIG_NUM,
|
||||
} btc_sig_t; //btc message type
|
||||
|
||||
typedef enum {
|
||||
BTC_PID_MAIN_INIT = 0,
|
||||
BTC_PID_GATTS,
|
||||
BTC_PID_GATTC,
|
||||
BTC_PID_GAP_BLE,
|
||||
BTC_PID_GAP_BT,
|
||||
BTC_PID_SDP,
|
||||
BTC_PID_BLE_HID,
|
||||
BTC_PID_BT_HID,
|
||||
BTC_PID_SPP,
|
||||
BTC_PID_SPPLIKE,
|
||||
BTC_PID_BLUFI,
|
||||
BTC_PID_NUM,
|
||||
} btc_pid_t; //btc profile id
|
||||
|
||||
typedef struct {
|
||||
void (* btc_call)(btc_msg_t *msg);
|
||||
void (* btc_cb)(btc_msg_t *msg);
|
||||
} btc_func_t;
|
||||
|
||||
typedef void (* btc_arg_deep_copy_t)(btc_msg_t *msg, void *dst, void *src);
|
||||
|
||||
bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func);
|
||||
|
||||
int btc_init(void);
|
||||
void btc_deinit(void);
|
||||
|
||||
#endif /* __BTC_TASK_H__ */
|
117
tools/sdk/include/bluedroid/bte.h
Normal file
117
tools/sdk/include/bluedroid/bte.h
Normal file
@ -0,0 +1,117 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2001-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 constants and definitions for the bte project
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTE_H
|
||||
#define BTE_H
|
||||
|
||||
//#include <semaphore.h>
|
||||
//#include <signal.h>
|
||||
//#include <pthread.h>
|
||||
#include "bt_target.h"
|
||||
|
||||
/* by default on shutdown, baudrate is reset 115kbits. this should NOT be need for platforms
|
||||
* that kill BTE driver and remove/reset BT chip
|
||||
*/
|
||||
#ifndef BTE_RESET_BAUD_ON_BT_DISABLE
|
||||
#define BTE_RESET_BAUD_ON_BT_DISABLE TRUE
|
||||
#endif
|
||||
|
||||
/* Target Modes (based on jumper settings on hardware [see user manual]) */
|
||||
enum {
|
||||
/* BTE BBY */
|
||||
/* J3 J4 SW3-3 SW3-2 SW3-1 */
|
||||
/* -------------------------------------------- */
|
||||
BTE_MODE_SERIAL_APP, /* OUT OUT OFF OFF OFF Sample serial port application */
|
||||
BTE_MODE_APPL, /* IN OUT OFF OFF ON Target used with Tester through RPC */
|
||||
BTE_MODE_RESERVED, /* OUT IN OFF ON OFF Reserved */
|
||||
BTE_MODE_SAMPLE_APPS, /* IN IN OFF ON ON Sample applications (ICP/HSP) */
|
||||
BTE_MODE_DONGLE, /* not yet supported ON OFF OFF Dongle mode */
|
||||
BTE_MODE_APPL_PROTOCOL_TRACE, /* this is a fake mode do allow protocol tracing in application without rpc */
|
||||
BTE_MODE_INVALID
|
||||
};
|
||||
|
||||
extern volatile UINT8 bte_target_mode; /* indicates the mode that the board is running in */
|
||||
|
||||
/* Startup options */
|
||||
extern UINT32 bte_startup_options; /* Switch and jumper settings at startup */
|
||||
void bte_get_startup_options(UINT32 *p_options); /* Platform specific function for getting startup options */
|
||||
|
||||
#define BTE_OPTIONS_TARGET_MODE_MASK 0x00000007 /* bits 2-0 indicate target mode (QuickConnect: jp3 & jp4, BBY: SW3-1 & SW3-2)*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions to define which type of application gets built
|
||||
****************************************************************************/
|
||||
#define BUILD_HCITOOL FALSE
|
||||
#define BUILD_L2PING FALSE
|
||||
|
||||
|
||||
#define LINUX_FM_DRIVER_INCLUDED FALSE
|
||||
|
||||
|
||||
/* hcisu userial operations. should probably go into bt_types to avoid collisions! */
|
||||
#define BT_EVT_TO_HCISU_USERIAL_OP (0x0080 | BT_EVT_HCISU)
|
||||
/* operation for above hcisu event */
|
||||
#define BT_HCISU_USERIAL_OPEN (0) /* open serial port calling USERIAL_Open() */
|
||||
#define BT_HCISU_USERIAL_CLOSE (1) /* close userial port */
|
||||
/* options associated with close op */
|
||||
#define BT_HCISU_USERIAL_CL_NO_DIS_BT 0 /* do not touch bt_wake and power gpio */
|
||||
#define BT_HCISU_USERIAL_CL_DIS_BT 1 /* put power and bt_wake into defined off state to preserve
|
||||
power */
|
||||
/* status codes for callback */
|
||||
/*
|
||||
#define BTE_HCISU_USERIAL_FAIL 0
|
||||
#define BTE_HCISU_USERIAL_OK 1
|
||||
typedef void (tUSERIAL_MSG_CBACK) (int status);
|
||||
typedef struct tHCISU_USERIAL_MSG_tag {
|
||||
BT_HDR hdr;
|
||||
tUSERIAL_MSG_CBACK *p_cback;
|
||||
UINT8 port; // port number
|
||||
UINT8 op;
|
||||
UINT8 option; // option for operation. depends on operation
|
||||
} tHCISU_USERIAL_MSG;
|
||||
|
||||
extern void bte_hcisu_userial_oper( tUSERIAL_MSG_CBACK *p_cback, UINT8 port, UINT8 op, UINT8 option );
|
||||
*/
|
||||
|
||||
/* Pointer to function for sending HCI commands and data to the HCI tranport */
|
||||
extern int (*p_bte_hci_send)(UINT16 port, BT_HDR *p_msg);
|
||||
|
||||
|
||||
/* Protocol trace mask */
|
||||
extern UINT32 bte_proto_trace_mask;
|
||||
|
||||
typedef struct tBAUD_REG_tag {
|
||||
UINT8 DHBR;
|
||||
UINT8 DLBR;
|
||||
UINT8 ExplicitBaudRate0;
|
||||
UINT8 ExplicitBaudRate1;
|
||||
UINT8 ExplicitBaudRate2;
|
||||
UINT8 ExplicitBaudRate3;
|
||||
} tBAUD_REG;
|
||||
|
||||
#include "gki.h"
|
||||
|
||||
extern const tBAUD_REG baud_rate_regs[];
|
||||
|
||||
#endif /* BTE_H */
|
37
tools/sdk/include/bluedroid/bte_appl.h
Executable file
37
tools/sdk/include/bluedroid/bte_appl.h
Executable file
@ -0,0 +1,37 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-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 interface file for the bte application task
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef struct {
|
||||
#if ((BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
|
||||
UINT8 ble_auth_req;
|
||||
UINT8 ble_io_cap;
|
||||
UINT8 ble_init_key;
|
||||
UINT8 ble_resp_key;
|
||||
UINT8 ble_max_key_size;
|
||||
#endif
|
||||
} tBTE_APPL_CFG;
|
||||
|
||||
extern tBTE_APPL_CFG bte_appl_cfg;
|
4029
tools/sdk/include/bluedroid/btm_api.h
Normal file
4029
tools/sdk/include/bluedroid/btm_api.h
Normal file
File diff suppressed because it is too large
Load Diff
1958
tools/sdk/include/bluedroid/btm_ble_api.h
Normal file
1958
tools/sdk/include/bluedroid/btm_ble_api.h
Normal file
File diff suppressed because it is too large
Load Diff
476
tools/sdk/include/bluedroid/btm_ble_int.h
Normal file
476
tools/sdk/include/bluedroid/btm_ble_int.h
Normal file
@ -0,0 +1,476 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-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 the main Bluetooth Manager (BTM) internal
|
||||
* definitions.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BTM_BLE_INT_H
|
||||
#define BTM_BLE_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
#include "hcidefs.h"
|
||||
#include "btm_ble_api.h"
|
||||
#include "btm_int.h"
|
||||
|
||||
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
|
||||
#include "smp_api.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* scanning enable status */
|
||||
#define BTM_BLE_SCAN_ENABLE 0x01
|
||||
#define BTM_BLE_SCAN_DISABLE 0x00
|
||||
|
||||
/* advertising enable status */
|
||||
#define BTM_BLE_ADV_ENABLE 0x01
|
||||
#define BTM_BLE_ADV_DISABLE 0x00
|
||||
|
||||
/* use the high 4 bits unused by inquiry mode */
|
||||
#define BTM_BLE_SELECT_SCAN 0x20
|
||||
#define BTM_BLE_NAME_REQUEST 0x40
|
||||
#define BTM_BLE_OBSERVE 0x80
|
||||
|
||||
#define BTM_BLE_MAX_WL_ENTRY 1
|
||||
#define BTM_BLE_AD_DATA_LEN 31
|
||||
|
||||
#define BTM_BLE_ENC_MASK 0x03
|
||||
|
||||
#define BTM_BLE_DUPLICATE_ENABLE 1
|
||||
#define BTM_BLE_DUPLICATE_DISABLE 0
|
||||
|
||||
#define BTM_BLE_GAP_DISC_SCAN_INT 18 /* Interval(scan_int) = 11.25 ms= 0x0010 * 0.625 ms */
|
||||
#define BTM_BLE_GAP_DISC_SCAN_WIN 18 /* scan_window = 11.25 ms= 0x0010 * 0.625 ms */
|
||||
#define BTM_BLE_GAP_ADV_INT 512 /* Tgap(gen_disc) = 1.28 s= 512 * 0.625 ms */
|
||||
#define BTM_BLE_GAP_LIM_TOUT 180 /* Tgap(lim_timeout) = 180s max */
|
||||
#define BTM_BLE_LOW_LATENCY_SCAN_INT 8000 /* Interval(scan_int) = 5s= 8000 * 0.625 ms */
|
||||
#define BTM_BLE_LOW_LATENCY_SCAN_WIN 8000 /* scan_window = 5s= 8000 * 0.625 ms */
|
||||
|
||||
|
||||
#define BTM_BLE_GAP_ADV_FAST_INT_1 48 /* TGAP(adv_fast_interval1) = 30(used) ~ 60 ms = 48 *0.625 */
|
||||
#define BTM_BLE_GAP_ADV_FAST_INT_2 160 /* TGAP(adv_fast_interval2) = 100(used) ~ 150 ms = 160 * 0.625 ms */
|
||||
#define BTM_BLE_GAP_ADV_SLOW_INT 2048 /* Tgap(adv_slow_interval) = 1.28 s= 512 * 0.625 ms */
|
||||
#define BTM_BLE_GAP_ADV_DIR_MAX_INT 800 /* Tgap(dir_conn_adv_int_max) = 500 ms = 800 * 0.625 ms */
|
||||
#define BTM_BLE_GAP_ADV_DIR_MIN_INT 400 /* Tgap(dir_conn_adv_int_min) = 250 ms = 400 * 0.625 ms */
|
||||
|
||||
#define BTM_BLE_GAP_FAST_ADV_TOUT 30
|
||||
|
||||
#define BTM_BLE_SEC_REQ_ACT_NONE 0
|
||||
#define BTM_BLE_SEC_REQ_ACT_ENCRYPT 1 /* encrypt the link using current key or key refresh */
|
||||
#define BTM_BLE_SEC_REQ_ACT_PAIR 2
|
||||
#define BTM_BLE_SEC_REQ_ACT_DISCARD 3 /* discard the sec request while encryption is started but not completed */
|
||||
typedef UINT8 tBTM_BLE_SEC_REQ_ACT;
|
||||
|
||||
#define BLE_STATIC_PRIVATE_MSB_MASK 0x3f
|
||||
#define BLE_RESOLVE_ADDR_MSB 0x40 /* most significant bit, bit7, bit6 is 01 to be resolvable random */
|
||||
#define BLE_RESOLVE_ADDR_MASK 0xc0 /* bit 6, and bit7 */
|
||||
#define BTM_BLE_IS_RESOLVE_BDA(x) ((x[0] & BLE_RESOLVE_ADDR_MASK) == BLE_RESOLVE_ADDR_MSB)
|
||||
|
||||
/* LE scan activity bit mask, continue with LE inquiry bits */
|
||||
#define BTM_LE_SELECT_CONN_ACTIVE 0x40 /* selection connection is in progress */
|
||||
#define BTM_LE_OBSERVE_ACTIVE 0x80 /* observe is in progress */
|
||||
|
||||
/* BLE scan activity mask checking */
|
||||
#define BTM_BLE_IS_SCAN_ACTIVE(x) ((x) & BTM_BLE_SCAN_ACTIVE_MASK)
|
||||
#define BTM_BLE_IS_INQ_ACTIVE(x) ((x) & BTM_BLE_INQUIRY_MASK)
|
||||
#define BTM_BLE_IS_OBS_ACTIVE(x) ((x) & BTM_LE_OBSERVE_ACTIVE)
|
||||
#define BTM_BLE_IS_SEL_CONN_ACTIVE(x) ((x) & BTM_LE_SELECT_CONN_ACTIVE)
|
||||
|
||||
/* BLE ADDR type ID bit */
|
||||
#define BLE_ADDR_TYPE_ID_BIT 0x02
|
||||
|
||||
#define BTM_VSC_CHIP_CAPABILITY_L_VERSION 55
|
||||
#define BTM_VSC_CHIP_CAPABILITY_M_VERSION 95
|
||||
|
||||
typedef struct {
|
||||
UINT16 data_mask;
|
||||
UINT8 *p_flags;
|
||||
UINT8 ad_data[BTM_BLE_AD_DATA_LEN];
|
||||
UINT8 *p_pad;
|
||||
} tBTM_BLE_LOCAL_ADV_DATA;
|
||||
|
||||
typedef struct {
|
||||
UINT32 inq_count; /* Used for determining if a response has already been */
|
||||
/* received for the current inquiry operation. (We do not */
|
||||
/* want to flood the caller with multiple responses from */
|
||||
/* the same device. */
|
||||
BOOLEAN scan_rsp;
|
||||
tBLE_BD_ADDR le_bda;
|
||||
} tINQ_LE_BDADDR;
|
||||
|
||||
#define BTM_BLE_ADV_DATA_LEN_MAX 31
|
||||
#define BTM_BLE_CACHE_ADV_DATA_MAX 62
|
||||
|
||||
#define BTM_BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == BTM_BLE_CONN_PARAM_UNDEF))
|
||||
|
||||
#define BTM_BLE_PRIVATE_ADDR_INT 900 /* 15 minutes minimum for random address refreshing */
|
||||
|
||||
typedef struct {
|
||||
UINT16 discoverable_mode;
|
||||
UINT16 connectable_mode;
|
||||
UINT32 scan_window;
|
||||
UINT32 scan_interval;
|
||||
UINT8 scan_type; /* current scan type: active or passive */
|
||||
UINT8 scan_duplicate_filter; /* duplicate filter enabled for scan */
|
||||
UINT16 adv_interval_min;
|
||||
UINT16 adv_interval_max;
|
||||
tBTM_BLE_AFP afp; /* advertising filter policy */
|
||||
tBTM_BLE_SFP sfp; /* scanning filter policy */
|
||||
|
||||
tBLE_ADDR_TYPE adv_addr_type;
|
||||
UINT8 evt_type;
|
||||
UINT8 adv_mode;
|
||||
tBLE_BD_ADDR direct_bda;
|
||||
tBTM_BLE_EVT directed_conn;
|
||||
BOOLEAN fast_adv_on;
|
||||
TIMER_LIST_ENT fast_adv_timer;
|
||||
|
||||
UINT8 adv_len;
|
||||
UINT8 adv_data_cache[BTM_BLE_CACHE_ADV_DATA_MAX];
|
||||
|
||||
/* inquiry BD addr database */
|
||||
UINT8 num_bd_entries;
|
||||
UINT8 max_bd_entries;
|
||||
tBTM_BLE_LOCAL_ADV_DATA adv_data;
|
||||
tBTM_BLE_ADV_CHNL_MAP adv_chnl_map;
|
||||
|
||||
TIMER_LIST_ENT inq_timer_ent;
|
||||
BOOLEAN scan_rsp;
|
||||
UINT8 state; /* Current state that the inquiry process is in */
|
||||
INT8 tx_power;
|
||||
} tBTM_BLE_INQ_CB;
|
||||
|
||||
|
||||
/* random address resolving complete callback */
|
||||
typedef void (tBTM_BLE_RESOLVE_CBACK) (void *match_rec, void *p);
|
||||
|
||||
typedef void (tBTM_BLE_ADDR_CBACK) (BD_ADDR_PTR static_random, void *p);
|
||||
|
||||
/* random address management control block */
|
||||
typedef struct {
|
||||
tBLE_ADDR_TYPE own_addr_type; /* local device LE address type */
|
||||
BD_ADDR private_addr;
|
||||
BD_ADDR random_bda;
|
||||
BOOLEAN busy;
|
||||
UINT16 index;
|
||||
tBTM_BLE_RESOLVE_CBACK *p_resolve_cback;
|
||||
tBTM_BLE_ADDR_CBACK *p_generate_cback;
|
||||
void *p;
|
||||
TIMER_LIST_ENT raddr_timer_ent;
|
||||
} tBTM_LE_RANDOM_CB;
|
||||
|
||||
#define BTM_BLE_MAX_BG_CONN_DEV_NUM 10
|
||||
|
||||
typedef struct {
|
||||
UINT16 min_conn_int;
|
||||
UINT16 max_conn_int;
|
||||
UINT16 slave_latency;
|
||||
UINT16 supervision_tout;
|
||||
|
||||
} tBTM_LE_CONN_PRAMS;
|
||||
|
||||
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr;
|
||||
UINT8 attr;
|
||||
BOOLEAN is_connected;
|
||||
BOOLEAN in_use;
|
||||
} tBTM_LE_BG_CONN_DEV;
|
||||
|
||||
/* white list using state as a bit mask */
|
||||
#define BTM_BLE_WL_IDLE 0
|
||||
#define BTM_BLE_WL_INIT 1
|
||||
#define BTM_BLE_WL_SCAN 2
|
||||
#define BTM_BLE_WL_ADV 4
|
||||
typedef UINT8 tBTM_BLE_WL_STATE;
|
||||
|
||||
/* resolving list using state as a bit mask */
|
||||
#define BTM_BLE_RL_IDLE 0
|
||||
#define BTM_BLE_RL_INIT 1
|
||||
#define BTM_BLE_RL_SCAN 2
|
||||
#define BTM_BLE_RL_ADV 4
|
||||
typedef UINT8 tBTM_BLE_RL_STATE;
|
||||
|
||||
/* BLE connection state */
|
||||
#define BLE_CONN_IDLE 0
|
||||
#define BLE_DIR_CONN 1
|
||||
#define BLE_BG_CONN 2
|
||||
#define BLE_CONN_CANCEL 3
|
||||
typedef UINT8 tBTM_BLE_CONN_ST;
|
||||
|
||||
typedef struct {
|
||||
void *p_param;
|
||||
} tBTM_BLE_CONN_REQ;
|
||||
|
||||
/* LE state request */
|
||||
#define BTM_BLE_STATE_INVALID 0
|
||||
#define BTM_BLE_STATE_CONN_ADV 1
|
||||
#define BTM_BLE_STATE_INIT 2
|
||||
#define BTM_BLE_STATE_MASTER 3
|
||||
#define BTM_BLE_STATE_SLAVE 4
|
||||
#define BTM_BLE_STATE_LO_DUTY_DIR_ADV 5
|
||||
#define BTM_BLE_STATE_HI_DUTY_DIR_ADV 6
|
||||
#define BTM_BLE_STATE_NON_CONN_ADV 7
|
||||
#define BTM_BLE_STATE_PASSIVE_SCAN 8
|
||||
#define BTM_BLE_STATE_ACTIVE_SCAN 9
|
||||
#define BTM_BLE_STATE_SCAN_ADV 10
|
||||
#define BTM_BLE_STATE_MAX 11
|
||||
typedef UINT8 tBTM_BLE_STATE;
|
||||
|
||||
#define BTM_BLE_STATE_CONN_ADV_BIT 0x0001
|
||||
#define BTM_BLE_STATE_INIT_BIT 0x0002
|
||||
#define BTM_BLE_STATE_MASTER_BIT 0x0004
|
||||
#define BTM_BLE_STATE_SLAVE_BIT 0x0008
|
||||
#define BTM_BLE_STATE_LO_DUTY_DIR_ADV_BIT 0x0010
|
||||
#define BTM_BLE_STATE_HI_DUTY_DIR_ADV_BIT 0x0020
|
||||
#define BTM_BLE_STATE_NON_CONN_ADV_BIT 0x0040
|
||||
#define BTM_BLE_STATE_PASSIVE_SCAN_BIT 0x0080
|
||||
#define BTM_BLE_STATE_ACTIVE_SCAN_BIT 0x0100
|
||||
#define BTM_BLE_STATE_SCAN_ADV_BIT 0x0200
|
||||
typedef UINT16 tBTM_BLE_STATE_MASK;
|
||||
|
||||
#define BTM_BLE_STATE_ALL_MASK 0x03ff
|
||||
#define BTM_BLE_STATE_ALL_ADV_MASK (BTM_BLE_STATE_CONN_ADV_BIT|BTM_BLE_STATE_LO_DUTY_DIR_ADV_BIT|BTM_BLE_STATE_HI_DUTY_DIR_ADV_BIT|BTM_BLE_STATE_SCAN_ADV_BIT)
|
||||
#define BTM_BLE_STATE_ALL_SCAN_MASK (BTM_BLE_STATE_PASSIVE_SCAN_BIT|BTM_BLE_STATE_ACTIVE_SCAN_BIT)
|
||||
#define BTM_BLE_STATE_ALL_CONN_MASK (BTM_BLE_STATE_MASTER_BIT|BTM_BLE_STATE_SLAVE_BIT)
|
||||
|
||||
#ifndef BTM_LE_RESOLVING_LIST_MAX
|
||||
#define BTM_LE_RESOLVING_LIST_MAX 0x20
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
BD_ADDR *resolve_q_random_pseudo;
|
||||
UINT8 *resolve_q_action;
|
||||
UINT8 q_next;
|
||||
UINT8 q_pending;
|
||||
} tBTM_BLE_RESOLVE_Q;
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN to_add;
|
||||
BD_ADDR bd_addr;
|
||||
UINT8 attr;
|
||||
} tBTM_BLE_WL_OP;
|
||||
|
||||
/* BLE privacy mode */
|
||||
#define BTM_PRIVACY_NONE 0 /* BLE no privacy */
|
||||
#define BTM_PRIVACY_1_1 1 /* BLE privacy 1.1, do not support privacy 1.0 */
|
||||
#define BTM_PRIVACY_1_2 2 /* BLE privacy 1.2 */
|
||||
#define BTM_PRIVACY_MIXED 3 /* BLE privacy mixed mode, broadcom propietary mode */
|
||||
typedef UINT8 tBTM_PRIVACY_MODE;
|
||||
|
||||
/* data length change event callback */
|
||||
typedef void (tBTM_DATA_LENGTH_CHANGE_CBACK) (UINT16 max_tx_length, UINT16 max_rx_length);
|
||||
|
||||
/* Define BLE Device Management control structure
|
||||
*/
|
||||
typedef struct {
|
||||
UINT8 scan_activity; /* LE scan activity mask */
|
||||
|
||||
/*****************************************************
|
||||
** BLE Inquiry
|
||||
*****************************************************/
|
||||
tBTM_BLE_INQ_CB inq_var;
|
||||
|
||||
/* observer callback and timer */
|
||||
tBTM_INQ_RESULTS_CB *p_obs_results_cb;
|
||||
tBTM_CMPL_CB *p_obs_cmpl_cb;
|
||||
TIMER_LIST_ENT obs_timer_ent;
|
||||
|
||||
/* background connection procedure cb value */
|
||||
tBTM_BLE_CONN_TYPE bg_conn_type;
|
||||
UINT32 scan_int;
|
||||
UINT32 scan_win;
|
||||
tBTM_BLE_SEL_CBACK *p_select_cback;
|
||||
|
||||
/* white list information */
|
||||
UINT8 white_list_avail_size;
|
||||
tBTM_BLE_WL_STATE wl_state;
|
||||
|
||||
BUFFER_Q conn_pending_q;
|
||||
tBTM_BLE_CONN_ST conn_state;
|
||||
|
||||
/* random address management control block */
|
||||
tBTM_LE_RANDOM_CB addr_mgnt_cb;
|
||||
|
||||
BOOLEAN enabled;
|
||||
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
BOOLEAN mixed_mode; /* privacy 1.2 mixed mode is on or not */
|
||||
tBTM_PRIVACY_MODE privacy_mode; /* privacy mode */
|
||||
UINT8 resolving_list_avail_size; /* resolving list available size */
|
||||
tBTM_BLE_RESOLVE_Q resolving_list_pend_q; /* Resolving list queue */
|
||||
tBTM_BLE_RL_STATE suspended_rl_state; /* Suspended resolving list state */
|
||||
UINT8 *irk_list_mask; /* IRK list availability mask, up to max entry bits */
|
||||
tBTM_BLE_RL_STATE rl_state; /* Resolving list state */
|
||||
#endif
|
||||
|
||||
tBTM_BLE_WL_OP wl_op_q[BTM_BLE_MAX_BG_CONN_DEV_NUM];
|
||||
|
||||
/* current BLE link state */
|
||||
tBTM_BLE_STATE_MASK cur_states; /* bit mask of tBTM_BLE_STATE */
|
||||
UINT8 link_count[2]; /* total link count master and slave*/
|
||||
} tBTM_BLE_CB;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void btm_ble_timeout(TIMER_LIST_ENT *p_tle);
|
||||
void btm_ble_process_adv_pkt (UINT8 *p);
|
||||
void btm_ble_proc_scan_rsp_rpt (UINT8 *p);
|
||||
tBTM_STATUS btm_ble_read_remote_name(BD_ADDR remote_bda, tBTM_INQ_INFO *p_cur, tBTM_CMPL_CB *p_cb);
|
||||
BOOLEAN btm_ble_cancel_remote_name(BD_ADDR remote_bda);
|
||||
|
||||
tBTM_STATUS btm_ble_set_discoverability(UINT16 combined_mode);
|
||||
tBTM_STATUS btm_ble_set_connectability(UINT16 combined_mode);
|
||||
tBTM_STATUS btm_ble_start_inquiry (UINT8 mode, UINT8 duration);
|
||||
void btm_ble_stop_scan(void);
|
||||
void btm_clear_all_pending_le_entry(void);
|
||||
|
||||
void btm_ble_stop_scan();
|
||||
BOOLEAN btm_ble_send_extended_scan_params(UINT8 scan_type, UINT32 scan_int,
|
||||
UINT32 scan_win, UINT8 addr_type_own,
|
||||
UINT8 scan_filter_policy);
|
||||
void btm_ble_stop_inquiry(void);
|
||||
void btm_ble_init (void);
|
||||
void btm_ble_connected (UINT8 *bda, UINT16 handle, UINT8 enc_mode, UINT8 role, tBLE_ADDR_TYPE addr_type, BOOLEAN addr_matched);
|
||||
void btm_ble_read_remote_features_complete(UINT8 *p);
|
||||
void btm_ble_write_adv_enable_complete(UINT8 *p);
|
||||
void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced);
|
||||
void btm_read_ble_local_supported_states_complete(UINT8 *p, UINT16 evt_len);
|
||||
tBTM_BLE_CONN_ST btm_ble_get_conn_st(void);
|
||||
void btm_ble_set_conn_st(tBTM_BLE_CONN_ST new_st);
|
||||
UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst,
|
||||
tBTM_BLE_ADV_DATA *p_data);
|
||||
tBTM_STATUS btm_ble_start_adv(void);
|
||||
tBTM_STATUS btm_ble_stop_adv(void);
|
||||
tBTM_STATUS btm_ble_start_scan(void);
|
||||
void btm_ble_create_ll_conn_complete (UINT8 status);
|
||||
|
||||
/* LE security function from btm_sec.c */
|
||||
#if SMP_INCLUDED == TRUE
|
||||
void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE_SEC_REQ_ACT *p_sec_req_act);
|
||||
void btm_ble_ltk_request_reply(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk);
|
||||
UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data);
|
||||
tBTM_STATUS btm_ble_set_encryption (BD_ADDR bd_addr, void *p_ref_data, UINT8 link_role);
|
||||
void btm_ble_ltk_request(UINT16 handle, UINT8 rand[8], UINT16 ediv);
|
||||
tBTM_STATUS btm_ble_start_encrypt(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk);
|
||||
void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable);
|
||||
#endif
|
||||
|
||||
/* LE device management functions */
|
||||
void btm_ble_reset_id( void );
|
||||
|
||||
/* security related functions */
|
||||
void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local );
|
||||
BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div);
|
||||
BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types);
|
||||
|
||||
void btm_ble_test_command_complete(UINT8 *p);
|
||||
void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_enc_cplt_cback);
|
||||
|
||||
void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY_VALUE *p_keys, BOOLEAN pass_to_application);
|
||||
void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size);
|
||||
UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr);
|
||||
|
||||
/* white list function */
|
||||
BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr);
|
||||
void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy);
|
||||
void btm_update_adv_filter_policy(tBTM_BLE_AFP adv_policy);
|
||||
void btm_ble_clear_white_list (void);
|
||||
void btm_read_white_list_size_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_add_2_white_list_complete(UINT8 status);
|
||||
void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_clear_white_list_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_white_list_init(UINT8 white_list_size);
|
||||
|
||||
/* background connection function */
|
||||
BOOLEAN btm_ble_suspend_bg_conn(void);
|
||||
BOOLEAN btm_ble_resume_bg_conn(void);
|
||||
void btm_ble_initiate_select_conn(BD_ADDR bda);
|
||||
BOOLEAN btm_ble_start_auto_conn(BOOLEAN start);
|
||||
BOOLEAN btm_ble_start_select_conn(BOOLEAN start, tBTM_BLE_SEL_CBACK *p_select_cback);
|
||||
BOOLEAN btm_ble_renew_bg_conn_params(BOOLEAN add, BD_ADDR bd_addr);
|
||||
void btm_write_dir_conn_wl(BD_ADDR target_addr);
|
||||
void btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bda, UINT8 status);
|
||||
BOOLEAN btm_execute_wl_dev_operation(void);
|
||||
void btm_ble_update_link_topology_mask(UINT8 role, BOOLEAN increase);
|
||||
|
||||
/* direct connection utility */
|
||||
BOOLEAN btm_send_pending_direct_conn(void);
|
||||
void btm_ble_enqueue_direct_conn_req(void *p_param);
|
||||
|
||||
/* BLE address management */
|
||||
void btm_gen_resolvable_private_addr (void *p_cmd_cplt_cback);
|
||||
void btm_gen_non_resolvable_private_addr (tBTM_BLE_ADDR_CBACK *p_cback, void *p);
|
||||
void btm_ble_resolve_random_addr(BD_ADDR random_bda, tBTM_BLE_RESOLVE_CBACK *p_cback, void *p);
|
||||
void btm_gen_resolve_paddr_low(tBTM_RAND_ENC *p);
|
||||
|
||||
/* privacy function */
|
||||
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
|
||||
/* BLE address mapping with CS feature */
|
||||
BOOLEAN btm_identity_addr_to_random_pseudo(BD_ADDR bd_addr, UINT8 *p_addr_type, BOOLEAN refresh);
|
||||
BOOLEAN btm_random_pseudo_to_identity_addr(BD_ADDR random_pseudo, UINT8 *p_static_addr_type);
|
||||
void btm_ble_refresh_peer_resolvable_private_addr(BD_ADDR pseudo_bda, BD_ADDR rra, UINT8 rra_type);
|
||||
void btm_ble_refresh_local_resolvable_private_addr(BD_ADDR pseudo_addr, BD_ADDR local_rpa);
|
||||
void btm_ble_read_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len) ;
|
||||
void btm_ble_remove_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_add_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_clear_resolving_list_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_read_ble_resolving_list_size_complete (UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_enable_resolving_list(UINT8);
|
||||
BOOLEAN btm_ble_disable_resolving_list(UINT8 rl_mask, BOOLEAN to_resume);
|
||||
void btm_ble_enable_resolving_list_for_platform (UINT8 rl_mask);
|
||||
void btm_ble_resolving_list_init(UINT8 max_irk_list_sz);
|
||||
void btm_ble_resolving_list_cleanup(void);
|
||||
#endif
|
||||
|
||||
void btm_ble_multi_adv_configure_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst);
|
||||
void btm_ble_multi_adv_init(void);
|
||||
void *btm_ble_multi_adv_get_ref(UINT8 inst_id);
|
||||
void btm_ble_multi_adv_cleanup(void);
|
||||
void btm_ble_multi_adv_reenable(UINT8 inst_id);
|
||||
void btm_ble_multi_adv_enb_privacy(BOOLEAN enable);
|
||||
char btm_ble_map_adv_tx_power(int tx_power_index);
|
||||
void btm_ble_batchscan_init(void);
|
||||
void btm_ble_batchscan_cleanup(void);
|
||||
void btm_ble_adv_filter_init(void);
|
||||
void btm_ble_adv_filter_cleanup(void);
|
||||
BOOLEAN btm_ble_topology_check(tBTM_BLE_STATE_MASK request);
|
||||
BOOLEAN btm_ble_clear_topology_mask(tBTM_BLE_STATE_MASK request_state);
|
||||
BOOLEAN btm_ble_set_topology_mask(tBTM_BLE_STATE_MASK request_state);
|
||||
|
||||
#if BTM_BLE_CONFORMANCE_TESTING == TRUE
|
||||
void btm_ble_set_no_disc_if_pair_fail (BOOLEAN disble_disc);
|
||||
void btm_ble_set_test_mac_value (BOOLEAN enable, UINT8 *p_test_mac_val);
|
||||
void btm_ble_set_test_local_sign_cntr_value(BOOLEAN enable, UINT32 test_local_sign_cntr);
|
||||
void btm_set_random_address(BD_ADDR random_bda);
|
||||
void btm_ble_set_keep_rfu_in_auth_req(BOOLEAN keep_rfu);
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
#endif
|
1094
tools/sdk/include/bluedroid/btm_int.h
Normal file
1094
tools/sdk/include/bluedroid/btm_int.h
Normal file
File diff suppressed because it is too large
Load Diff
280
tools/sdk/include/bluedroid/btu.h
Normal file
280
tools/sdk/include/bluedroid/btu.h
Normal file
@ -0,0 +1,280 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-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 the main Bluetooth Upper Layer definitions. The Broadcom
|
||||
* implementations of L2CAP RFCOMM, SDP and the BTIf run as one GKI task. The
|
||||
* btu_task switches between them.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BTU_H
|
||||
#define BTU_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
|
||||
// HACK(zachoverflow): temporary dark magic
|
||||
#define BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK 0x1700 // didn't look used in bt_types...here goes nothing
|
||||
typedef struct {
|
||||
void (*callback)(BT_HDR *);
|
||||
} post_to_task_hack_t;
|
||||
|
||||
typedef struct {
|
||||
void (*callback)(BT_HDR *);
|
||||
BT_HDR *response;
|
||||
void *context;
|
||||
} command_complete_hack_t;
|
||||
|
||||
typedef struct {
|
||||
void (*callback)(BT_HDR *);
|
||||
uint8_t status;
|
||||
BT_HDR *command;
|
||||
void *context;
|
||||
} command_status_hack_t;
|
||||
|
||||
/* callbacks
|
||||
*/
|
||||
typedef void (*tBTU_TIMER_CALLBACK)(TIMER_LIST_ENT *p_tle);
|
||||
typedef void (*tBTU_EVENT_CALLBACK)(BT_HDR *p_hdr);
|
||||
|
||||
|
||||
/* Define the timer types maintained by BTU
|
||||
*/
|
||||
#define BTU_TTYPE_BTM_DEV_CTL 1
|
||||
#define BTU_TTYPE_L2CAP_LINK 2
|
||||
#define BTU_TTYPE_L2CAP_CHNL 3
|
||||
#define BTU_TTYPE_L2CAP_HOLD 4
|
||||
#define BTU_TTYPE_SDP 5
|
||||
#define BTU_TTYPE_BTM_SCO 6
|
||||
#define BTU_TTYPE_BTM_ACL 9
|
||||
#define BTU_TTYPE_BTM_RMT_NAME 10
|
||||
#define BTU_TTYPE_RFCOMM_MFC 11
|
||||
#define BTU_TTYPE_RFCOMM_PORT 12
|
||||
#define BTU_TTYPE_TCS_L2CAP 13
|
||||
#define BTU_TTYPE_TCS_CALL 14
|
||||
#define BTU_TTYPE_TCS_WUG 15
|
||||
#define BTU_TTYPE_AUTO_SYNC 16
|
||||
#define BTU_TTYPE_CTP_RECON 17
|
||||
#define BTU_TTYPE_CTP_T100 18
|
||||
#define BTU_TTYPE_CTP_GUARD 19
|
||||
#define BTU_TTYPE_CTP_DETACH 20
|
||||
|
||||
#define BTU_TTYPE_SPP_CONN_RETRY 21
|
||||
#define BTU_TTYPE_USER_FUNC 22
|
||||
|
||||
#define BTU_TTYPE_FTP_DISC 25
|
||||
#define BTU_TTYPE_OPP_DISC 26
|
||||
|
||||
#define BTU_TTYPE_CTP_TL_DISCVY 28
|
||||
#define BTU_TTYPE_IPFRAG_TIMER 29
|
||||
#define BTU_TTYPE_HSP2_AT_CMD_TO 30
|
||||
#define BTU_TTYPE_HSP2_REPEAT_RING 31
|
||||
|
||||
#define BTU_TTYPE_CTP_GW_INIT 32
|
||||
#define BTU_TTYPE_CTP_GW_CONN 33
|
||||
#define BTU_TTYPE_CTP_GW_IDLE 35
|
||||
|
||||
#define BTU_TTYPE_ICP_L2CAP 36
|
||||
#define BTU_TTYPE_ICP_T100 37
|
||||
|
||||
#define BTU_TTYPE_HSP2_WAIT_OK 38
|
||||
|
||||
/* HCRP Timers */
|
||||
#define BTU_TTYPE_HCRP_NOTIF_REG 39
|
||||
#define BTU_TTYPE_HCRP_PROTO_RSP 40
|
||||
#define BTU_TTYPE_HCRP_CR_GRANT 41
|
||||
#define BTU_TTYPE_HCRP_CR_CHECK 42
|
||||
#define BTU_TTYPE_HCRP_W4_CLOSE 43
|
||||
|
||||
/* HCRPM Timers */
|
||||
#define BTU_TTYPE_HCRPM_NOTIF_REG 44
|
||||
#define BTU_TTYPE_HCRPM_NOTIF_KEEP 45
|
||||
#define BTU_TTYPE_HCRPM_API_RSP 46
|
||||
#define BTU_TTYPE_HCRPM_W4_OPEN 47
|
||||
#define BTU_TTYPE_HCRPM_W4_CLOSE 48
|
||||
|
||||
/* BNEP Timers */
|
||||
#define BTU_TTYPE_BNEP 50
|
||||
|
||||
#define BTU_TTYPE_HSP2_SDP_FAIL_TO 55
|
||||
#define BTU_TTYPE_HSP2_SDP_RTRY_TO 56
|
||||
|
||||
/* BTU internal */
|
||||
/* unused 60 */
|
||||
|
||||
#define BTU_TTYPE_AVDT_CCB_RET 61
|
||||
#define BTU_TTYPE_AVDT_CCB_RSP 62
|
||||
#define BTU_TTYPE_AVDT_CCB_IDLE 63
|
||||
#define BTU_TTYPE_AVDT_SCB_TC 64
|
||||
|
||||
#define BTU_TTYPE_HID_DEV_REPAGE_TO 65
|
||||
#define BTU_TTYPE_HID_HOST_REPAGE_TO 66
|
||||
|
||||
#define BTU_TTYPE_HSP2_DELAY_CKPD_RCV 67
|
||||
|
||||
#define BTU_TTYPE_SAP_TO 68
|
||||
|
||||
/* BPP Timer */
|
||||
#define BTU_TTYPE_BPP_REF_CHNL 72
|
||||
|
||||
/* LP HC idle Timer */
|
||||
#define BTU_TTYPE_LP_HC_IDLE_TO 74
|
||||
|
||||
/* Patch RAM Timer */
|
||||
#define BTU_TTYPE_PATCHRAM_TO 75
|
||||
|
||||
/* eL2CAP Info Request and other proto cmds timer */
|
||||
#define BTU_TTYPE_L2CAP_FCR_ACK 78
|
||||
#define BTU_TTYPE_L2CAP_INFO 79
|
||||
|
||||
#define BTU_TTYPE_MCA_CCB_RSP 98
|
||||
|
||||
/* BTU internal timer for BLE activity */
|
||||
#define BTU_TTYPE_BLE_INQUIRY 99
|
||||
#define BTU_TTYPE_BLE_GAP_LIM_DISC 100
|
||||
#define BTU_TTYPE_ATT_WAIT_FOR_RSP 101
|
||||
#define BTU_TTYPE_SMP_PAIRING_CMD 102
|
||||
#define BTU_TTYPE_BLE_RANDOM_ADDR 103
|
||||
#define BTU_TTYPE_ATT_WAIT_FOR_APP_RSP 104
|
||||
#define BTU_TTYPE_ATT_WAIT_FOR_IND_ACK 105
|
||||
|
||||
#define BTU_TTYPE_BLE_GAP_FAST_ADV 106
|
||||
#define BTU_TTYPE_BLE_OBSERVE 107
|
||||
|
||||
|
||||
#define BTU_TTYPE_UCD_TO 108
|
||||
|
||||
/* This is the inquiry response information held by BTU, and available
|
||||
** to applications.
|
||||
*/
|
||||
typedef struct {
|
||||
BD_ADDR remote_bd_addr;
|
||||
UINT8 page_scan_rep_mode;
|
||||
UINT8 page_scan_per_mode;
|
||||
UINT8 page_scan_mode;
|
||||
DEV_CLASS dev_class;
|
||||
UINT16 clock_offset;
|
||||
} tBTU_INQ_INFO;
|
||||
|
||||
|
||||
|
||||
#define BTU_MAX_REG_TIMER (2) /* max # timer callbacks which may register */
|
||||
#define BTU_MAX_REG_EVENT (6) /* max # event callbacks which may register */
|
||||
#define BTU_DEFAULT_DATA_SIZE (0x2a0)
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
#define BTU_DEFAULT_BLE_DATA_SIZE (27)
|
||||
#endif
|
||||
|
||||
/* structure to hold registered timers */
|
||||
typedef struct {
|
||||
TIMER_LIST_ENT *p_tle; /* timer entry */
|
||||
tBTU_TIMER_CALLBACK timer_cb; /* callback triggered when timer expires */
|
||||
} tBTU_TIMER_REG;
|
||||
|
||||
/* structure to hold registered event callbacks */
|
||||
typedef struct {
|
||||
UINT16 event_range; /* start of event range */
|
||||
tBTU_EVENT_CALLBACK event_cb; /* callback triggered when event is in range */
|
||||
} tBTU_EVENT_REG;
|
||||
|
||||
#define NFC_MAX_LOCAL_CTRLS 0
|
||||
|
||||
/* the index to BTU command queue array */
|
||||
#define NFC_CONTROLLER_ID (1)
|
||||
#define BTU_MAX_LOCAL_CTRLS (1 + NFC_MAX_LOCAL_CTRLS) /* only BR/EDR */
|
||||
|
||||
/* Define structure holding BTU variables
|
||||
*/
|
||||
typedef struct {
|
||||
tBTU_TIMER_REG timer_reg[BTU_MAX_REG_TIMER];
|
||||
tBTU_EVENT_REG event_reg[BTU_MAX_REG_EVENT];
|
||||
|
||||
BOOLEAN reset_complete; /* TRUE after first ack from device received */
|
||||
UINT8 trace_level; /* Trace level for HCI layer */
|
||||
} tBTU_CB;
|
||||
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
*/
|
||||
/* Global BTU data */
|
||||
#if BTU_DYNAMIC_MEMORY == FALSE
|
||||
extern tBTU_CB btu_cb;
|
||||
#else
|
||||
extern tBTU_CB *btu_cb_ptr;
|
||||
#define btu_cb (*btu_cb_ptr)
|
||||
#endif
|
||||
|
||||
extern const BD_ADDR BT_BD_ANY;
|
||||
|
||||
/* Functions provided by btu_task.c
|
||||
************************************
|
||||
*/
|
||||
void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
|
||||
void btu_stop_timer (TIMER_LIST_ENT *p_tle);
|
||||
void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
|
||||
void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle);
|
||||
|
||||
void btu_uipc_rx_cback(BT_HDR *p_msg);
|
||||
|
||||
/*
|
||||
** Quick Timer
|
||||
*/
|
||||
#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_process_quick_timer_evt (void);
|
||||
#endif
|
||||
|
||||
#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
|
||||
void btu_check_bt_sleep (void);
|
||||
#endif
|
||||
|
||||
/* Functions provided by btu_hcif.c
|
||||
************************************
|
||||
*/
|
||||
void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_buf);
|
||||
void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_msg);
|
||||
void btu_hcif_send_host_rdy_for_data(void);
|
||||
void btu_hcif_cmd_timeout (UINT8 controller_id);
|
||||
|
||||
/* Functions provided by btu_core.c
|
||||
************************************
|
||||
*/
|
||||
void btu_init_core(void);
|
||||
void btu_free_core(void);
|
||||
|
||||
void BTU_StartUp(void);
|
||||
void BTU_ShutDown(void);
|
||||
|
||||
void btu_task_start_up(void);
|
||||
void btu_task_shut_down(void);
|
||||
|
||||
UINT16 BTU_BleAclPktSize(void);
|
||||
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
#endif
|
59
tools/sdk/include/bluedroid/buffer.h
Executable file
59
tools/sdk/include/bluedroid/buffer.h
Executable file
@ -0,0 +1,59 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _BUFFER_H_
|
||||
#define _BUFFER_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct buffer_t buffer_t;
|
||||
|
||||
// Returns a new buffer of |size| bytes. Returns NULL if a buffer could not be
|
||||
// allocated. |size| must be non-zero. The caller must release this buffer with
|
||||
// |buffer_free|.
|
||||
buffer_t *buffer_new(size_t size);
|
||||
|
||||
// Creates a new reference to the buffer |buf|. A reference is indistinguishable
|
||||
// from the original: writes to the original will be reflected in the reference
|
||||
// and vice versa. In other words, this function creates an alias to |buf|. The
|
||||
// caller must release the returned buffer with |buffer_free|. Note that releasing
|
||||
// the returned buffer does not release |buf|. |buf| must not be NULL.
|
||||
buffer_t *buffer_new_ref(const buffer_t *buf);
|
||||
|
||||
// Creates a new reference to the last |slice_size| bytes of |buf|. See
|
||||
// |buffer_new_ref| for a description of references. |slice_size| must be
|
||||
// greater than 0 and may be at most |buffer_length|
|
||||
// (0 < slice_size <= buffer_length). |buf| must not be NULL.
|
||||
buffer_t *buffer_new_slice(const buffer_t *buf, size_t slice_size);
|
||||
|
||||
// Frees a buffer object. |buf| may be NULL.
|
||||
void buffer_free(buffer_t *buf);
|
||||
|
||||
// Returns a pointer to a writeable memory region for |buf|. All references
|
||||
// and slices that share overlapping bytes will also be written to when
|
||||
// writing to the returned pointer. The caller may safely write up to
|
||||
// |buffer_length| consecutive bytes starting at the address returned by
|
||||
// this function. |buf| must not be NULL.
|
||||
void *buffer_ptr(const buffer_t *buf);
|
||||
|
||||
// Returns the length of the writeable memory region referred to by |buf|.
|
||||
// |buf| must not be NULL.
|
||||
size_t buffer_length(const buffer_t *buf);
|
||||
|
||||
#endif /*_BUFFER_H_*/
|
25
tools/sdk/include/bluedroid/buffer_allocator.h
Executable file
25
tools/sdk/include/bluedroid/buffer_allocator.h
Executable file
@ -0,0 +1,25 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _BUFFER_ALLOCATOR_H_
|
||||
|
||||
#include "allocator.h"
|
||||
|
||||
const allocator_t *buffer_allocator_get_interface();
|
||||
|
||||
#endif /*_BUFFER_ALLOCATOR_H_*/
|
120
tools/sdk/include/bluedroid/button_pro.h
Normal file
120
tools/sdk/include/bluedroid/button_pro.h
Normal file
@ -0,0 +1,120 @@
|
||||
#include "prf_defs.h"
|
||||
// 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.
|
||||
|
||||
|
||||
#if (BUT_PROFILE_CFG)
|
||||
#include "bt_target.h"
|
||||
#include "gatt_api.h"
|
||||
#include "gattdefs.h"
|
||||
#include "esp_gatt_api.h"
|
||||
|
||||
#define KEY_SUCCESS GATT_SUCCESS
|
||||
#define KEY_ILLEGAL_PARAM GATT_ILLEGAL_PARAMETER
|
||||
#define KEY_NO_RESOURCES GATT_NO_RESOURCES
|
||||
|
||||
//define the key serivce uuid
|
||||
#define ATT_SVC_BUTTON 0xFFFF
|
||||
//define the key Char uuid
|
||||
#define ATT_CHAR_BUTTON_WIT 0xFF01
|
||||
#define ATT_CHAR_BUTTON_NTF 0xFF02
|
||||
|
||||
#define BUTTON_PRESS_NTF_CFG 0x01
|
||||
|
||||
#define BUTTON_VAL_MAX_LEN (10)
|
||||
|
||||
#define BUTT_MAX_APPS GATT_CL_MAX_LCB
|
||||
|
||||
#define BUT_MAX_STRING_DATA 7
|
||||
|
||||
typedef void (*but_prf_cb_t)(uint8_t app_id, uint8_t event, uint16_t len, uint8_t *value);
|
||||
|
||||
#ifndef BUT_MAX_INT_NUM
|
||||
#define BUT_MAX_INT_NUM 4
|
||||
#endif
|
||||
|
||||
enum {
|
||||
RECEIVE_NET_PASSWD_EVT,
|
||||
RECEIVE_NET_SSD_EVT,
|
||||
RECEIVE_EVT_MAX
|
||||
};
|
||||
|
||||
/// button Service Attributes Indexes
|
||||
enum {
|
||||
KEY_IDX_SVC,
|
||||
KEY_IDX_BUTTON_WIT_CHAR,
|
||||
KEY_IDX_BUTTON_WIT_VAL,
|
||||
KEY_IDX_BUTTON_NTF_CHAR,
|
||||
KEY_IDX_BUTTON_NTF_VAL,
|
||||
KEY_IDX_BUTTON_NTF_CFG,
|
||||
|
||||
KEY_IDX_NB,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
BD_ADDR remote_bda;
|
||||
BOOLEAN need_rsp;
|
||||
uint16_t clt_cfg;
|
||||
} but_write_data_t;
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN congest;
|
||||
uint16_t conn_id;
|
||||
BOOLEAN connected;
|
||||
BD_ADDR remote_bda;
|
||||
uint32_t trans_id;
|
||||
uint8_t cur_srvc_id;
|
||||
|
||||
} but_clcb_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t app_id;
|
||||
uint16_t but_wirt_hdl;
|
||||
uint16_t but_ntf_hdl;
|
||||
uint16_t but_cfg_hdl;
|
||||
|
||||
but_prf_cb_t p_cback;
|
||||
|
||||
} but_inst_t;
|
||||
|
||||
|
||||
/* service engine control block */
|
||||
typedef struct {
|
||||
but_clcb_t clcb; /* connection link*/
|
||||
esp_gatt_if_t gatt_if;
|
||||
BOOLEAN enabled;
|
||||
BOOLEAN is_primery;
|
||||
but_inst_t button_inst;
|
||||
uint8_t inst_id;
|
||||
} button_env_cb_t;
|
||||
|
||||
void Button_CreateService(void);
|
||||
|
||||
but_clcb_t *button_env_clcb_alloc(uint16_t conn_id, BD_ADDR bda);
|
||||
|
||||
uint16_t button_env_find_conn_id_by_bd_adddr(BD_ADDR bda);
|
||||
|
||||
BOOLEAN button_env_clcb_dealloc(uint16_t conn_id);
|
||||
|
||||
esp_gatt_status_t button_init(but_prf_cb_t call_back);
|
||||
|
||||
void button_disable(uint16_t connid);
|
||||
|
||||
void button_msg_notify(uint16_t len, uint8_t *button_msg);
|
||||
|
||||
extern button_env_cb_t button_cb_env;
|
||||
|
||||
#endif ///BUT_PROFILE_CFG
|
85
tools/sdk/include/bluedroid/controller.h
Normal file
85
tools/sdk/include/bluedroid/controller.h
Normal file
@ -0,0 +1,85 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _CONTROLLER_H_
|
||||
#define _CONTROLLER_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "bdaddr.h"
|
||||
#include "device_features.h"
|
||||
#include "hci_layer.h"
|
||||
#include "hci_packet_factory.h"
|
||||
#include "hci_packet_parser.h"
|
||||
|
||||
typedef struct controller_t {
|
||||
void (*start_up)(void);
|
||||
void (*shut_down)(void);
|
||||
bool (*get_is_ready)(void);
|
||||
|
||||
const bt_bdaddr_t *(*get_address)(void);
|
||||
const bt_version_t *(*get_bt_version)(void);
|
||||
|
||||
const bt_device_features_t *(*get_features_classic)(int index);
|
||||
|
||||
uint8_t (*get_last_features_classic_index)(void);
|
||||
|
||||
const bt_device_features_t *(*get_features_ble)(void);
|
||||
const uint8_t *(*get_ble_supported_states)(void);
|
||||
|
||||
bool (*supports_simple_pairing)(void);
|
||||
bool (*supports_secure_connections)(void);
|
||||
bool (*supports_simultaneous_le_bredr)(void);
|
||||
bool (*supports_reading_remote_extended_features)(void);
|
||||
bool (*supports_interlaced_inquiry_scan)(void);
|
||||
bool (*supports_rssi_with_inquiry_results)(void);
|
||||
bool (*supports_extended_inquiry_response)(void);
|
||||
bool (*supports_master_slave_role_switch)(void);
|
||||
|
||||
bool (*supports_ble)(void);
|
||||
bool (*supports_ble_packet_extension)(void);
|
||||
bool (*supports_ble_connection_parameters_request)(void);
|
||||
bool (*supports_ble_privacy)(void);
|
||||
|
||||
// Get the cached acl data sizes for the controller.
|
||||
uint16_t (*get_acl_data_size_classic)(void);
|
||||
uint16_t (*get_acl_data_size_ble)(void);
|
||||
|
||||
// Get the cached acl packet sizes for the controller.
|
||||
// This is a convenience function for the respective
|
||||
// acl data size + size of the acl header.
|
||||
uint16_t (*get_acl_packet_size_classic)(void);
|
||||
uint16_t (*get_acl_packet_size_ble)(void);
|
||||
|
||||
uint16_t (*get_ble_default_data_packet_length)(void);
|
||||
|
||||
// Get the number of acl packets the controller can buffer.
|
||||
uint16_t (*get_acl_buffer_count_classic)(void);
|
||||
uint8_t (*get_acl_buffer_count_ble)(void);
|
||||
|
||||
uint8_t (*get_ble_white_list_size)(void);
|
||||
|
||||
uint8_t (*get_ble_resolving_list_max_size)(void);
|
||||
void (*set_ble_resolving_list_max_size)(int resolving_list_max_size);
|
||||
} controller_t;
|
||||
|
||||
const controller_t *controller_get_interface();
|
||||
|
||||
#endif /*_CONTROLLER_H_*/
|
29
tools/sdk/include/bluedroid/device_features.h
Normal file
29
tools/sdk/include/bluedroid/device_features.h
Normal file
@ -0,0 +1,29 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _DEVICE_FEATURES_H_
|
||||
#define _DEVICE_FEATURES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Represents a page of device feature enabled/disabled bits returned
|
||||
// by the local controller. See the bluetooth spec for bit indexes.
|
||||
typedef struct {
|
||||
uint8_t as_array[8];
|
||||
} bt_device_features_t;
|
||||
|
||||
#endif /*_DEVICE_FEATURES_H_*/
|
338
tools/sdk/include/bluedroid/dis_api.h
Normal file
338
tools/sdk/include/bluedroid/dis_api.h
Normal file
@ -0,0 +1,338 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2013 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Header file for profile folder.
|
||||
**
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SRVC_DIS_API_H
|
||||
#define SRVC_DIS_API_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gatt_api.h"
|
||||
#include "gattdefs.h"
|
||||
#include "esp_gatts_api.h"
|
||||
|
||||
#define DIS_SUCCESS GATT_SUCCESS
|
||||
#define DIS_ILLEGAL_PARAM GATT_ILLEGAL_PARAMETER
|
||||
#define DIS_NO_RESOURCES GATT_NO_RESOURCES
|
||||
typedef UINT8 tDIS_STATUS;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Data structure for DIS
|
||||
*****************************************************************************/
|
||||
|
||||
#define DIS_ATTR_SYS_ID_BIT 0x0001
|
||||
#define DIS_ATTR_MODEL_NUM_BIT 0x0002
|
||||
#define DIS_ATTR_SERIAL_NUM_BIT 0x0004
|
||||
#define DIS_ATTR_FW_NUM_BIT 0x0008
|
||||
#define DIS_ATTR_HW_NUM_BIT 0x0010
|
||||
#define DIS_ATTR_SW_NUM_BIT 0x0020
|
||||
#define DIS_ATTR_MANU_NAME_BIT 0x0040
|
||||
#define DIS_ATTR_IEEE_DATA_BIT 0x0080
|
||||
#define DIS_ATTR_PNP_ID_BIT 0x0100
|
||||
typedef UINT16 tDIS_ATTR_MASK;
|
||||
|
||||
#define DIS_ATTR_ALL_MASK 0xffff
|
||||
|
||||
typedef tDIS_ATTR_MASK tDIS_ATTR_BIT ;
|
||||
|
||||
#define DIS_MAX_NUM_INC_SVR 0
|
||||
#define DIS_MAX_CHAR_NUM 9
|
||||
#define DIS_MAX_ATTR_NUM (DIS_MAX_CHAR_NUM * 2 + DIS_MAX_NUM_INC_SVR + 1)
|
||||
|
||||
#ifndef DIS_ATTR_DB_SIZE
|
||||
#define DIS_ATTR_DB_SIZE GATT_DB_MEM_SIZE(DIS_MAX_NUM_INC_SVR, DIS_MAX_CHAR_NUM, 0)
|
||||
#endif
|
||||
|
||||
#define DIS_SYSTEM_ID_SIZE 8
|
||||
#define DIS_PNP_ID_SIZE 7
|
||||
|
||||
|
||||
typedef struct {
|
||||
UINT16 uuid;
|
||||
UINT16 handle;
|
||||
} tDIS_DB_ENTRY;
|
||||
|
||||
typedef struct {
|
||||
UINT16 len;
|
||||
UINT8 *p_data;
|
||||
} tDIS_STRING;
|
||||
|
||||
typedef struct {
|
||||
UINT16 vendor_id;
|
||||
UINT16 product_id;
|
||||
UINT16 product_version;
|
||||
UINT8 vendor_id_src;
|
||||
|
||||
} tDIS_PNP_ID;
|
||||
|
||||
typedef union {
|
||||
UINT64 system_id;
|
||||
tDIS_PNP_ID pnp_id;
|
||||
tDIS_STRING data_str;
|
||||
} tDIS_ATTR;
|
||||
|
||||
#define DIS_MAX_STRING_DATA 7
|
||||
|
||||
typedef struct {
|
||||
UINT16 attr_mask;
|
||||
UINT64 system_id;
|
||||
tDIS_PNP_ID pnp_id;
|
||||
UINT8 *data_string[DIS_MAX_STRING_DATA];
|
||||
} tDIS_VALUE;
|
||||
|
||||
//typedef void (tDIS_READ_CBACK)(BD_ADDR addr, tDIS_VALUE *p_dis_value);
|
||||
|
||||
typedef struct {
|
||||
tDIS_DB_ENTRY dis_attr[DIS_MAX_CHAR_NUM];
|
||||
tDIS_VALUE dis_value;
|
||||
|
||||
// tDIS_READ_CBACK *p_read_dis_cback;
|
||||
|
||||
UINT16 service_handle;
|
||||
UINT16 max_handle;
|
||||
|
||||
bool enabled;
|
||||
|
||||
// UINT8 dis_read_uuid_idx;
|
||||
// tDIS_ATTR_MASK request_mask;
|
||||
} tDIS_CB;
|
||||
|
||||
/*****************************************************************************
|
||||
** Data structure used by Battery Service
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef BA_MAX_INT_NUM
|
||||
#define BA_MAX_INT_NUM 4
|
||||
#endif
|
||||
|
||||
#define BATTERY_LEVEL_SIZE 1
|
||||
|
||||
typedef struct {
|
||||
BD_ADDR remote_bda;
|
||||
BOOLEAN need_rsp;
|
||||
UINT16 clt_cfg;
|
||||
} tBA_WRITE_DATA;
|
||||
|
||||
#define BA_READ_CLT_CFG_REQ 1
|
||||
#define BA_READ_PRE_FMT_REQ 2
|
||||
#define BA_READ_RPT_REF_REQ 3
|
||||
#define BA_READ_LEVEL_REQ 4
|
||||
#define BA_WRITE_CLT_CFG_REQ 5
|
||||
|
||||
typedef void (tBA_CBACK)(UINT32 trans_id, UINT16 conn_id, UINT8 app_id, UINT8 event, tBA_WRITE_DATA *p_data);
|
||||
|
||||
#define BA_LEVEL_NOTIFY 0x01
|
||||
#define BA_LEVEL_PRE_FMT 0x02
|
||||
#define BA_LEVEL_RPT_REF 0x04
|
||||
typedef UINT8 tBA_LEVEL_DESCR;
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN is_pri;
|
||||
tBA_LEVEL_DESCR ba_level_descr;
|
||||
tGATT_TRANSPORT transport;
|
||||
tBA_CBACK *p_cback;
|
||||
|
||||
} tBA_REG_INFO;
|
||||
|
||||
typedef union {
|
||||
UINT8 ba_level;
|
||||
UINT16 clt_cfg;
|
||||
tGATT_CHAR_RPT_REF rpt_ref;
|
||||
tGATT_CHAR_PRES pres_fmt;
|
||||
} tBA_RSP_DATA;
|
||||
|
||||
typedef struct {
|
||||
UINT8 app_id;
|
||||
UINT16 ba_level_hdl;
|
||||
UINT16 clt_cfg_hdl;
|
||||
UINT16 rpt_ref_hdl;
|
||||
UINT16 pres_fmt_hdl;
|
||||
|
||||
tBA_CBACK *p_cback;
|
||||
|
||||
UINT16 pending_handle;
|
||||
//UINT8 pending_clcb_idx;
|
||||
UINT8 pending_evt;
|
||||
} tBA_INST;
|
||||
|
||||
typedef struct {
|
||||
tBA_INST battery_inst[BA_MAX_INT_NUM];
|
||||
UINT8 inst_id;
|
||||
bool enabled;
|
||||
} tBATTERY_CB;
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
** Service Engine API
|
||||
*****************************************************************************/
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function srvc_eng_init
|
||||
**
|
||||
** Description Initializa the GATT Service engine, register a GATT application
|
||||
** as for a central service management.
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern tGATT_STATUS srvc_eng_init (void);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** DIS Server Function
|
||||
*****************************************************************************/
|
||||
|
||||
extern bool dis_valid_handle_range(UINT16 handle);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function DIS_Init
|
||||
**
|
||||
** Description Initializa the Device Information Service Server.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void DIS_Init (tBTA_GATTS_IF gatt_if, tDIS_ATTR_MASK dis_attr_mask);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function DIS_SrUpdate
|
||||
**
|
||||
** Description Update the DIS server attribute values
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR *p_info);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function dis_AddChar
|
||||
**
|
||||
** Description add characteristic for dis
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void dis_AddChar(UINT16 service_id);
|
||||
/*******************************************************************************
|
||||
** dis_s_read_attr_value
|
||||
**
|
||||
** Process read DIS attribute request.
|
||||
*******************************************************************************/
|
||||
|
||||
extern void dis_s_read_attr_value (tGATTS_DATA *p_data, tGATT_VALUE *p_value,
|
||||
UINT32 trans_id, UINT16 conn_id);
|
||||
/*****************************************************************************
|
||||
** DIS Client Function
|
||||
*****************************************************************************/
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function DIS_ReadDISInfo
|
||||
**
|
||||
** Description Read remote device DIS information.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern BOOLEAN DIS_ReadDISInfo(BD_ADDR peer_bda, tDIS_READ_CBACK *p_cback,
|
||||
// tDIS_ATTR_MASK mask);
|
||||
|
||||
/*******************************************************************************
|
||||
** BATTERY SERVICE API
|
||||
*******************************************************************************/
|
||||
/***************************************************************
|
||||
**
|
||||
** Function bas_register
|
||||
**
|
||||
** Description register app for battery service
|
||||
**
|
||||
****************************************************************/
|
||||
extern void bas_register(void);
|
||||
/***************************************************************
|
||||
**
|
||||
** Function bas_init
|
||||
**
|
||||
** Description register battery service
|
||||
**
|
||||
****************************************************************/
|
||||
extern void bas_init(tBTA_GATTS_IF gatt_if, UINT16 app_id);
|
||||
|
||||
/***************************************************************
|
||||
**
|
||||
** Function bas_AddChar
|
||||
**
|
||||
** Description add characteristic for battery service
|
||||
**
|
||||
****************************************************************/
|
||||
extern void bas_AddChar(UINT16 service_id, tBT_UUID *char_uuid);
|
||||
/***************************************************************
|
||||
**
|
||||
** Function bas_AddCharDescr
|
||||
**
|
||||
** Description add descriptor for battery service if needed
|
||||
**
|
||||
****************************************************************/
|
||||
extern void bas_AddCharDescr(UINT16 service_id, UINT16 attr_id);
|
||||
/***************************************************************
|
||||
**
|
||||
** Function bas_service_cmpl
|
||||
**
|
||||
** Description create battery service complete
|
||||
**
|
||||
****************************************************************/
|
||||
extern void bas_service_cmpl(UINT16 service_id, tBTA_GATT_STATUS status);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function Battery_Rsp
|
||||
**
|
||||
** Description Respond to a battery service request
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void Battery_Rsp (UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
tGATT_STATUS st, UINT8 event, tBA_RSP_DATA *p_rsp);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function Battery_Notify
|
||||
**
|
||||
** Description Send battery level notification
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void Battery_Notify (UINT16 conn_id, UINT8 app_id, BD_ADDR remote_bda, UINT8 battery_level);
|
||||
|
||||
/*****************************************************************************
|
||||
** Function bas_s_read_attr_value
|
||||
**
|
||||
** Description it will be called when client send a read request
|
||||
******************************************************************************/
|
||||
extern void bas_s_read_attr_value(tGATTS_DATA *p_data, UINT32 trans_id, UINT16 conn_id);
|
||||
/*****************************************************************************
|
||||
** Function bas_s_write_attr_value
|
||||
**
|
||||
** Description it will be called when client send a write request
|
||||
******************************************************************************/
|
||||
extern void bas_s_write_attr_value(tGATTS_DATA *p_data, UINT32 trans_id,
|
||||
UINT16 conn_id, BD_ADDR bd_addr);
|
||||
|
||||
extern void gatts_server_test(void);
|
||||
#ifdef __cplusplus
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
155
tools/sdk/include/bluedroid/dyn_mem.h
Executable file
155
tools/sdk/include/bluedroid/dyn_mem.h
Executable file
@ -0,0 +1,155 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef DYN_MEM_H
|
||||
#define DYN_MEM_H
|
||||
|
||||
/****************************************************************************
|
||||
** 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.
|
||||
*/
|
||||
#ifndef BTU_DYNAMIC_MEMORY
|
||||
#define BTU_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTM_DYNAMIC_MEMORY
|
||||
#define BTM_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef SDP_DYNAMIC_MEMORY
|
||||
//#define SDP_DYNAMIC_MEMORY FALSE
|
||||
#define SDP_DYNAMIC_MEMORY TRUE
|
||||
#endif
|
||||
|
||||
#ifndef L2C_DYNAMIC_MEMORY
|
||||
#define L2C_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef RFC_DYNAMIC_MEMORY
|
||||
#define RFC_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef TCS_DYNAMIC_MEMORY
|
||||
#define TCS_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BNEP_DYNAMIC_MEMORY
|
||||
#define BNEP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef AVDT_DYNAMIC_MEMORY
|
||||
#define AVDT_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef AVCT_DYNAMIC_MEMORY
|
||||
#define AVCT_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef MCA_DYNAMIC_MEMORY
|
||||
#define MCA_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef GATT_DYNAMIC_MEMORY
|
||||
#define GATT_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef SMP_DYNAMIC_MEMORY
|
||||
#define SMP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
** Define memory usage for each PROFILE component (if not defined in bdroid_buildcfg.h)
|
||||
** The default for each component is to use static memory allocations.
|
||||
*/
|
||||
#ifndef A2D_DYNAMIC_MEMORY
|
||||
#define A2D_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef VDP_DYNAMIC_MEMORY
|
||||
#define VDP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef AVRC_DYNAMIC_MEMORY
|
||||
#define AVRC_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BIP_DYNAMIC_MEMORY
|
||||
#define BIP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BPP_DYNAMIC_MEMORY
|
||||
#define BPP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef CTP_DYNAMIC_MEMORY
|
||||
#define CTP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef FTP_DYNAMIC_MEMORY
|
||||
#define FTP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HCRP_DYNAMIC_MEMORY
|
||||
#define HCRP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HFP_DYNAMIC_MEMORY
|
||||
#define HFP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HID_DYNAMIC_MEMORY
|
||||
#define HID_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HSP2_DYNAMIC_MEMORY
|
||||
#define HSP2_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef ICP_DYNAMIC_MEMORY
|
||||
#define ICP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef OPP_DYNAMIC_MEMORY
|
||||
#define OPP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef PAN_DYNAMIC_MEMORY
|
||||
#define PAN_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef SPP_DYNAMIC_MEMORY
|
||||
#define SPP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef SLIP_DYNAMIC_MEMORY
|
||||
#define SLIP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#ifndef LLCP_DYNAMIC_MEMORY
|
||||
#define LLCP_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
** Define memory usage for BTA (if not defined in bdroid_buildcfg.h)
|
||||
** The default for each component is to use static memory allocations.
|
||||
*/
|
||||
#ifndef BTA_DYNAMIC_MEMORY
|
||||
#define BTA_DYNAMIC_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#endif /* #ifdef DYN_MEM_H */
|
||||
|
360
tools/sdk/include/bluedroid/esp_blufi_api.h
Normal file
360
tools/sdk/include/bluedroid/esp_blufi_api.h
Normal file
@ -0,0 +1,360 @@
|
||||
// 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 __ESP_BLUFI_API_H__
|
||||
#define __ESP_BLUFI_API_H__
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_gatt_defs.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ESP_BLUFI_EVENT_INIT_FINISH = 0, /*<! When BLUFI init complete, this event happen */
|
||||
ESP_BLUFI_EVENT_DEINIT_FINISH, /*<! When BLUFI deinit complete, this event happen */
|
||||
ESP_BLUFI_EVENT_SET_WIFI_OPMODE, /*<! When Phone set ESP32 wifi operation mode(AP/STA/AP_STA), this event happen */
|
||||
ESP_BLUFI_EVENT_BLE_CONNECT, /*<! When Phone connect to ESP32 with BLE, this event happen */
|
||||
ESP_BLUFI_EVENT_BLE_DISCONNECT, /*<! When Phone disconnect with BLE, this event happen */
|
||||
ESP_BLUFI_EVENT_REQ_CONNECT_TO_AP, /*<! When Phone request ESP32's STA connect to AP, this event happen */
|
||||
ESP_BLUFI_EVENT_REQ_DISCONNECT_FROM_AP, /*<! When Phone request ESP32's STA disconnect from AP, this event happen */
|
||||
ESP_BLUFI_EVENT_GET_WIFI_STATUS, /*<! When Phone get ESP32 wifi status, this event happen */
|
||||
ESP_BLUFI_EVENT_DEAUTHENTICATE_STA, /*<! When Phone deauthenticate sta from SOFTAP, this event happen */
|
||||
/* recv data */
|
||||
ESP_BLUFI_EVENT_RECV_STA_BSSID, /*<! When Phone send STA BSSID to ESP32 to connect, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_STA_SSID, /*<! When Phone send STA SSID to ESP32 to connect, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_STA_PASSWD, /*<! When Phone send STA PASSWORD to ESP32 to connect, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SOFTAP_SSID, /*<! When Phone send SOFTAP SSID to ESP32 to start SOFTAP, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SOFTAP_PASSWD, /*<! When Phone send SOFTAP PASSWORD to ESP32 to start SOFTAP, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SOFTAP_MAX_CONN_NUM, /*<! When Phone send SOFTAP max connection number to ESP32 to start SOFTAP, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SOFTAP_AUTH_MODE, /*<! When Phone send SOFTAP authentication mode to ESP32 to start SOFTAP, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SOFTAP_CHANNEL, /*<! When Phone send SOFTAP channel to ESP32 to start SOFTAP, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_USERNAME, /*<! When Phone send username to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_CA_CERT, /*<! When Phone send CA certificate to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_CLIENT_CERT, /*<! When Phone send Client certificate to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SERVER_CERT, /*<! When Phone send Server certificate to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_CLIENT_PRIV_KEY, /*<! When Phone send Client Private key to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY, /*<! When Phone send Server Private key to ESP32, this event happen */
|
||||
} esp_blufi_cb_event_t;
|
||||
|
||||
/// BLUFI config status
|
||||
typedef enum {
|
||||
ESP_BLUFI_STA_CONN_SUCCESS = 0x00,
|
||||
ESP_BLUFI_STA_CONN_FAIL = 0x01,
|
||||
} esp_blufi_sta_conn_state_t;
|
||||
|
||||
/// BLUFI init status
|
||||
typedef enum {
|
||||
ESP_BLUFI_INIT_OK = 0,
|
||||
ESP_BLUFI_INIT_FAILED = 0,
|
||||
} esp_blufi_init_state_t;
|
||||
|
||||
/// BLUFI deinit status
|
||||
typedef enum {
|
||||
ESP_BLUFI_DEINIT_OK = 0,
|
||||
ESP_BLUFI_DEINIT_FAILED = 0,
|
||||
} esp_blufi_deinit_state_t;
|
||||
|
||||
/**
|
||||
* @brief BLUFI extra information structure
|
||||
*/
|
||||
typedef struct {
|
||||
//station
|
||||
uint8_t sta_bssid[6]; /*!< BSSID of station interface */
|
||||
bool sta_bssid_set; /*!< is BSSID of station interface set */
|
||||
uint8_t *sta_ssid; /*!< SSID of station interface */
|
||||
int sta_ssid_len; /*!< length of SSID of station interface */
|
||||
uint8_t *sta_passwd; /*!< password of station interface */
|
||||
int sta_passwd_len; /*!< length of password of station interface */
|
||||
uint8_t *softap_ssid; /*!< SSID of softap interface */
|
||||
int softap_ssid_len; /*!< length of SSID of softap interface */
|
||||
uint8_t *softap_passwd; /*!< password of station interface */
|
||||
int softap_passwd_len; /*!< length of password of station interface */
|
||||
uint8_t softap_authmode; /*!< authentication mode of softap interface */
|
||||
bool softap_authmode_set; /*!< is authentication mode of softap interface set */
|
||||
uint8_t softap_max_conn_num; /*!< max connection number of softap interface */
|
||||
bool softap_max_conn_num_set; /*!< is max connection number of softap interface set */
|
||||
uint8_t softap_channel; /*!< channel of softap interface */
|
||||
bool softap_channel_set; /*!< is channel of softap interface set */
|
||||
} esp_blufi_extra_info_t;
|
||||
|
||||
/**
|
||||
* @brief BLUFI callback parameters union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_BLUFI_EVENT_INIT_FINISH
|
||||
*/
|
||||
struct blufi_init_finish_evt_param {
|
||||
esp_blufi_init_state_t state; /*!< Initial status */
|
||||
} init_finish; /*!< Blufi callback param of ESP_BLUFI_EVENT_INIT_FINISH */
|
||||
|
||||
/**
|
||||
* @brief ESP_BLUFI_EVENT_DEINIT_FINISH
|
||||
*/
|
||||
struct blufi_deinit_finish_evt_param {
|
||||
esp_blufi_deinit_state_t state; /*!< De-initial status */
|
||||
} deinit_finish; /*!< Blufi callback param of ESP_BLUFI_EVENT_DEINIT_FINISH */
|
||||
|
||||
/**
|
||||
* @brief ESP_BLUFI_EVENT_SET_WIFI_MODE
|
||||
*/
|
||||
struct blufi_set_wifi_mode_evt_param {
|
||||
wifi_mode_t op_mode; /*!< Wifi operation mode */
|
||||
} wifi_mode; /*!< Blufi callback param of ESP_BLUFI_EVENT_INIT_FINISH */
|
||||
|
||||
/**
|
||||
* @brief ESP_BLUFI_EVENT_CONNECT
|
||||
*/
|
||||
struct blufi_connect_evt_param {
|
||||
esp_bd_addr_t remote_bda; /*!< Blufi Remote bluetooth device address */
|
||||
} connect; /*!< Blufi callback param of ESP_BLUFI_EVENT_CONNECT */
|
||||
|
||||
/**
|
||||
* @brief ESP_BLUFI_EVENT_DISCONNECT
|
||||
*/
|
||||
struct blufi_disconnect_evt_param {
|
||||
esp_bd_addr_t remote_bda; /*!< Blufi Remote bluetooth device address */
|
||||
} disconnect; /*!< Blufi callback param of ESP_BLUFI_EVENT_DISCONNECT */
|
||||
|
||||
/* ESP_BLUFI_EVENT_REQ_WIFI_CONNECT */ /* No callback param */
|
||||
/* ESP_BLUFI_EVENT_REQ_WIFI_DISCONNECT */ /* No callback param */
|
||||
|
||||
/**
|
||||
* @brief ESP_BLUFI_EVENT_RECV_STA_BSSID
|
||||
*/
|
||||
struct blufi_recv_sta_bssid_evt_param {
|
||||
uint8_t bssid[6]; /*!< BSSID */
|
||||
} sta_bssid; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_STA_BSSID */
|
||||
|
||||
/**
|
||||
* @brief ESP_BLUFI_EVENT_RECV_STA_SSID
|
||||
*/
|
||||
struct blufi_recv_sta_ssid_evt_param {
|
||||
uint8_t *ssid; /*!< SSID */
|
||||
int ssid_len; /*!< SSID length */
|
||||
} sta_ssid; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_STA_SSID */
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* ESP_BLUFI_EVENT_RECV_STA_PASSWD
|
||||
*/
|
||||
struct blufi_recv_sta_passwd_evt_param {
|
||||
uint8_t *passwd; /*!< Password */
|
||||
int passwd_len; /*!< Password Length */
|
||||
} sta_passwd; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_STA_PASSWD */
|
||||
|
||||
/**
|
||||
* @brief ESP_BLUFI_EVENT_RECV_SOFTAP_SSID
|
||||
*/
|
||||
struct blufi_recv_softap_ssid_evt_param {
|
||||
uint8_t *ssid; /*!< SSID */
|
||||
int ssid_len; /*!< SSID length */
|
||||
} softap_ssid; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_SOFTAP_SSID */
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* ESP_BLUFI_EVENT_RECV_SOFTAP_PASSWD
|
||||
*/
|
||||
struct blufi_recv_softap_passwd_evt_param {
|
||||
uint8_t *passwd; /*!< Password */
|
||||
int passwd_len; /*!< Password Length */
|
||||
} softap_passwd; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_SOFTAP_PASSWD */
|
||||
|
||||
/**
|
||||
* @brief ESP_BLUFI_EVENT_RECV_SOFTAP_MAX_CONN_NUM
|
||||
*/
|
||||
struct blufi_recv_softap_max_conn_num_evt_param {
|
||||
int max_conn_num; /*!< SSID */
|
||||
} softap_max_conn_num; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_SOFTAP_MAX_CONN_NUM */
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* ESP_BLUFI_EVENT_RECV_SOFTAP_AUTH_MODE
|
||||
*/
|
||||
struct blufi_recv_softap_auth_mode_evt_param {
|
||||
wifi_auth_mode_t auth_mode; /*!< Authentication mode */
|
||||
} softap_auth_mode; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_SOFTAP_AUTH_MODE */
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* ESP_BLUFI_EVENT_RECV_SOFTAP_CHANNEL
|
||||
*/
|
||||
struct blufi_recv_softap_channel_evt_param {
|
||||
uint8_t channel; /*!< Authentication mode */
|
||||
} softap_channel; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_SOFTAP_CHANNEL */
|
||||
|
||||
/**
|
||||
* @brief ESP_BLUFI_EVENT_RECV_USERNAME
|
||||
*/
|
||||
struct blufi_recv_username_evt_param {
|
||||
uint8_t *name; /*!< Username point */
|
||||
int name_len; /*!< Username length */
|
||||
} username; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_USERNAME*/
|
||||
|
||||
/**
|
||||
* @brief ESP_BLUFI_EVENT_RECV_CA_CERT
|
||||
*/
|
||||
struct blufi_recv_ca_evt_param {
|
||||
uint8_t *cert; /*!< CA certificate point */
|
||||
int cert_len; /*!< CA certificate length */
|
||||
} ca; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_CA_CERT */
|
||||
|
||||
/**
|
||||
* ESP_BLUFI_EVENT_RECV_CLIENT_CERT
|
||||
*/
|
||||
struct blufi_recv_client_cert_evt_param {
|
||||
uint8_t *cert; /*!< Client certificate point */
|
||||
int cert_len; /*!< Client certificate length */
|
||||
} client_cert; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_CLIENT_CERT */
|
||||
|
||||
/**
|
||||
* ESP_BLUFI_EVENT_RECV_SERVER_CERT
|
||||
*/
|
||||
struct blufi_recv_server_cert_evt_param {
|
||||
uint8_t *cert; /*!< Client certificate point */
|
||||
int cert_len; /*!< Client certificate length */
|
||||
} server_cert; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_SERVER_CERT */
|
||||
|
||||
/**
|
||||
* ESP_BLUFI_EVENT_RECV_CLIENT_PRIV_KEY
|
||||
*/
|
||||
struct blufi_recv_client_pkey_evt_param {
|
||||
uint8_t *pkey; /*!< Client Private Key point, if Client certificate not contain Key */
|
||||
int pkey_len; /*!< Client Private key length */
|
||||
} client_pkey; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_CLIENT_PRIV_KEY */
|
||||
/**
|
||||
* ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY
|
||||
*/
|
||||
struct blufi_recv_server_pkey_evt_param {
|
||||
uint8_t *pkey; /*!< Client Private Key point, if Client certificate not contain Key */
|
||||
int pkey_len; /*!< Client Private key length */
|
||||
} server_pkey; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY */
|
||||
|
||||
} esp_blufi_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief BLUFI event callback function type
|
||||
* @param event : Event type
|
||||
* @param param : Point to callback parameter, currently is union type
|
||||
*/
|
||||
typedef void (* esp_blufi_event_cb_t)(esp_blufi_cb_event_t event, esp_blufi_cb_param_t *param);
|
||||
|
||||
/* security function declare */
|
||||
|
||||
/**
|
||||
* @brief BLUFI negotiate data handler
|
||||
* @param data : data from phone
|
||||
* @param len : length of data from phone
|
||||
* @param output_data : data want to send to phone
|
||||
* @param output_len : length of data want to send to phone
|
||||
*/
|
||||
typedef void (*esp_blufi_negotiate_data_handler_t)(uint8_t *data, int len, uint8_t **output_data, int *output_len, bool *need_free);
|
||||
|
||||
/**
|
||||
* @brief BLUFI encrypt the data after negotiate a share key
|
||||
* @param iv8 : initial vector(8bit), normally, blufi core will input packet sequence number
|
||||
* @param crypt_data : plain text and encrypted data, the encrypt function must support autochthonous encrypt
|
||||
* @param crypt_len : length of plain text
|
||||
* @return Nonnegative number is encrypted length, if error, return negative number;
|
||||
*/
|
||||
typedef int (* esp_blufi_encrypt_func_t)(uint8_t iv8, uint8_t *crypt_data, int cyprt_len);
|
||||
|
||||
/**
|
||||
* @brief BLUFI decrypt the data after negotiate a share key
|
||||
* @param iv8 : initial vector(8bit), normally, blufi core will input packet sequence number
|
||||
* @param crypt_data : encrypted data and plain text, the encrypt function must support autochthonous decrypt
|
||||
* @param crypt_len : length of encrypted text
|
||||
* @return Nonnegative number is decrypted length, if error, return negative number;
|
||||
*/
|
||||
typedef int (* esp_blufi_decrypt_func_t)(uint8_t iv8, uint8_t *crypt_data, int crypt_len);
|
||||
|
||||
/**
|
||||
* @brief BLUFI checksum
|
||||
* @param iv8 : initial vector(8bit), normally, blufi core will input packet sequence number
|
||||
* @param data : data need to checksum
|
||||
* @param len : length of data
|
||||
*/
|
||||
typedef uint16_t (*esp_blufi_checksum_func_t)(uint8_t iv8, uint8_t *data, int len);
|
||||
|
||||
/**
|
||||
* @brief BLUFI callback functions type
|
||||
*/
|
||||
typedef struct {
|
||||
esp_blufi_event_cb_t event_cb; /*!< BLUFI event callback */
|
||||
esp_blufi_negotiate_data_handler_t negotiate_data_handler; /*!< BLUFI negotiate data function for negotiate share key */
|
||||
esp_blufi_encrypt_func_t encrypt_func; /*!< BLUFI encrypt data function with share key generated by negotiate_data_handler */
|
||||
esp_blufi_decrypt_func_t decrypt_func; /*!< BLUFI decrypt data function with share key generated by negotiate_data_handler */
|
||||
esp_blufi_checksum_func_t checksum_func; /*!< BLUFI check sum function (FCS) */
|
||||
} esp_blufi_callbacks_t;
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to receive blufi callback event
|
||||
*
|
||||
* @param[in] callbacks: callback functions
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_blufi_register_callbacks(esp_blufi_callbacks_t *callbacks);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to initialize blufi_profile
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_blufi_profile_init(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to de-initialize blufi_profile
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_blufi_profile_deinit(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to send wifi connection report
|
||||
* @param opmode : wifi opmode
|
||||
* @param sta_conn_state : station is already in connection or not
|
||||
* @param softap_conn_num : softap connection number
|
||||
* @param extra_info : extra information, such as sta_ssid, softap_ssid and etc.
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_blufi_send_wifi_conn_report(wifi_mode_t opmode, esp_blufi_sta_conn_state_t sta_conn_state, uint8_t softap_conn_num, esp_blufi_extra_info_t *extra_info);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Get BLUFI profile version
|
||||
*
|
||||
* @return Most 8bit significant is Great version, Least 8bit is Sub version
|
||||
*
|
||||
*/
|
||||
uint16_t esp_blufi_get_version(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLUFI_API_ */
|
106
tools/sdk/include/bluedroid/esp_bt_defs.h
Normal file
106
tools/sdk/include/bluedroid/esp_bt_defs.h
Normal file
@ -0,0 +1,106 @@
|
||||
// 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 __ESP_BT_DEFS_H__
|
||||
#define __ESP_BT_DEFS_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// Status Return Value
|
||||
typedef enum {
|
||||
ESP_BT_STATUS_SUCCESS = 0, /* Successful operation. */
|
||||
ESP_BT_STATUS_FAILURE = 1, /* Generic failure. */
|
||||
ESP_BT_STATUS_PENDING = 2, /* API cannot be completed right now */
|
||||
ESP_BT_STATUS_BUSY = 3,
|
||||
ESP_BT_STATUS_NO_RESOURCES = 4,
|
||||
ESP_BT_STATUS_WRONG_MODE = 5,
|
||||
} esp_bt_status_t;
|
||||
|
||||
/// Default GATT interface id
|
||||
#define ESP_DEFAULT_GATT_IF 0xff
|
||||
|
||||
/// Default BLE connection param, if the value doesn't be overwritten
|
||||
#define ESP_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
|
||||
|
||||
/// Check the param is valid or not
|
||||
#define ESP_BLE_IS_VALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == ESP_BLE_CONN_PARAM_UNDEF))
|
||||
|
||||
/// UUID type
|
||||
typedef struct {
|
||||
#define ESP_UUID_LEN_16 2
|
||||
#define ESP_UUID_LEN_32 4
|
||||
#define ESP_UUID_LEN_128 16
|
||||
uint16_t len; /*!< UUID length, 16bit, 32bit or 128bit */
|
||||
union {
|
||||
uint16_t uuid16;
|
||||
uint32_t uuid32;
|
||||
uint8_t uuid128[ESP_UUID_LEN_128];
|
||||
} uuid; /*!< UUID */
|
||||
} __attribute__((packed)) esp_bt_uuid_t;
|
||||
|
||||
/// Bluetooth device type
|
||||
typedef enum {
|
||||
ESP_BT_DEVICE_TYPE_BREDR = 0x01,
|
||||
ESP_BT_DEVICE_TYPE_BLE = 0x02,
|
||||
ESP_BT_DEVICE_TYPE_DUMO = 0x03,
|
||||
} esp_bt_dev_type_t;
|
||||
|
||||
/// Bluetooth address length
|
||||
#define ESP_BD_ADDR_LEN 6
|
||||
|
||||
/// Bluetooth device address
|
||||
typedef uint8_t esp_bd_addr_t[ESP_BD_ADDR_LEN];
|
||||
|
||||
/// Own BD address source of the device
|
||||
typedef enum {
|
||||
/// Public Address
|
||||
BD_ADDR_PUBLIC,
|
||||
/// Provided random address
|
||||
BD_ADDR_PROVIDED_RND,
|
||||
/// Provided static random address
|
||||
BD_ADDR_GEN_STATIC_RND,
|
||||
/// Generated resolvable private random address
|
||||
BD_ADDR_GEN_RSLV,
|
||||
/// Generated non-resolvable private random address
|
||||
BD_ADDR_GEN_NON_RSLV,
|
||||
/// Provided Reconnection address
|
||||
BD_ADDR_PROVIDED_RECON,
|
||||
} esp_bd_addr_type_t;
|
||||
|
||||
/// BLE device address type
|
||||
typedef enum {
|
||||
BLE_ADDR_TYPE_PUBLIC = 0x00,
|
||||
BLE_ADDR_TYPE_RANDOM = 0x01,
|
||||
BLE_ADDR_TYPE_RPA_PUBLIC = 0x02,
|
||||
BLE_ADDR_TYPE_RPA_RANDOM = 0x03,
|
||||
} esp_ble_addr_type_t;
|
||||
|
||||
/// Minimum of the application id
|
||||
#define ESP_APP_ID_MIN 0x0000
|
||||
/// Maximum of the application id
|
||||
#define ESP_APP_ID_MAX 0x7fff
|
||||
|
||||
#define ESP_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#define ESP_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_BT_DEFS_H__ */
|
38
tools/sdk/include/bluedroid/esp_bt_device.h
Normal file
38
tools/sdk/include/bluedroid/esp_bt_device.h
Normal file
@ -0,0 +1,38 @@
|
||||
// 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 __ESP_BT_DEVICE_H__
|
||||
#define __ESP_BT_DEVICE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Get bluetooth device address. Must use after "esp_bluedroid_enable".
|
||||
*
|
||||
* @return bluetooth device address (six bytes), or NULL if bluetooth stack is not enabled
|
||||
*/
|
||||
const uint8_t *esp_bt_dev_get_address(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __ESP_BT_DEVICE_H__ */
|
81
tools/sdk/include/bluedroid/esp_bt_main.h
Normal file
81
tools/sdk/include/bluedroid/esp_bt_main.h
Normal file
@ -0,0 +1,81 @@
|
||||
// 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 __ESP_BT_MAIN_H__
|
||||
#define __ESP_BT_MAIN_H__
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bluetooth stack status type, to indicate whether the bluetooth stack is ready
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BLUEDROID_STATUS_UNINITIALIZED = 0, /*!< Bluetooth not initialized */
|
||||
ESP_BLUEDROID_STATUS_INITIALIZED, /*!< Bluetooth initialized but not enabled */
|
||||
ESP_BLUEDROID_STATUS_ENABLED /*!< Bluetooth initialized and enabled */
|
||||
} esp_bluedroid_status_t;
|
||||
|
||||
/**
|
||||
* @brief Get bluetooth stack status
|
||||
*
|
||||
* @return Bluetooth stack status
|
||||
*
|
||||
*/
|
||||
esp_bluedroid_status_t esp_bluedroid_get_status(void);
|
||||
|
||||
/**
|
||||
* @brief Enable bluetooth, must after esp_bluedroid_init()
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - Other : Failed
|
||||
*/
|
||||
esp_err_t esp_bluedroid_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable bluetooth, must prior to esp_bluedroid_deinit()
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - Other : Failed
|
||||
*/
|
||||
esp_err_t esp_bluedroid_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Init and alloc the resource for bluetooth, must be prior to every bluetooth stuff
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - Other : Failed
|
||||
*/
|
||||
esp_err_t esp_bluedroid_init(void);
|
||||
|
||||
/**
|
||||
* @brief Deinit and free the resource for bluetooth, must be after every bluetooth stuff
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - Other : Failed
|
||||
*/
|
||||
esp_err_t esp_bluedroid_deinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_BT_MAIN_H__ */
|
496
tools/sdk/include/bluedroid/esp_gap_ble_api.h
Normal file
496
tools/sdk/include/bluedroid/esp_gap_ble_api.h
Normal file
@ -0,0 +1,496 @@
|
||||
// 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 __ESP_GAP_BLE_API_H__
|
||||
#define __ESP_GAP_BLE_API_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**@{
|
||||
* BLE_ADV_DATA_FLAG data flag bit definition used for advertising data flag
|
||||
*/
|
||||
#define ESP_BLE_ADV_FLAG_LIMIT_DISC (0x01 << 0)
|
||||
#define ESP_BLE_ADV_FLAG_GEN_DISC (0x01 << 1)
|
||||
#define ESP_BLE_ADV_FLAG_BREDR_NOT_SPT (0x01 << 2)
|
||||
#define ESP_BLE_ADV_FLAG_DMT_CONTROLLER_SPT (0x01 << 3)
|
||||
#define ESP_BLE_ADV_FLAG_DMT_HOST_SPT (0x01 << 4)
|
||||
#define ESP_BLE_ADV_FLAG_NON_LIMIT_DISC (0x00 )
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/// GAP BLE callback event type
|
||||
typedef enum {
|
||||
ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT = 0, /*!< When advertising data set complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT, /*!< When scan response data set complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT, /*!< When scan parameters set complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_RESULT_EVT, /*!< When one scan result ready, the event comes each time */
|
||||
ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
|
||||
} esp_gap_ble_cb_event_t;
|
||||
|
||||
/// Advertising data maximum length
|
||||
#define ESP_BLE_ADV_DATA_LEN_MAX 31
|
||||
/// Scan response data maximum length
|
||||
#define ESP_BLE_SCAN_RSP_DATA_LEN_MAX 31
|
||||
|
||||
/// The type of advertising data(not adv_type)
|
||||
typedef enum {
|
||||
ESP_BLE_AD_TYPE_FLAG = 0x01,
|
||||
ESP_BLE_AD_TYPE_16SRV_PART = 0x02,
|
||||
ESP_BLE_AD_TYPE_16SRV_CMPL = 0x03,
|
||||
ESP_BLE_AD_TYPE_32SRV_PART = 0x04,
|
||||
ESP_BLE_AD_TYPE_32SRV_CMPL = 0x05,
|
||||
ESP_BLE_AD_TYPE_128SRV_PART = 0x06,
|
||||
ESP_BLE_AD_TYPE_128SRV_CMPL = 0x07,
|
||||
ESP_BLE_AD_TYPE_NAME_SHORT = 0x08,
|
||||
ESP_BLE_AD_TYPE_NAME_CMPL = 0x09,
|
||||
ESP_BLE_AD_TYPE_TX_PWR = 0x0A,
|
||||
ESP_BLE_AD_TYPE_DEV_CLASS = 0x0D,
|
||||
ESP_BLE_AD_TYPE_SM_TK = 0x10,
|
||||
ESP_BLE_AD_TYPE_SM_OOB_FLAG = 0x11,
|
||||
ESP_BLE_AD_TYPE_INT_RANGE = 0x12,
|
||||
ESP_BLE_AD_TYPE_SOL_SRV_UUID = 0x14,
|
||||
ESP_BLE_AD_TYPE_128SOL_SRV_UUID = 0x15,
|
||||
ESP_BLE_AD_TYPE_SERVICE_DATA = 0x16,
|
||||
ESP_BLE_AD_TYPE_PUBLIC_TARGET = 0x17,
|
||||
ESP_BLE_AD_TYPE_RANDOM_TARGET = 0x18,
|
||||
ESP_BLE_AD_TYPE_APPEARANCE = 0x19,
|
||||
ESP_BLE_AD_TYPE_ADV_INT = 0x1A,
|
||||
ESP_BLE_AD_TYPE_32SOL_SRV_UUID = 0x1B,
|
||||
ESP_BLE_AD_TYPE_32SERVICE_DATA = 0x1C,
|
||||
ESP_BLE_AD_TYPE_128SERVICE_DATA = 0x1D,
|
||||
ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE = 0xFF,
|
||||
} esp_ble_adv_data_type;
|
||||
|
||||
/// Advertising mode
|
||||
typedef enum {
|
||||
ADV_TYPE_IND = 0x00,
|
||||
ADV_TYPE_DIRECT_IND_HIGH = 0x01,
|
||||
ADV_TYPE_SCAN_IND = 0x02,
|
||||
ADV_TYPE_NONCONN_IND = 0x03,
|
||||
ADV_TYPE_DIRECT_IND_LOW = 0x04,
|
||||
} esp_ble_adv_type_t;
|
||||
|
||||
/// Advertising channel mask
|
||||
typedef enum {
|
||||
ADV_CHNL_37 = 0x01,
|
||||
ADV_CHNL_38 = 0x02,
|
||||
ADV_CHNL_39 = 0x04,
|
||||
ADV_CHNL_ALL = 0x07,
|
||||
} esp_ble_adv_channel_t;
|
||||
|
||||
typedef enum {
|
||||
///Allow both scan and connection requests from anyone
|
||||
ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY = 0x00,
|
||||
///Allow both scan req from White List devices only and connection req from anyone
|
||||
ADV_FILTER_ALLOW_SCAN_WLST_CON_ANY,
|
||||
///Allow both scan req from anyone and connection req from White List devices only
|
||||
ADV_FILTER_ALLOW_SCAN_ANY_CON_WLST,
|
||||
///Allow scan and connection requests from White List devices only
|
||||
ADV_FILTER_ALLOW_SCAN_WLST_CON_WLST,
|
||||
///Enumeration end value for advertising filter policy value check
|
||||
} esp_ble_adv_filter_t;
|
||||
|
||||
/// Advertising parameters
|
||||
typedef struct {
|
||||
uint16_t adv_int_min; /*!< Minimum advertising interval for
|
||||
undirected and low duty cycle directed advertising.
|
||||
Range: 0x0020 to 0x4000 Default: N = 0x0800 (1.28 second)
|
||||
Time = N * 0.625 msec Time Range: 20 ms to 10.24 sec */
|
||||
uint16_t adv_int_max; /*!< Maximum advertising interval for
|
||||
undirected and low duty cycle directed advertising.
|
||||
Range: 0x0020 to 0x4000 Default: N = 0x0800 (1.28 second)
|
||||
Time = N * 0.625 msec Time Range: 20 ms to 10.24 sec Advertising max interval */
|
||||
esp_ble_adv_type_t adv_type; /*!< Advertising type */
|
||||
esp_ble_addr_type_t own_addr_type; /*!< Owner bluetooth device address type */
|
||||
esp_bd_addr_t peer_addr; /*!< Peer device bluetooth device address */
|
||||
esp_ble_addr_type_t peer_addr_type; /*!< Peer device bluetooth device address type */
|
||||
esp_ble_adv_channel_t channel_map; /*!< Advertising channel map */
|
||||
esp_ble_adv_filter_t adv_filter_policy; /*!< Advertising filter policy */
|
||||
} esp_ble_adv_params_t;
|
||||
|
||||
/// Advertising data content, according to "Supplement to the Bluetooth Core Specification"
|
||||
typedef struct {
|
||||
bool set_scan_rsp; /*!< Set this advertising data as scan response or not*/
|
||||
bool include_name; /*!< Advertising data include device name or not */
|
||||
bool include_txpower; /*!< Advertising data include TX power */
|
||||
int min_interval; /*!< Advertising data show advertising min interval */
|
||||
int max_interval; /*!< Advertising data show advertising max interval */
|
||||
int appearance; /*!< External appearance of device */
|
||||
uint16_t manufacturer_len; /*!< Manufacturer data length */
|
||||
uint8_t *p_manufacturer_data; /*!< Manufacturer data point */
|
||||
uint16_t service_data_len; /*!< Service data length */
|
||||
uint8_t *p_service_data; /*!< Service data point */
|
||||
uint16_t service_uuid_len; /*!< Service uuid length */
|
||||
uint8_t *p_service_uuid; /*!< Service uuid array point */
|
||||
uint8_t flag; /*!< Advertising flag of discovery mode, see BLE_ADV_DATA_FLAG detail */
|
||||
} esp_ble_adv_data_t;
|
||||
|
||||
/// Own BD address source of the device
|
||||
typedef enum {
|
||||
/// Public Address
|
||||
ESP_PUBLIC_ADDR,
|
||||
/// Provided random address
|
||||
ESP_PROVIDED_RND_ADDR,
|
||||
/// Provided static random address
|
||||
ESP_GEN_STATIC_RND_ADDR,
|
||||
/// Generated resolvable private random address
|
||||
ESP_GEN_RSLV_ADDR,
|
||||
/// Generated non-resolvable private random address
|
||||
ESP_GEN_NON_RSLV_ADDR,
|
||||
/// Provided Reconnection address
|
||||
ESP_PROVIDED_RECON_ADDR,
|
||||
} esp_ble_own_addr_src_t;
|
||||
|
||||
/// Ble scan type
|
||||
typedef enum {
|
||||
BLE_SCAN_TYPE_PASSIVE = 0x0, /*!< Passive scan */
|
||||
BLE_SCAN_TYPE_ACTIVE = 0x1, /*!< Active scan */
|
||||
} esp_ble_scan_type_t;
|
||||
|
||||
/// Ble scan filter type
|
||||
typedef enum {
|
||||
BLE_SCAN_FILTER_ALLOW_ALL = 0x0, /*!< Accept all :
|
||||
1. advertisement packets except directed advertising packets not addressed to this device (default). */
|
||||
BLE_SCAN_FILTER_ALLOW_ONLY_WLST = 0x1, /*!< Accept only :
|
||||
1. advertisement packets from devices where the advertiser’s address is in the White list.
|
||||
2. Directed advertising packets which are not addressed for this device shall be ignored. */
|
||||
BLE_SCAN_FILTER_ALLOW_UND_RPA_DIR = 0x2, /*!< Accept all :
|
||||
1. undirected advertisement packets, and
|
||||
2. directed advertising packets where the initiator address is a resolvable private address, and
|
||||
3. directed advertising packets addressed to this device. */
|
||||
BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR = 0x3, /*!< Accept all :
|
||||
1. advertisement packets from devices where the advertiser’s address is in the White list, and
|
||||
2. directed advertising packets where the initiator address is a resolvable private address, and
|
||||
3. directed advertising packets addressed to this device.*/
|
||||
} esp_ble_scan_filter_t;
|
||||
|
||||
/// Ble scan parameters
|
||||
typedef struct {
|
||||
esp_ble_scan_type_t scan_type; /*!< Scan type */
|
||||
esp_ble_addr_type_t own_addr_type; /*!< Owner address type */
|
||||
esp_ble_scan_filter_t scan_filter_policy; /*!< Scan filter policy */
|
||||
uint16_t scan_interval; /*!< Scan interval. This is defined as the time interval from
|
||||
when the Controller started its last LE scan until it begins the subsequent LE scan.
|
||||
Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms)
|
||||
Time = N * 0.625 msec
|
||||
Time Range: 2.5 msec to 10.24 seconds*/
|
||||
uint16_t scan_window; /*!< Scan window. The duration of the LE scan. LE_Scan_Window
|
||||
shall be less than or equal to LE_Scan_Interval
|
||||
Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms)
|
||||
Time = N * 0.625 msec
|
||||
Time Range: 2.5 msec to 10240 msec */
|
||||
} esp_ble_scan_params_t;
|
||||
|
||||
/// Connection update parameters
|
||||
typedef struct {
|
||||
esp_bd_addr_t bda; /*!< Bluetooth device address */
|
||||
uint16_t min_int; /*!< Min connection interval */
|
||||
uint16_t max_int; /*!< Max connection interval */
|
||||
uint16_t latency; /*!< Slave latency for the connection in number of connection events. Range: 0x0000 to 0x01F3 */
|
||||
uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80.
|
||||
Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec
|
||||
Time Range: 100 msec to 32 seconds */
|
||||
} esp_ble_conn_update_params_t;
|
||||
|
||||
/// Sub Event of ESP_GAP_BLE_SCAN_RESULT_EVT
|
||||
typedef enum {
|
||||
ESP_GAP_SEARCH_INQ_RES_EVT = 0, /*!< Inquiry result for a peer device. */
|
||||
ESP_GAP_SEARCH_INQ_CMPL_EVT = 1, /*!< Inquiry complete. */
|
||||
ESP_GAP_SEARCH_DISC_RES_EVT = 2, /*!< Discovery result for a peer device. */
|
||||
ESP_GAP_SEARCH_DISC_BLE_RES_EVT = 3, /*!< Discovery result for BLE GATT based service on a peer device. */
|
||||
ESP_GAP_SEARCH_DISC_CMPL_EVT = 4, /*!< Discovery complete. */
|
||||
ESP_GAP_SEARCH_DI_DISC_CMPL_EVT = 5, /*!< Discovery complete. */
|
||||
ESP_GAP_SEARCH_SEARCH_CANCEL_CMPL_EVT = 6, /*!< Search cancelled */
|
||||
} esp_gap_search_evt_t;
|
||||
|
||||
/**
|
||||
* @brief Ble scan result event type, to indicate the
|
||||
* result is scan response or advertising data or other
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BLE_EVT_CONN_ADV = 0x00, /*!< Connectable undirected advertising (ADV_IND) */
|
||||
ESP_BLE_EVT_CONN_DIR_ADV = 0x01, /*!< Connectable directed advertising (ADV_DIRECT_IND) */
|
||||
ESP_BLE_EVT_DISC_ADV = 0x02, /*!< Scannable undirected advertising (ADV_SCAN_IND) */
|
||||
ESP_BLE_EVT_NON_CONN_ADV = 0x03, /*!< Non connectable undirected advertising (ADV_NONCONN_IND) */
|
||||
ESP_BLE_EVT_SCAN_RSP = 0x04, /*!< Scan Response (SCAN_RSP) */
|
||||
} esp_ble_evt_type_t;
|
||||
|
||||
/**
|
||||
* @brief Gap callback parameters union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_adv_data_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set advertising data operation success status */
|
||||
} adv_data_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_scan_rsp_data_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set scan response data operation success status */
|
||||
} scan_rsp_data_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_scan_param_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set scan param operation success status */
|
||||
} scan_param_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SCAN_RESULT_EVT
|
||||
*/
|
||||
struct ble_scan_result_evt_param {
|
||||
esp_gap_search_evt_t search_evt; /*!< Search event type */
|
||||
esp_bd_addr_t bda; /*!< Bluetooth device address which has been searched */
|
||||
esp_bt_dev_type_t dev_type; /*!< Device type */
|
||||
esp_ble_addr_type_t ble_addr_type; /*!< Ble device address type */
|
||||
esp_ble_evt_type_t ble_evt_type; /*!< Ble scan result event type */
|
||||
int rssi; /*!< Searched device's RSSI */
|
||||
uint8_t ble_adv[ESP_BLE_ADV_DATA_LEN_MAX + ESP_BLE_SCAN_RSP_DATA_LEN_MAX]; /*!< Received EIR */
|
||||
int flag; /*!< Advertising data flag bit */
|
||||
int num_resps; /*!< Scan result number */
|
||||
} scan_rst; /*!< Event parameter of ESP_GAP_BLE_SCAN_RESULT_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_adv_data_raw_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set raw advertising data operation success status */
|
||||
} adv_data_raw_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_scan_rsp_data_raw_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set raw advertising data operation success status */
|
||||
} scan_rsp_data_raw_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT */
|
||||
} esp_ble_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief GAP callback function type
|
||||
* @param event : Event type
|
||||
* @param param : Point to callback parameter, currently is union type
|
||||
*/
|
||||
typedef void (* esp_gap_ble_cb_t)(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief This function is called to occur gap event, such as scan result
|
||||
*
|
||||
* @param[in] callback: callback function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to override the BTA default ADV parameters.
|
||||
*
|
||||
* @param[in] adv_data: Pointer to User defined ADV data structure. This
|
||||
* memory space can not be freed until callback of config_adv_data
|
||||
* is received.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_adv_data (esp_ble_adv_data_t *adv_data);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to set scan parameters
|
||||
*
|
||||
* @param[in] scan_params: Pointer to User defined scan_params data structure. This
|
||||
* memory space can not be freed until callback of set_scan_params
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_scan_params(esp_ble_scan_params_t *scan_params);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This procedure keep the device scanning the peer device which advertising on the air
|
||||
*
|
||||
* @param[in] duration: Keeping the scanning time, the unit is second.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_start_scanning(uint32_t duration);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function call to stop the device scanning the peer device which advertising on the air
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_stop_scanning(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to start advertising.
|
||||
*
|
||||
* @param[in] adv_params: pointer to User defined adv_params data structure.
|
||||
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_start_advertising (esp_ble_adv_params_t *adv_params);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to stop advertising.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_stop_advertising(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Update connection parameters, can only be used when connection is up.
|
||||
*
|
||||
* @param[in] params - connection update parameters
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is to set maximum LE data packet size
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_data_length);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function set the random address for the application
|
||||
*
|
||||
* @param[in] rand_addr: the random address which should be setting
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Enable/disable privacy on the local device
|
||||
*
|
||||
* @param[in] privacy_enable - enable/disable privacy on remote device.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set device name to the local device
|
||||
*
|
||||
* @param[in] name - device name.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_device_name(const char *name);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to get ADV data for a specific type.
|
||||
*
|
||||
* @param[in] adv_data - pointer of ADV data which to be resolved
|
||||
* @param[in] type - finding ADV data type
|
||||
* @param[out] length - return the length of ADV data not including type
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
uint8_t *esp_ble_resolve_adv_data(uint8_t *adv_data, uint8_t type, uint8_t *length);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set raw advertising data. User need to fill
|
||||
* ADV data by self.
|
||||
*
|
||||
* @param[in] raw_data : raw advertising data
|
||||
* @param[in] raw_data_len : raw advertising data length , less than 31 bytes
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set raw scan response data. User need to fill
|
||||
* scan response data by self.
|
||||
*
|
||||
* @param[in] raw_data : raw scan response data
|
||||
* @param[in] raw_data_len : raw scan response data length , less than 31 bytes
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_GAP_BLE_API_H__ */
|
384
tools/sdk/include/bluedroid/esp_gatt_defs.h
Normal file
384
tools/sdk/include/bluedroid/esp_gatt_defs.h
Normal file
@ -0,0 +1,384 @@
|
||||
// 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 __ESP_GATT_DEFS_H__
|
||||
#define __ESP_GATT_DEFS_H__
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// GATT INVALID UUID
|
||||
#define ESP_GATT_ILLEGAL_UUID 0
|
||||
/// GATT INVALID HANDLE
|
||||
#define ESP_GATT_ILLEGAL_HANDLE 0
|
||||
/// GATT attribute max handle
|
||||
#define ESP_GATT_ATTR_HANDLE_MAX 100
|
||||
|
||||
|
||||
/**@{
|
||||
* All "ESP_GATT_UUID_xxx" is attribute types
|
||||
*/
|
||||
#define ESP_GATT_UUID_IMMEDIATE_ALERT_SVC 0x1802 /* Immediate alert Service*/
|
||||
#define ESP_GATT_UUID_LINK_LOSS_SVC 0x1803 /* Link Loss Service*/
|
||||
#define ESP_GATT_UUID_TX_POWER_SVC 0x1804 /* TX Power Service*/
|
||||
#define ESP_GATT_UUID_CURRENT_TIME_SVC 0x1805 /* Current Time Service Service*/
|
||||
#define ESP_GATT_UUID_REF_TIME_UPDATE_SVC 0x1806 /* Reference Time Update Service*/
|
||||
#define ESP_GATT_UUID_NEXT_DST_CHANGE_SVC 0x1807 /* Next DST Change Service*/
|
||||
#define ESP_GATT_UUID_GLUCOSE_SVC 0x1808 /* Glucose Service*/
|
||||
#define ESP_GATT_UUID_HEALTH_THERMOM_SVC 0x1809 /* Health Thermometer Service*/
|
||||
#define ESP_GATT_UUID_DEVICE_INFO_SVC 0x180A /* Device Information Service*/
|
||||
#define ESP_GATT_UUID_HEART_RATE_SVC 0x180D /* Heart Rate Service*/
|
||||
#define ESP_GATT_UUID_PHONE_ALERT_STATUS_SVC 0x180E /* Phone Alert Status Service*/
|
||||
#define ESP_GATT_UUID_BATTERY_SERVICE_SVC 0x180F /* Battery Service*/
|
||||
#define ESP_GATT_UUID_BLOOD_PRESSURE_SVC 0x1810 /* Blood Pressure Service*/
|
||||
#define ESP_GATT_UUID_ALERT_NTF_SVC 0x1811 /* Alert Notification Service*/
|
||||
#define ESP_GATT_UUID_HID_SVC 0x1812 /* HID Service*/
|
||||
#define ESP_GATT_UUID_SCAN_PARAMETERS_SVC 0x1813 /* Scan Parameters Service*/
|
||||
#define ESP_GATT_UUID_RUNNING_SPEED_CADENCE_SVC 0x1814 /* Running Speed and Cadence Service*/
|
||||
#define ESP_GATT_UUID_CYCLING_SPEED_CADENCE_SVC 0x1816 /* Cycling Speed and Cadence Service*/
|
||||
#define ESP_GATT_UUID_CYCLING_POWER_SVC 0x1818 /* Cycling Power Service*/
|
||||
#define ESP_GATT_UUID_LOCATION_AND_NAVIGATION_SVC 0x1819 /* Location and Navigation Service*/
|
||||
#define ESP_GATT_UUID_USER_DATA_SVC 0x181C /* User Data Service*/
|
||||
#define ESP_GATT_UUID_WEIGHT_SCALE_SVC 0x181D /* Weight Scale Service*/
|
||||
|
||||
#define ESP_GATT_UUID_PRI_SERVICE 0x2800
|
||||
#define ESP_GATT_UUID_SEC_SERVICE 0x2801
|
||||
#define ESP_GATT_UUID_INCLUDE_SERVICE 0x2802
|
||||
#define ESP_GATT_UUID_CHAR_DECLARE 0x2803 /* Characteristic Declaration*/
|
||||
|
||||
#define ESP_GATT_UUID_CHAR_EXT_PROP 0x2900 /* Characteristic Extended Properties */
|
||||
#define ESP_GATT_UUID_CHAR_DESCRIPTION 0x2901 /* Characteristic User Description*/
|
||||
#define ESP_GATT_UUID_CHAR_CLIENT_CONFIG 0x2902 /* Client Characteristic Configuration */
|
||||
#define ESP_GATT_UUID_CHAR_SRVR_CONFIG 0x2903 /* Server Characteristic Configuration */
|
||||
#define ESP_GATT_UUID_CHAR_PRESENT_FORMAT 0x2904 /* Characteristic Presentation Format*/
|
||||
#define ESP_GATT_UUID_CHAR_AGG_FORMAT 0x2905 /* Characteristic Aggregate Format*/
|
||||
#define ESP_GATT_UUID_CHAR_VALID_RANGE 0x2906 /* Characteristic Valid Range */
|
||||
#define ESP_GATT_UUID_EXT_RPT_REF_DESCR 0x2907
|
||||
#define ESP_GATT_UUID_RPT_REF_DESCR 0x2908
|
||||
|
||||
/* GAP Profile Attributes */
|
||||
#define ESP_GATT_UUID_GAP_DEVICE_NAME 0x2A00
|
||||
#define ESP_GATT_UUID_GAP_ICON 0x2A01
|
||||
#define ESP_GATT_UUID_GAP_PREF_CONN_PARAM 0x2A04
|
||||
#define ESP_GATT_UUID_GAP_CENTRAL_ADDR_RESOL 0x2AA6
|
||||
|
||||
/* Attribute Profile Attribute UUID */
|
||||
#define ESP_GATT_UUID_GATT_SRV_CHGD 0x2A05
|
||||
|
||||
/* Link ESP_Loss Service */
|
||||
#define ESP_GATT_UUID_ALERT_LEVEL 0x2A06 /* Alert Level */
|
||||
#define ESP_GATT_UUID_TX_POWER_LEVEL 0x2A07 /* TX power level */
|
||||
|
||||
/* Current Time Service */
|
||||
#define ESP_GATT_UUID_CURRENT_TIME 0x2A2B /* Current Time */
|
||||
#define ESP_GATT_UUID_LOCAL_TIME_INFO 0x2A0F /* Local time info */
|
||||
#define ESP_GATT_UUID_REF_TIME_INFO 0x2A14 /* reference time information */
|
||||
|
||||
/* Network availability Profile */
|
||||
#define ESP_GATT_UUID_NW_STATUS 0x2A18 /* network availability status */
|
||||
#define ESP_GATT_UUID_NW_TRIGGER 0x2A1A /* Network availability trigger */
|
||||
|
||||
/* Phone alert */
|
||||
#define ESP_GATT_UUID_ALERT_STATUS 0x2A3F /* alert status */
|
||||
#define ESP_GATT_UUID_RINGER_CP 0x2A40 /* ringer control point */
|
||||
#define ESP_GATT_UUID_RINGER_SETTING 0x2A41 /* ringer setting */
|
||||
|
||||
/* Glucose Service */
|
||||
#define ESP_GATT_UUID_GM_MEASUREMENT 0x2A18
|
||||
#define ESP_GATT_UUID_GM_CONTEXT 0x2A34
|
||||
#define ESP_GATT_UUID_GM_CONTROL_POINT 0x2A52
|
||||
#define ESP_GATT_UUID_GM_FEATURE 0x2A51
|
||||
|
||||
/* device information characteristic */
|
||||
#define ESP_GATT_UUID_SYSTEM_ID 0x2A23
|
||||
#define ESP_GATT_UUID_MODEL_NUMBER_STR 0x2A24
|
||||
#define ESP_GATT_UUID_SERIAL_NUMBER_STR 0x2A25
|
||||
#define ESP_GATT_UUID_FW_VERSION_STR 0x2A26
|
||||
#define ESP_GATT_UUID_HW_VERSION_STR 0x2A27
|
||||
#define ESP_GATT_UUID_SW_VERSION_STR 0x2A28
|
||||
#define ESP_GATT_UUID_MANU_NAME 0x2A29
|
||||
#define ESP_GATT_UUID_IEEE_DATA 0x2A2A
|
||||
#define ESP_GATT_UUID_PNP_ID 0x2A50
|
||||
|
||||
/* HID characteristics */
|
||||
#define ESP_GATT_UUID_HID_INFORMATION 0x2A4A
|
||||
#define ESP_GATT_UUID_HID_REPORT_MAP 0x2A4B
|
||||
#define ESP_GATT_UUID_HID_CONTROL_POINT 0x2A4C
|
||||
#define ESP_GATT_UUID_HID_REPORT 0x2A4D
|
||||
#define ESP_GATT_UUID_HID_PROTO_MODE 0x2A4E
|
||||
#define ESP_GATT_UUID_HID_BT_KB_INPUT 0x2A22
|
||||
#define ESP_GATT_UUID_HID_BT_KB_OUTPUT 0x2A32
|
||||
#define ESP_GATT_UUID_HID_BT_MOUSE_INPUT 0x2A33
|
||||
|
||||
/// Heart Rate Measurement
|
||||
#define ESP_GATT_HEART_RATE_MEAS 0x2A37
|
||||
/// Body Sensor Location
|
||||
#define ESP_GATT_BODY_SENSOR_LOCATION 0x2A38
|
||||
/// Heart Rate Control Point
|
||||
#define ESP_GATT_HEART_RATE_CNTL_POINT 0x2A39
|
||||
|
||||
/* Battery Service characteristics */
|
||||
#define ESP_GATT_UUID_BATTERY_LEVEL 0x2A19
|
||||
|
||||
/* Sensor Service */
|
||||
#define ESP_GATT_UUID_SC_CONTROL_POINT 0x2A55
|
||||
#define ESP_GATT_UUID_SENSOR_LOCATION 0x2A5D
|
||||
|
||||
/* Runners speed and cadence service */
|
||||
#define ESP_GATT_UUID_RSC_MEASUREMENT 0x2A53
|
||||
#define ESP_GATT_UUID_RSC_FEATURE 0x2A54
|
||||
|
||||
/* Cycling speed and cadence service */
|
||||
#define ESP_GATT_UUID_CSC_MEASUREMENT 0x2A5B
|
||||
#define ESP_GATT_UUID_CSC_FEATURE 0x2A5C
|
||||
|
||||
/* Scan ESP_Parameter characteristics */
|
||||
#define ESP_GATT_UUID_SCAN_INT_WINDOW 0x2A4F
|
||||
#define ESP_GATT_UUID_SCAN_REFRESH 0x2A31
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/// Attribute write data type from the client
|
||||
typedef enum {
|
||||
ESP_GATT_PREP_WRITE_CANCEL = 0x00, /*!< Prepare write cancel */
|
||||
ESP_GATT_PREP_WRITE_EXEC = 0x01, /*!< Prepare write execute */
|
||||
} esp_gatt_prep_write_type;
|
||||
|
||||
/**
|
||||
* @brief GATT success code and error codes
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_OK = 0x0,
|
||||
ESP_GATT_INVALID_HANDLE = 0x01, /* 0x0001 */
|
||||
ESP_GATT_READ_NOT_PERMIT = 0x02, /* 0x0002 */
|
||||
ESP_GATT_WRITE_NOT_PERMIT = 0x03, /* 0x0003 */
|
||||
ESP_GATT_INVALID_PDU = 0x04, /* 0x0004 */
|
||||
ESP_GATT_INSUF_AUTHENTICATION = 0x05, /* 0x0005 */
|
||||
ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /* 0x0006 */
|
||||
ESP_GATT_INVALID_OFFSET = 0x07, /* 0x0007 */
|
||||
ESP_GATT_INSUF_AUTHORIZATION = 0x08, /* 0x0008 */
|
||||
ESP_GATT_PREPARE_Q_FULL = 0x09, /* 0x0009 */
|
||||
ESP_GATT_NOT_FOUND = 0x0a, /* 0x000a */
|
||||
ESP_GATT_NOT_LONG = 0x0b, /* 0x000b */
|
||||
ESP_GATT_INSUF_KEY_SIZE = 0x0c, /* 0x000c */
|
||||
ESP_GATT_INVALID_ATTR_LEN = 0x0d, /* 0x000d */
|
||||
ESP_GATT_ERR_UNLIKELY = 0x0e, /* 0x000e */
|
||||
ESP_GATT_INSUF_ENCRYPTION = 0x0f, /* 0x000f */
|
||||
ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /* 0x0010 */
|
||||
ESP_GATT_INSUF_RESOURCE = 0x11, /* 0x0011 */
|
||||
|
||||
ESP_GATT_NO_RESOURCES = 0x80, /* 0x80 */
|
||||
ESP_GATT_INTERNAL_ERROR = 0x81, /* 0x81 */
|
||||
ESP_GATT_WRONG_STATE = 0x82, /* 0x82 */
|
||||
ESP_GATT_DB_FULL = 0x83, /* 0x83 */
|
||||
ESP_GATT_BUSY = 0x84, /* 0x84 */
|
||||
ESP_GATT_ERROR = 0x85, /* 0x85 */
|
||||
ESP_GATT_CMD_STARTED = 0x86, /* 0x86 */
|
||||
ESP_GATT_ILLEGAL_PARAMETER = 0x87, /* 0x87 */
|
||||
ESP_GATT_PENDING = 0x88, /* 0x88 */
|
||||
ESP_GATT_AUTH_FAIL = 0x89, /* 0x89 */
|
||||
ESP_GATT_MORE = 0x8a, /* 0x8a */
|
||||
ESP_GATT_INVALID_CFG = 0x8b, /* 0x8b */
|
||||
ESP_GATT_SERVICE_STARTED = 0x8c, /* 0x8c */
|
||||
ESP_GATT_ENCRYPED_MITM = ESP_GATT_OK,
|
||||
ESP_GATT_ENCRYPED_NO_MITM = 0x8d, /* 0x8d */
|
||||
ESP_GATT_NOT_ENCRYPTED = 0x8e, /* 0x8e */
|
||||
ESP_GATT_CONGESTED = 0x8f, /* 0x8f */
|
||||
ESP_GATT_DUP_REG = 0x90, /* 0x90 */
|
||||
ESP_GATT_ALREADY_OPEN = 0x91, /* 0x91 */
|
||||
ESP_GATT_CANCEL = 0x92, /* 0x92 */
|
||||
|
||||
/* 0xE0 ~ 0xFC reserved for future use */
|
||||
ESP_GATT_CCC_CFG_ERR = 0xfd, /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
|
||||
ESP_GATT_PRC_IN_PROGRESS = 0xfe, /* 0xFE Procedure Already in progress */
|
||||
ESP_GATT_OUT_OF_RANGE = 0xff, /* 0xFFAttribute value out of range */
|
||||
} esp_gatt_status_t;
|
||||
|
||||
/**
|
||||
* @brief Gatt Connection reason enum
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_CONN_UNKNOWN = 0, /*!< Gatt connection unknown */
|
||||
ESP_GATT_CONN_L2C_FAILURE = 1, /*!< General L2cap failure */
|
||||
ESP_GATT_CONN_TIMEOUT = 0x08, /*!< Connection timeout */
|
||||
ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13, /*!< Connection terminate by peer user */
|
||||
ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16, /*!< Connectionterminated by local host */
|
||||
ESP_GATT_CONN_FAIL_ESTABLISH = 0x3e, /*!< Connection fail to establish */
|
||||
ESP_GATT_CONN_LMP_TIMEOUT = 0x22, /*!< Connection fail for LMP response tout */
|
||||
ESP_GATT_CONN_CONN_CANCEL = 0x0100, /*!< L2CAP connection cancelled */
|
||||
ESP_GATT_CONN_NONE = 0x0101 /*!< No connection to cancel */
|
||||
} esp_gatt_conn_reason_t;
|
||||
|
||||
/**
|
||||
* @brief Gatt id, include uuid and instance id
|
||||
*/
|
||||
typedef struct {
|
||||
esp_bt_uuid_t uuid; /*!< UUID */
|
||||
uint8_t inst_id; /*!< Instance id */
|
||||
} __attribute__((packed)) esp_gatt_id_t;
|
||||
|
||||
/**
|
||||
* @brief Gatt service id, include id
|
||||
* (uuid and instance id) and primary flag
|
||||
*/
|
||||
typedef struct {
|
||||
esp_gatt_id_t id; /*!< Gatt id, include uuid and instance */
|
||||
bool is_primary; /*!< This service is primary or not */
|
||||
} __attribute__((packed)) esp_gatt_srvc_id_t;
|
||||
|
||||
/**
|
||||
* @brief Gatt authentication request type
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_AUTH_REQ_NONE = 0,
|
||||
ESP_GATT_AUTH_REQ_NO_MITM = 1, /* unauthenticated encryption */
|
||||
ESP_GATT_AUTH_REQ_MITM = 2, /* authenticated encryption */
|
||||
ESP_GATT_AUTH_REQ_SIGNED_NO_MITM = 3,
|
||||
ESP_GATT_AUTH_REQ_SIGNED_MITM = 4,
|
||||
} esp_gatt_auth_req_t;
|
||||
|
||||
/**
|
||||
* @brief Attribute permissions
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_PERM_READ = (1 << 0), /* bit 0 - 0x0001 */
|
||||
ESP_GATT_PERM_READ_ENCRYPTED = (1 << 1), /* bit 1 - 0x0002 */
|
||||
ESP_GATT_PERM_READ_ENC_MITM = (1 << 2), /* bit 2 - 0x0004 */
|
||||
ESP_GATT_PERM_WRITE = (1 << 4), /* bit 4 - 0x0010 */
|
||||
ESP_GATT_PERM_WRITE_ENCRYPTED = (1 << 5), /* bit 5 - 0x0020 */
|
||||
ESP_GATT_PERM_WRITE_ENC_MITM = (1 << 6), /* bit 6 - 0x0040 */
|
||||
ESP_GATT_PERM_WRITE_SIGNED = (1 << 7), /* bit 7 - 0x0080 */
|
||||
ESP_GATT_PERM_WRITE_SIGNED_MITM = (1 << 8), /* bit 8 - 0x0100 */
|
||||
} esp_gatt_perm_t;
|
||||
|
||||
/* definition of characteristic properties */
|
||||
typedef enum {
|
||||
ESP_GATT_CHAR_PROP_BIT_BROADCAST = (1 << 0), /* 0x01 */
|
||||
ESP_GATT_CHAR_PROP_BIT_READ = (1 << 1), /* 0x02 */
|
||||
ESP_GATT_CHAR_PROP_BIT_WRITE_NR = (1 << 2), /* 0x04 */
|
||||
ESP_GATT_CHAR_PROP_BIT_WRITE = (1 << 3), /* 0x08 */
|
||||
ESP_GATT_CHAR_PROP_BIT_NOTIFY = (1 << 4), /* 0x10 */
|
||||
ESP_GATT_CHAR_PROP_BIT_INDICATE = (1 << 5), /* 0x20 */
|
||||
ESP_GATT_CHAR_PROP_BIT_AUTH = (1 << 6), /* 0x40 */
|
||||
ESP_GATT_CHAR_PROP_BIT_EXT_PROP = (1 << 7), /* 0x80 */
|
||||
} esp_gatt_char_prop_t;
|
||||
|
||||
/// GATT maximum attribute length
|
||||
#define ESP_GATT_MAX_ATTR_LEN 600 //as same as GATT_MAX_ATTR_LEN
|
||||
|
||||
|
||||
/**
|
||||
* @brief Attribute description (used to create database)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t uuid_length; /*!< UUID length */
|
||||
uint8_t *uuid_p; /*!< UUID value */
|
||||
uint16_t perm; /*!< Attribute permission */
|
||||
uint16_t max_length; /*!< Maximum length of the element*/
|
||||
uint16_t length; /*!< Current length of the element*/
|
||||
uint8_t *value; /*!< Element value array*/
|
||||
} esp_attr_desc_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief attribute auto respose flag
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
#define ESP_GATT_RSP_BY_APP 0
|
||||
#define ESP_GATT_AUTO_RSP 1
|
||||
uint8_t auto_rsp; /*!< need the app response to the client if need_rsp set to 1*/
|
||||
} esp_attr_control_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief attribute type added to the gatt server database
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_attr_control_t attr_control; /*!< The attribue control type*/
|
||||
esp_attr_desc_t att_desc; /*!< The attribue type*/
|
||||
} esp_gatts_attr_db_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief set the attribute value type
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t attr_max_len; /*!< attribute max value length */
|
||||
uint16_t attr_len; /*!< attribute current value length */
|
||||
uint8_t *attr_value; /*!< the pointer to attribute value */
|
||||
} esp_attr_value_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gatt include service entry element
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_hdl; /*!< Gatt start handle value of included service */
|
||||
uint16_t end_hdl; /*!< Gatt end handle value of included service */
|
||||
uint16_t uuid; /*!< Gatt attribute value UUID of included service */
|
||||
} esp_gatts_incl_svc_desc_t; /*!< Gatt include service entry element */
|
||||
|
||||
/**
|
||||
* @brief Gatt include 128 bit service entry element
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_hdl; /*!< Gatt start handle value of included 128 bit service */
|
||||
uint16_t end_hdl; /*!< Gatt end handle value of included 128 bit service */
|
||||
} esp_gatts_incl128_svc_desc_t; /*!< Gatt include 128 bit service entry element */
|
||||
|
||||
|
||||
|
||||
|
||||
/// Gatt attribute value
|
||||
typedef struct {
|
||||
uint8_t value[ESP_GATT_MAX_ATTR_LEN]; /*!< Gatt attribute value */
|
||||
uint16_t handle; /*!< Gatt attribute handle */
|
||||
uint16_t offset; /*!< Gatt attribute value offset */
|
||||
uint16_t len; /*!< Gatt attribute value length */
|
||||
uint8_t auth_req; /*!< Gatt authentication request */
|
||||
} esp_gatt_value_t;
|
||||
|
||||
/// GATT remote read request response type
|
||||
typedef union {
|
||||
esp_gatt_value_t attr_value; /*!< Gatt attribute structure */
|
||||
uint16_t handle; /*!< Gatt attribute handle */
|
||||
} esp_gatt_rsp_t;
|
||||
|
||||
/**
|
||||
* @brief Gatt write type
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_WRITE_TYPE_NO_RSP = 1, /*!< Gatt write attribute need no response */
|
||||
ESP_GATT_WRITE_TYPE_RSP, /*!< Gatt write attribute need remote response */
|
||||
} esp_gatt_write_type_t;
|
||||
|
||||
#define ESP_GATT_IF_NONE 0xff /*!< If callback report gattc_if/gatts_if as this macro, means this event is not correspond to any app */
|
||||
|
||||
typedef uint8_t esp_gatt_if_t; /*!< Gatt interface type, different application on GATT client use different gatt_if */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_GATT_DEFS_H__ */
|
607
tools/sdk/include/bluedroid/esp_gattc_api.h
Normal file
607
tools/sdk/include/bluedroid/esp_gattc_api.h
Normal file
@ -0,0 +1,607 @@
|
||||
// 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 __ESP_GATTC_API_H__
|
||||
#define __ESP_GATTC_API_H__
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_gatt_defs.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// GATT Client callback function events
|
||||
typedef enum {
|
||||
ESP_GATTC_REG_EVT = 0, /*!< When GATT client is registered, the event comes */
|
||||
ESP_GATTC_UNREG_EVT = 1, /*!< When GATT client is unregistered, the event comes */
|
||||
ESP_GATTC_OPEN_EVT = 2, /*!< When GATT connection is set up, the event comes */
|
||||
ESP_GATTC_READ_CHAR_EVT = 3, /*!< When GATT characteristic is read, the event comes */
|
||||
ESP_GATTC_WRITE_CHAR_EVT = 4, /*!< When GATT characteristic write operation completes, the event comes */
|
||||
ESP_GATTC_CLOSE_EVT = 5, /*!< When GATT connection is closed, the event comes */
|
||||
ESP_GATTC_SEARCH_CMPL_EVT = 6, /*!< When GATT service discovery is completed, the event comes */
|
||||
ESP_GATTC_SEARCH_RES_EVT = 7, /*!< When GATT service discovery result is got, the event comes */
|
||||
ESP_GATTC_READ_DESCR_EVT = 8, /*!< When GATT characteristic descriptor read completes, the event comes */
|
||||
ESP_GATTC_WRITE_DESCR_EVT = 9, /*!< When GATT characteristic descriptor write completes, the event comes */
|
||||
ESP_GATTC_NOTIFY_EVT = 10, /*!< When GATT notification or indication arrives, the event comes */
|
||||
ESP_GATTC_PREP_WRITE_EVT = 11, /*!< When GATT prepare-write operation completes, the event comes */
|
||||
ESP_GATTC_EXEC_EVT = 12, /*!< When write execution completes, the event comes */
|
||||
ESP_GATTC_ACL_EVT = 13, /*!< When ACL connection is up, the event comes */
|
||||
ESP_GATTC_CANCEL_OPEN_EVT = 14, /*!< When GATT client ongoing connection is cancelled, the event comes */
|
||||
ESP_GATTC_SRVC_CHG_EVT = 15, /*!< When "service changed" occurs, the event comes */
|
||||
ESP_GATTC_ENC_CMPL_CB_EVT = 17, /*!< When encryption procedure completes, the event comes */
|
||||
ESP_GATTC_CFG_MTU_EVT = 18, /*!< When configuration of MTU completes, the event comes */
|
||||
ESP_GATTC_ADV_DATA_EVT = 19, /*!< When advertising of data, the event comes */
|
||||
ESP_GATTC_MULT_ADV_ENB_EVT = 20, /*!< When multi-advertising is enabled, the event comes */
|
||||
ESP_GATTC_MULT_ADV_UPD_EVT = 21, /*!< When multi-advertising parameters are updated, the event comes */
|
||||
ESP_GATTC_MULT_ADV_DATA_EVT = 22, /*!< When multi-advertising data arrives, the event comes */
|
||||
ESP_GATTC_MULT_ADV_DIS_EVT = 23, /*!< When multi-advertising is disabled, the event comes */
|
||||
ESP_GATTC_CONGEST_EVT = 24, /*!< When GATT connection congestion comes, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_ENB_EVT = 25, /*!< When batch scan is enabled, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_CFG_EVT = 26, /*!< When batch scan storage is configured, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_RD_EVT = 27, /*!< When Batch scan read event is reported, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_THR_EVT = 28, /*!< When Batch scan threshold is set, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_PARAM_EVT = 29, /*!< When Batch scan parameters are set, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_DIS_EVT = 30, /*!< When Batch scan is disabled, the event comes */
|
||||
ESP_GATTC_SCAN_FLT_CFG_EVT = 31, /*!< When Scan filter configuration completes, the event comes */
|
||||
ESP_GATTC_SCAN_FLT_PARAM_EVT = 32, /*!< When Scan filter parameters are set, the event comes */
|
||||
ESP_GATTC_SCAN_FLT_STATUS_EVT = 33, /*!< When Scan filter status is reported, the event comes */
|
||||
ESP_GATTC_ADV_VSC_EVT = 34, /*!< When advertising vendor spec content event is reported, the event comes */
|
||||
ESP_GATTC_GET_CHAR_EVT = 35, /*!< When characteristic is got from GATT server, the event comes */
|
||||
ESP_GATTC_GET_DESCR_EVT = 36, /*!< When characteristic descriptor is got from GATT server, the event comes */
|
||||
ESP_GATTC_GET_INCL_SRVC_EVT = 37, /*!< When included service is got from GATT server, the event comes */
|
||||
ESP_GATTC_REG_FOR_NOTIFY_EVT = 38, /*!< When register for notification of a service completes, the event comes */
|
||||
ESP_GATTC_UNREG_FOR_NOTIFY_EVT = 39, /*!< When unregister for notification of a service completes, the event comes */
|
||||
} esp_gattc_cb_event_t;
|
||||
|
||||
/// Maximum Transmission Unit used in GATT
|
||||
#define ESP_GATT_DEF_BLE_MTU_SIZE 23
|
||||
|
||||
/// Maximum Transmission Unit allowed in GATT
|
||||
#define ESP_GATT_MAX_MTU_SIZE 517
|
||||
|
||||
/**
|
||||
* @brief Gatt client callback parameters union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_GATTC_REG_EVT
|
||||
*/
|
||||
struct gattc_reg_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t app_id; /*!< Application id which input in register API */
|
||||
} reg; /*!< Gatt client callback param of ESP_GATTC_REG_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_OPEN_EVT
|
||||
*/
|
||||
struct gattc_open_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
uint16_t mtu; /*!< MTU size */
|
||||
} open; /*!< Gatt client callback param of ESP_GATTC_OPEN_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_CLOSE_EVT
|
||||
*/
|
||||
struct gattc_close_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
esp_gatt_conn_reason_t reason; /*!< The reason of gatt connection close */
|
||||
} close; /*!< Gatt client callback param of ESP_GATTC_CLOSE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_CFG_MTU_EVT
|
||||
*/
|
||||
struct gattc_cfg_mtu_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
uint16_t mtu; /*!< MTU size */
|
||||
} cfg_mtu; /*!< Gatt client callback param of ESP_GATTC_CFG_MTU_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_SEARCH_CMPL_EVT
|
||||
*/
|
||||
struct gattc_search_cmpl_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
} search_cmpl; /*!< Gatt client callback param of ESP_GATTC_SEARCH_CMPL_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_SEARCH_RES_EVT
|
||||
*/
|
||||
struct gattc_search_res_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
} search_res; /*!< Gatt client callback param of ESP_GATTC_SEARCH_RES_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_READ_CHAR_EVT, ESP_GATTC_READ_DESCR_EVT
|
||||
*/
|
||||
struct gattc_read_char_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
|
||||
uint8_t *value; /*!< Characteristic value */
|
||||
uint16_t value_type; /*!< Characteristic value type */
|
||||
uint16_t value_len; /*!< Characteristic value length */
|
||||
} read; /*!< Gatt client callback param of ESP_GATTC_READ_CHAR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_WRITE_CHAR_EVT, ESP_GATTC_PREP_WRITE_EVT, ESP_GATTC_WRITE_DESCR_EVT
|
||||
*/
|
||||
struct gattc_write_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
|
||||
} write; /*!< Gatt client callback param of ESP_GATTC_WRITE_DESCR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_EXEC_EVT
|
||||
*/
|
||||
struct gattc_exec_cmpl_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
} exec_cmpl; /*!< Gatt client callback param of ESP_GATTC_EXEC_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_NOTIFY_EVT
|
||||
*/
|
||||
struct gattc_notify_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
|
||||
uint16_t value_len; /*!< Notify attribute value */
|
||||
uint8_t *value; /*!< Notify attribute value */
|
||||
bool is_notify; /*!< True means notify, false means indicate */
|
||||
} notify; /*!< Gatt client callback param of ESP_GATTC_NOTIFY_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_SRVC_CHG_EVT
|
||||
*/
|
||||
struct gattc_srvc_chg_evt_param {
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
} srvc_chg; /*!< Gatt client callback param of ESP_GATTC_SRVC_CHG_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_CONGEST_EVT
|
||||
*/
|
||||
struct gattc_congest_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
bool congested; /*!< Congested or not */
|
||||
} congest; /*!< Gatt client callback param of ESP_GATTC_CONGEST_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_GET_CHAR_EVT
|
||||
*/
|
||||
struct gattc_get_char_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
esp_gatt_char_prop_t char_prop; /*!< Characteristic property */
|
||||
} get_char; /*!< Gatt client callback param of ESP_GATTC_GET_CHAR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_GET_DESCR_EVT
|
||||
*/
|
||||
struct gattc_get_descr_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
|
||||
} get_descr; /*!< Gatt client callback param of ESP_GATTC_GET_DESCR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_GET_INCL_SRVC_EVT
|
||||
*/
|
||||
struct gattc_get_incl_srvc_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_srvc_id_t incl_srvc_id;/*!< Included service id, include service uuid and other information */
|
||||
} get_incl_srvc; /*!< Gatt client callback param of ESP_GATTC_GET_INCL_SRVC_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_REG_FOR_NOTIFY_EVT
|
||||
*/
|
||||
struct gattc_reg_for_notify_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
} reg_for_notify; /*!< Gatt client callback param of ESP_GATTC_REG_FOR_NOTIFY_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_UNREG_FOR_NOTIFY_EVT
|
||||
*/
|
||||
struct gattc_unreg_for_notify_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
} unreg_for_notify; /*!< Gatt client callback param of ESP_GATTC_UNREG_FOR_NOTIFY_EVT */
|
||||
|
||||
|
||||
} esp_ble_gattc_cb_param_t; /*!< GATT client callback parameter union type */
|
||||
|
||||
/**
|
||||
* @brief GATT Client callback function type
|
||||
* @param event : Event type
|
||||
* @param gatts_if : GATT client access interface, normally
|
||||
* different gattc_if correspond to different profile
|
||||
* @param param : Point to callback parameter, currently is union type
|
||||
*/
|
||||
typedef void (* esp_gattc_cb_t)(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief This function is called to register application callbacks
|
||||
* with GATTC module.
|
||||
*
|
||||
* @param[in] callback : pointer to the application callback function.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_register_callback(esp_gattc_cb_t callback);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to register application callbacks
|
||||
* with GATTC module.
|
||||
*
|
||||
* @param[in] app_id : Application Identify (UUID), for different application
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_app_register(uint16_t app_id);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to unregister an application
|
||||
* from GATTC module.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Open a direct connection or add a background auto connection
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] remote_bda: remote device bluetooth device address.
|
||||
* @param[in] is_direct: direct connection or background auto connection
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, bool is_direct);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Close a connection to a GATT server.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID to be closed.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Configure the MTU size in the GATT channel. This can be done
|
||||
* only once per connection.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID.
|
||||
* @param[in] mtu: desired MTU size to use.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_config_mtu (esp_gatt_if_t gattc_if, uint16_t conn_id, uint16_t mtu);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to request a GATT service discovery
|
||||
* on a GATT server. This function report service search result
|
||||
* by a callback event, and followed by a service search complete
|
||||
* event.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID.
|
||||
* @param[in] filter_uuid: a UUID of the service application is interested in.
|
||||
* If Null, discover for all services.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_search_service(esp_gatt_if_t gattc_if, uint16_t conn_id, esp_bt_uuid_t *filter_uuid);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to find the first characteristic of the
|
||||
* service on the given server.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID which identify the server.
|
||||
* @param[in] srvc_id: service ID
|
||||
* @param[in] start_char_id: the start characteristic ID
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_get_characteristic(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *start_char_id);
|
||||
|
||||
/**
|
||||
* @brief This function is called to find the descriptor of the
|
||||
* service on the given server.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID which identify the server.
|
||||
* @param[in] srvc_id: the service ID of which the characteristic is belonged to.
|
||||
* @param[in] char_id: Characteristic ID, if NULL find the first available
|
||||
* characteristic.
|
||||
* @param[in] start_descr_id: the start descriptor id
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_get_descriptor(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *start_descr_id);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to find the first characteristic of the
|
||||
* service on the given server.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID which identify the server.
|
||||
* @param[in] srvc_id: the service ID of which the characteristic is belonged to.
|
||||
* @param[in] start_incl_srvc_id: the start include service id
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_get_included_service(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_srvc_id_t *start_incl_srvc_id);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to read a service's characteristics of
|
||||
* the given characteristic ID
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] srvc_id : service ID.
|
||||
* @param[in] char_id : characteristic ID to read.
|
||||
* @param[in] auth_req : authenticate request type
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to read a characteristics descriptor.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] srvc_id : service ID.
|
||||
* @param[in] char_id : characteristic ID to read.
|
||||
* @param[in] descr_id : characteristic descriptor ID to read.
|
||||
* @param[in] auth_req : authenticate request type
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_read_char_descr (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to write characteristic value.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] srvc_id : service ID.
|
||||
* @param[in] char_id : characteristic ID to write.
|
||||
* @param[in] value_len: length of the value to be written.
|
||||
* @param[in] value : the value to be written.
|
||||
* @param[in] write_type : the type of attribute write operation.
|
||||
* @param[in] auth_req : authentication request.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_write_char( esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_write_type_t write_type,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to write characteristic descriptor value.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID
|
||||
* @param[in] srvc_id : service ID.
|
||||
* @param[in] char_id : characteristic ID.
|
||||
* @param[in] descr_id : characteristic descriptor ID to write.
|
||||
* @param[in] value_len: length of the value to be written.
|
||||
* @param[in] value : the value to be written.
|
||||
* @param[in] write_type : the type of attribute write operation.
|
||||
* @param[in] auth_req : authentication request.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_write_type_t write_type,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to prepare write a characteristic value.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] srvc_id : service ID.
|
||||
* @param[in] char_id : GATT characteristic ID of the service.
|
||||
* @param[in] offset : offset of the write value.
|
||||
* @param[in] value_len: length of the value to be written.
|
||||
* @param[in] value : the value to be written.
|
||||
* @param[in] auth_req : authentication request.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
uint16_t offset,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to execute write a prepare write sequence.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] is_execute : execute or cancel.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_execute_write (esp_gatt_if_t gattc_if, uint16_t conn_id, bool is_execute);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to register for notification of a service.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] server_bda : target GATT server.
|
||||
* @param[in] srvc_id : pointer to GATT service ID.
|
||||
* @param[in] char_id : pointer to GATT characteristic ID.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: registration succeeds
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to de-register for notification of a service.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] server_bda : target GATT server.
|
||||
* @param[in] srvc_id : pointer to GATT service ID.
|
||||
* @param[in] char_id : pointer to GATT characteristic ID.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: unregister succeeds
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_GATTC_API_H__ */
|
542
tools/sdk/include/bluedroid/esp_gatts_api.h
Normal file
542
tools/sdk/include/bluedroid/esp_gatts_api.h
Normal file
@ -0,0 +1,542 @@
|
||||
// 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 __ESP_GATTS_API_H__
|
||||
#define __ESP_GATTS_API_H__
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_gatt_defs.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// GATT Server callback function events
|
||||
typedef enum {
|
||||
ESP_GATTS_REG_EVT = 0, /*!< When register application id, the event comes */
|
||||
ESP_GATTS_READ_EVT = 1, /*!< When gatt client request read operation, the event comes */
|
||||
ESP_GATTS_WRITE_EVT = 2, /*!< When gatt client request write operation, the event comes */
|
||||
ESP_GATTS_EXEC_WRITE_EVT = 3, /*!< When gatt client request execute write, the event comes */
|
||||
ESP_GATTS_MTU_EVT = 4, /*!< When set mtu complete, the event comes */
|
||||
ESP_GATTS_CONF_EVT = 5, /*!< When receive confirm, the event comes */
|
||||
ESP_GATTS_UNREG_EVT = 6, /*!< When unregister application id, the event comes */
|
||||
ESP_GATTS_CREATE_EVT = 7, /*!< When create service complete, the event comes */
|
||||
ESP_GATTS_ADD_INCL_SRVC_EVT = 8, /*!< When add included service complete, the event comes */
|
||||
ESP_GATTS_ADD_CHAR_EVT = 9, /*!< When add characteristic complete, the event comes */
|
||||
ESP_GATTS_ADD_CHAR_DESCR_EVT = 10, /*!< When add descriptor complete, the event comes */
|
||||
ESP_GATTS_DELETE_EVT = 11, /*!< When delete service complete, the event comes */
|
||||
ESP_GATTS_START_EVT = 12, /*!< When start service complete, the event comes */
|
||||
ESP_GATTS_STOP_EVT = 13, /*!< When stop service complete, the event comes */
|
||||
ESP_GATTS_CONNECT_EVT = 14, /*!< When gatt client connect, the event comes */
|
||||
ESP_GATTS_DISCONNECT_EVT = 15, /*!< When gatt client disconnect, the event comes */
|
||||
ESP_GATTS_OPEN_EVT = 16, /*!< When connect to peer, the event comes */
|
||||
ESP_GATTS_CANCEL_OPEN_EVT = 17, /*!< When disconnect from peer, the event comes */
|
||||
ESP_GATTS_CLOSE_EVT = 18, /*!< When gatt server close, the event comes */
|
||||
ESP_GATTS_LISTEN_EVT = 19, /*!< When gatt listen to be connected the event comes */
|
||||
ESP_GATTS_CONGEST_EVT = 20, /*!< When congest happen, the event comes */
|
||||
/* following is extra event */
|
||||
ESP_GATTS_RESPONSE_EVT = 21, /*!< When gatt send response complete, the event comes */
|
||||
ESP_GATTS_CREAT_ATTR_TAB_EVT = 22,
|
||||
ESP_GATTS_SET_ATTR_VAL_EVT = 23,
|
||||
} esp_gatts_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Gatt server callback parameters union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_GATTS_REG_EVT
|
||||
*/
|
||||
struct gatts_reg_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t app_id; /*!< Application id which input in register API */
|
||||
} reg; /*!< Gatt server callback param of ESP_GATTS_REG_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_READ_EVT
|
||||
*/
|
||||
struct gatts_read_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
uint32_t trans_id; /*!< Transfer id */
|
||||
esp_bd_addr_t bda; /*!< The bluetooth device address which been read */
|
||||
uint16_t handle; /*!< The attribute handle */
|
||||
uint16_t offset; /*!< Offset of the value, if the value is too long */
|
||||
bool is_long; /*!< The value is too long or not */
|
||||
bool need_rsp; /*!< The read operation need to do response */
|
||||
} read; /*!< Gatt server callback param of ESP_GATTS_READ_EVT */
|
||||
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_WRITE_EVT
|
||||
*/
|
||||
struct gatts_write_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
uint32_t trans_id; /*!< Transfer id */
|
||||
esp_bd_addr_t bda; /*!< The bluetooth device address which been written */
|
||||
uint16_t handle; /*!< The attribute handle */
|
||||
uint16_t offset; /*!< Offset of the value, if the value is too long */
|
||||
bool need_rsp; /*!< The write operation need to do response */
|
||||
bool is_prep; /*!< This write operation is prepare write */
|
||||
uint16_t len; /*!< The write attribute value length */
|
||||
uint8_t *value; /*!< The write attribute value */
|
||||
} write; /*!< Gatt server callback param of ESP_GATTS_WRITE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_EXEC_WRITE_EVT
|
||||
*/
|
||||
struct gatts_exec_write_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
uint32_t trans_id; /*!< Transfer id */
|
||||
esp_bd_addr_t bda; /*!< The bluetooth device address which been written */
|
||||
#define ESP_GATT_PREP_WRITE_CANCEL 0x00 /*!< Prepare write flag to indicate cancel prepare write */
|
||||
#define ESP_GATT_PREP_WRITE_EXEC 0x01 /*!< Prepare write flag to indicate execute prepare write */
|
||||
uint8_t exec_write_flag; /*!< Execute write flag */
|
||||
} exec_write; /*!< Gatt server callback param of ESP_GATTS_EXEC_WRITE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_MTU_EVT
|
||||
*/
|
||||
struct gatts_mtu_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
uint16_t mtu; /*!< MTU size */
|
||||
} mtu; /*!< Gatt server callback param of ESP_GATTS_MTU_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_CONF_EVT
|
||||
*/
|
||||
struct gatts_conf_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
} conf; /*!< Gatt server callback param of ESP_GATTS_CONF_EVT (confirm) */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_UNREG_EVT
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_CREATE_EVT
|
||||
*/
|
||||
struct gatts_create_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t service_handle; /*!< Service attribute handle */
|
||||
esp_gatt_srvc_id_t service_id; /*!< Service id, include service uuid and other information */
|
||||
} create; /*!< Gatt server callback param of ESP_GATTS_CREATE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_ADD_INCL_SRVC_EVT
|
||||
*/
|
||||
struct gatts_add_incl_srvc_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t attr_handle; /*!< Included service attribute handle */
|
||||
uint16_t service_handle; /*!< Service attribute handle */
|
||||
} add_incl_srvc; /*!< Gatt server callback param of ESP_GATTS_ADD_INCL_SRVC_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_ADD_CHAR_EVT
|
||||
*/
|
||||
struct gatts_add_char_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t attr_handle; /*!< Characteristic attribute handle */
|
||||
uint16_t service_handle; /*!< Service attribute handle */
|
||||
esp_bt_uuid_t char_uuid; /*!< Characteristic uuid */
|
||||
} add_char; /*!< Gatt server callback param of ESP_GATTS_ADD_CHAR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_ADD_CHAR_DESCR_EVT
|
||||
*/
|
||||
struct gatts_add_char_descr_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t attr_handle; /*!< Descriptor attribute handle */
|
||||
uint16_t service_handle; /*!< Service attribute handle */
|
||||
esp_bt_uuid_t char_uuid; /*!< Characteristic uuid */
|
||||
} add_char_descr; /*!< Gatt server callback param of ESP_GATTS_ADD_CHAR_DESCR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_DELETE_EVT
|
||||
*/
|
||||
struct gatts_delete_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t service_handle; /*!< Service attribute handle */
|
||||
} del; /*!< Gatt server callback param of ESP_GATTS_DELETE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_START_EVT
|
||||
*/
|
||||
struct gatts_start_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t service_handle; /*!< Service attribute handle */
|
||||
} start; /*!< Gatt server callback param of ESP_GATTS_START_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_STOP_EVT
|
||||
*/
|
||||
struct gatts_stop_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t service_handle; /*!< Service attribute handle */
|
||||
} stop; /*!< Gatt server callback param of ESP_GATTS_STOP_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_CONNECT_EVT
|
||||
*/
|
||||
struct gatts_connect_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
bool is_connected; /*!< Indicate it is connected or not */
|
||||
} connect; /*!< Gatt server callback param of ESP_GATTS_CONNECT_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_DISCONNECT_EVT
|
||||
*/
|
||||
struct gatts_disconnect_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
bool is_connected; /*!< Indicate it is connected or not */
|
||||
} disconnect; /*!< Gatt server callback param of ESP_GATTS_DISCONNECT_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_OPEN_EVT
|
||||
*/
|
||||
/**
|
||||
* @brief ESP_GATTS_CANCEL_OPEN_EVT
|
||||
*/
|
||||
/**
|
||||
* @brief ESP_GATTS_CLOSE_EVT
|
||||
*/
|
||||
/**
|
||||
* @brief ESP_GATTS_LISTEN_EVT
|
||||
*/
|
||||
/**
|
||||
* @brief ESP_GATTS_CONGEST_EVT
|
||||
*/
|
||||
struct gatts_congest_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
bool congested; /*!< Congested or not */
|
||||
} congest; /*!< Gatt server callback param of ESP_GATTS_CONGEST_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_RESPONSE_EVT
|
||||
*/
|
||||
struct gatts_rsp_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t handle; /*!< Attribute handle which send response */
|
||||
} rsp; /*!< Gatt server callback param of ESP_GATTS_RESPONSE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_CREAT_ATTR_TAB_EVT
|
||||
*/
|
||||
struct gatts_add_attr_tab_evt_param{
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
esp_bt_uuid_t svc_uuid; /*!< Service uuid type */
|
||||
uint16_t num_handle; /*!< The number of the attribute handle to be added to the gatts database */
|
||||
uint16_t *handles; /*!< The number to the handles */
|
||||
} add_attr_tab; /*!< Gatt server callback param of ESP_GATTS_CREAT_ATTR_TAB_EVT */
|
||||
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_SET_ATTR_VAL_EVT
|
||||
*/
|
||||
struct gatts_set_attr_val_evt_param{
|
||||
uint16_t srvc_handle; /*!< The service handle */
|
||||
uint16_t attr_handle; /*!< The attribute handle */
|
||||
esp_gatt_status_t status; /*!< Operation status*/
|
||||
} set_attr_val; /*!< Gatt server callback param of ESP_GATTS_SET_ATTR_VAL_EVT */
|
||||
|
||||
} esp_ble_gatts_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief GATT Server callback function type
|
||||
* @param event : Event type
|
||||
* @param gatts_if : GATT server access interface, normally
|
||||
* different gatts_if correspond to different profile
|
||||
* @param param : Point to callback parameter, currently is union type
|
||||
*/
|
||||
typedef void (* esp_gatts_cb_t)(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief This function is called to register application callbacks
|
||||
* with BTA GATTS module.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_register_callback(esp_gatts_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief This function is called to register application identifier
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_app_register(uint16_t app_id);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief unregister with GATT Server.
|
||||
*
|
||||
* @param[in] gatts_if: GATT server access interface
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_app_unregister(esp_gatt_if_t gatts_if);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create a service. When service creation is done, a callback
|
||||
* event BTA_GATTS_CREATE_SRVC_EVT is called to report status
|
||||
* and service ID to the profile. The service ID obtained in
|
||||
* the callback function needs to be used when adding included
|
||||
* service and characteristics/descriptors into the service.
|
||||
*
|
||||
* @param[in] gatts_if: GATT server access interface
|
||||
* @param[in] service_id: service ID.
|
||||
* @param[in] num_handle: number of handle requested for this service.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatts_if,
|
||||
esp_gatt_srvc_id_t *service_id, uint16_t num_handle);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create a service attribute tab.
|
||||
* @param[in] gatts_attr_db: the pointer to the service attr tab
|
||||
* @param[in] gatts_if: GATT server access interface
|
||||
* @param[in] max_nb_attr: the number of attribute to be added to the service database.
|
||||
* @param[in] srvc_inst_id: the instance id of the service
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db,
|
||||
esp_gatt_if_t gatts_if,
|
||||
uint8_t max_nb_attr,
|
||||
uint8_t srvc_inst_id);
|
||||
/**
|
||||
* @brief This function is called to add an included service. After included
|
||||
* service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT
|
||||
* is reported the included service ID.
|
||||
*
|
||||
* @param[in] service_handle: service handle to which this included service is to
|
||||
* be added.
|
||||
* @param[in] included_service_handle: the service ID to be included.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_add_included_service(uint16_t service_handle, uint16_t included_service_handle);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to add a characteristic into a service.
|
||||
*
|
||||
* @param[in] service_handle: service handle to which this included service is to
|
||||
* be added.
|
||||
* @param[in] char_uuid : Characteristic UUID.
|
||||
* @param[in] perm : Characteristic value declaration attribute permission.
|
||||
* @param[in] property : Characteristic Properties
|
||||
* @param[in] char_val : Characteristic value
|
||||
* @param[in] control : attribute response control byte
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_add_char(uint16_t service_handle, esp_bt_uuid_t *char_uuid,
|
||||
esp_gatt_perm_t perm, esp_gatt_char_prop_t property, esp_attr_value_t *char_val,
|
||||
esp_attr_control_t *control);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to add characteristic descriptor. When
|
||||
* it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called
|
||||
* to report the status and an ID number for this descriptor.
|
||||
*
|
||||
* @param[in] service_handle: service handle to which this characteristic descriptor is to
|
||||
* be added.
|
||||
* @param[in] perm: descriptor access permission.
|
||||
* @param[in] descr_uuid: descriptor UUID.
|
||||
* @param[in] char_descr_val : Characteristic descriptor value
|
||||
* @param[in] control : attribute response control byte
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_add_char_descr (uint16_t service_handle,
|
||||
esp_bt_uuid_t *descr_uuid,
|
||||
esp_gatt_perm_t perm, esp_attr_value_t *char_descr_val,
|
||||
esp_attr_control_t *control);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to delete a service. When this is done,
|
||||
* a callback event BTA_GATTS_DELETE_EVT is report with the status.
|
||||
*
|
||||
* @param[in] service_handle: service_handle to be deleted.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_delete_service(uint16_t service_handle);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to start a service.
|
||||
*
|
||||
* @param[in] service_handle: the service handle to be started.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_start_service(uint16_t service_handle);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to stop a service.
|
||||
*
|
||||
* @param[in] service_handle - service to be topped.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Send indicate or notify to GATT client.
|
||||
* Set param need_confirm as false will send notification, otherwise indication.
|
||||
*
|
||||
* @param[in] gatts_if: GATT server access interface
|
||||
* @param[in] conn_id - connection id to indicate.
|
||||
* @param[in] attr_handle - attribute handle to indicate.
|
||||
* @param[in] value_len - indicate value length.
|
||||
* @param[in] value: value to indicate.
|
||||
* @param[in] need_confirm - Whether a confirmation is required.
|
||||
* false sends a GATT notification, true sends a GATT indication.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id, uint16_t attr_handle,
|
||||
uint16_t value_len, uint8_t *value, bool need_confirm);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to send a response to a request.
|
||||
*
|
||||
* @param[in] gatts_if: GATT server access interface
|
||||
* @param[in] conn_id - connection identifier.
|
||||
* @param[in] trans_id - transfer id
|
||||
* @param[in] status - response status
|
||||
* @param[in] rsp - response data.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_send_response(esp_gatt_if_t gatts_if, uint16_t conn_id, uint32_t trans_id,
|
||||
esp_gatt_status_t status, esp_gatt_rsp_t *rsp);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to set the attribute value by the application
|
||||
*
|
||||
* @param[in] attr_handle: the attribute handle which to be set
|
||||
* @param[in] length: the value length
|
||||
* @param[in] value: the pointer to the attribute value
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_set_attr_value(uint16_t attr_handle, uint16_t length, const uint8_t *value);
|
||||
|
||||
/**
|
||||
* @brief Retrieve attribute value
|
||||
*
|
||||
* @param[in] attr_handle: Attribute handle.
|
||||
* @param[out] length: pointer to the attribute value length
|
||||
* @param[out] value: Pointer to attribute value payload, the value cannot be modified by user
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, const uint8_t **value);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Open a direct open connection or add a background auto connection
|
||||
*
|
||||
* @param[in] gatts_if: GATT server access interface
|
||||
* @param[in] remote_bda: remote device bluetooth device address.
|
||||
* @param[in] is_direct: direct connection or background auto connection
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatts_if, esp_bd_addr_t remote_bda, bool is_direct);
|
||||
|
||||
/**
|
||||
* @brief Close a connection a remote device.
|
||||
*
|
||||
* @param[in] gatts_if: GATT server access interface
|
||||
* @param[in] conn_id: connection ID to be closed.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_close(esp_gatt_if_t gatts_if, uint16_t conn_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_GATTS_API_H__ */
|
30
tools/sdk/include/bluedroid/event_mask.h
Normal file
30
tools/sdk/include/bluedroid/event_mask.h
Normal file
@ -0,0 +1,30 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _EVENT_MASK_H_
|
||||
#define _EVENT_MASK_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Represents a mask which can be used to tell the controller which
|
||||
// HCI events the stack wishes to be informed about. See the bluetooth
|
||||
// spec for more information on what each bit means.
|
||||
typedef struct {
|
||||
uint8_t as_array[8];
|
||||
} bt_event_mask_t;
|
||||
|
||||
#endif /*_EVENT_MASK_H_*/
|
102
tools/sdk/include/bluedroid/fixed_queue.h
Executable file
102
tools/sdk/include/bluedroid/fixed_queue.h
Executable file
@ -0,0 +1,102 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _FIXED_QUEUE_H_
|
||||
#define _FIXED_QUEUE_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct fixed_queue_t;
|
||||
typedef struct fixed_queue_t fixed_queue_t;
|
||||
//typedef struct reactor_t reactor_t;
|
||||
|
||||
typedef void (*fixed_queue_free_cb)(void *data);
|
||||
typedef void (*fixed_queue_cb)(fixed_queue_t *queue);
|
||||
|
||||
// Creates a new fixed queue with the given |capacity|. If more elements than
|
||||
// |capacity| are added to the queue, the caller is blocked until space is
|
||||
// made available in the queue. Returns NULL on failure. The caller must free
|
||||
// the returned queue with |fixed_queue_free|.
|
||||
fixed_queue_t *fixed_queue_new(size_t capacity);
|
||||
|
||||
// Freeing a queue that is currently in use (i.e. has waiters
|
||||
// blocked on it) results in undefined behaviour.
|
||||
void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb);
|
||||
|
||||
// Returns a value indicating whether the given |queue| is empty. |queue| may
|
||||
// not be NULL.
|
||||
bool fixed_queue_is_empty(fixed_queue_t *queue);
|
||||
|
||||
// Returns the maximum number of elements this queue may hold. |queue| may
|
||||
// not be NULL.
|
||||
size_t fixed_queue_capacity(fixed_queue_t *queue);
|
||||
|
||||
// Enqueues the given |data| into the |queue|. The caller will be blocked
|
||||
// if nore more space is available in the queue. Neither |queue| nor |data|
|
||||
// may be NULL.
|
||||
void fixed_queue_enqueue(fixed_queue_t *queue, void *data);
|
||||
|
||||
// Dequeues the next element from |queue|. If the queue is currently empty,
|
||||
// this function will block the caller until an item is enqueued. This
|
||||
// function will never return NULL. |queue| may not be NULL.
|
||||
void *fixed_queue_dequeue(fixed_queue_t *queue);
|
||||
|
||||
// Tries to enqueue |data| into the |queue|. This function will never block
|
||||
// the caller. If the queue capacity would be exceeded by adding one more
|
||||
// element, this function returns false immediately. Otherwise, this function
|
||||
// returns true. Neither |queue| nor |data| may be NULL.
|
||||
bool fixed_queue_try_enqueue(fixed_queue_t *queue, void *data);
|
||||
|
||||
// Tries to dequeue an element from |queue|. This function will never block
|
||||
// the caller. If the queue is empty, this function returns NULL immediately.
|
||||
// Otherwise, the next element in the queue is returned. |queue| may not be
|
||||
// NULL.
|
||||
//void *fixed_queue_try_dequeue(fixed_queue_t *queue);
|
||||
|
||||
// Returns the first element from |queue|, if present, without dequeuing it.
|
||||
// This function will never block the caller. Returns NULL if there are no elements
|
||||
// in the queue. |queue| may not be NULL.
|
||||
//void *fixed_queue_try_peek(fixed_queue_t *queue);
|
||||
|
||||
// This function returns a valid file descriptor. Callers may perform one
|
||||
// operation on the fd: select(2). If |select| indicates that the file
|
||||
// descriptor is readable, the caller may call |fixed_queue_enqueue| without
|
||||
// blocking. The caller must not close the returned file descriptor. |queue|
|
||||
// may not be NULL.
|
||||
//int fixed_queue_get_enqueue_fd(const fixed_queue_t *queue);
|
||||
|
||||
// This function returns a valid file descriptor. Callers may perform one
|
||||
// operation on the fd: select(2). If |select| indicates that the file
|
||||
// descriptor is readable, the caller may call |fixed_queue_dequeue| without
|
||||
// blocking. The caller must not close the returned file descriptor. |queue|
|
||||
// may not be NULL.
|
||||
//int fixed_queue_get_dequeue_fd(const fixed_queue_t *queue);
|
||||
|
||||
// Registers |queue| with |reactor| for dequeue operations. When there is an element
|
||||
// in the queue, ready_cb will be called. The |context| parameter is passed, untouched,
|
||||
// to the callback routine. Neither |queue|, nor |reactor|, nor |read_cb| may be NULL.
|
||||
// |context| may be NULL.
|
||||
void fixed_queue_register_dequeue(fixed_queue_t *queue, fixed_queue_cb ready_cb);
|
||||
|
||||
// Unregisters the dequeue ready callback for |queue| from whichever reactor
|
||||
// it is registered with, if any. This function is idempotent.
|
||||
void fixed_queue_unregister_dequeue(fixed_queue_t *queue);
|
||||
|
||||
void fixed_queue_process(fixed_queue_t *queue);
|
||||
|
||||
#endif
|
52
tools/sdk/include/bluedroid/future.h
Normal file
52
tools/sdk/include/bluedroid/future.h
Normal file
@ -0,0 +1,52 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 __FUTURE_H__
|
||||
#define __FUTURE_H__
|
||||
// #pragma once
|
||||
|
||||
#include "osi_arch.h"
|
||||
|
||||
struct future {
|
||||
bool ready_can_be_called;
|
||||
osi_sem_t semaphore; // NULL semaphore means immediate future
|
||||
void *result;
|
||||
};
|
||||
typedef struct future future_t;
|
||||
|
||||
#define FUTURE_SUCCESS ((void *)1)
|
||||
#define FUTURE_FAIL ((void *)0)
|
||||
|
||||
// Constructs a new future_t object. Returns NULL on failure.
|
||||
future_t *future_new(void);
|
||||
|
||||
// Constructs a new future_t object with an immediate |value|. No waiting will
|
||||
// occur in the call to |future_await| because the value is already present.
|
||||
// Returns NULL on failure.
|
||||
future_t *future_new_immediate(void *value);
|
||||
|
||||
// Signals that the |future| is ready, passing |value| back to the context
|
||||
// waiting for the result. Must only be called once for every future.
|
||||
// |future| may not be NULL.
|
||||
void future_ready(future_t *future, void *value);
|
||||
|
||||
// Waits for the |future| to be ready. Returns the value set in |future_ready|.
|
||||
// Frees the future before return. |future| may not be NULL.
|
||||
void *future_await(future_t *async_result);
|
||||
|
||||
#endif /* __FUTURE_H__ */
|
391
tools/sdk/include/bluedroid/gap_api.h
Normal file
391
tools/sdk/include/bluedroid/gap_api.h
Normal file
@ -0,0 +1,391 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2013 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef GAP_API_H
|
||||
#define GAP_API_H
|
||||
|
||||
#include "sdpdefs.h"
|
||||
#include "profiles_api.h"
|
||||
#include "btm_api.h"
|
||||
#include "l2c_api.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
/*** GAP Error and Status Codes ***/
|
||||
#define GAP_UNSUPPORTED (GAP_ERR_GRP + 0x01) /* Unsupported call */
|
||||
#define GAP_EOINQDB (GAP_ERR_GRP + 0x02) /* End of inquiry database marker */
|
||||
#define GAP_ERR_BUSY (GAP_ERR_GRP + 0x03) /* The requested function was busy */
|
||||
#define GAP_ERR_NO_CTRL_BLK (GAP_ERR_GRP + 0x04) /* No control blocks available */
|
||||
#define GAP_ERR_STARTING_CMD (GAP_ERR_GRP + 0x05) /* Error occurred while initiating the command */
|
||||
#define GAP_NO_BDADDR_REC (GAP_ERR_GRP + 0x06) /* No Inquiry DB record for BD_ADDR */
|
||||
#define GAP_ERR_ILL_MODE (GAP_ERR_GRP + 0x07) /* An illegal mode parameter was detected */
|
||||
#define GAP_ERR_ILL_INQ_TIME (GAP_ERR_GRP + 0x08) /* An illegal time parameter was detected */
|
||||
#define GAP_ERR_ILL_PARM (GAP_ERR_GRP + 0x09) /* An illegal parameter was detected */
|
||||
#define GAP_ERR_REM_NAME (GAP_ERR_GRP + 0x0a) /* Error starting the remote device name request */
|
||||
#define GAP_CMD_INITIATED (GAP_ERR_GRP + 0x0b) /* The GAP command was started (result pending) */
|
||||
#define GAP_DEVICE_NOT_UP (GAP_ERR_GRP + 0x0c) /* The device was not up; the request was not executed */
|
||||
#define GAP_BAD_BD_ADDR (GAP_ERR_GRP + 0x0d) /* The bd addr passed in was not found or invalid */
|
||||
|
||||
#define GAP_ERR_BAD_HANDLE (GAP_ERR_GRP + 0x0e) /* Bad GAP handle */
|
||||
#define GAP_ERR_BUF_OFFSET (GAP_ERR_GRP + 0x0f) /* Buffer offset invalid */
|
||||
#define GAP_ERR_BAD_STATE (GAP_ERR_GRP + 0x10) /* Connection is in invalid state */
|
||||
#define GAP_NO_DATA_AVAIL (GAP_ERR_GRP + 0x11) /* No data available */
|
||||
#define GAP_ERR_CONGESTED (GAP_ERR_GRP + 0x12) /* BT stack is congested */
|
||||
#define GAP_ERR_SECURITY (GAP_ERR_GRP + 0x13) /* Security failed */
|
||||
|
||||
#define GAP_ERR_PROCESSING (GAP_ERR_GRP + 0x14) /* General error processing BTM request */
|
||||
#define GAP_ERR_TIMEOUT (GAP_ERR_GRP + 0x15) /* Timeout occurred while processing cmd */
|
||||
#define GAP_EVT_CONN_OPENED 0x0100
|
||||
#define GAP_EVT_CONN_CLOSED 0x0101
|
||||
#define GAP_EVT_CONN_DATA_AVAIL 0x0102
|
||||
#define GAP_EVT_CONN_CONGESTED 0x0103
|
||||
#define GAP_EVT_CONN_UNCONGESTED 0x0104
|
||||
/* Values for 'chan_mode_mask' field */
|
||||
/* GAP_ConnOpen() - optional channels to negotiate */
|
||||
#define GAP_FCR_CHAN_OPT_BASIC L2CAP_FCR_CHAN_OPT_BASIC
|
||||
#define GAP_FCR_CHAN_OPT_ERTM L2CAP_FCR_CHAN_OPT_ERTM
|
||||
#define GAP_FCR_CHAN_OPT_STREAM L2CAP_FCR_CHAN_OPT_STREAM
|
||||
/*** used in connection variables and functions ***/
|
||||
#define GAP_INVALID_HANDLE 0xFFFF
|
||||
|
||||
/* This is used to change the criteria for AMP */
|
||||
#define GAP_PROTOCOL_ID (UUID_PROTOCOL_UDP)
|
||||
|
||||
|
||||
#ifndef GAP_PREFER_CONN_INT_MAX
|
||||
#define GAP_PREFER_CONN_INT_MAX BTM_BLE_CONN_INT_MIN
|
||||
#endif
|
||||
|
||||
#ifndef GAP_PREFER_CONN_INT_MIN
|
||||
#define GAP_PREFER_CONN_INT_MIN BTM_BLE_CONN_INT_MIN
|
||||
#endif
|
||||
|
||||
#ifndef GAP_PREFER_CONN_LATENCY
|
||||
#define GAP_PREFER_CONN_LATENCY 0
|
||||
#endif
|
||||
|
||||
#ifndef GAP_PREFER_CONN_SP_TOUT
|
||||
#define GAP_PREFER_CONN_SP_TOUT 2000
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
/*
|
||||
** Callback function for connection services
|
||||
*/
|
||||
typedef void (tGAP_CONN_CALLBACK) (UINT16 gap_handle, UINT16 event);
|
||||
|
||||
/*
|
||||
** Define the callback function prototypes. Parameters are specific
|
||||
** to each event and are described below
|
||||
*/
|
||||
typedef void (tGAP_CALLBACK) (UINT16 event, void *p_data);
|
||||
|
||||
|
||||
/* Definition of the GAP_FindAddrByName results structure */
|
||||
typedef struct {
|
||||
UINT16 status;
|
||||
BD_ADDR bd_addr;
|
||||
tBTM_BD_NAME devname;
|
||||
} tGAP_FINDADDR_RESULTS;
|
||||
|
||||
typedef struct {
|
||||
UINT16 int_min;
|
||||
UINT16 int_max;
|
||||
UINT16 latency;
|
||||
UINT16 sp_tout;
|
||||
} tGAP_BLE_PREF_PARAM;
|
||||
|
||||
typedef union {
|
||||
tGAP_BLE_PREF_PARAM conn_param;
|
||||
BD_ADDR reconn_bda;
|
||||
UINT16 icon;
|
||||
UINT8 *p_dev_name;
|
||||
UINT8 addr_resolution;
|
||||
|
||||
} tGAP_BLE_ATTR_VALUE;
|
||||
|
||||
typedef void (tGAP_BLE_CMPL_CBACK)(BOOLEAN status, BD_ADDR addr, UINT16 length, char *p_name);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
|
||||
/*** Functions for L2CAP connection interface ***/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnOpen
|
||||
**
|
||||
** Description This function is called to open a generic L2CAP connection.
|
||||
**
|
||||
** Returns handle of the connection if successful, else GAP_INVALID_HANDLE
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnOpen (char *p_serv_name, UINT8 service_id, BOOLEAN is_server,
|
||||
BD_ADDR p_rem_bda, UINT16 psm, tL2CAP_CFG_INFO *p_cfg,
|
||||
tL2CAP_ERTM_INFO *ertm_info,
|
||||
UINT16 security, UINT8 chan_mode_mask, tGAP_CONN_CALLBACK *p_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnClose
|
||||
**
|
||||
** Description This function is called to close a connection.
|
||||
**
|
||||
** Returns BT_PASS - closed OK
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnClose (UINT16 gap_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnReadData
|
||||
**
|
||||
** Description GKI buffer unaware application will call this function
|
||||
** after receiving GAP_EVT_RXDATA event. A data copy is made
|
||||
** into the receive buffer parameter.
|
||||
**
|
||||
** Returns BT_PASS - data read
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
** GAP_NO_DATA_AVAIL - no data available
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data,
|
||||
UINT16 max_len, UINT16 *p_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_GetRxQueueCnt
|
||||
**
|
||||
** Description This function return number of bytes on the rx queue.
|
||||
**
|
||||
** Parameters: handle - Handle returned in the GAP_ConnOpen
|
||||
** p_rx_queue_count - Pointer to return queue count in.
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int GAP_GetRxQueueCnt (UINT16 handle, UINT32 *p_rx_queue_count);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnBTRead
|
||||
**
|
||||
** Description GKI buffer aware applications will call this function after
|
||||
** receiving an GAP_EVT_RXDATA event to process the incoming
|
||||
** data buffer.
|
||||
**
|
||||
** Returns BT_PASS - data read
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
** GAP_NO_DATA_AVAIL - no data available
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnBTRead (UINT16 gap_handle, BT_HDR **pp_buf);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnBTWrite
|
||||
**
|
||||
** Description GKI buffer aware applications can call this function to write data
|
||||
** by passing a pointer to the GKI buffer of data.
|
||||
**
|
||||
** Returns BT_PASS - data read
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
** GAP_ERR_BAD_STATE - connection not established
|
||||
** GAP_INVALID_BUF_OFFSET - buffer offset is invalid
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnBTWrite (UINT16 gap_handle, BT_HDR *p_buf);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnWriteData
|
||||
**
|
||||
** Description GKI buffer unaware application will call this function
|
||||
** to send data to the connection. A data copy is made into a GKI
|
||||
** buffer.
|
||||
**
|
||||
** Returns BT_PASS - data read
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
** GAP_ERR_BAD_STATE - connection not established
|
||||
** GAP_CONGESTION - system is congested
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data,
|
||||
UINT16 max_len, UINT16 *p_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnReconfig
|
||||
**
|
||||
** Description Applications can call this function to reconfigure the connection.
|
||||
**
|
||||
** Returns BT_PASS - config process started
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnReconfig (UINT16 gap_handle, tL2CAP_CFG_INFO *p_cfg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnSetIdleTimeout
|
||||
**
|
||||
** Description Higher layers call this function to set the idle timeout for
|
||||
** a connection, or for all future connections. The "idle timeout"
|
||||
** is the amount of time that a connection can remain up with
|
||||
** no L2CAP channels on it. A timeout of zero means that the
|
||||
** connection will be torn down immediately when the last channel
|
||||
** is removed. A timeout of 0xFFFF means no timeout. Values are
|
||||
** in seconds.
|
||||
**
|
||||
** Returns BT_PASS - config process started
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnSetIdleTimeout (UINT16 gap_handle, UINT16 timeout);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnGetRemoteAddr
|
||||
**
|
||||
** Description This function is called to get the remote BD address
|
||||
** of a connection.
|
||||
**
|
||||
** Returns BT_PASS - closed OK
|
||||
** GAP_ERR_BAD_HANDLE - invalid handle
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 *GAP_ConnGetRemoteAddr (UINT16 gap_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnGetRemMtuSize
|
||||
**
|
||||
** Description Returns the remote device's MTU size.
|
||||
**
|
||||
** Returns UINT16 - maximum size buffer that can be transmitted to the peer
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnGetRemMtuSize (UINT16 gap_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_ConnGetL2CAPCid
|
||||
**
|
||||
** Description Returns the L2CAP channel id
|
||||
**
|
||||
** Parameters: handle - Handle of the connection
|
||||
**
|
||||
** Returns UINT16 - The L2CAP channel id
|
||||
** 0, if error
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GAP_ConnGetL2CAPCid (UINT16 gap_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_SetTraceLevel
|
||||
**
|
||||
** Description This function sets the trace level for GAP. If called with
|
||||
** a value of 0xFF, it simply returns the current trace level.
|
||||
**
|
||||
** Returns The new or current trace level
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 GAP_SetTraceLevel (UINT8 new_level);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_Init
|
||||
**
|
||||
** Description Initializes the control blocks used by GAP.
|
||||
** This routine should not be called except once per
|
||||
** stack invocation.
|
||||
**
|
||||
** Returns Nothing
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void GAP_Init(void);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_BleAttrDBUpdate
|
||||
**
|
||||
** Description update GAP local BLE attribute database.
|
||||
**
|
||||
** Returns Nothing
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_BleReadPeerPrefConnParams
|
||||
**
|
||||
** Description Start a process to read a connected peripheral's preferred
|
||||
** connection parameters
|
||||
**
|
||||
** Returns TRUE if read started, else FALSE if GAP is busy
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN GAP_BleReadPeerPrefConnParams (BD_ADDR peer_bda);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_BleReadPeerDevName
|
||||
**
|
||||
** Description Start a process to read a connected peripheral's device name.
|
||||
**
|
||||
** Returns TRUE if request accepted
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN GAP_BleReadPeerDevName (BD_ADDR peer_bda, tGAP_BLE_CMPL_CBACK *p_cback);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_BleReadPeerAddressResolutionCap
|
||||
**
|
||||
** Description Start a process to read peer address resolution capability
|
||||
**
|
||||
** Returns TRUE if request accepted
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN GAP_BleReadPeerAddressResolutionCap (BD_ADDR peer_bda,
|
||||
tGAP_BLE_CMPL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function GAP_BleCancelReadPeerDevName
|
||||
**
|
||||
** Description Cancel reading a peripheral's device name.
|
||||
**
|
||||
** Returns TRUE if request accepted
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN GAP_BleCancelReadPeerDevName (BD_ADDR peer_bda);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* GAP_API_H */
|
154
tools/sdk/include/bluedroid/gap_int.h
Normal file
154
tools/sdk/include/bluedroid/gap_int.h
Normal file
@ -0,0 +1,154 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2013 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef GAP_INT_H
|
||||
#define GAP_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gap_api.h"
|
||||
#include "gki.h"
|
||||
#include "gatt_api.h"
|
||||
#define GAP_MAX_BLOCKS 2 /* Concurrent GAP commands pending at a time*/
|
||||
/* Define the Generic Access Profile control structure */
|
||||
typedef struct {
|
||||
void *p_data; /* Pointer to any data returned in callback */
|
||||
tGAP_CALLBACK *gap_cback; /* Pointer to users callback function */
|
||||
tGAP_CALLBACK *gap_inq_rslt_cback; /* Used for inquiry results */
|
||||
UINT16 event; /* Passed back in the callback */
|
||||
UINT8 index; /* Index of this control block and callback */
|
||||
BOOLEAN in_use; /* True when structure is allocated */
|
||||
} tGAP_INFO;
|
||||
|
||||
/* Define the control block for the FindAddrByName operation (Only 1 active at a time) */
|
||||
typedef struct {
|
||||
tGAP_CALLBACK *p_cback;
|
||||
tBTM_INQ_INFO *p_cur_inq; /* Pointer to the current inquiry database entry */
|
||||
tGAP_FINDADDR_RESULTS results;
|
||||
BOOLEAN in_use;
|
||||
} tGAP_FINDADDR_CB;
|
||||
|
||||
/* Define the GAP Connection Control Block.
|
||||
*/
|
||||
typedef struct {
|
||||
#define GAP_CCB_STATE_IDLE 0
|
||||
#define GAP_CCB_STATE_LISTENING 1
|
||||
#define GAP_CCB_STATE_CONN_SETUP 2
|
||||
#define GAP_CCB_STATE_CFG_SETUP 3
|
||||
#define GAP_CCB_STATE_WAIT_SEC 4
|
||||
#define GAP_CCB_STATE_CONNECTED 5
|
||||
UINT8 con_state;
|
||||
|
||||
#define GAP_CCB_FLAGS_IS_ORIG 0x01
|
||||
#define GAP_CCB_FLAGS_HIS_CFG_DONE 0x02
|
||||
#define GAP_CCB_FLAGS_MY_CFG_DONE 0x04
|
||||
#define GAP_CCB_FLAGS_SEC_DONE 0x08
|
||||
#define GAP_CCB_FLAGS_CONN_DONE 0x0E
|
||||
UINT8 con_flags;
|
||||
|
||||
UINT8 service_id; /* Used by BTM */
|
||||
UINT16 gap_handle; /* GAP handle */
|
||||
UINT16 connection_id; /* L2CAP CID */
|
||||
BOOLEAN rem_addr_specified;
|
||||
UINT8 chan_mode_mask; /* Supported channel modes (FCR) */
|
||||
BD_ADDR rem_dev_address;
|
||||
UINT16 psm;
|
||||
UINT16 rem_mtu_size;
|
||||
|
||||
BOOLEAN is_congested;
|
||||
BUFFER_Q tx_queue; /* Queue of buffers waiting to be sent */
|
||||
BUFFER_Q rx_queue; /* Queue of buffers waiting to be read */
|
||||
|
||||
UINT32 rx_queue_size; /* Total data count in rx_queue */
|
||||
|
||||
tGAP_CONN_CALLBACK *p_callback; /* Users callback function */
|
||||
|
||||
tL2CAP_CFG_INFO cfg; /* Configuration */
|
||||
tL2CAP_ERTM_INFO ertm_info; /* Pools and modes for ertm */
|
||||
} tGAP_CCB;
|
||||
|
||||
typedef struct {
|
||||
#if ((defined AMP_INCLUDED) && (AMP_INCLUDED == TRUE))
|
||||
tAMP_APPL_INFO reg_info;
|
||||
#else
|
||||
tL2CAP_APPL_INFO reg_info; /* L2CAP Registration info */
|
||||
#endif
|
||||
tGAP_CCB ccb_pool[GAP_MAX_CONNECTIONS];
|
||||
} tGAP_CONN;
|
||||
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
#define GAP_MAX_CHAR_NUM 4
|
||||
|
||||
typedef struct {
|
||||
UINT16 handle;
|
||||
UINT16 uuid;
|
||||
tGAP_BLE_ATTR_VALUE attr_value;
|
||||
} tGAP_ATTR;
|
||||
#endif
|
||||
/**********************************************************************
|
||||
** M A I N C O N T R O L B L O C K
|
||||
***********************************************************************/
|
||||
|
||||
#define GAP_MAX_CL GATT_CL_MAX_LCB
|
||||
|
||||
typedef struct {
|
||||
UINT16 uuid;
|
||||
tGAP_BLE_CMPL_CBACK *p_cback;
|
||||
} tGAP_BLE_REQ;
|
||||
|
||||
typedef struct {
|
||||
BD_ADDR bda;
|
||||
tGAP_BLE_CMPL_CBACK *p_cback;
|
||||
UINT16 conn_id;
|
||||
UINT16 cl_op_uuid;
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN connected;
|
||||
BUFFER_Q pending_req_q;
|
||||
|
||||
} tGAP_CLCB;
|
||||
|
||||
typedef struct {
|
||||
tGAP_INFO blk[GAP_MAX_BLOCKS];
|
||||
tBTM_CMPL_CB *btm_cback[GAP_MAX_BLOCKS];
|
||||
UINT8 trace_level;
|
||||
tGAP_FINDADDR_CB findaddr_cb; /* Contains the control block for finding a device addr */
|
||||
tBTM_INQ_INFO *cur_inqptr;
|
||||
|
||||
#if GAP_CONN_INCLUDED == TRUE
|
||||
tGAP_CONN conn;
|
||||
#endif
|
||||
|
||||
/* LE GAP attribute database */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tGAP_ATTR gatt_attr[GAP_MAX_CHAR_NUM];
|
||||
tGAP_CLCB clcb[GAP_MAX_CL]; /* connection link*/
|
||||
tGATT_IF gatt_if;
|
||||
#endif
|
||||
} tGAP_CB;
|
||||
|
||||
|
||||
extern tGAP_CB gap_cb;
|
||||
#if (GAP_CONN_INCLUDED == TRUE)
|
||||
extern void gap_conn_init(void);
|
||||
#endif
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
extern void gap_attr_db_init(void);
|
||||
#endif
|
||||
|
||||
#endif
|
1204
tools/sdk/include/bluedroid/gatt_api.h
Normal file
1204
tools/sdk/include/bluedroid/gatt_api.h
Normal file
File diff suppressed because it is too large
Load Diff
698
tools/sdk/include/bluedroid/gatt_int.h
Normal file
698
tools/sdk/include/bluedroid/gatt_int.h
Normal file
@ -0,0 +1,698 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef GATT_INT_H
|
||||
#define GATT_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
|
||||
#include "bt_trace.h"
|
||||
#include "gatt_api.h"
|
||||
#include "btm_ble_api.h"
|
||||
#include "btu.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define GATT_CREATE_CONN_ID(tcb_idx, gatt_if) ((UINT16) ((((UINT8)(tcb_idx) ) << 8) | ((UINT8) (gatt_if))))
|
||||
#define GATT_GET_TCB_IDX(conn_id) ((UINT8) (((UINT16) (conn_id)) >> 8))
|
||||
#define GATT_GET_GATT_IF(conn_id) ((tGATT_IF)((UINT8) (conn_id)))
|
||||
|
||||
#define GATT_GET_SR_REG_PTR(index) (&gatt_cb.sr_reg[(UINT8) (index)]);
|
||||
#define GATT_TRANS_ID_MAX 0x0fffffff /* 4 MSB is reserved */
|
||||
#define GATT_RSP_BY_APP 0x00
|
||||
#define GATT_RSP_BY_STACK 0x01
|
||||
#define GATT_RSP_DEFAULT GATT_RSP_BY_APP //need to rsp by the app.
|
||||
|
||||
/* security action for GATT write and read request */
|
||||
#define GATT_SEC_NONE 0
|
||||
#define GATT_SEC_OK 1
|
||||
#define GATT_SEC_SIGN_DATA 2 /* compute the signature for the write cmd */
|
||||
#define GATT_SEC_ENCRYPT 3 /* encrypt the link with current key */
|
||||
#define GATT_SEC_ENCRYPT_NO_MITM 4 /* unauthenticated encryption or better */
|
||||
#define GATT_SEC_ENCRYPT_MITM 5 /* authenticated encryption */
|
||||
#define GATT_SEC_ENC_PENDING 6 /* wait for link encryption pending */
|
||||
typedef UINT8 tGATT_SEC_ACTION;
|
||||
|
||||
|
||||
#define GATT_ATTR_OP_SPT_MTU (0x00000001 << 0)
|
||||
#define GATT_ATTR_OP_SPT_FIND_INFO (0x00000001 << 1)
|
||||
#define GATT_ATTR_OP_SPT_FIND_BY_TYPE (0x00000001 << 2)
|
||||
#define GATT_ATTR_OP_SPT_READ_BY_TYPE (0x00000001 << 3)
|
||||
#define GATT_ATTR_OP_SPT_READ (0x00000001 << 4)
|
||||
#define GATT_ATTR_OP_SPT_MULT_READ (0x00000001 << 5)
|
||||
#define GATT_ATTR_OP_SPT_READ_BLOB (0x00000001 << 6)
|
||||
#define GATT_ATTR_OP_SPT_READ_BY_GRP_TYPE (0x00000001 << 7)
|
||||
#define GATT_ATTR_OP_SPT_WRITE (0x00000001 << 8)
|
||||
#define GATT_ATTR_OP_SPT_WRITE_CMD (0x00000001 << 9)
|
||||
#define GATT_ATTR_OP_SPT_PREP_WRITE (0x00000001 << 10)
|
||||
#define GATT_ATTR_OP_SPT_EXE_WRITE (0x00000001 << 11)
|
||||
#define GATT_ATTR_OP_SPT_HDL_VALUE_CONF (0x00000001 << 12)
|
||||
#define GATT_ATTR_OP_SP_SIGN_WRITE (0x00000001 << 13)
|
||||
|
||||
#define GATT_INDEX_INVALID 0xff
|
||||
|
||||
#define GATT_PENDING_REQ_NONE 0
|
||||
|
||||
|
||||
#define GATT_WRITE_CMD_MASK 0xc0 /*0x1100-0000*/
|
||||
#define GATT_AUTH_SIGN_MASK 0x80 /*0x1000-0000*/
|
||||
#define GATT_AUTH_SIGN_LEN 12
|
||||
|
||||
#define GATT_HDR_SIZE 3 /* 1B opcode + 2B handle */
|
||||
|
||||
/* wait for ATT cmd response timeout value */
|
||||
#define GATT_WAIT_FOR_RSP_TOUT 30
|
||||
#define GATT_WAIT_FOR_DISC_RSP_TOUT 5
|
||||
#define GATT_REQ_RETRY_LIMIT 2
|
||||
|
||||
/* characteristic descriptor type */
|
||||
#define GATT_DESCR_EXT_DSCPTOR 1 /* Characteristic Extended Properties */
|
||||
#define GATT_DESCR_USER_DSCPTOR 2 /* Characteristic User Description */
|
||||
#define GATT_DESCR_CLT_CONFIG 3 /* Client Characteristic Configuration */
|
||||
#define GATT_DESCR_SVR_CONFIG 4 /* Server Characteristic Configuration */
|
||||
#define GATT_DESCR_PRES_FORMAT 5 /* Characteristic Presentation Format */
|
||||
#define GATT_DESCR_AGGR_FORMAT 6 /* Characteristic Aggregate Format */
|
||||
#define GATT_DESCR_VALID_RANGE 7 /* Characteristic Valid Range */
|
||||
#define GATT_DESCR_UNKNOWN 0xff
|
||||
|
||||
#define GATT_SEC_FLAG_LKEY_UNAUTHED BTM_SEC_FLAG_LKEY_KNOWN
|
||||
#define GATT_SEC_FLAG_LKEY_AUTHED BTM_SEC_FLAG_LKEY_AUTHED
|
||||
#define GATT_SEC_FLAG_ENCRYPTED BTM_SEC_FLAG_ENCRYPTED
|
||||
typedef UINT8 tGATT_SEC_FLAG;
|
||||
|
||||
/* Find Information Response Type
|
||||
*/
|
||||
#define GATT_INFO_TYPE_PAIR_16 0x01
|
||||
#define GATT_INFO_TYPE_PAIR_128 0x02
|
||||
|
||||
/* GATT client FIND_TYPE_VALUE_Request data */
|
||||
typedef struct {
|
||||
tBT_UUID uuid; /* type of attribute to be found */
|
||||
UINT16 s_handle; /* starting handle */
|
||||
UINT16 e_handle; /* ending handle */
|
||||
UINT16 value_len; /* length of the attribute value */
|
||||
UINT8 value[GATT_MAX_MTU_SIZE]; /* pointer to the attribute value to be found */
|
||||
} tGATT_FIND_TYPE_VALUE;
|
||||
|
||||
/* client request message to ATT protocol
|
||||
*/
|
||||
typedef union {
|
||||
tGATT_READ_BY_TYPE browse; /* read by type request */
|
||||
tGATT_FIND_TYPE_VALUE find_type_value;/* find by type value */
|
||||
tGATT_READ_MULTI read_multi; /* read multiple request */
|
||||
tGATT_READ_PARTIAL read_blob; /* read blob */
|
||||
tGATT_VALUE attr_value; /* write request */
|
||||
/* prepare write */
|
||||
/* write blob */
|
||||
UINT16 handle; /* read, handle value confirmation */
|
||||
UINT16 mtu;
|
||||
tGATT_EXEC_FLAG exec_write; /* execute write */
|
||||
} tGATT_CL_MSG;
|
||||
|
||||
/* error response strucutre */
|
||||
typedef struct {
|
||||
UINT16 handle;
|
||||
UINT8 cmd_code;
|
||||
UINT8 reason;
|
||||
} tGATT_ERROR;
|
||||
|
||||
/* server response message to ATT protocol
|
||||
*/
|
||||
typedef union {
|
||||
/* data type member event */
|
||||
tGATT_VALUE attr_value; /* READ, HANDLE_VALUE_IND, PREPARE_WRITE */
|
||||
/* READ_BLOB, READ_BY_TYPE */
|
||||
tGATT_ERROR error; /* ERROR_RSP */
|
||||
UINT16 handle; /* WRITE, WRITE_BLOB */
|
||||
UINT16 mtu; /* exchange MTU request */
|
||||
} tGATT_SR_MSG;
|
||||
|
||||
/* Characteristic declaration attribute value
|
||||
*/
|
||||
typedef struct {
|
||||
tGATT_CHAR_PROP property;
|
||||
UINT16 char_val_handle;
|
||||
} tGATT_CHAR_DECL;
|
||||
|
||||
/* attribute value maintained in the server database
|
||||
*/
|
||||
typedef union {
|
||||
tBT_UUID uuid; /* service declaration */
|
||||
tGATT_CHAR_DECL char_decl; /* characteristic declaration */
|
||||
tGATT_INCL_SRVC incl_handle; /* included service */
|
||||
tGATT_ATTR_VAL attr_val;
|
||||
} tGATT_ATTR_VALUE;
|
||||
|
||||
/* Attribute UUID type
|
||||
*/
|
||||
#define GATT_ATTR_UUID_TYPE_16 0
|
||||
#define GATT_ATTR_UUID_TYPE_128 1
|
||||
#define GATT_ATTR_UUID_TYPE_32 2
|
||||
typedef UINT8 tGATT_ATTR_UUID_TYPE;
|
||||
|
||||
/* 16 bits UUID Attribute in server database
|
||||
*/
|
||||
typedef struct {
|
||||
void *p_next; /* pointer to the next attribute, either tGATT_ATTR16 or tGATT_ATTR128 */
|
||||
tGATT_ATTR_VALUE *p_value;
|
||||
tGATT_ATTR_UUID_TYPE uuid_type;
|
||||
tGATT_PERM permission;
|
||||
tGATTS_ATTR_CONTROL control;
|
||||
UINT16 handle;
|
||||
UINT16 uuid;
|
||||
} tGATT_ATTR16;
|
||||
|
||||
/* 32 bits UUID Attribute in server database
|
||||
*/
|
||||
typedef struct {
|
||||
void *p_next; /* pointer to the next attribute, either tGATT_ATTR16, tGATT_ATTR32 or tGATT_ATTR128 */
|
||||
tGATT_ATTR_VALUE *p_value;
|
||||
tGATT_ATTR_UUID_TYPE uuid_type;
|
||||
tGATT_PERM permission;
|
||||
tGATTS_ATTR_CONTROL control;
|
||||
UINT16 handle;
|
||||
UINT32 uuid;
|
||||
} tGATT_ATTR32;
|
||||
|
||||
|
||||
/* 128 bits UUID Attribute in server database
|
||||
*/
|
||||
typedef struct {
|
||||
void *p_next; /* pointer to the next attribute, either tGATT_ATTR16 or tGATT_ATTR128 */
|
||||
tGATT_ATTR_VALUE *p_value;
|
||||
tGATT_ATTR_UUID_TYPE uuid_type;
|
||||
tGATT_PERM permission;
|
||||
tGATTS_ATTR_CONTROL control;
|
||||
UINT16 handle;
|
||||
UINT8 uuid[LEN_UUID_128];
|
||||
} tGATT_ATTR128;
|
||||
|
||||
/* Service Database definition
|
||||
*/
|
||||
typedef struct {
|
||||
void *p_attr_list; /* pointer to the first attribute, either tGATT_ATTR16 or tGATT_ATTR128 */
|
||||
UINT8 *p_free_mem; /* Pointer to free memory */
|
||||
BUFFER_Q svc_buffer; /* buffer queue used for service database */
|
||||
UINT32 mem_free; /* Memory still available */
|
||||
UINT16 end_handle; /* Last handle number */
|
||||
UINT16 next_handle; /* Next usable handle value */
|
||||
} tGATT_SVC_DB;
|
||||
|
||||
/* Data Structure used for GATT server */
|
||||
/* A GATT registration record consists of a handle, and 1 or more attributes */
|
||||
/* A service registration information record consists of beginning and ending */
|
||||
/* attribute handle, service UUID and a set of GATT server callback. */
|
||||
typedef struct {
|
||||
tGATT_SVC_DB *p_db; /* pointer to the service database */
|
||||
tBT_UUID app_uuid; /* applicatino UUID */
|
||||
UINT32 sdp_handle; /* primamry service SDP handle */
|
||||
UINT16 service_instance; /* service instance number */
|
||||
UINT16 type; /* service type UUID, primary or secondary */
|
||||
UINT16 s_hdl; /* service starting handle */
|
||||
UINT16 e_hdl; /* service ending handle */
|
||||
tGATT_IF gatt_if; /* this service is belong to which application */
|
||||
BOOLEAN in_use;
|
||||
} tGATT_SR_REG;
|
||||
|
||||
#define GATT_LISTEN_TO_ALL 0xff
|
||||
#define GATT_LISTEN_TO_NONE 0
|
||||
|
||||
/* Data Structure used for GATT server */
|
||||
/* An GATT registration record consists of a handle, and 1 or more attributes */
|
||||
/* A service registration information record consists of beginning and ending */
|
||||
/* attribute handle, service UUID and a set of GATT server callback. */
|
||||
|
||||
typedef struct {
|
||||
tBT_UUID app_uuid128;
|
||||
tGATT_CBACK app_cb;
|
||||
tGATT_IF gatt_if; /* one based */
|
||||
BOOLEAN in_use;
|
||||
UINT8 listening; /* if adv for all has been enabled */
|
||||
} tGATT_REG;
|
||||
|
||||
|
||||
|
||||
|
||||
/* command queue for each connection */
|
||||
typedef struct {
|
||||
BT_HDR *p_cmd;
|
||||
UINT16 clcb_idx;
|
||||
UINT8 op_code;
|
||||
BOOLEAN to_send;
|
||||
} tGATT_CMD_Q;
|
||||
|
||||
|
||||
#if GATT_MAX_SR_PROFILES <= 8
|
||||
typedef UINT8 tGATT_APP_MASK;
|
||||
#elif GATT_MAX_SR_PROFILES <= 16
|
||||
typedef UINT16 tGATT_APP_MASK;
|
||||
#elif GATT_MAX_SR_PROFILES <= 32
|
||||
typedef UINT32 tGATT_APP_MASK;
|
||||
#endif
|
||||
|
||||
/* command details for each connection */
|
||||
typedef struct {
|
||||
BT_HDR *p_rsp_msg;
|
||||
UINT32 trans_id;
|
||||
tGATT_READ_MULTI multi_req;
|
||||
BUFFER_Q multi_rsp_q;
|
||||
UINT16 handle;
|
||||
UINT8 op_code;
|
||||
UINT8 status;
|
||||
UINT8 cback_cnt[GATT_MAX_APPS];
|
||||
} tGATT_SR_CMD;
|
||||
|
||||
#define GATT_CH_CLOSE 0
|
||||
#define GATT_CH_CLOSING 1
|
||||
#define GATT_CH_CONN 2
|
||||
#define GATT_CH_CFG 3
|
||||
#define GATT_CH_OPEN 4
|
||||
|
||||
typedef UINT8 tGATT_CH_STATE;
|
||||
|
||||
#define GATT_GATT_START_HANDLE 1
|
||||
#define GATT_GAP_START_HANDLE 20
|
||||
#define GATT_APP_START_HANDLE 40
|
||||
|
||||
typedef struct hdl_cfg {
|
||||
UINT16 gatt_start_hdl;
|
||||
UINT16 gap_start_hdl;
|
||||
UINT16 app_start_hdl;
|
||||
} tGATT_HDL_CFG;
|
||||
|
||||
typedef struct hdl_list_elem {
|
||||
struct hdl_list_elem *p_next;
|
||||
struct hdl_list_elem *p_prev;
|
||||
tGATTS_HNDL_RANGE asgn_range; /* assigned handle range */
|
||||
tGATT_SVC_DB svc_db;
|
||||
BOOLEAN in_use;
|
||||
} tGATT_HDL_LIST_ELEM;
|
||||
|
||||
typedef struct {
|
||||
tGATT_HDL_LIST_ELEM *p_first;
|
||||
tGATT_HDL_LIST_ELEM *p_last;
|
||||
UINT16 count;
|
||||
} tGATT_HDL_LIST_INFO;
|
||||
|
||||
|
||||
typedef struct srv_list_elem {
|
||||
struct srv_list_elem *p_next;
|
||||
struct srv_list_elem *p_prev;
|
||||
UINT16 s_hdl;
|
||||
UINT8 i_sreg;
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN is_primary;
|
||||
} tGATT_SRV_LIST_ELEM;
|
||||
|
||||
|
||||
typedef struct {
|
||||
tGATT_SRV_LIST_ELEM *p_last_primary;
|
||||
tGATT_SRV_LIST_ELEM *p_first;
|
||||
tGATT_SRV_LIST_ELEM *p_last;
|
||||
UINT16 count;
|
||||
} tGATT_SRV_LIST_INFO;
|
||||
|
||||
typedef struct {
|
||||
BUFFER_Q pending_enc_clcb; /* pending encryption channel q */
|
||||
tGATT_SEC_ACTION sec_act;
|
||||
BD_ADDR peer_bda;
|
||||
tBT_TRANSPORT transport;
|
||||
UINT32 trans_id;
|
||||
|
||||
UINT16 att_lcid; /* L2CAP channel ID for ATT */
|
||||
UINT16 payload_size;
|
||||
|
||||
tGATT_CH_STATE ch_state;
|
||||
UINT8 ch_flags;
|
||||
|
||||
tGATT_IF app_hold_link[GATT_MAX_APPS];
|
||||
|
||||
/* server needs */
|
||||
/* server response data */
|
||||
tGATT_SR_CMD sr_cmd;
|
||||
UINT16 indicate_handle;
|
||||
BUFFER_Q pending_ind_q;
|
||||
|
||||
TIMER_LIST_ENT conf_timer_ent; /* peer confirm to indication timer */
|
||||
|
||||
UINT8 prep_cnt[GATT_MAX_APPS];
|
||||
UINT8 ind_count;
|
||||
|
||||
tGATT_CMD_Q cl_cmd_q[GATT_CL_MAX_LCB];
|
||||
TIMER_LIST_ENT ind_ack_timer_ent; /* local app confirm to indication timer */
|
||||
UINT8 pending_cl_req;
|
||||
UINT8 next_slot_inq; /* index of next available slot in queue */
|
||||
|
||||
BOOLEAN in_use;
|
||||
UINT8 tcb_idx;
|
||||
} tGATT_TCB;
|
||||
|
||||
|
||||
/* logic channel */
|
||||
typedef struct {
|
||||
UINT16 next_disc_start_hdl; /* starting handle for the next inc srvv discovery */
|
||||
tGATT_DISC_RES result;
|
||||
BOOLEAN wait_for_read_rsp;
|
||||
} tGATT_READ_INC_UUID128;
|
||||
typedef struct {
|
||||
tGATT_TCB *p_tcb; /* associated TCB of this CLCB */
|
||||
tGATT_REG *p_reg; /* owner of this CLCB */
|
||||
UINT8 sccb_idx;
|
||||
UINT8 *p_attr_buf; /* attribute buffer for read multiple, prepare write */
|
||||
tBT_UUID uuid;
|
||||
UINT16 conn_id; /* connection handle */
|
||||
UINT16 clcb_idx;
|
||||
UINT16 s_handle; /* starting handle of the active request */
|
||||
UINT16 e_handle; /* ending handle of the active request */
|
||||
UINT16 counter; /* used as offset, attribute length, num of prepare write */
|
||||
UINT16 start_offset;
|
||||
tGATT_AUTH_REQ auth_req; /* authentication requirement */
|
||||
UINT8 operation; /* one logic channel can have one operation active */
|
||||
UINT8 op_subtype; /* operation subtype */
|
||||
UINT8 status; /* operation status */
|
||||
BOOLEAN first_read_blob_after_read;
|
||||
tGATT_READ_INC_UUID128 read_uuid128;
|
||||
BOOLEAN in_use;
|
||||
TIMER_LIST_ENT rsp_timer_ent; /* peer response timer */
|
||||
UINT8 retry_count;
|
||||
|
||||
} tGATT_CLCB;
|
||||
|
||||
typedef struct {
|
||||
tGATT_CLCB *p_clcb;
|
||||
} tGATT_PENDING_ENC_CLCB;
|
||||
|
||||
|
||||
#define GATT_SIGN_WRITE 1
|
||||
#define GATT_VERIFY_SIGN_DATA 2
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tGATT_CLCB *p_clcb;
|
||||
} tGATT_SIGN_WRITE_OP;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tGATT_TCB *p_tcb;
|
||||
BT_HDR *p_data;
|
||||
|
||||
} tGATT_VERIFY_SIGN_OP;
|
||||
|
||||
|
||||
typedef struct {
|
||||
UINT16 clcb_idx;
|
||||
BOOLEAN in_use;
|
||||
} tGATT_SCCB;
|
||||
|
||||
typedef struct {
|
||||
UINT16 handle;
|
||||
UINT16 uuid;
|
||||
UINT32 service_change;
|
||||
} tGATT_SVC_CHG;
|
||||
|
||||
typedef struct {
|
||||
tGATT_IF gatt_if[GATT_MAX_APPS];
|
||||
tGATT_IF listen_gif[GATT_MAX_APPS];
|
||||
BD_ADDR remote_bda;
|
||||
BOOLEAN in_use;
|
||||
} tGATT_BG_CONN_DEV;
|
||||
|
||||
#define GATT_SVC_CHANGED_CONNECTING 1 /* wait for connection */
|
||||
#define GATT_SVC_CHANGED_SERVICE 2 /* GATT service discovery */
|
||||
#define GATT_SVC_CHANGED_CHARACTERISTIC 3 /* service change char discovery */
|
||||
#define GATT_SVC_CHANGED_DESCRIPTOR 4 /* service change CCC discoery */
|
||||
#define GATT_SVC_CHANGED_CONFIGURE_CCCD 5 /* config CCC */
|
||||
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN connected;
|
||||
BD_ADDR bda;
|
||||
tBT_TRANSPORT transport;
|
||||
|
||||
/* GATT service change CCC related variables */
|
||||
UINT8 ccc_stage;
|
||||
UINT8 ccc_result;
|
||||
UINT16 s_handle;
|
||||
UINT16 e_handle;
|
||||
} tGATT_PROFILE_CLCB;
|
||||
|
||||
typedef struct {
|
||||
tGATT_TCB tcb[GATT_MAX_PHY_CHANNEL];
|
||||
BUFFER_Q sign_op_queue;
|
||||
|
||||
tGATT_SR_REG sr_reg[GATT_MAX_SR_PROFILES];
|
||||
UINT16 next_handle; /* next available handle */
|
||||
tGATT_SVC_CHG gattp_attr; /* GATT profile attribute service change */
|
||||
tGATT_IF gatt_if;
|
||||
tGATT_HDL_LIST_INFO hdl_list_info;
|
||||
tGATT_HDL_LIST_ELEM hdl_list[GATT_MAX_SR_PROFILES];
|
||||
tGATT_SRV_LIST_INFO srv_list_info;
|
||||
tGATT_SRV_LIST_ELEM srv_list[GATT_MAX_SR_PROFILES];
|
||||
|
||||
BUFFER_Q srv_chg_clt_q; /* service change clients queue */
|
||||
BUFFER_Q pending_new_srv_start_q; /* pending new service start queue */
|
||||
tGATT_REG cl_rcb[GATT_MAX_APPS];
|
||||
tGATT_CLCB clcb[GATT_CL_MAX_LCB]; /* connection link control block*/
|
||||
tGATT_SCCB sccb[GATT_MAX_SCCB]; /* sign complete callback function GATT_MAX_SCCB <= GATT_CL_MAX_LCB */
|
||||
UINT8 trace_level;
|
||||
UINT16 def_mtu_size;
|
||||
|
||||
#if GATT_CONFORMANCE_TESTING == TRUE
|
||||
BOOLEAN enable_err_rsp;
|
||||
UINT8 req_op_code;
|
||||
UINT8 err_status;
|
||||
UINT16 handle;
|
||||
#endif
|
||||
|
||||
tGATT_PROFILE_CLCB profile_clcb[GATT_MAX_APPS];
|
||||
UINT16 handle_of_h_r; /* Handle of the handles reused characteristic value */
|
||||
|
||||
tGATT_APPL_INFO cb_info;
|
||||
|
||||
|
||||
|
||||
tGATT_HDL_CFG hdl_cfg;
|
||||
tGATT_BG_CONN_DEV bgconn_dev[GATT_MAX_BG_CONN_DEV];
|
||||
|
||||
} tGATT_CB;
|
||||
|
||||
|
||||
#define GATT_SIZE_OF_SRV_CHG_HNDL_RANGE 4
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Global GATT data */
|
||||
#if GATT_DYNAMIC_MEMORY == FALSE
|
||||
extern tGATT_CB gatt_cb;
|
||||
#else
|
||||
extern tGATT_CB *gatt_cb_ptr;
|
||||
#define gatt_cb (*gatt_cb_ptr)
|
||||
#endif
|
||||
|
||||
#if GATT_CONFORMANCE_TESTING == TRUE
|
||||
extern void gatt_set_err_rsp(BOOLEAN enable, UINT8 req_op_code, UINT8 err_status);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* internal functions */
|
||||
extern void gatt_init (void);
|
||||
extern void gatt_free(void);
|
||||
|
||||
/* from gatt_main.c */
|
||||
extern BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb);
|
||||
extern BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT transport);
|
||||
extern BOOLEAN gatt_connect (BD_ADDR rem_bda, tGATT_TCB *p_tcb, tBT_TRANSPORT transport);
|
||||
extern void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf);
|
||||
extern void gatt_update_app_use_link_flag ( tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN is_add, BOOLEAN check_acl_link);
|
||||
|
||||
extern void gatt_profile_db_init(void);
|
||||
extern void gatt_set_ch_state(tGATT_TCB *p_tcb, tGATT_CH_STATE ch_state);
|
||||
extern tGATT_CH_STATE gatt_get_ch_state(tGATT_TCB *p_tcb);
|
||||
extern void gatt_init_srv_chg(void);
|
||||
extern void gatt_proc_srv_chg (void);
|
||||
extern void gatt_send_srv_chg_ind (BD_ADDR peer_bda);
|
||||
extern void gatt_chk_srv_chg(tGATTS_SRV_CHG *p_srv_chg_clt);
|
||||
extern void gatt_add_a_bonded_dev_for_srv_chg (BD_ADDR bda);
|
||||
|
||||
/* from gatt_attr.c */
|
||||
extern UINT16 gatt_profile_find_conn_id_by_bd_addr(BD_ADDR bda);
|
||||
|
||||
|
||||
/* Functions provided by att_protocol.c */
|
||||
extern tGATT_STATUS attp_send_cl_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code, tGATT_CL_MSG *p_msg);
|
||||
extern BT_HDR *attp_build_sr_msg(tGATT_TCB *p_tcb, UINT8 op_code, tGATT_SR_MSG *p_msg);
|
||||
extern tGATT_STATUS attp_send_sr_msg (tGATT_TCB *p_tcb, BT_HDR *p_msg);
|
||||
extern tGATT_STATUS attp_send_msg_to_l2cap(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP);
|
||||
|
||||
/* utility functions */
|
||||
extern UINT8 *gatt_dbg_op_name(UINT8 op_code);
|
||||
extern UINT32 gatt_add_sdp_record (tBT_UUID *p_uuid, UINT16 start_hdl, UINT16 end_hdl);
|
||||
extern BOOLEAN gatt_parse_uuid_from_cmd(tBT_UUID *p_uuid, UINT16 len, UINT8 **p_data);
|
||||
extern UINT8 gatt_build_uuid_to_stream(UINT8 **p_dst, tBT_UUID uuid);
|
||||
extern BOOLEAN gatt_uuid_compare(tBT_UUID src, tBT_UUID tar);
|
||||
extern void gatt_convert_uuid32_to_uuid128(UINT8 uuid_128[LEN_UUID_128], UINT32 uuid_32);
|
||||
extern void gatt_sr_get_sec_info(BD_ADDR rem_bda, tBT_TRANSPORT transport, UINT8 *p_sec_flag, UINT8 *p_key_size);
|
||||
extern void gatt_start_rsp_timer(UINT16 clcb_idx);
|
||||
extern void gatt_start_conf_timer(tGATT_TCB *p_tcb);
|
||||
extern void gatt_rsp_timeout(TIMER_LIST_ENT *p_tle);
|
||||
extern void gatt_ind_ack_timeout(TIMER_LIST_ENT *p_tle);
|
||||
extern void gatt_start_ind_ack_timer(tGATT_TCB *p_tcb);
|
||||
extern tGATT_STATUS gatt_send_error_rsp(tGATT_TCB *p_tcb, UINT8 err_code, UINT8 op_code, UINT16 handle, BOOLEAN deq);
|
||||
extern void gatt_dbg_display_uuid(tBT_UUID bt_uuid);
|
||||
extern tGATT_PENDING_ENC_CLCB *gatt_add_pending_enc_channel_clcb(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb );
|
||||
|
||||
extern tGATTS_PENDING_NEW_SRV_START *gatt_sr_is_new_srv_chg(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst);
|
||||
|
||||
extern BOOLEAN gatt_is_srv_chg_ind_pending (tGATT_TCB *p_tcb);
|
||||
extern tGATTS_SRV_CHG *gatt_is_bda_in_the_srv_chg_clt_list (BD_ADDR bda);
|
||||
|
||||
extern BOOLEAN gatt_find_the_connected_bda(UINT8 start_idx, BD_ADDR bda, UINT8 *p_found_idx, tBT_TRANSPORT *p_transport);
|
||||
extern void gatt_set_srv_chg(void);
|
||||
extern void gatt_delete_dev_from_srv_chg_clt_list(BD_ADDR bd_addr);
|
||||
extern tGATT_VALUE *gatt_add_pending_ind(tGATT_TCB *p_tcb, tGATT_VALUE *p_ind);
|
||||
extern tGATTS_PENDING_NEW_SRV_START *gatt_add_pending_new_srv_start( tGATTS_HNDL_RANGE *p_new_srv_start);
|
||||
extern void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id);
|
||||
extern BOOLEAN gatt_update_listen_mode(void);
|
||||
extern BOOLEAN gatt_cl_send_next_cmd_inq(tGATT_TCB *p_tcb);
|
||||
|
||||
/* reserved handle list */
|
||||
extern tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_app_id (tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst);
|
||||
extern tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_handle(UINT16 handle);
|
||||
extern tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_attr_handle(UINT16 attr_handle);
|
||||
extern tGATT_HDL_LIST_ELEM *gatt_alloc_hdl_buffer(void);
|
||||
extern void gatt_free_hdl_buffer(tGATT_HDL_LIST_ELEM *p);
|
||||
extern BOOLEAN gatt_is_last_attribute(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM *p_start, tBT_UUID value);
|
||||
extern void gatt_update_last_pri_srv_info(tGATT_SRV_LIST_INFO *p_list);
|
||||
extern BOOLEAN gatt_add_a_srv_to_list(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM *p_new);
|
||||
extern BOOLEAN gatt_remove_a_srv_from_list(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_ELEM *p_remove);
|
||||
extern BOOLEAN gatt_add_an_item_to_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIST_ELEM *p_new);
|
||||
extern BOOLEAN gatt_remove_an_item_from_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIST_ELEM *p_remove);
|
||||
extern tGATTS_SRV_CHG *gatt_add_srv_chg_clt(tGATTS_SRV_CHG *p_srv_chg);
|
||||
|
||||
/* for background connection */
|
||||
extern BOOLEAN gatt_update_auto_connect_dev (tGATT_IF gatt_if, BOOLEAN add, BD_ADDR bd_addr, BOOLEAN is_initiator);
|
||||
extern BOOLEAN gatt_is_bg_dev_for_app(tGATT_BG_CONN_DEV *p_dev, tGATT_IF gatt_if);
|
||||
extern BOOLEAN gatt_remove_bg_dev_for_app(tGATT_IF gatt_if, BD_ADDR bd_addr);
|
||||
extern UINT8 gatt_get_num_apps_for_bg_dev(BD_ADDR bd_addr);
|
||||
extern BOOLEAN gatt_find_app_for_bg_dev(BD_ADDR bd_addr, tGATT_IF *p_gatt_if);
|
||||
extern tGATT_BG_CONN_DEV *gatt_find_bg_dev(BD_ADDR remote_bda);
|
||||
extern void gatt_deregister_bgdev_list(tGATT_IF gatt_if);
|
||||
extern void gatt_reset_bgdev_list(void);
|
||||
|
||||
/* server function */
|
||||
extern UINT8 gatt_sr_find_i_rcb_by_handle(UINT16 handle);
|
||||
extern UINT8 gatt_sr_find_i_rcb_by_app_id(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst);
|
||||
extern UINT8 gatt_sr_alloc_rcb(tGATT_HDL_LIST_ELEM *p_list);
|
||||
extern tGATT_STATUS gatt_sr_process_app_rsp (tGATT_TCB *p_tcb, tGATT_IF gatt_if, UINT32 trans_id, UINT8 op_code, tGATT_STATUS status, tGATTS_RSP *p_msg);
|
||||
extern void gatt_server_handle_client_req (tGATT_TCB *p_tcb, UINT8 op_code,
|
||||
UINT16 len, UINT8 *p_data);
|
||||
extern void gatt_sr_send_req_callback(UINT16 conn_id, UINT32 trans_id,
|
||||
UINT8 op_code, tGATTS_DATA *p_req_data);
|
||||
extern UINT32 gatt_sr_enqueue_cmd (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 handle);
|
||||
extern BOOLEAN gatt_cancel_open(tGATT_IF gatt_if, BD_ADDR bda);
|
||||
|
||||
/* */
|
||||
|
||||
extern tGATT_REG *gatt_get_regcb (tGATT_IF gatt_if);
|
||||
extern BOOLEAN gatt_is_clcb_allocated (UINT16 conn_id);
|
||||
extern tGATT_CLCB *gatt_clcb_alloc (UINT16 conn_id);
|
||||
extern void gatt_clcb_dealloc (tGATT_CLCB *p_clcb);
|
||||
|
||||
extern void gatt_sr_copy_prep_cnt_to_cback_cnt(tGATT_TCB *p_tcb );
|
||||
extern BOOLEAN gatt_sr_is_cback_cnt_zero(tGATT_TCB *p_tcb );
|
||||
extern BOOLEAN gatt_sr_is_prep_cnt_zero(tGATT_TCB *p_tcb );
|
||||
extern void gatt_sr_reset_cback_cnt(tGATT_TCB *p_tcb );
|
||||
extern void gatt_sr_reset_prep_cnt(tGATT_TCB *p_tcb );
|
||||
extern void gatt_sr_update_cback_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN is_inc, BOOLEAN is_reset_first);
|
||||
extern void gatt_sr_update_prep_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN is_inc, BOOLEAN is_reset_first);
|
||||
|
||||
extern BOOLEAN gatt_find_app_hold_link(tGATT_TCB *p_tcb, UINT8 start_idx, UINT8 *p_found_idx, tGATT_IF *p_gatt_if);
|
||||
extern UINT8 gatt_num_apps_hold_link(tGATT_TCB *p_tcb);
|
||||
extern UINT8 gatt_num_clcb_by_bd_addr(BD_ADDR bda);
|
||||
extern tGATT_TCB *gatt_find_tcb_by_cid(UINT16 lcid);
|
||||
extern tGATT_TCB *gatt_allocate_tcb_by_bdaddr(BD_ADDR bda, tBT_TRANSPORT transport);
|
||||
extern tGATT_TCB *gatt_get_tcb_by_idx(UINT8 tcb_idx);
|
||||
extern tGATT_TCB *gatt_find_tcb_by_addr(BD_ADDR bda, tBT_TRANSPORT transport);
|
||||
extern BOOLEAN gatt_send_ble_burst_data (BD_ADDR remote_bda, BT_HDR *p_buf);
|
||||
|
||||
/* GATT client functions */
|
||||
extern void gatt_dequeue_sr_cmd (tGATT_TCB *p_tcb);
|
||||
extern UINT8 gatt_send_write_msg(tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code, UINT16 handle,
|
||||
UINT16 len, UINT16 offset, UINT8 *p_data);
|
||||
extern void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport);
|
||||
extern void gatt_end_operation(tGATT_CLCB *p_clcb, tGATT_STATUS status, void *p_data);
|
||||
|
||||
extern void gatt_act_discovery(tGATT_CLCB *p_clcb);
|
||||
extern void gatt_act_read(tGATT_CLCB *p_clcb, UINT16 offset);
|
||||
extern void gatt_act_write(tGATT_CLCB *p_clcb, UINT8 sec_act);
|
||||
extern UINT8 gatt_act_send_browse(tGATT_TCB *p_tcb, UINT16 index, UINT8 op, UINT16 s_handle, UINT16 e_handle,
|
||||
tBT_UUID uuid);
|
||||
extern tGATT_CLCB *gatt_cmd_dequeue(tGATT_TCB *p_tcb, UINT8 *p_opcode);
|
||||
extern BOOLEAN gatt_cmd_enq(tGATT_TCB *p_tcb, UINT16 clcb_idx, BOOLEAN to_send, UINT8 op_code, BT_HDR *p_buf);
|
||||
extern void gatt_client_handle_server_rsp (tGATT_TCB *p_tcb, UINT8 op_code,
|
||||
UINT16 len, UINT8 *p_data);
|
||||
extern void gatt_send_queue_write_cancel (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, tGATT_EXEC_FLAG flag);
|
||||
|
||||
/* gatt_auth.c */
|
||||
extern BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb);
|
||||
extern void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf);
|
||||
extern tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb );
|
||||
extern tGATT_STATUS gatt_get_link_encrypt_status(tGATT_TCB *p_tcb);
|
||||
extern tGATT_SEC_ACTION gatt_get_sec_act(tGATT_TCB *p_tcb);
|
||||
extern void gatt_set_sec_act(tGATT_TCB *p_tcb, tGATT_SEC_ACTION sec_act);
|
||||
|
||||
/* gatt_db.c */
|
||||
extern BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID *p_service, BOOLEAN is_pri, UINT16 s_hdl, UINT16 num_handle);
|
||||
extern UINT16 gatts_add_included_service (tGATT_SVC_DB *p_db, UINT16 s_handle, UINT16 e_handle, tBT_UUID service);
|
||||
extern UINT16 gatts_add_characteristic (tGATT_SVC_DB *p_db, tGATT_PERM perm,
|
||||
tGATT_CHAR_PROP property,
|
||||
tBT_UUID *p_char_uuid, tGATT_ATTR_VAL *attr_val,
|
||||
tGATTS_ATTR_CONTROL *control);
|
||||
extern UINT16 gatts_add_char_descr (tGATT_SVC_DB *p_db, tGATT_PERM perm,
|
||||
tBT_UUID *p_dscp_uuid, tGATT_ATTR_VAL *attr_val,
|
||||
tGATTS_ATTR_CONTROL *control);
|
||||
|
||||
extern tGATT_STATUS gatts_set_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
||||
UINT16 length, UINT8 *value);
|
||||
|
||||
extern tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
||||
UINT16 *length, UINT8 **value);
|
||||
extern BOOLEAN gatts_is_auto_response(UINT16 attr_handle);
|
||||
extern tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb, tGATT_SVC_DB *p_db, UINT8 op_code, BT_HDR *p_rsp, UINT16 s_handle,
|
||||
UINT16 e_handle, tBT_UUID type, UINT16 *p_len, tGATT_SEC_FLAG sec_flag, UINT8 key_size, UINT32 trans_id, UINT16 *p_cur_handle);
|
||||
extern tGATT_STATUS gatts_read_attr_value_by_handle(tGATT_TCB *p_tcb, tGATT_SVC_DB *p_db, UINT8 op_code, UINT16 handle, UINT16 offset,
|
||||
UINT8 *p_value, UINT16 *p_len, UINT16 mtu, tGATT_SEC_FLAG sec_flag, UINT8 key_size, UINT32 trans_id);
|
||||
extern tGATT_STATUS gatts_write_attr_value_by_handle(tGATT_SVC_DB *p_db,
|
||||
UINT16 handle, UINT16 offset,
|
||||
UINT8 *p_value, UINT16 len);
|
||||
extern tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code, UINT16 handle, UINT16 offset, UINT8 *p_data,
|
||||
UINT16 len, tGATT_SEC_FLAG sec_flag, UINT8 key_size);
|
||||
extern tGATT_STATUS gatts_read_attr_perm_check(tGATT_SVC_DB *p_db, BOOLEAN is_long, UINT16 handle, tGATT_SEC_FLAG sec_flag, UINT8 key_size);
|
||||
extern void gatts_update_srv_list_elem(UINT8 i_sreg, UINT16 handle, BOOLEAN is_primary);
|
||||
extern tBT_UUID *gatts_get_service_uuid (tGATT_SVC_DB *p_db);
|
||||
|
||||
extern void gatt_reset_bgdev_list(void);
|
||||
#endif
|
124
tools/sdk/include/bluedroid/gattdefs.h
Normal file
124
tools/sdk/include/bluedroid/gattdefs.h
Normal file
@ -0,0 +1,124 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-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 internally used ATT definitions
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _GATTDEFS_H
|
||||
#define _GATTDEFS_H
|
||||
|
||||
#define GATT_ILLEGAL_UUID 0
|
||||
|
||||
/* GATT attribute types
|
||||
*/
|
||||
#define GATT_UUID_PRI_SERVICE 0x2800
|
||||
#define GATT_UUID_SEC_SERVICE 0x2801
|
||||
#define GATT_UUID_INCLUDE_SERVICE 0x2802
|
||||
#define GATT_UUID_CHAR_DECLARE 0x2803 /* Characteristic Declaration*/
|
||||
|
||||
#define GATT_UUID_CHAR_EXT_PROP 0x2900 /* Characteristic Extended Properties */
|
||||
#define GATT_UUID_CHAR_DESCRIPTION 0x2901 /* Characteristic User Description*/
|
||||
#define GATT_UUID_CHAR_CLIENT_CONFIG 0x2902 /* Client Characteristic Configuration */
|
||||
#define GATT_UUID_CHAR_SRVR_CONFIG 0x2903 /* Server Characteristic Configuration */
|
||||
#define GATT_UUID_CHAR_PRESENT_FORMAT 0x2904 /* Characteristic Presentation Format*/
|
||||
#define GATT_UUID_CHAR_AGG_FORMAT 0x2905 /* Characteristic Aggregate Format*/
|
||||
#define GATT_UUID_CHAR_VALID_RANGE 0x2906 /* Characteristic Valid Range */
|
||||
#define GATT_UUID_EXT_RPT_REF_DESCR 0x2907
|
||||
#define GATT_UUID_RPT_REF_DESCR 0x2908
|
||||
|
||||
|
||||
/* GAP Profile Attributes
|
||||
*/
|
||||
#define GATT_UUID_GAP_DEVICE_NAME 0x2A00
|
||||
#define GATT_UUID_GAP_ICON 0x2A01
|
||||
#define GATT_UUID_GAP_PREF_CONN_PARAM 0x2A04
|
||||
#define GATT_UUID_GAP_CENTRAL_ADDR_RESOL 0x2AA6
|
||||
|
||||
/* Attribute Profile Attribute UUID */
|
||||
#define GATT_UUID_GATT_SRV_CHGD 0x2A05
|
||||
/* Attribute Protocol Test */
|
||||
|
||||
/* Link Loss Service */
|
||||
#define GATT_UUID_ALERT_LEVEL 0x2A06 /* Alert Level */
|
||||
#define GATT_UUID_TX_POWER_LEVEL 0x2A07 /* TX power level */
|
||||
|
||||
/* Time Profile */
|
||||
/* Current Time Service */
|
||||
#define GATT_UUID_CURRENT_TIME 0x2A2B /* Current Time */
|
||||
#define GATT_UUID_LOCAL_TIME_INFO 0x2A0F /* Local time info */
|
||||
#define GATT_UUID_REF_TIME_INFO 0x2A14 /* reference time information */
|
||||
|
||||
/* NwA Profile */
|
||||
#define GATT_UUID_NW_STATUS 0x2A18 /* network availability status */
|
||||
#define GATT_UUID_NW_TRIGGER 0x2A1A /* Network availability trigger */
|
||||
|
||||
/* phone alert */
|
||||
#define GATT_UUID_ALERT_STATUS 0x2A3F /* alert status */
|
||||
#define GATT_UUID_RINGER_CP 0x2A40 /* ringer control point */
|
||||
#define GATT_UUID_RINGER_SETTING 0x2A41 /* ringer setting */
|
||||
|
||||
/* Glucose Service */
|
||||
#define GATT_UUID_GM_MEASUREMENT 0x2A18
|
||||
#define GATT_UUID_GM_CONTEXT 0x2A34
|
||||
#define GATT_UUID_GM_CONTROL_POINT 0x2A52
|
||||
#define GATT_UUID_GM_FEATURE 0x2A51
|
||||
|
||||
/* device infor characteristic */
|
||||
#define GATT_UUID_SYSTEM_ID 0x2A23
|
||||
#define GATT_UUID_MODEL_NUMBER_STR 0x2A24
|
||||
#define GATT_UUID_SERIAL_NUMBER_STR 0x2A25
|
||||
#define GATT_UUID_FW_VERSION_STR 0x2A26
|
||||
#define GATT_UUID_HW_VERSION_STR 0x2A27
|
||||
#define GATT_UUID_SW_VERSION_STR 0x2A28
|
||||
#define GATT_UUID_MANU_NAME 0x2A29
|
||||
#define GATT_UUID_IEEE_DATA 0x2A2A
|
||||
#define GATT_UUID_PNP_ID 0x2A50
|
||||
|
||||
/* HID characteristics */
|
||||
#define GATT_UUID_HID_INFORMATION 0x2A4A
|
||||
#define GATT_UUID_HID_REPORT_MAP 0x2A4B
|
||||
#define GATT_UUID_HID_CONTROL_POINT 0x2A4C
|
||||
#define GATT_UUID_HID_REPORT 0x2A4D
|
||||
#define GATT_UUID_HID_PROTO_MODE 0x2A4E
|
||||
#define GATT_UUID_HID_BT_KB_INPUT 0x2A22
|
||||
#define GATT_UUID_HID_BT_KB_OUTPUT 0x2A32
|
||||
#define GATT_UUID_HID_BT_MOUSE_INPUT 0x2A33
|
||||
|
||||
/* Battery Service char */
|
||||
#define GATT_UUID_BATTERY_LEVEL 0x2A19
|
||||
|
||||
#define GATT_UUID_SC_CONTROL_POINT 0x2A55
|
||||
#define GATT_UUID_SENSOR_LOCATION 0x2A5D
|
||||
|
||||
/* RUNNERS SPEED AND CADENCE SERVICE */
|
||||
#define GATT_UUID_RSC_MEASUREMENT 0x2A53
|
||||
#define GATT_UUID_RSC_FEATURE 0x2A54
|
||||
|
||||
/* CYCLING SPEED AND CADENCE SERVICE */
|
||||
#define GATT_UUID_CSC_MEASUREMENT 0x2A5B
|
||||
#define GATT_UUID_CSC_FEATURE 0x2A5C
|
||||
|
||||
|
||||
/* Scan Parameter charatceristics */
|
||||
#define GATT_UUID_SCAN_INT_WINDOW 0x2A4F
|
||||
#define GATT_UUID_SCAN_REFRESH 0x2A31
|
||||
|
||||
#endif
|
132
tools/sdk/include/bluedroid/gki.h
Normal file
132
tools/sdk/include/bluedroid/gki.h
Normal file
@ -0,0 +1,132 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _GKI_H_
|
||||
#define _GKI_H_
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "bt_types.h"
|
||||
#include "gki_common.h"
|
||||
#include "gki_int.h"
|
||||
#include "allocator.h"
|
||||
|
||||
#define ALIGN_POOL(pl_size) ( (((pl_size) + 3) / sizeof(UINT32)) * sizeof(UINT32))
|
||||
#define BUFFER_HDR_SIZE (sizeof(BUFFER_HDR_T)) /* Offset past header */
|
||||
#define BUFFER_PADDING_SIZE (sizeof(BUFFER_HDR_T) + sizeof(UINT32)) /* Header + Magic Number */
|
||||
#define MAGIC_NO 0xDDBADDBA
|
||||
|
||||
#define BUF_STATUS_FREE 0
|
||||
#define BUF_STATUS_UNLINKED 1
|
||||
#define BUF_STATUS_QUEUED 2
|
||||
|
||||
/* Timer list entry callback type
|
||||
*/
|
||||
typedef void (TIMER_CBACK)(void *p_tle);
|
||||
#ifndef TIMER_PARAM_TYPE
|
||||
#define TIMER_PARAM_TYPE UINT32
|
||||
#endif
|
||||
/* Define a timer list entry
|
||||
*/
|
||||
typedef struct _tle {
|
||||
struct _tle *p_next;
|
||||
struct _tle *p_prev;
|
||||
TIMER_CBACK *p_cback;
|
||||
INT32 ticks;
|
||||
INT32 ticks_initial;
|
||||
TIMER_PARAM_TYPE param;
|
||||
TIMER_PARAM_TYPE data;
|
||||
UINT16 event;
|
||||
UINT8 in_use;
|
||||
} TIMER_LIST_ENT;
|
||||
|
||||
/***********************************************************************
|
||||
** This queue is a general purpose buffer queue, for application use.
|
||||
*/
|
||||
typedef struct {
|
||||
void *_p_first;
|
||||
void *_p_last;
|
||||
UINT16 _count;
|
||||
} BUFFER_Q;
|
||||
|
||||
#define GKI_PUBLIC_POOL 0 /* General pool accessible to GKI_getbuf() */
|
||||
#define GKI_RESTRICTED_POOL 1 /* Inaccessible pool to GKI_getbuf() */
|
||||
|
||||
/***********************************************************************
|
||||
** Function prototypes
|
||||
*/
|
||||
|
||||
/* To get and release buffers, change owner and get size
|
||||
*/
|
||||
void *GKI_getbuf_func(UINT16);
|
||||
void *GKI_getpoolbuf_func(UINT8);
|
||||
void GKI_freebuf(void *);
|
||||
UINT16 GKI_get_buf_size (void *);
|
||||
void *GKI_getpoolbuf (UINT8);
|
||||
UINT16 GKI_poolcount (UINT8);
|
||||
UINT16 GKI_poolfreecount (UINT8);
|
||||
UINT16 GKI_poolutilization (UINT8);
|
||||
|
||||
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
|
||||
|
||||
#define GKI_getbuf(_size) \
|
||||
({ \
|
||||
BUFFER_HDR_T *header = osi_malloc((_size) + BUFFER_HDR_SIZE); \
|
||||
header->status = BUF_STATUS_UNLINKED; \
|
||||
header->p_next = NULL; \
|
||||
header->Type = 0; \
|
||||
header->size = (_size); \
|
||||
(void *)(header + 1); \
|
||||
})
|
||||
|
||||
#define GKI_getpoolbuf(_pool_id) \
|
||||
({ \
|
||||
(void *)GKI_getbuf(gki_cb.com.pool_size[(_pool_id)]); \
|
||||
})
|
||||
|
||||
#else
|
||||
#define GKI_getbuf GKI_getbuf_func
|
||||
#define GKI_getpoolbuf GKI_getpoolbuf_func
|
||||
|
||||
#endif /* CONFIG_BLUEDROID_MEM_DEBUG */
|
||||
|
||||
/* User buffer queue management
|
||||
*/
|
||||
void *GKI_dequeue (BUFFER_Q *);
|
||||
void GKI_enqueue (BUFFER_Q *, void *);
|
||||
void *GKI_getfirst (BUFFER_Q *);
|
||||
void *GKI_getlast (BUFFER_Q *);
|
||||
void *GKI_getnext (void *);
|
||||
void GKI_init_q (BUFFER_Q *);
|
||||
UINT16 GKI_queue_length(BUFFER_Q *);
|
||||
BOOLEAN GKI_queue_is_empty(BUFFER_Q *);
|
||||
void *GKI_remove_from_queue (BUFFER_Q *, void *);
|
||||
UINT16 GKI_get_pool_bufsize (UINT8);
|
||||
|
||||
/* Timer management
|
||||
*/
|
||||
void GKI_delay(UINT32);
|
||||
|
||||
/* Disable Interrupts, Enable Interrupts
|
||||
*/
|
||||
void GKI_enable(void);
|
||||
void GKI_disable(void);
|
||||
|
||||
/* os timer operation */
|
||||
UINT32 GKI_get_os_tick_count(void);
|
||||
|
||||
#endif /*_GKI_H_*/
|
65
tools/sdk/include/bluedroid/gki_common.h
Normal file
65
tools/sdk/include/bluedroid/gki_common.h
Normal file
@ -0,0 +1,65 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _GKI_COMMON_H_
|
||||
#define _GKI_COMMON_H_
|
||||
|
||||
#include "gki.h"
|
||||
|
||||
typedef struct _buffer_hdr {
|
||||
struct _buffer_hdr *p_next; /* next buffer in the queue */
|
||||
UINT8 q_id; /* id of the queue */
|
||||
UINT8 status; /* FREE, UNLINKED or QUEUED */
|
||||
UINT8 Type;
|
||||
UINT16 size;
|
||||
} BUFFER_HDR_T;
|
||||
|
||||
typedef struct _free_queue {
|
||||
BUFFER_HDR_T *_p_first; /* first buffer in the queue */
|
||||
BUFFER_HDR_T *_p_last; /* last buffer in the queue */
|
||||
UINT16 size; /* size of the buffers in the pool */
|
||||
UINT16 total; /* toatal number of buffers */
|
||||
UINT16 cur_cnt; /* number of buffers currently allocated */
|
||||
UINT16 max_cnt; /* maximum number of buffers allocated at any time */
|
||||
} FREE_QUEUE_T;
|
||||
|
||||
/* Put all GKI variables into one control block
|
||||
*/
|
||||
typedef struct {
|
||||
/* Define the buffer pool management variables
|
||||
*/
|
||||
FREE_QUEUE_T freeq[GKI_NUM_TOTAL_BUF_POOLS];
|
||||
|
||||
UINT16 pool_buf_size[GKI_NUM_TOTAL_BUF_POOLS];
|
||||
|
||||
/* Define the buffer pool start addresses
|
||||
*/
|
||||
UINT8 *pool_start[GKI_NUM_TOTAL_BUF_POOLS]; /* array of pointers to the start of each buffer pool */
|
||||
UINT8 *pool_end[GKI_NUM_TOTAL_BUF_POOLS]; /* array of pointers to the end of each buffer pool */
|
||||
UINT16 pool_size[GKI_NUM_TOTAL_BUF_POOLS]; /* actual size of the buffers in a pool */
|
||||
|
||||
/* Define the buffer pool access control variables */
|
||||
UINT16 pool_access_mask; /* Bits are set if the corresponding buffer pool is a restricted pool */
|
||||
} tGKI_COM_CB;
|
||||
|
||||
/* Internal GKI function prototypes
|
||||
*/
|
||||
void gki_buffer_init(void);
|
||||
void gki_buffer_cleanup(void);
|
||||
|
||||
#endif /*_GKI_COMMON_H_*/
|
34
tools/sdk/include/bluedroid/gki_int.h
Normal file
34
tools/sdk/include/bluedroid/gki_int.h
Normal file
@ -0,0 +1,34 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _GKI_INT_H_
|
||||
#define _GKI_INT_H_
|
||||
|
||||
//#include <pthread.h>
|
||||
#include "bt_defs.h"
|
||||
|
||||
#include "gki_common.h"
|
||||
|
||||
typedef struct {
|
||||
pthread_mutex_t lock;
|
||||
tGKI_COM_CB com;
|
||||
} tGKI_CB;
|
||||
|
||||
extern tGKI_CB gki_cb;
|
||||
|
||||
#endif /*_GKI_INT_H_*/
|
244
tools/sdk/include/bluedroid/gki_target.h
Executable file
244
tools/sdk/include/bluedroid/gki_target.h
Executable file
@ -0,0 +1,244 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _GKI_TARGET_H_
|
||||
#define _GKI_TARGET_H_
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Buffer configuration
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
/* The size of the buffers in pool 0. */
|
||||
#ifndef GKI_BUF0_SIZE
|
||||
#define GKI_BUF0_SIZE 64
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 0. */
|
||||
#ifndef GKI_BUF0_MAX
|
||||
#define GKI_BUF0_MAX 96
|
||||
#endif
|
||||
|
||||
/* The ID of buffer pool 0. */
|
||||
#ifndef GKI_POOL_ID_0
|
||||
#define GKI_POOL_ID_0 0
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 1. */
|
||||
#ifndef GKI_BUF1_SIZE
|
||||
#define GKI_BUF1_SIZE 288
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 1. */
|
||||
#ifndef GKI_BUF1_MAX
|
||||
#define GKI_BUF1_MAX 52
|
||||
#endif
|
||||
|
||||
/* The ID of buffer pool 1. */
|
||||
#ifndef GKI_POOL_ID_1
|
||||
#define GKI_POOL_ID_1 1
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 2. */
|
||||
#ifndef GKI_BUF2_SIZE
|
||||
#define GKI_BUF2_SIZE 660
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 2. */
|
||||
#ifndef GKI_BUF2_MAX
|
||||
#define GKI_BUF2_MAX 90
|
||||
#endif
|
||||
|
||||
/* The ID of buffer pool 2. */
|
||||
#ifndef GKI_POOL_ID_2
|
||||
#define GKI_POOL_ID_2 2
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 3. */
|
||||
#ifndef GKI_BUF3_SIZE
|
||||
#define GKI_BUF3_SIZE (4096+16)
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 3. */
|
||||
#ifndef GKI_BUF3_MAX
|
||||
#define GKI_BUF3_MAX 400
|
||||
#endif
|
||||
|
||||
/* The ID of buffer pool 3. */
|
||||
#ifndef GKI_POOL_ID_3
|
||||
#define GKI_POOL_ID_3 3
|
||||
#endif
|
||||
|
||||
/* The size of the largest PUBLIC fixed buffer in system. */
|
||||
#ifndef GKI_MAX_BUF_SIZE
|
||||
#define GKI_MAX_BUF_SIZE GKI_BUF3_SIZE
|
||||
#endif
|
||||
|
||||
/* The pool ID of the largest PUBLIC fixed buffer in system. */
|
||||
#ifndef GKI_MAX_BUF_SIZE_POOL_ID
|
||||
#define GKI_MAX_BUF_SIZE_POOL_ID GKI_POOL_ID_3
|
||||
#endif
|
||||
|
||||
/* Pool 4 is used for BluetoothSocket L2CAP connections */
|
||||
/* The size of the buffers in pool 4. */
|
||||
#ifndef GKI_BUF4_SIZE
|
||||
#define GKI_BUF4_SIZE (8080+26)
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 4. */
|
||||
#ifndef GKI_BUF4_MAX
|
||||
#define GKI_BUF4_MAX (OBX_NUM_SERVERS + OBX_NUM_CLIENTS)
|
||||
#endif
|
||||
|
||||
/* The ID of buffer pool 4. */
|
||||
#ifndef GKI_POOL_ID_4
|
||||
#define GKI_POOL_ID_4 4
|
||||
#endif
|
||||
|
||||
/* The number of fixed GKI buffer pools.
|
||||
eL2CAP requires Pool ID 5
|
||||
If BTM_SCO_HCI_INCLUDED is FALSE, Pool ID 6 is unnecessary, otherwise set to 7
|
||||
If BTA_HL_INCLUDED is FALSE then Pool ID 7 is uncessary and set the following to 7, otherwise set to 8
|
||||
If BLE_INCLUDED is FALSE then Pool ID 8 is uncessary and set the following to 8, otherwise set to 9
|
||||
POOL_ID 9 is a public pool meant for large buffer needs such as SDP_DB
|
||||
*/
|
||||
#ifndef GKI_NUM_FIXED_BUF_POOLS
|
||||
#define GKI_NUM_FIXED_BUF_POOLS 10
|
||||
#endif
|
||||
|
||||
/* The buffer pool usage mask. */
|
||||
#ifndef GKI_DEF_BUFPOOL_PERM_MASK
|
||||
/* Setting POOL_ID 9 as a public pool meant for large buffers such as SDP_DB */
|
||||
#define GKI_DEF_BUFPOOL_PERM_MASK 0xfdf0
|
||||
#endif
|
||||
|
||||
/* The following is intended to be a reserved pool for L2CAP
|
||||
Flow control and retransmissions and intentionally kept out
|
||||
of order */
|
||||
|
||||
/* The number of buffers in buffer pool 5. */
|
||||
#ifndef GKI_BUF5_MAX
|
||||
#define GKI_BUF5_MAX 64
|
||||
#endif
|
||||
|
||||
/* The ID of buffer pool 5. */
|
||||
#ifndef GKI_POOL_ID_5
|
||||
#define GKI_POOL_ID_5 5
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 5
|
||||
** Special pool used by L2CAP retransmissions only. This size based on segment
|
||||
** that will fit into both DH5 and 2-DH3 packet types after accounting for GKI
|
||||
** header. 13 bytes of max headers allows us a 339 payload max. (in btui_app.txt)
|
||||
** Note: 748 used for insight scriptwrapper with CAT-2 scripts.
|
||||
*/
|
||||
#ifndef GKI_BUF5_SIZE
|
||||
#define GKI_BUF5_SIZE 748
|
||||
#endif
|
||||
|
||||
/* The following is intended to be a reserved pool for SCO
|
||||
over HCI data and intentionally kept out of order */
|
||||
|
||||
/* The ID of buffer pool 6. */
|
||||
#ifndef GKI_POOL_ID_6
|
||||
#define GKI_POOL_ID_6 6
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 6,
|
||||
BUF_SIZE = max SCO data 255 + sizeof(BT_HDR) = 8 + SCO packet header 3 + padding 2 = 268 */
|
||||
#ifndef GKI_BUF6_SIZE
|
||||
#define GKI_BUF6_SIZE 268
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 6. */
|
||||
#ifndef GKI_BUF6_MAX
|
||||
#define GKI_BUF6_MAX 60
|
||||
#endif
|
||||
|
||||
|
||||
/* The following pool is a dedicated pool for HDP
|
||||
If a shared pool is more desirable then
|
||||
1. set BTA_HL_LRG_DATA_POOL_ID to the desired Gki Pool ID
|
||||
2. make sure that the shared pool size is larger than 9472
|
||||
3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since
|
||||
POOL ID 7 is not needed
|
||||
*/
|
||||
|
||||
/* The ID of buffer pool 7. */
|
||||
#ifndef GKI_POOL_ID_7
|
||||
#define GKI_POOL_ID_7 7
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 7 */
|
||||
#ifndef GKI_BUF7_SIZE
|
||||
#define GKI_BUF7_SIZE (10240 + 24)
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 7. */
|
||||
#ifndef GKI_BUF7_MAX
|
||||
#define GKI_BUF7_MAX 2
|
||||
#endif
|
||||
|
||||
/* The following pool is a dedicated pool for GATT
|
||||
If a shared pool is more desirable then
|
||||
1. set GATT_DB_POOL_ID to the desired Gki Pool ID
|
||||
2. make sure that the shared pool size fit a common GATT database needs
|
||||
3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since
|
||||
POOL ID 8 is not needed
|
||||
*/
|
||||
|
||||
/* The ID of buffer pool 8. */
|
||||
#ifndef GKI_POOL_ID_8
|
||||
#define GKI_POOL_ID_8 8
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 8 */
|
||||
#ifndef GKI_BUF8_SIZE
|
||||
#define GKI_BUF8_SIZE 128
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 8. */
|
||||
#ifndef GKI_BUF8_MAX
|
||||
#define GKI_BUF8_MAX 30
|
||||
#endif
|
||||
|
||||
/* The following pool is meant for large allocations such as SDP_DB */
|
||||
#ifndef GKI_POOL_ID_9
|
||||
#define GKI_POOL_ID_9 9
|
||||
#endif
|
||||
|
||||
#ifndef GKI_BUF9_SIZE
|
||||
#define GKI_BUF9_SIZE 8192
|
||||
#endif
|
||||
|
||||
#ifndef GKI_BUF9_MAX
|
||||
#define GKI_BUF9_MAX 5
|
||||
#endif
|
||||
|
||||
/* The number of fixed and dynamic buffer pools */
|
||||
#ifndef GKI_NUM_TOTAL_BUF_POOLS
|
||||
#define GKI_NUM_TOTAL_BUF_POOLS 10
|
||||
#endif
|
||||
|
||||
int gki_init(void);
|
||||
void gki_clean_up(void);
|
||||
|
||||
//void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...);
|
||||
|
||||
#endif /*_GKI_TARGET_H_*/
|
33
tools/sdk/include/bluedroid/hash_functions.h
Executable file
33
tools/sdk/include/bluedroid/hash_functions.h
Executable file
@ -0,0 +1,33 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _HASH_FUNCTIONS_H_
|
||||
#define _HASH_FUNCTIONS_H_
|
||||
|
||||
#include "hash_map.h"
|
||||
|
||||
hash_index_t hash_function_naive(const void *key);
|
||||
|
||||
hash_index_t hash_function_integer(const void *key);
|
||||
|
||||
// Hashes a pointer based only on its address value
|
||||
hash_index_t hash_function_pointer(const void *key);
|
||||
|
||||
hash_index_t hash_function_string(const void *key);
|
||||
|
||||
#endif /* _HASH_FUNCTIONS_H_ */
|
110
tools/sdk/include/bluedroid/hash_map.h
Normal file
110
tools/sdk/include/bluedroid/hash_map.h
Normal file
@ -0,0 +1,110 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _HASH_MAP_H_
|
||||
#define _HASH_MAP_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct hash_map_t;
|
||||
typedef struct hash_map_t hash_map_t;
|
||||
|
||||
typedef struct hash_map_entry_t {
|
||||
const void *key;
|
||||
void *data;
|
||||
const hash_map_t *hash_map;
|
||||
} hash_map_entry_t;
|
||||
|
||||
typedef size_t hash_index_t;
|
||||
|
||||
// Takes a key structure and returns a hash value.
|
||||
typedef hash_index_t (*hash_index_fn)(const void *key);
|
||||
typedef bool (*hash_map_iter_cb)(hash_map_entry_t *hash_entry, void *context);
|
||||
|
||||
typedef bool (*key_equality_fn)(const void *x, const void *y);
|
||||
|
||||
typedef void (*key_free_fn)(void *data);
|
||||
typedef void (*data_free_fn)(void *data);
|
||||
|
||||
// Returns a new, empty hash_map. Returns NULL if not enough memory could be allocated
|
||||
// for the hash_map structure. The returned hash_map must be freed with |hash_map_free|.
|
||||
// The |num_bucket| specifies the number of hashable buckets for the map and must not
|
||||
// be zero. The |hash_fn| specifies a hash function to be used and must not be NULL.
|
||||
// The |key_fn| and |data_fn| are called whenever a hash_map element is removed from
|
||||
// the hash_map. They can be used to release resources held by the hash_map element,
|
||||
// e.g. memory or file descriptor. |key_fn| and |data_fn| may be NULL if no cleanup
|
||||
// is necessary on element removal. |equality_fn| is used to check for key equality.
|
||||
// If |equality_fn| is NULL, default pointer equality is used.
|
||||
hash_map_t *hash_map_new(
|
||||
size_t size,
|
||||
hash_index_fn hash_fn,
|
||||
key_free_fn key_fn,
|
||||
data_free_fn data_fn,
|
||||
key_equality_fn equality_fn);
|
||||
|
||||
// Frees the hash_map. This function accepts NULL as an argument, in which case it
|
||||
// behaves like a no-op.
|
||||
void hash_map_free(hash_map_t *hash_map);
|
||||
|
||||
// Returns true if the hash_map is empty (has no elements), false otherwise.
|
||||
// Note that a NULL |hash_map| is not the same as an empty |hash_map|. This function
|
||||
// does not accept a NULL |hash_map|.
|
||||
//bool hash_map_is_empty(const hash_map_t *hash_map);
|
||||
|
||||
// Returns the number of elements in the hash map. This function does not accept a
|
||||
// NULL |hash_map|.
|
||||
//size_t hash_map_size(const hash_map_t *hash_map);
|
||||
|
||||
// Returns the number of buckets in the hash map. This function does not accept a
|
||||
// NULL |hash_map|.
|
||||
//size_t hash_map_num_buckets(const hash_map_t *hash_map);
|
||||
|
||||
// Returns true if the hash_map has a valid entry for the presented key.
|
||||
// This function does not accept a NULL |hash_map|.
|
||||
bool hash_map_has_key(const hash_map_t *hash_map, const void *key);
|
||||
|
||||
// Returns the element indexed by |key| in the hash_map without removing it. |hash_map|
|
||||
// may not be NULL. Returns NULL if no entry indexed by |key|.
|
||||
void *hash_map_get(const hash_map_t *hash_map, const void *key);
|
||||
|
||||
// Sets the value |data| indexed by |key| into the |hash_map|. Neither |data| nor
|
||||
// |hash_map| may be NULL. This function does not make copies of |data| nor |key|
|
||||
// so the pointers must remain valid at least until the element is removed from the
|
||||
// hash_map or the hash_map is freed. Returns true if |data| could be set, false
|
||||
// otherwise (e.g. out of memory).
|
||||
bool hash_map_set(hash_map_t *hash_map, const void *key, void *data);
|
||||
|
||||
// Removes data indexed by |key| from the hash_map. |hash_map| may not be NULL.
|
||||
// If |key_fn| or |data_fn| functions were specified in |hash_map_new|, they
|
||||
// will be called back with |key| or |data| respectively. This function returns true
|
||||
// if |key| was found in the hash_map and removed, false otherwise.
|
||||
bool hash_map_erase(hash_map_t *hash_map, const void *key);
|
||||
|
||||
// Removes all elements in the hash_map. Calling this function will return the hash_map
|
||||
// to the same state it was in after |hash_map_new|. |hash_map| may not be NULL.
|
||||
void hash_map_clear(hash_map_t *hash_map);
|
||||
|
||||
// Iterates through the entire |hash_map| and calls |callback| for each data
|
||||
// element and passes through the |context| argument. If the hash_map is
|
||||
// empty, |callback| will never be called. It is not safe to mutate the
|
||||
// hash_map inside the callback. Neither |hash_map| nor |callback| may be NULL.
|
||||
// If |callback| returns false, the iteration loop will immediately exit.
|
||||
void hash_map_foreach(hash_map_t *hash_map, hash_map_iter_cb callback, void *context);
|
||||
|
||||
#endif /* _HASH_MAP_H_ */
|
85
tools/sdk/include/bluedroid/hci_hal.h
Normal file
85
tools/sdk/include/bluedroid/hci_hal.h
Normal file
@ -0,0 +1,85 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _HCI_HAL_H_
|
||||
#define _HCI_HAL_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bt_types.h"
|
||||
|
||||
typedef enum {
|
||||
DATA_TYPE_COMMAND = 1,
|
||||
DATA_TYPE_ACL = 2,
|
||||
DATA_TYPE_SCO = 3,
|
||||
DATA_TYPE_EVENT = 4
|
||||
} serial_data_type_t;
|
||||
|
||||
typedef void (*packet_ready_cb)(BT_HDR *packet);
|
||||
|
||||
typedef struct {
|
||||
// Called when the HAL detects inbound data.
|
||||
// Data |type| may be ACL, SCO, or EVENT.
|
||||
// Executes in the context of the thread supplied to |init|.
|
||||
packet_ready_cb packet_ready;
|
||||
|
||||
/*
|
||||
// Called when the HAL detects inbound astronauts named Dave.
|
||||
// HAL will deny all requests to open the pod bay doors after this.
|
||||
dave_ready_cb dave_ready;
|
||||
*/
|
||||
} hci_hal_callbacks_t;
|
||||
|
||||
typedef struct hci_hal_t {
|
||||
// Initialize the HAL, with |upper_callbacks| and |upper_thread| to run in the context of.
|
||||
//bool (*init)(const hci_hal_callbacks_t *upper_callbacks);
|
||||
|
||||
// Connect to the underlying hardware, and let data start flowing.
|
||||
bool (*open)(const hci_hal_callbacks_t *upper_callbacks);
|
||||
// Disconnect from the underlying hardware, and close the HAL.
|
||||
// "Daisy, Daisy..."
|
||||
void (*close)(void);
|
||||
|
||||
// Retrieve up to |max_size| bytes for ACL, SCO, or EVENT data packets into
|
||||
// |buffer|, blocking until max_size bytes read if |block| is true.
|
||||
// Only guaranteed to be correct in the context of a data_ready callback
|
||||
// of the corresponding type.
|
||||
//size_t (*read_data)(serial_data_type_t type, uint8_t *buffer, size_t max_size);
|
||||
// The upper layer must call this to notify the HAL that it has finished
|
||||
// reading a packet of the specified |type|. Underlying implementations that
|
||||
// use shared channels for multiple data types depend on this to know when
|
||||
// to reinterpret the data stream.
|
||||
//void (*packet_finished)(serial_data_type_t type);
|
||||
// Transmit COMMAND, ACL, or SCO data packets.
|
||||
// |data| may not be NULL. |length| must be greater than zero.
|
||||
//
|
||||
// IMPORTANT NOTE:
|
||||
// Depending on the underlying implementation, the byte right
|
||||
// before the beginning of |data| may be borrowed during this call
|
||||
// and then restored to its original value.
|
||||
// This is safe in the bluetooth context, because there is always a buffer
|
||||
// header that prefixes data you're sending.
|
||||
uint16_t (*transmit_data)(serial_data_type_t type, uint8_t *data, uint16_t length);
|
||||
} hci_hal_t;
|
||||
|
||||
|
||||
// Gets the correct hal implementation, as compiled for.
|
||||
const hci_hal_t *hci_hal_h4_get_interface(void);
|
||||
|
||||
#endif /* _HCI_HAL_H */
|
31
tools/sdk/include/bluedroid/hci_internals.h
Executable file
31
tools/sdk/include/bluedroid/hci_internals.h
Executable file
@ -0,0 +1,31 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _HCI_INTERNALS_H_
|
||||
#define _HCI_INTERNALS_H_
|
||||
|
||||
// 2 bytes for opcode, 1 byte for parameter length (Volume 2, Part E, 5.4.1)
|
||||
#define HCI_COMMAND_PREAMBLE_SIZE 3
|
||||
// 2 bytes for handle, 2 bytes for data length (Volume 2, Part E, 5.4.2)
|
||||
#define HCI_ACL_PREAMBLE_SIZE 4
|
||||
// 2 bytes for handle, 1 byte for data length (Volume 2, Part E, 5.4.3)
|
||||
#define HCI_SCO_PREAMBLE_SIZE 3
|
||||
// 1 byte for event code, 1 byte for parameter length (Volume 2, Part E, 5.4.4)
|
||||
#define HCI_EVENT_PREAMBLE_SIZE 2
|
||||
|
||||
#endif /* _HCI_INTERNALS_H_ */
|
103
tools/sdk/include/bluedroid/hci_layer.h
Normal file
103
tools/sdk/include/bluedroid/hci_layer.h
Normal file
@ -0,0 +1,103 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _HCI_LAYER_H_
|
||||
#define _HCI_LAYER_H_
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "allocator.h"
|
||||
#include "fixed_queue.h"
|
||||
#include "osi.h"
|
||||
#include "future.h"
|
||||
///// LEGACY DEFINITIONS /////
|
||||
|
||||
/* Message event mask across Host/Controller lib and stack */
|
||||
#define MSG_EVT_MASK 0xFF00 /* eq. BT_EVT_MASK */
|
||||
#define MSG_SUB_EVT_MASK 0x00FF /* eq. BT_SUB_EVT_MASK */
|
||||
|
||||
/* Message event ID passed from Host/Controller lib to stack */
|
||||
#define MSG_HC_TO_STACK_HCI_ERR 0x1300 /* eq. BT_EVT_TO_BTU_HCIT_ERR */
|
||||
#define MSG_HC_TO_STACK_HCI_ACL 0x1100 /* eq. BT_EVT_TO_BTU_HCI_ACL */
|
||||
#define MSG_HC_TO_STACK_HCI_SCO 0x1200 /* eq. BT_EVT_TO_BTU_HCI_SCO */
|
||||
#define MSG_HC_TO_STACK_HCI_EVT 0x1000 /* eq. BT_EVT_TO_BTU_HCI_EVT */
|
||||
#define MSG_HC_TO_STACK_L2C_SEG_XMIT 0x1900 /* eq. BT_EVT_TO_BTU_L2C_SEG_XMIT */
|
||||
|
||||
/* Message event ID passed from stack to vendor lib */
|
||||
#define MSG_STACK_TO_HC_HCI_ACL 0x2100 /* eq. BT_EVT_TO_LM_HCI_ACL */
|
||||
#define MSG_STACK_TO_HC_HCI_SCO 0x2200 /* eq. BT_EVT_TO_LM_HCI_SCO */
|
||||
#define MSG_STACK_TO_HC_HCI_CMD 0x2000 /* eq. BT_EVT_TO_LM_HCI_CMD */
|
||||
|
||||
/* Local Bluetooth Controller ID for BR/EDR */
|
||||
#define LOCAL_BR_EDR_CONTROLLER_ID 0
|
||||
|
||||
///// END LEGACY DEFINITIONS /////
|
||||
|
||||
typedef struct hci_hal_t hci_hal_t;
|
||||
//typedef struct btsnoop_t btsnoop_t;
|
||||
typedef struct controller_t controller_t;
|
||||
//typedef struct hci_inject_t hci_inject_t;
|
||||
typedef struct packet_fragmenter_t packet_fragmenter_t;
|
||||
//typedef struct vendor_t vendor_t;
|
||||
//typedef struct low_power_manager_t low_power_manager_t;
|
||||
|
||||
//typedef unsigned char * bdaddr_t;
|
||||
typedef uint16_t command_opcode_t;
|
||||
|
||||
/*
|
||||
typedef enum {
|
||||
LPM_DISABLE,
|
||||
LPM_ENABLE,
|
||||
LPM_WAKE_ASSERT,
|
||||
LPM_WAKE_DEASSERT
|
||||
} low_power_command_t;
|
||||
*/
|
||||
|
||||
typedef void (*command_complete_cb)(BT_HDR *response, void *context);
|
||||
typedef void (*command_status_cb)(uint8_t status, BT_HDR *command, void *context);
|
||||
|
||||
typedef struct hci_t {
|
||||
// Send a low power command, if supported and the low power manager is enabled.
|
||||
//void (*send_low_power_command)(low_power_command_t command);
|
||||
|
||||
// Do the postload sequence (call after the rest of the BT stack initializes).
|
||||
void (*do_postload)(void);
|
||||
|
||||
// Set the queue to receive ACL data in
|
||||
void (*set_data_queue)(fixed_queue_t *queue);
|
||||
|
||||
// Send a command through the HCI layer
|
||||
void (*transmit_command)(
|
||||
BT_HDR *command,
|
||||
command_complete_cb complete_callback,
|
||||
command_status_cb status_cb,
|
||||
void *context
|
||||
);
|
||||
|
||||
future_t *(*transmit_command_futured)(BT_HDR *command);
|
||||
|
||||
// Send some data downward through the HCI layer
|
||||
void (*transmit_downward)(uint16_t type, void *data);
|
||||
} hci_t;
|
||||
|
||||
const hci_t *hci_layer_get_interface();
|
||||
|
||||
int hci_start_up(void);
|
||||
void hci_shut_down(void);
|
||||
|
||||
|
||||
#endif /* _HCI_LAYER_H_ */
|
48
tools/sdk/include/bluedroid/hci_packet_factory.h
Normal file
48
tools/sdk/include/bluedroid/hci_packet_factory.h
Normal file
@ -0,0 +1,48 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _HCI_PACKET_FACTORY_H_
|
||||
#define _HCI_PACKET_FACTORY_H_
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "event_mask.h"
|
||||
|
||||
typedef struct {
|
||||
BT_HDR *(*make_reset)(void);
|
||||
BT_HDR *(*make_read_buffer_size)(void);
|
||||
BT_HDR *(*make_host_buffer_size)(uint16_t acl_size, uint8_t sco_size, uint16_t acl_count, uint16_t sco_count);
|
||||
BT_HDR *(*make_read_local_version_info)(void);
|
||||
BT_HDR *(*make_read_bd_addr)(void);
|
||||
BT_HDR *(*make_read_local_supported_commands)(void);
|
||||
BT_HDR *(*make_read_local_extended_features)(uint8_t page_number);
|
||||
BT_HDR *(*make_write_simple_pairing_mode)(uint8_t mode);
|
||||
BT_HDR *(*make_write_secure_connections_host_support)(uint8_t mode);
|
||||
BT_HDR *(*make_set_event_mask)(const bt_event_mask_t *event_mask);
|
||||
BT_HDR *(*make_ble_write_host_support)(uint8_t supported_host, uint8_t simultaneous_host);
|
||||
BT_HDR *(*make_ble_read_white_list_size)(void);
|
||||
BT_HDR *(*make_ble_read_buffer_size)(void);
|
||||
BT_HDR *(*make_ble_read_supported_states)(void);
|
||||
BT_HDR *(*make_ble_read_local_supported_features)(void);
|
||||
BT_HDR *(*make_ble_read_resolving_list_size)(void);
|
||||
BT_HDR *(*make_ble_read_suggested_default_data_length)(void);
|
||||
BT_HDR *(*make_ble_set_event_mask)(const bt_event_mask_t *event_mask);
|
||||
} hci_packet_factory_t;
|
||||
|
||||
const hci_packet_factory_t *hci_packet_factory_get_interface();
|
||||
|
||||
#endif /*_HCI_PACKET_FACTORY_H_*/
|
99
tools/sdk/include/bluedroid/hci_packet_parser.h
Normal file
99
tools/sdk/include/bluedroid/hci_packet_parser.h
Normal file
@ -0,0 +1,99 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Google, Inc.
|
||||
*
|
||||
* 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 _HCI_PACKET_PARSER_H_
|
||||
#define _HCI_PACKET_PARSER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "allocator.h"
|
||||
#include "bdaddr.h"
|
||||
#include "bt_types.h"
|
||||
#include "device_features.h"
|
||||
//#include "features.h"
|
||||
#include "version.h"
|
||||
|
||||
typedef struct {
|
||||
void (*parse_generic_command_complete)(BT_HDR *response);
|
||||
|
||||
void (*parse_read_buffer_size_response)(
|
||||
BT_HDR *response,
|
||||
uint16_t *data_size_ptr,
|
||||
uint16_t *acl_buffer_count_ptr
|
||||
);
|
||||
|
||||
void (*parse_read_local_version_info_response)(
|
||||
BT_HDR *response,
|
||||
bt_version_t *bt_version_ptr
|
||||
);
|
||||
|
||||
void (*parse_read_bd_addr_response)(
|
||||
BT_HDR *response,
|
||||
bt_bdaddr_t *address_ptr
|
||||
);
|
||||
|
||||
void (*parse_read_local_supported_commands_response)(
|
||||
BT_HDR *response,
|
||||
uint8_t *supported_commands_ptr,
|
||||
size_t supported_commands_length
|
||||
);
|
||||
|
||||
void (*parse_read_local_extended_features_response)(
|
||||
BT_HDR *response,
|
||||
uint8_t *page_number_ptr,
|
||||
uint8_t *max_page_number_ptr,
|
||||
bt_device_features_t *feature_pages,
|
||||
size_t feature_pages_count
|
||||
);
|
||||
|
||||
void (*parse_ble_read_white_list_size_response)(
|
||||
BT_HDR *response,
|
||||
uint8_t *white_list_size_ptr
|
||||
);
|
||||
|
||||
void (*parse_ble_read_buffer_size_response)(
|
||||
BT_HDR *response,
|
||||
uint16_t *data_size_ptr,
|
||||
uint8_t *acl_buffer_count_ptr
|
||||
);
|
||||
|
||||
void (*parse_ble_read_supported_states_response)(
|
||||
BT_HDR *response,
|
||||
uint8_t *supported_states,
|
||||
size_t supported_states_size
|
||||
);
|
||||
|
||||
void (*parse_ble_read_local_supported_features_response)(
|
||||
BT_HDR *response,
|
||||
bt_device_features_t *supported_features
|
||||
);
|
||||
|
||||
void (*parse_ble_read_resolving_list_size_response) (
|
||||
BT_HDR *response,
|
||||
uint8_t *resolving_list_size_ptr
|
||||
);
|
||||
|
||||
void (*parse_ble_read_suggested_default_data_length_response)(
|
||||
BT_HDR *response,
|
||||
uint16_t *ble_default_packet_length_ptr
|
||||
);
|
||||
} hci_packet_parser_t;
|
||||
|
||||
const hci_packet_parser_t *hci_packet_parser_get_interface();
|
||||
|
||||
#endif /*_HCI_PACKET_PARSER_H_*/
|
2605
tools/sdk/include/bluedroid/hcidefs.h
Normal file
2605
tools/sdk/include/bluedroid/hcidefs.h
Normal file
File diff suppressed because it is too large
Load Diff
811
tools/sdk/include/bluedroid/hcimsgs.h
Normal file
811
tools/sdk/include/bluedroid/hcimsgs.h
Normal file
@ -0,0 +1,811 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef HCIMSGS_H
|
||||
#define HCIMSGS_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "hcidefs.h"
|
||||
#include "bt_types.h"
|
||||
|
||||
void bte_main_hci_send(BT_HDR *p_msg, UINT16 event);
|
||||
void bte_main_lpm_allow_bt_device_sleep(void);
|
||||
|
||||
/* Message by message.... */
|
||||
|
||||
BOOLEAN btsnd_hcic_inquiry(const LAP inq_lap, UINT8 duration,
|
||||
UINT8 response_cnt);
|
||||
|
||||
#define HCIC_PARAM_SIZE_INQUIRY 5
|
||||
|
||||
|
||||
#define HCIC_INQ_INQ_LAP_OFF 0
|
||||
#define HCIC_INQ_DUR_OFF 3
|
||||
#define HCIC_INQ_RSP_CNT_OFF 4
|
||||
/* Inquiry */
|
||||
|
||||
/* Inquiry Cancel */
|
||||
BOOLEAN btsnd_hcic_inq_cancel(void);
|
||||
|
||||
#define HCIC_PARAM_SIZE_INQ_CANCEL 0
|
||||
|
||||
/* Periodic Inquiry Mode */
|
||||
BOOLEAN btsnd_hcic_per_inq_mode(UINT16 max_period, UINT16 min_period,
|
||||
const LAP inq_lap, UINT8 duration,
|
||||
UINT8 response_cnt);
|
||||
|
||||
#define HCIC_PARAM_SIZE_PER_INQ_MODE 9
|
||||
|
||||
#define HCI_PER_INQ_MAX_INTRVL_OFF 0
|
||||
#define HCI_PER_INQ_MIN_INTRVL_OFF 2
|
||||
#define HCI_PER_INQ_INQ_LAP_OFF 4
|
||||
#define HCI_PER_INQ_DURATION_OFF 7
|
||||
#define HCI_PER_INQ_RSP_CNT_OFF 8
|
||||
/* Periodic Inquiry Mode */
|
||||
|
||||
/* Exit Periodic Inquiry Mode */
|
||||
BOOLEAN btsnd_hcic_exit_per_inq(void);
|
||||
|
||||
#define HCIC_PARAM_SIZE_EXIT_PER_INQ 0
|
||||
/* Create Connection */
|
||||
BOOLEAN btsnd_hcic_create_conn(BD_ADDR dest, UINT16 packet_types,
|
||||
UINT8 page_scan_rep_mode,
|
||||
UINT8 page_scan_mode,
|
||||
UINT16 clock_offset,
|
||||
UINT8 allow_switch);
|
||||
|
||||
#define HCIC_PARAM_SIZE_CREATE_CONN 13
|
||||
|
||||
#define HCIC_CR_CONN_BD_ADDR_OFF 0
|
||||
#define HCIC_CR_CONN_PKT_TYPES_OFF 6
|
||||
#define HCIC_CR_CONN_REP_MODE_OFF 8
|
||||
#define HCIC_CR_CONN_PAGE_SCAN_MODE_OFF 9
|
||||
#define HCIC_CR_CONN_CLK_OFF_OFF 10
|
||||
#define HCIC_CR_CONN_ALLOW_SWITCH_OFF 12
|
||||
/* Create Connection */
|
||||
|
||||
/* Disconnect */
|
||||
BOOLEAN btsnd_hcic_disconnect(UINT16 handle, UINT8 reason);
|
||||
|
||||
#define HCIC_PARAM_SIZE_DISCONNECT 3
|
||||
|
||||
#define HCI_DISC_HANDLE_OFF 0
|
||||
#define HCI_DISC_REASON_OFF 2
|
||||
/* Disconnect */
|
||||
|
||||
#if BTM_SCO_INCLUDED == TRUE
|
||||
/* Add SCO Connection */
|
||||
BOOLEAN btsnd_hcic_add_SCO_conn (UINT16 handle, UINT16 packet_types);
|
||||
#endif /* BTM_SCO_INCLUDED */
|
||||
|
||||
#define HCIC_PARAM_SIZE_ADD_SCO_CONN 4
|
||||
|
||||
#define HCI_ADD_SCO_HANDLE_OFF 0
|
||||
#define HCI_ADD_SCO_PACKET_TYPES_OFF 2
|
||||
/* Add SCO Connection */
|
||||
|
||||
/* Create Connection Cancel */
|
||||
BOOLEAN btsnd_hcic_create_conn_cancel(BD_ADDR dest);
|
||||
|
||||
#define HCIC_PARAM_SIZE_CREATE_CONN_CANCEL 6
|
||||
|
||||
#define HCIC_CR_CONN_CANCEL_BD_ADDR_OFF 0
|
||||
/* Create Connection Cancel */
|
||||
|
||||
/* Accept Connection Request */
|
||||
BOOLEAN btsnd_hcic_accept_conn (BD_ADDR bd_addr, UINT8 role);
|
||||
|
||||
#define HCIC_PARAM_SIZE_ACCEPT_CONN 7
|
||||
|
||||
#define HCI_ACC_CONN_BD_ADDR_OFF 0
|
||||
#define HCI_ACC_CONN_ROLE_OFF 6
|
||||
/* Accept Connection Request */
|
||||
|
||||
/* Reject Connection Request */
|
||||
BOOLEAN btsnd_hcic_reject_conn (BD_ADDR bd_addr, UINT8 reason);
|
||||
|
||||
#define HCIC_PARAM_SIZE_REJECT_CONN 7
|
||||
|
||||
#define HCI_REJ_CONN_BD_ADDR_OFF 0
|
||||
#define HCI_REJ_CONN_REASON_OFF 6
|
||||
/* Reject Connection Request */
|
||||
|
||||
/* Link Key Request Reply */
|
||||
BOOLEAN btsnd_hcic_link_key_req_reply (BD_ADDR bd_addr,
|
||||
LINK_KEY link_key);
|
||||
|
||||
#define HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY 22
|
||||
|
||||
#define HCI_LINK_KEY_REPLY_BD_ADDR_OFF 0
|
||||
#define HCI_LINK_KEY_REPLY_LINK_KEY_OFF 6
|
||||
/* Link Key Request Reply */
|
||||
|
||||
/* Link Key Request Neg Reply */
|
||||
BOOLEAN btsnd_hcic_link_key_neg_reply (BD_ADDR bd_addr);
|
||||
|
||||
#define HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY 6
|
||||
|
||||
#define HCI_LINK_KEY_NEG_REP_BD_ADR_OFF 0
|
||||
/* Link Key Request Neg Reply */
|
||||
|
||||
/* PIN Code Request Reply */
|
||||
BOOLEAN btsnd_hcic_pin_code_req_reply (BD_ADDR bd_addr,
|
||||
UINT8 pin_code_len,
|
||||
PIN_CODE pin_code);
|
||||
|
||||
#define HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY 23
|
||||
|
||||
#define HCI_PIN_CODE_REPLY_BD_ADDR_OFF 0
|
||||
#define HCI_PIN_CODE_REPLY_PIN_LEN_OFF 6
|
||||
#define HCI_PIN_CODE_REPLY_PIN_CODE_OFF 7
|
||||
/* PIN Code Request Reply */
|
||||
|
||||
/* Link Key Request Neg Reply */
|
||||
BOOLEAN btsnd_hcic_pin_code_neg_reply (BD_ADDR bd_addr);
|
||||
|
||||
#define HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY 6
|
||||
|
||||
#define HCI_PIN_CODE_NEG_REP_BD_ADR_OFF 0
|
||||
/* Link Key Request Neg Reply */
|
||||
|
||||
/* Change Connection Type */
|
||||
BOOLEAN btsnd_hcic_change_conn_type (UINT16 handle, UINT16 packet_types);
|
||||
|
||||
#define HCIC_PARAM_SIZE_CHANGE_CONN_TYPE 4
|
||||
|
||||
#define HCI_CHNG_PKT_TYPE_HANDLE_OFF 0
|
||||
#define HCI_CHNG_PKT_TYPE_PKT_TYPE_OFF 2
|
||||
/* Change Connection Type */
|
||||
|
||||
#define HCIC_PARAM_SIZE_CMD_HANDLE 2
|
||||
|
||||
#define HCI_CMD_HANDLE_HANDLE_OFF 0
|
||||
|
||||
BOOLEAN btsnd_hcic_auth_request (UINT16 handle); /* Authentication Request */
|
||||
|
||||
/* Set Connection Encryption */
|
||||
BOOLEAN btsnd_hcic_set_conn_encrypt (UINT16 handle, BOOLEAN enable);
|
||||
#define HCIC_PARAM_SIZE_SET_CONN_ENCRYPT 3
|
||||
|
||||
|
||||
#define HCI_SET_ENCRYPT_HANDLE_OFF 0
|
||||
#define HCI_SET_ENCRYPT_ENABLE_OFF 2
|
||||
/* Set Connection Encryption */
|
||||
|
||||
/* Remote Name Request */
|
||||
BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr,
|
||||
UINT8 page_scan_rep_mode,
|
||||
UINT8 page_scan_mode,
|
||||
UINT16 clock_offset);
|
||||
|
||||
#define HCIC_PARAM_SIZE_RMT_NAME_REQ 10
|
||||
|
||||
#define HCI_RMT_NAME_BD_ADDR_OFF 0
|
||||
#define HCI_RMT_NAME_REP_MODE_OFF 6
|
||||
#define HCI_RMT_NAME_PAGE_SCAN_MODE_OFF 7
|
||||
#define HCI_RMT_NAME_CLK_OFF_OFF 8
|
||||
/* Remote Name Request */
|
||||
|
||||
/* Remote Name Request Cancel */
|
||||
BOOLEAN btsnd_hcic_rmt_name_req_cancel(BD_ADDR bd_addr);
|
||||
|
||||
#define HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL 6
|
||||
|
||||
#define HCI_RMT_NAME_CANCEL_BD_ADDR_OFF 0
|
||||
/* Remote Name Request Cancel */
|
||||
|
||||
BOOLEAN btsnd_hcic_rmt_features_req(UINT16 handle); /* Remote Features Request */
|
||||
|
||||
/* Remote Extended Features */
|
||||
BOOLEAN btsnd_hcic_rmt_ext_features(UINT16 handle, UINT8 page_num);
|
||||
|
||||
#define HCIC_PARAM_SIZE_RMT_EXT_FEATURES 3
|
||||
|
||||
#define HCI_RMT_EXT_FEATURES_HANDLE_OFF 0
|
||||
#define HCI_RMT_EXT_FEATURES_PAGE_NUM_OFF 2
|
||||
/* Remote Extended Features */
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_rmt_ver_req(UINT16 handle); /* Remote Version Info Request */
|
||||
BOOLEAN btsnd_hcic_read_rmt_clk_offset(UINT16 handle); /* Remote Clock Offset */
|
||||
BOOLEAN btsnd_hcic_read_lmp_handle(UINT16 handle); /* Remote LMP Handle */
|
||||
|
||||
BOOLEAN btsnd_hcic_setup_esco_conn (UINT16 handle,
|
||||
UINT32 tx_bw, UINT32 rx_bw,
|
||||
UINT16 max_latency, UINT16 voice,
|
||||
UINT8 retrans_effort,
|
||||
UINT16 packet_types);
|
||||
#define HCIC_PARAM_SIZE_SETUP_ESCO 17
|
||||
|
||||
#define HCI_SETUP_ESCO_HANDLE_OFF 0
|
||||
#define HCI_SETUP_ESCO_TX_BW_OFF 2
|
||||
#define HCI_SETUP_ESCO_RX_BW_OFF 6
|
||||
#define HCI_SETUP_ESCO_MAX_LAT_OFF 10
|
||||
#define HCI_SETUP_ESCO_VOICE_OFF 12
|
||||
#define HCI_SETUP_ESCO_RETRAN_EFF_OFF 14
|
||||
#define HCI_SETUP_ESCO_PKT_TYPES_OFF 15
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_accept_esco_conn (BD_ADDR bd_addr,
|
||||
UINT32 tx_bw, UINT32 rx_bw,
|
||||
UINT16 max_latency,
|
||||
UINT16 content_fmt,
|
||||
UINT8 retrans_effort,
|
||||
UINT16 packet_types);
|
||||
#define HCIC_PARAM_SIZE_ACCEPT_ESCO 21
|
||||
|
||||
#define HCI_ACCEPT_ESCO_BDADDR_OFF 0
|
||||
#define HCI_ACCEPT_ESCO_TX_BW_OFF 6
|
||||
#define HCI_ACCEPT_ESCO_RX_BW_OFF 10
|
||||
#define HCI_ACCEPT_ESCO_MAX_LAT_OFF 14
|
||||
#define HCI_ACCEPT_ESCO_VOICE_OFF 16
|
||||
#define HCI_ACCEPT_ESCO_RETRAN_EFF_OFF 18
|
||||
#define HCI_ACCEPT_ESCO_PKT_TYPES_OFF 19
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_reject_esco_conn (BD_ADDR bd_addr, UINT8 reason);
|
||||
#define HCIC_PARAM_SIZE_REJECT_ESCO 7
|
||||
|
||||
#define HCI_REJECT_ESCO_BDADDR_OFF 0
|
||||
#define HCI_REJECT_ESCO_REASON_OFF 6
|
||||
|
||||
/* Hold Mode */
|
||||
BOOLEAN btsnd_hcic_hold_mode(UINT16 handle, UINT16 max_hold_period,
|
||||
UINT16 min_hold_period);
|
||||
|
||||
#define HCIC_PARAM_SIZE_HOLD_MODE 6
|
||||
|
||||
#define HCI_HOLD_MODE_HANDLE_OFF 0
|
||||
#define HCI_HOLD_MODE_MAX_PER_OFF 2
|
||||
#define HCI_HOLD_MODE_MIN_PER_OFF 4
|
||||
/* Hold Mode */
|
||||
|
||||
/* Sniff Mode */
|
||||
BOOLEAN btsnd_hcic_sniff_mode(UINT16 handle,
|
||||
UINT16 max_sniff_period,
|
||||
UINT16 min_sniff_period,
|
||||
UINT16 sniff_attempt,
|
||||
UINT16 sniff_timeout);
|
||||
|
||||
#define HCIC_PARAM_SIZE_SNIFF_MODE 10
|
||||
|
||||
|
||||
#define HCI_SNIFF_MODE_HANDLE_OFF 0
|
||||
#define HCI_SNIFF_MODE_MAX_PER_OFF 2
|
||||
#define HCI_SNIFF_MODE_MIN_PER_OFF 4
|
||||
#define HCI_SNIFF_MODE_ATTEMPT_OFF 6
|
||||
#define HCI_SNIFF_MODE_TIMEOUT_OFF 8
|
||||
/* Sniff Mode */
|
||||
|
||||
BOOLEAN btsnd_hcic_exit_sniff_mode(UINT16 handle); /* Exit Sniff Mode */
|
||||
|
||||
/* Park Mode */
|
||||
BOOLEAN btsnd_hcic_park_mode (UINT16 handle,
|
||||
UINT16 beacon_max_interval,
|
||||
UINT16 beacon_min_interval);
|
||||
|
||||
#define HCIC_PARAM_SIZE_PARK_MODE 6
|
||||
|
||||
#define HCI_PARK_MODE_HANDLE_OFF 0
|
||||
#define HCI_PARK_MODE_MAX_PER_OFF 2
|
||||
#define HCI_PARK_MODE_MIN_PER_OFF 4
|
||||
/* Park Mode */
|
||||
|
||||
BOOLEAN btsnd_hcic_exit_park_mode(UINT16 handle); /* Exit Park Mode */
|
||||
|
||||
/* QoS Setup */
|
||||
BOOLEAN btsnd_hcic_qos_setup (UINT16 handle, UINT8 flags,
|
||||
UINT8 service_type,
|
||||
UINT32 token_rate, UINT32 peak,
|
||||
UINT32 latency, UINT32 delay_var);
|
||||
|
||||
#define HCIC_PARAM_SIZE_QOS_SETUP 20
|
||||
|
||||
#define HCI_QOS_HANDLE_OFF 0
|
||||
#define HCI_QOS_FLAGS_OFF 2
|
||||
#define HCI_QOS_SERVICE_TYPE_OFF 3
|
||||
#define HCI_QOS_TOKEN_RATE_OFF 4
|
||||
#define HCI_QOS_PEAK_BANDWIDTH_OFF 8
|
||||
#define HCI_QOS_LATENCY_OFF 12
|
||||
#define HCI_QOS_DELAY_VAR_OFF 16
|
||||
/* QoS Setup */
|
||||
|
||||
/* Switch Role Request */
|
||||
BOOLEAN btsnd_hcic_switch_role (BD_ADDR bd_addr, UINT8 role);
|
||||
|
||||
#define HCIC_PARAM_SIZE_SWITCH_ROLE 7
|
||||
|
||||
#define HCI_SWITCH_BD_ADDR_OFF 0
|
||||
#define HCI_SWITCH_ROLE_OFF 6
|
||||
/* Switch Role Request */
|
||||
|
||||
/* Write Policy Settings */
|
||||
BOOLEAN btsnd_hcic_write_policy_set(UINT16 handle, UINT16 settings);
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_POLICY_SET 4
|
||||
|
||||
#define HCI_WRITE_POLICY_HANDLE_OFF 0
|
||||
#define HCI_WRITE_POLICY_SETTINGS_OFF 2
|
||||
/* Write Policy Settings */
|
||||
|
||||
/* Write Default Policy Settings */
|
||||
BOOLEAN btsnd_hcic_write_def_policy_set(UINT16 settings);
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET 2
|
||||
|
||||
#define HCI_WRITE_DEF_POLICY_SETTINGS_OFF 0
|
||||
/* Write Default Policy Settings */
|
||||
|
||||
/******************************************
|
||||
** Lisbon Features
|
||||
*******************************************/
|
||||
#if BTM_SSR_INCLUDED == TRUE
|
||||
/* Sniff Subrating */
|
||||
BOOLEAN btsnd_hcic_sniff_sub_rate(UINT16 handle, UINT16 max_lat,
|
||||
UINT16 min_remote_lat,
|
||||
UINT16 min_local_lat);
|
||||
|
||||
#define HCIC_PARAM_SIZE_SNIFF_SUB_RATE 8
|
||||
|
||||
#define HCI_SNIFF_SUB_RATE_HANDLE_OFF 0
|
||||
#define HCI_SNIFF_SUB_RATE_MAX_LAT_OFF 2
|
||||
#define HCI_SNIFF_SUB_RATE_MIN_REM_LAT_OFF 4
|
||||
#define HCI_SNIFF_SUB_RATE_MIN_LOC_LAT_OFF 6
|
||||
/* Sniff Subrating */
|
||||
|
||||
#else /* BTM_SSR_INCLUDED == FALSE */
|
||||
|
||||
#define btsnd_hcic_sniff_sub_rate(handle, max_lat, min_remote_lat, min_local_lat) FALSE
|
||||
|
||||
#endif /* BTM_SSR_INCLUDED */
|
||||
|
||||
/* Extended Inquiry Response */
|
||||
void btsnd_hcic_write_ext_inquiry_response(void *buffer, UINT8 fec_req);
|
||||
|
||||
#define HCIC_PARAM_SIZE_EXT_INQ_RESP 241
|
||||
|
||||
#define HCIC_EXT_INQ_RESP_FEC_OFF 0
|
||||
#define HCIC_EXT_INQ_RESP_RESPONSE 1
|
||||
/* IO Capabilities Response */
|
||||
BOOLEAN btsnd_hcic_io_cap_req_reply (BD_ADDR bd_addr, UINT8 capability,
|
||||
UINT8 oob_present, UINT8 auth_req);
|
||||
|
||||
#define HCIC_PARAM_SIZE_IO_CAP_RESP 9
|
||||
|
||||
#define HCI_IO_CAP_BD_ADDR_OFF 0
|
||||
#define HCI_IO_CAPABILITY_OFF 6
|
||||
#define HCI_IO_CAP_OOB_DATA_OFF 7
|
||||
#define HCI_IO_CAP_AUTH_REQ_OFF 8
|
||||
|
||||
/* IO Capabilities Req Neg Reply */
|
||||
BOOLEAN btsnd_hcic_io_cap_req_neg_reply (BD_ADDR bd_addr, UINT8 err_code);
|
||||
|
||||
#define HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY 7
|
||||
|
||||
#define HCI_IO_CAP_NR_BD_ADDR_OFF 0
|
||||
#define HCI_IO_CAP_NR_ERR_CODE 6
|
||||
|
||||
/* Read Local OOB Data */
|
||||
BOOLEAN btsnd_hcic_read_local_oob_data (void);
|
||||
|
||||
#define HCIC_PARAM_SIZE_R_LOCAL_OOB 0
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_user_conf_reply (BD_ADDR bd_addr, BOOLEAN is_yes);
|
||||
|
||||
#define HCIC_PARAM_SIZE_UCONF_REPLY 6
|
||||
|
||||
#define HCI_USER_CONF_BD_ADDR_OFF 0
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_user_passkey_reply (BD_ADDR bd_addr, UINT32 value);
|
||||
|
||||
#define HCIC_PARAM_SIZE_U_PKEY_REPLY 10
|
||||
|
||||
#define HCI_USER_PASSKEY_BD_ADDR_OFF 0
|
||||
#define HCI_USER_PASSKEY_VALUE_OFF 6
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_user_passkey_neg_reply (BD_ADDR bd_addr);
|
||||
|
||||
#define HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY 6
|
||||
|
||||
#define HCI_USER_PASSKEY_NEG_BD_ADDR_OFF 0
|
||||
|
||||
/* Remote OOB Data Request Reply */
|
||||
BOOLEAN btsnd_hcic_rem_oob_reply (BD_ADDR bd_addr, UINT8 *p_c,
|
||||
UINT8 *p_r);
|
||||
|
||||
#define HCIC_PARAM_SIZE_REM_OOB_REPLY 38
|
||||
|
||||
#define HCI_REM_OOB_DATA_BD_ADDR_OFF 0
|
||||
#define HCI_REM_OOB_DATA_C_OFF 6
|
||||
#define HCI_REM_OOB_DATA_R_OFF 22
|
||||
|
||||
/* Remote OOB Data Request Negative Reply */
|
||||
BOOLEAN btsnd_hcic_rem_oob_neg_reply (BD_ADDR bd_addr);
|
||||
|
||||
#define HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY 6
|
||||
|
||||
#define HCI_REM_OOB_DATA_NEG_BD_ADDR_OFF 0
|
||||
|
||||
/* Read Tx Power Level */
|
||||
BOOLEAN btsnd_hcic_read_inq_tx_power (void);
|
||||
|
||||
#define HCIC_PARAM_SIZE_R_TX_POWER 0
|
||||
|
||||
/* Read Default Erroneous Data Reporting */
|
||||
BOOLEAN btsnd_hcic_read_default_erroneous_data_rpt (void);
|
||||
|
||||
#define HCIC_PARAM_SIZE_R_ERR_DATA_RPT 0
|
||||
|
||||
#if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
|
||||
BOOLEAN btsnd_hcic_enhanced_flush (UINT16 handle, UINT8 packet_type);
|
||||
|
||||
#define HCIC_PARAM_SIZE_ENHANCED_FLUSH 3
|
||||
#endif
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_send_keypress_notif (BD_ADDR bd_addr, UINT8 notif);
|
||||
|
||||
#define HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF 7
|
||||
|
||||
#define HCI_SEND_KEYPRESS_NOTIF_BD_ADDR_OFF 0
|
||||
#define HCI_SEND_KEYPRESS_NOTIF_NOTIF_OFF 6
|
||||
|
||||
/**** end of Simple Pairing Commands ****/
|
||||
|
||||
/* Store Current Settings */
|
||||
#define MAX_FILT_COND (sizeof (BD_ADDR) + 1)
|
||||
|
||||
BOOLEAN btsnd_hcic_set_event_filter(UINT8 filt_type,
|
||||
UINT8 filt_cond_type,
|
||||
UINT8 *filt_cond,
|
||||
UINT8 filt_cond_len);
|
||||
|
||||
#define HCIC_PARAM_SIZE_SET_EVT_FILTER 9
|
||||
|
||||
#define HCI_FILT_COND_FILT_TYPE_OFF 0
|
||||
#define HCI_FILT_COND_COND_TYPE_OFF 1
|
||||
#define HCI_FILT_COND_FILT_OFF 2
|
||||
/* Set Event Filter */
|
||||
|
||||
/* Delete Stored Key */
|
||||
BOOLEAN btsnd_hcic_delete_stored_key (BD_ADDR bd_addr, BOOLEAN delete_all_flag);
|
||||
|
||||
#define HCIC_PARAM_SIZE_DELETE_STORED_KEY 7
|
||||
|
||||
#define HCI_DELETE_KEY_BD_ADDR_OFF 0
|
||||
#define HCI_DELETE_KEY_ALL_FLAG_OFF 6
|
||||
/* Delete Stored Key */
|
||||
|
||||
/* Change Local Name */
|
||||
BOOLEAN btsnd_hcic_change_name(BD_NAME name);
|
||||
|
||||
#define HCIC_PARAM_SIZE_CHANGE_NAME BD_NAME_LEN
|
||||
|
||||
#define HCI_CHANGE_NAME_NAME_OFF 0
|
||||
/* Change Local Name */
|
||||
|
||||
|
||||
#define HCIC_PARAM_SIZE_READ_CMD 0
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_PARAM1 1
|
||||
|
||||
#define HCIC_WRITE_PARAM1_PARAM_OFF 0
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_PARAM2 2
|
||||
|
||||
#define HCIC_WRITE_PARAM2_PARAM_OFF 0
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_PARAM3 3
|
||||
|
||||
#define HCIC_WRITE_PARAM3_PARAM_OFF 0
|
||||
|
||||
#define HCIC_PARAM_SIZE_SET_AFH_CHANNELS 10
|
||||
|
||||
BOOLEAN btsnd_hcic_write_pin_type(UINT8 type); /* Write PIN Type */
|
||||
BOOLEAN btsnd_hcic_write_auto_accept(UINT8 flag); /* Write Auto Accept */
|
||||
BOOLEAN btsnd_hcic_read_name (void); /* Read Local Name */
|
||||
BOOLEAN btsnd_hcic_write_page_tout(UINT16 timeout); /* Write Page Timout */
|
||||
BOOLEAN btsnd_hcic_write_scan_enable(UINT8 flag); /* Write Scan Enable */
|
||||
BOOLEAN btsnd_hcic_write_pagescan_cfg(UINT16 interval,
|
||||
UINT16 window); /* Write Page Scan Activity */
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG 4
|
||||
|
||||
#define HCI_SCAN_CFG_INTERVAL_OFF 0
|
||||
#define HCI_SCAN_CFG_WINDOW_OFF 2
|
||||
/* Write Page Scan Activity */
|
||||
|
||||
/* Write Inquiry Scan Activity */
|
||||
BOOLEAN btsnd_hcic_write_inqscan_cfg(UINT16 interval, UINT16 window);
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG 4
|
||||
|
||||
#define HCI_SCAN_CFG_INTERVAL_OFF 0
|
||||
#define HCI_SCAN_CFG_WINDOW_OFF 2
|
||||
/* Write Inquiry Scan Activity */
|
||||
|
||||
BOOLEAN btsnd_hcic_write_auth_enable(UINT8 flag); /* Write Authentication Enable */
|
||||
BOOLEAN btsnd_hcic_write_dev_class(DEV_CLASS dev); /* Write Class of Device */
|
||||
BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags); /* Write Voice Settings */
|
||||
|
||||
/* Host Controller to Host flow control */
|
||||
#define HCI_HOST_FLOW_CTRL_OFF 0
|
||||
#define HCI_HOST_FLOW_CTRL_ACL_ON 1
|
||||
#define HCI_HOST_FLOW_CTRL_SCO_ON 2
|
||||
#define HCI_HOST_FLOW_CTRL_BOTH_ON 3
|
||||
|
||||
BOOLEAN btsnd_hcic_write_auto_flush_tout(UINT16 handle,
|
||||
UINT16 timeout); /* Write Retransmit Timout */
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT 4
|
||||
|
||||
#define HCI_FLUSH_TOUT_HANDLE_OFF 0
|
||||
#define HCI_FLUSH_TOUT_TOUT_OFF 2
|
||||
|
||||
BOOLEAN btsnd_hcic_read_tx_power(UINT16 handle, UINT8 type); /* Read Tx Power */
|
||||
|
||||
#define HCIC_PARAM_SIZE_READ_TX_POWER 3
|
||||
|
||||
#define HCI_READ_TX_POWER_HANDLE_OFF 0
|
||||
#define HCI_READ_TX_POWER_TYPE_OFF 2
|
||||
|
||||
/* Read transmit power level parameter */
|
||||
#define HCI_READ_CURRENT 0x00
|
||||
#define HCI_READ_MAXIMUM 0x01
|
||||
|
||||
BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles,
|
||||
UINT16 *handle,
|
||||
UINT16 *num_pkts); /* Set Host Buffer Size */
|
||||
|
||||
#define HCIC_PARAM_SIZE_NUM_PKTS_DONE_SIZE sizeof(btmsg_hcic_num_pkts_done_t)
|
||||
|
||||
#define MAX_DATA_HANDLES 10
|
||||
|
||||
#define HCI_PKTS_DONE_NUM_HANDLES_OFF 0
|
||||
#define HCI_PKTS_DONE_HANDLE_OFF 1
|
||||
#define HCI_PKTS_DONE_NUM_PKTS_OFF 3
|
||||
|
||||
/* Write Link Supervision Timeout */
|
||||
BOOLEAN btsnd_hcic_write_link_super_tout(UINT8 local_controller_id, UINT16 handle, UINT16 timeout);
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT 4
|
||||
|
||||
#define HCI_LINK_SUPER_TOUT_HANDLE_OFF 0
|
||||
#define HCI_LINK_SUPER_TOUT_TOUT_OFF 2
|
||||
/* Write Link Supervision Timeout */
|
||||
|
||||
BOOLEAN btsnd_hcic_write_cur_iac_lap (UINT8 num_cur_iac,
|
||||
LAP *const iac_lap); /* Write Current IAC LAP */
|
||||
|
||||
#define MAX_IAC_LAPS 0x40
|
||||
|
||||
#define HCI_WRITE_IAC_LAP_NUM_OFF 0
|
||||
#define HCI_WRITE_IAC_LAP_LAP_OFF 1
|
||||
/* Write Current IAC LAP */
|
||||
|
||||
BOOLEAN btsnd_hcic_get_link_quality (UINT16 handle); /* Get Link Quality */
|
||||
BOOLEAN btsnd_hcic_read_rssi (UINT16 handle); /* Read RSSI */
|
||||
BOOLEAN btsnd_hcic_enable_test_mode (void); /* Enable Device Under Test Mode */
|
||||
BOOLEAN btsnd_hcic_write_pagescan_type(UINT8 type); /* Write Page Scan Type */
|
||||
BOOLEAN btsnd_hcic_write_inqscan_type(UINT8 type); /* Write Inquiry Scan Type */
|
||||
BOOLEAN btsnd_hcic_write_inquiry_mode(UINT8 type); /* Write Inquiry Mode */
|
||||
|
||||
#define HCI_DATA_HANDLE_MASK 0x0FFF
|
||||
|
||||
#define HCID_GET_HANDLE_EVENT(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset) + \
|
||||
(*((UINT8 *)((p) + 1) + p->offset + 1) << 8)))
|
||||
|
||||
#define HCID_GET_HANDLE(u16) (UINT16)((u16) & HCI_DATA_HANDLE_MASK)
|
||||
|
||||
#define HCI_DATA_EVENT_MASK 3
|
||||
#define HCI_DATA_EVENT_OFFSET 12
|
||||
#define HCID_GET_EVENT(u16) (UINT8)(((u16) >> HCI_DATA_EVENT_OFFSET) & HCI_DATA_EVENT_MASK)
|
||||
|
||||
#define HCI_DATA_BCAST_MASK 3
|
||||
#define HCI_DATA_BCAST_OFFSET 10
|
||||
#define HCID_GET_BCAST(u16) (UINT8)(((u16) >> HCI_DATA_BCAST_OFFSET) & HCI_DATA_BCAST_MASK)
|
||||
|
||||
#define HCID_GET_ACL_LEN(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset + 2) + \
|
||||
(*((UINT8 *)((p) + 1) + p->offset + 3) << 8)))
|
||||
|
||||
#define HCID_HEADER_SIZE 4
|
||||
|
||||
#define HCID_GET_SCO_LEN(p) (*((UINT8 *)((p) + 1) + p->offset + 2))
|
||||
|
||||
void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode,
|
||||
UINT8 len, UINT8 *p_data,
|
||||
void *p_cmd_cplt_cback);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/********************************************************************************
|
||||
** BLE Commands
|
||||
** Note: "local_controller_id" is for transport, not counted in HCI message size
|
||||
*********************************************************************************/
|
||||
#define HCIC_BLE_RAND_DI_SIZE 8
|
||||
#define HCIC_BLE_ENCRYT_KEY_SIZE 16
|
||||
#define HCIC_BLE_IRK_SIZE 16
|
||||
|
||||
#define HCIC_PARAM_SIZE_SET_USED_FEAT_CMD 8
|
||||
#define HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD 6
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS 15
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP 31
|
||||
#define HCIC_PARAM_SIZE_WRITE_ADV_ENABLE 1
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM 7
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE 2
|
||||
#define HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN 25
|
||||
#define HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL 0
|
||||
#define HCIC_PARAM_SIZE_CLEAR_WHITE_LIST 0
|
||||
#define HCIC_PARAM_SIZE_ADD_WHITE_LIST 7
|
||||
#define HCIC_PARAM_SIZE_REMOVE_WHITE_LIST 7
|
||||
#define HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS 14
|
||||
#define HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS 5
|
||||
#define HCIC_PARAM_SIZE_READ_CHNL_MAP 2
|
||||
#define HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT 2
|
||||
#define HCIC_PARAM_SIZE_BLE_ENCRYPT 32
|
||||
#define HCIC_PARAM_SIZE_BLE_RAND 0
|
||||
#define HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED 2
|
||||
|
||||
#define HCIC_BLE_RAND_DI_SIZE 8
|
||||
#define HCIC_BLE_ENCRYT_KEY_SIZE 16
|
||||
#define HCIC_PARAM_SIZE_BLE_START_ENC (4 + HCIC_BLE_RAND_DI_SIZE + HCIC_BLE_ENCRYT_KEY_SIZE)
|
||||
#define HCIC_PARAM_SIZE_LTK_REQ_REPLY (2 + HCIC_BLE_ENCRYT_KEY_SIZE)
|
||||
#define HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY 2
|
||||
#define HCIC_BLE_CHNL_MAP_SIZE 5
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA 31
|
||||
|
||||
#define HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST (7 + HCIC_BLE_IRK_SIZE * 2)
|
||||
#define HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST 7
|
||||
#define HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST 0
|
||||
#define HCIC_PARAM_SIZE_BLE_READ_RESOLVING_LIST_SIZE 0
|
||||
#define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER 7
|
||||
#define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL 7
|
||||
#define HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE 1
|
||||
#define HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT 2
|
||||
#define HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH 6
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM 11
|
||||
|
||||
/* ULP HCI command */
|
||||
BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_buffer_size (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_local_spt_feat (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8]);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_random_addr (BD_ADDR random_addr);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
UINT8 adv_type, UINT8 addr_type_own,
|
||||
UINT8 addr_type_dir, BD_ADDR direct_bda,
|
||||
UINT8 channel_map, UINT8 adv_filter_policy);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
|
||||
UINT16 scan_int, UINT16 scan_win,
|
||||
UINT8 addr_type, UINT8 scan_filter_policy);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_create_ll_conn (UINT16 scan_int, UINT16 scan_win,
|
||||
UINT8 init_filter_policy, UINT8 addr_type_peer, BD_ADDR bda_peer, UINT8 addr_type_own,
|
||||
UINT16 conn_int_min, UINT16 conn_int_max, UINT16 conn_latency, UINT16 conn_timeout,
|
||||
UINT16 min_ce_len, UINT16 max_ce_len);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_create_conn_cancel (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_white_list_size (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_clear_white_list (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_add_white_list (UINT8 addr_type, BD_ADDR bda);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_remove_from_white_list (UINT8 addr_type, BD_ADDR bda);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_upd_ll_conn_params (UINT16 handle, UINT16 conn_int_min, UINT16 conn_int_max,
|
||||
UINT16 conn_latency, UINT16 conn_timeout, UINT16 min_len, UINT16 max_len);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_host_chnl_class (UINT8 chnl_map[HCIC_BLE_CHNL_MAP_SIZE]);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_chnl_map (UINT16 handle);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_remote_feat ( UINT16 handle);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_encrypt (UINT8 *key, UINT8 key_len, UINT8 *plain_text, UINT8 pt_len, void *p_cmd_cplt_cback);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_rand (void *p_cmd_cplt_cback);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_start_enc ( UINT16 handle,
|
||||
UINT8 rand[HCIC_BLE_RAND_DI_SIZE],
|
||||
UINT16 ediv, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_ltk_req_reply (UINT16 handle, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_ltk_req_neg_reply (UINT16 handle);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_supported_states (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_write_host_supported (UINT8 le_host_spt, UINT8 simul_le_host_spt);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_host_supported (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_receiver_test(UINT8 rx_freq);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_transmitter_test(UINT8 tx_freq, UINT8 test_data_len,
|
||||
UINT8 payload);
|
||||
BOOLEAN btsnd_hcic_ble_test_end(void);
|
||||
|
||||
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
|
||||
|
||||
#define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY 14
|
||||
BOOLEAN btsnd_hcic_ble_rc_param_req_reply(UINT16 handle,
|
||||
UINT16 conn_int_min, UINT16 conn_int_max,
|
||||
UINT16 conn_latency, UINT16 conn_timeout,
|
||||
UINT16 min_ce_len, UINT16 max_ce_len);
|
||||
|
||||
#define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY 3
|
||||
BOOLEAN btsnd_hcic_ble_rc_param_req_neg_reply(UINT16 handle, UINT8 reason);
|
||||
|
||||
#endif /* BLE_LLT_INCLUDED */
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_data_length(UINT16 conn_handle, UINT16 tx_octets,
|
||||
UINT16 tx_time);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_add_device_resolving_list (UINT8 addr_type_peer,
|
||||
BD_ADDR bda_peer,
|
||||
UINT8 irk_peer[HCIC_BLE_IRK_SIZE],
|
||||
UINT8 irk_local[HCIC_BLE_IRK_SIZE]);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_rm_device_resolving_list (UINT8 addr_type_peer,
|
||||
BD_ADDR bda_peer);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_clear_resolving_list (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_resolvable_addr_peer (UINT8 addr_type_peer,
|
||||
BD_ADDR bda_peer);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_resolvable_addr_local (UINT8 addr_type_peer,
|
||||
BD_ADDR bda_peer);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_addr_resolution_enable (UINT8 addr_resolution_enable);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_rand_priv_addr_timeout (UINT16 rpa_timout);
|
||||
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
||||
BOOLEAN btsnd_hcic_read_authenticated_payload_tout(UINT16 handle);
|
||||
|
||||
BOOLEAN btsnd_hcic_write_authenticated_payload_tout(UINT16 handle,
|
||||
UINT16 timeout);
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_AUTHENT_PAYLOAD_TOUT 4
|
||||
|
||||
#define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0
|
||||
#define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_TOUT_OFF 2
|
||||
|
||||
#endif
|
265
tools/sdk/include/bluedroid/hid_le_prf.h
Normal file
265
tools/sdk/include/bluedroid/hid_le_prf.h
Normal file
@ -0,0 +1,265 @@
|
||||
// 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.
|
||||
|
||||
#include "prf_defs.h"
|
||||
|
||||
#if (HIDD_LE_PROFILE_CFG)
|
||||
#include "bta_gatts_int.h"
|
||||
#include "bt_types.h"
|
||||
#include "bta_api.h"
|
||||
#include "gatt_api.h"
|
||||
#include "bt_app_api.h"
|
||||
|
||||
/// Maximal number of HIDS that can be added in the DB
|
||||
#ifndef USE_ONE_HIDS_INSTANCE
|
||||
#define HIDD_LE_NB_HIDS_INST_MAX (2)
|
||||
#else
|
||||
#define HIDD_LE_NB_HIDS_INST_MAX (1)
|
||||
#endif
|
||||
|
||||
// Number of HID reports defined in the service
|
||||
#define HID_NUM_REPORTS 9
|
||||
|
||||
|
||||
#define ATT_SVC_HID 0x1812
|
||||
|
||||
/// Maximal number of Report Char. that can be added in the DB for one HIDS - Up to 11
|
||||
#define HIDD_LE_NB_REPORT_INST_MAX (5)
|
||||
|
||||
/// Maximal length of Report Char. Value
|
||||
#define HIDD_LE_REPORT_MAX_LEN (45)
|
||||
/// Maximal length of Report Map Char. Value
|
||||
#define HIDD_LE_REPORT_MAP_MAX_LEN (512)
|
||||
|
||||
/// Length of Boot Report Char. Value Maximal Length
|
||||
#define HIDD_LE_BOOT_REPORT_MAX_LEN (8)
|
||||
|
||||
/// Boot KB Input Report Notification Configuration Bit Mask
|
||||
#define HIDD_LE_BOOT_KB_IN_NTF_CFG_MASK (0x40)
|
||||
/// Boot KB Input Report Notification Configuration Bit Mask
|
||||
#define HIDD_LE_BOOT_MOUSE_IN_NTF_CFG_MASK (0x80)
|
||||
/// Boot Report Notification Configuration Bit Mask
|
||||
#define HIDD_LE_REPORT_NTF_CFG_MASK (0x20)
|
||||
|
||||
|
||||
/* HID information flags */
|
||||
#define HID_FLAGS_REMOTE_WAKE 0x01 // RemoteWake
|
||||
#define HID_FLAGS_NORMALLY_CONNECTABLE 0x02 // NormallyConnectable
|
||||
|
||||
/* Control point commands */
|
||||
#define HID_CMD_SUSPEND 0x00 // Suspend
|
||||
#define HID_CMD_EXIT_SUSPEND 0x01 // Exit Suspend
|
||||
|
||||
/* HID protocol mode values */
|
||||
#define HID_PROTOCOL_MODE_BOOT 0x00 // Boot Protocol Mode
|
||||
#define HID_PROTOCOL_MODE_REPORT 0x01 // Report Protocol Mode
|
||||
|
||||
/* Attribute value lengths */
|
||||
#define HID_PROTOCOL_MODE_LEN 1 // HID Protocol Mode
|
||||
#define HID_INFORMATION_LEN 4 // HID Information
|
||||
#define HID_REPORT_REF_LEN 2 // HID Report Reference Descriptor
|
||||
#define HID_EXT_REPORT_REF_LEN 2 // External Report Reference Descriptor
|
||||
|
||||
// HID feature flags
|
||||
#define HID_KBD_FLAGS HID_FLAGS_REMOTE_WAKE
|
||||
|
||||
|
||||
/// HID Service Attributes Indexes
|
||||
enum {
|
||||
HIDD_LE_IDX_SVC,
|
||||
|
||||
// Included Service
|
||||
HIDD_LE_IDX_INCL_SVC,
|
||||
|
||||
// HID Information
|
||||
HIDD_LE_IDX_HID_INFO_CHAR,
|
||||
HIDD_LE_IDX_HID_INFO_VAL,
|
||||
|
||||
// HID Control Point
|
||||
HIDD_LE_IDX_HID_CTNL_PT_CHAR,
|
||||
HIDD_LE_IDX_HID_CTNL_PT_VAL,
|
||||
|
||||
// Report Map
|
||||
HIDD_LE_IDX_REPORT_MAP_CHAR,
|
||||
HIDD_LE_IDX_REPORT_MAP_VAL,
|
||||
HIDD_LE_IDX_REPORT_MAP_EXT_REP_REF,
|
||||
|
||||
// Protocol Mode
|
||||
HIDD_LE_IDX_PROTO_MODE_CHAR,
|
||||
HIDD_LE_IDX_PROTO_MODE_VAL,
|
||||
|
||||
// Boot Keyboard Input Report
|
||||
HIDD_LE_IDX_BOOT_KB_IN_REPORT_CHAR,
|
||||
HIDD_LE_IDX_BOOT_KB_IN_REPORT_VAL,
|
||||
HIDD_LE_IDX_BOOT_KB_IN_REPORT_NTF_CFG,
|
||||
|
||||
// Boot Keyboard Output Report
|
||||
HIDD_LE_IDX_BOOT_KB_OUT_REPORT_CHAR,
|
||||
HIDD_LE_IDX_BOOT_KB_OUT_REPORT_VAL,
|
||||
|
||||
// Boot Mouse Input Report
|
||||
HIDD_LE_IDX_BOOT_MOUSE_IN_REPORT_CHAR,
|
||||
HIDD_LE_IDX_BOOT_MOUSE_IN_REPORT_VAL,
|
||||
HIDD_LE_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG,
|
||||
|
||||
// Report
|
||||
HIDD_LE_IDX_REPORT_CHAR,
|
||||
HIDD_LE_IDX_REPORT_VAL,
|
||||
HIDD_LE_IDX_REPORT_REP_REF,
|
||||
HIDD_LE_IDX_REPORT_NTF_CFG,
|
||||
|
||||
HIDD_LE_IDX_NB,
|
||||
};
|
||||
|
||||
|
||||
/// Attribute Table Indexes
|
||||
enum {
|
||||
HIDD_LE_INFO_CHAR,
|
||||
HIDD_LE_CTNL_PT_CHAR,
|
||||
HIDD_LE_REPORT_MAP_CHAR,
|
||||
HIDD_LE_REPORT_CHAR,
|
||||
HIDD_LE_PROTO_MODE_CHAR,
|
||||
HIDD_LE_BOOT_KB_IN_REPORT_CHAR,
|
||||
HIDD_LE_BOOT_KB_OUT_REPORT_CHAR,
|
||||
HIDD_LE_BOOT_MOUSE_IN_REPORT_CHAR,
|
||||
HIDD_LE_CHAR_MAX //= HIDD_LE_REPORT_CHAR + HIDD_LE_NB_REPORT_INST_MAX,
|
||||
};
|
||||
|
||||
///att read event table Indexs
|
||||
enum {
|
||||
HIDD_LE_READ_INFO_EVT,
|
||||
HIDD_LE_READ_CTNL_PT_EVT,
|
||||
HIDD_LE_READ_REPORT_MAP_EVT,
|
||||
HIDD_LE_READ_REPORT_EVT,
|
||||
HIDD_LE_READ_PROTO_MODE_EVT,
|
||||
HIDD_LE_BOOT_KB_IN_REPORT_EVT,
|
||||
HIDD_LE_BOOT_KB_OUT_REPORT_EVT,
|
||||
HIDD_LE_BOOT_MOUSE_IN_REPORT_EVT,
|
||||
|
||||
HID_LE_EVT_MAX
|
||||
};
|
||||
|
||||
/// Client Characteristic Configuration Codes
|
||||
enum {
|
||||
HIDD_LE_DESC_MASK = 0x10,
|
||||
|
||||
HIDD_LE_BOOT_KB_IN_REPORT_CFG = HIDD_LE_BOOT_KB_IN_REPORT_CHAR | HIDD_LE_DESC_MASK,
|
||||
HIDD_LE_BOOT_MOUSE_IN_REPORT_CFG = HIDD_LE_BOOT_MOUSE_IN_REPORT_CHAR | HIDD_LE_DESC_MASK,
|
||||
HIDD_LE_REPORT_CFG = HIDD_LE_REPORT_CHAR | HIDD_LE_DESC_MASK,
|
||||
};
|
||||
|
||||
/// Features Flag Values
|
||||
enum {
|
||||
HIDD_LE_CFG_KEYBOARD = 0x01,
|
||||
HIDD_LE_CFG_MOUSE = 0x02,
|
||||
HIDD_LE_CFG_PROTO_MODE = 0x04,
|
||||
HIDD_LE_CFG_MAP_EXT_REF = 0x08,
|
||||
HIDD_LE_CFG_BOOT_KB_WR = 0x10,
|
||||
HIDD_LE_CFG_BOOT_MOUSE_WR = 0x20,
|
||||
};
|
||||
|
||||
/// Report Char. Configuration Flag Values
|
||||
enum {
|
||||
HIDD_LE_CFG_REPORT_IN = 0x01,
|
||||
HIDD_LE_CFG_REPORT_OUT = 0x02,
|
||||
//HOGPD_CFG_REPORT_FEAT can be used as a mask to check Report type
|
||||
HIDD_LE_CFG_REPORT_FEAT = 0x03,
|
||||
HIDD_LE_CFG_REPORT_WR = 0x10,
|
||||
};
|
||||
|
||||
/// Pointer to the connection clean-up function
|
||||
#define HIDD_LE_CLEANUP_FNCT (NULL)
|
||||
|
||||
/*
|
||||
* TYPE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// HIDD Features structure
|
||||
typedef struct {
|
||||
/// Service Features
|
||||
uint8_t svc_features;
|
||||
/// Number of Report Char. instances to add in the database
|
||||
uint8_t report_nb;
|
||||
/// Report Char. Configuration
|
||||
uint8_t report_char_cfg[HIDD_LE_NB_REPORT_INST_MAX];
|
||||
} hidd_feature_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN congest;
|
||||
uint16_t conn_id;
|
||||
BOOLEAN connected;
|
||||
BD_ADDR remote_bda;
|
||||
uint32_t trans_id;
|
||||
uint8_t cur_srvc_id;
|
||||
|
||||
} hidd_clcb_t;
|
||||
|
||||
// HID report mapping table
|
||||
typedef struct {
|
||||
uint16_t handle; // Handle of report characteristic
|
||||
uint16_t cccdHandle; // Handle of CCCD for report characteristic
|
||||
uint8_t id; // Report ID
|
||||
uint8_t type; // Report type
|
||||
uint8_t mode; // Protocol mode (report or boot)
|
||||
} hidRptMap_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
/// hidd profile id
|
||||
uint8_t app_id;
|
||||
/// Notified handle
|
||||
uint16_t ntf_handle;
|
||||
///Attribute handle Table
|
||||
uint16_t att_tbl[HIDD_LE_CHAR_MAX];
|
||||
/// Supported Features
|
||||
hidd_feature_t hidd_feature[HIDD_LE_NB_HIDS_INST_MAX];
|
||||
/// Current Protocol Mode
|
||||
uint8_t proto_mode[HIDD_LE_NB_HIDS_INST_MAX];
|
||||
/// Number of HIDS added in the database
|
||||
uint8_t hids_nb;
|
||||
uint8_t pending_evt;
|
||||
uint16_t pending_hal;
|
||||
} hidd_inst_t;
|
||||
|
||||
|
||||
/* service engine control block */
|
||||
typedef struct {
|
||||
hidd_clcb_t hidd_clcb; /* connection link*/
|
||||
esp_gatt_if_t gatt_if;
|
||||
BOOLEAN enabled;
|
||||
BOOLEAN is_primery;
|
||||
hidd_inst_t hidd_inst;
|
||||
uint8_t inst_id;
|
||||
} hidd_le_env_t;
|
||||
|
||||
extern hidd_le_env_t hidd_le_env;
|
||||
|
||||
|
||||
void hidd_le_create_service(BOOLEAN is_primary);
|
||||
|
||||
void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id,
|
||||
esp_gatt_status_t status, uint8_t event, tGATTS_DATA *p_rsp);
|
||||
|
||||
void hidd_read_attr_value(tGATTS_DATA *p_data, uint32_t trans_id);
|
||||
|
||||
|
||||
tGATT_STATUS hidd_le_init (void);
|
||||
|
||||
|
||||
#endif ///HIDD_LE_PROFILE_CFG
|
||||
|
||||
|
156
tools/sdk/include/bluedroid/hiddefs.h
Normal file
156
tools/sdk/include/bluedroid/hiddefs.h
Normal file
@ -0,0 +1,156 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-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 HID protocol definitions
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef HIDDEFS_H
|
||||
#define HIDDEFS_H
|
||||
|
||||
#include "sdp_api.h"
|
||||
/*
|
||||
** tHID_STATUS: HID result codes, returned by HID and device and host functions.
|
||||
*/
|
||||
enum {
|
||||
HID_SUCCESS,
|
||||
HID_ERR_NOT_REGISTERED,
|
||||
HID_ERR_ALREADY_REGISTERED,
|
||||
HID_ERR_NO_RESOURCES,
|
||||
HID_ERR_NO_CONNECTION,
|
||||
HID_ERR_INVALID_PARAM,
|
||||
HID_ERR_UNSUPPORTED,
|
||||
HID_ERR_UNKNOWN_COMMAND,
|
||||
HID_ERR_CONGESTED,
|
||||
HID_ERR_CONN_IN_PROCESS,
|
||||
HID_ERR_ALREADY_CONN,
|
||||
HID_ERR_DISCONNECTING,
|
||||
HID_ERR_SET_CONNABLE_FAIL,
|
||||
/* Device specific error codes */
|
||||
HID_ERR_HOST_UNKNOWN,
|
||||
HID_ERR_L2CAP_FAILED,
|
||||
HID_ERR_AUTH_FAILED,
|
||||
HID_ERR_SDP_BUSY,
|
||||
HID_ERR_GATT,
|
||||
|
||||
HID_ERR_INVALID = 0xFF
|
||||
};
|
||||
|
||||
typedef UINT8 tHID_STATUS;
|
||||
|
||||
#define HID_L2CAP_CONN_FAIL (0x0100) /* Connection Attempt was made but failed */
|
||||
#define HID_L2CAP_REQ_FAIL (0x0200) /* L2CAP_ConnectReq API failed */
|
||||
#define HID_L2CAP_CFG_FAIL (0x0400) /* L2CAP Configuration was rejected by peer */
|
||||
|
||||
|
||||
|
||||
/* Define the HID transaction types
|
||||
*/
|
||||
#define HID_TRANS_HANDSHAKE (0)
|
||||
#define HID_TRANS_CONTROL (1)
|
||||
#define HID_TRANS_GET_REPORT (4)
|
||||
#define HID_TRANS_SET_REPORT (5)
|
||||
#define HID_TRANS_GET_PROTOCOL (6)
|
||||
#define HID_TRANS_SET_PROTOCOL (7)
|
||||
#define HID_TRANS_GET_IDLE (8)
|
||||
#define HID_TRANS_SET_IDLE (9)
|
||||
#define HID_TRANS_DATA (10)
|
||||
#define HID_TRANS_DATAC (11)
|
||||
|
||||
#define HID_GET_TRANS_FROM_HDR(x) ((x >> 4) & 0x0f)
|
||||
#define HID_GET_PARAM_FROM_HDR(x) (x & 0x0f)
|
||||
#define HID_BUILD_HDR(t,p) (UINT8)((t << 4) | (p & 0x0f))
|
||||
|
||||
|
||||
/* Parameters for Handshake
|
||||
*/
|
||||
#define HID_PAR_HANDSHAKE_RSP_SUCCESS (0)
|
||||
#define HID_PAR_HANDSHAKE_RSP_NOT_READY (1)
|
||||
#define HID_PAR_HANDSHAKE_RSP_ERR_INVALID_REP_ID (2)
|
||||
#define HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ (3)
|
||||
#define HID_PAR_HANDSHAKE_RSP_ERR_INVALID_PARAM (4)
|
||||
#define HID_PAR_HANDSHAKE_RSP_ERR_UNKNOWN (14)
|
||||
#define HID_PAR_HANDSHAKE_RSP_ERR_FATAL (15)
|
||||
|
||||
|
||||
/* Parameters for Control
|
||||
*/
|
||||
#define HID_PAR_CONTROL_NOP (0)
|
||||
#define HID_PAR_CONTROL_HARD_RESET (1)
|
||||
#define HID_PAR_CONTROL_SOFT_RESET (2)
|
||||
#define HID_PAR_CONTROL_SUSPEND (3)
|
||||
#define HID_PAR_CONTROL_EXIT_SUSPEND (4)
|
||||
#define HID_PAR_CONTROL_VIRTUAL_CABLE_UNPLUG (5)
|
||||
|
||||
|
||||
/* Different report types in get, set, data
|
||||
*/
|
||||
#define HID_PAR_REP_TYPE_MASK (0x03)
|
||||
#define HID_PAR_REP_TYPE_OTHER (0x00)
|
||||
#define HID_PAR_REP_TYPE_INPUT (0x01)
|
||||
#define HID_PAR_REP_TYPE_OUTPUT (0x02)
|
||||
#define HID_PAR_REP_TYPE_FEATURE (0x03)
|
||||
|
||||
/* Parameters for Get Report
|
||||
*/
|
||||
|
||||
/* Buffer size in two bytes after Report ID */
|
||||
#define HID_PAR_GET_REP_BUFSIZE_FOLLOWS (0x08)
|
||||
|
||||
|
||||
/* Parameters for Protocol Type
|
||||
*/
|
||||
#define HID_PAR_PROTOCOL_MASK (0x01)
|
||||
#define HID_PAR_PROTOCOL_REPORT (0x01)
|
||||
#define HID_PAR_PROTOCOL_BOOT_MODE (0x00)
|
||||
|
||||
#define HID_PAR_REP_TYPE_MASK (0x03)
|
||||
|
||||
/* Descriptor types in the SDP record
|
||||
*/
|
||||
#define HID_SDP_DESCRIPTOR_REPORT (0x22)
|
||||
#define HID_SDP_DESCRIPTOR_PHYSICAL (0x23)
|
||||
|
||||
typedef struct desc_info {
|
||||
UINT16 dl_len;
|
||||
UINT8 *dsc_list;
|
||||
} tHID_DEV_DSCP_INFO;
|
||||
|
||||
#define HID_SSR_PARAM_INVALID 0xffff
|
||||
|
||||
typedef struct sdp_info {
|
||||
char svc_name[HID_MAX_SVC_NAME_LEN]; /*Service Name */
|
||||
char svc_descr[HID_MAX_SVC_DESCR_LEN]; /*Service Description*/
|
||||
char prov_name[HID_MAX_PROV_NAME_LEN]; /*Provider Name.*/
|
||||
UINT16 rel_num; /*Release Number */
|
||||
UINT16 hpars_ver; /*HID Parser Version.*/
|
||||
UINT16 ssr_max_latency; /* HIDSSRHostMaxLatency value, if HID_SSR_PARAM_INVALID not used*/
|
||||
UINT16 ssr_min_tout; /* HIDSSRHostMinTimeout value, if HID_SSR_PARAM_INVALID not used* */
|
||||
UINT8 sub_class; /*Device Subclass.*/
|
||||
UINT8 ctry_code; /*Country Code.*/
|
||||
UINT16 sup_timeout;/* Supervisory Timeout */
|
||||
|
||||
tHID_DEV_DSCP_INFO dscp_info; /* Descriptor list and Report list to be set in the SDP record.
|
||||
This parameter is used if HID_DEV_USE_GLB_SDP_REC is set to FALSE.*/
|
||||
tSDP_DISC_REC *p_sdp_layer_rec;
|
||||
} tHID_DEV_SDP_INFO;
|
||||
|
||||
#endif
|
||||
|
235
tools/sdk/include/bluedroid/hidh_api.h
Normal file
235
tools/sdk/include/bluedroid/hidh_api.h
Normal file
@ -0,0 +1,235 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef HIDH_API_H
|
||||
#define HIDH_API_H
|
||||
|
||||
#include "hiddefs.h"
|
||||
#include "sdp_api.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
enum {
|
||||
HID_SDP_NO_SERV_UUID = (SDP_ILLEGAL_PARAMETER + 1),
|
||||
HID_SDP_MANDATORY_MISSING
|
||||
};
|
||||
|
||||
/* Attributes mask values to be used in HID_HostAddDev API */
|
||||
#define HID_VIRTUAL_CABLE 0x0001
|
||||
#define HID_NORMALLY_CONNECTABLE 0x0002
|
||||
#define HID_RECONN_INIT 0x0004
|
||||
#define HID_SDP_DISABLE 0x0008
|
||||
#define HID_BATTERY_POWER 0x0010
|
||||
#define HID_REMOTE_WAKE 0x0020
|
||||
#define HID_SUP_TOUT_AVLBL 0x0040
|
||||
#define HID_SSR_MAX_LATENCY 0x0080
|
||||
#define HID_SSR_MIN_TOUT 0x0100
|
||||
|
||||
#define HID_SEC_REQUIRED 0x8000
|
||||
#define HID_ATTR_MASK_IGNORE 0
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
typedef void (tHID_HOST_SDP_CALLBACK) (UINT16 result, UINT16 attr_mask,
|
||||
tHID_DEV_SDP_INFO *sdp_rec );
|
||||
|
||||
/* HID-HOST returns the events in the following table to the application via tHID_HOST_DEV_CALLBACK
|
||||
HID_HDEV_EVT_OPEN Connected to device with Interrupt and Control Channels in OPEN state.
|
||||
Data = NA
|
||||
HID_HDEV_EVT_CLOSE Connection with device is closed. Data=reason code.
|
||||
HID_HDEV_EVT_RETRYING Lost connection is being re-connected.
|
||||
Data=Retrial number
|
||||
HID_HDEV_EVT_IN_REPORT Device sent an input report Data=Report Type pdata= pointer to BT_HDR
|
||||
(GKI buffer having report data.)
|
||||
HID_HDEV_EVT_HANDSHAKE Device sent SET_REPORT Data=Result-code pdata=NA.
|
||||
HID_HDEV_EVT_VC_UNPLUG Device sent Virtual Unplug Data=NA. pdata=NA.
|
||||
*/
|
||||
|
||||
enum {
|
||||
HID_HDEV_EVT_OPEN,
|
||||
HID_HDEV_EVT_CLOSE,
|
||||
HID_HDEV_EVT_RETRYING,
|
||||
HID_HDEV_EVT_INTR_DATA,
|
||||
HID_HDEV_EVT_INTR_DATC,
|
||||
HID_HDEV_EVT_CTRL_DATA,
|
||||
HID_HDEV_EVT_CTRL_DATC,
|
||||
HID_HDEV_EVT_HANDSHAKE,
|
||||
HID_HDEV_EVT_VC_UNPLUG
|
||||
};
|
||||
typedef void (tHID_HOST_DEV_CALLBACK) (UINT8 dev_handle,
|
||||
BD_ADDR addr,
|
||||
UINT8 event, /* Event from HID-DEVICE. */
|
||||
UINT32 data, /* Integer data corresponding to the event.*/
|
||||
BT_HDR *p_buf ); /* Pointer data corresponding to the event. */
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostGetSDPRecord
|
||||
**
|
||||
** Description This function reads the device SDP record.
|
||||
**
|
||||
** Returns tHID_STATUS
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostGetSDPRecord (BD_ADDR addr,
|
||||
tSDP_DISCOVERY_DB *p_db,
|
||||
UINT32 db_len,
|
||||
tHID_HOST_SDP_CALLBACK *sdp_cback );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostRegister
|
||||
**
|
||||
** Description This function registers HID-Host with lower layers.
|
||||
**
|
||||
** Returns tHID_STATUS
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostRegister (tHID_HOST_DEV_CALLBACK *dev_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostDeregister
|
||||
**
|
||||
** Description This function is called when the host is about power down.
|
||||
**
|
||||
** Returns tHID_STATUS
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostDeregister(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostAddDev
|
||||
**
|
||||
** Description This is called so HID-host may manage this device.
|
||||
**
|
||||
** Returns tHID_STATUS
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostAddDev (BD_ADDR addr, UINT16 attr_mask,
|
||||
UINT8 *handle );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostRemoveDev
|
||||
**
|
||||
** Description This removes the device from list devices that host has to manage.
|
||||
**
|
||||
** Returns tHID_STATUS
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostRemoveDev (UINT8 dev_handle );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostOpenDev
|
||||
**
|
||||
** Description This function is called when the user wants to initiate a
|
||||
** connection attempt to a device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostOpenDev (UINT8 dev_handle );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostWriteDev
|
||||
**
|
||||
** Description This function is called when the host has a report to send.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostWriteDev(UINT8 dev_handle, UINT8 t_type,
|
||||
UINT8 param, UINT16 data,
|
||||
UINT8 report_id, BT_HDR *pbuf);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostCloseDev
|
||||
**
|
||||
** Description This function disconnects the device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostCloseDev(UINT8 dev_handle );
|
||||
|
||||
/*******************************************************************************
|
||||
** Function HID_HostInit
|
||||
**
|
||||
** Description This function initializes the control block and trace variable
|
||||
**
|
||||
** Returns void
|
||||
*******************************************************************************/
|
||||
extern void HID_HostInit(void);
|
||||
|
||||
/*******************************************************************************
|
||||
** Function HID_HostSetSecurityLevel
|
||||
**
|
||||
** Description This function sets the security level for the devices which
|
||||
** are marked by application as requiring security
|
||||
**
|
||||
** Returns tHID_STATUS
|
||||
*******************************************************************************/
|
||||
extern tHID_STATUS HID_HostSetSecurityLevel( char serv_name[], UINT8 sec_lvl );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function hid_known_hid_device
|
||||
**
|
||||
** Description This function checks if this device is of type HID Device
|
||||
**
|
||||
** Returns TRUE if device exists else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN hid_known_hid_device (BD_ADDR bd_addr);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostSetTraceLevel
|
||||
**
|
||||
** Description This function sets the trace level for HID Host. If called with
|
||||
** a value of 0xFF, it simply reads the current trace level.
|
||||
**
|
||||
** Returns the new (current) trace level
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 HID_HostSetTraceLevel (UINT8 new_level);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HIDH_API_H */
|
44
tools/sdk/include/bluedroid/interop.h
Normal file
44
tools/sdk/include/bluedroid/interop.h
Normal file
@ -0,0 +1,44 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Google, Inc.
|
||||
*
|
||||
* 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 _INTEROP_H_
|
||||
#define _INTEROP_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "bt_defs.h"
|
||||
|
||||
typedef enum {
|
||||
// Disable secure connections
|
||||
// This is for pre BT 4.1/2 devices that do not handle secure mode
|
||||
// very well.
|
||||
INTEROP_DISABLE_LE_SECURE_CONNECTIONS,
|
||||
|
||||
// Some devices have proven problematic during the pairing process, often
|
||||
// requiring multiple retries to complete pairing. To avoid degrading the user
|
||||
// experience for those devices, automatically re-try pairing if page
|
||||
// timeouts are received during pairing.
|
||||
INTEROP_AUTO_RETRY_PAIRING
|
||||
} interop_feature_t;
|
||||
|
||||
// Check if a given |addr| matches a known interoperability workaround as identified
|
||||
// by the |interop_feature_t| enum. This API is used for simple address based lookups
|
||||
// where more information is not available. No look-ups or random address resolution
|
||||
// is performed on |addr|.
|
||||
bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr);
|
||||
|
||||
#endif /*_INTEROP_H_*/
|
50
tools/sdk/include/bluedroid/interop_database.h
Normal file
50
tools/sdk/include/bluedroid/interop_database.h
Normal file
@ -0,0 +1,50 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Google, Inc.
|
||||
*
|
||||
* 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 _INTEROP_DATABASE_H_
|
||||
#define _INTEROP_DATABASE_H_
|
||||
|
||||
#include "interop.h"
|
||||
|
||||
typedef struct {
|
||||
bt_bdaddr_t addr;
|
||||
uint8_t len;
|
||||
interop_feature_t feature;
|
||||
} interop_entry_t;
|
||||
|
||||
static const interop_entry_t interop_database[] = {
|
||||
// Nexus Remote (Spike)
|
||||
// Note: May affect other Asus brand devices
|
||||
{{{0x08, 0x62, 0x66, 0, 0, 0}}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS},
|
||||
{{{0x38, 0x2c, 0x4a, 0xc9, 0, 0}}, 4, INTEROP_DISABLE_LE_SECURE_CONNECTIONS},
|
||||
{{{0x38, 0x2c, 0x4a, 0xe6, 0, 0}}, 4, INTEROP_DISABLE_LE_SECURE_CONNECTIONS},
|
||||
{{{0x54, 0xa0, 0x50, 0xd9, 0, 0}}, 4, INTEROP_DISABLE_LE_SECURE_CONNECTIONS},
|
||||
{{{0xac, 0x9e, 0x17, 0, 0, 0}}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS},
|
||||
{{{0xf0, 0x79, 0x59, 0, 0, 0}}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS},
|
||||
|
||||
// Motorola Key Link
|
||||
{{{0x1c, 0x96, 0x5a, 0, 0, 0}}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS},
|
||||
|
||||
// Flic smart button
|
||||
{{{0x80, 0xe4, 0xda, 0x70, 0, 0}}, 4, INTEROP_DISABLE_LE_SECURE_CONNECTIONS},
|
||||
|
||||
// BMW car kits (Harman/Becker)
|
||||
{{{0x9c, 0xdf, 0x03, 0, 0, 0}}, 3, INTEROP_AUTO_RETRY_PAIRING}
|
||||
};
|
||||
|
||||
#endif /*_INTEROP_DATABASE_H_*/
|
1137
tools/sdk/include/bluedroid/l2c_api.h
Normal file
1137
tools/sdk/include/bluedroid/l2c_api.h
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user