Hi everyone.
I have a problem with processing with recived UART data. I'm using software UART from example > peripheral > uart.
I use nRF to comunicate with GSM module. When I send AT command need to check recived data. Example shows how react to one symbol i.e.:
while (true) { uint8_t cr; while (app_uart_get(&cr) != NRF_SUCCESS); while (app_uart_put(cr) != NRF_SUCCESS); if (cr == 'q' || cr == 'Q') { //do something }
I want to check if recived data contain words i.e.
check if recived data contain "+CGNSPWR=0
On the begining I tried to store recived data in array and then check it. Probably I do something wrong because my stored data contains message, but from few earlier receivs.
Thats my function:
void UART(void) { unsigned char data[100]; unsigned char finale[100]; uint32_t count = 0; uint32_t cr; uint32_t clean; while (1) { while (app_uart_get(&cr) != NRF_SUCCESS) ; if (cr != '\r') { data[count] = cr; count++; } else { for (uint32_t i = 0; i < clean; i++) { finale[i] = 0; } for (uint32_t i = 0; i < count; i++) { finale[i] = data[i]; } clean = count + 1; count = 0; break; } } }
I send message using app_uart_put() then use this UART(); function then Im checking finale[] if it contain what I need.
Can someone help me with that function?
Or any sugestion how to build neew one?