Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
mringwal committed Oct 9, 2017
2 parents a559921 + 9c7c30e commit 594831bf2d61711bd7799b36822c8b4d071d089a
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -65,6 +65,7 @@
// #undef HAVE_BTSTACK_STDIN
static uint8_t hid_service_buffer[250];
static uint8_t device_id_sdp_service_buffer[100];
static const char hid_device_name[] = "BTstack HID Keyboard";
static btstack_packet_callback_registration_t hci_event_callback_registration;
static uint16_t hid_cid;
@@ -352,8 +353,15 @@ int btstack_main(int argc, const char * argv[]){
memset(hid_service_buffer, 0, sizeof(hid_service_buffer));
// hid sevice subclass 2540 Keyboard, hid counntry code 33 US, hid virtual cable off, hid reconnect initiate off, hid boot device off
hid_create_sdp_record(hid_service_buffer, 0x10001, 0x2540, 33, 0, 0, 0, hid_descriptor_keyboard_boot_mode, sizeof(hid_descriptor_keyboard_boot_mode), hid_device_name);
printf("SDP service record size: %u\n", de_get_len( hid_service_buffer));
printf("HID service record size: %u\n", de_get_len( hid_service_buffer));
sdp_register_service(hid_service_buffer);
// See https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers if you don't have a USB Vendor ID and need a Bluetooth Vendor ID
// device info: BlueKitchen GmbH, product 1, version 1
device_id_create_sdp_record(device_id_sdp_service_buffer, 0x10003, DEVICE_ID_VENDOR_ID_SOURCE_BLUETOOTH, BLUETOOTH_COMPANY_ID_BLUEKITCHEN_GMBH, 1, 1);
printf("Device ID SDP service record size: %u\n", de_get_len((uint8_t*)device_id_sdp_service_buffer));
sdp_register_service(device_id_sdp_service_buffer);
// HID Device
hid_device_init();
View
@@ -12,9 +12,11 @@ Status: Basic port incl. all examples. BTstack runs on dedicated FreeRTOS thread
In port/esp32, run
./integrate_btstack.sh
./integrate_btstack.py
The script will copy parts of the BTstack tree into the ESP-IDF as $IDF_PATH/components/btstack and then create project folders for all examples. Each example project folder, e.g. port/esp32/examples/spp_and_le_counter, contains a Makefile. Please run the command again after updating the BTstack tree to also update the copy in the ESP-IDF.
The script will copy parts of the BTstack tree into the ESP-IDF as $IDF_PATH/components/btstack and then create project folders for all examples.
Each example project folder, e.g. port/esp32/examples/spp_and_le_counter, contains a Makefile. Please run the command again after updating the BTstack tree (e.g. by git pull) to also update the copy in the ESP-IDF.
To compile an example, run:
@@ -34,7 +36,7 @@ You can quit the monitor with CTRL-].
## Old Make Versions
Compilation fails with older versions of the make tool, e.g. make 3.8.1 (from 2006) providedby the current Xcode 9 on macOS.
Compilation fails with older versions of the make tool, e.g. make 3.8.1 (from 2006) provided by the current Xcode 9 on macOS.
Interestingly, if you run make a second time, it completes the compilation.
## Configuration
@@ -31,71 +31,76 @@
COMPONENT_EXTRA_CLEAN = EXAMPLE.h
'''
# get script path
script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
# path to examples
examples_embedded = script_path + "/../../example/"
# path to samples
example_folder = script_path + "/example/"
print("Creating examples folder")
if not os.path.exists(example_folder):
os.makedirs(example_folder)
print("Creating examples in examples folder")
# iterate over btstack examples
for file in os.listdir(examples_embedded):
if not file.endswith(".c"):
continue
if file in ['panu_demo.c', 'sco_demo_util.c']:
continue
example = file[:-2]
gatt_path = examples_embedded + example + ".gatt"
# create folder
apps_folder = example_folder + example + "/"
if os.path.exists(apps_folder):
shutil.rmtree(apps_folder)
os.makedirs(apps_folder)
# copy files
for item in ['sdkconfig', 'set_port.sh']:
shutil.copyfile(script_path + '/template/' + item, apps_folder + '/' + item)
# mark set_port.sh as executable
os.chmod(apps_folder + '/set_port.sh', 0o755)
# create Makefile file
with open(apps_folder + "Makefile", "wt") as fout:
fout.write(mk_template.replace("EXAMPLE", example).replace("TOOL", script_path).replace("DATE",time.strftime("%c")))
# create main folder
main_folder = apps_folder + "main/"
if not os.path.exists(main_folder):
os.makedirs(main_folder)
# copy example file
shutil.copyfile(examples_embedded + file, apps_folder + "/main/" + example + ".c")
# add sco_demo_util.c for audio examples
if example in ['hfp_ag_demo','hfp_hf_demo', 'hsp_ag_demo', 'hsp_hf_demo']:
shutil.copy(examples_embedded + 'sco_demo_util.c', apps_folder + '/main/')
shutil.copy(examples_embedded + 'sco_demo_util.h', apps_folder + '/main/')
# add component.mk file to main folder
main_component_mk = apps_folder + "/main/component.mk"
shutil.copyfile(script_path + '/template/main/component.mk', main_component_mk)
# add rules to compile gatt db if .gatt file is present
gatt_path = examples_embedded + example + ".gatt"
if os.path.exists(gatt_path):
shutil.copy(gatt_path, apps_folder + "/main/" + example + ".gatt")
with open(main_component_mk, "a") as fout:
fout.write(component_mk_gatt_add_on.replace("EXAMPLE", example))
print("- %s including GATT DB compilation rules" % example)
else:
print("- %s" % example)
def create_examples(script_path):
# path to examples
examples_embedded = script_path + "/../../example/"
# path to samples
example_folder = script_path + "/example/"
print("Creating examples folder")
if not os.path.exists(example_folder):
os.makedirs(example_folder)
print("Creating examples in examples folder")
# iterate over btstack examples
for file in os.listdir(examples_embedded):
if not file.endswith(".c"):
continue
if file in ['panu_demo.c', 'sco_demo_util.c']:
continue
example = file[:-2]
gatt_path = examples_embedded + example + ".gatt"
# create folder
apps_folder = example_folder + example + "/"
if os.path.exists(apps_folder):
shutil.rmtree(apps_folder)
os.makedirs(apps_folder)
# copy files
for item in ['sdkconfig', 'set_port.sh']:
shutil.copyfile(script_path + '/template/' + item, apps_folder + '/' + item)
# mark set_port.sh as executable
os.chmod(apps_folder + '/set_port.sh', 0o755)
# create Makefile file
with open(apps_folder + "Makefile", "wt") as fout:
fout.write(mk_template.replace("EXAMPLE", example).replace("TOOL", script_path).replace("DATE",time.strftime("%c")))
# create main folder
main_folder = apps_folder + "main/"
if not os.path.exists(main_folder):
os.makedirs(main_folder)
# copy example file
shutil.copyfile(examples_embedded + file, apps_folder + "/main/" + example + ".c")
# add sco_demo_util.c for audio examples
if example in ['hfp_ag_demo','hfp_hf_demo', 'hsp_ag_demo', 'hsp_hf_demo']:
shutil.copy(examples_embedded + 'sco_demo_util.c', apps_folder + '/main/')
shutil.copy(examples_embedded + 'sco_demo_util.h', apps_folder + '/main/')
# add component.mk file to main folder
main_component_mk = apps_folder + "/main/component.mk"
shutil.copyfile(script_path + '/template/main/component.mk', main_component_mk)
# add rules to compile gatt db if .gatt file is present
gatt_path = examples_embedded + example + ".gatt"
if os.path.exists(gatt_path):
shutil.copy(gatt_path, apps_folder + "/main/" + example + ".gatt")
with open(main_component_mk, "a") as fout:
fout.write(component_mk_gatt_add_on.replace("EXAMPLE", example))
print("- %s including GATT DB compilation rules" % example)
else:
print("- %s" % example)
if __name__ == '__main__':
# get script path
script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
create_examples(script_path)
@@ -0,0 +1,52 @@
#!/usr/bin/env python
#
# Add btstack component to esp-idf
#
import os
import sys
import shutil
import create_examples
if not 'IDF_PATH' in os.environ:
print('Error: IDF_PATH not defined. Please set IDF_PATH as described here:\nhttp://esp-idf.readthedocs.io/en/latest/get-started/index.html#get-started-get-esp-idf');
sys.exit(10)
IDF_PATH=os.environ['IDF_PATH']
print("IDF_PATH=%s" % IDF_PATH)
IDF_COMPONENTS=IDF_PATH + "/components"
if not os.path.exists(IDF_COMPONENTS):
print("Error: No components folder at $IDF_PATH/components, please check IDF_PATH")
sys.exit(10)
IDF_BTSTACK=IDF_COMPONENTS+"/btstack"
if os.path.exists(IDF_BTSTACK):
print("Deleting old BTstack component %s" % IDF_BTSTACK)
shutil.rmtree(IDF_BTSTACK)
# get local dir
local_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
# create components/btstack
print("Creating BTstack component at %s" % IDF_COMPONENTS)
shutil.copytree(local_dir+'/components/btstack', IDF_BTSTACK)
dirs_to_copy = [
'src',
'3rd-party/bluedroid',
'3rd-party/hxcmod-player',
'platform/freertos',
'platform/embedded',
'tool'
]
for dir in dirs_to_copy:
print('- %s' % dir)
shutil.copytree(local_dir + '/../../' + dir, IDF_BTSTACK + '/' + dir)
# create example/btstack
create_examples.create_examples(local_dir)

This file was deleted.

Oops, something went wrong.
View
@@ -1697,21 +1697,6 @@ typedef uint8_t sm_key_t[16];
*/
#define AVRCP_SUBEVENT_PLAYER_APPLICATION_VALUE_RESPONSE 0x0F
/**
* @format 12
* @param subevent_code
* @param avrcp_cid
*/
#define AVRCP_SUBEVENT_UNIT_INFO_QUERY 0x10
/**
* @format 121
* @param subevent_code
* @param avrcp_cid
* @param offset page*4
*/
#define AVRCP_SUBEVENT_SUBUNIT_INFO_QUERY 0x11
/**
* @format 12
* @param subevent_code
@@ -1733,13 +1718,6 @@ typedef uint8_t sm_key_t[16];
*/
#define AVRCP_SUBEVENT_PLAY_STATUS_QUERY 0x14
/**
* @format 12
* @param subevent_code
* @param avrcp_cid
*/
#define AVRCP_SUBEVENT_NOW_PLAYING_INFO_QUERY 0x15
/**
* @format 12111
* @param subevent_code
@@ -1748,7 +1726,7 @@ typedef uint8_t sm_key_t[16];
* @param operands_length
* @param operand
*/
#define AVRCP_SUBEVENT_OPERATION 0x16
#define AVRCP_SUBEVENT_OPERATION 0x15
/**
* @format 121BH1
View
@@ -5494,35 +5494,6 @@ static inline uint8_t avrcp_subevent_player_application_value_response_get_comma
return event[5];
}
/**
* @brief Get field avrcp_cid from event AVRCP_SUBEVENT_UNIT_INFO_QUERY
* @param event packet
* @return avrcp_cid
* @note: btstack_type 2
*/
static inline uint16_t avrcp_subevent_unit_info_query_get_avrcp_cid(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field avrcp_cid from event AVRCP_SUBEVENT_SUBUNIT_INFO_QUERY
* @param event packet
* @return avrcp_cid
* @note: btstack_type 2
*/
static inline uint16_t avrcp_subevent_subunit_info_query_get_avrcp_cid(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field offset from event AVRCP_SUBEVENT_SUBUNIT_INFO_QUERY
* @param event packet
* @return offset
* @note: btstack_type 1
*/
static inline uint8_t avrcp_subevent_subunit_info_query_get_offset(const uint8_t * event){
return event[5];
}
/**
* @brief Get field avrcp_cid from event AVRCP_SUBEVENT_COMPANY_IDS_QUERY
* @param event packet
@@ -5553,16 +5524,6 @@ static inline uint16_t avrcp_subevent_play_status_query_get_avrcp_cid(const uint
return little_endian_read_16(event, 3);
}
/**
* @brief Get field avrcp_cid from event AVRCP_SUBEVENT_NOW_PLAYING_INFO_QUERY
* @param event packet
* @return avrcp_cid
* @note: btstack_type 2
*/
static inline uint16_t avrcp_subevent_now_playing_info_query_get_avrcp_cid(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field avrcp_cid from event AVRCP_SUBEVENT_OPERATION
* @param event packet
Oops, something went wrong.

0 comments on commit 594831b

Please sign in to comment.