component/bt: Merge branch 'feature/btdm_bluedroid' into feature/bt_gap

This commit is contained in:
wangmengyang 2016-10-21 15:19:39 +08:00
commit 063e9e8287
13 changed files with 1695 additions and 1695 deletions

View file

@ -1,461 +1,461 @@
/****************************************************************************** /******************************************************************************
* *
* Copyright (C) 2014 Google, Inc. * Copyright (C) 2014 Google, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at: * You may obtain a copy of the License at:
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
******************************************************************************/ ******************************************************************************/
#include <stdbool.h> #include <stdbool.h>
#include "bt_trace.h" #include "bt_trace.h"
#include "bdaddr.h" #include "bdaddr.h"
#include "bt_types.h" #include "bt_types.h"
#include "controller.h" #include "controller.h"
#include "event_mask.h" #include "event_mask.h"
#include "hcimsgs.h" #include "hcimsgs.h"
#include "hci_layer.h" #include "hci_layer.h"
#include "hci_packet_factory.h" #include "hci_packet_factory.h"
#include "hci_packet_parser.h" #include "hci_packet_parser.h"
#include "btm_ble_api.h" #include "btm_ble_api.h"
#include "version.h" #include "version.h"
#include "future.h" #include "future.h"
const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x06\x7f" }; const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x06\x7f" };
#if (BLE_INCLUDED) #if (BLE_INCLUDED)
const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_DUMO_EVENT_MASK_EXT }; const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_DUMO_EVENT_MASK_EXT };
#else #else
const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_LISBON_EVENT_MASK_EXT }; const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_LISBON_EVENT_MASK_EXT };
#endif #endif
// TODO(zachoverflow): factor out into common module // TODO(zachoverflow): factor out into common module
const uint8_t SCO_HOST_BUFFER_SIZE = 0xff; const uint8_t SCO_HOST_BUFFER_SIZE = 0xff;
#define HCI_SUPPORTED_COMMANDS_ARRAY_SIZE 64 #define HCI_SUPPORTED_COMMANDS_ARRAY_SIZE 64
#define MAX_FEATURES_CLASSIC_PAGE_COUNT 3 #define MAX_FEATURES_CLASSIC_PAGE_COUNT 3
#define BLE_SUPPORTED_STATES_SIZE 8 #define BLE_SUPPORTED_STATES_SIZE 8
#define BLE_SUPPORTED_FEATURES_SIZE 8 #define BLE_SUPPORTED_FEATURES_SIZE 8
static const hci_t *hci; static const hci_t *hci;
static const hci_packet_factory_t *packet_factory; static const hci_packet_factory_t *packet_factory;
static const hci_packet_parser_t *packet_parser; static const hci_packet_parser_t *packet_parser;
static bt_bdaddr_t address; static bt_bdaddr_t address;
static bt_version_t bt_version; static bt_version_t bt_version;
static uint8_t supported_commands[HCI_SUPPORTED_COMMANDS_ARRAY_SIZE]; static uint8_t supported_commands[HCI_SUPPORTED_COMMANDS_ARRAY_SIZE];
static bt_device_features_t features_classic[MAX_FEATURES_CLASSIC_PAGE_COUNT]; static bt_device_features_t features_classic[MAX_FEATURES_CLASSIC_PAGE_COUNT];
static uint8_t last_features_classic_page_index; static uint8_t last_features_classic_page_index;
static uint16_t acl_data_size_classic; static uint16_t acl_data_size_classic;
static uint16_t acl_data_size_ble; static uint16_t acl_data_size_ble;
static uint16_t acl_buffer_count_classic; static uint16_t acl_buffer_count_classic;
static uint8_t acl_buffer_count_ble; static uint8_t acl_buffer_count_ble;
static uint8_t ble_white_list_size; static uint8_t ble_white_list_size;
static uint8_t ble_resolving_list_max_size; static uint8_t ble_resolving_list_max_size;
static uint8_t ble_supported_states[BLE_SUPPORTED_STATES_SIZE]; static uint8_t ble_supported_states[BLE_SUPPORTED_STATES_SIZE];
static bt_device_features_t features_ble; static bt_device_features_t features_ble;
static uint16_t ble_suggested_default_data_length; static uint16_t ble_suggested_default_data_length;
static bool readable; static bool readable;
static bool ble_supported; static bool ble_supported;
static bool simple_pairing_supported; static bool simple_pairing_supported;
static bool secure_connections_supported; static bool secure_connections_supported;
#define AWAIT_COMMAND(command) future_await(hci->transmit_command_futured(command)) #define AWAIT_COMMAND(command) future_await(hci->transmit_command_futured(command))
// Module lifecycle functions // Module lifecycle functions
static void start_up(void) { static void start_up(void) {
BT_HDR *response; BT_HDR *response;
// Send the initial reset command // Send the initial reset command
response = AWAIT_COMMAND(packet_factory->make_reset()); response = AWAIT_COMMAND(packet_factory->make_reset());
packet_parser->parse_generic_command_complete(response); packet_parser->parse_generic_command_complete(response);
// Request the classic buffer size next // Request the classic buffer size next
response = AWAIT_COMMAND(packet_factory->make_read_buffer_size()); response = AWAIT_COMMAND(packet_factory->make_read_buffer_size());
packet_parser->parse_read_buffer_size_response( packet_parser->parse_read_buffer_size_response(
response, &acl_data_size_classic, &acl_buffer_count_classic); response, &acl_data_size_classic, &acl_buffer_count_classic);
// Tell the controller about our buffer sizes and buffer counts next // Tell the controller about our buffer sizes and buffer counts next
// TODO(zachoverflow): factor this out. eww l2cap contamination. And why just a hardcoded 10? // TODO(zachoverflow): factor this out. eww l2cap contamination. And why just a hardcoded 10?
response = AWAIT_COMMAND( response = AWAIT_COMMAND(
packet_factory->make_host_buffer_size( packet_factory->make_host_buffer_size(
L2CAP_MTU_SIZE, L2CAP_MTU_SIZE,
SCO_HOST_BUFFER_SIZE, SCO_HOST_BUFFER_SIZE,
L2CAP_HOST_FC_ACL_BUFS, L2CAP_HOST_FC_ACL_BUFS,
10 10
) )
); );
packet_parser->parse_generic_command_complete(response); packet_parser->parse_generic_command_complete(response);
// Read the local version info off the controller next, including // Read the local version info off the controller next, including
// information such as manufacturer and supported HCI version // information such as manufacturer and supported HCI version
response = AWAIT_COMMAND(packet_factory->make_read_local_version_info()); response = AWAIT_COMMAND(packet_factory->make_read_local_version_info());
packet_parser->parse_read_local_version_info_response(response, &bt_version); packet_parser->parse_read_local_version_info_response(response, &bt_version);
// Read the bluetooth address off the controller next // Read the bluetooth address off the controller next
response = AWAIT_COMMAND(packet_factory->make_read_bd_addr()); response = AWAIT_COMMAND(packet_factory->make_read_bd_addr());
packet_parser->parse_read_bd_addr_response(response, &address); packet_parser->parse_read_bd_addr_response(response, &address);
// Request the controller's supported commands next // Request the controller's supported commands next
response = AWAIT_COMMAND(packet_factory->make_read_local_supported_commands()); response = AWAIT_COMMAND(packet_factory->make_read_local_supported_commands());
packet_parser->parse_read_local_supported_commands_response( packet_parser->parse_read_local_supported_commands_response(
response, response,
supported_commands, supported_commands,
HCI_SUPPORTED_COMMANDS_ARRAY_SIZE HCI_SUPPORTED_COMMANDS_ARRAY_SIZE
); );
// Read page 0 of the controller features next // Read page 0 of the controller features next
uint8_t page_number = 0; uint8_t page_number = 0;
response = AWAIT_COMMAND(packet_factory->make_read_local_extended_features(page_number)); response = AWAIT_COMMAND(packet_factory->make_read_local_extended_features(page_number));
packet_parser->parse_read_local_extended_features_response( packet_parser->parse_read_local_extended_features_response(
response, response,
&page_number, &page_number,
&last_features_classic_page_index, &last_features_classic_page_index,
features_classic, features_classic,
MAX_FEATURES_CLASSIC_PAGE_COUNT MAX_FEATURES_CLASSIC_PAGE_COUNT
); );
assert(page_number == 0); assert(page_number == 0);
page_number++; page_number++;
// Inform the controller what page 0 features we support, based on what // Inform the controller what page 0 features we support, based on what
// it told us it supports. We need to do this first before we request the // it told us it supports. We need to do this first before we request the
// next page, because the controller's response for page 1 may be // next page, because the controller's response for page 1 may be
// dependent on what we configure from page 0 // dependent on what we configure from page 0
simple_pairing_supported = HCI_SIMPLE_PAIRING_SUPPORTED(features_classic[0].as_array); simple_pairing_supported = HCI_SIMPLE_PAIRING_SUPPORTED(features_classic[0].as_array);
if (simple_pairing_supported) { if (simple_pairing_supported) {
response = AWAIT_COMMAND(packet_factory->make_write_simple_pairing_mode(HCI_SP_MODE_ENABLED)); response = AWAIT_COMMAND(packet_factory->make_write_simple_pairing_mode(HCI_SP_MODE_ENABLED));
packet_parser->parse_generic_command_complete(response); packet_parser->parse_generic_command_complete(response);
} }
#if (BLE_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE)
if (HCI_LE_SPT_SUPPORTED(features_classic[0].as_array)) { if (HCI_LE_SPT_SUPPORTED(features_classic[0].as_array)) {
uint8_t simultaneous_le_host = HCI_SIMUL_LE_BREDR_SUPPORTED(features_classic[0].as_array) ? BTM_BLE_SIMULTANEOUS_HOST : 0; uint8_t simultaneous_le_host = HCI_SIMUL_LE_BREDR_SUPPORTED(features_classic[0].as_array) ? BTM_BLE_SIMULTANEOUS_HOST : 0;
response = AWAIT_COMMAND( response = AWAIT_COMMAND(
packet_factory->make_ble_write_host_support(BTM_BLE_HOST_SUPPORT, simultaneous_le_host) packet_factory->make_ble_write_host_support(BTM_BLE_HOST_SUPPORT, simultaneous_le_host)
); );
packet_parser->parse_generic_command_complete(response); packet_parser->parse_generic_command_complete(response);
} }
#endif #endif
// Done telling the controller about what page 0 features we support // Done telling the controller about what page 0 features we support
// Request the remaining feature pages // Request the remaining feature pages
while (page_number <= last_features_classic_page_index && while (page_number <= last_features_classic_page_index &&
page_number < MAX_FEATURES_CLASSIC_PAGE_COUNT) { page_number < MAX_FEATURES_CLASSIC_PAGE_COUNT) {
response = AWAIT_COMMAND(packet_factory->make_read_local_extended_features(page_number)); response = AWAIT_COMMAND(packet_factory->make_read_local_extended_features(page_number));
packet_parser->parse_read_local_extended_features_response( packet_parser->parse_read_local_extended_features_response(
response, response,
&page_number, &page_number,
&last_features_classic_page_index, &last_features_classic_page_index,
features_classic, features_classic,
MAX_FEATURES_CLASSIC_PAGE_COUNT MAX_FEATURES_CLASSIC_PAGE_COUNT
); );
page_number++; page_number++;
} }
#if (SC_MODE_INCLUDED == TRUE) #if (SC_MODE_INCLUDED == TRUE)
secure_connections_supported = HCI_SC_CTRLR_SUPPORTED(features_classic[2].as_array); secure_connections_supported = HCI_SC_CTRLR_SUPPORTED(features_classic[2].as_array);
if (secure_connections_supported) { if (secure_connections_supported) {
response = AWAIT_COMMAND(packet_factory->make_write_secure_connections_host_support(HCI_SC_MODE_ENABLED)); response = AWAIT_COMMAND(packet_factory->make_write_secure_connections_host_support(HCI_SC_MODE_ENABLED));
packet_parser->parse_generic_command_complete(response); packet_parser->parse_generic_command_complete(response);
} }
#endif #endif
#if (BLE_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE)
ble_supported = last_features_classic_page_index >= 1 && HCI_LE_HOST_SUPPORTED(features_classic[1].as_array); ble_supported = last_features_classic_page_index >= 1 && HCI_LE_HOST_SUPPORTED(features_classic[1].as_array);
if (ble_supported) { if (ble_supported) {
// Request the ble white list size next // Request the ble white list size next
response = AWAIT_COMMAND(packet_factory->make_ble_read_white_list_size()); response = AWAIT_COMMAND(packet_factory->make_ble_read_white_list_size());
packet_parser->parse_ble_read_white_list_size_response(response, &ble_white_list_size); packet_parser->parse_ble_read_white_list_size_response(response, &ble_white_list_size);
// Request the ble buffer size next // Request the ble buffer size next
response = AWAIT_COMMAND(packet_factory->make_ble_read_buffer_size()); response = AWAIT_COMMAND(packet_factory->make_ble_read_buffer_size());
packet_parser->parse_ble_read_buffer_size_response( packet_parser->parse_ble_read_buffer_size_response(
response, response,
&acl_data_size_ble, &acl_data_size_ble,
&acl_buffer_count_ble &acl_buffer_count_ble
); );
// Response of 0 indicates ble has the same buffer size as classic // Response of 0 indicates ble has the same buffer size as classic
if (acl_data_size_ble == 0) if (acl_data_size_ble == 0)
acl_data_size_ble = acl_data_size_classic; acl_data_size_ble = acl_data_size_classic;
// Request the ble supported states next // Request the ble supported states next
response = AWAIT_COMMAND(packet_factory->make_ble_read_supported_states()); response = AWAIT_COMMAND(packet_factory->make_ble_read_supported_states());
packet_parser->parse_ble_read_supported_states_response( packet_parser->parse_ble_read_supported_states_response(
response, response,
ble_supported_states, ble_supported_states,
sizeof(ble_supported_states) sizeof(ble_supported_states)
); );
// Request the ble supported features next // Request the ble supported features next
response = AWAIT_COMMAND(packet_factory->make_ble_read_local_supported_features()); response = AWAIT_COMMAND(packet_factory->make_ble_read_local_supported_features());
packet_parser->parse_ble_read_local_supported_features_response( packet_parser->parse_ble_read_local_supported_features_response(
response, response,
&features_ble &features_ble
); );
if (HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array)) { if (HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array)) {
response = AWAIT_COMMAND(packet_factory->make_ble_read_resolving_list_size()); response = AWAIT_COMMAND(packet_factory->make_ble_read_resolving_list_size());
packet_parser->parse_ble_read_resolving_list_size_response( packet_parser->parse_ble_read_resolving_list_size_response(
response, response,
&ble_resolving_list_max_size); &ble_resolving_list_max_size);
} }
if (HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array)) { if (HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array)) {
response = AWAIT_COMMAND(packet_factory->make_ble_read_suggested_default_data_length()); response = AWAIT_COMMAND(packet_factory->make_ble_read_suggested_default_data_length());
packet_parser->parse_ble_read_suggested_default_data_length_response( packet_parser->parse_ble_read_suggested_default_data_length_response(
response, response,
&ble_suggested_default_data_length); &ble_suggested_default_data_length);
} }
// Set the ble event mask next // Set the ble event mask next
response = AWAIT_COMMAND(packet_factory->make_ble_set_event_mask(&BLE_EVENT_MASK)); response = AWAIT_COMMAND(packet_factory->make_ble_set_event_mask(&BLE_EVENT_MASK));
packet_parser->parse_generic_command_complete(response); packet_parser->parse_generic_command_complete(response);
} }
#endif #endif
if (simple_pairing_supported) { if (simple_pairing_supported) {
response = AWAIT_COMMAND(packet_factory->make_set_event_mask(&CLASSIC_EVENT_MASK)); response = AWAIT_COMMAND(packet_factory->make_set_event_mask(&CLASSIC_EVENT_MASK));
packet_parser->parse_generic_command_complete(response); packet_parser->parse_generic_command_complete(response);
} }
readable = true; readable = true;
// return future_new_immediate(FUTURE_SUCCESS); // return future_new_immediate(FUTURE_SUCCESS);
return; return;
} }
static void shut_down(void) { static void shut_down(void) {
readable = false; readable = false;
} }
static bool get_is_ready(void) { static bool get_is_ready(void) {
return readable; return readable;
} }
static const bt_bdaddr_t *get_address(void) { static const bt_bdaddr_t *get_address(void) {
assert(readable); assert(readable);
return &address; return &address;
} }
static const bt_version_t *get_bt_version(void) { static const bt_version_t *get_bt_version(void) {
assert(readable); assert(readable);
return &bt_version; return &bt_version;
} }
// TODO(zachoverflow): hide inside, move decoder inside too // TODO(zachoverflow): hide inside, move decoder inside too
static const bt_device_features_t *get_features_classic(int index) { static const bt_device_features_t *get_features_classic(int index) {
assert(readable); assert(readable);
assert(index < MAX_FEATURES_CLASSIC_PAGE_COUNT); assert(index < MAX_FEATURES_CLASSIC_PAGE_COUNT);
return &features_classic[index]; return &features_classic[index];
} }
static uint8_t get_last_features_classic_index(void) { static uint8_t get_last_features_classic_index(void) {
assert(readable); assert(readable);
return last_features_classic_page_index; return last_features_classic_page_index;
} }
static const bt_device_features_t *get_features_ble(void) { static const bt_device_features_t *get_features_ble(void) {
assert(readable); assert(readable);
assert(ble_supported); assert(ble_supported);
return &features_ble; return &features_ble;
} }
static const uint8_t *get_ble_supported_states(void) { static const uint8_t *get_ble_supported_states(void) {
assert(readable); assert(readable);
assert(ble_supported); assert(ble_supported);
return ble_supported_states; return ble_supported_states;
} }
static bool supports_simple_pairing(void) { static bool supports_simple_pairing(void) {
assert(readable); assert(readable);
return simple_pairing_supported; return simple_pairing_supported;
} }
static bool supports_secure_connections(void) { static bool supports_secure_connections(void) {
assert(readable); assert(readable);
return secure_connections_supported; return secure_connections_supported;
} }
static bool supports_simultaneous_le_bredr(void) { static bool supports_simultaneous_le_bredr(void) {
assert(readable); assert(readable);
return HCI_SIMUL_LE_BREDR_SUPPORTED(features_classic[0].as_array); return HCI_SIMUL_LE_BREDR_SUPPORTED(features_classic[0].as_array);
} }
static bool supports_reading_remote_extended_features(void) { static bool supports_reading_remote_extended_features(void) {
assert(readable); assert(readable);
return HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(supported_commands); return HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(supported_commands);
} }
static bool supports_interlaced_inquiry_scan(void) { static bool supports_interlaced_inquiry_scan(void) {
assert(readable); assert(readable);
return HCI_LMP_INTERLACED_INQ_SCAN_SUPPORTED(features_classic[0].as_array); return HCI_LMP_INTERLACED_INQ_SCAN_SUPPORTED(features_classic[0].as_array);
} }
static bool supports_rssi_with_inquiry_results(void) { static bool supports_rssi_with_inquiry_results(void) {
assert(readable); assert(readable);
return HCI_LMP_INQ_RSSI_SUPPORTED(features_classic[0].as_array); return HCI_LMP_INQ_RSSI_SUPPORTED(features_classic[0].as_array);
} }
static bool supports_extended_inquiry_response(void) { static bool supports_extended_inquiry_response(void) {
assert(readable); assert(readable);
return HCI_EXT_INQ_RSP_SUPPORTED(features_classic[0].as_array); return HCI_EXT_INQ_RSP_SUPPORTED(features_classic[0].as_array);
} }
static bool supports_master_slave_role_switch(void) { static bool supports_master_slave_role_switch(void) {
assert(readable); assert(readable);
return HCI_SWITCH_SUPPORTED(features_classic[0].as_array); return HCI_SWITCH_SUPPORTED(features_classic[0].as_array);
} }
static bool supports_ble(void) { static bool supports_ble(void) {
assert(readable); assert(readable);
return ble_supported; return ble_supported;
} }
static bool supports_ble_privacy(void) { static bool supports_ble_privacy(void) {
assert(readable); assert(readable);
assert(ble_supported); assert(ble_supported);
return HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array); return HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array);
} }
static bool supports_ble_packet_extension(void) { static bool supports_ble_packet_extension(void) {
assert(readable); assert(readable);
assert(ble_supported); assert(ble_supported);
return HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array); return HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array);
} }
static bool supports_ble_connection_parameters_request(void) { static bool supports_ble_connection_parameters_request(void) {
assert(readable); assert(readable);
assert(ble_supported); assert(ble_supported);
return HCI_LE_CONN_PARAM_REQ_SUPPORTED(features_ble.as_array); return HCI_LE_CONN_PARAM_REQ_SUPPORTED(features_ble.as_array);
} }
static uint16_t get_acl_data_size_classic(void) { static uint16_t get_acl_data_size_classic(void) {
assert(readable); assert(readable);
return acl_data_size_classic; return acl_data_size_classic;
} }
static uint16_t get_acl_data_size_ble(void) { static uint16_t get_acl_data_size_ble(void) {
assert(readable); assert(readable);
assert(ble_supported); assert(ble_supported);
return acl_data_size_ble; return acl_data_size_ble;
} }
static uint16_t get_acl_packet_size_classic(void) { static uint16_t get_acl_packet_size_classic(void) {
assert(readable); assert(readable);
return acl_data_size_classic + HCI_DATA_PREAMBLE_SIZE; return acl_data_size_classic + HCI_DATA_PREAMBLE_SIZE;
} }
static uint16_t get_acl_packet_size_ble(void) { static uint16_t get_acl_packet_size_ble(void) {
assert(readable); assert(readable);
return acl_data_size_ble + HCI_DATA_PREAMBLE_SIZE; return acl_data_size_ble + HCI_DATA_PREAMBLE_SIZE;
} }
static uint16_t get_ble_suggested_default_data_length(void) { static uint16_t get_ble_suggested_default_data_length(void) {
assert(readable); assert(readable);
assert(ble_supported); assert(ble_supported);
return ble_suggested_default_data_length; return ble_suggested_default_data_length;
} }
static uint16_t get_acl_buffer_count_classic(void) { static uint16_t get_acl_buffer_count_classic(void) {
assert(readable); assert(readable);
return acl_buffer_count_classic; return acl_buffer_count_classic;
} }
static uint8_t get_acl_buffer_count_ble(void) { static uint8_t get_acl_buffer_count_ble(void) {
assert(readable); assert(readable);
assert(ble_supported); assert(ble_supported);
return acl_buffer_count_ble; return acl_buffer_count_ble;
} }
static uint8_t get_ble_white_list_size(void) { static uint8_t get_ble_white_list_size(void) {
assert(readable); assert(readable);
assert(ble_supported); assert(ble_supported);
return ble_white_list_size; return ble_white_list_size;
} }
static uint8_t get_ble_resolving_list_max_size(void) { static uint8_t get_ble_resolving_list_max_size(void) {
assert(readable); assert(readable);
assert(ble_supported); assert(ble_supported);
return ble_resolving_list_max_size; return ble_resolving_list_max_size;
} }
static void set_ble_resolving_list_max_size(int resolving_list_max_size) { static void set_ble_resolving_list_max_size(int resolving_list_max_size) {
assert(readable); assert(readable);
assert(ble_supported); assert(ble_supported);
ble_resolving_list_max_size = resolving_list_max_size; ble_resolving_list_max_size = resolving_list_max_size;
} }
static const controller_t interface = { static const controller_t interface = {
start_up, start_up,
shut_down, shut_down,
get_is_ready, get_is_ready,
get_address, get_address,
get_bt_version, get_bt_version,
get_features_classic, get_features_classic,
get_last_features_classic_index, get_last_features_classic_index,
get_features_ble, get_features_ble,
get_ble_supported_states, get_ble_supported_states,
supports_simple_pairing, supports_simple_pairing,
supports_secure_connections, supports_secure_connections,
supports_simultaneous_le_bredr, supports_simultaneous_le_bredr,
supports_reading_remote_extended_features, supports_reading_remote_extended_features,
supports_interlaced_inquiry_scan, supports_interlaced_inquiry_scan,
supports_rssi_with_inquiry_results, supports_rssi_with_inquiry_results,
supports_extended_inquiry_response, supports_extended_inquiry_response,
supports_master_slave_role_switch, supports_master_slave_role_switch,
supports_ble, supports_ble,
supports_ble_packet_extension, supports_ble_packet_extension,
supports_ble_connection_parameters_request, supports_ble_connection_parameters_request,
supports_ble_privacy, supports_ble_privacy,
get_acl_data_size_classic, get_acl_data_size_classic,
get_acl_data_size_ble, get_acl_data_size_ble,
get_acl_packet_size_classic, get_acl_packet_size_classic,
get_acl_packet_size_ble, get_acl_packet_size_ble,
get_ble_suggested_default_data_length, get_ble_suggested_default_data_length,
get_acl_buffer_count_classic, get_acl_buffer_count_classic,
get_acl_buffer_count_ble, get_acl_buffer_count_ble,
get_ble_white_list_size, get_ble_white_list_size,
get_ble_resolving_list_max_size, get_ble_resolving_list_max_size,
set_ble_resolving_list_max_size set_ble_resolving_list_max_size
}; };
const controller_t *controller_get_interface() { const controller_t *controller_get_interface() {
static bool loaded = false; static bool loaded = false;
if (!loaded) { if (!loaded) {
loaded = true; loaded = true;
hci = hci_layer_get_interface(); hci = hci_layer_get_interface();
packet_factory = hci_packet_factory_get_interface(); packet_factory = hci_packet_factory_get_interface();
packet_parser = hci_packet_parser_get_interface(); packet_parser = hci_packet_parser_get_interface();
} }
return &interface; return &interface;
} }

