Test

Revision:
0:aaec057956ca
Child:
1:56cb59d5a0e6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 23 15:02:36 2022 +0000
@@ -0,0 +1,59 @@
+#include "mbed.h"
+#include<stdio.h>
+#include<string.h>
+
+/* !!!Change pins according to your connection!!! */
+DigitalOut RST_KEY(D4,0);
+DigitalOut LOW_PWR_KEY(D5,1);
+DigitalOut PWR_KEY(D6,1);
+
+/*DigitalOut LED_R(D7,1);
+DigitalOut LED_G(D8,1);
+DigitalOut LED_B(D9,1);*/
+
+
+/* !!!Change pins according to your connection!!! */
+BufferedSerial uart(D8,D2, 115200); // UART TX, RX
+ATCmdParser module(&uart,"\r\n");
+
+// init the module
+bool ModulePowerOn() {
+    int i=0;
+    bool result = false;
+    RST_KEY = 0;
+    thread_sleep_for(3000);
+    RST_KEY = 1;
+    thread_sleep_for(15000);
+
+    result =  module.recv("OK");
+    if(!result){
+        for(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);
+    }
+}
\ No newline at end of file