Jan Kamidra
/
Mbed_A9G_test
Test
Diff: main.cpp
- Revision:
- 4:928351381957
- Parent:
- 3:17fe954e8cfc
- Child:
- 5:70b84276766a
--- a/main.cpp Wed Mar 23 16:58:28 2022 +0000 +++ b/main.cpp Wed Mar 23 17:38:04 2022 +0000 @@ -1,32 +1,24 @@ #include "mbed.h" /* !!!Change pins according to your connection!!! */ -BufferedSerial uart(D10,D2 115200); // UART TX, RX +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()){ + 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");