mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-15 23:42:52 +00:00
gap: declare more hci functions as gap functions
This commit is contained in:
parent
313e337b78
commit
15a95bd5aa
@ -14,7 +14,7 @@ functionality is split between and . Please check both.
|
|||||||
|
|
||||||
A remote unconnected Bluetooth device must be set as “discoverable” in
|
A remote unconnected Bluetooth device must be set as “discoverable” in
|
||||||
order to be seen by a device performing the inquiry scan. To become
|
order to be seen by a device performing the inquiry scan. To become
|
||||||
discoverable, an application can call *hci_discoverable_control* with
|
discoverable, an application can call *gap_discoverable_control* with
|
||||||
input parameter 1. If you want to provide a helpful name for your
|
input parameter 1. If you want to provide a helpful name for your
|
||||||
device, the application can set its local name by calling
|
device, the application can set its local name by calling
|
||||||
$gap_set_local_name$. To save energy, you may set the device as
|
$gap_set_local_name$. To save energy, you may set the device as
|
||||||
@ -26,7 +26,7 @@ undiscoverable again, once a connection is established. See Listing
|
|||||||
int main(void){
|
int main(void){
|
||||||
...
|
...
|
||||||
// make discoverable
|
// make discoverable
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
btstack_run_loop_execute();
|
btstack_run_loop_execute();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ undiscoverable again, once a connection is established. See Listing
|
|||||||
switch(state){
|
switch(state){
|
||||||
case W4_CHANNEL_COMPLETE:
|
case W4_CHANNEL_COMPLETE:
|
||||||
// if connection is successful, make device undiscoverable
|
// if connection is successful, make device undiscoverable
|
||||||
hci_discoverable_control(0);
|
gap_discoverable_control(0);
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,8 +220,8 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
compute_signal();
|
compute_signal();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
hci_ssp_set_io_capability(SSP_IO_CAPABILITY_DISPLAY_YES_NO);
|
gap_ssp_set_io_capability(SSP_IO_CAPABILITY_DISPLAY_YES_NO);
|
||||||
gap_set_local_name("BTstack HSP HS");
|
gap_set_local_name("BTstack HSP HS");
|
||||||
|
|
||||||
// register for HCI events
|
// register for HCI events
|
||||||
|
@ -486,7 +486,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
memcpy(&event_addr, &packet[9], sizeof(bd_addr_t));
|
memcpy(&event_addr, &packet[9], sizeof(bd_addr_t));
|
||||||
printf("BNEP connection open succeeded to %s source UUID 0x%04x dest UUID: 0x%04x, max frame size %u\n", bd_addr_to_str(event_addr), uuid_source, uuid_dest, mtu);
|
printf("BNEP connection open succeeded to %s source UUID 0x%04x dest UUID: 0x%04x, max frame size %u\n", bd_addr_to_str(event_addr), uuid_source, uuid_dest, mtu);
|
||||||
/* Create the tap interface */
|
/* Create the tap interface */
|
||||||
hci_local_bd_addr(local_addr);
|
gap_local_bd_addr(local_addr);
|
||||||
tap_fd = tap_alloc(tap_dev_name, local_addr);
|
tap_fd = tap_alloc(tap_dev_name, local_addr);
|
||||||
if (tap_fd < 0) {
|
if (tap_fd < 0) {
|
||||||
printf("Creating BNEP tap device failed: %s\n", strerror(errno));
|
printf("Creating BNEP tap device failed: %s\n", strerror(errno));
|
||||||
|
@ -262,7 +262,7 @@ static void heartbeat_handler(struct btstack_timer_source *ts){
|
|||||||
int btstack_main(void);
|
int btstack_main(void);
|
||||||
int btstack_main(void)
|
int btstack_main(void)
|
||||||
{
|
{
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
|
|
||||||
// register for HCI events
|
// register for HCI events
|
||||||
hci_event_callback_registration.callback = &packet_handler;
|
hci_event_callback_registration.callback = &packet_handler;
|
||||||
@ -280,7 +280,7 @@ int btstack_main(void)
|
|||||||
sdp_register_service(spp_service_buffer);
|
sdp_register_service(spp_service_buffer);
|
||||||
printf("SDP service record size: %u\n", de_get_len(spp_service_buffer));
|
printf("SDP service record size: %u\n", de_get_len(spp_service_buffer));
|
||||||
|
|
||||||
hci_ssp_set_io_capability(SSP_IO_CAPABILITY_DISPLAY_YES_NO);
|
gap_ssp_set_io_capability(SSP_IO_CAPABILITY_DISPLAY_YES_NO);
|
||||||
|
|
||||||
// setup le device db
|
// setup le device db
|
||||||
le_device_db_init();
|
le_device_db_init();
|
||||||
|
@ -263,8 +263,8 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
one_shot_timer_setup();
|
one_shot_timer_setup();
|
||||||
spp_service_setup();
|
spp_service_setup();
|
||||||
|
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
hci_ssp_set_io_capability(SSP_IO_CAPABILITY_DISPLAY_YES_NO);
|
gap_ssp_set_io_capability(SSP_IO_CAPABILITY_DISPLAY_YES_NO);
|
||||||
gap_set_local_name("BTstack SPP Counter");
|
gap_set_local_name("BTstack SPP Counter");
|
||||||
|
|
||||||
// turn on!
|
// turn on!
|
||||||
|
@ -229,7 +229,7 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
|
|
||||||
puts("SPP FlowControl Demo: simulates processing on received data...\n\r");
|
puts("SPP FlowControl Demo: simulates processing on received data...\n\r");
|
||||||
gap_set_local_name("BTstack SPP Flow Control");
|
gap_set_local_name("BTstack SPP Flow Control");
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
|
|
||||||
// turn on!
|
// turn on!
|
||||||
hci_power_control(HCI_POWER_ON);
|
hci_power_control(HCI_POWER_ON);
|
||||||
|
@ -953,7 +953,7 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui
|
|||||||
if (!client) break;
|
if (!client) break;
|
||||||
client->discoverable = packet[3];
|
client->discoverable = packet[3];
|
||||||
// merge state
|
// merge state
|
||||||
hci_discoverable_control(clients_require_discoverable());
|
gap_discoverable_control(clients_require_discoverable());
|
||||||
break;
|
break;
|
||||||
case BTSTACK_SET_BLUETOOTH_ENABLED:
|
case BTSTACK_SET_BLUETOOTH_ENABLED:
|
||||||
log_info("BTSTACK_SET_BLUETOOTH_ENABLED: %u\n", packet[3]);
|
log_info("BTSTACK_SET_BLUETOOTH_ENABLED: %u\n", packet[3]);
|
||||||
@ -1341,7 +1341,7 @@ static int daemon_client_handler(connection_t *connection, uint16_t packet_type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update discoverable mode
|
// update discoverable mode
|
||||||
hci_discoverable_control(clients_require_discoverable());
|
gap_discoverable_control(clients_require_discoverable());
|
||||||
// start power off, if last active client
|
// start power off, if last active client
|
||||||
if (!clients_require_power_on()){
|
if (!clients_require_power_on()){
|
||||||
start_power_off_timer();
|
start_power_off_timer();
|
||||||
@ -2058,7 +2058,7 @@ int main (int argc, char * const * argv){
|
|||||||
|
|
||||||
#ifdef HAVE_PLATFORM_IPHONE_OS
|
#ifdef HAVE_PLATFORM_IPHONE_OS
|
||||||
// iPhone doesn't use SSP yet as there's no UI for it yet and auto accept is not an option
|
// iPhone doesn't use SSP yet as there's no UI for it yet and auto accept is not an option
|
||||||
hci_ssp_set_enable(0);
|
gap_ssp_set_enable(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// register for HCI events
|
// register for HCI events
|
||||||
|
@ -244,7 +244,7 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
// set local name
|
// set local name
|
||||||
gap_set_local_name("BlueMSP-Demo");
|
gap_set_local_name("BlueMSP-Demo");
|
||||||
// make discoverable
|
// make discoverable
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
|
|
||||||
printf("Run...\n\r");
|
printf("Run...\n\r");
|
||||||
// turn on!
|
// turn on!
|
||||||
|
@ -229,7 +229,7 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
// set local name
|
// set local name
|
||||||
gap_set_local_name("BTstack SPP Sensor");
|
gap_set_local_name("BTstack SPP Sensor");
|
||||||
// make discoverable
|
// make discoverable
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
// turn on!
|
// turn on!
|
||||||
hci_power_control(HCI_POWER_ON);
|
hci_power_control(HCI_POWER_ON);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -244,7 +244,7 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
// set local name
|
// set local name
|
||||||
gap_set_local_name("BlueMSP-Demo");
|
gap_set_local_name("BlueMSP-Demo");
|
||||||
// make discoverable
|
// make discoverable
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
|
|
||||||
printf("Run...\n\r");
|
printf("Run...\n\r");
|
||||||
// turn on!
|
// turn on!
|
||||||
|
@ -230,7 +230,7 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
// set local name
|
// set local name
|
||||||
gap_set_local_name("BTstack SPP Sensor");
|
gap_set_local_name("BTstack SPP Sensor");
|
||||||
// make discoverable
|
// make discoverable
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
|
|
||||||
// turn on!
|
// turn on!
|
||||||
hci_power_control(HCI_POWER_ON);
|
hci_power_control(HCI_POWER_ON);
|
||||||
|
@ -876,13 +876,13 @@ static void sm_init_setup(sm_connection_t * sm_conn){
|
|||||||
if (sm_conn->sm_role){
|
if (sm_conn->sm_role){
|
||||||
// slave
|
// slave
|
||||||
local_packet = &setup->sm_s_pres;
|
local_packet = &setup->sm_s_pres;
|
||||||
hci_le_advertisement_address(&setup->sm_s_addr_type, setup->sm_s_address);
|
gap_advertisements_get_address(&setup->sm_s_addr_type, setup->sm_s_address);
|
||||||
setup->sm_m_addr_type = sm_conn->sm_peer_addr_type;
|
setup->sm_m_addr_type = sm_conn->sm_peer_addr_type;
|
||||||
memcpy(setup->sm_m_address, sm_conn->sm_peer_address, 6);
|
memcpy(setup->sm_m_address, sm_conn->sm_peer_address, 6);
|
||||||
} else {
|
} else {
|
||||||
// master
|
// master
|
||||||
local_packet = &setup->sm_m_preq;
|
local_packet = &setup->sm_m_preq;
|
||||||
hci_le_advertisement_address(&setup->sm_m_addr_type, setup->sm_m_address);
|
gap_advertisements_get_address(&setup->sm_m_addr_type, setup->sm_m_address);
|
||||||
setup->sm_s_addr_type = sm_conn->sm_peer_addr_type;
|
setup->sm_s_addr_type = sm_conn->sm_peer_addr_type;
|
||||||
memcpy(setup->sm_s_address, sm_conn->sm_peer_address, 6);
|
memcpy(setup->sm_s_address, sm_conn->sm_peer_address, 6);
|
||||||
|
|
||||||
@ -1532,7 +1532,7 @@ static void sm_run(void){
|
|||||||
bd_addr_t local_address;
|
bd_addr_t local_address;
|
||||||
uint8_t buffer[8];
|
uint8_t buffer[8];
|
||||||
buffer[0] = SM_CODE_IDENTITY_ADDRESS_INFORMATION;
|
buffer[0] = SM_CODE_IDENTITY_ADDRESS_INFORMATION;
|
||||||
hci_le_advertisement_address(&buffer[1], local_address);
|
gap_advertisements_get_address(&buffer[1], local_address);
|
||||||
reverse_bd_addr(local_address, &buffer[2]);
|
reverse_bd_addr(local_address, &buffer[2]);
|
||||||
l2cap_send_connectionless(connection->sm_handle, L2CAP_CID_SECURITY_MANAGER_PROTOCOL, (uint8_t*) buffer, sizeof(buffer));
|
l2cap_send_connectionless(connection->sm_handle, L2CAP_CID_SECURITY_MANAGER_PROTOCOL, (uint8_t*) buffer, sizeof(buffer));
|
||||||
sm_timeout_reset(connection);
|
sm_timeout_reset(connection);
|
||||||
|
@ -685,7 +685,7 @@ static bnep_channel_t * bnep_channel_create_for_addr(bd_addr_t addr)
|
|||||||
channel->state = BNEP_CHANNEL_STATE_CLOSED;
|
channel->state = BNEP_CHANNEL_STATE_CLOSED;
|
||||||
channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(l2cap_max_mtu());
|
channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(l2cap_max_mtu());
|
||||||
bd_addr_copy(channel->remote_addr, addr);
|
bd_addr_copy(channel->remote_addr, addr);
|
||||||
hci_local_bd_addr(channel->local_addr);
|
gap_local_bd_addr(channel->local_addr);
|
||||||
|
|
||||||
channel->net_filter_count = 0;
|
channel->net_filter_count = 0;
|
||||||
channel->multicast_filter_count = 0;
|
channel->multicast_filter_count = 0;
|
||||||
|
53
src/gap.h
53
src/gap.h
@ -140,6 +140,28 @@ void gap_set_bondable_mode(int enabled);
|
|||||||
*/
|
*/
|
||||||
int gap_get_bondable_mode(void);
|
int gap_get_bondable_mode(void);
|
||||||
|
|
||||||
|
/* Configure Secure Simple Pairing */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable will enable SSP during init.
|
||||||
|
*/
|
||||||
|
void gap_ssp_set_enable(int enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set IO Capability. BTstack will return capability to SSP requests
|
||||||
|
*/
|
||||||
|
void gap_ssp_set_io_capability(int ssp_io_capability);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set Authentication Requirements using during SSP
|
||||||
|
*/
|
||||||
|
void gap_ssp_set_authentication_requirement(int authentication_requirement);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief If set, BTstack will confirm a numeric comparison and enter '000000' if requested.
|
||||||
|
*/
|
||||||
|
void gap_ssp_set_auto_accept(int auto_accept);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Start dedicated bonding with device. Disconnect after bonding.
|
* @brief Start dedicated bonding with device. Disconnect after bonding.
|
||||||
* @param device
|
* @param device
|
||||||
@ -292,6 +314,37 @@ int gap_auto_connection_stop(bd_addr_type_t address_typ, bd_addr_t address);
|
|||||||
*/
|
*/
|
||||||
void gap_auto_connection_stop_all(void);
|
void gap_auto_connection_stop_all(void);
|
||||||
|
|
||||||
|
// Classic
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Override page scan mode. Page scan mode enabled by l2cap when services are registered
|
||||||
|
* @note Might be used to reduce power consumption while Bluetooth module stays powered but no (new)
|
||||||
|
* connections are expected
|
||||||
|
*/
|
||||||
|
void gap_connectable_control(uint8_t enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Allows to control if device is discoverable. OFF by default.
|
||||||
|
*/
|
||||||
|
void gap_discoverable_control(uint8_t enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets local address.
|
||||||
|
*/
|
||||||
|
void gap_local_bd_addr(bd_addr_t address_buffer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deletes link key for remote device with baseband address.
|
||||||
|
*/
|
||||||
|
void gap_drop_link_key_for_bd_addr(bd_addr_t addr);
|
||||||
|
|
||||||
|
// LE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get addr type and address used in advertisement packets.
|
||||||
|
*/
|
||||||
|
void gap_advertisements_get_address(uint8_t * addr_type, bd_addr_t addr);
|
||||||
|
|
||||||
|
|
||||||
/* API_END*/
|
/* API_END*/
|
||||||
|
|
||||||
|
30
src/hci.c
30
src/hci.c
@ -275,7 +275,7 @@ int hci_authentication_active_for_handle(hci_con_handle_t handle){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hci_drop_link_key_for_bd_addr(bd_addr_t addr){
|
void gap_drop_link_key_for_bd_addr(bd_addr_t addr){
|
||||||
if (hci_stack->link_key_db) {
|
if (hci_stack->link_key_db) {
|
||||||
hci_stack->link_key_db->delete_link_key(addr);
|
hci_stack->link_key_db->delete_link_key(addr);
|
||||||
}
|
}
|
||||||
@ -795,7 +795,7 @@ int hci_non_flushable_packet_boundary_flag_supported(void){
|
|||||||
return (hci_stack->local_supported_features[6] & (1 << 6)) != 0;
|
return (hci_stack->local_supported_features[6] & (1 << 6)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hci_ssp_supported(void){
|
static int gap_ssp_supported(void){
|
||||||
// No. 51, byte 6, bit 3
|
// No. 51, byte 6, bit 3
|
||||||
return (hci_stack->local_supported_features[6] & (1 << 3)) != 0;
|
return (hci_stack->local_supported_features[6] & (1 << 3)) != 0;
|
||||||
}
|
}
|
||||||
@ -815,7 +815,7 @@ static int hci_le_supported(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get addr type and address used in advertisement packets
|
// get addr type and address used in advertisement packets
|
||||||
void hci_le_advertisement_address(uint8_t * addr_type, bd_addr_t addr){
|
void gap_advertisements_get_address(uint8_t * addr_type, bd_addr_t addr){
|
||||||
*addr_type = hci_stack->adv_addr_type;
|
*addr_type = hci_stack->adv_addr_type;
|
||||||
if (hci_stack->adv_addr_type){
|
if (hci_stack->adv_addr_type){
|
||||||
memcpy(addr, hci_stack->adv_address, 6);
|
memcpy(addr, hci_stack->adv_address, 6);
|
||||||
@ -1266,7 +1266,7 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hci_ssp_supported()){
|
if (!gap_ssp_supported()){
|
||||||
hci_stack->substate = HCI_INIT_WRITE_PAGE_TIMEOUT;
|
hci_stack->substate = HCI_INIT_WRITE_PAGE_TIMEOUT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1513,7 +1513,7 @@ static void event_handler(uint8_t *packet, int size){
|
|||||||
|
|
||||||
// if authentication error, also delete link key
|
// if authentication error, also delete link key
|
||||||
if (packet[2] == 0x05) {
|
if (packet[2] == 0x05) {
|
||||||
hci_drop_link_key_for_bd_addr(addr);
|
gap_drop_link_key_for_bd_addr(addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2250,7 +2250,7 @@ static void hci_update_scan_enable(void){
|
|||||||
hci_run();
|
hci_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hci_discoverable_control(uint8_t enable){
|
void gap_discoverable_control(uint8_t enable){
|
||||||
if (enable) enable = 1; // normalize argument
|
if (enable) enable = 1; // normalize argument
|
||||||
|
|
||||||
if (hci_stack->discoverable == enable){
|
if (hci_stack->discoverable == enable){
|
||||||
@ -2262,7 +2262,7 @@ void hci_discoverable_control(uint8_t enable){
|
|||||||
hci_update_scan_enable();
|
hci_update_scan_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hci_connectable_control(uint8_t enable){
|
void gap_connectable_control(uint8_t enable){
|
||||||
if (enable) enable = 1; // normalize argument
|
if (enable) enable = 1; // normalize argument
|
||||||
|
|
||||||
// don't emit event
|
// don't emit event
|
||||||
@ -2272,7 +2272,7 @@ void hci_connectable_control(uint8_t enable){
|
|||||||
hci_update_scan_enable();
|
hci_update_scan_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hci_local_bd_addr(bd_addr_t address_buffer){
|
void gap_local_bd_addr(bd_addr_t address_buffer){
|
||||||
memcpy(address_buffer, hci_stack->local_bd_addr, 6);
|
memcpy(address_buffer, hci_stack->local_bd_addr, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2857,24 +2857,24 @@ void hci_disconnect_security_block(hci_con_handle_t con_handle){
|
|||||||
// Configure Secure Simple Pairing
|
// Configure Secure Simple Pairing
|
||||||
|
|
||||||
// enable will enable SSP during init
|
// enable will enable SSP during init
|
||||||
void hci_ssp_set_enable(int enable){
|
void gap_ssp_set_enable(int enable){
|
||||||
hci_stack->ssp_enable = enable;
|
hci_stack->ssp_enable = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hci_local_ssp_activated(void){
|
static int hci_local_ssp_activated(void){
|
||||||
return hci_ssp_supported() && hci_stack->ssp_enable;
|
return gap_ssp_supported() && hci_stack->ssp_enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if set, BTstack will respond to io capability request using authentication requirement
|
// if set, BTstack will respond to io capability request using authentication requirement
|
||||||
void hci_ssp_set_io_capability(int io_capability){
|
void gap_ssp_set_io_capability(int io_capability){
|
||||||
hci_stack->ssp_io_capability = io_capability;
|
hci_stack->ssp_io_capability = io_capability;
|
||||||
}
|
}
|
||||||
void hci_ssp_set_authentication_requirement(int authentication_requirement){
|
void gap_ssp_set_authentication_requirement(int authentication_requirement){
|
||||||
hci_stack->ssp_authentication_requirement = authentication_requirement;
|
hci_stack->ssp_authentication_requirement = authentication_requirement;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if set, BTstack will confirm a numberic comparion and enter '000000' if requested
|
// if set, BTstack will confirm a numberic comparion and enter '000000' if requested
|
||||||
void hci_ssp_set_auto_accept(int auto_accept){
|
void gap_ssp_set_auto_accept(int auto_accept){
|
||||||
hci_stack->ssp_auto_accept = auto_accept;
|
hci_stack->ssp_auto_accept = auto_accept;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3059,7 +3059,7 @@ int hci_remote_ssp_supported(hci_con_handle_t con_handle){
|
|||||||
return (connection->bonding_flags & BONDING_REMOTE_SUPPORTS_SSP) ? 1 : 0;
|
return (connection->bonding_flags & BONDING_REMOTE_SUPPORTS_SSP) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hci_ssp_supported_on_both_sides(hci_con_handle_t handle){
|
int gap_ssp_supported_on_both_sides(hci_con_handle_t handle){
|
||||||
return hci_local_ssp_activated() && hci_remote_ssp_supported(handle);
|
return hci_local_ssp_activated() && hci_remote_ssp_supported(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3172,7 +3172,7 @@ int gap_dedicated_bonding(bd_addr_t device, int mitm_protection_required){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete linkn key
|
// delete linkn key
|
||||||
hci_drop_link_key_for_bd_addr(device);
|
gap_drop_link_key_for_bd_addr(device);
|
||||||
|
|
||||||
// configure LEVEL_2/3, dedicated bonding
|
// configure LEVEL_2/3, dedicated bonding
|
||||||
connection->state = SEND_CREATE_CONNECTION;
|
connection->state = SEND_CREATE_CONNECTION;
|
||||||
|
180
src/hci.h
180
src/hci.h
@ -656,42 +656,12 @@ typedef struct {
|
|||||||
|
|
||||||
} hci_stack_t;
|
} hci_stack_t;
|
||||||
|
|
||||||
|
|
||||||
/* API_START */
|
/* API_START */
|
||||||
|
|
||||||
|
|
||||||
/**
|
// HCI init and configuration
|
||||||
* @brief Check hci packet buffer and if SCO packet can be sent to controller
|
|
||||||
*/
|
|
||||||
int hci_can_send_sco_packet_now(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check if SCO packet can be sent to controller
|
|
||||||
*/
|
|
||||||
int hci_can_send_prepared_sco_packet_now(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Send SCO packet prepared in hci packet buffer
|
|
||||||
*/
|
|
||||||
int hci_send_sco_packet_buffer(int size);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Override page scan mode
|
|
||||||
*/
|
|
||||||
void hci_connectable_control(uint8_t enable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Shutdown HCI
|
|
||||||
*/
|
|
||||||
void hci_close(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check if CMD packet can be sent to controller
|
|
||||||
*/
|
|
||||||
int hci_can_send_command_packet_now(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Gets local address.
|
|
||||||
*/
|
|
||||||
void hci_local_bd_addr(bd_addr_t address_buffer);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set up HCI. Needs to be called before any other function.
|
* @brief Set up HCI. Needs to be called before any other function.
|
||||||
@ -719,10 +689,40 @@ void hci_set_link_key_db(btstack_link_key_db_t const * link_key_db);
|
|||||||
void hci_set_class_of_device(uint32_t class_of_device);
|
void hci_set_class_of_device(uint32_t class_of_device);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set Public BD ADDR - passed on to Bluetooth chipset if supported in bt_control_h
|
* @brief Set callback for Bluetooth Hardware Error
|
||||||
|
*/
|
||||||
|
void hci_set_hardware_error_callback(void (*fn)(void));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set Public BD ADDR - passed on to Bluetooth chipset during init if supported in bt_control_h
|
||||||
*/
|
*/
|
||||||
void hci_set_bd_addr(bd_addr_t addr);
|
void hci_set_bd_addr(bd_addr_t addr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure Voice Setting for use with SCO data in HSP/HFP
|
||||||
|
*/
|
||||||
|
void hci_set_sco_voice_setting(uint16_t voice_setting);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get SCO Voice Setting
|
||||||
|
* @return current voice setting
|
||||||
|
*/
|
||||||
|
uint16_t hci_get_sco_voice_setting(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Requests the change of BTstack power mode.
|
||||||
|
*/
|
||||||
|
int hci_power_control(HCI_POWER_MODE mode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Shutdown HCI
|
||||||
|
*/
|
||||||
|
void hci_close(void);
|
||||||
|
|
||||||
|
|
||||||
|
// Callback registration
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Add event packet handler.
|
* @brief Add event packet handler.
|
||||||
*/
|
*/
|
||||||
@ -738,68 +738,21 @@ void hci_register_acl_packet_handler(void (*handler)(uint8_t packet_type, uint8_
|
|||||||
*/
|
*/
|
||||||
void hci_register_sco_packet_handler(void (*handler)(uint8_t packet_type, uint8_t *packet, uint16_t size));
|
void hci_register_sco_packet_handler(void (*handler)(uint8_t packet_type, uint8_t *packet, uint16_t size));
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Requests the change of BTstack power mode.
|
|
||||||
*/
|
|
||||||
int hci_power_control(HCI_POWER_MODE mode);
|
|
||||||
|
|
||||||
/**
|
// Sending HCI Commands
|
||||||
* @brief Allows to control if device is discoverable. OFF by default.
|
|
||||||
|
/**
|
||||||
|
* @brief Check if CMD packet can be sent to controller
|
||||||
*/
|
*/
|
||||||
void hci_discoverable_control(uint8_t enable);
|
int hci_can_send_command_packet_now(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Creates and sends HCI command packets based on a template and a list of parameters. Will return error if outgoing data buffer is occupied.
|
* @brief Creates and sends HCI command packets based on a template and a list of parameters. Will return error if outgoing data buffer is occupied.
|
||||||
*/
|
*/
|
||||||
int hci_send_cmd(const hci_cmd_t *cmd, ...);
|
int hci_send_cmd(const hci_cmd_t *cmd, ...);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Deletes link key for remote device with baseband address.
|
|
||||||
*/
|
|
||||||
void hci_drop_link_key_for_bd_addr(bd_addr_t addr);
|
|
||||||
|
|
||||||
/* Configure Secure Simple Pairing */
|
// Sending SCO Packets
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable will enable SSP during init.
|
|
||||||
*/
|
|
||||||
void hci_ssp_set_enable(int enable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set IO Capability. BTstack will return capability to SSP requests
|
|
||||||
*/
|
|
||||||
void hci_ssp_set_io_capability(int ssp_io_capability);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set Authentication Requirements using during SSP
|
|
||||||
*/
|
|
||||||
void hci_ssp_set_authentication_requirement(int authentication_requirement);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief If set, BTstack will confirm a numeric comparison and enter '000000' if requested.
|
|
||||||
*/
|
|
||||||
void hci_ssp_set_auto_accept(int auto_accept);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get addr type and address used in advertisement packets.
|
|
||||||
*/
|
|
||||||
void hci_le_advertisement_address(uint8_t * addr_type, bd_addr_t addr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set callback for Bluetooth Hardware Error
|
|
||||||
*/
|
|
||||||
void hci_set_hardware_error_callback(void (*fn)(void));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configure Voice Setting for use with SCO data in HSP/HFP
|
|
||||||
*/
|
|
||||||
void hci_set_sco_voice_setting(uint16_t voice_setting);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get SCO Voice Setting
|
|
||||||
* @return current voice setting
|
|
||||||
*/
|
|
||||||
uint16_t hci_get_sco_voice_setting(void);
|
|
||||||
|
|
||||||
/** @brief Get SCO packet length for current SCO Voice setting
|
/** @brief Get SCO packet length for current SCO Voice setting
|
||||||
* @note Using SCO packets of the exact length is required for USB transfer
|
* @note Using SCO packets of the exact length is required for USB transfer
|
||||||
@ -807,6 +760,25 @@ uint16_t hci_get_sco_voice_setting(void);
|
|||||||
*/
|
*/
|
||||||
int hci_get_sco_packet_length(void);
|
int hci_get_sco_packet_length(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check hci packet buffer and if SCO packet can be sent to controller
|
||||||
|
*/
|
||||||
|
int hci_can_send_sco_packet_now(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if SCO packet can be sent to controller
|
||||||
|
*/
|
||||||
|
int hci_can_send_prepared_sco_packet_now(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Send SCO packet prepared in hci packet buffer
|
||||||
|
*/
|
||||||
|
int hci_send_sco_packet_buffer(int size);
|
||||||
|
|
||||||
|
|
||||||
|
// Outgoing packet buffer, also used for SCO packets
|
||||||
|
// see hci_can_send_prepared_sco_packet_now amn hci_send_sco_packet_buffer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reserves outgoing packet buffer.
|
* Reserves outgoing packet buffer.
|
||||||
* @return 1 on success
|
* @return 1 on success
|
||||||
@ -827,11 +799,28 @@ void hci_release_packet_buffer(void);
|
|||||||
|
|
||||||
/* API_END */
|
/* API_END */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get connection iterator. Only used by l2cap.c and sm.c
|
* Get connection iterator. Only used by l2cap.c and sm.c
|
||||||
*/
|
*/
|
||||||
void hci_connections_get_iterator(btstack_linked_list_iterator_t *it);
|
void hci_connections_get_iterator(btstack_linked_list_iterator_t *it);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get internal hci_connection_t for given handle. Used by L2CAP, SM, daemon
|
||||||
|
*/
|
||||||
|
hci_connection_t * hci_connection_for_handle(hci_con_handle_t con_handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get internal hci_connection_t for given Bluetooth addres. Called by L2CAP
|
||||||
|
*/
|
||||||
|
hci_connection_t * hci_connection_for_bd_addr_and_type(bd_addr_t addr, bd_addr_type_t addr_type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if outgoing packet buffer is reserved. Used for internal checks in l2cap.c
|
||||||
|
*/
|
||||||
|
int hci_is_packet_buffer_reserved(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check hci packet buffer is free and a classic acl packet can be sent to controller
|
* Check hci packet buffer is free and a classic acl packet can be sent to controller
|
||||||
*/
|
*/
|
||||||
@ -857,21 +846,6 @@ int hci_can_send_prepared_acl_packet_now(hci_con_handle_t con_handle);
|
|||||||
*/
|
*/
|
||||||
int hci_send_acl_packet_buffer(int size);
|
int hci_send_acl_packet_buffer(int size);
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if outgoing packet buffer is reserved. Used for internal checks in l2cap.c
|
|
||||||
*/
|
|
||||||
int hci_is_packet_buffer_reserved(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get internal hci_connection_t for given handle. Used by L2CAP, SM, daemon
|
|
||||||
*/
|
|
||||||
hci_connection_t * hci_connection_for_handle(hci_con_handle_t con_handle);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get internal hci_connection_t for given Bluetooth addres. Called by L2CAP
|
|
||||||
*/
|
|
||||||
hci_connection_t * hci_connection_for_bd_addr_and_type(bd_addr_t addr, bd_addr_type_t addr_type);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if authentication is active. It delays automatic disconnect while no L2CAP connection
|
* Check if authentication is active. It delays automatic disconnect while no L2CAP connection
|
||||||
* Called by l2cap.
|
* Called by l2cap.
|
||||||
@ -896,7 +870,7 @@ int hci_non_flushable_packet_boundary_flag_supported(void);
|
|||||||
/**
|
/**
|
||||||
* Check if SSP is supported on both sides. Called by L2CAP
|
* Check if SSP is supported on both sides. Called by L2CAP
|
||||||
*/
|
*/
|
||||||
int hci_ssp_supported_on_both_sides(hci_con_handle_t handle);
|
int gap_ssp_supported_on_both_sides(hci_con_handle_t handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconn because of security block. Called by L2CAP
|
* Disconn because of security block. Called by L2CAP
|
||||||
|
10
src/l2cap.c
10
src/l2cap.c
@ -155,7 +155,7 @@ void l2cap_init(void){
|
|||||||
|
|
||||||
hci_register_acl_packet_handler(&l2cap_acl_handler);
|
hci_register_acl_packet_handler(&l2cap_acl_handler);
|
||||||
|
|
||||||
hci_connectable_control(0); // no services yet
|
gap_connectable_control(0); // no services yet
|
||||||
}
|
}
|
||||||
|
|
||||||
void l2cap_register_packet_handler(void (*handler)(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)){
|
void l2cap_register_packet_handler(void (*handler)(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)){
|
||||||
@ -763,7 +763,7 @@ static void l2cap_handle_remote_supported_features_received(l2cap_channel_t * ch
|
|||||||
|
|
||||||
// we have been waiting for remote supported features, if both support SSP,
|
// we have been waiting for remote supported features, if both support SSP,
|
||||||
log_info("l2cap received remote supported features, sec_level_0_allowed for psm %u = %u", channel->psm, l2cap_security_level_0_allowed_for_PSM(channel->psm));
|
log_info("l2cap received remote supported features, sec_level_0_allowed for psm %u = %u", channel->psm, l2cap_security_level_0_allowed_for_PSM(channel->psm));
|
||||||
if (hci_ssp_supported_on_both_sides(channel->handle) && !l2cap_security_level_0_allowed_for_PSM(channel->psm)){
|
if (gap_ssp_supported_on_both_sides(channel->handle) && !l2cap_security_level_0_allowed_for_PSM(channel->psm)){
|
||||||
// request security level 2
|
// request security level 2
|
||||||
channel->state = L2CAP_STATE_WAIT_OUTGOING_SECURITY_LEVEL_UPDATE;
|
channel->state = L2CAP_STATE_WAIT_OUTGOING_SECURITY_LEVEL_UPDATE;
|
||||||
gap_request_security_level(channel->handle, LEVEL_2);
|
gap_request_security_level(channel->handle, LEVEL_2);
|
||||||
@ -1243,7 +1243,7 @@ static void l2cap_signaling_handler_channel(l2cap_channel_t *channel, uint8_t *c
|
|||||||
|
|
||||||
// drop link key if security block
|
// drop link key if security block
|
||||||
if (L2CAP_CONNECTION_RESPONSE_RESULT_SUCCESSFUL + result == L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_SECURITY){
|
if (L2CAP_CONNECTION_RESPONSE_RESULT_SUCCESSFUL + result == L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_SECURITY){
|
||||||
hci_drop_link_key_for_bd_addr(channel->address);
|
gap_drop_link_key_for_bd_addr(channel->address);
|
||||||
}
|
}
|
||||||
|
|
||||||
// discard channel
|
// discard channel
|
||||||
@ -1556,7 +1556,7 @@ uint8_t l2cap_register_service(btstack_packet_handler_t service_packet_handler,
|
|||||||
btstack_linked_list_add(&l2cap_services, (btstack_linked_item_t *) service);
|
btstack_linked_list_add(&l2cap_services, (btstack_linked_item_t *) service);
|
||||||
|
|
||||||
// enable page scan
|
// enable page scan
|
||||||
hci_connectable_control(1);
|
gap_connectable_control(1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1572,7 +1572,7 @@ void l2cap_unregister_service(uint16_t psm){
|
|||||||
|
|
||||||
// disable page scan when no services registered
|
// disable page scan when no services registered
|
||||||
if (!btstack_linked_list_empty(&l2cap_services)) return;
|
if (!btstack_linked_list_empty(&l2cap_services)) return;
|
||||||
hci_connectable_control(0);
|
gap_connectable_control(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bluetooth 4.0 - allows to register handler for Attribute Protocol and Security Manager Protocol
|
// Bluetooth 4.0 - allows to register handler for Attribute Protocol and Security Manager Protocol
|
||||||
|
@ -675,7 +675,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
|
|||||||
break;
|
break;
|
||||||
case CENTRAL_W4_RECONNECTION_ADDRESS_QUERY_COMPLETE:
|
case CENTRAL_W4_RECONNECTION_ADDRESS_QUERY_COMPLETE:
|
||||||
central_state = CENTRAL_IDLE;
|
central_state = CENTRAL_IDLE;
|
||||||
hci_le_advertisement_address(&address_type, our_private_address);
|
gap_advertisements_get_address(&address_type, our_private_address);
|
||||||
printf("Our private address: %s\n", bd_addr_to_str(our_private_address));
|
printf("Our private address: %s\n", bd_addr_to_str(our_private_address));
|
||||||
reverse_bd_addr(our_private_address, flipped_address);
|
reverse_bd_addr(our_private_address, flipped_address);
|
||||||
gatt_client_write_value_of_characteristic(handle_gatt_client_event, handle, gap_reconnection_address_characteristic.value_handle, 6, flipped_address);
|
gatt_client_write_value_of_characteristic(handle_gatt_client_event, handle, gap_reconnection_address_characteristic.value_handle, 6, flipped_address);
|
||||||
@ -864,7 +864,7 @@ static void print_screen(void){
|
|||||||
static void show_usage(void){
|
static void show_usage(void){
|
||||||
uint8_t iut_address_type;
|
uint8_t iut_address_type;
|
||||||
bd_addr_t iut_address;
|
bd_addr_t iut_address;
|
||||||
hci_le_advertisement_address(&iut_address_type, iut_address);
|
gap_advertisements_get_address(&iut_address_type, iut_address);
|
||||||
|
|
||||||
reset_screen();
|
reset_screen();
|
||||||
|
|
||||||
@ -1375,13 +1375,13 @@ static void ui_process_command(char buffer){
|
|||||||
case 'c':
|
case 'c':
|
||||||
gap_connectable = 0;
|
gap_connectable = 0;
|
||||||
update_advertisment_params();
|
update_advertisment_params();
|
||||||
hci_connectable_control(gap_connectable);
|
gap_connectable_control(gap_connectable);
|
||||||
show_usage();
|
show_usage();
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
gap_connectable = 1;
|
gap_connectable = 1;
|
||||||
update_advertisment_params();
|
update_advertisment_params();
|
||||||
hci_connectable_control(gap_connectable);
|
gap_connectable_control(gap_connectable);
|
||||||
show_usage();
|
show_usage();
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
@ -1712,8 +1712,8 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
current_pts_address_type = public_pts_address_type;
|
current_pts_address_type = public_pts_address_type;
|
||||||
|
|
||||||
// classic discoverable / connectable
|
// classic discoverable / connectable
|
||||||
hci_connectable_control(0);
|
gap_connectable_control(0);
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
|
|
||||||
// allow foor terminal input
|
// allow foor terminal input
|
||||||
btstack_stdin_setup(stdin_process);
|
btstack_stdin_setup(stdin_process);
|
||||||
|
@ -836,7 +836,7 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
|
|
||||||
/* Turn on the device */
|
/* Turn on the device */
|
||||||
hci_power_control(HCI_POWER_ON);
|
hci_power_control(HCI_POWER_ON);
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
|
|
||||||
btstack_stdin_setup(stdin_process);
|
btstack_stdin_setup(stdin_process);
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ static void update_auth_req(void){
|
|||||||
gap_auth_req |= 4; // General bonding
|
gap_auth_req |= 4; // General bonding
|
||||||
}
|
}
|
||||||
printf("Authentication Requirements: %u\n", gap_auth_req);
|
printf("Authentication Requirements: %u\n", gap_auth_req);
|
||||||
hci_ssp_set_authentication_requirement(gap_auth_req);
|
gap_ssp_set_authentication_requirement(gap_auth_req);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_found_service(const char * name, uint8_t port){
|
static void handle_found_service(const char * name, uint8_t port){
|
||||||
@ -504,22 +504,22 @@ static int stdin_process(struct btstack_data_source *ds){
|
|||||||
switch (buffer){
|
switch (buffer){
|
||||||
case 'c':
|
case 'c':
|
||||||
gap_connectable = 0;
|
gap_connectable = 0;
|
||||||
hci_connectable_control(0);
|
gap_connectable_control(0);
|
||||||
show_usage();
|
show_usage();
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
gap_connectable = 1;
|
gap_connectable = 1;
|
||||||
hci_connectable_control(1);
|
gap_connectable_control(1);
|
||||||
show_usage();
|
show_usage();
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
gap_discoverable = 0;
|
gap_discoverable = 0;
|
||||||
hci_discoverable_control(0);
|
gap_discoverable_control(0);
|
||||||
show_usage();
|
show_usage();
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
gap_discoverable = 1;
|
gap_discoverable = 1;
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
show_usage();
|
show_usage();
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
@ -556,22 +556,22 @@ static int stdin_process(struct btstack_data_source *ds){
|
|||||||
|
|
||||||
case 'e':
|
case 'e':
|
||||||
gap_io_capabilities = "IO_CAPABILITY_DISPLAY_ONLY";
|
gap_io_capabilities = "IO_CAPABILITY_DISPLAY_ONLY";
|
||||||
hci_ssp_set_io_capability(IO_CAPABILITY_DISPLAY_ONLY);
|
gap_ssp_set_io_capability(IO_CAPABILITY_DISPLAY_ONLY);
|
||||||
show_usage();
|
show_usage();
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
gap_io_capabilities = "IO_CAPABILITY_DISPLAY_YES_NO";
|
gap_io_capabilities = "IO_CAPABILITY_DISPLAY_YES_NO";
|
||||||
hci_ssp_set_io_capability(IO_CAPABILITY_DISPLAY_YES_NO);
|
gap_ssp_set_io_capability(IO_CAPABILITY_DISPLAY_YES_NO);
|
||||||
show_usage();
|
show_usage();
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
gap_io_capabilities = "IO_CAPABILITY_NO_INPUT_NO_OUTPUT";
|
gap_io_capabilities = "IO_CAPABILITY_NO_INPUT_NO_OUTPUT";
|
||||||
hci_ssp_set_io_capability(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
|
gap_ssp_set_io_capability(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
|
||||||
show_usage();
|
show_usage();
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
gap_io_capabilities = "IO_CAPABILITY_KEYBOARD_ONLY";
|
gap_io_capabilities = "IO_CAPABILITY_KEYBOARD_ONLY";
|
||||||
hci_ssp_set_io_capability(IO_CAPABILITY_KEYBOARD_ONLY);
|
gap_ssp_set_io_capability(IO_CAPABILITY_KEYBOARD_ONLY);
|
||||||
show_usage();
|
show_usage();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -670,7 +670,7 @@ static int stdin_process(struct btstack_data_source *ds){
|
|||||||
|
|
||||||
case '=':
|
case '=':
|
||||||
printf("Deleting Link Key for %s\n", bd_addr_to_str(remote));
|
printf("Deleting Link Key for %s\n", bd_addr_to_str(remote));
|
||||||
hci_drop_link_key_for_bd_addr(remote);
|
gap_drop_link_key_for_bd_addr(remote);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'U':
|
case 'U':
|
||||||
@ -762,10 +762,10 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
|
|
||||||
hci_set_class_of_device(0x220404);
|
hci_set_class_of_device(0x220404);
|
||||||
hci_disable_l2cap_timeout_check();
|
hci_disable_l2cap_timeout_check();
|
||||||
hci_ssp_set_io_capability(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
|
gap_ssp_set_io_capability(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
|
||||||
gap_io_capabilities = "IO_CAPABILITY_NO_INPUT_NO_OUTPUT";
|
gap_io_capabilities = "IO_CAPABILITY_NO_INPUT_NO_OUTPUT";
|
||||||
hci_ssp_set_authentication_requirement(0);
|
gap_ssp_set_authentication_requirement(0);
|
||||||
hci_ssp_set_auto_accept(0);
|
gap_ssp_set_auto_accept(0);
|
||||||
update_auth_req();
|
update_auth_req();
|
||||||
|
|
||||||
// register for HCI events
|
// register for HCI events
|
||||||
@ -791,8 +791,8 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
printf("Dummy service record size: %u\n\r", de_get_len((uint8_t*)dummy_service_buffer));
|
printf("Dummy service record size: %u\n\r", de_get_len((uint8_t*)dummy_service_buffer));
|
||||||
sdp_register_service((uint8_t*)dummy_service_buffer);
|
sdp_register_service((uint8_t*)dummy_service_buffer);
|
||||||
|
|
||||||
hci_discoverable_control(0);
|
gap_discoverable_control(0);
|
||||||
hci_connectable_control(0);
|
gap_connectable_control(0);
|
||||||
|
|
||||||
// turn on!
|
// turn on!
|
||||||
hci_power_control(HCI_POWER_ON);
|
hci_power_control(HCI_POWER_ON);
|
||||||
|
@ -174,7 +174,7 @@ static void sco_packet_handler(uint8_t packet_type, uint8_t * packet, uint16_t s
|
|||||||
static void show_usage(void){
|
static void show_usage(void){
|
||||||
uint8_t iut_address_type;
|
uint8_t iut_address_type;
|
||||||
bd_addr_t iut_address;
|
bd_addr_t iut_address;
|
||||||
hci_le_advertisement_address(&iut_address_type, iut_address);
|
gap_advertisements_get_address(&iut_address_type, iut_address);
|
||||||
|
|
||||||
printf("\n--- Bluetooth HSP Headset Test Console %s ---\n", bd_addr_to_str(iut_address));
|
printf("\n--- Bluetooth HSP Headset Test Console %s ---\n", bd_addr_to_str(iut_address));
|
||||||
printf("---\n");
|
printf("---\n");
|
||||||
@ -324,7 +324,7 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
hsp_hs_create_sdp_record((uint8_t *)hsp_service_buffer, 0x10004, rfcomm_channel_nr, hsp_hs_service_name, 0);
|
hsp_hs_create_sdp_record((uint8_t *)hsp_service_buffer, 0x10004, rfcomm_channel_nr, hsp_hs_service_name, 0);
|
||||||
sdp_register_service((uint8_t *)hsp_service_buffer);
|
sdp_register_service((uint8_t *)hsp_service_buffer);
|
||||||
|
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
hci_set_class_of_device(0x200418);
|
hci_set_class_of_device(0x200418);
|
||||||
|
|
||||||
btstack_stdin_setup(stdin_process);
|
btstack_stdin_setup(stdin_process);
|
||||||
|
@ -88,7 +88,7 @@ int btstack_main(int argc, const char * argv[]);
|
|||||||
int btstack_main(int argc, const char * argv[]){
|
int btstack_main(int argc, const char * argv[]){
|
||||||
|
|
||||||
hci_set_class_of_device(0x220404);
|
hci_set_class_of_device(0x220404);
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
|
|
||||||
l2cap_init();
|
l2cap_init();
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ int btstack_main(int argc, const char * argv[]);
|
|||||||
int btstack_main(int argc, const char * argv[]){
|
int btstack_main(int argc, const char * argv[]){
|
||||||
|
|
||||||
hci_set_class_of_device(0x220404);
|
hci_set_class_of_device(0x220404);
|
||||||
hci_discoverable_control(1);
|
gap_discoverable_control(1);
|
||||||
|
|
||||||
/* Register for HCI events */
|
/* Register for HCI events */
|
||||||
hci_event_callback_registration.callback = &packet_handler;
|
hci_event_callback_registration.callback = &packet_handler;
|
||||||
|
@ -136,7 +136,7 @@ void hci_connections_get_iterator(btstack_linked_list_iterator_t *it){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get addr type and address used in advertisement packets
|
// get addr type and address used in advertisement packets
|
||||||
void hci_le_advertisement_address(uint8_t * addr_type, bd_addr_t addr){
|
void gap_advertisements_get_address(uint8_t * addr_type, bd_addr_t addr){
|
||||||
*addr_type = 0;
|
*addr_type = 0;
|
||||||
uint8_t dummy[] = { 0x00, 0x1b, 0xdc, 0x07, 0x32, 0xef };
|
uint8_t dummy[] = { 0x00, 0x1b, 0xdc, 0x07, 0x32, 0xef };
|
||||||
memcpy(addr, dummy, 6);
|
memcpy(addr, dummy, 6);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user