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

Dependents:   DISCO-F746NG_rtos_test MbedTableControl

Embed: (wiki syntax)

« Back to documentation index

HC06Bluetooth Class Reference

HC06Bluetooth Class Reference

This class creates an object representing the HC06 Bluetooth Module The baud rate for the device is configured to be 115200. More...

#include <HC06Bluetooth.h>

Public Member Functions

 HC06Bluetooth (PinName TX, PinName RX, Baudrate baudrate=B115200, void(*lineCallbackFunc)(const char *readString, size_t strlen)=NULL, void(*charCallbackFunc)(char readChar)=NULL)
 Constructor for the HC06_Bluetooth class.
void runSetup (std::string deviceName, std::string PIN="1234")
 Run the setup routine to configure the device name and the device pin.
void print (const char *buffer)
 Print information in buffer to the output.
void println (const char *buffer)
 Print information in buffer to the output followed by a newline.
void print (char c)
 Print a character to output.

Detailed Description

This class creates an object representing the HC06 Bluetooth Module The baud rate for the device is configured to be 115200.

Definition at line 22 of file HC06Bluetooth.h.


Constructor & Destructor Documentation

HC06Bluetooth ( PinName  TX,
PinName  RX,
Baudrate  baudrate = B115200,
void(*)(const char *readString, size_t strlen)  lineCallbackFunc = NULL,
void(*)(char readChar)  charCallbackFunc = NULL 
)

Constructor for the HC06_Bluetooth class.

Parameters:
TXThe pin that the TX line is attached to.
RXThe pin that the RX line is attached to.
deviceNameThe name that you want your system to be identified as when you connect to it i.e. "Weimen's MAE433Robot"
passwordA 4-digit numeric PIN that you want your device to connect with. It defaults to "1234".
lineCallbackFuncThe callback function that will be called once a newline character is encountered on the receiving data. The callback function takes as an argument a string containing the line that has been read.
Remarks:
The callback function is run within within an interrupt service routine, so it should be written to be safe for ISRs.
Parameters:
charCallbackFuncA function that will be called once a new character has been read. It should return void and take as an argument the character that has been read.
Remarks:
The callback function is run within within an interrupt service routine, so it should be written to be safe for ISRs.

Definition at line 20 of file HC06Bluetooth.cpp.


Member Function Documentation

void print ( const char *  buffer )

Print information in buffer to the output.

Parameters:
bufferA null-terminated buffer containing the data you want to send.

Definition at line 104 of file HC06Bluetooth.cpp.

void print ( char  c )

Print a character to output.

Parameters:
charThe character you want to print to output.

Definition at line 116 of file HC06Bluetooth.cpp.

void println ( const char *  buffer )

Print information in buffer to the output followed by a newline.

Parameters:
bufferA null-terminated buffer containing the data you want to send.

Definition at line 110 of file HC06Bluetooth.cpp.

void runSetup ( std::string  deviceName,
std::string  PIN = "1234" 
)

Run the setup routine to configure the device name and the device pin.

Remarks:
: You only need to run this once during the entire time you have the module, since the device name and PIN are saved by the module itself! However, you may run the function again if you would like to change the deviceName or PIN.
Parameters:
deviceNameThe name of the device, as a string. It must only contain alphanumeric characters - no spaces allowed.
PINThe device PIN.

Definition at line 33 of file HC06Bluetooth.cpp.