Skip to main content
KPeri
Associate
Mar 1, 2019 10:14 AM UTC
Question

GSM AT Command response

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

    This topic has been closed for replies.

    3 replies

    After Forever
    Senior III
    Mar 1, 2019 11:19 AM UTC

    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.

    Visitor II
    Oct 11, 2023 6:31 PM UTC

    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

    Tesla DeLorean
    Guru
    Oct 11, 2023 6:49 PM UTC

    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..