mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-17 02:42:33 +00:00
Merge branch 'develop' of https://github.com/bluekitchen/btstack into develop
This commit is contained in:
commit
1ba6689f24
@ -195,7 +195,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
case GAP_EVENT_DEDICATED_BONDING_COMPLETED:
|
||||
// data: event(8), len(8), status (8), bd_addr(48)
|
||||
printf("GAP Dedicated Bonding Complete, status %u\n", packet[2]);
|
||||
reverse_bd_addr(&packet[3], addr);
|
||||
gap_event_dedicated_bonding_completed_get_address(packet, addr);
|
||||
int index = getDeviceIndexForAddress(addr);
|
||||
if (index >= 0) {
|
||||
devices[index].state = BONDING_COMPLETED;
|
||||
|
@ -108,13 +108,11 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
||||
break;
|
||||
|
||||
case L2CAP_EVENT_INCOMING_CONNECTION:
|
||||
// data: event(8), len(8), address(48), handle (16), psm (16), source cid(16) dest cid(16)
|
||||
reverse_bd_addr(&packet[2],
|
||||
event_addr);
|
||||
con_handle = little_endian_read_16(packet, 8);
|
||||
psm = little_endian_read_16(packet, 10);
|
||||
local_cid = little_endian_read_16(packet, 12);
|
||||
remote_cid = little_endian_read_16(packet, 14);
|
||||
l2cap_event_incoming_connection_get_address(packet, event_addr);
|
||||
con_handle = l2cap_event_incoming_connection_get_handle(packet);
|
||||
psm = l2cap_event_incoming_connection_get_psm(packet);
|
||||
local_cid = l2cap_event_incoming_connection_get_local_cid(packet);
|
||||
remote_cid = l2cap_event_incoming_connection_get_remote_cid(packet);
|
||||
printf("L2CAP_EVENT_INCOMING_CONNECTION %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x\n",
|
||||
bd_addr_to_str(event_addr), con_handle, psm, local_cid, remote_cid);
|
||||
|
||||
@ -143,28 +141,29 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
||||
|
||||
case L2CAP_EVENT_CHANNEL_OPENED:
|
||||
// inform about new l2cap connection
|
||||
reverse_bd_addr(&packet[3],
|
||||
event_addr);
|
||||
psm = little_endian_read_16(packet, 11);
|
||||
local_cid = little_endian_read_16(packet, 13);
|
||||
con_handle = little_endian_read_16(packet, 9);
|
||||
if (packet[2] == 0) {
|
||||
printf("Channel successfully opened: %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x\n",
|
||||
bd_addr_to_str(event_addr), con_handle, psm, local_cid, little_endian_read_16(packet, 15));
|
||||
|
||||
if (psm == PSM_HID_CONTROL){
|
||||
hid_control = local_cid;
|
||||
}
|
||||
if (psm == PSM_HID_INTERRUPT){
|
||||
hid_interrupt = local_cid;
|
||||
}
|
||||
if (hid_control && hid_interrupt){
|
||||
bt_send_cmd(&hci_switch_role_command, &event_addr, 0);
|
||||
}
|
||||
} else {
|
||||
printf("L2CAP connection to device %s failed. status code %u\n", bd_addr_to_str(event_addr), packet[2]);
|
||||
l2cap_event_channel_opened_get_address(packet, event_addr);
|
||||
|
||||
if (l2cap_event_channel_opened_get_status(packet)){
|
||||
printf("L2CAP connection to device %s failed. status code %u\n",
|
||||
bd_addr_to_str(event_addr), l2cap_event_channel_opened_get_status(packet));
|
||||
exit(1);
|
||||
}
|
||||
psm = l2cap_event_channel_opened_get_psm(packet);
|
||||
local_cid = l2cap_event_channel_opened_get_local_cid(packet);
|
||||
con_handle = l2cap_event_channel_opened_get_handle(packet);
|
||||
|
||||
printf("Channel successfully opened: %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x\n",
|
||||
bd_addr_to_str(event_addr), con_handle, psm, local_cid, l2cap_event_channel_opened_get_remote_cid(packet));
|
||||
|
||||
if (psm == PSM_HID_CONTROL){
|
||||
hid_control = local_cid;
|
||||
}
|
||||
if (psm == PSM_HID_INTERRUPT){
|
||||
hid_interrupt = local_cid;
|
||||
}
|
||||
if (hid_control && hid_interrupt){
|
||||
bt_send_cmd(&hci_switch_role_command, &event_addr, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case HCI_EVENT_ROLE_CHANGE: {
|
||||
|
@ -123,14 +123,13 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
||||
break;
|
||||
|
||||
case L2CAP_EVENT_INCOMING_CONNECTION:
|
||||
// data: event(8), len(8), address(48), handle (16), psm (16), source cid(16) dest cid(16)
|
||||
reverse_bd_addr(&packet[2],
|
||||
event_addr);
|
||||
con_handle = little_endian_read_16(packet, 8);
|
||||
psm = little_endian_read_16(packet, 10);
|
||||
local_cid = little_endian_read_16(packet, 12);
|
||||
// remote_cid = little_endian_read_16(packet, 14);
|
||||
printf("L2CAP_EVENT_INCOMING_CONNECTION %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x\n", bd_addr_to_str(event_addr), con_handle, psm, local_cid);
|
||||
l2cap_event_incoming_connection_get_address(packet, event_addr);
|
||||
con_handle = l2cap_event_incoming_connection_get_handle(packet);
|
||||
psm = l2cap_event_incoming_connection_get_psm(packet);
|
||||
local_cid = l2cap_event_incoming_connection_get_local_cid(packet);
|
||||
printf("L2CAP_EVENT_INCOMING_CONNECTION %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x\n",
|
||||
bd_addr_to_str(event_addr), con_handle, psm, local_cid, l2cap_event_incoming_connection_get_remote_cid(packet));
|
||||
|
||||
// accept
|
||||
bt_send_cmd(&l2cap_accept_connection_cmd, local_cid);
|
||||
break;
|
||||
@ -157,17 +156,20 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
||||
|
||||
case L2CAP_EVENT_CHANNEL_OPENED:
|
||||
// inform about new l2cap connection
|
||||
reverse_bd_addr(&packet[3],
|
||||
event_addr);
|
||||
l2cap_event_channel_opened_get_address(packet, event_addr);
|
||||
|
||||
if (l2cap_event_channel_opened_get_status(packet)){
|
||||
printf("L2CAP connection to device %s failed. status code %u\n",
|
||||
bd_addr_to_str(event_addr), l2cap_event_channel_opened_get_status(packet));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
psm = little_endian_read_16(packet, 11);
|
||||
local_cid = little_endian_read_16(packet, 13);
|
||||
con_handle = little_endian_read_16(packet, 9);
|
||||
if (packet[2] == 0) {
|
||||
printf("Channel successfully opened: %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x\n",
|
||||
bd_addr_to_str(event_addr), con_handle, psm, local_cid, little_endian_read_16(packet, 15));
|
||||
} else {
|
||||
printf("L2CAP connection to device %s failed. status code %u\n", bd_addr_to_str(event_addr), packet[2]);
|
||||
}
|
||||
printf("Channel successfully opened: %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x\n",
|
||||
bd_addr_to_str(event_addr), con_handle, psm, local_cid, l2cap_event_channel_opened_get_remote_cid(packet));
|
||||
|
||||
break;
|
||||
|
||||
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
||||
|
@ -387,8 +387,7 @@ typedef uint8_t sm_key_t[16];
|
||||
#define L2CAP_EVENT_CHANNEL_CLOSED 0x71
|
||||
|
||||
/**
|
||||
* @format 1BH222
|
||||
* @param status
|
||||
* @format BH222
|
||||
* @param address
|
||||
* @param handle
|
||||
* @param psm
|
||||
|
@ -987,15 +987,6 @@ static inline uint16_t l2cap_event_channel_closed_get_local_cid(const uint8_t *
|
||||
return little_endian_read_16(event, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field status from event L2CAP_EVENT_INCOMING_CONNECTION
|
||||
* @param event packet
|
||||
* @return status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t l2cap_event_incoming_connection_get_status(const uint8_t * event){
|
||||
return event[2];
|
||||
}
|
||||
/**
|
||||
* @brief Get field address from event L2CAP_EVENT_INCOMING_CONNECTION
|
||||
* @param event packet
|
||||
@ -1003,7 +994,7 @@ static inline uint8_t l2cap_event_incoming_connection_get_status(const uint8_t *
|
||||
* @note: btstack_type B
|
||||
*/
|
||||
static inline void l2cap_event_incoming_connection_get_address(const uint8_t * event, bd_addr_t address){
|
||||
reverse_bd_addr(&event[3], address);
|
||||
reverse_bd_addr(&event[2], address);
|
||||
}
|
||||
/**
|
||||
* @brief Get field handle from event L2CAP_EVENT_INCOMING_CONNECTION
|
||||
@ -1012,7 +1003,7 @@ static inline void l2cap_event_incoming_connection_get_address(const uint8_t * e
|
||||
* @note: btstack_type H
|
||||
*/
|
||||
static inline hci_con_handle_t l2cap_event_incoming_connection_get_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 9);
|
||||
return little_endian_read_16(event, 8);
|
||||
}
|
||||
/**
|
||||
* @brief Get field psm from event L2CAP_EVENT_INCOMING_CONNECTION
|
||||
@ -1021,7 +1012,7 @@ static inline hci_con_handle_t l2cap_event_incoming_connection_get_handle(const
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t l2cap_event_incoming_connection_get_psm(const uint8_t * event){
|
||||
return little_endian_read_16(event, 11);
|
||||
return little_endian_read_16(event, 10);
|
||||
}
|
||||
/**
|
||||
* @brief Get field local_cid from event L2CAP_EVENT_INCOMING_CONNECTION
|
||||
@ -1030,7 +1021,7 @@ static inline uint16_t l2cap_event_incoming_connection_get_psm(const uint8_t * e
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t l2cap_event_incoming_connection_get_local_cid(const uint8_t * event){
|
||||
return little_endian_read_16(event, 13);
|
||||
return little_endian_read_16(event, 12);
|
||||
}
|
||||
/**
|
||||
* @brief Get field remote_cid from event L2CAP_EVENT_INCOMING_CONNECTION
|
||||
@ -1039,7 +1030,7 @@ static inline uint16_t l2cap_event_incoming_connection_get_local_cid(const uint8
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t l2cap_event_incoming_connection_get_remote_cid(const uint8_t * event){
|
||||
return little_endian_read_16(event, 15);
|
||||
return little_endian_read_16(event, 14);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user