View file

@ -1,100 +1,100 @@
/****************************************************************************** /******************************************************************************
* *
* Copyright (C) 2014 Google, Inc. * Copyright (C) 2014 Google, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at: * You may obtain a copy of the License at:
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
******************************************************************************/ ******************************************************************************/
// #define LOG_TAG "bt_osi_future" // #define LOG_TAG "bt_osi_future"
// #include <assert.h> // #include <assert.h>
#include "bt_trace.h" #include "bt_trace.h"
#include "allocator.h" #include "allocator.h"
#include "future.h" #include "future.h"
#include "osi.h" #include "osi.h"
//#include "osi/include/log.h" //#include "osi/include/log.h"
#include "osi_arch.h" #include "osi_arch.h"
struct future_t { struct future_t {
bool ready_can_be_called; bool ready_can_be_called;
osi_sem_t semaphore; // NULL semaphore means immediate future osi_sem_t semaphore; // NULL semaphore means immediate future
void *result; void *result;
}; };
static void future_free(future_t *future); static void future_free(future_t *future);
future_t *future_new(void) { future_t *future_new(void) {
future_t *ret = osi_calloc(sizeof(future_t)); future_t *ret = osi_calloc(sizeof(future_t));
if (!ret) { if (!ret) {
LOG_ERROR("%s unable to allocate memory for return value.", __func__); LOG_ERROR("%s unable to allocate memory for return value.", __func__);
goto error; goto error;
} }
if (osi_sem_new(&ret->semaphore, 1, 0)!=0) { if (osi_sem_new(&ret->semaphore, 1, 0)!=0) {
LOG_ERROR("%s unable to allocate memory for the semaphore.", __func__); LOG_ERROR("%s unable to allocate memory for the semaphore.", __func__);
goto error; goto error;
} }
ret->ready_can_be_called = true; ret->ready_can_be_called = true;
return ret; return ret;
error:; error:;
future_free(ret); future_free(ret);
return NULL; return NULL;
} }
future_t *future_new_immediate(void *value) { future_t *future_new_immediate(void *value) {
future_t *ret = osi_calloc(sizeof(future_t)); future_t *ret = osi_calloc(sizeof(future_t));
if (!ret) { if (!ret) {
LOG_ERROR("%s unable to allocate memory for return value.", __func__); LOG_ERROR("%s unable to allocate memory for return value.", __func__);
goto error; goto error;
} }
ret->result = value; ret->result = value;
ret->ready_can_be_called = false; ret->ready_can_be_called = false;
return ret; return ret;
error:; error:;
future_free(ret); future_free(ret);
return NULL; return NULL;
} }
void future_ready(future_t *future, void *value) { void future_ready(future_t *future, void *value) {
assert(future != NULL); assert(future != NULL);
assert(future->ready_can_be_called); assert(future->ready_can_be_called);
future->ready_can_be_called = false; future->ready_can_be_called = false;
future->result = value; future->result = value;
osi_sem_signal(&future->semaphore); osi_sem_signal(&future->semaphore);
} }
void *future_await(future_t *future) { void *future_await(future_t *future) {
assert(future != NULL); assert(future != NULL);
// If the future is immediate, it will not have a semaphore // If the future is immediate, it will not have a semaphore
if (future->semaphore) if (future->semaphore)
osi_sem_wait(&future->semaphore, 0); osi_sem_wait(&future->semaphore, 0);
void *result = future->result; void *result = future->result;
future_free(future); future_free(future);
return result; return result;
} }
static void future_free(future_t *future) { static void future_free(future_t *future) {
if (!future) if (!future)
return; return;
if (!future->semaphore) if (!future->semaphore)
osi_sem_free(&future->semaphore); osi_sem_free(&future->semaphore);
osi_free(future); osi_free(future);
} }

