From 225a2744a1f2ec36481cee820e162a3561a47bc1 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 31 Mar 2016 14:22:40 +0200 Subject: [PATCH] rfcomm: add rfcomm_request_can_send_now_event --- src/classic/rfcomm.c | 10 ++++++++++ src/classic/rfcomm.h | 26 +++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/classic/rfcomm.c b/src/classic/rfcomm.c index ab666437a..106c4a4fa 100644 --- a/src/classic/rfcomm.c +++ b/src/classic/rfcomm.c @@ -1937,6 +1937,16 @@ int rfcomm_can_send_packet_now(uint16_t rfcomm_cid){ return res; } +void rfcomm_request_can_send_now_event(uint16_t rfcomm_cid){ + rfcomm_channel_t * channel = rfcomm_channel_for_rfcomm_cid(rfcomm_cid); + if (!channel){ + log_error("rfcomm_send cid 0x%02x doesn't exist!", rfcomm_cid); + return; + } + channel->waiting_for_can_send_now = 1; + rfcomm_notify_channel_can_send(); +} + static int rfcomm_assert_send_valid(rfcomm_channel_t * channel , uint16_t len){ if (len > channel->max_frame_size){ log_error("rfcomm_send cid 0x%02x, rfcomm data lenght exceeds MTU!", channel->rfcomm_cid); diff --git a/src/classic/rfcomm.h b/src/classic/rfcomm.h index 4dd809c26..467c15e76 100644 --- a/src/classic/rfcomm.h +++ b/src/classic/rfcomm.h @@ -319,37 +319,61 @@ void rfcomm_decline_connection(uint16_t rfcomm_cid); void rfcomm_grant_credits(uint16_t rfcomm_cid, uint8_t credits); /** - * @brief Checks if RFCOMM can send packet. Returns yes if packet can be sent. + * @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 + * @result != 0 if can send now */ int rfcomm_can_send_packet_now(uint16_t rfcomm_cid); +/** + * @brief Request emission of RFCOMM_EVENT_CAN_SEND_NOW as soon as possible + * @note RFCOMM_EVENT_CAN_SEND_NOW might be emitted during call to this function + * so packet handler should be ready to handle it + * @param rfcomm_cid + */ +void rfcomm_request_can_send_now_event(uint16_t rfcomm_cid); + /** * @brief Sends RFCOMM data packet to the RFCOMM channel with given identifier. + * @param rfcomm_cid */ int rfcomm_send(uint16_t rfcomm_cid, uint8_t *data, uint16_t len); /** * @brief Sends Local Line Status, see LINE_STATUS_.. + * @param rfcomm_cid + * @param line_status */ int rfcomm_send_local_line_status(uint16_t rfcomm_cid, uint8_t line_status); /** * @brief Send local modem status. see MODEM_STAUS_.. + * @param rfcomm_cid + * @param modem_status */ int rfcomm_send_modem_status(uint16_t rfcomm_cid, uint8_t modem_status); /** * @brief Configure remote port + * @param rfcomm_cid + * @param baud_rate + * @param data_bits + * @param stop_bits + * @param parity + * @param flow_control */ int rfcomm_send_port_configuration(uint16_t rfcomm_cid, rpn_baud_t baud_rate, rpn_data_bits_t data_bits, rpn_stop_bits_t stop_bits, rpn_parity_t parity, rpn_flow_control_t flow_control); /** * @brief Query remote port + * @param rfcomm_cid */ int rfcomm_query_port_configuration(uint16_t rfcomm_cid); /** * @brief Query max frame size + * @param rfcomm_cid */ uint16_t rfcomm_get_max_frame_size(uint16_t rfcomm_cid);