5G Academy / Mbed 2 deprecated Gruppo_Temperature

Dependencies:   mbed X_NUCLEO_IKS01A2

Revision:
0:1473d1ad6c5d
Child:
1:8d29427339c0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 22 13:15:26 2020 +0000
@@ -0,0 +1,62 @@
+#include "mbed.h"
+#include "string.h"
+
+void modem_at_cmd(char*,int);
+void wait4join(void);
+
+Serial pc(D1,D0,115200);
+Serial lora(PB_6,PA_10,115200);
+
+char c;
+
+char* msg1 = {"AT"};
+char* msg2 = {"AT+APPEUI=0000000000000001"};
+char* msg3 = {"AT+AK=00000000000000000000000000000001"};
+char* msg4 = {"AT+JOIN=1"};
+char* msg5 = {"AT+SEND=15,3031323334,0"};
+
+int main()
+{
+    pc.printf("Test seriale no pc\r\n");
+    modem_at_cmd(msg1,(int)strlen(msg1));
+    pc.printf("Inviato AT\r\n");
+    wait(1);
+    modem_at_cmd(msg2,(int)strlen(msg2));
+    pc.printf("Inviato EUI\r\n");
+    wait(1);
+    modem_at_cmd(msg3,(int)strlen(msg3));
+    pc.printf("Inviato AK\r\n");
+    wait(1);
+    modem_at_cmd(msg4,(int)strlen(msg4));
+    pc.printf("Inviato JOIN\r\n");
+    wait4join();
+    modem_at_cmd(msg5,(int)strlen(msg5));
+    pc.printf("Inviato send\r\n");
+}
+
+void modem_at_cmd(char* buffer, int n){
+    for(uint8_t i=0; i<n; i++) {
+        lora.putc(buffer[i]);
+        pc.putc(buffer[i]);
+    }
+    lora.putc(13);
+    pc.putc(13);
+    pc.printf("\n");
+    c=0;
+    do {
+        if (lora.readable()) {
+            c = lora.getc();
+            pc.putc(c);
+        }
+    } while(c!=' ');
+}
+
+void wait4join(){
+    c=0;
+    do {
+        if (lora.readable()) {
+            c = lora.getc();
+            pc.putc(c);
+        }
+    }while(c!='d');
+}
\ No newline at end of file