mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-07 16:20:19 +00:00
don't emit X_EVENT_CAN_SEND_NOW if x_can_send_now returns false
This commit is contained in:
parent
a6ef64ba22
commit
0b9d7e785b
@ -105,11 +105,7 @@ void att_dispatch_register_server(btstack_packet_handler_t packet_handler){
|
|||||||
* @param handle
|
* @param handle
|
||||||
*/
|
*/
|
||||||
int att_dispatch_client_can_send_now(hci_con_handle_t con_handle){
|
int att_dispatch_client_can_send_now(hci_con_handle_t con_handle){
|
||||||
int res = l2cap_can_send_fixed_channel_packet_now(con_handle, L2CAP_CID_ATTRIBUTE_PROTOCOL);
|
return l2cap_can_send_fixed_channel_packet_now(con_handle, L2CAP_CID_ATTRIBUTE_PROTOCOL);
|
||||||
if (!res){
|
|
||||||
att_client_waiting_for_can_send =1;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,9 +113,27 @@ int att_dispatch_client_can_send_now(hci_con_handle_t con_handle){
|
|||||||
* @param handle
|
* @param handle
|
||||||
*/
|
*/
|
||||||
int att_dispatch_server_can_send_now(hci_con_handle_t con_handle){
|
int att_dispatch_server_can_send_now(hci_con_handle_t con_handle){
|
||||||
int res = l2cap_can_send_fixed_channel_packet_now(con_handle, L2CAP_CID_ATTRIBUTE_PROTOCOL);
|
return l2cap_can_send_fixed_channel_packet_now(con_handle, L2CAP_CID_ATTRIBUTE_PROTOCOL);
|
||||||
if (!res){
|
}
|
||||||
att_server_waiting_for_can_send =1;
|
|
||||||
}
|
/**
|
||||||
return res;
|
* @brief Request emission of L2CAP_EVENT_CAN_SEND_NOW as soon as possible for client
|
||||||
|
* @note L2CAP_EVENT_CAN_SEND_NOW might be emitted during call to this function
|
||||||
|
* so packet handler should be ready to handle it
|
||||||
|
* @param con_handle
|
||||||
|
*/
|
||||||
|
void att_dispatch_client_request_can_send_now_event(hci_con_handle_t con_handle){
|
||||||
|
att_client_waiting_for_can_send = 1;
|
||||||
|
l2cap_request_can_send_fix_channel_now_event(con_handle, L2CAP_CID_ATTRIBUTE_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Request emission of L2CAP_EVENT_CAN_SEND_NOW as soon as possible for server
|
||||||
|
* @note L2CAP_EVENT_CAN_SEND_NOW might be emitted during call to this function
|
||||||
|
* so packet handler should be ready to handle it
|
||||||
|
* @param con_handle
|
||||||
|
*/
|
||||||
|
void att_dispatch_server_request_can_send_now_event(hci_con_handle_t con_handle){
|
||||||
|
att_server_waiting_for_can_send = 1;
|
||||||
|
l2cap_request_can_send_fix_channel_now_event(con_handle, L2CAP_CID_ATTRIBUTE_PROTOCOL);
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,21 @@ int att_dispatch_client_can_send_now(hci_con_handle_t con_handle);
|
|||||||
*/
|
*/
|
||||||
int att_dispatch_server_can_send_now(hci_con_handle_t con_handle);
|
int att_dispatch_server_can_send_now(hci_con_handle_t con_handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Request emission of L2CAP_EVENT_CAN_SEND_NOW as soon as possible for client
|
||||||
|
* @note L2CAP_EVENT_CAN_SEND_NOW might be emitted during call to this function
|
||||||
|
* so packet handler should be ready to handle it
|
||||||
|
* @param con_handle
|
||||||
|
*/
|
||||||
|
void att_dispatch_client_request_can_send_now_event(hci_con_handle_t con_handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Request emission of L2CAP_EVENT_CAN_SEND_NOW as soon as possible for server
|
||||||
|
* @note L2CAP_EVENT_CAN_SEND_NOW might be emitted during call to this function
|
||||||
|
* so packet handler should be ready to handle it
|
||||||
|
* @param con_handle
|
||||||
|
*/
|
||||||
|
void att_dispatch_server_request_can_send_now_event(hci_con_handle_t con_handle);
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -415,16 +415,12 @@ void att_server_register_packet_handler(btstack_packet_handler_t handler){
|
|||||||
|
|
||||||
int att_server_can_send_packet_now(void){
|
int att_server_can_send_packet_now(void){
|
||||||
if (att_connection.con_handle == 0) return 0;
|
if (att_connection.con_handle == 0) return 0;
|
||||||
int can_send = att_dispatch_server_can_send_now(att_connection.con_handle);
|
return att_dispatch_server_can_send_now(att_connection.con_handle);
|
||||||
if (!can_send){
|
|
||||||
att_client_waiting_for_can_send = 1;
|
|
||||||
}
|
|
||||||
return can_send;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void att_server_request_can_send_now_event(){
|
void att_server_request_can_send_now_event(){
|
||||||
att_client_waiting_for_can_send = 1;
|
att_client_waiting_for_can_send = 1;
|
||||||
att_server_notify_can_send();
|
att_dispatch_server_request_can_send_now_event(att_connection.con_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
int att_server_notify(uint16_t attribute_handle, uint8_t *value, uint16_t value_len){
|
int att_server_notify(uint16_t attribute_handle, uint8_t *value, uint16_t value_len){
|
||||||
|
@ -378,13 +378,7 @@ int bnep_can_send_packet_now(uint16_t bnep_cid)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int can_send = l2cap_can_send_packet_now(channel->l2cap_cid);
|
return l2cap_can_send_packet_now(channel->l2cap_cid);
|
||||||
|
|
||||||
if (!can_send){
|
|
||||||
channel->waiting_for_can_send_now = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return can_send;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bnep_request_can_send_now_event(uint16_t bnep_cid)
|
void bnep_request_can_send_now_event(uint16_t bnep_cid)
|
||||||
|
@ -1934,11 +1934,7 @@ int rfcomm_can_send_packet_now(uint16_t rfcomm_cid){
|
|||||||
log_error("rfcomm_send cid 0x%02x doesn't exist!", rfcomm_cid);
|
log_error("rfcomm_send cid 0x%02x doesn't exist!", rfcomm_cid);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int res = rfcomm_channel_can_send(channel);
|
return rfcomm_channel_can_send(channel);
|
||||||
if (!res){
|
|
||||||
channel->waiting_for_can_send_now = 1;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rfcomm_request_can_send_now_event(uint16_t rfcomm_cid){
|
void rfcomm_request_can_send_now_event(uint16_t rfcomm_cid){
|
||||||
|
@ -320,7 +320,6 @@ void rfcomm_grant_credits(uint16_t rfcomm_cid, uint8_t credits);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Checks if RFCOMM can send packet.
|
* @brief Checks if RFCOMM can send packet.
|
||||||
* @note If packet cannot be sent now, a RFCOMM_EVENT_CAN_SEND_NOW will be emitted later
|
|
||||||
* @param rfcomm_cid
|
* @param rfcomm_cid
|
||||||
* @result != 0 if can send now
|
* @result != 0 if can send now
|
||||||
*/
|
*/
|
||||||
|
34
src/l2cap.c
34
src/l2cap.c
@ -246,6 +246,8 @@ static l2cap_channel_t * l2cap_get_channel_for_local_cid(uint16_t local_cid){
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
|
||||||
void l2cap_request_can_send_now_event(uint16_t local_cid){
|
void l2cap_request_can_send_now_event(uint16_t local_cid){
|
||||||
l2cap_channel_t *channel = l2cap_get_channel_for_local_cid(local_cid);
|
l2cap_channel_t *channel = l2cap_get_channel_for_local_cid(local_cid);
|
||||||
if (!channel) return;
|
if (!channel) return;
|
||||||
@ -253,37 +255,33 @@ void l2cap_request_can_send_now_event(uint16_t local_cid){
|
|||||||
l2cap_notify_channel_can_send();
|
l2cap_notify_channel_can_send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void l2cap_request_can_send_fix_channel_now_event(hci_con_handle_t con_handle, uint16_t channel_id){
|
||||||
|
int index = l2cap_fixed_channel_table_index_for_channel_id(channel_id);
|
||||||
|
if (index < 0) return;
|
||||||
|
fixed_channels[index].waiting_for_can_send_now = 1;
|
||||||
|
l2cap_notify_channel_can_send();
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
|
||||||
int l2cap_can_send_packet_now(uint16_t local_cid){
|
int l2cap_can_send_packet_now(uint16_t local_cid){
|
||||||
l2cap_channel_t *channel = l2cap_get_channel_for_local_cid(local_cid);
|
l2cap_channel_t *channel = l2cap_get_channel_for_local_cid(local_cid);
|
||||||
if (!channel) return 0;
|
if (!channel) return 0;
|
||||||
int can_send = hci_can_send_acl_packet_now(channel->con_handle);
|
return hci_can_send_acl_packet_now(channel->con_handle);
|
||||||
if (!can_send){
|
|
||||||
channel->waiting_for_can_send_now = 1;
|
|
||||||
}
|
|
||||||
return can_send;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int l2cap_can_send_prepared_packet_now(uint16_t local_cid){
|
int l2cap_can_send_prepared_packet_now(uint16_t local_cid){
|
||||||
l2cap_channel_t *channel = l2cap_get_channel_for_local_cid(local_cid);
|
l2cap_channel_t *channel = l2cap_get_channel_for_local_cid(local_cid);
|
||||||
if (!channel) return 0;
|
if (!channel) return 0;
|
||||||
int can_send = hci_can_send_prepared_acl_packet_now(channel->con_handle);
|
return hci_can_send_prepared_acl_packet_now(channel->con_handle);
|
||||||
if (!can_send){
|
|
||||||
channel->waiting_for_can_send_now = 1;
|
|
||||||
}
|
|
||||||
return can_send;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int l2cap_can_send_fixed_channel_packet_now(hci_con_handle_t con_handle, uint16_t channel_id){
|
int l2cap_can_send_fixed_channel_packet_now(hci_con_handle_t con_handle, uint16_t channel_id){
|
||||||
int can_send = hci_can_send_acl_packet_now(con_handle);
|
return hci_can_send_acl_packet_now(con_handle);
|
||||||
if (!can_send){
|
|
||||||
int index = l2cap_fixed_channel_table_index_for_channel_id(channel_id);
|
|
||||||
if (index >= 0){
|
|
||||||
fixed_channels[index].waiting_for_can_send_now = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return can_send;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
|
||||||
uint16_t l2cap_get_remote_mtu_for_local_cid(uint16_t local_cid){
|
uint16_t l2cap_get_remote_mtu_for_local_cid(uint16_t local_cid){
|
||||||
l2cap_channel_t * channel = l2cap_get_channel_for_local_cid(local_cid);
|
l2cap_channel_t * channel = l2cap_get_channel_for_local_cid(local_cid);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
|
@ -167,6 +167,7 @@ typedef struct l2cap_signaling_response {
|
|||||||
|
|
||||||
void l2cap_register_fixed_channel(btstack_packet_handler_t packet_handler, uint16_t channel_id);
|
void l2cap_register_fixed_channel(btstack_packet_handler_t packet_handler, uint16_t channel_id);
|
||||||
int l2cap_can_send_fixed_channel_packet_now(hci_con_handle_t con_handle, uint16_t channel_id);
|
int l2cap_can_send_fixed_channel_packet_now(hci_con_handle_t con_handle, uint16_t channel_id);
|
||||||
|
void l2cap_request_can_send_fix_channel_now_event(hci_con_handle_t con_handle, uint16_t channel_id);
|
||||||
int l2cap_send_connectionless(hci_con_handle_t con_handle, uint16_t cid, uint8_t *data, uint16_t len);
|
int l2cap_send_connectionless(hci_con_handle_t con_handle, uint16_t cid, uint8_t *data, uint16_t len);
|
||||||
int l2cap_send_prepared_connectionless(hci_con_handle_t con_handle, uint16_t cid, uint16_t len);
|
int l2cap_send_prepared_connectionless(hci_con_handle_t con_handle, uint16_t cid, uint16_t len);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user