mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-03 20:54:18 +00:00
sink initiator smg pts tests
This commit is contained in:
parent
b6a2be33c1
commit
3338b9aef0
@ -1208,19 +1208,64 @@ typedef uint8_t sm_key_t[16];
|
||||
|
||||
/** AVDTP Subevent */
|
||||
|
||||
// /**
|
||||
// * @format 11HB
|
||||
// * @param subevent_code
|
||||
// * @param status 0 == OK
|
||||
// * @param con_handle
|
||||
// * @param bd_addr
|
||||
// */
|
||||
// #define AVDTP_SUBEVENT_CONNECTION_ESTABLISHED 0x01
|
||||
/**
|
||||
* @format 1HB1
|
||||
* @param subevent_code
|
||||
* @param con_handle
|
||||
* @param bd_addr
|
||||
* @param status 0 == OK
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED 0x01
|
||||
|
||||
// /**
|
||||
// * @format 1
|
||||
// * @param subevent_code
|
||||
// */
|
||||
// #define AVDTP_SUBEVENT_CONNECTION_RELEASED 0x02
|
||||
/**
|
||||
* @format 1
|
||||
* @param subevent_code
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_SIGNALING_CONNECTION_RELEASED 0x02
|
||||
|
||||
/**
|
||||
* @format 1H1111
|
||||
* @param subevent_code
|
||||
* @param handle
|
||||
* @param seid 0x01 – 0x3E
|
||||
* @param in_use 0-not in use, 1-in use
|
||||
* @param media_type 0-audio, 1-video, 2-multimedia
|
||||
* @param sep_type 0-source, 1-sink
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_SIGNALING_SEP_FOUND 0x03
|
||||
|
||||
/**
|
||||
* @format 1H1
|
||||
* @param subevent_code
|
||||
* @param con_handle
|
||||
* @param status 0 == OK
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_SIGNALING_DONE 0x04
|
||||
|
||||
/**
|
||||
* @format 1H11111111
|
||||
* @param subevent_code
|
||||
* @param con_handle
|
||||
* @param media_type
|
||||
* @param sampling_frequency
|
||||
* @param channel_mode
|
||||
* @param block_length
|
||||
* @param subbands
|
||||
* @param allocation_method
|
||||
* @param min_bitpool_value
|
||||
* @param max_bitpool_value
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC 0x05
|
||||
|
||||
/**
|
||||
* @format 1H122
|
||||
* @param subevent_code
|
||||
* @param con_handle
|
||||
* @param media_type
|
||||
* @param media_codec_type
|
||||
* @param media_codec_information_len
|
||||
* @param media_codec_information
|
||||
*/
|
||||
#define AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER 0x06
|
||||
|
||||
#endif
|
||||
|
@ -3792,6 +3792,219 @@ static inline hci_con_handle_t ancs_subevent_client_disconnected_get_handle(cons
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get field con_handle from event AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED
|
||||
* @param event packet
|
||||
* @return con_handle
|
||||
* @note: btstack_type H
|
||||
*/
|
||||
static inline hci_con_handle_t avdtp_subevent_signaling_connection_established_get_con_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field bd_addr from event AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED
|
||||
* @param event packet
|
||||
* @param Pointer to storage for bd_addr
|
||||
* @note: btstack_type B
|
||||
*/
|
||||
static inline void avdtp_subevent_signaling_connection_established_get_bd_addr(const uint8_t * event, bd_addr_t bd_addr){
|
||||
reverse_bd_addr(&event[5], bd_addr);
|
||||
}
|
||||
/**
|
||||
* @brief Get field status from event AVDTP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED
|
||||
* @param event packet
|
||||
* @return status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_connection_established_get_status(const uint8_t * event){
|
||||
return event[11];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get field handle from event AVDTP_SUBEVENT_SIGNALING_SEP_FOUND
|
||||
* @param event packet
|
||||
* @return handle
|
||||
* @note: btstack_type H
|
||||
*/
|
||||
static inline hci_con_handle_t avdtp_subevent_signaling_sep_found_get_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field seid from event AVDTP_SUBEVENT_SIGNALING_SEP_FOUND
|
||||
* @param event packet
|
||||
* @return seid
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_sep_found_get_seid(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field in_use from event AVDTP_SUBEVENT_SIGNALING_SEP_FOUND
|
||||
* @param event packet
|
||||
* @return in_use
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_sep_found_get_in_use(const uint8_t * event){
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_type from event AVDTP_SUBEVENT_SIGNALING_SEP_FOUND
|
||||
* @param event packet
|
||||
* @return media_type
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_sep_found_get_media_type(const uint8_t * event){
|
||||
return event[7];
|
||||
}
|
||||
/**
|
||||
* @brief Get field sep_type from event AVDTP_SUBEVENT_SIGNALING_SEP_FOUND
|
||||
* @param event packet
|
||||
* @return sep_type
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_sep_found_get_sep_type(const uint8_t * event){
|
||||
return event[8];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field con_handle from event AVDTP_SUBEVENT_SIGNALING_DONE
|
||||
* @param event packet
|
||||
* @return con_handle
|
||||
* @note: btstack_type H
|
||||
*/
|
||||
static inline hci_con_handle_t avdtp_subevent_signaling_done_get_con_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field status from event AVDTP_SUBEVENT_SIGNALING_DONE
|
||||
* @param event packet
|
||||
* @return status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_done_get_status(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field con_handle from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC
|
||||
* @param event packet
|
||||
* @return con_handle
|
||||
* @note: btstack_type H
|
||||
*/
|
||||
static inline hci_con_handle_t avdtp_subevent_signaling_media_codec_sbc_get_con_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_type from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC
|
||||
* @param event packet
|
||||
* @return media_type
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_get_media_type(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field sampling_frequency from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC
|
||||
* @param event packet
|
||||
* @return sampling_frequency
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_get_sampling_frequency(const uint8_t * event){
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field channel_mode from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC
|
||||
* @param event packet
|
||||
* @return channel_mode
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_get_channel_mode(const uint8_t * event){
|
||||
return event[7];
|
||||
}
|
||||
/**
|
||||
* @brief Get field block_length from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC
|
||||
* @param event packet
|
||||
* @return block_length
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_get_block_length(const uint8_t * event){
|
||||
return event[8];
|
||||
}
|
||||
/**
|
||||
* @brief Get field subbands from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC
|
||||
* @param event packet
|
||||
* @return subbands
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_get_subbands(const uint8_t * event){
|
||||
return event[9];
|
||||
}
|
||||
/**
|
||||
* @brief Get field allocation_method from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC
|
||||
* @param event packet
|
||||
* @return allocation_method
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_get_allocation_method(const uint8_t * event){
|
||||
return event[10];
|
||||
}
|
||||
/**
|
||||
* @brief Get field min_bitpool_value from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC
|
||||
* @param event packet
|
||||
* @return min_bitpool_value
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_get_min_bitpool_value(const uint8_t * event){
|
||||
return event[11];
|
||||
}
|
||||
/**
|
||||
* @brief Get field max_bitpool_value from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_SBC
|
||||
* @param event packet
|
||||
* @return max_bitpool_value
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_sbc_get_max_bitpool_value(const uint8_t * event){
|
||||
return event[12];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field con_handle from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER
|
||||
* @param event packet
|
||||
* @return con_handle
|
||||
* @note: btstack_type H
|
||||
*/
|
||||
static inline hci_con_handle_t avdtp_subevent_signaling_media_codec_other_get_con_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_type from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER
|
||||
* @param event packet
|
||||
* @return media_type
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t avdtp_subevent_signaling_media_codec_other_get_media_type(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_codec_type from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER
|
||||
* @param event packet
|
||||
* @return media_codec_type
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t avdtp_subevent_signaling_media_codec_other_get_media_codec_type(const uint8_t * event){
|
||||
return little_endian_read_16(event, 6);
|
||||
}
|
||||
/**
|
||||
* @brief Get field media_codec_information_len from event AVDTP_SUBEVENT_SIGNALING_MEDIA_CODEC_OTHER
|
||||
* @param event packet
|
||||
* @return media_codec_information_len
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t avdtp_subevent_signaling_media_codec_other_get_media_codec_information_len(const uint8_t * event){
|
||||
return little_endian_read_16(event, 8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* API_END */
|
||||
|
@ -239,7 +239,7 @@ def create_events(events):
|
||||
for event_type, event_name, format, args in events:
|
||||
parts = event_name.split("_")
|
||||
event_group = parts[0]
|
||||
if not event_group in [ 'BTSTACK', 'GAP', 'HCI', 'HSP', 'HFP', 'SDP', 'ANCS', 'SM', 'L2CAP', 'RFCOMM', 'GATT', 'BNEP', 'ATT']:
|
||||
if not event_group in [ 'BTSTACK', 'GAP', 'HCI', 'HSP', 'HFP', 'SDP', 'ANCS', 'SM', 'L2CAP', 'RFCOMM', 'GATT', 'BNEP', 'ATT', 'AVDTP']:
|
||||
print("// %s " % event_name)
|
||||
continue
|
||||
print(event_name)
|
||||
|
146
tool/btstack_parser.py
Executable file
146
tool/btstack_parser.py
Executable file
@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env python
|
||||
# BlueKitchen GmbH (c) 2014
|
||||
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
|
||||
# paths
|
||||
bluetooth_h_path = 'src/bluetooth.h'
|
||||
btstack_defines_h_path = 'src/btstack_defines.h'
|
||||
daemon_cmds_c_path = 'platform/daemon/src/daemon_cmds.c'
|
||||
hci_cmds_c_path = 'src/hci_cmd.c'
|
||||
hci_cmds_h_path = 'src/hci_cmd.h'
|
||||
hci_h_path = 'src/hci.h'
|
||||
|
||||
btstack_root = os.path.abspath(os.path.dirname(sys.argv[0]) + '/..')
|
||||
print ("BTstack root %s" % btstack_root)
|
||||
|
||||
def set_btstack_root(path):
|
||||
global btstack_root
|
||||
btstack_root = path
|
||||
|
||||
def assert_dir(path):
|
||||
if not os.access(path, os.R_OK):
|
||||
os.makedirs(path)
|
||||
|
||||
def cap(x):
|
||||
if x.lower() == 'btstack':
|
||||
return 'BTstack'
|
||||
acronyms = ['ATT', 'GAP', 'GATT', 'HCI', 'L2CAP', 'LE', 'RFCOMM', 'SM', 'SDP', 'UUID16', 'UUID128', 'HSP', 'HFP', 'ANCS']
|
||||
if x.upper() in acronyms:
|
||||
return x.upper()
|
||||
return x.capitalize()
|
||||
|
||||
def camel_case(name):
|
||||
return ''.join(map(cap, name.split('_')))
|
||||
|
||||
def camel_case_var(name):
|
||||
if name in ['uuid128', 'uuid16']:
|
||||
return name
|
||||
camel = camel_case(name)
|
||||
return camel[0].lower() + camel[1:]
|
||||
|
||||
def read_defines(infile):
|
||||
defines = dict()
|
||||
with open (infile, 'rt') as fin:
|
||||
for line in fin:
|
||||
parts = re.match('#define\s+(\w+)\s+(\w*)',line)
|
||||
if parts and len(parts.groups()) == 2:
|
||||
(key, value) = parts.groups()
|
||||
defines[key] = value
|
||||
return defines
|
||||
|
||||
def parse_defines():
|
||||
global btstack_root
|
||||
defines = dict()
|
||||
defines.update(read_defines(btstack_root + '/' + hci_cmds_h_path))
|
||||
defines.update(read_defines(btstack_root + '/' + hci_h_path))
|
||||
defines.update(read_defines(btstack_root + '/' + bluetooth_h_path))
|
||||
defines.update(read_defines(btstack_root + '/' + btstack_defines_h_path))
|
||||
return defines
|
||||
|
||||
def my_parse_events(path):
|
||||
events = []
|
||||
subevents = []
|
||||
params = []
|
||||
event_types = set()
|
||||
format = None
|
||||
with open (path, 'rt') as fin:
|
||||
for line in fin:
|
||||
parts = re.match('.*@format\s*(\w*)\s*', line)
|
||||
if parts and len(parts.groups()) == 1:
|
||||
format = parts.groups()[0]
|
||||
parts = re.match('.*@param\s*(\w*)\s*', line)
|
||||
if parts and len(parts.groups()) == 1:
|
||||
param = parts.groups()[0]
|
||||
params.append(param)
|
||||
parts = re.match('\s*#define\s+(\w+)\s+(\w*)',line)
|
||||
if parts and len(parts.groups()) == 2:
|
||||
(key, value) = parts.groups()
|
||||
if format != None:
|
||||
# renaming needed by Java Binding (... subevents are just enumerated with others due to event factory)
|
||||
if "_subevent_" in key.lower():
|
||||
subevents.append((value, key, format, params))
|
||||
else:
|
||||
events.append((value, key, format, params))
|
||||
event_types.add(key)
|
||||
params = []
|
||||
format = None
|
||||
return (events, subevents, event_types)
|
||||
|
||||
def parse_events():
|
||||
global btstack_root
|
||||
|
||||
# parse bluetooth.h to get used events
|
||||
(bluetooth_events, bluetooth_subevents, bluetooth_event_types) = my_parse_events(btstack_root + '/' + bluetooth_h_path)
|
||||
|
||||
# parse btstack_defines to get events
|
||||
(btstack_events, btstack_subevents, btstack_event_types) = my_parse_events(btstack_root + '/' + btstack_defines_h_path)
|
||||
|
||||
# concat lists
|
||||
(events, subvents, event_types) = (bluetooth_events + btstack_events, bluetooth_subevents + btstack_subevents, bluetooth_event_types | btstack_event_types)
|
||||
|
||||
return (events, subvents, event_types)
|
||||
|
||||
def my_parse_commands(infile):
|
||||
commands = []
|
||||
with open (infile, 'rt') as fin:
|
||||
|
||||
params = []
|
||||
for line in fin:
|
||||
|
||||
parts = re.match('.*@param\s*(\w*)\s*', line)
|
||||
if parts and len(parts.groups()) == 1:
|
||||
param = parts.groups()[0]
|
||||
params.append(camel_case_var(param))
|
||||
continue
|
||||
|
||||
declaration = re.match('const\s+hci_cmd_t\s+(\w+)[\s=]+', line)
|
||||
if declaration:
|
||||
command_name = camel_case(declaration.groups()[0])
|
||||
if command_name.endswith('Cmd'):
|
||||
command_name = command_name[:-len('Cmd')]
|
||||
continue
|
||||
|
||||
definition = re.match('\s*OPCODE\\(\s*(\w+)\s*,\s+(\w+)\s*\\)\s*,\s\\"(\w*)\\".*', line)
|
||||
if definition:
|
||||
(ogf, ocf, format) = definition.groups()
|
||||
if len(params) != len(format):
|
||||
params = []
|
||||
arg_counter = 1
|
||||
for f in format:
|
||||
arg_name = 'arg%u' % arg_counter
|
||||
params.append(arg_name)
|
||||
arg_counter += 1
|
||||
commands.append((command_name, ogf, ocf, format, params))
|
||||
params = []
|
||||
continue
|
||||
return commands
|
||||
|
||||
def parse_commands():
|
||||
global btstack_root
|
||||
commands = []
|
||||
commands = commands = my_parse_commands(btstack_root + '/' + hci_cmds_c_path)
|
||||
commands = commands = my_parse_commands(btstack_root + '/' + daemon_cmds_c_path)
|
||||
return commands
|
Loading…
x
Reference in New Issue
Block a user