77 lines
1.7 KiB
C++
77 lines
1.7 KiB
C++
#include "BluetoothSerial.h"
|
|
|
|
class BTSerialInterface
|
|
{
|
|
public:
|
|
virtual bool begin(String deviceName) = 0;
|
|
virtual void disconnect() = 0;
|
|
virtual void end() = 0;
|
|
virtual esp_err_t register_callback(esp_spp_cb_t * callback) = 0;
|
|
virtual void setTimeout(unsigned long timeout) = 0;
|
|
|
|
virtual int available() = 0;
|
|
virtual bool hasClient() = 0;
|
|
virtual size_t readBytes(uint8_t *buffer, size_t bufferSize) = 0;
|
|
|
|
//virtual bool isCongested() = 0;
|
|
virtual size_t write(const uint8_t *buffer, size_t size) = 0;
|
|
virtual void flush() = 0;
|
|
};
|
|
|
|
|
|
class BTClassicSerial : public virtual BTSerialInterface, public BluetoothSerial
|
|
{
|
|
// Everything is already implemented in BluetoothSerial since the code was
|
|
// originally written using that class
|
|
public:
|
|
bool begin(String deviceName)
|
|
{
|
|
return BluetoothSerial::begin(deviceName);
|
|
}
|
|
|
|
void disconnect()
|
|
{
|
|
BluetoothSerial::disconnect();
|
|
}
|
|
|
|
void end()
|
|
{
|
|
BluetoothSerial::end();
|
|
}
|
|
|
|
esp_err_t register_callback(esp_spp_cb_t * callback)
|
|
{
|
|
return BluetoothSerial::register_callback(callback);
|
|
}
|
|
|
|
void setTimeout(unsigned long timeout)
|
|
{
|
|
BluetoothSerial::setTimeout(timeout);
|
|
}
|
|
|
|
int available()
|
|
{
|
|
return BluetoothSerial::available();
|
|
}
|
|
|
|
bool hasClient()
|
|
{
|
|
return BluetoothSerial::hasClient();
|
|
}
|
|
|
|
size_t readBytes(uint8_t *buffer, size_t bufferSize)
|
|
{
|
|
return BluetoothSerial::readBytes(buffer, bufferSize);
|
|
}
|
|
|
|
size_t write(const uint8_t *buffer, size_t size)
|
|
{
|
|
return BluetoothSerial::write(buffer, size);
|
|
}
|
|
|
|
void flush()
|
|
{
|
|
BluetoothSerial::flush();
|
|
}
|
|
};
|