View file

@ -1,45 +1,45 @@
/****************************************************************************** /******************************************************************************
* *
* Copyright (C) 2014 Google, Inc. * Copyright (C) 2014 Google, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at: * You may obtain a copy of the License at:
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
******************************************************************************/ ******************************************************************************/
#ifndef __FUTURE_H__ #ifndef __FUTURE_H__
#define __FUTURE_H__ #define __FUTURE_H__
// #pragma once // #pragma once
typedef struct future_t future_t; typedef struct future_t future_t;
#define FUTURE_SUCCESS ((void *)1) #define FUTURE_SUCCESS ((void *)1)
#define FUTURE_FAIL ((void *)0) #define FUTURE_FAIL ((void *)0)
// Constructs a new future_t object. Returns NULL on failure. // Constructs a new future_t object. Returns NULL on failure.
future_t *future_new(void); future_t *future_new(void);
// Constructs a new future_t object with an immediate |value|. No waiting will // 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. // occur in the call to |future_await| because the value is already present.
// Returns NULL on failure. // Returns NULL on failure.
future_t *future_new_immediate(void *value); future_t *future_new_immediate(void *value);
// Signals that the |future| is ready, passing |value| back to the context // Signals that the |future| is ready, passing |value| back to the context
// waiting for the result. Must only be called once for every future. // waiting for the result. Must only be called once for every future.
// |future| may not be NULL. // |future| may not be NULL.
void future_ready(future_t *future, void *value); void future_ready(future_t *future, void *value);
// Waits for the |future| to be ready. Returns the value set in |future_ready|. // Waits for the |future| to be ready. Returns the value set in |future_ready|.
// Frees the future before return. |future| may not be NULL. // Frees the future before return. |future| may not be NULL.
void *future_await(future_t *async_result); void *future_await(future_t *async_result);
#endif /* __FUTURE_H__ */ #endif /* __FUTURE_H__ */

View file

