Jan Kamidra
/
Mbed_A9G_test
Test
main.cpp@4:928351381957, 2022-03-23 (annotated)
- Committer:
- JohnnyK
- Date:
- Wed Mar 23 17:38:04 2022 +0000
- Revision:
- 4:928351381957
- Parent:
- 3:17fe954e8cfc
- Child:
- 5:70b84276766a
simplification of the whole example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JohnnyK | 0:aaec057956ca | 1 | #include "mbed.h" |
JohnnyK | 0:aaec057956ca | 2 | |
JohnnyK | 0:aaec057956ca | 3 | /* !!!Change pins according to your connection!!! */ |
JohnnyK | 4:928351381957 | 4 | BufferedSerial uart(D10,D2, 115200); // UART TX, RX |
JohnnyK | 0:aaec057956ca | 5 | ATCmdParser module(&uart,"\r\n"); |
JohnnyK | 0:aaec057956ca | 6 | |
JohnnyK | 0:aaec057956ca | 7 | |
JohnnyK | 0:aaec057956ca | 8 | // setup |
JohnnyK | 0:aaec057956ca | 9 | int main() { |
JohnnyK | 0:aaec057956ca | 10 | printf("Mbed A9G test\n"); |
JohnnyK | 0:aaec057956ca | 11 | module.debug_on(true); |
JohnnyK | 4:928351381957 | 12 | bool result = false; |
JohnnyK | 4:928351381957 | 13 | for(int i=0;i<5;i++){ |
JohnnyK | 4:928351381957 | 14 | module.send("AT"); |
JohnnyK | 4:928351381957 | 15 | thread_sleep_for(500); |
JohnnyK | 4:928351381957 | 16 | result = module.recv("OK"); |
JohnnyK | 4:928351381957 | 17 | if(result){ |
JohnnyK | 4:928351381957 | 18 | break; |
JohnnyK | 4:928351381957 | 19 | } |
JohnnyK | 4:928351381957 | 20 | } |
JohnnyK | 4:928351381957 | 21 | if(result){ |
JohnnyK | 0:aaec057956ca | 22 | printf("Module is up!\n"); |
JohnnyK | 0:aaec057956ca | 23 | } else { |
JohnnyK | 0:aaec057956ca | 24 | printf("No communication with module!\n"); |
JohnnyK | 0:aaec057956ca | 25 | } |
JohnnyK | 0:aaec057956ca | 26 | |
JohnnyK | 0:aaec057956ca | 27 | // loop |
JohnnyK | 0:aaec057956ca | 28 | while(true) |
JohnnyK | 0:aaec057956ca | 29 | { |
JohnnyK | 0:aaec057956ca | 30 | //do something in loop |
JohnnyK | 0:aaec057956ca | 31 | thread_sleep_for(1000); |
JohnnyK | 0:aaec057956ca | 32 | } |
JohnnyK | 0:aaec057956ca | 33 | } |