rename BLECentralUart to BLEClientUart
This commit is contained in:
1 parent
1f65aa9a3c
commit
91a3aa0e9c
4 files changed
+22
-22
No files matched your search
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
#include <bluefruit.h>
|
||||
|
||||
BLECentralUart bleCentralUart;
|
||||
BLEClientUart bleCentralUart;
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
#include "services/BLEMidi.h"
|
||||
#include "services/BLEAncs.h"
|
||||
|
||||
#include "central_services/BLECentralUart.h"
|
||||
#include "central_services/BLEClientUart.h"
|
||||
|
||||
#define BLE_MAX_DATA_PER_MTU (GATT_MTU_SIZE_DEFAULT - 3)
|
||||
|
||||
|
||||
@@ -38,14 +38,14 @@
|
||||
|
||||
void bleuart_central_notify_cb(BLECentralCharacteristic& chr, uint8_t* data, uint16_t len);
|
||||
|
||||
BLECentralUart::BLECentralUart(uint16_t fifo_depth)
|
||||
BLEClientUart::BLEClientUart(uint16_t fifo_depth)
|
||||
: BLEClientService(BLEUART_UUID_SERVICE), _txd(BLEUART_UUID_CHR_TXD), _rxd(BLEUART_UUID_CHR_RXD),
|
||||
_fifo(fifo_depth, 1)
|
||||
{
|
||||
_rx_cb = NULL;
|
||||
}
|
||||
|
||||
bool BLECentralUart::begin(void)
|
||||
bool BLEClientUart::begin(void)
|
||||
{
|
||||
// Invoke base class begin()
|
||||
BLEClientService::begin();
|
||||
@@ -59,22 +59,22 @@ bool BLECentralUart::begin(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BLECentralUart::enableTXD(void)
|
||||
bool BLEClientUart::enableTXD(void)
|
||||
{
|
||||
return _txd.enableNotify();
|
||||
}
|
||||
|
||||
bool BLECentralUart::disableTXD(void)
|
||||
bool BLEClientUart::disableTXD(void)
|
||||
{
|
||||
return _txd.disableNotify();
|
||||
}
|
||||
|
||||
void BLECentralUart::setRxCallback( rx_callback_t fp)
|
||||
void BLEClientUart::setRxCallback( rx_callback_t fp)
|
||||
{
|
||||
_rx_cb = fp;
|
||||
}
|
||||
|
||||
bool BLECentralUart::discover(uint16_t conn_handle)
|
||||
bool BLEClientUart::discover(uint16_t conn_handle)
|
||||
{
|
||||
// Call BLECentralService discover
|
||||
VERIFY( BLEClientService::discover(conn_handle) );
|
||||
@@ -87,7 +87,7 @@ bool BLECentralUart::discover(uint16_t conn_handle)
|
||||
return true;
|
||||
}
|
||||
|
||||
void BLECentralUart::disconnect(void)
|
||||
void BLEClientUart::disconnect(void)
|
||||
{
|
||||
BLEClientService::disconnect();
|
||||
|
||||
@@ -96,7 +96,7 @@ void BLECentralUart::disconnect(void)
|
||||
|
||||
void bleuart_central_notify_cb(BLECentralCharacteristic& chr, uint8_t* data, uint16_t len)
|
||||
{
|
||||
BLECentralUart& uart_svc = (BLECentralUart&) chr.parentService();
|
||||
BLEClientUart& uart_svc = (BLEClientUart&) chr.parentService();
|
||||
uart_svc._fifo.write(data, len);
|
||||
|
||||
// invoke callback
|
||||
@@ -106,40 +106,40 @@ void bleuart_central_notify_cb(BLECentralCharacteristic& chr, uint8_t* data, uin
|
||||
/*------------------------------------------------------------------*/
|
||||
/* STREAM API
|
||||
*------------------------------------------------------------------*/
|
||||
int BLECentralUart::read (void)
|
||||
int BLEClientUart::read (void)
|
||||
{
|
||||
uint8_t ch;
|
||||
return read(&ch, 1) ? (int) ch : EOF;
|
||||
}
|
||||
|
||||
int BLECentralUart::read (uint8_t * buf, size_t size)
|
||||
int BLEClientUart::read (uint8_t * buf, size_t size)
|
||||
{
|
||||
return _fifo.read(buf, size);
|
||||
}
|
||||
|
||||
size_t BLECentralUart::write (uint8_t b)
|
||||
size_t BLEClientUart::write (uint8_t b)
|
||||
{
|
||||
return write(&b, 1);
|
||||
}
|
||||
|
||||
size_t BLECentralUart::write (const uint8_t *content, size_t len)
|
||||
size_t BLEClientUart::write (const uint8_t *content, size_t len)
|
||||
{
|
||||
// do nothing
|
||||
return _rxd.write(content, len);
|
||||
}
|
||||
|
||||
int BLECentralUart::available (void)
|
||||
int BLEClientUart::available (void)
|
||||
{
|
||||
return _fifo.count();
|
||||
}
|
||||
|
||||
int BLECentralUart::peek (void)
|
||||
int BLEClientUart::peek (void)
|
||||
{
|
||||
uint8_t ch;
|
||||
return _fifo.peek(&ch) ? (int) ch : EOF;
|
||||
}
|
||||
|
||||
void BLECentralUart::flush (void)
|
||||
void BLEClientUart::flush (void)
|
||||
{
|
||||
_fifo.clear();
|
||||
}
|
||||
+5
-5
@@ -33,8 +33,8 @@
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
#ifndef BLECENTRALUART_H_
|
||||
#define BLECENTRALUART_H_
|
||||
#ifndef BLECLIENTUART_H_
|
||||
#define BLECLIENTUART_H_
|
||||
|
||||
#include "bluefruit_common.h"
|
||||
#include "utility/adafruit_fifo.h"
|
||||
@@ -44,12 +44,12 @@
|
||||
|
||||
#include "services/BLEUart.h"
|
||||
|
||||
class BLECentralUart : public BLEClientService, public Stream
|
||||
class BLEClientUart : public BLEClientService, public Stream
|
||||
{
|
||||
public:
|
||||
typedef void (*rx_callback_t) (void);
|
||||
|
||||
BLECentralUart(uint16_t fifo_depth = BLE_UART_DEFAULT_FIFO_DEPTH);
|
||||
BLEClientUart(uint16_t fifo_depth = BLE_UART_DEFAULT_FIFO_DEPTH);
|
||||
|
||||
virtual bool begin(void);
|
||||
virtual bool discover(uint16_t conn_handle);
|
||||
@@ -84,4 +84,4 @@ class BLECentralUart : public BLEClientService, public Stream
|
||||
friend void bleuart_central_notify_cb(BLECentralCharacteristic& chr, uint8_t* data, uint16_t len);
|
||||
};
|
||||
|
||||
#endif /* BLECENTRALUART_H_ */
|
||||
#endif /* BLECLIENTUART_H_ */
|
||||
Reference in new issue
Block a user