@ -1,154 +1,154 @@
/** /**
**************************************************************************************** ****************************************************************************************
* *
* @file bt_prf_sys_main.c * @file bt_prf_sys_main.c
* *
* @brief Application entry point * @brief Application entry point
* *
* Copyright (C) Espressif 2016 * Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/13 * Created by Yulong at 2016/10/13
* *
* *
**************************************************************************************** ****************************************************************************************
*/ */
#include "thread.h" #include "thread.h"
#include "bt_prf_sys.h" #include "bt_prf_sys.h"
#include "fixed_queue.h" #include "fixed_queue.h"
#include "bt_prf_task.h" #include "bt_prf_task.h"
#include "gki.h" #include "gki.h"
#include <string.h> #include <string.h>
tBT_PRF_SYS_CB bt_prf_sys_cb; tBT_PRF_SYS_CB bt_prf_sys_cb;
fixed_queue_t *bt_profile_msg_queue; fixed_queue_t *bt_profile_msg_queue;
static const tBT_PRF_SYS_REG bt_prf_sys_reg = static const tBT_PRF_SYS_REG bt_prf_sys_reg =
{ {
NULL, NULL,
NULL NULL
}; };
void bt_prf_sys_init(void) void bt_prf_sys_init(void)
{ {
memset(&bt_prf_sys_cb,0,sizeof(tBT_PRF_SYS_CB)); memset(&bt_prf_sys_cb,0,sizeof(tBT_PRF_SYS_CB));
} }
/******************************************************************************* /*******************************************************************************
** **
** Function bt_prf_sys_event ** Function bt_prf_sys_event
** **
** Description profile task event handler; called from task event handler. ** Description profile task event handler; called from task event handler.
** **
** **
** Returns void ** Returns void
** **
*******************************************************************************/ *******************************************************************************/
void bt_prf_sys_event(BT_HDR *p_msg) void bt_prf_sys_event(BT_HDR *p_msg)
{ {
UINT8 id; UINT8 id;
BOOLEAN freebuf = TRUE; BOOLEAN freebuf = TRUE;
APPL_TRACE_EVENT("profile task got event 0x%x\n", p_msg->event); APPL_TRACE_EVENT("profile task got event 0x%x\n", p_msg->event);
/* get subsystem id from event */ /* get subsystem id from event */
id = (UINT8) (p_msg->event >> 8); id = (UINT8) (p_msg->event >> 8);
/* verify id and call subsystem event handler */ /* verify id and call subsystem event handler */
if ((id < PRF_ID_MAX) && (bt_prf_sys_cb.reg[id] != NULL)) if ((id < PRF_ID_MAX) && (bt_prf_sys_cb.reg[id] != NULL))
{ {
freebuf = (*bt_prf_sys_cb.reg[id]->evt_hdlr)(p_msg); freebuf = (*bt_prf_sys_cb.reg[id]->evt_hdlr)(p_msg);
} }
else else
{ {
APPL_TRACE_WARNING("profile task got unregistered event id %d\n", id); APPL_TRACE_WARNING("profile task got unregistered event id %d\n", id);
} }
if (freebuf) if (freebuf)
{ {
GKI_freebuf(p_msg); GKI_freebuf(p_msg);
} }
} }
/******************************************************************************* /*******************************************************************************
** **
** Function bt_prf_sys_register ** Function bt_prf_sys_register
** **
** Description Called by other profile subsystems to register their event ** Description Called by other profile subsystems to register their event
** handler. ** handler.
** **
** Parameters id:the Identifiers index of the profile ** Parameters id:the Identifiers index of the profile
** p_reg:the callback event which has been register to the profile task ** p_reg:the callback event which has been register to the profile task
** Returns void ** Returns void
** **
*******************************************************************************/ *******************************************************************************/
void bt_prf_sys_register(UINT8 id, const tBT_PRF_SYS_REG *p_reg) void bt_prf_sys_register(UINT8 id, const tBT_PRF_SYS_REG *p_reg)
{ {
bt_prf_sys_cb.reg[id] = (tBT_PRF_SYS_REG *) p_reg; bt_prf_sys_cb.reg[id] = (tBT_PRF_SYS_REG *) p_reg;
bt_prf_sys_cb.is_reg[id] = TRUE; bt_prf_sys_cb.is_reg[id] = TRUE;
} }
/******************************************************************************* /*******************************************************************************
** **
** Function bt_prf_sys_deregister ** Function bt_prf_sys_deregister
** **
** Description Called by other profile subsystems to de-register ** Description Called by other profile subsystems to de-register
** handler. ** handler.
** **
** Parameters id:Identifiers index of the profile ** Parameters id:Identifiers index of the profile
** Returns void ** Returns void
** **
*******************************************************************************/ *******************************************************************************/
void bt_prf_sys_deregister(UINT8 id) void bt_prf_sys_deregister(UINT8 id)
{ {
bt_prf_sys_cb.is_reg[id] = FALSE; bt_prf_sys_cb.is_reg[id] = FALSE;
} }
/******************************************************************************* /*******************************************************************************
** **
** Function bt_prf_sys_is_register ** Function bt_prf_sys_is_register
** **
** Description Called by other profile subsystems to get registeration ** Description Called by other profile subsystems to get registeration
** status. ** status.
** **
** **
** Returns void ** Returns void
** **
*******************************************************************************/ *******************************************************************************/
BOOLEAN bt_prf_sys_is_register(UINT8 id) BOOLEAN bt_prf_sys_is_register(UINT8 id)
{ {
return bt_prf_sys_cb.is_reg[id]; return bt_prf_sys_cb.is_reg[id];
} }
/******************************************************************************* /*******************************************************************************
** **
** Function bt_prf_sys_sendmsg ** Function bt_prf_sys_sendmsg
** **
** Description Send a GKI message to the profile task. ** Description Send a GKI message to the profile task.
** **
** **
** Returns void ** Returns void
** **
*******************************************************************************/ *******************************************************************************/
void bt_prf_sys_sendmsg(void *p_msg) void bt_prf_sys_sendmsg(void *p_msg)
{ {
// There is a race condition that occurs if the stack is shut down while // There is a race condition that occurs if the stack is shut down while
// there is a procedure in progress that can schedule a task via this // there is a procedure in progress that can schedule a task via this
// message queue. This causes |btu_bta_msg_queue| to get cleaned up before // message queue. This causes |btu_bta_msg_queue| to get cleaned up before
// it gets used here; hence we check for NULL before using it. // it gets used here; hence we check for NULL before using it.
if (bt_profile_msg_queue) { if (bt_profile_msg_queue) {
fixed_queue_enqueue(bt_profile_msg_queue, p_msg); fixed_queue_enqueue(bt_profile_msg_queue, p_msg);
bt_prf_task_post(SIG_PRF_WORK); bt_prf_task_post(SIG_PRF_WORK);
} }
} }

View file

@ -1,59 +1,59 @@
/** /**
**************************************************************************************** ****************************************************************************************
* *
* @file bt_prf_task.c * @file bt_prf_task.c
* *
* @brief Application entry point * @brief Application entry point
* *
* Copyright (C) Espressif 2016 * Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/11 * Created by Yulong at 2016/10/11
* *
* *
**************************************************************************************** ****************************************************************************************
*/ */
#include "bt_prf_task.h" #include "bt_prf_task.h"
#include "bt_prf_sys.h" #include "bt_prf_sys.h"
#include "allocator.h" #include "allocator.h"
#include "thread.h" #include "thread.h"
#include "gki.h" #include "gki.h"
//thread_t *bt_workqueue_thread; //thread_t *bt_workqueue_thread;
//static const char *BT_WORKQUEUE_NAME = "bt_workqueue"; //static const char *BT_WORKQUEUE_NAME = "bt_workqueue";
xTaskHandle xProfileTaskHandle = NULL; xTaskHandle xProfileTaskHandle = NULL;
xQueueHandle xProfileQueue = 0; xQueueHandle xProfileQueue = 0;
// Communication queue between bt_proflie_task and app. // Communication queue between bt_proflie_task and app.
extern fixed_queue_t *bt_profile_msg_queue; extern fixed_queue_t *bt_profile_msg_queue;
/***************************************************************************** /*****************************************************************************
** **
** Function bt_prf_task_thread_handler ** Function bt_prf_task_thread_handler
** **
** Description Process profile Task Thread. ** Description Process profile Task Thread.
******************************************************************************/ ******************************************************************************/
void bt_prf_task_thread_handler(void *arg) void bt_prf_task_thread_handler(void *arg)
{ {
//ke_event_clear(KE_EVENT_BTU_TASK_THREAD); //ke_event_clear(KE_EVENT_BTU_TASK_THREAD);
TaskEvt_t *e; TaskEvt_t *e;
for (;;) { for (;;) {
if (pdTRUE == xQueueReceive(xProfileQueue, &e, (portTickType)portMAX_DELAY)) { if (pdTRUE == xQueueReceive(xProfileQueue, &e, (portTickType)portMAX_DELAY)) {
if (e->sig == SIG_BTU_WORK) { if (e->sig == SIG_BTU_WORK) {
fixed_queue_process(bt_profile_msg_queue); fixed_queue_process(bt_profile_msg_queue);
} }
else if (e->sig == SIG_BTU_START_UP) { else if (e->sig == SIG_BTU_START_UP) {
bt_prf_task_start_up(); bt_prf_task_start_up();
} }
osi_free(e); osi_free(e);
} }
} }
} }
void bt_prf_task_post(uint32_t sig) void bt_prf_task_post(uint32_t sig)
{ {
TaskEvt_t *evt = (TaskEvt_t *)osi_malloc(sizeof(TaskEvt_t)); TaskEvt_t *evt = (TaskEvt_t *)osi_malloc(sizeof(TaskEvt_t));
if (evt == NULL) if (evt == NULL)
@ -62,72 +62,72 @@
evt->sig = sig; evt->sig = sig;
evt->par = 0; evt->par = 0;
if (xQueueSend(xProfileQueue, &evt, 10/portTICK_RATE_MS) != pdTRUE) { if (xQueueSend(xProfileQueue, &evt, 10/portTICK_RATE_MS) != pdTRUE) {
ets_printf("xProfileQueue failed\n"); ets_printf("xProfileQueue failed\n");
} }
} }
void bt_profile_msg_ready(fixed_queue_t *queue) { void bt_profile_msg_ready(fixed_queue_t *queue) {
BT_HDR *p_msg; BT_HDR *p_msg;
while (!fixed_queue_is_empty(queue)) { while (!fixed_queue_is_empty(queue)) {
p_msg = (BT_HDR *)fixed_queue_dequeue(queue); p_msg = (BT_HDR *)fixed_queue_dequeue(queue);
if(p_msg != NULL) if(p_msg != NULL)
{ {
bt_prf_sys_event(p_msg); bt_prf_sys_event(p_msg);
} }
} }
} }
void bt_prf_task_start_up(void) void bt_prf_task_start_up(void)
{ {
fixed_queue_register_dequeue(bt_profile_msg_queue, bt_profile_msg_ready); fixed_queue_register_dequeue(bt_profile_msg_queue, bt_profile_msg_ready);
} }
void bt_prf_task_shut_down(void) void bt_prf_task_shut_down(void)
{ {
fixed_queue_unregister_dequeue(bt_profile_msg_queue); fixed_queue_unregister_dequeue(bt_profile_msg_queue);
bt_prf_free_core(); bt_prf_free_core();
} }
void bt_prf_StartUp(void) void bt_prf_StartUp(void)
{ {
bt_profile_msg_queue = fixed_queue_new(SIZE_MAX); bt_profile_msg_queue = fixed_queue_new(SIZE_MAX);
if (bt_profile_msg_queue == NULL) if (bt_profile_msg_queue == NULL)
goto error_exit; goto error_exit;
return; return;
error_exit:; error_exit:;
LOG_ERROR("%s Unable to allocate resources for bt_workqueue\n", __func__); LOG_ERROR("%s Unable to allocate resources for bt_workqueue\n", __func__);
bt_prf_ShutDown(); bt_prf_ShutDown();
} }
void bt_prf_ShutDown(void) void bt_prf_ShutDown(void)
{ {
bt_prf_task_shut_down(); bt_prf_task_shut_down();
//thread_free(bt_workqueue_thread); //thread_free(bt_workqueue_thread);
vTaskDelete(xProfileTaskHandle); vTaskDelete(xProfileTaskHandle);
vQueueDelete(xProfileQueue); vQueueDelete(xProfileQueue);
bt_profile_msg_queue = NULL; bt_profile_msg_queue = NULL;
// bt_workqueue_thread = NULL; // bt_workqueue_thread = NULL;
xProfileTaskHandle = NULL; xProfileTaskHandle = NULL;
xProfileQueue = 0; xProfileQueue = 0;
} }
void bt_prf_free_core(void) void bt_prf_free_core(void)
{ {
} }

View file

@ -1,17 +1,17 @@
/** /**
**************************************************************************************** ****************************************************************************************
* *
* @file bt_profile_act.c * @file bt_profile_act.c
* *
* @brief Application entry point * @brief Application entry point
* *
* Copyright (C) Espressif 2016 * Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/13 * Created by Yulong at 2016/10/13
* *
* *
**************************************************************************************** ****************************************************************************************
*/ */

View file

