BLuetooth HC05 AT mode ENSMM CROC

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jimbaud
Date:
Mon Jan 18 16:45:44 2021 +0000
Parent:
7:804c6a1f49ce
Commit message:
BLuetooth HC05 AT mode

Changed in this revision

MODSERIAL.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/MODSERIAL.lib	Tue Aug 12 18:48:24 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/edodm85/code/MODSERIAL/#4213f9a7c3ad
--- a/main.cpp	Tue Aug 12 18:48:24 2014 +0000
+++ b/main.cpp	Mon Jan 18 16:45:44 2021 +0000
@@ -1,105 +1,30 @@
-/*
- * Author: Edoardo De Marchi
- * Date: 12-08-14
- * Notes: HC05 AT command
-*/
-
 #include "mbed.h"
-#include "MODSERIAL.h"
-
-
-MODSERIAL pc(USBTX, USBRX); 
-DigitalOut led1(LED1);
-
-    
-#if   defined(TARGET_LPC1768)
-MODSERIAL blue(p9, p10);          // TX = P9  RX = P10
-//MODSERIAL blue(p13, p14);         // TX = P13  RX = P14
-#elif defined(TARGET_LPC4330_M4)
-MODSERIAL blue(UART0_TX, UART0_RX);        // P6_4, P6_5
-//MODSERIAL blue(UART3_TX, UART3_RX);        // P2_3, P2_4
-#endif
-
-
-
-
-bool new_send = false;
-bool new_response = false;
-char ATCmd[80];
-char blueChar[80];
-
-
-void commandAT(char *v)         // Send the AT command
-{        
-
-  int i=0;
-  
-  while(v[i] != NULL)
-  { 
-    blue.putc(v[i]);
-    i++;
-  } 
-  blue.printf("\r\n");
-}
+ signed value;
+Serial pc(USBTX, USBRX);
+ 
+Serial blue(D8, D2);          // TX, RX
 
 
-// This function is called when a character goes into the RX buffer.
-void rxBlueCallback(MODSERIAL_IRQ_INFO *q) 
-{
-    new_response = true;
-}
-
-// This function is called when a character goes into the RX buffer.
-void rxPcCallback(MODSERIAL_IRQ_INFO *q) 
-{
-    new_send = true;
-}
-
+DigitalOut myled(LED1);
 
-int main()
+int main() 
 {
-   blue.baud(38400);
-   pc.baud(115200);
-   
-   blue.attach(&rxBlueCallback);
-   pc.attach(&rxPcCallback);
+    blue.baud(38400);
+    pc.baud(9600);
+    pc.printf("Bluetooth Start\r\n");
     
-   pc.printf("AT Mode Start\r\n"); 
-   int i = 0;
-   
-   while(1)
-   {
-        if(new_send)
+    // echo back characters and toggle the LED
+    while (1) 
+    {
+        if (blue.readable()) 
         {
-            int i = 0;
-        
-            while(pc.readable())
-            {
-                ATCmd[i] = pc.getc();
-                i++;
-            }
-            commandAT(ATCmd);
-            memset(ATCmd, 0, sizeof(ATCmd));
-            new_send = false;
-        }else
-        if(new_response)
+            pc.putc(blue.getc());
+            myled = !myled;
+        }
+        if (pc.readable()) 
         {
-            int i = 0;
-            while(blue.readable())
-            {
-                blueChar[i] = blue.getc();
-                i++;
-            }
-            printf("Response: %s", blueChar); 
-            memset(blueChar, 0, sizeof(blueChar)); 
-            new_response = false;   
-        }    
-        wait_ms(100);
-        i++;
-        if(i == 5)
-        {
-            led1 = !led1;
-            i=0;    
+            blue.putc(pc.getc());
+            myled = !myled;
         }
-    } 
+    }
 }
\ No newline at end of file
--- a/mbed-src.lib	Tue Aug 12 18:48:24 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed-src/#4abd2456cfa5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jan 18 16:45:44 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file