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

Dependents:   DISCO-F746NG_rtos_test MbedTableControl

Revision:
12:5ba022adbbfb
Parent:
11:aeb8c5c27111
Child:
15:6a0aeaa39291
--- a/HC06Bluetooth.h	Tue Aug 02 16:48:13 2016 +0000
+++ b/HC06Bluetooth.h	Tue Aug 02 20:16:26 2016 +0000
@@ -14,6 +14,8 @@
 #include <string>
 
 const int dataBufferSize = 256;
+// WARNING: DO NOT CHANGE THESE VALUES, AS THEY ARE USED TO INDEX INTO AN ARRAY FOR IMPLEMENTATION.
+enum Baudrate {B1200, B2400, B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800, B921600, B1382400, END};
 
 class HC06Bluetooth {
 public: // Public methods.
@@ -30,7 +32,7 @@
      * the character that has been read.
      * @remark The callback function is run within within an interrupt service routine, so it should be written to be safe for ISRs.
      */
-    HC06Bluetooth(PinName TX, PinName RX, void (*lineCallbackFunc) (const char* readString, size_t strlen) = NULL, void (*charCallbackFunc) (char readChar) = NULL);
+    HC06Bluetooth(PinName TX, PinName RX, Baudrate baudrate = B115200, void (*lineCallbackFunc) (const char* readString, size_t strlen) = NULL, void (*charCallbackFunc) (char readChar) = NULL);
     virtual ~HC06Bluetooth();
     /**
      * @brief Run the setup routine to configure the device name and the device pin.
@@ -58,6 +60,7 @@
 
 private:
     RawSerial btSerialObj;
+    Baudrate baudrate;
     void receiveByteISR();
     /// Pointer to a callback function the client provides when a line is received.
     void (*lineCallbackFunc) (const char*, size_t strlen);