Skip to content
Snippets Groups Projects
Commit 765a0fc4 authored by schneider's avatar schneider
Browse files

change(ble): Better ble uart performance

parent ee5e69a4
No related branches found
No related tags found
1 merge request!446Initial MicroPython BLE support (GATTS)
...@@ -125,11 +125,10 @@ static uint8_t UARTWriteCback( ...@@ -125,11 +125,10 @@ static uint8_t UARTWriteCback(
return ATT_SUCCESS; return ATT_SUCCESS;
} }
static int ble_uart_lasttick = 0;
static bool done; static bool done;
static bool again; static bool again;
void ble_uart_flush(void) static void ble_uart_flush(void)
{ {
if (ble_uart_buf_tx_fill == 0) { if (ble_uart_buf_tx_fill == 0) {
return; return;
...@@ -140,10 +139,9 @@ void ble_uart_flush(void) ...@@ -140,10 +139,9 @@ void ble_uart_flush(void)
if (AttsCccEnabled(connId, UART_TX_CH_CCC_IDX)) { if (AttsCccEnabled(connId, UART_TX_CH_CCC_IDX)) {
done = false; done = false;
again = true; again = true;
int t0 = xTaskGetTickCount();
// TODO: Modify for no initial delay while (!done && ((xTaskGetTickCount() - t0) < 1000)) {
while (!done && ((xTaskGetTickCount() -
ble_uart_lasttick) < 1000)) {
if (again) { if (again) {
again = false; again = false;
AttsHandleValueNtf( AttsHandleValueNtf(
...@@ -153,15 +151,22 @@ void ble_uart_flush(void) ...@@ -153,15 +151,22 @@ void ble_uart_flush(void)
ble_uart_tx_buf ble_uart_tx_buf
); );
} }
vTaskDelay(5); /* This function is supposed to only be called
* from the API scheduler with lowest priority.
*
* If that is not the case anymore, use a delay
* instead of the yield. Ideally refactor to avoid
* the delay.
*/
//vTaskDelay(5);
taskYIELD();
} }
ble_uart_lasttick = xTaskGetTickCount();
} }
} }
ble_uart_buf_tx_fill = 0; ble_uart_buf_tx_fill = 0;
} }
void ble_uart_write_char(uint8_t c) static void ble_uart_write_char(uint8_t c)
{ {
ble_uart_tx_buf[ble_uart_buf_tx_fill] = c; ble_uart_tx_buf[ble_uart_buf_tx_fill] = c;
ble_uart_buf_tx_fill++; ble_uart_buf_tx_fill++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment