mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-07 16:20:19 +00:00
extracted rfcomm_cen_send_packet_now method
This commit is contained in:
parent
e731911be9
commit
92062b88a8
14
src/rfcomm.c
14
src/rfcomm.c
@ -1987,13 +1987,11 @@ void rfcomm_register_packet_handler(void (*handler)(void * connection, uint8_t p
|
|||||||
app_packet_handler = handler;
|
app_packet_handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send packet over specific channel
|
int rfcomm_can_send_packet_now(uint16_t rfcomm_cid){
|
||||||
int rfcomm_send_internal(uint16_t rfcomm_cid, uint8_t *data, uint16_t len){
|
|
||||||
|
|
||||||
rfcomm_channel_t * channel = rfcomm_channel_for_rfcomm_cid(rfcomm_cid);
|
rfcomm_channel_t * channel = rfcomm_channel_for_rfcomm_cid(rfcomm_cid);
|
||||||
if (!channel){
|
if (!channel){
|
||||||
log_error("rfcomm_send_internal cid 0x%02x doesn't exist!", rfcomm_cid);
|
log_error("rfcomm_send_internal cid 0x%02x doesn't exist!", rfcomm_cid);
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!channel->credits_outgoing){
|
if (!channel->credits_outgoing){
|
||||||
@ -2012,7 +2010,13 @@ int rfcomm_send_internal(uint16_t rfcomm_cid, uint8_t *data, uint16_t len){
|
|||||||
}
|
}
|
||||||
// log_info("rfcomm_send_internal: len %u... outgoing credits %u, l2cap credit %us, granted %u",
|
// log_info("rfcomm_send_internal: len %u... outgoing credits %u, l2cap credit %us, granted %u",
|
||||||
// len, channel->credits_outgoing, channel->multiplexer->l2cap_credits, channel->packets_granted);
|
// len, channel->credits_outgoing, channel->multiplexer->l2cap_credits, channel->packets_granted);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// send packet over specific channel
|
||||||
|
int rfcomm_send_internal(uint16_t rfcomm_cid, uint8_t *data, uint16_t len){
|
||||||
|
int err = rfcomm_can_send_packet_now();
|
||||||
|
if (err) return err;
|
||||||
|
|
||||||
// send might cause l2cap to emit new credits, update counters first
|
// send might cause l2cap to emit new credits, update counters first
|
||||||
channel->credits_outgoing--;
|
channel->credits_outgoing--;
|
||||||
|
@ -405,6 +405,9 @@ void rfcomm_decline_connection_internal(uint16_t rfcomm_cid);
|
|||||||
// Grant more incoming credits to the remote side for the given RFCOMM channel identifier.
|
// Grant more incoming credits to the remote side for the given RFCOMM channel identifier.
|
||||||
void rfcomm_grant_credits(uint16_t rfcomm_cid, uint8_t credits);
|
void rfcomm_grant_credits(uint16_t rfcomm_cid, uint8_t credits);
|
||||||
|
|
||||||
|
// Chekcs if RFCOMM can send packet. If yes returns 0, otherwise returns an error code.
|
||||||
|
int rfcomm_can_send_packet_now(uint16_t rfcomm_cid);
|
||||||
|
|
||||||
// Sends RFCOMM data packet to the RFCOMM channel with given identifier.
|
// Sends RFCOMM data packet to the RFCOMM channel with given identifier.
|
||||||
int rfcomm_send_internal(uint16_t rfcomm_cid, uint8_t *data, uint16_t len);
|
int rfcomm_send_internal(uint16_t rfcomm_cid, uint8_t *data, uint16_t len);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user