/** Transmit buffer */
int (*transmit_buf)(TRANSAC transac, char *p_buf, int len);
- /** Controls receive flow */
- int (*set_rxflow)(bt_rx_flow_state_t state);
-
/** Controls HCI logging on/off */
int (*logging)(bt_hc_logging_state_t state, char *p_path);
// This function returns the number of bytes actually written, which may be
// less than |len|. This function may block.
uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len);
-
-// Pauses reading data from the serial port. No new buffers will be produced
-// until |userial_resume_reading| is called. This function is idempotent.
-void userial_pause_reading(void);
-
-// Resumes reading data from the serial port if reads were previously paused.
-// This function is idempotent.
-void userial_resume_reading(void);
}
-/** Controls receive flow */
-static int set_rxflow(bt_rx_flow_state_t state) {
- BTHCDBG("set_rxflow %d", state);
-
- switch (state) {
- case BT_RXFLOW_ON:
- userial_resume_reading();
- break;
-
- case BT_RXFLOW_OFF:
- userial_pause_reading();
- break;
-
- default:
- assert(false);
- ALOGE("%s unexpected flow state: %d", __func__, state);
- return BT_HC_STATUS_FAIL;
- }
-
- return BT_HC_STATUS_SUCCESS;
-}
-
-
/** Controls HCI logging on/off */
static int logging(bt_hc_logging_state_t state, char *p_path)
{
preload,
postload,
transmit_buf,
- set_rxflow,
logging,
cleanup
};
// Note that the values must be >= 0x8000000000000000 to guarantee delivery
// of the message (see eventfd(2) for details on blocking behaviour).
enum {
- USERIAL_RX_EXIT = 0x8000000000000000ULL,
- USERIAL_RX_FLOW_OFF = 0x8000000000000001ULL,
- USERIAL_RX_FLOW_ON = 0x8000000000000002ULL,
+ USERIAL_RX_EXIT = 0x8000000000000000ULL
};
/******************************************************************************
** - signal_fds[1]: trigger from userial_close
*****************************************************************************/
static int event_fd = -1;
-static uint8_t rx_flow_on = TRUE;
static inline int add_event_fd(fd_set *set) {
if (event_fd == -1) {
{
/* Initialize the input fd set */
FD_ZERO(&input);
- if (rx_flow_on == TRUE)
- {
- FD_SET(fd, &input);
- }
+ FD_SET(fd, &input);
int fd_max = add_event_fd(&input);
fd_max = fd_max > fd ? fd_max : fd;
{
uint64_t event = read_event();
switch (event) {
- case USERIAL_RX_FLOW_ON:
- USERIALDBG("RX flow ON");
- rx_flow_on = TRUE;
- break;
- case USERIAL_RX_FLOW_OFF:
- USERIALDBG("RX flow OFF");
- rx_flow_on = FALSE;
- break;
case USERIAL_RX_EXIT:
USERIALDBG("RX termination");
return -1;
USERIALDBG("Entering userial_read_thread()");
prctl(PR_SET_NAME, (unsigned long)"userial_read", 0, 0, 0);
- rx_flow_on = TRUE;
userial_running = 1;
raise_priority_a2dp(TASK_HIGH_USERIAL_READ);
userial_cb.fd = -1;
}
-
-void userial_pause_reading(void) {
- if (userial_running)
- send_event(USERIAL_RX_FLOW_OFF);
-}
-
-void userial_resume_reading(void) {
- if (userial_running)
- send_event(USERIAL_RX_FLOW_ON);
-}
enum {
USERIAL_RX_EXIT,
- USERIAL_RX_FLOW_OFF,
- USERIAL_RX_FLOW_ON
};
/******************************************************************************
** - signal_fds[1]: trigger from userial_close
*****************************************************************************/
static int signal_fds[2]={0,1};
-static uint8_t rx_flow_on = TRUE;
static inline int create_signal_fds(fd_set* set)
{
if(signal_fds[0]==0 && socketpair(AF_UNIX, SOCK_STREAM, 0, signal_fds)<0)
USERIALDBG("Entering userial_read_thread()");
- rx_flow_on = TRUE;
userial_running = 1;
raise_priority_a2dp(TASK_HIGH_USERIAL_READ);
{
/* Initialize the input fd set */
FD_ZERO(&input);
- if (rx_flow_on == TRUE)
- {
- FD_SET(userial_cb.fd[CH_EVT], &input);
- FD_SET(userial_cb.fd[CH_ACL_IN], &input);
- }
+ FD_SET(userial_cb.fd[CH_EVT], &input);
+ FD_SET(userial_cb.fd[CH_ACL_IN], &input);
int fd_max = create_signal_fds(&input);
fd_max = (fd_max>userial_cb.fd[CH_EVT]) ? fd_max : userial_cb.fd[CH_EVT];
userial_running = 0;
break;
}
- else if (reason == USERIAL_RX_FLOW_OFF)
- {
- USERIALDBG("RX flow OFF");
- rx_flow_on = FALSE;
- }
- else if (reason == USERIAL_RX_FLOW_ON)
- {
- USERIALDBG("RX flow ON");
- rx_flow_on = TRUE;
- }
}
if (n > 0)
for (idx=0; idx < CH_MAX; idx++)
userial_cb.fd[idx] = -1;
}
-
-void userial_pause_reading(void) {
- if (userial_running)
- send_wakeup_signal(USERIAL_RX_FLOW_OFF);
-}
-
-void userial_resume_reading(void) {
- if (userial_running)
- send_wakeup_signal(USERIAL_RX_FLOW_ON);
-}