rfcomm: add rfcomm_request_can_send_now_event

This commit is contained in:
Matthias Ringwald 2016-03-31 14:22:40 +02:00
parent 6dcd2e7718
commit 225a2744a1
2 changed files with 35 additions and 1 deletions

View File

@ -1937,6 +1937,16 @@ int rfcomm_can_send_packet_now(uint16_t rfcomm_cid){
return res; 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){ static int rfcomm_assert_send_valid(rfcomm_channel_t * channel , uint16_t len){
if (len > channel->max_frame_size){ if (len > channel->max_frame_size){
log_error("rfcomm_send cid 0x%02x, rfcomm data lenght exceeds MTU!", channel->rfcomm_cid); log_error("rfcomm_send cid 0x%02x, rfcomm data lenght exceeds MTU!", channel->rfcomm_cid);

View File

@ -319,37 +319,61 @@ void rfcomm_decline_connection(uint16_t rfcomm_cid);
void rfcomm_grant_credits(uint16_t rfcomm_cid, uint8_t credits); 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); 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. * @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); int rfcomm_send(uint16_t rfcomm_cid, uint8_t *data, uint16_t len);
/** /**
* @brief Sends Local Line Status, see LINE_STATUS_.. * @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); int rfcomm_send_local_line_status(uint16_t rfcomm_cid, uint8_t line_status);
/** /**
* @brief Send local modem status. see MODEM_STAUS_.. * @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); int rfcomm_send_modem_status(uint16_t rfcomm_cid, uint8_t modem_status);
/** /**
* @brief Configure remote port * @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); 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 * @brief Query remote port
* @param rfcomm_cid
*/ */
int rfcomm_query_port_configuration(uint16_t rfcomm_cid); int rfcomm_query_port_configuration(uint16_t rfcomm_cid);
/** /**
* @brief Query max frame size * @brief Query max frame size
* @param rfcomm_cid
*/ */
uint16_t rfcomm_get_max_frame_size(uint16_t rfcomm_cid); uint16_t rfcomm_get_max_frame_size(uint16_t rfcomm_cid);