-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathBluetoothSerial.h
More file actions
74 lines (51 loc) · 1.92 KB
/
Copy pathBluetoothSerial.h
File metadata and controls
74 lines (51 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*-------------------------------------------------------------------------
Arduino library for the Teensy3Bluetooth Serial shield available at the hackerspaceshop.com
Check it out here:
http://www.hackerspaceshop.com/teensy/teensy-3-1-bluetooth-module.html
Written by Amir Hassan and Florian Bittner for hackerspaceshop.com,
contributions by members of the open source community.
This is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see
<http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------*/
#ifndef __BLUETOOTHSERIAL_H__
#if (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#include <pins_arduino.h>
#endif
#include <Print.h>
#include <Stream.h>
#include <SoftwareSerial.h>
class BluetoothSerial : public Stream {
private:
SoftwareSerial mySerial;
public:
BluetoothSerial(int rx_pin, int tx_pin) : mySerial(rx_pin, tx_pin)
{}
~BluetoothSerial()
{}
void begin(unsigned long speed = 9600);
void end();
void setBaudrate(unsigned long speed);
void setPinCode(const char* pin_code);
void setDeviceName(const char* device_name);
virtual int available();
virtual int read();
virtual int peek();;
virtual void flush();
virtual size_t write(uint8_t c);
void onSerialConnectionChange(void (*userFunc)(void));
using Print::write;
};
extern BluetoothSerial BTSerial;
#endif