I'm trying to configure UART functionality in my program, and in the event handler under APP_UART_DATA_READY I'm missing bytes that I should normally have received. The code is as simple as the following:
case APP_UART_DATA_READY: { uint8_t ch; app_uart_get(&ch); uart_data[uart_data_size++] = ch; // Flash the LED, not needed but just to make sure we're hitting this code for (int i = 0; i < 1; i++) { nrf_gpio_pin_toggle(LED_1); nrf_delay_ms(50); nrf_gpio_pin_toggle(LED_1); nrf_delay_ms(50); } if (uart_data_size == SMARTLINK_DATA_SIZE) { // Process further and advertise... } } break;
The above works fine when I send individual characters (through PUTTY or another device UART), but problems arise when a lot of characters are sent to it at once (for example, in PUTTY setting local echo and local line editing to on). Baud rate is 115200. APP_IRQ_PRIORITY_LOW in uart fifo init. I really have to idea regarding what can be wrong. No scanning or advertising is working at the moment the code is hit. Initialization of UART is same as in ble_app_uart.
The problem really starts showing when I send 8 or more bytes concurrently (ie. type 7 characters in PUTTY and then the CR). For less than that I can eventually see the data being advertised and the LED will flash the right number of times (ie. type "abc" and press Enter then the LED flashes 4 times). However for 8 bytes the LED will indeed flash one, but then it won't read anythiing. The state of my uart_data buffer is as though nothing has been read at all!