This commit is contained in:
hathach committed 2017-03-31 22:51:20 +07:00
1 parent fde64249d7
commit 006f74aade
7 files changed
+8 -12

No files matched your search

@@ -36,8 +36,6 @@
#include "bluefruit.h"
#define BLE_CENTRAL_TIMEOUT 3000
/**
* Constructor
*/
@@ -37,7 +37,6 @@
#include "bluefruit.h"
#define MAX_DESCIRPTORS 8
#define CENTRAL_CHR_TIMEOUT 100
void BLECentralCharacteristic::_init(void)
{
@@ -154,7 +153,7 @@ uint16_t BLECentralCharacteristic::write_resp(const void* data, int len)
if ( ERROR_NONE != sd_ble_gattc_write(conn_handle, &param) ) break;
if ( !xSemaphoreTake(_sem, CENTRAL_CHR_TIMEOUT) ) break;
if ( !xSemaphoreTake(_sem, ms2tick(BLE_GENERIC_TIMEOUT) ) ) break;
remaining -= packet_len;
u8data += packet_len;
@@ -36,8 +36,6 @@
#include "bluefruit.h"
#define BLE_CENTRAL_TIMEOUT 3000
BLEDiscovery::BLEDiscovery(void)
{
_hdl_range.start_handle = 1;
@@ -71,7 +69,7 @@ bool BLEDiscovery::_discoverService(uint16_t conn_handle, BLECentralService& svc
VERIFY_STATUS( sd_ble_gattc_primary_services_discover(conn_handle, start_handle, &svc.uuid._uuid), false );
// wait for discovery event: timeout or has no data
if ( !xSemaphoreTake(_sem, BLE_CENTRAL_TIMEOUT) || (_evt_bufsize == 0) ) return false;
if ( !xSemaphoreTake(_sem, ms2tick(BLE_DISCOVERY_TIMEOUT)) || (_evt_bufsize == 0) ) return false;
// Check the discovered UUID with input one
if ( (disc_svc.count == 1) && (svc.uuid == disc_svc.services[0].uuid) )
@@ -103,7 +101,7 @@ uint8_t BLEDiscovery::discoverCharacteristic(uint16_t conn_handle, BLECentralCha
// wait for discovery event: timeout or has no data
// Assume only 1 characteristic discovered each
if ( !xSemaphoreTake(_sem, BLE_CENTRAL_TIMEOUT) || (_evt_bufsize == 0) || (disc_chr.count == 0) ) break;
if ( !xSemaphoreTake(_sem, ms2tick(BLE_DISCOVERY_TIMEOUT)) || (_evt_bufsize == 0) || (disc_chr.count == 0) ) break;
// increase handle range for next discovery
_hdl_range.start_handle = disc_chr.chars[0].handle_value + 1;
@@ -142,7 +140,7 @@ uint16_t BLEDiscovery::_discoverDescriptor(uint16_t conn_handle, ble_gattc_evt_d
VERIFY_STATUS( sd_ble_gattc_descriptors_discover(conn_handle, &_hdl_range), 0 );
// wait for discovery event: timeout or has no data
if ( !xSemaphoreTake(_sem, BLE_CENTRAL_TIMEOUT) || (_evt_bufsize == 0) ) return 0;
if ( !xSemaphoreTake(_sem, ms2tick(BLE_DISCOVERY_TIMEOUT)) || (_evt_bufsize == 0) ) return 0;
result = min16(disc_desc->count, max_count);
if (result)
@@ -43,6 +43,8 @@
#include "BLECentralCharacteristic.h"
#include "BLECentralService.h"
#define BLE_DISCOVERY_TIMEOUT 1000
class BLEDiscovery
{
private:
+1 -1
View File
@@ -50,7 +50,7 @@ bool BLEGap::getTxPacket(uint16_t conn_handle)
{
VERIFY( (conn_handle < BLE_GAP_MAX_CONN) && (_txpacket_sem[conn_handle] != NULL) );
return xSemaphoreTake(_txpacket_sem[conn_handle], ms2tick(BLE_GAP_TIMEOUT));
return xSemaphoreTake(_txpacket_sem[conn_handle], ms2tick(BLE_GENERIC_TIMEOUT));
}
void BLEGap::_eventHandler(ble_evt_t* evt)
-1
View File
@@ -41,7 +41,6 @@
#include "BLEUuid.h"
#define BLE_GAP_MAX_CONN (BLE_CENTRAL_MAX_CONN+BLE_PRPH_MAX_CONN)
#define BLE_GAP_TIMEOUT 100
class BLEGap
{
@@ -139,7 +139,7 @@ class BLEAncs : public BLECentralService
bool enableNotification(void);
bool disableNotification(void);
bool getAttribute(uint32_t uid, uint8_t attr, void* buffer, uint16_t bufsize);
uint16_t getAttribute(uint32_t uid, uint8_t attr, void* buffer, uint16_t bufsize);
protected:
virtual void disconnect(void);