library for Bluetooth Shield from Seeed Studio
Fork of BluetoothSerial by
BluetoothSerial.h
00001 /** 00002 * The library is for Bluetooth Shield from Seeed Studio 00003 */ 00004 00005 #ifndef __BLUETOOTH_SERIAL_H__ 00006 #define __BLUETOOTH_SERIAL_H__ 00007 00008 #include "mbed.h" 00009 00010 #define BLUETOOTH_SERIAL_DEFAULT_BAUD 38400 00011 #define BLUETOOTH_SERIAL_TIMEOUT 10000 00012 #define BLUETOOTH_SERIAL_EOL "\r\n" 00013 00014 00015 class BluetoothSerial : public Stream { 00016 public: 00017 BluetoothSerial(PinName tx, PinName rx); 00018 00019 /** 00020 * Setup bluetooth module(serial port baud rate) 00021 */ 00022 void setup(); 00023 00024 /** 00025 * Set bluetooth module as a master 00026 * \param name device name 00027 * \param autoc 1: auto-connection, 0 not 00028 */ 00029 void master(const char *name, uint8_t autoc = 0); 00030 00031 /** 00032 * Set bluetooth module as a slave 00033 * \param name device name 00034 * \param autoc 1: auto-connection, 0 not 00035 * \param oaut 1: permit paired device to connect, 0: not 00036 */ 00037 void slave(const char *name, uint8_t autoc = 0, uint8_t oaut = 1); 00038 00039 /** 00040 * Inquire bluetooth devices and connect the specified device 00041 */ 00042 int connect(const char *name); 00043 00044 /** 00045 * Make the bluetooth module inquirable and available to connect, used in slave mode 00046 */ 00047 int connect(); 00048 00049 int readable() { 00050 return _serial.readable(); 00051 } 00052 00053 int writeable() { 00054 return _serial.writeable(); 00055 } 00056 00057 00058 protected: 00059 virtual int _getc(); 00060 virtual int _putc(int c); 00061 00062 void clear(); 00063 int readline(uint8_t *buf, int len, uint32_t timeout = 0); 00064 00065 Serial _serial; 00066 uint8_t _buf[64]; 00067 }; 00068 00069 #endif // __BLUETOOTH_SERIAL_H__
Generated on Sat Jul 16 2022 00:15:55 by
![doxygen](doxygen.png)