@ -1,134 +1,134 @@
/** /**
**************************************************************************************** ****************************************************************************************
* *
* @file bt_prf_task.h * @file bt_prf_task.h
* *
* @brief Application entry point * @brief Application entry point
* *
* Copyright (C) Espressif 2016 * Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/12 * Created by Yulong at 2016/10/12
* *
* *
**************************************************************************************** ****************************************************************************************
*/ */
#include <string.h> #include <string.h>
enum enum
{ {
API_BLE_DEVICE_READY_IND, API_BLE_DEVICE_READY_IND,
API_BLE_DM_CMP_EVT, API_BLE_DM_CMP_EVT,
API_BLE_CONN_CMP_EVT, API_BLE_CONN_CMP_EVT,
API_BLE_CONN_REQ_IND, API_BLE_CONN_REQ_IND,
API_BLE_DISCONN_IND, API_BLE_DISCONN_IND,
API_BLE_MODULE_INIT_CMP_EVT, API_BLE_MODULE_INIT_CMP_EVT,
API_BLE_ADV_REPORT_IND, API_BLE_ADV_REPORT_IND,
#if (BLE_SEC) #if (BLE_SEC)
API_BLE_BOND_REQ_IND, API_BLE_BOND_REQ_IND,
API_BLE_BOND_REQ_IND, API_BLE_BOND_REQ_IND,
API_BLE_ENCRYPT_REQ_IND, API_BLE_ENCRYPT_REQ_IND,
API_BLE_ENCRYPT_IND, API_BLE_ENCRYPT_IND,
#endif ///BLE_SEC #endif ///BLE_SEC
#if (BLE_DISS_SERVER) #if (BLE_DISS_SERVER)
API_BLE_CREATE_DB_CFM, API_BLE_CREATE_DB_CFM,
API_BLE_DISABLE_IND, API_BLE_DISABLE_IND,
#endif ///BLE_DISS_SERVER #endif ///BLE_DISS_SERVER
#if (BLE_PROX_REPORTER) #if (BLE_PROX_REPORTER)
API_BLE_PROXR_ALERT_IND, API_BLE_PROXR_ALERT_IND,
API_BLE_PXP_TIMER, API_BLE_PXP_TIMER,
API_BLE_PROXR_CREATE_DB_CFM, API_BLE_PROXR_CREATE_DB_CFM,
API_BLE_PROXR_DISABLE_IND, API_BLE_PROXR_DISABLE_IND,
#endif ///BLE_PROX_REPORTER #endif ///BLE_PROX_REPORTER
#if (BLE_BUT_SERVER) #if (BLE_BUT_SERVER)
API_BLE_BUT_VAL_RECEIVCE, API_BLE_BUT_VAL_RECEIVCE,
API_BLE_CREATE_DB_CFM, API_BLE_CREATE_DB_CFM,
API_BLE_VAL_SEND_CFM, API_BLE_VAL_SEND_CFM,
#endif ///BLE_BUT_SERVER #endif ///BLE_BUT_SERVER
#if (BLE_APP_KEYBOARD) #if (BLE_APP_KEYBOARD)
API_BLE_HIDD_CREATE_DB_CFM, API_BLE_HIDD_CREATE_DB_CFM,
API_BLE_DISABLE_IND, API_BLE_DISABLE_IND,
API_BLE_NTF_SENT_CFM, API_BLE_NTF_SENT_CFM,
API_BLE_HIDD_TIMER, API_BLE_HIDD_TIMER,
API_BLE_GREEN_LED_TIMER, API_BLE_GREEN_LED_TIMER,
API_BLE_RED_LED_TIMER, API_BLE_RED_LED_TIMER,
#ifndef MITM_ON #ifndef MITM_ON
API_BLE_HIDD_ENC_TIMER, API_BLE_HIDD_ENC_TIMER,
#endif ///MITM_ON #endif ///MITM_ON
API_BLE_UPDATED_PRIVACY_IND, API_BLE_UPDATED_PRIVACY_IND,
API_BLE_UPDATED_RECON_ADDR_IND, API_BLE_UPDATED_RECON_ADDR_IND,
API_BLE_HID_MSG, API_BLE_HID_MSG,
#endif ///BLE_APP_KEYBOARD #endif ///BLE_APP_KEYBOARD
#if (BLE_BATT_SERVER) #if (BLE_BATT_SERVER)
API_BLE_BATT_CREATE_DB_CFM, API_BLE_BATT_CREATE_DB_CFM,
API_BLE_BATT_LEVEL_UPD_CFM, API_BLE_BATT_LEVEL_UPD_CFM,
API_BLE_BATT_LEVEL_NTF_CFG_IND, API_BLE_BATT_LEVEL_NTF_CFG_IND,
API_BLE_BATT_TIMER, API_BLE_BATT_TIMER,
APP_BLE_ALERT_TIMER, APP_BLE_ALERT_TIMER,
#endif ///BLE_BATT_SERVER #endif ///BLE_BATT_SERVER
#if (BLE_FINDME_TARGET) #if (BLE_FINDME_TARGET)
API_BLE_FINDT_ALERT_IND, API_BLE_FINDT_ALERT_IND,
#endif ///BLE_FINDME_TARGET #endif ///BLE_FINDME_TARGET
#if (BLE_FINDME_LOCATOR) #if (BLE_FINDME_LOCATOR)
API_BLE_FINDL_ENABLE_CFM, API_BLE_FINDL_ENABLE_CFM,
#endif ///BLE_FINDME_LOCATOR #endif ///BLE_FINDME_LOCATOR
#if (HAS_MULTI_BOND) #if (HAS_MULTI_BOND)
API_BLE_PAIR_TIMER, API_BLE_PAIR_TIMER,
#endif ///HAS_MULTI_BOND #endif ///HAS_MULTI_BOND
#if (BLE_SPOTA_RECEIVER) #if (BLE_SPOTA_RECEIVER)
API_BLE_SPOTAR_PATCH_MEM_DEV_IND, API_BLE_SPOTAR_PATCH_MEM_DEV_IND,
API_BLE_SPOTAR_GPIO_MAP_IND, API_BLE_SPOTAR_GPIO_MAP_IND,
API_BLE_SPOTAR_PATCH_LEN_IND, API_BLE_SPOTAR_PATCH_LEN_IND,
API_BLE_SPOTAR_PATCH_DATA_IND, API_BLE_SPOTAR_PATCH_DATA_IND,
API_BLE_SPOTAR_CREATE_DB_CFM, API_BLE_SPOTAR_CREATE_DB_CFM,
#endif ///BLE_SPOTA_RECEIVER #endif ///BLE_SPOTA_RECEIVER
#if (BLE_APP_SMARTTAG) #if (BLE_APP_SMARTTAG)
API_BLE_ADV_TIMER, API_BLE_ADV_TIMER,
API_BLE_ADV_BLINK_TIMER, API_BLE_ADV_BLINK_TIMER,
API_BLE_WAKEUP_MSG, API_BLE_WAKEUP_MSG,
#endif ///BLE_APP_SMARTTAG #endif ///BLE_APP_SMARTTAG
#if (BLE_APP_PROXR) #if (BLE_APP_PROXR)
API_BLE_ADV_TIMER, API_BLE_ADV_TIMER,
API_BLE_WAKEUP_MSG, API_BLE_WAKEUP_MSG,
#endif ///BLE_APP_PROXR #endif ///BLE_APP_PROXR
#if (BLE_INTEGRATED_HOST_GTL_CENTRAL) #if (BLE_INTEGRATED_HOST_GTL_CENTRAL)
API_BLE_EXT_TEST_REQ, API_BLE_EXT_TEST_REQ,
API_BLE_EXT_SCAN_CMD, API_BLE_EXT_SCAN_CMD,
API_BLE_EXT_CONNECT_CMD, API_BLE_EXT_CONNECT_CMD,
API_BLE_EXT_DISCONNECT_CMD, API_BLE_EXT_DISCONNECT_CMD,
API_BLE_EXT_TRANSMIT_CMD, API_BLE_EXT_TRANSMIT_CMD,
#endif ///BLE_INTEGRATED_HOST_GTL #endif ///BLE_INTEGRATED_HOST_GTL
#if (BLE_APP_THROUGHPUT_PERIPHERAL) #if (BLE_APP_THROUGHPUT_PERIPHERAL)
API_BLE_EXT_TEST_REQ, API_BLE_EXT_TEST_REQ,
API_BLE_EXT_DISCONNECT_CMD, API_BLE_EXT_DISCONNECT_CMD,
API_BLE_EXT_TRANSMIT_CMD, API_BLE_EXT_TRANSMIT_CMD,
#endif ///BLE_APP_THROUGHPUT_PERIPHERAL #endif ///BLE_APP_THROUGHPUT_PERIPHERAL
#if (BLE_STREAMDATA_HOST) #if (BLE_STREAMDATA_HOST)
API_BLE_STREAMDATAH_ENABLE_CFM, API_BLE_STREAMDATAH_ENABLE_CFM,
API_BLE_STREAMDATAH_RCV_DATA_PACKET_IND, API_BLE_STREAMDATAH_RCV_DATA_PACKET_IND,
#endif ///BLE_STREAMDATA_HOST #endif ///BLE_STREAMDATA_HOST
#if (BLE_STREAMDATA_DEVICE) #if (BLE_STREAMDATA_DEVICE)
API_BLE_STREAMDATAD_CREATE_DB_CFM, API_BLE_STREAMDATAD_CREATE_DB_CFM,
API_BLE_STREAMDATAD_RCV_DATA_PACKET_IND, API_BLE_STREAMDATAD_RCV_DATA_PACKET_IND,
#endif ///BLE_STREAMDATA_DEVICE #endif ///BLE_STREAMDATA_DEVICE
}; };

View file

