mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-20 18:40:31 +00:00
extend btstack defines, and memory generator
This commit is contained in:
parent
1691a5f70a
commit
a23045e2bf
@ -834,6 +834,7 @@ typedef uint8_t sm_key_t[16];
|
||||
#define HCI_EVENT_HSP_META 0xE8
|
||||
#define HCI_EVENT_HFP_META 0xE9
|
||||
#define HCI_EVENT_ANCS_META 0xEA
|
||||
#define HCI_EVENT_AVDTP_META 0xEA
|
||||
|
||||
// Potential other meta groups
|
||||
// #define HCI_EVENT_BNEP_META 0xxx
|
||||
@ -916,7 +917,7 @@ typedef uint8_t sm_key_t[16];
|
||||
/** HFP Subevent */
|
||||
|
||||
/**
|
||||
* @format 11HB1
|
||||
* @format 11HB
|
||||
* @param subevent_code
|
||||
* @param status 0 == OK
|
||||
* @param con_handle
|
||||
@ -931,7 +932,7 @@ typedef uint8_t sm_key_t[16];
|
||||
#define HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED 0x02
|
||||
|
||||
/**
|
||||
* @format 11HB11
|
||||
* @format 11HB1
|
||||
* @param subevent_code
|
||||
* @param status 0 == OK
|
||||
* @param handle
|
||||
@ -1126,4 +1127,22 @@ typedef uint8_t sm_key_t[16];
|
||||
*/
|
||||
#define ANCS_SUBEVENT_CLIENT_DISCONNECTED 0xF2
|
||||
|
||||
|
||||
/** AVDTP Subevent */
|
||||
|
||||
// /**
|
||||
// * @format 11HB
|
||||
// * @param subevent_code
|
||||
// * @param status 0 == OK
|
||||
// * @param con_handle
|
||||
// * @param bd_addr
|
||||
// */
|
||||
// #define AVDTP_SUBEVENT_CONNECTION_ESTABLISHED 0x01
|
||||
|
||||
// /**
|
||||
// * @format 1
|
||||
// * @param subevent_code
|
||||
// */
|
||||
// #define AVDTP_SUBEVENT_CONNECTION_RELEASED 0x02
|
||||
|
||||
#endif
|
||||
|
@ -207,7 +207,7 @@ uint16_t l2cap_max_le_mtu(void);
|
||||
* @param psm
|
||||
* @param mtu
|
||||
* @param local_cid
|
||||
* @param status
|
||||
* @return status
|
||||
*/
|
||||
uint8_t l2cap_create_channel(btstack_packet_handler_t packet_handler, bd_addr_t address, uint16_t psm, uint16_t mtu, uint16_t * out_local_cid);
|
||||
|
||||
|
1
test/avdtp/.gitignore
vendored
Normal file
1
test/avdtp/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
avdtp_test
|
@ -61,7 +61,7 @@ EXAMPLES = hfp_ag_parser_test hfp_ag_client_test hfp_hf_parser_test hfp_hf_clien
|
||||
all: ${EXAMPLES}
|
||||
|
||||
clean:
|
||||
rm -rf *.o $(EXAMPLES) $(CLIENT_EXAMPLES) *.dSYM *.wav
|
||||
rm -rf *.o $(EXAMPLES) $(CLIENT_EXAMPLES) *.dSYM *.wav data/*.wav
|
||||
|
||||
hfp_ag_parser_test: ${COMMON_OBJ} hfp_gsm_model.o hfp_ag.o hfp.o hfp_ag_parser_test.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
@ -67,6 +67,8 @@ extern "C" {
|
||||
#include "classic/btstack_link_key_db_memory.h"
|
||||
#include "classic/rfcomm.h"
|
||||
#include "classic/sdp_server.h"
|
||||
#include "../test/avdtp/avdtp_sink.h"
|
||||
#include "../test/avdtp/avdtp_source.h"
|
||||
|
||||
// BLE
|
||||
#ifdef ENABLE_BLE
|
||||
|
@ -1,146 +0,0 @@
|
||||
#!/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
|
58
tool/template.h
Normal file
58
tool/template.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2016 BlueKitchen GmbH
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the names of
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* 4. Any redistribution, use, or modification is done solely for
|
||||
* personal benefit and not for any commercial purpose or for
|
||||
* monetary gain.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
|
||||
* RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Please inquire about commercial licensing options at
|
||||
* contact@bluekitchen-gmbh.com
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* file.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __FILE_H
|
||||
#define __FILE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ...
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __FILE_H
|
Loading…
x
Reference in New Issue
Block a user