This program send an AT command to the HC05 module and shows the response into a terminal.

Dependencies:   mbed-src MODSERIAL

Notebook page HERE

Revision:
0:7bb229e58814
Child:
1:a11db105c379
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 31 19:52:52 2012 +0000
@@ -0,0 +1,58 @@
+/*
+ * Author: Edoardo De Marchi
+ * Date: 31-05-12
+ * Notes: AT command
+*/
+
+#include "mbed.h"
+#include "MODSERIAL.h"
+
+
+MODSERIAL pc(USBTX, USBRX);      // tx, rx
+MODSERIAL blue(p9,p10);          // HC05
+DigitalOut led1(LED1);
+DigitalOut led4(LED4);
+
+
+void commandAT(char *v){
+
+  int i=0;
+  
+  while(v[i] != NULL){ 
+    blue.putc(v[i]);
+    i++;
+  }
+  
+  blue.printf("\r\n");
+}
+
+
+// This function is called when a character goes into the RX buffer.
+void rxCallback(MODSERIAL_IRQ_INFO *q) {
+    led4 = !led4;
+    pc.putc(blue.getc());
+}
+
+
+int main(){
+  
+   blue.baud(38400);
+   pc.baud(115200);
+
+   char s[80];
+   
+   while(1){
+        pc.printf("Command: ");
+        pc.scanf("%s",s);
+      
+        wait_us(100);
+      
+        commandAT(s);
+        wait_us(100);
+        
+        pc.printf("Response: ");
+      
+        blue.attach(&rxCallback, MODSERIAL::RxIrq);
+        wait(1);
+    } 
+}
\ No newline at end of file