extracted rfcomm_cen_send_packet_now method

This commit is contained in:
mila@ringwald.ch 2014-10-23 09:50:11 +00:00
parent e731911be9
commit 92062b88a8
2 changed files with 12 additions and 5 deletions

View File

@ -1987,13 +1987,11 @@ void rfcomm_register_packet_handler(void (*handler)(void * connection, uint8_t p
app_packet_handler = handler;
}
// send packet over specific channel
int rfcomm_send_internal(uint16_t rfcomm_cid, uint8_t *data, uint16_t len){
int rfcomm_can_send_packet_now(uint16_t rfcomm_cid){
rfcomm_channel_t * channel = rfcomm_channel_for_rfcomm_cid(rfcomm_cid);
if (!channel){
log_error("rfcomm_send_internal cid 0x%02x doesn't exist!", rfcomm_cid);
return 0;
return 1;
}
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",
// 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
channel->credits_outgoing--;

View File

@ -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.
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.
int rfcomm_send_internal(uint16_t rfcomm_cid, uint8_t *data, uint16_t len);