Adding BLEClientDis
- add get/set HandleRange for BLEDiscovery - implement destructor for BLEClientCharacteristic - add BLEGatt::_removeCharacteristic(client) -
This commit is contained in:
1 parent
f72401271e
commit
ae20fa0176
12 files changed
+90
-16
No files matched your search
@@ -33,6 +33,7 @@ BLEUart KEYWORD1
|
||||
# Gatt Client
|
||||
BLECentralUart KEYWORD1
|
||||
BLEAncs KEYWORD1
|
||||
BLEClientDis KEYWORD1
|
||||
|
||||
AncsNotification_t KEYWORD3
|
||||
|
||||
@@ -182,6 +183,8 @@ clearData KEYWORD2
|
||||
begin KEYWORD2
|
||||
begun KEYWORD2
|
||||
discoverCharacteristic KEYWORD2
|
||||
setHandleRange KEYWORD2
|
||||
getHandleRange KEYWORD2
|
||||
|
||||
#######################################
|
||||
# BLEUuid Methods (KEYWORD2)
|
||||
@@ -192,6 +195,17 @@ size KEYWORD2
|
||||
|
||||
|
||||
|
||||
#######################################
|
||||
# BLEClientDis Methods (KEYWORD2)
|
||||
#######################################
|
||||
getModel KEYWORD2
|
||||
getSerial KEYWORD2
|
||||
getFirmwareRev KEYWORD2
|
||||
getHardwareRev KEYWORD2
|
||||
getSoftwareRev KEYWORD2
|
||||
getManufacturer KEYWORD2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name=Adafruit BLE Libraries for Bluefruit52
|
||||
version=0.5.5
|
||||
version=0.6.0
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=Arduino library for nRF52-based Adafruit Bluefruit LE modules
|
||||
|
||||
@@ -60,6 +60,29 @@ BLEClientCharacteristic::BLEClientCharacteristic(BLEUuid bleuuid)
|
||||
_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
BLEClientCharacteristic::~BLEClientCharacteristic()
|
||||
{
|
||||
_adamsg.stop();
|
||||
Bluefruit.Gatt._removeCharacteristic(this);
|
||||
}
|
||||
|
||||
void BLEClientCharacteristic::begin(BLEClientService* parent_svc)
|
||||
{
|
||||
// Add UUID128 if needed
|
||||
uuid.begin();
|
||||
|
||||
// Use the last (discovered) service as parent if not provided
|
||||
_service = ( parent_svc == NULL ) ? BLEClientService::lastService : parent_svc;
|
||||
|
||||
// Register to Bluefruit (required for callback and write response)
|
||||
(void) Bluefruit.Gatt._addCharacteristic(this);
|
||||
|
||||
_adamsg.begin(true);
|
||||
}
|
||||
|
||||
void BLEClientCharacteristic::assign(ble_gattc_char_t* gattc_chr)
|
||||
{
|
||||
_chr = *gattc_chr;
|
||||
@@ -110,19 +133,6 @@ bool BLEClientCharacteristic::discoverDescriptor(uint16_t conn_handle)
|
||||
return true;
|
||||
}
|
||||
|
||||
void BLEClientCharacteristic::begin(void)
|
||||
{
|
||||
// Add UUID128 if needed
|
||||
uuid.begin();
|
||||
|
||||
_service = BLEClientService::lastService;
|
||||
|
||||
// Register to Bluefruit (required for callback and write response)
|
||||
(void) Bluefruit.Gatt._addCharacteristic(this);
|
||||
|
||||
_adamsg.begin(true);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* READ
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
@@ -54,9 +54,12 @@ class BLEClientCharacteristic
|
||||
BLEClientCharacteristic(void);
|
||||
BLEClientCharacteristic(BLEUuid bleuuid);
|
||||
|
||||
virtual ~BLEClientCharacteristic();
|
||||
|
||||
void assign(ble_gattc_char_t* gattc_chr);
|
||||
bool discoverDescriptor(uint16_t conn_handle);
|
||||
void begin(void);
|
||||
|
||||
void begin(BLEClientService* parent_svc = NULL);
|
||||
|
||||
uint16_t valueHandle(void);
|
||||
uint8_t properties(void);
|
||||
|
||||
@@ -59,6 +59,16 @@ bool BLEDiscovery::begun(void)
|
||||
return (_sem != NULL);
|
||||
}
|
||||
|
||||
void BLEDiscovery::setHandleRange(ble_gattc_handle_range_t handle_range)
|
||||
{
|
||||
_hdl_range = handle_range;
|
||||
}
|
||||
|
||||
ble_gattc_handle_range_t BLEDiscovery::getHandleRange(void)
|
||||
{
|
||||
return _hdl_range;
|
||||
}
|
||||
|
||||
bool BLEDiscovery::_discoverService(uint16_t conn_handle, BLEClientService& svc, uint16_t start_handle)
|
||||
{
|
||||
ble_gattc_evt_prim_srvc_disc_rsp_t disc_svc;
|
||||
|
||||
@@ -62,6 +62,9 @@ class BLEDiscovery
|
||||
void begin(void);
|
||||
bool begun(void);
|
||||
|
||||
void setHandleRange(ble_gattc_handle_range_t handle_range);
|
||||
ble_gattc_handle_range_t getHandleRange(void);
|
||||
|
||||
uint8_t discoverCharacteristic(uint16_t conn_handle, BLEClientCharacteristic* chr[], uint8_t count);
|
||||
|
||||
uint8_t discoverCharacteristic(uint16_t conn_handle, BLEClientCharacteristic& chr1)
|
||||
|
||||
@@ -110,6 +110,9 @@ void BLEGatt::_eventHandler(ble_evt_t* evt)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Server
|
||||
*------------------------------------------------------------------*/
|
||||
bool BLEGatt::_addCharacteristic(BLECharacteristic* chr)
|
||||
{
|
||||
if ( _server.chr_count == BLE_GATT_MAX_SERVER_CHARS ) return false;
|
||||
@@ -118,7 +121,29 @@ bool BLEGatt::_addCharacteristic(BLECharacteristic* chr)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Client
|
||||
*------------------------------------------------------------------*/
|
||||
void BLEGatt::_removeCharacteristic(BLEClientCharacteristic* chr)
|
||||
{
|
||||
for(int i=0; i<_client.chr_count; i++)
|
||||
{
|
||||
// found the char, swap with the last one
|
||||
if ( _client.chr_list[i] == chr )
|
||||
{
|
||||
vTaskSuspendAll();
|
||||
|
||||
_client.chr_count--;
|
||||
|
||||
_client.chr_list[i] = _client.chr_list[ _client.chr_count ];
|
||||
_client.chr_list[_client.chr_count] = NULL;
|
||||
|
||||
( void ) xTaskResumeAll();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BLEGatt::_addCharacteristic(BLEClientCharacteristic* chr)
|
||||
{
|
||||
|
||||
@@ -69,6 +69,8 @@ class BLEGatt
|
||||
|
||||
// Client
|
||||
bool _addCharacteristic(BLEClientCharacteristic* chr);
|
||||
void _removeCharacteristic(BLEClientCharacteristic* chr);
|
||||
|
||||
bool _addService(BLEClientService* svc);
|
||||
|
||||
void _eventHandler(ble_evt_t* evt);
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
|
||||
#include "clients/BLEAncs.h"
|
||||
#include "clients/BLEClientUart.h"
|
||||
#include "clients/BLEClientDis.h"
|
||||
|
||||
#define BLE_MAX_DATA_PER_MTU (GATT_MTU_SIZE_DEFAULT - 3)
|
||||
|
||||
|
||||
@@ -52,6 +52,11 @@ void AdaMsg::begin(bool dynamic)
|
||||
if ( !_dynamic ) _sem = xSemaphoreCreateBinary();
|
||||
}
|
||||
|
||||
void AdaMsg::stop(void)
|
||||
{
|
||||
if (!_dynamic) vSemaphoreDelete(_sem);
|
||||
}
|
||||
|
||||
void AdaMsg::prepare(void* buf, uint16_t bufsize)
|
||||
{
|
||||
buffer = (uint8_t*) buf;
|
||||
|
||||
@@ -53,6 +53,7 @@ class AdaMsg
|
||||
|
||||
// dynamic mean semaphore is malloced and freed only when in action
|
||||
void begin(bool dynamic = true);
|
||||
void stop(void);
|
||||
|
||||
void prepare(void* buf, uint16_t bufsize);
|
||||
int32_t waitUntilComplete(uint32_t ms);
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
name=Adafruit Boards
|
||||
version=0.5.5
|
||||
version=0.6.0
|
||||
|
||||
# Compile variables
|
||||
# -----------------
|
||||
|
||||
Reference in new issue
Block a user