2018-11-26 11:58:15 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the "bluetoothheater" distribution
|
|
|
|
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Ray Jones <ray@mrjones.id.au>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-10-31 18:57:21 +00:00
|
|
|
|
|
|
|
#include "BluetoothAbstract.h"
|
2018-12-16 07:34:39 +00:00
|
|
|
#include "../Utility/Moderator.h"
|
2018-10-31 18:57:21 +00:00
|
|
|
|
|
|
|
// Define the serial port for access to a HC-05 module.
|
|
|
|
// This is generally Serial2, but different platforms use
|
|
|
|
// a different class for the implementation.
|
|
|
|
#ifdef __arm__
|
|
|
|
// for Arduino Due
|
|
|
|
static UARTClass& HC05_SerialPort(Serial2);
|
|
|
|
#else
|
|
|
|
// for Mega, ESP32
|
|
|
|
static HardwareSerial& HC05_SerialPort(Serial2);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// define a derived class that offers bluetooth messaging over the HC-05
|
|
|
|
|
|
|
|
class CBluetoothHC05 : public CBluetoothAbstract {
|
|
|
|
bool ATCommand(const char* str);
|
|
|
|
int _sensePin, _keyPin;
|
2018-12-15 09:34:58 +00:00
|
|
|
CModerator foldbackModerator;
|
2018-10-31 18:57:21 +00:00
|
|
|
public:
|
|
|
|
CBluetoothHC05(int keyPin, int sensePin);
|
2018-12-12 10:37:02 +00:00
|
|
|
void begin();
|
2018-12-13 12:19:10 +00:00
|
|
|
void send(const char* Str);
|
2018-10-31 18:57:21 +00:00
|
|
|
void check();
|
2018-11-14 11:12:18 +00:00
|
|
|
virtual bool isConnected();
|
2018-10-31 18:57:21 +00:00
|
|
|
protected:
|
|
|
|
virtual void openSerial(int baudrate);
|
2018-12-15 09:34:58 +00:00
|
|
|
virtual void foldbackDesiredTemp();
|
2019-01-10 05:01:52 +00:00
|
|
|
void flush();
|
2018-10-31 18:57:21 +00:00
|
|
|
};
|