cancel
Showing results for 
Search instead for 
Did you mean: 

GSM AT Command response

KPeri
Associate II

Hi

I am sending a AT command through USART2 -

char CGSN[] = "AT+CGSN\r\n";

HAL_UART_Transmit(&huart2,(uint8_t *)CGSN, sizeof(CGSN),100);

HAL_Delay(500);

 HAL_UART_Receive_IT(&huart2,(uint8_t *)&ch,1);

I am receiving ch in callback and storing each byte in a buffer

the response stored in buffer is - \r\n9876543212345\r\n\r\nOK\r\n

how do i filter out n" 9876543212345 "and "OK" and store in separately array

Thanks & Regards

3 REPLIES 3

You can use the standard C "strtok" function for example.

Also this question is not related to STM32, it's a general C language question.

Ayush
Associate

Can you please send a code for the same things because I working the same but using the DMA method but gsm doesn't reply for AT commands

Debug the code using polled or IRQ methods.

Modem can respond immediately so no random delays, be prepared to get data back. If modem not responding check UART connection to correct pins and baud rates, and is powered up properly. 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..