rename BLECentralService to BLEClientService
This commit is contained in:
1 parent
266d99630b
commit
98fc8f54be
17 files changed
+50
-51
No files matched your search
+4
-4
@@ -18,9 +18,9 @@
|
||||
|
||||
### BLE Library
|
||||
|
||||
- Initial Central support
|
||||
- Add BLECentralService
|
||||
- Add BLECentralCharacteristic
|
||||
- Initial Central support and Gatt client service/characteristic
|
||||
- Add BLEClientService
|
||||
- Add BLEClientCharacteristic
|
||||
- Add BLEDiscovery
|
||||
- Add BLEGap and BLEGatt to manage peripheral & central with Gatt client and server support
|
||||
- BLE API changes
|
||||
@@ -33,7 +33,7 @@
|
||||
- Change BLEMid send/sendSplit return type from `err_t` to `bool`
|
||||
- New BLE Serivce
|
||||
- Apple Notification Center Service (ANCS)
|
||||
- Central BLE UART
|
||||
- BLEClientUart
|
||||
- Add separated Thread for callbacks to allow most functions API() to be invoked directly in the callback
|
||||
|
||||
#### New Examples
|
||||
|
||||
@@ -124,7 +124,7 @@ bool BLEAdvertising::addService(BLEService& service)
|
||||
return addUuid(service.uuid);
|
||||
}
|
||||
|
||||
bool BLEAdvertising::addService(BLECentralService& service)
|
||||
bool BLEAdvertising::addService(BLEClientService& service)
|
||||
{
|
||||
// Central service is added to Solicitation UUID
|
||||
switch ( service.uuid.size() )
|
||||
|
||||
@@ -38,11 +38,10 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "bluefruit_common.h"
|
||||
#include "BLEClientService.h"
|
||||
|
||||
#include "BLEUuid.h"
|
||||
#include "BLEService.h"
|
||||
#include "BLECentralService.h"
|
||||
|
||||
#include "services/BLEBeacon.h"
|
||||
|
||||
//enum
|
||||
@@ -70,7 +69,7 @@ public:
|
||||
|
||||
bool addUuid(BLEUuid bleuuid);
|
||||
bool addService(BLEService& service);
|
||||
bool addService(BLECentralService& service);
|
||||
bool addService(BLEClientService& service);
|
||||
|
||||
bool setBeacon(BLEBeacon& beacon);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "BLEService.h"
|
||||
|
||||
#include "BLECentralCharacteristic.h"
|
||||
#include "BLECentralService.h"
|
||||
#include "BLEClientService.h"
|
||||
|
||||
|
||||
class AdafruitBluefruit;
|
||||
|
||||
@@ -76,7 +76,7 @@ uint16_t BLECentralCharacteristic::valueHandle()
|
||||
return _chr.handle_value;
|
||||
}
|
||||
|
||||
BLECentralService& BLECentralCharacteristic::parentService (void)
|
||||
BLEClientService& BLECentralCharacteristic::parentService (void)
|
||||
{
|
||||
return *_service;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ void BLECentralCharacteristic::begin(void)
|
||||
// Add UUID128 if needed
|
||||
uuid.begin();
|
||||
|
||||
_service = BLECentralService::lastService;
|
||||
_service = BLEClientService::lastService;
|
||||
|
||||
// Register to Bluefruit (required for callback and write response)
|
||||
(void) Bluefruit.Gatt._addCharacteristic(this);
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include "BLECharacteristic.h"
|
||||
|
||||
// Forward declaration
|
||||
class BLECentralService;
|
||||
class BLEClientService;
|
||||
|
||||
class BLECentralCharacteristic
|
||||
{
|
||||
@@ -59,7 +59,7 @@ class BLECentralCharacteristic
|
||||
void begin(void);
|
||||
|
||||
uint16_t valueHandle();
|
||||
BLECentralService& parentService(void);
|
||||
BLEClientService& parentService(void);
|
||||
|
||||
/*------------- Read -------------*/
|
||||
uint16_t read(void* buffer, int bufsize);
|
||||
@@ -85,7 +85,7 @@ class BLECentralCharacteristic
|
||||
ble_gattc_char_t _chr;
|
||||
uint16_t _cccd_handle;
|
||||
|
||||
BLECentralService* _service;
|
||||
BLEClientService* _service;
|
||||
notify_cb_t _notify_cb;
|
||||
bool _use_AdaCallback; // whether callback is invoked in seperated task with AdaCallback
|
||||
|
||||
|
||||
@@ -37,27 +37,27 @@
|
||||
#include "bluefruit.h"
|
||||
|
||||
// Last service that is discovered
|
||||
BLECentralService* BLECentralService::lastService = NULL;
|
||||
BLEClientService* BLEClientService::lastService = NULL;
|
||||
|
||||
void BLECentralService::_init(void)
|
||||
void BLEClientService::_init(void)
|
||||
{
|
||||
_conn_hdl = BLE_CONN_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
BLECentralService::BLECentralService(void)
|
||||
BLEClientService::BLEClientService(void)
|
||||
: uuid()
|
||||
{
|
||||
_init();
|
||||
}
|
||||
|
||||
BLECentralService::BLECentralService(BLEUuid bleuuid)
|
||||
BLEClientService::BLEClientService(BLEUuid bleuuid)
|
||||
: uuid(bleuuid)
|
||||
{
|
||||
_init();
|
||||
}
|
||||
|
||||
|
||||
bool BLECentralService::begin(void)
|
||||
bool BLEClientService::begin(void)
|
||||
{
|
||||
// Add UUID128 if needed
|
||||
uuid.begin();
|
||||
@@ -68,24 +68,24 @@ bool BLECentralService::begin(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BLECentralService::discover(uint16_t conn_handle)
|
||||
bool BLEClientService::discover(uint16_t conn_handle)
|
||||
{
|
||||
VERIFY( Bluefruit.Discovery._discoverService(conn_handle, *this) );
|
||||
_conn_hdl = conn_handle;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BLECentralService::discovered(void)
|
||||
bool BLEClientService::discovered(void)
|
||||
{
|
||||
return _conn_hdl != BLE_CONN_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
uint16_t BLECentralService::connHandle(void)
|
||||
uint16_t BLEClientService::connHandle(void)
|
||||
{
|
||||
return _conn_hdl;
|
||||
}
|
||||
|
||||
void BLECentralService::disconnect(void)
|
||||
void BLEClientService::disconnect(void)
|
||||
{
|
||||
_conn_hdl = BLE_CONN_HANDLE_INVALID;
|
||||
// inherited service may want to clean up its own characteristic
|
||||
|
||||
+8
-8
@@ -1,6 +1,6 @@
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@file BLECentralService.h
|
||||
@file BLEClientService.h
|
||||
@author hathach
|
||||
|
||||
@section LICENSE
|
||||
@@ -33,13 +33,13 @@
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
#ifndef BLECENTRALSERVICE_H_
|
||||
#define BLECENTRALSERVICE_H_
|
||||
#ifndef BLECLIENTSERVICE_H_
|
||||
#define BLECLIENTSERVICE_H_
|
||||
|
||||
#include "bluefruit_common.h"
|
||||
#include "BLEUuid.h"
|
||||
|
||||
class BLECentralService
|
||||
class BLEClientService
|
||||
{
|
||||
protected:
|
||||
uint16_t _conn_hdl;
|
||||
@@ -48,12 +48,12 @@ class BLECentralService
|
||||
virtual void disconnect(void);
|
||||
|
||||
public:
|
||||
static BLECentralService* lastService;
|
||||
static BLEClientService* lastService;
|
||||
|
||||
BLEUuid uuid;
|
||||
|
||||
BLECentralService(void);
|
||||
BLECentralService(BLEUuid bleuuid);
|
||||
BLEClientService(void);
|
||||
BLEClientService(BLEUuid bleuuid);
|
||||
|
||||
virtual bool begin(void);
|
||||
|
||||
@@ -67,4 +67,4 @@ class BLECentralService
|
||||
|
||||
|
||||
|
||||
#endif /* BLECENTRALSERVICE_H_ */
|
||||
#endif /* BLECLIENTSERVICE_H_ */
|
||||
@@ -59,7 +59,7 @@ bool BLEDiscovery::begun(void)
|
||||
return (_sem != NULL);
|
||||
}
|
||||
|
||||
bool BLEDiscovery::_discoverService(uint16_t conn_handle, BLECentralService& svc, uint16_t start_handle)
|
||||
bool BLEDiscovery::_discoverService(uint16_t conn_handle, BLEClientService& svc, uint16_t start_handle)
|
||||
{
|
||||
ble_gattc_evt_prim_srvc_disc_rsp_t disc_svc;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
#include "BLEUuid.h"
|
||||
#include "BLECentralCharacteristic.h"
|
||||
#include "BLECentralService.h"
|
||||
#include "BLEClientService.h"
|
||||
|
||||
#define BLE_DISCOVERY_TIMEOUT 1000
|
||||
|
||||
@@ -99,7 +99,7 @@ class BLEDiscovery
|
||||
* Although declare as public, it is meant to be invoked by internal
|
||||
* code. User should not call these directly
|
||||
*------------------------------------------------------------------*/
|
||||
bool _discoverService(uint16_t conn_handle, BLECentralService& svc, uint16_t start_handle = 1);
|
||||
bool _discoverService(uint16_t conn_handle, BLEClientService& svc, uint16_t start_handle = 1);
|
||||
uint16_t _discoverDescriptor(uint16_t conn_handle, ble_gattc_evt_desc_disc_rsp_t* disc_desc, uint16_t max_count);
|
||||
|
||||
friend class AdafruitBluefruit;
|
||||
|
||||
@@ -97,7 +97,7 @@ bool BLEGatt::_addCharacteristic(BLECentralCharacteristic* chr)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BLEGatt::_addService(BLECentralService* svc)
|
||||
bool BLEGatt::_addService(BLEClientService* svc)
|
||||
{
|
||||
VERIFY( client._svc_count < BLE_GATT_MAX_CLIENT_SERVICE );
|
||||
client._svc_list[ client._svc_count++ ] = svc;
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "BLEService.h"
|
||||
|
||||
#include "BLECentralCharacteristic.h"
|
||||
#include "BLECentralService.h"
|
||||
#include "BLEClientService.h"
|
||||
|
||||
#define BLE_GATT_MAX_SERVER_CHARS 40
|
||||
|
||||
@@ -67,7 +67,7 @@ class BLEGatt
|
||||
|
||||
// Client
|
||||
bool _addCharacteristic(BLECentralCharacteristic* chr);
|
||||
bool _addService(BLECentralService* svc);
|
||||
bool _addService(BLEClientService* svc);
|
||||
|
||||
void _eventHandler(ble_evt_t* evt);
|
||||
|
||||
@@ -79,7 +79,7 @@ class BLEGatt
|
||||
|
||||
struct {
|
||||
uint8_t _svc_count;
|
||||
BLECentralService* _svc_list[BLE_GATT_MAX_CLIENT_SERVICE];
|
||||
BLEClientService* _svc_list[BLE_GATT_MAX_CLIENT_SERVICE];
|
||||
|
||||
uint8_t _chars_count;
|
||||
BLECentralCharacteristic* _chars_list[BLE_GATT_MAX_CLIENT_CHARS];
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
#include "BLECentral.h"
|
||||
#include "BLECentralCharacteristic.h"
|
||||
#include "BLECentralService.h"
|
||||
#include "BLEClientService.h"
|
||||
#include "BLEDiscovery.h"
|
||||
#include "BLEGap.h"
|
||||
#include "BLEGatt.h"
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
void bleuart_central_notify_cb(BLECentralCharacteristic& chr, uint8_t* data, uint16_t len);
|
||||
|
||||
BLECentralUart::BLECentralUart(uint16_t fifo_depth)
|
||||
: BLECentralService(BLEUART_UUID_SERVICE), _txd(BLEUART_UUID_CHR_TXD), _rxd(BLEUART_UUID_CHR_RXD),
|
||||
: BLEClientService(BLEUART_UUID_SERVICE), _txd(BLEUART_UUID_CHR_TXD), _rxd(BLEUART_UUID_CHR_RXD),
|
||||
_fifo(fifo_depth, 1)
|
||||
{
|
||||
_rx_cb = NULL;
|
||||
@@ -48,7 +48,7 @@ BLECentralUart::BLECentralUart(uint16_t fifo_depth)
|
||||
bool BLECentralUart::begin(void)
|
||||
{
|
||||
// Invoke base class begin()
|
||||
BLECentralService::begin();
|
||||
BLEClientService::begin();
|
||||
|
||||
_rxd.begin();
|
||||
_txd.begin();
|
||||
@@ -77,7 +77,7 @@ void BLECentralUart::setRxCallback( rx_callback_t fp)
|
||||
bool BLECentralUart::discover(uint16_t conn_handle)
|
||||
{
|
||||
// Call BLECentralService discover
|
||||
VERIFY( BLECentralService::discover(conn_handle) );
|
||||
VERIFY( BLEClientService::discover(conn_handle) );
|
||||
_conn_hdl = BLE_CONN_HANDLE_INVALID; // make as invalid until we found all chars
|
||||
|
||||
// Discover TXD, RXD characteristics
|
||||
@@ -89,7 +89,7 @@ bool BLECentralUart::discover(uint16_t conn_handle)
|
||||
|
||||
void BLECentralUart::disconnect(void)
|
||||
{
|
||||
BLECentralService::disconnect();
|
||||
BLEClientService::disconnect();
|
||||
|
||||
flush();
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@
|
||||
#include "utility/adafruit_fifo.h"
|
||||
|
||||
#include "BLECentralCharacteristic.h"
|
||||
#include "BLECentralService.h"
|
||||
#include "BLEClientService.h"
|
||||
|
||||
#include "services/BLEUart.h"
|
||||
|
||||
class BLECentralUart : public BLECentralService, public Stream
|
||||
class BLECentralUart : public BLEClientService, public Stream
|
||||
{
|
||||
public:
|
||||
typedef void (*rx_callback_t) (void);
|
||||
|
||||
@@ -72,7 +72,7 @@ const uint8_t BLEANCS_UUID_CHR_DATA[] =
|
||||
};
|
||||
|
||||
BLEAncs::BLEAncs(void)
|
||||
: BLECentralService(BLEANCS_UUID_SERVICE), _control(BLEANCS_UUID_CHR_CONTROL),
|
||||
: BLEClientService(BLEANCS_UUID_SERVICE), _control(BLEANCS_UUID_CHR_CONTROL),
|
||||
_notification(BLEANCS_UUID_CHR_NOTIFICATION), _data(BLEANCS_UUID_CHR_DATA)
|
||||
{
|
||||
_notif_cb = NULL;
|
||||
@@ -85,7 +85,7 @@ BLEAncs::BLEAncs(void)
|
||||
bool BLEAncs::begin(void)
|
||||
{
|
||||
// Invoke base class begin()
|
||||
BLECentralService::begin();
|
||||
BLEClientService::begin();
|
||||
|
||||
// Initialize Discovery module if needed
|
||||
if ( !Bluefruit.Discovery.begun() ) Bluefruit.Discovery.begin();
|
||||
@@ -109,7 +109,7 @@ bool BLEAncs::begin(void)
|
||||
bool BLEAncs::discover(uint16_t conn_handle)
|
||||
{
|
||||
// Call BLECentralService discover
|
||||
VERIFY( BLECentralService::discover(conn_handle) );
|
||||
VERIFY( BLEClientService::discover(conn_handle) );
|
||||
_conn_hdl = BLE_CONN_HANDLE_INVALID; // make as invalid until we found all chars
|
||||
|
||||
// Discover characteristics
|
||||
@@ -123,7 +123,7 @@ bool BLEAncs::discover(uint16_t conn_handle)
|
||||
|
||||
void BLEAncs::disconnect(void)
|
||||
{
|
||||
BLECentralService::disconnect();
|
||||
BLEClientService::disconnect();
|
||||
}
|
||||
|
||||
void BLEAncs::setNotificationCallback(notification_callback_t fp)
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "bluefruit_common.h"
|
||||
|
||||
#include "BLECentralCharacteristic.h"
|
||||
#include "BLECentralService.h"
|
||||
#include "BLEClientService.h"
|
||||
|
||||
extern const uint8_t BLEANCS_UUID_SERVICE[];
|
||||
extern const uint8_t BLEANCS_UUID_CHR_CONTROL[];
|
||||
@@ -129,7 +129,7 @@ typedef struct
|
||||
|
||||
VERIFY_STATIC( sizeof(AncsNotification_t) == 8);
|
||||
|
||||
class BLEAncs : public BLECentralService
|
||||
class BLEAncs : public BLEClientService
|
||||
{
|
||||
public:
|
||||
typedef void (*notification_callback_t) (AncsNotification_t* notif);
|
||||
|
||||
Reference in new issue
Block a user