اطلاعیه

Collapse
No announcement yet.

پروژه ساده در keil برای ارتباط stm32f1xx با SIM900

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    پروژه ساده در keil برای ارتباط stm32f1xx با SIM900

    با سلام

    من به دنبال یک پروژه ساده در keil برای ارسال یا دریافت SMS با stm32f1xx از طریق SIM900 هستم . متاسفانه در گوگل پیدا نکردم.

    با تشکر

    #2
    پاسخ : پروژه ساده در keil برای ارتباط stm32f1xx با SIM900



    int8_t answer;


    char response[100];


    //************************************************** ***********************************************
    unsigned long millis()
    {
    RunTime __rt= SystemTime();
    return __rt.startSEC;
    }

    //************************************************** ***********************************************

    int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout)
    {
    uint8_t x=0, answer=0;
    unsigned long previous;

    memset(response, '\0', 100); // Initialize the string
    delay(100);
    USART2_buffer_Init(); // Clean the input buffer
    USART2_WriteLine(ATcommand); // Send the AT command

    x = 0; previous = millis();

    do{
    if(USART2_DataReady() != 0)
    {
    response[x] = USART2_GetChar(); x++;
    if (strstr(response, expected_answer) != NULL){ answer = 1; }
    }
    }
    while((answer == 0) && ((millis() - previous) < timeout));

    return answer;
    }



    void SendTextMessage()
    {
    USART2_WriteLine("AT+CMGF=1\r" delay(1000);
    USART2_WriteLine("AT + CMGS = \"+989147366927\"" delay(1000);
    USART2_WriteLine("Salam Fathi Jooon..!" delay(1000);
    USART2_PutChar(26); delay(1000);
    USART2_WriteLine("\r\n"
    }





    :smile:
    The losers find problem in every answer but the winners find an answer in every problem

    FETAMAKER

    دیدگاه

    لطفا صبر کنید...
    X