static void *bt_rx_monitor(void *ptr) { UCHAR ucRxBuf[512]; int iPktLen; DBG("Thread %lu starts\n", rxThread); while (1){ memset(ucRxBuf, 0, sizeof(ucRxBuf)); int iPktLen = 0; // Receive HCI packet from BT Controller if(EM_BT_read(ucRxBuf, sizeof(ucRxBuf), &iPktLen)) { DBG("Send packet to PC\n"); // Send the packet to PC if(RELAYER_write(serial_fd, ucRxBuf, iPktLen)){ sched_yield(); continue; } else{ ERR("Send packet to PC failed\n"); pthread_kill(txThread, SIGRTMIN); break; } } else{ if (iPktLen == 0){ continue; } else{ ERR("Receive packet from BT Controller failed\n"); pthread_kill(txThread, SIGRTMIN); break; } } } return 0; }
void *bt_rx_monitor(void *ptr) { UCHAR ucRxBuf[512]; int iPktLen, i; while (!fExit){ memset(ucRxBuf, 0, sizeof(ucRxBuf)); int iPktLen = 0; // Receive HCI packet from BT chip if(EM_BT_read(ucRxBuf, sizeof(ucRxBuf), &iPktLen)){ // Dump Rx packet DBG("Send packet to PC:\n"); for (i = 0; i < iPktLen; i++) { DBG("%02x\n", ucRxBuf[i]); } // Send the packet to PC if(RELAYER_write(uart_fd, ucRxBuf, iPktLen)){ sched_yield(); continue; } else{ fExit = TRUE; } } else{ if (iPktLen == 0) continue; else{ ERR("Receive packet from BT chip failed\n"); fExit = TRUE; } } } return 0; }