rename BLECentralCharacteristic to BLEClientCharacteristic

This commit is contained in:
hathach committed 2017-04-12 13:39:02 +07:00
1 parent 3d0014fa8a
commit 2733036325
13 files changed
+64 -64

No files matched your search

+1 -1
View File
@@ -65,7 +65,7 @@ void adafruit_callback_task(void* arg)
break;
case BLECentralCharacteristic_notify_cb_t:
((BLECentralCharacteristic::notify_cb_t) func) ( *((BLECentralCharacteristic*) args[0]), (uint8_t*) args[1], (uint16_t) args[2] );
((BLEClientCharacteristic::notify_cb_t) func) ( *((BLEClientCharacteristic*) args[0]), (uint8_t*) args[1], (uint16_t) args[2] );
break;
default: VERIFY_MESS(NRF_ERROR_INVALID_PARAM); break;
+1 -1
View File
@@ -41,9 +41,9 @@
#include "BLEUuid.h"
#include "BLECharacteristic.h"
#include "BLEClientCharacteristic.h"
#include "BLEService.h"
#include "BLECentralCharacteristic.h"
#include "BLEClientService.h"
@@ -39,7 +39,7 @@
#define MAX_DESCIRPTORS 8
void BLECentralCharacteristic::_init(void)
void BLEClientCharacteristic::_init(void)
{
varclr(&_chr);
_cccd_handle = 0;
@@ -49,39 +49,39 @@ void BLECentralCharacteristic::_init(void)
_sem = NULL;
}
BLECentralCharacteristic::BLECentralCharacteristic(void)
BLEClientCharacteristic::BLEClientCharacteristic(void)
: uuid()
{
_init();
}
BLECentralCharacteristic::BLECentralCharacteristic(BLEUuid bleuuid)
BLEClientCharacteristic::BLEClientCharacteristic(BLEUuid bleuuid)
: uuid(bleuuid)
{
_init();
}
void BLECentralCharacteristic::assign(ble_gattc_char_t* gattc_chr)
void BLEClientCharacteristic::assign(ble_gattc_char_t* gattc_chr)
{
_chr = *gattc_chr;
}
void BLECentralCharacteristic::useAdaCallback(bool enabled)
void BLEClientCharacteristic::useAdaCallback(bool enabled)
{
_use_AdaCallback = enabled;
}
uint16_t BLECentralCharacteristic::valueHandle()
uint16_t BLEClientCharacteristic::valueHandle()
{
return _chr.handle_value;
}
BLEClientService& BLECentralCharacteristic::parentService (void)
BLEClientService& BLEClientCharacteristic::parentService (void)
{
return *_service;
}
bool BLECentralCharacteristic::discoverDescriptor(uint16_t conn_handle)
bool BLEClientCharacteristic::discoverDescriptor(uint16_t conn_handle)
{
struct {
uint16_t count;
@@ -104,7 +104,7 @@ bool BLECentralCharacteristic::discoverDescriptor(uint16_t conn_handle)
return true;
}
void BLECentralCharacteristic::begin(void)
void BLEClientCharacteristic::begin(void)
{
// Add UUID128 if needed
uuid.begin();
@@ -118,7 +118,7 @@ void BLECentralCharacteristic::begin(void)
/*------------------------------------------------------------------*/
/* READ
*------------------------------------------------------------------*/
uint16_t BLECentralCharacteristic::read(void* buffer, int bufsize)
uint16_t BLEClientCharacteristic::read(void* buffer, int bufsize)
{
// TODO implement READ
// VERIFY_STATUS( sd_ble_gattc_read(Bluefruit.Central.connHandle(), _chr.handle_value, offset), 0 );
@@ -129,7 +129,7 @@ uint16_t BLECentralCharacteristic::read(void* buffer, int bufsize)
/*------------------------------------------------------------------*/
/* WRITE
*------------------------------------------------------------------*/
uint16_t BLECentralCharacteristic::write_resp(const void* data, int len)
uint16_t BLEClientCharacteristic::write_resp(const void* data, int len)
{
// Break into multiple MTU-3 packet
// TODO Currently SD132 v2.0 MTU is fixed with max payload = 20
@@ -178,7 +178,7 @@ uint16_t BLECentralCharacteristic::write_resp(const void* data, int len)
return len - remaining;
}
uint16_t BLECentralCharacteristic::write(const void* data, int len)
uint16_t BLEClientCharacteristic::write(const void* data, int len)
{
// Break into multiple MTU-3 packet
// TODO Currently SD132 v2.0 MTU is fixed with max payload = 20
@@ -216,12 +216,12 @@ uint16_t BLECentralCharacteristic::write(const void* data, int len)
return len;
}
void BLECentralCharacteristic::setNotifyCallback(notify_cb_t fp)
void BLEClientCharacteristic::setNotifyCallback(notify_cb_t fp)
{
_notify_cb = fp;
}
bool BLECentralCharacteristic::writeCCCD(uint16_t value)
bool BLEClientCharacteristic::writeCCCD(uint16_t value)
{
const uint16_t conn_handle = _service->connHandle();
@@ -243,29 +243,29 @@ bool BLECentralCharacteristic::writeCCCD(uint16_t value)
return true;
}
bool BLECentralCharacteristic::enableNotify(void)
bool BLEClientCharacteristic::enableNotify(void)
{
VERIFY( _chr.char_props.notify );
return writeCCCD(0x0001);
}
bool BLECentralCharacteristic::disableNotify(void)
bool BLEClientCharacteristic::disableNotify(void)
{
return writeCCCD(0x0000);
}
bool BLECentralCharacteristic::enableIndicate (void)
bool BLEClientCharacteristic::enableIndicate (void)
{
VERIFY( _chr.char_props.indicate );
return writeCCCD(0x0002);
}
bool BLECentralCharacteristic::disableIndicate (void)
bool BLEClientCharacteristic::disableIndicate (void)
{
return writeCCCD(0x0000);
}
void BLECentralCharacteristic::_eventHandler(ble_evt_t* evt)
void BLEClientCharacteristic::_eventHandler(ble_evt_t* evt)
{
switch(evt->header.evt_id)
{
@@ -33,8 +33,8 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**************************************************************************/
#ifndef BLECENTRALCHARACTERISTIC_H_
#define BLECENTRALCHARACTERISTIC_H_
#ifndef BLECLIENTCHARACTERISTIC_H_
#define BLECLIENTCHARACTERISTIC_H_
#include "bluefruit_common.h"
#include "BLEUuid.h"
@@ -43,16 +43,16 @@
// Forward declaration
class BLEClientService;
class BLECentralCharacteristic
class BLEClientCharacteristic
{
public:
typedef void (*notify_cb_t ) (BLECentralCharacteristic& chr, uint8_t* data, uint16_t len);
typedef void (*indicate_cb_t) (BLECentralCharacteristic& chr, uint8_t* data, uint16_t len);
typedef void (*notify_cb_t ) (BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
typedef void (*indicate_cb_t) (BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
BLEUuid uuid;
BLECentralCharacteristic(void);
BLECentralCharacteristic(BLEUuid bleuuid);
BLEClientCharacteristic(void);
BLEClientCharacteristic(BLEUuid bleuuid);
void assign(ble_gattc_char_t* gattc_chr);
bool discoverDescriptor(uint16_t conn_handle);
@@ -97,4 +97,4 @@ class BLECentralCharacteristic
friend class BLEGatt;
};
#endif /* BLECENTRALCHARACTERISTIC_H_ */
#endif /* BLECLIENTCHARACTERISTIC_H_ */
@@ -84,7 +84,7 @@ bool BLEDiscovery::_discoverService(uint16_t conn_handle, BLEClientService& svc,
return false;
}
uint8_t BLEDiscovery::discoverCharacteristic(uint16_t conn_handle, BLECentralCharacteristic* chr[], uint8_t count)
uint8_t BLEDiscovery::discoverCharacteristic(uint16_t conn_handle, BLEClientCharacteristic* chr[], uint8_t count)
{
uint8_t found = 0;
+12 -12
View File
@@ -38,9 +38,9 @@
#include <Arduino.h>
#include "bluefruit_common.h"
#include "BLEClientCharacteristic.h"
#include "BLEUuid.h"
#include "BLECentralCharacteristic.h"
#include "BLEClientService.h"
#define BLE_DISCOVERY_TIMEOUT 1000
@@ -62,35 +62,35 @@ class BLEDiscovery
void begin(void);
bool begun(void);
uint8_t discoverCharacteristic(uint16_t conn_handle, BLECentralCharacteristic* chr[], uint8_t count);
uint8_t discoverCharacteristic(uint16_t conn_handle, BLEClientCharacteristic* chr[], uint8_t count);
uint8_t discoverCharacteristic(uint16_t conn_handle, BLECentralCharacteristic& chr1)
uint8_t discoverCharacteristic(uint16_t conn_handle, BLEClientCharacteristic& chr1)
{
BLECentralCharacteristic* chr_arr[] = {&chr1};
BLEClientCharacteristic* chr_arr[] = {&chr1};
return discoverCharacteristic(conn_handle, chr_arr, arrcount(chr_arr));
}
uint8_t discoverCharacteristic(uint16_t conn_handle, BLECentralCharacteristic& chr1, BLECentralCharacteristic& chr2)
uint8_t discoverCharacteristic(uint16_t conn_handle, BLEClientCharacteristic& chr1, BLEClientCharacteristic& chr2)
{
BLECentralCharacteristic* chr_arr[] = {&chr1, &chr2};
BLEClientCharacteristic* chr_arr[] = {&chr1, &chr2};
return discoverCharacteristic(conn_handle, chr_arr, arrcount(chr_arr));
}
uint8_t discoverCharacteristic(uint16_t conn_handle, BLECentralCharacteristic& chr1, BLECentralCharacteristic& chr2, BLECentralCharacteristic& chr3)
uint8_t discoverCharacteristic(uint16_t conn_handle, BLEClientCharacteristic& chr1, BLEClientCharacteristic& chr2, BLEClientCharacteristic& chr3)
{
BLECentralCharacteristic* chr_arr[] = {&chr1, &chr2, &chr3};
BLEClientCharacteristic* chr_arr[] = {&chr1, &chr2, &chr3};
return discoverCharacteristic(conn_handle, chr_arr, arrcount(chr_arr));
}
uint8_t discoverCharacteristic(uint16_t conn_handle, BLECentralCharacteristic& chr1, BLECentralCharacteristic& chr2, BLECentralCharacteristic& chr3, BLECentralCharacteristic& chr4)
uint8_t discoverCharacteristic(uint16_t conn_handle, BLEClientCharacteristic& chr1, BLEClientCharacteristic& chr2, BLEClientCharacteristic& chr3, BLEClientCharacteristic& chr4)
{
BLECentralCharacteristic* chr_arr[] = {&chr1, &chr2, &chr3, &chr4};
BLEClientCharacteristic* chr_arr[] = {&chr1, &chr2, &chr3, &chr4};
return discoverCharacteristic(conn_handle, chr_arr, arrcount(chr_arr));
}
uint8_t discoverCharacteristic(uint16_t conn_handle, BLECentralCharacteristic& chr1, BLECentralCharacteristic& chr2, BLECentralCharacteristic& chr3, BLECentralCharacteristic& chr4, BLECentralCharacteristic& chr5)
uint8_t discoverCharacteristic(uint16_t conn_handle, BLEClientCharacteristic& chr1, BLEClientCharacteristic& chr2, BLEClientCharacteristic& chr3, BLEClientCharacteristic& chr4, BLEClientCharacteristic& chr5)
{
BLECentralCharacteristic* chr_arr[] = {&chr1, &chr2, &chr3, &chr4, &chr5};
BLEClientCharacteristic* chr_arr[] = {&chr1, &chr2, &chr3, &chr4, &chr5};
return discoverCharacteristic(conn_handle, chr_arr, arrcount(chr_arr));
}
+1 -1
View File
@@ -89,7 +89,7 @@ bool BLEGatt::_addCharacteristic(BLECharacteristic* chr)
bool BLEGatt::_addCharacteristic(BLECentralCharacteristic* chr)
bool BLEGatt::_addCharacteristic(BLEClientCharacteristic* chr)
{
VERIFY( client._chars_count < BLE_GATT_MAX_CLIENT_CHARS );
client._chars_list[ client._chars_count++ ] = chr;
+3 -3
View File
@@ -41,9 +41,9 @@
#include "BLEUuid.h"
#include "BLECharacteristic.h"
#include "BLEClientCharacteristic.h"
#include "BLEService.h"
#include "BLECentralCharacteristic.h"
#include "BLEClientService.h"
#define BLE_GATT_MAX_SERVER_CHARS 40
@@ -66,7 +66,7 @@ class BLEGatt
bool _addCharacteristic(BLECharacteristic* chr);
// Client
bool _addCharacteristic(BLECentralCharacteristic* chr);
bool _addCharacteristic(BLEClientCharacteristic* chr);
bool _addService(BLEClientService* svc);
void _eventHandler(ble_evt_t* evt);
@@ -82,7 +82,7 @@ class BLEGatt
BLEClientService* _svc_list[BLE_GATT_MAX_CLIENT_SERVICE];
uint8_t _chars_count;
BLECentralCharacteristic* _chars_list[BLE_GATT_MAX_CLIENT_CHARS];
BLEClientCharacteristic* _chars_list[BLE_GATT_MAX_CLIENT_CHARS];
}client;
};
+1 -1
View File
@@ -53,7 +53,7 @@
#include "BLEService.h"
#include "BLECentral.h"
#include "BLECentralCharacteristic.h"
#include "BLEClientCharacteristic.h"
#include "BLEClientService.h"
#include "BLEDiscovery.h"
#include "BLEGap.h"
@@ -36,7 +36,7 @@
#include "bluefruit.h"
void bleuart_central_notify_cb(BLECentralCharacteristic& chr, uint8_t* data, uint16_t len);
void bleuart_central_notify_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
BLEClientUart::BLEClientUart(uint16_t fifo_depth)
: BLEClientService(BLEUART_UUID_SERVICE), _txd(BLEUART_UUID_CHR_TXD), _rxd(BLEUART_UUID_CHR_RXD),
@@ -94,7 +94,7 @@ void BLEClientUart::disconnect(void)
flush();
}
void bleuart_central_notify_cb(BLECentralCharacteristic& chr, uint8_t* data, uint16_t len)
void bleuart_central_notify_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len)
{
BLEClientUart& uart_svc = (BLEClientUart&) chr.parentService();
uart_svc._fifo.write(data, len);
@@ -39,7 +39,7 @@
#include "bluefruit_common.h"
#include "utility/adafruit_fifo.h"
#include "BLECentralCharacteristic.h"
#include "BLEClientCharacteristic.h"
#include "BLEClientService.h"
#include "services/BLEUart.h"
@@ -75,13 +75,13 @@ class BLEClientUart : public BLEClientService, public Stream
virtual void disconnect(void);
private:
BLECentralCharacteristic _txd;
BLECentralCharacteristic _rxd;
BLEClientCharacteristic _txd;
BLEClientCharacteristic _rxd;
Adafruit_FIFO _fifo;
rx_callback_t _rx_cb;
friend void bleuart_central_notify_cb(BLECentralCharacteristic& chr, uint8_t* data, uint16_t len);
friend void bleuart_central_notify_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
};
#endif /* BLECLIENTUART_H_ */
@@ -38,8 +38,8 @@
#define BLE_ANCS_TIMEOUT (4*BLE_GENERIC_TIMEOUT)
void bleancs_notification_cb(BLECentralCharacteristic& chr, uint8_t* data, uint16_t len);
void bleancs_data_cb(BLECentralCharacteristic& chr, uint8_t* data, uint16_t len);
void bleancs_notification_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
void bleancs_data_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
/* ANCS Service : 7905F431-B5CE-4E99-A40F-4B1E122D00D0
* Notification Source : 9FBF120D-6301-42D9-8C58-25E699A21DBD
@@ -113,7 +113,7 @@ bool BLEAncs::discover(uint16_t conn_handle)
_conn_hdl = BLE_CONN_HANDLE_INVALID; // make as invalid until we found all chars
// Discover characteristics
BLECentralCharacteristic* chr_arr[] = { &_control, &_notification, &_data };
BLEClientCharacteristic* chr_arr[] = { &_control, &_notification, &_data };
VERIFY( 3 == Bluefruit.Discovery.discoverCharacteristic(conn_handle, chr_arr, 3) );
@@ -328,13 +328,13 @@ void BLEAncs::_handleData(uint8_t* data, uint16_t len)
/*------------------------------------------------------------------*/
/* Callback
*------------------------------------------------------------------*/
void bleancs_notification_cb(BLECentralCharacteristic& chr, uint8_t* data, uint16_t len)
void bleancs_notification_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len)
{
BLEAncs& svc = (BLEAncs&) chr.parentService();
svc._handleNotification(data, len);
}
void bleancs_data_cb(BLECentralCharacteristic& chr, uint8_t* data, uint16_t len)
void bleancs_data_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len)
{
BLEAncs& svc = (BLEAncs&) chr.parentService();
svc._handleData(data, len);
@@ -36,9 +36,9 @@
#ifndef BLEANCS_H_
#define BLEANCS_H_
#include "../BLEClientCharacteristic.h"
#include "bluefruit_common.h"
#include "BLECentralCharacteristic.h"
#include "BLEClientService.h"
extern const uint8_t BLEANCS_UUID_SERVICE[];
@@ -151,9 +151,9 @@ class BLEAncs : public BLEClientService
virtual void disconnect(void);
private:
BLECentralCharacteristic _control;
BLECentralCharacteristic _notification;
BLECentralCharacteristic _data;
BLEClientCharacteristic _control;
BLEClientCharacteristic _notification;
BLEClientCharacteristic _data;
notification_callback_t _notif_cb;
@@ -165,8 +165,8 @@ class BLEAncs : public BLEClientService
void _handleNotification(uint8_t* data, uint16_t len);
void _handleData(uint8_t* data, uint16_t len);
friend void bleancs_notification_cb(BLECentralCharacteristic& chr, uint8_t* data, uint16_t len);
friend void bleancs_data_cb (BLECentralCharacteristic& chr, uint8_t* data, uint16_t len);
friend void bleancs_notification_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
friend void bleancs_data_cb (BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
};