Test

main.cpp

Committer:
JohnnyK
Date:
2022-03-23
Revision:
4:928351381957
Parent:
3:17fe954e8cfc
Child:
5:70b84276766a

File content as of revision 4:928351381957:

#include "mbed.h"

/* !!!Change pins according to your connection!!! */
BufferedSerial uart(D10,D2, 115200); // UART TX, RX
ATCmdParser module(&uart,"\r\n");


// setup
int main() {
    printf("Mbed A9G test\n");
    module.debug_on(true);
    bool result = false;
    for(int i=0;i<5;i++){
        module.send("AT");
        thread_sleep_for(500);
        result =  module.recv("OK");
        if(result){
            break;
        }
    }
    if(result){
        printf("Module is up!\n");  
    } else {
        printf("No communication with module!\n");  
    }

    // loop
    while(true)
    {
        //do something in loop
        thread_sleep_for(1000);
    }
}