@ -1,86 +1,86 @@
/** /**
**************************************************************************************** ****************************************************************************************
* *
* @file bt_prf_sys.h * @file bt_prf_sys.h
* *
* @brief Application entry point * @brief Application entry point
* *
* Copyright (C) Espressif 2016 * Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/12 * Created by Yulong at 2016/10/12
* *
* *
**************************************************************************************** ****************************************************************************************
*/ */
#ifndef _PROFILE_SYS_H__ #ifndef _PROFILE_SYS_H__
#define _PROFILE_SYS_H__ #define _PROFILE_SYS_H__
#include "bt_types.h" #include "bt_types.h"
enum enum
{ {
PRF_ID_SYS, PRF_ID_SYS,
PRF_ID_CONN, PRF_ID_CONN,
PRF_ID_HIDD_LE, PRF_ID_HIDD_LE,
PRF_ID_HIDH_LE, PRF_ID_HIDH_LE,
PRF_ID_DISS_LE, PRF_ID_DISS_LE,
PRF_ID_DISC_LE, PRF_ID_DISC_LE,
PRF_ID_AIRSYNC_LE, PRF_ID_AIRSYNC_LE,
PRF_ID_ANCC_LE, PRF_ID_ANCC_LE,
PRF_ID_BUT_LE, PRF_ID_BUT_LE,
PRF_ID_MAX PRF_ID_MAX
}; };
typedef UINT8 tBT_PRF_SYS_CONN_STATUS; typedef UINT8 tBT_PRF_SYS_CONN_STATUS;
/* disable function type */ /* disable function type */
typedef void (tBT_PRF_SYS_DISABLE)(void); typedef void (tBT_PRF_SYS_DISABLE)(void);
/* event handler function type */ /* event handler function type */
typedef BOOLEAN (tBT_PRF_SYS_EVT_HDLR)(BT_HDR *p_msg); typedef BOOLEAN (tBT_PRF_SYS_EVT_HDLR)(BT_HDR *p_msg);
/* conn callback for role / low power manager*/ /* conn callback for role / low power manager*/
typedef void (tBT_PRF_SYS_CONN_CBACK)(tBT_PRF_SYS_CONN_STATUS status, typedef void (tBT_PRF_SYS_CONN_CBACK)(tBT_PRF_SYS_CONN_STATUS status,
UINT8 id, UINT8 app_id, BD_ADDR peer_addr); UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
/* Calculate start of event enumeration; id is top 8 bits of event */ /* Calculate start of event enumeration; id is top 8 bits of event */
#define BT_PRF_SYS_EVT_START(id) ((id) << 8) #define BT_PRF_SYS_EVT_START(id) ((id) << 8)
/* registration structure */ /* registration structure */
typedef struct typedef struct
{ {
tBT_PRF_SYS_EVT_HDLR *evt_hdlr; tBT_PRF_SYS_EVT_HDLR *evt_hdlr;
tBT_PRF_SYS_DISABLE *disable; tBT_PRF_SYS_DISABLE *disable;
} tBT_PRF_SYS_REG; } tBT_PRF_SYS_REG;
/* system manager control block */ /* system manager control block */
typedef struct typedef struct
{ {
tBT_PRF_SYS_REG *reg[PRF_ID_MAX]; /* registration structures */ tBT_PRF_SYS_REG *reg[PRF_ID_MAX]; /* registration structures */
BOOLEAN is_reg[PRF_ID_MAX]; /* registration structures */ BOOLEAN is_reg[PRF_ID_MAX]; /* registration structures */
tBT_PRF_SYS_CONN_CBACK *prm_cb; /* role management callback registered by DM */ tBT_PRF_SYS_CONN_CBACK *prm_cb; /* role management callback registered by DM */
tBT_PRF_SYS_CONN_CBACK *ppm_cb; /* low power management callback registered by DM */ tBT_PRF_SYS_CONN_CBACK *ppm_cb; /* low power management callback registered by DM */
tBT_PRF_SYS_CONN_CBACK *p_policy_cb; /* link policy change callback registered by DM */ tBT_PRF_SYS_CONN_CBACK *p_policy_cb; /* link policy change callback registered by DM */
} tBT_PRF_SYS_CB; } tBT_PRF_SYS_CB;
extern tBT_PRF_SYS_CB bt_prf_sys_cb; extern tBT_PRF_SYS_CB bt_prf_sys_cb;
extern void bt_prf_sys_init(void); extern void bt_prf_sys_init(void);
extern void bt_prf_sys_free(void); extern void bt_prf_sys_free(void);
extern void bt_prf_sys_event(BT_HDR *p_msg); extern void bt_prf_sys_event(BT_HDR *p_msg);
extern void bt_prf_sys_register(UINT8 id, const tBT_PRF_SYS_REG *p_reg); extern void bt_prf_sys_register(UINT8 id, const tBT_PRF_SYS_REG *p_reg);
extern void bt_prf_sys_deregister(UINT8 id); extern void bt_prf_sys_deregister(UINT8 id);
extern BOOLEAN bt_prf_sys_is_register(UINT8 id); extern BOOLEAN bt_prf_sys_is_register(UINT8 id);
extern void bt_prf_sys_idle(UINT8 id, UINT8 app_id, BD_ADDR peer_addr); extern void bt_prf_sys_idle(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
extern void bt_prf_sys_busy(UINT8 id, UINT8 app_id, BD_ADDR peer_addr); extern void bt_prf_sys_busy(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
#endif ///_PROFILE_SYS_H__ #endif ///_PROFILE_SYS_H__

View file

@ -1,50 +1,50 @@
/** /**
**************************************************************************************** ****************************************************************************************
* *
* @file bt_prf_task.h * @file bt_prf_task.h
* *
* @brief Application entry point * @brief Application entry point
* *
* Copyright (C) Espressif 2016 * Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/11 * Created by Yulong at 2016/10/11
* *
* *
**************************************************************************************** ****************************************************************************************
*/ */
#include <stddef.h> #include <stddef.h>
#include "bt_defs.h" #include "bt_defs.h"
#include "fixed_queue.h" #include "fixed_queue.h"
#ifndef BT_PRF_TASK_H__ #ifndef BT_PRF_TASK_H__
#define BT_PRF_TASK_H__ #define BT_PRF_TASK_H__
/* Functions provided by btu_core.c /* Functions provided by btu_core.c
************************************ ************************************
*/ */
void bt_prf_task_thread_handler(void *arg);
void bt_prf_init_core(void);
void bt_prf_free_core(void);
void bt_prf_task_post(uint32_t sig);
void bt_prf_StartUp(void);
void bt_prf_ShutDown(void);
void bt_prf_task_start_up(void); void bt_prf_task_thread_handler(void *arg);
void bt_prf_task_shut_down(void);
void bt_prf_init_core(void);
void bt_profile_msg_ready(fixed_queue_t *queue); void bt_prf_free_core(void);
void bt_prf_task_post(uint32_t sig);
void bt_prf_StartUp(void);
void bt_prf_ShutDown(void);
void bt_prf_task_start_up(void);
#endif /// BT_PRF_TASK_H__ void bt_prf_task_shut_down(void);
void bt_profile_msg_ready(fixed_queue_t *queue);
#endif /// BT_PRF_TASK_H__

View file

@ -1,115 +1,115 @@
/** /**
**************************************************************************************** ****************************************************************************************
* *
* @file wx_airsync_prf.h * @file wx_airsync_prf.h
* *
* @brief Application entry point * @brief Application entry point
* *
* Copyright (C) Espressif 2016 * Copyright (C) Espressif 2016
* Created by Yulong at 2016/9/29 * Created by Yulong at 2016/9/29
* *
* *
**************************************************************************************** ****************************************************************************************
*/ */
#include "prf_defs.h" #include "prf_defs.h"
#if (WX_AIRSYNC_CFG) #if (WX_AIRSYNC_CFG)
#include "bt_target.h" #include "bt_target.h"
#include "gatt_api.h" #include "gatt_api.h"
#include "gattdefs.h" #include "gattdefs.h"
/// Maximum Transmission Unit /// Maximum Transmission Unit
#define ATT_DEFAULT_MTU (23) #define ATT_DEFAULT_MTU (23)
#define BLE_WECHAT_MAX_DATA_LEN (ATT_DEFAULT_MTU - 3) #define BLE_WECHAT_MAX_DATA_LEN (ATT_DEFAULT_MTU - 3)
//define the key serivce uuid //define the key serivce uuid
#define ATT_SVC_AIRSYNC 0xFEE7 #define ATT_SVC_AIRSYNC 0xFEE7
//define the airsync Char uuid //define the airsync Char uuid
#define ATT_CHAR_AIRSYNC_WIT 0xFEC7 #define ATT_CHAR_AIRSYNC_WIT 0xFEC7
#define ATT_CHAR_AIRSYBC_NTF 0xFEC8 #define ATT_CHAR_AIRSYBC_NTF 0xFEC8
#define ATT_CHAR_AIRSYNC_READ 0xFEC9 #define ATT_CHAR_AIRSYNC_READ 0xFEC9
typedef void (tAIRSYNC_CBACK)(UINT8 app_id, UINT8 event, UINT8 len, UINT8 *data); typedef void (tAIRSYNC_CBACK)(UINT8 app_id, UINT8 event, UINT8 len, UINT8 *data);
/// WX AirSync Service Attributes Indexes /// WX AirSync Service Attributes Indexes
enum enum
{ {
WX_IDX_SVC, WX_IDX_SVC,
WX_IDX_AIRSYNC_WIT_CHAR, WX_IDX_AIRSYNC_WIT_CHAR,
WX_IDX_AIRSYNC_WIT_VAL, WX_IDX_AIRSYNC_WIT_VAL,
WX_IDX_AIRSYNC_NTF_CHAR, WX_IDX_AIRSYNC_NTF_CHAR,
WX_IDX_AIRSYNC_NTF_VAL, WX_IDX_AIRSYNC_NTF_VAL,
WX_IDX_AIRSYNC_READ_CHAR, WX_IDX_AIRSYNC_READ_CHAR,
WX_IDX_AIRSYNC_READ_VAL, WX_IDX_AIRSYNC_READ_VAL,
WX_IDX_AIRSYNC_NTF_CFG, WX_IDX_AIRSYNC_NTF_CFG,
KEY_IDX_NB, KEY_IDX_NB,
}; };
typedef struct typedef struct
{ {
BD_ADDR remote_bda; BD_ADDR remote_bda;
BOOLEAN need_rsp; BOOLEAN need_rsp;
UINT16 clt_cfg; UINT16 clt_cfg;
}tAirSync_WRITE_DATA; }tAirSync_WRITE_DATA;
typedef struct typedef struct
{ {
BOOLEAN in_use; BOOLEAN in_use;
BOOLEAN congest; BOOLEAN congest;
UINT16 conn_id; UINT16 conn_id;
BOOLEAN connected; BOOLEAN connected;
BD_ADDR remote_bda; BD_ADDR remote_bda;
UINT32 trans_id; UINT32 trans_id;
UINT8 cur_srvc_id; UINT8 cur_srvc_id;
}tAirSync_CLCB; }tAirSync_CLCB;
typedef struct typedef struct
{ {
UINT8 app_id; UINT8 app_id;
UINT16 airsync_wirt_hdl; UINT16 airsync_wirt_hdl;
UINT16 airsync_ntf_hdl; UINT16 airsync_ntf_hdl;
UINT16 airsync_read_hdl; UINT16 airsync_read_hdl;
UINT16 airsync_cfg_hdl; UINT16 airsync_cfg_hdl;
tAIRSYNC_CBACK *p_cback; tAIRSYNC_CBACK *p_cback;
}tAirSync_INST; }tAirSync_INST;
/* service engine control block */ /* service engine control block */
typedef struct typedef struct
{ {
tAirSync_CLCB clcb; /* connection link*/ tAirSync_CLCB clcb; /* connection link*/
tGATT_IF gatt_if; tGATT_IF gatt_if;
BOOLEAN enabled; BOOLEAN enabled;
BOOLEAN is_primery; BOOLEAN is_primery;
tAirSync_INST airsync_inst; tAirSync_INST airsync_inst;
UINT8 inst_id; UINT8 inst_id;
}tAIRSYNC_CB_ENV; }tAIRSYNC_CB_ENV;
void AirSync_CreateService(void); void AirSync_CreateService(void);
tAirSync_CLCB *airsync_env_clcb_alloc (UINT16 conn_id, BD_ADDR remote_bda); tAirSync_CLCB *airsync_env_clcb_alloc (UINT16 conn_id, BD_ADDR remote_bda);
UINT16 AirSync_env_find_conn_id_by_bd_adddr(BD_ADDR bda); UINT16 AirSync_env_find_conn_id_by_bd_adddr(BD_ADDR bda);
BOOLEAN AirSync_env_clcb_dealloc(UINT16 conn_id); BOOLEAN AirSync_env_clcb_dealloc(UINT16 conn_id);
tGATT_STATUS AirSync_Init(tAIRSYNC_CBACK *call_back); tGATT_STATUS AirSync_Init(tAIRSYNC_CBACK *call_back);
void AirSync_msg_notify(UINT8 len, UINT8 *button_msg); void AirSync_msg_notify(UINT8 len, UINT8 *button_msg);
extern tAIRSYNC_CB_ENV airsync_cb_env; extern tAIRSYNC_CB_ENV airsync_cb_env;
#endif ///WX_AIRSYNC_CFG #endif ///WX_AIRSYNC_CFG

View file

@ -1,286 +1,286 @@
/** /**
**************************************************************************************** ****************************************************************************************
* *
* @file wx_airsync_prf.c * @file wx_airsync_prf.c
* *
* @brief Application entry point * @brief Application entry point
* *
* Copyright (C) Espressif 2016 * Copyright (C) Espressif 2016
* Created by Yulong at 2016/9/29 * Created by Yulong at 2016/9/29
* *
* *
**************************************************************************************** ****************************************************************************************
*/ */
#include "wx_airsync_prf.h" #include "wx_airsync_prf.h"
#if (WX_AIRSYNC_CFG) #if (WX_AIRSYNC_CFG)
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include "bt_target.h" #include "bt_target.h"
#include "bt_trace.h" #include "bt_trace.h"
#include "bt_types.h" #include "bt_types.h"
#include "gatt_api.h" #include "gatt_api.h"
#include "bta_api.h" #include "bta_api.h"
#include "bta_gatt_api.h" #include "bta_gatt_api.h"
#include "bta_gatts_int.h" #include "bta_gatts_int.h"
tAIRSYNC_CB_ENV airsync_cb_env; tAIRSYNC_CB_ENV airsync_cb_env;
/***************************************************************************** /*****************************************************************************
** Constants ** Constants
*****************************************************************************/ *****************************************************************************/
static void airsync_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data); static void airsync_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data);
/******************************************************************************* /*******************************************************************************
** **
** Function airsync_profile_cb ** Function airsync_profile_cb
** **
** Description the callback function after the profile has been register to the BTA manager module ** Description the callback function after the profile has been register to the BTA manager module
** **
** Returns NULL ** Returns NULL
** **
*******************************************************************************/ *******************************************************************************/
static void airsync_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) static void airsync_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
{ {
tBTA_GATTS_RSP rsp; tBTA_GATTS_RSP rsp;
tBT_UUID uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}}; tBT_UUID uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}};
tAirSync_INST *p_inst = &airsync_cb_env.airsync_inst; tAirSync_INST *p_inst = &airsync_cb_env.airsync_inst;
LOG_ERROR("airsync profile cb event = %x\n",event); LOG_ERROR("airsync profile cb event = %x\n",event);
switch(event) switch(event)
{ {
case BTA_GATTS_REG_EVT: case BTA_GATTS_REG_EVT:
if(p_data->reg_oper.status != BTA_GATT_OK) if(p_data->reg_oper.status != BTA_GATT_OK)
{ {
LOG_ERROR("button profile register failed\n"); LOG_ERROR("button profile register failed\n");
} }
airsync_cb_env.gatt_if = p_data->reg_oper.server_if; airsync_cb_env.gatt_if = p_data->reg_oper.server_if;
airsync_cb_env.enabled = true; airsync_cb_env.enabled = true;
if(p_data->reg_oper.uuid.uu.uuid16 == ATT_SVC_AIRSYNC) if(p_data->reg_oper.uuid.uu.uuid16 == ATT_SVC_AIRSYNC)
{ {
AirSync_CreateService(); AirSync_CreateService();
} }
break; break;
case BTA_GATTS_READ_EVT: case BTA_GATTS_READ_EVT:
if(airsync_cb_env.clcb.connected && airsync_cb_env.enabled){ if(airsync_cb_env.clcb.connected && airsync_cb_env.enabled){
//tBTA_GATTS_RSP rsp; //tBTA_GATTS_RSP rsp;
memset(&rsp,0,sizeof(tBTA_GATTS_API_RSP)); memset(&rsp,0,sizeof(tBTA_GATTS_API_RSP));
rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle; rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle;
rsp.attr_value.len = 2; rsp.attr_value.len = 2;
BTA_GATTS_SendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id, BTA_GATTS_SendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
p_data->req_data.status,&rsp); p_data->req_data.status,&rsp);
} }
break; break;
case BTA_GATTS_WRITE_EVT: case BTA_GATTS_WRITE_EVT:
if(airsync_cb_env.clcb.connected && airsync_cb_env.enabled){ if(airsync_cb_env.clcb.connected && airsync_cb_env.enabled){
BTA_GATTS_SendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id, BTA_GATTS_SendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
p_data->req_data.status,NULL); p_data->req_data.status,NULL);
} }
break; break;
case BTA_GATTS_CONF_EVT: case BTA_GATTS_CONF_EVT:
break; break;
case BTA_GATTS_CREATE_EVT: case BTA_GATTS_CREATE_EVT:
uuid.uu.uuid16 = ATT_CHAR_AIRSYNC_WIT; uuid.uu.uuid16 = ATT_CHAR_AIRSYNC_WIT;
airsync_cb_env.clcb.cur_srvc_id= p_data->create.service_id; airsync_cb_env.clcb.cur_srvc_id= p_data->create.service_id;
airsync_cb_env.is_primery = p_data->create.is_primary; airsync_cb_env.is_primery = p_data->create.is_primary;
//start the airsync service after created //start the airsync service after created
BTA_GATTS_StartService(p_data->create.service_id,BTA_GATT_TRANSPORT_LE); BTA_GATTS_StartService(p_data->create.service_id,BTA_GATT_TRANSPORT_LE);
//add the frist airsync characteristic --> write characteristic //add the frist airsync characteristic --> write characteristic
BTA_GATTS_AddCharacteristic(airsync_cb_env.clcb.cur_srvc_id,&uuid, BTA_GATTS_AddCharacteristic(airsync_cb_env.clcb.cur_srvc_id,&uuid,
(GATT_PERM_WRITE|GATT_PERM_READ), (GATT_PERM_WRITE|GATT_PERM_READ),
(GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_WRITE)); (GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_WRITE));
break; break;
case BTA_GATTS_ADD_CHAR_EVT: case BTA_GATTS_ADD_CHAR_EVT:
if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYNC_WIT) if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYNC_WIT)
{ {
uuid.uu.uuid16 = ATT_CHAR_AIRSYBC_NTF; uuid.uu.uuid16 = ATT_CHAR_AIRSYBC_NTF;
//tBTA_GATT_PERM perm = GATT_PERM_READ; //tBTA_GATT_PERM perm = GATT_PERM_READ;
//tBTA_GATT_CHAR_PROP prop = (GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_NOTIFY); //tBTA_GATT_CHAR_PROP prop = (GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_NOTIFY);
//save the att handle to the env //save the att handle to the env
airsync_cb_env.airsync_inst.airsync_wirt_hdl = p_data->add_result.attr_id; airsync_cb_env.airsync_inst.airsync_wirt_hdl = p_data->add_result.attr_id;
//add the second airsync characteristic --> Notify characteristic //add the second airsync characteristic --> Notify characteristic
BTA_GATTS_AddCharacteristic(airsync_cb_env.clcb.cur_srvc_id,&uuid, BTA_GATTS_AddCharacteristic(airsync_cb_env.clcb.cur_srvc_id,&uuid,
GATT_PERM_READ,(GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_INDICATE)); GATT_PERM_READ,(GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_INDICATE));
}else if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYBC_NTF){ }else if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYBC_NTF){
//tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_WRITE); //tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_WRITE);
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG; uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
airsync_cb_env.airsync_inst.airsync_ntf_hdl = p_data->add_result.attr_id; airsync_cb_env.airsync_inst.airsync_ntf_hdl = p_data->add_result.attr_id;
BTA_GATTS_AddCharDescriptor (airsync_cb_env.clcb.cur_srvc_id, BTA_GATTS_AddCharDescriptor (airsync_cb_env.clcb.cur_srvc_id,
(GATT_PERM_WRITE|GATT_PERM_WRITE), (GATT_PERM_WRITE|GATT_PERM_WRITE),
&uuid); &uuid);
uuid.uu.uuid16 = ATT_CHAR_AIRSYNC_READ; uuid.uu.uuid16 = ATT_CHAR_AIRSYNC_READ;
//add the third airsync characteristic --> Read characteristic //add the third airsync characteristic --> Read characteristic
BTA_GATTS_AddCharacteristic(airsync_cb_env.clcb.cur_srvc_id,&uuid, BTA_GATTS_AddCharacteristic(airsync_cb_env.clcb.cur_srvc_id,&uuid,
GATT_PERM_READ, GATT_PERM_READ,
GATT_CHAR_PROP_BIT_READ); GATT_CHAR_PROP_BIT_READ);
}else if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYNC_READ){ }else if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYNC_READ){
airsync_cb_env.airsync_inst.airsync_read_hdl = p_data->add_result.attr_id; airsync_cb_env.airsync_inst.airsync_read_hdl = p_data->add_result.attr_id;
} }
break; break;
case BTA_GATTS_ADD_CHAR_DESCR_EVT: case BTA_GATTS_ADD_CHAR_DESCR_EVT:
if(p_data->add_result.char_uuid.uu.uuid16 == GATT_UUID_CHAR_CLIENT_CONFIG) if(p_data->add_result.char_uuid.uu.uuid16 == GATT_UUID_CHAR_CLIENT_CONFIG)
{ {
airsync_cb_env.airsync_inst.airsync_cfg_hdl = p_data->add_result.attr_id; airsync_cb_env.airsync_inst.airsync_cfg_hdl = p_data->add_result.attr_id;
} }
break; break;
case BTA_GATTS_CONNECT_EVT: case BTA_GATTS_CONNECT_EVT:
//set the connection flag to true //set the connection flag to true
airsync_env_clcb_alloc(p_data->conn.conn_id, p_data->conn.remote_bda); airsync_env_clcb_alloc(p_data->conn.conn_id, p_data->conn.remote_bda);
break; break;
case BTA_GATTS_DISCONNECT_EVT: case BTA_GATTS_DISCONNECT_EVT:
//set the connection flag to true //set the connection flag to true
airsync_cb_env.clcb.connected = false; airsync_cb_env.clcb.connected = false;
break; break;
case BTA_GATTS_OPEN_EVT: case BTA_GATTS_OPEN_EVT:
break; break;
case BTA_GATTS_CLOSE_EVT: case BTA_GATTS_CLOSE_EVT:
if(airsync_cb_env.clcb.connected && (airsync_cb_env.clcb.conn_id == p_data->conn.conn_id)) if(airsync_cb_env.clcb.connected && (airsync_cb_env.clcb.conn_id == p_data->conn.conn_id))
{ {
//set the connection channal congested flag to true //set the connection channal congested flag to true
airsync_cb_env.clcb.congest = p_data->congest.congested; airsync_cb_env.clcb.congest = p_data->congest.congested;
} }
break; break;
case BTA_GATTS_LISTEN_EVT: case BTA_GATTS_LISTEN_EVT:
break; break;
case BTA_GATTS_CONGEST_EVT: case BTA_GATTS_CONGEST_EVT:
//set the congest flag //set the congest flag
airsync_cb_env.clcb.congest = p_data->congest.congested; airsync_cb_env.clcb.congest = p_data->congest.congested;
break; break;
default: default:
break; break;
} }
} }
/******************************************************************************* /*******************************************************************************
** **
** Function AirSync_CreateService ** Function AirSync_CreateService
** **
** Description Create a Service for the airsync profile ** Description Create a Service for the airsync profile
** **
** Returns NULL ** Returns NULL
** **
*******************************************************************************/ *******************************************************************************/
void AirSync_CreateService(void) void AirSync_CreateService(void)
{ {
tBTA_GATTS_IF server_if ; tBTA_GATTS_IF server_if ;
tBT_UUID uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}}; tBT_UUID uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}};
UINT16 num_handle = KEY_IDX_NB; UINT16 num_handle = KEY_IDX_NB;
UINT8 inst = 0x00; UINT8 inst = 0x00;
server_if = airsync_cb_env.gatt_if; server_if = airsync_cb_env.gatt_if;
airsync_cb_env.inst_id = inst; airsync_cb_env.inst_id = inst;
BTA_GATTS_CreateService(server_if,&uuid,inst,num_handle,true); BTA_GATTS_CreateService(server_if,&uuid,inst,num_handle,true);
} }
/******************************************************************************* /*******************************************************************************
** **
** Function airsync_env_clcb_alloc ** Function airsync_env_clcb_alloc
** **
** Description The function allocates a GATT profile connection link control block ** Description The function allocates a GATT profile connection link control block
** **
** Returns NULL if not found. Otherwise pointer to the connection link block. ** Returns NULL if not found. Otherwise pointer to the connection link block.
** **
*******************************************************************************/ *******************************************************************************/
tAirSync_CLCB *airsync_env_clcb_alloc (UINT16 conn_id, BD_ADDR remote_bda) tAirSync_CLCB *airsync_env_clcb_alloc (UINT16 conn_id, BD_ADDR remote_bda)
{ {
tAirSync_CLCB *p_clcb = NULL; tAirSync_CLCB *p_clcb = NULL;
p_clcb = &airsync_cb_env.clcb; p_clcb = &airsync_cb_env.clcb;
if(!p_clcb->in_use) if(!p_clcb->in_use)
{ {
p_clcb->in_use = TRUE; p_clcb->in_use = TRUE;
p_clcb->conn_id = conn_id; p_clcb->conn_id = conn_id;
LOG_ERROR("p_clcb->conn_id = %x\n",conn_id); LOG_ERROR("p_clcb->conn_id = %x\n",conn_id);
p_clcb->connected = TRUE; p_clcb->connected = TRUE;
memcpy(p_clcb->remote_bda,remote_bda,BD_ADDR_LEN); memcpy(p_clcb->remote_bda,remote_bda,BD_ADDR_LEN);
} }
return p_clcb; return p_clcb;
} }
/******************************************************************************* /*******************************************************************************
** **
** Function airsync_env_find_conn_id_by_bd_adddr ** Function airsync_env_find_conn_id_by_bd_adddr
** **
** Description The function searches all LCB with macthing bd address ** Description The function searches all LCB with macthing bd address
** **
** Returns total number of clcb found. ** Returns total number of clcb found.
** **
*******************************************************************************/ *******************************************************************************/
UINT16 airsync_env_find_conn_id_by_bd_adddr(BD_ADDR remote_bda) UINT16 airsync_env_find_conn_id_by_bd_adddr(BD_ADDR remote_bda)
{ {
UINT8 i_clcb; UINT8 i_clcb;
tAirSync_CLCB *p_clcb = NULL; tAirSync_CLCB *p_clcb = NULL;
for(i_clcb = 0, p_clcb = &airsync_cb_env.clcb; i_clcb < 1; i_clcb++, p_clcb++) for(i_clcb = 0, p_clcb = &airsync_cb_env.clcb; i_clcb < 1; i_clcb++, p_clcb++)
{ {
if(p_clcb->in_use && p_clcb->connected &&memcmp(p_clcb->remote_bda,remote_bda,BD_ADDR_LEN)) if(p_clcb->in_use && p_clcb->connected &&memcmp(p_clcb->remote_bda,remote_bda,BD_ADDR_LEN))
{ {
return p_clcb->conn_id; return p_clcb->conn_id;
} }
} }
return GATT_INVALID_CONN_ID; return GATT_INVALID_CONN_ID;
} }
/******************************************************************************* /*******************************************************************************
** **
** Function airsync_init ** Function airsync_init
** **
** Description Initializa the GATT Service for airsync profiles. ** Description Initializa the GATT Service for airsync profiles.
** **
*******************************************************************************/ *******************************************************************************/
tGATT_STATUS AirSync_Init(tAIRSYNC_CBACK *call_back) tGATT_STATUS AirSync_Init(tAIRSYNC_CBACK *call_back)
{ {
tBT_UUID app_uuid = {LEN_UUID_16,{ATT_SVC_AIRSYNC}}; tBT_UUID app_uuid = {LEN_UUID_16,{ATT_SVC_AIRSYNC}};
if(airsync_cb_env.enabled) if(airsync_cb_env.enabled)
{ {
LOG_ERROR("airsync svc already initaliezd\n"); LOG_ERROR("airsync svc already initaliezd\n");
return GATT_ERROR; return GATT_ERROR;
} }
else else
{ {
memset(&airsync_cb_env,0,sizeof(tAIRSYNC_CB_ENV)); memset(&airsync_cb_env,0,sizeof(tAIRSYNC_CB_ENV));
} }
if(call_back != NULL) if(call_back != NULL)
{ {
airsync_cb_env.airsync_inst.p_cback = call_back; airsync_cb_env.airsync_inst.p_cback = call_back;
} }
/* register the airsync profile to the BTA_GATTS module*/ /* register the airsync profile to the BTA_GATTS module*/
BTA_GATTS_AppRegister(&app_uuid,airsync_profile_cb); BTA_GATTS_AppRegister(&app_uuid,airsync_profile_cb);
airsync_cb_env.enabled = TRUE; airsync_cb_env.enabled = TRUE;
return GATT_SUCCESS; return GATT_SUCCESS;
} }
#endif ///WX_AIRSYNC_CFG #endif ///WX_AIRSYNC_CFG

