Test

main.cpp

Committer:
JohnnyK
Date:
2022-03-23
Revision:
3:17fe954e8cfc
Parent:
2:e7101cf1ca6e
Child:
4:928351381957

File content as of revision 3:17fe954e8cfc:

#include "mbed.h"

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

// init the module
bool ModulePowerOn() {
    bool result = false;
    result =  module.recv("OK");
    if(!result){
        for(int i=0;i<10;i++){
            module.send("AT");
            thread_sleep_for(500);
            result =  module.recv("OK");
            if(result){
                break;
            }
        }
    }
    return result;
}

// setup
int main() {
   
    printf("Mbed A9G test\n");
    module.debug_on(true);
    if(ModulePowerOn()){
        printf("Module is up!\n");  
    } else {
        printf("No communication with module!\n");  
    }

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