Driver for the JY-MCU v1.06 HC-06 Bluetooth module.

Dependents:   DISCO-F746NG_rtos_test MbedTableControl

Revision:
2:7e0453895727
Parent:
1:026034717620
Child:
3:ee17212e838e
--- a/HC06Bluetooth.cpp	Mon Jun 06 02:40:00 2016 +0000
+++ b/HC06Bluetooth.cpp	Tue Jun 07 18:10:14 2016 +0000
@@ -8,8 +8,8 @@
 #include <HC06Bluetooth.hpp>
 #include <algorithm>
 
-HC06Bluetooth::HC06Bluetooth(PinName TX, PinName RX, std::string deviceName)
-: btSerialObj(TX, RX) {
+HC06Bluetooth::HC06Bluetooth(PinName TX, PinName RX, std::string deviceName, void (*callbackFunc) (const char* readString))
+: btSerialObj(TX, RX), callbackFunc (callbackFunc) {
     // The default baud rate is 9600. Overwrite it to 230400.
     btSerialObj.puts("AT+BAUD9");
     btSerialObj.baud(230400);
@@ -28,10 +28,6 @@
     btSerialObj.puts(buffer);
 }
 
-void HC06Bluetooth::setCallback(void (*callbackFunc) (const char* readString)) {
-    HC06Bluetooth::callbackFunc = callbackFunc;
-}
-
 void HC06Bluetooth::receiveByteISR() {
     while(btSerialObj.readable()) {
         // Get the character from the input.
@@ -54,5 +50,5 @@
             dataReceivedBufferPos++;
         }
     }
+}
 
-}