View file

@ -1,134 +1,134 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "freertos/queue.h" #include "freertos/queue.h"
#include "freertos/semphr.h" #include "freertos/semphr.h"
#include "freertos/xtensa_api.h" #include "freertos/xtensa_api.h"
#include "freertos/portmacro.h" #include "freertos/portmacro.h"
#include "esp_types.h" #include "esp_types.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_task.h" #include "esp_task.h"
#include "esp_intr.h" #include "esp_intr.h"
#include "esp_attr.h" #include "esp_attr.h"
#include "bt.h" #include "bt.h"
#if CONFIG_BT_ENABLED #if CONFIG_BT_ENABLED
/* not for user call, so don't put to include file */ /* not for user call, so don't put to include file */
extern void btdm_osi_funcs_register(void *osi_funcs); extern void btdm_osi_funcs_register(void *osi_funcs);
extern void btdm_controller_init(void); extern void btdm_controller_init(void);
#define BT_DEBUG(...) #define BT_DEBUG(...)
#define BT_API_CALL_CHECK(info, api_call, ret) \ #define BT_API_CALL_CHECK(info, api_call, ret) \
do{\ do{\
esp_err_t __err = (api_call);\ esp_err_t __err = (api_call);\
if ((ret) != __err) {\ if ((ret) != __err) {\
BT_DEBUG("%s %d %s ret=%d\n", __FUNCTION__, __LINE__, (info), __err);\ BT_DEBUG("%s %d %s ret=%d\n", __FUNCTION__, __LINE__, (info), __err);\
return __err;\ return __err;\
}\ }\
} while(0) } while(0)
struct osi_funcs_t { struct osi_funcs_t {
xt_handler (*_set_isr)(int n, xt_handler f, void *arg); xt_handler (*_set_isr)(int n, xt_handler f, void *arg);
void (*_ints_on)(unsigned int mask); void (*_ints_on)(unsigned int mask);
void (*_interrupt_disable)(void); void (*_interrupt_disable)(void);
void (*_interrupt_restore)(void); void (*_interrupt_restore)(void);
void (*_task_yield)(void); void (*_task_yield)(void);
void *(*_semphr_create)(uint32_t max, uint32_t init); void *(*_semphr_create)(uint32_t max, uint32_t init);
int32_t (*_semphr_give_from_isr)(void *semphr, void *hptw); int32_t (*_semphr_give_from_isr)(void *semphr, void *hptw);
int32_t (*_semphr_take)(void *semphr, uint32_t block_time_ms); int32_t (*_semphr_take)(void *semphr, uint32_t block_time_ms);
void *(*_mutex_create)(void); void *(*_mutex_create)(void);
int32_t (*_mutex_lock)(void *mutex); int32_t (*_mutex_lock)(void *mutex);
int32_t (*_mutex_unlock)(void *mutex); int32_t (*_mutex_unlock)(void *mutex);
esp_err_t (* _read_efuse_mac)(uint8_t mac[6]); esp_err_t (* _read_efuse_mac)(uint8_t mac[6]);
}; };
static portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED; static portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED;
static void IRAM_ATTR interrupt_disable(void) static void IRAM_ATTR interrupt_disable(void)
{ {
portENTER_CRITICAL(&global_int_mux); portENTER_CRITICAL(&global_int_mux);
} }
static void IRAM_ATTR interrupt_restore(void) static void IRAM_ATTR interrupt_restore(void)
{ {
portEXIT_CRITICAL(&global_int_mux); portEXIT_CRITICAL(&global_int_mux);
} }
static void * IRAM_ATTR semphr_create_wrapper(uint32_t max, uint32_t init) static void * IRAM_ATTR semphr_create_wrapper(uint32_t max, uint32_t init)
{ {
return (void *)xSemaphoreCreateCounting(max, init); return (void *)xSemaphoreCreateCounting(max, init);
} }
static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw)
{ {
return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);
} }
static int32_t IRAM_ATTR semphr_take_wrapper(void *semphr, uint32_t block_time_ms) static int32_t IRAM_ATTR semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
{ {
return (int32_t)xSemaphoreTake(semphr, block_time_ms / portTICK_RATE_MS); return (int32_t)xSemaphoreTake(semphr, block_time_ms / portTICK_RATE_MS);
} }
static void * IRAM_ATTR mutex_create_wrapper(void) static void * IRAM_ATTR mutex_create_wrapper(void)
{ {
return (void *)xSemaphoreCreateMutex(); return (void *)xSemaphoreCreateMutex();
} }
static int32_t IRAM_ATTR mutex_lock_wrapper(void *mutex) static int32_t IRAM_ATTR mutex_lock_wrapper(void *mutex)
{ {
return (int32_t)xSemaphoreTake(mutex, portMAX_DELAY); return (int32_t)xSemaphoreTake(mutex, portMAX_DELAY);
} }
static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex) static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex)
{ {
return (int32_t)xSemaphoreGive(mutex); return (int32_t)xSemaphoreGive(mutex);
} }
static struct osi_funcs_t osi_funcs = { static struct osi_funcs_t osi_funcs = {
._set_isr = xt_set_interrupt_handler, ._set_isr = xt_set_interrupt_handler,
._ints_on = xt_ints_on, ._ints_on = xt_ints_on,
._interrupt_disable = interrupt_disable, ._interrupt_disable = interrupt_disable,
._interrupt_restore = interrupt_restore, ._interrupt_restore = interrupt_restore,
._task_yield = vPortYield, ._task_yield = vPortYield,
._semphr_create = semphr_create_wrapper, ._semphr_create = semphr_create_wrapper,
._semphr_give_from_isr = semphr_give_from_isr_wrapper, ._semphr_give_from_isr = semphr_give_from_isr_wrapper,
._semphr_take = semphr_take_wrapper, ._semphr_take = semphr_take_wrapper,
._mutex_create = mutex_create_wrapper, ._mutex_create = mutex_create_wrapper,
._mutex_lock = mutex_lock_wrapper, ._mutex_lock = mutex_lock_wrapper,
._mutex_unlock = mutex_unlock_wrapper, ._mutex_unlock = mutex_unlock_wrapper,
._read_efuse_mac = system_efuse_read_mac, ._read_efuse_mac = system_efuse_read_mac,
}; };
static void bt_controller_task(void *pvParam) static void bt_controller_task(void *pvParam)
{ {
btdm_osi_funcs_register(&osi_funcs); btdm_osi_funcs_register(&osi_funcs);
btdm_controller_init(); btdm_controller_init();
} }
void bt_controller_init() void bt_controller_init()
{ {
xTaskCreatePinnedToCore(bt_controller_task, "btController", xTaskCreatePinnedToCore(bt_controller_task, "btController",
ESP_TASK_BT_CONTROLLER_STACK, NULL, ESP_TASK_BT_CONTROLLER_STACK, NULL,
ESP_TASK_BT_CONTROLLER_PRIO, NULL, 0); ESP_TASK_BT_CONTROLLER_PRIO, NULL, 0);
} }
#endif #endif

View file

@ -19,7 +19,7 @@
#include "hash_map.h" #include "hash_map.h"
#include "hash_functions.h" #include "hash_functions.h"
#include "alarm.h" #include "alarm.h"
//#include "app_button.h" #include "app_button.h"
#if (BUT_PROFILE_CFG) #if (BUT_PROFILE_CFG)
#include "button_pro.h" #include "button_pro.h"
#endif ///BUT_PROFILE_CFG #endif ///BUT_PROFILE_CFG