able to discover ancs on iphone

This commit is contained in:
hathach committed 2017-03-30 14:59:37 +07:00
1 parent ff481dd327
commit e8873a43e7
5 files changed
+51 -17

No files matched your search

@@ -97,7 +97,7 @@ uint8_t BLEDiscovery::discoverCharacteristic(uint16_t conn_handle, BLECentralCha
_evt_buf = &disc_chr;
_evt_bufsize = sizeof(disc_chr);
LOG_LV1(Discover, "[CHR] Handle start = %d, end = %d", _hdl_range.start_handle, _hdl_range.end_handle);
// LOG_LV1(Discover, "[CHR] Handle start = %d, end = %d", _hdl_range.start_handle, _hdl_range.end_handle);
VERIFY_STATUS( sd_ble_gattc_characteristics_discover(conn_handle, &_hdl_range), found );
@@ -136,7 +136,7 @@ uint16_t BLEDiscovery::_discoverDescriptor(uint16_t conn_handle, ble_gattc_evt_d
_evt_buf = disc_desc;
_evt_bufsize = sizeof(ble_gattc_evt_desc_disc_rsp_t) + (max_count-1)*sizeof(ble_gattc_desc_t);
LOG_LV1(Discover, "[DESC] Handle start = %d, end = %d", _hdl_range.start_handle, _hdl_range.end_handle);
// LOG_LV1(Discover, "[DESC] Handle start = %d, end = %d", _hdl_range.start_handle, _hdl_range.end_handle);
uint16_t result = 0;
VERIFY_STATUS( sd_ble_gattc_descriptors_discover(conn_handle, &_hdl_range), 0 );
+6 -1
View File
@@ -52,7 +52,8 @@
#define CFG_ADV_BLINKY_INTERVAL 500
#define CFG_BLE_TASK_STACKSIZE (512*3)
#define CFG_SOC_TASK_STACKSIZE (configMINIMAL_STACK_SIZE*5) // 300
#define CFG_WORKER_TASK_STACKSIZE (512*1)
#define CFG_SOC_TASK_STACKSIZE (200)
#define CFG_BOND_NFFS_DIR "/adafruit/bond"
#define BOND_FILENAME CFG_BOND_NFFS_DIR "/%04x"
@@ -71,6 +72,8 @@ extern "C"
void adafruit_ble_task(void* arg);
void adafruit_soc_task(void* arg);
COMMENT_OUT( void adafruit_worker_task(void* arg); )
/*------------------------------------------------------------------*/
/* INTERNAL FUNCTION
@@ -425,6 +428,8 @@ void adafruit_soc_task(void* arg)
}
}
COMMENT_OUT(void adafruit_worker_task(void* arg) { } )
/*------------------------------------------------------------------*/
/* BLE Event handler
*------------------------------------------------------------------*/
@@ -48,18 +48,18 @@ const uint8_t BLEANCS_UUID_SERVICE[] =
0x99, 0x4E, 0xCE, 0xB5, 0x31, 0xF4, 0x05, 0x79
};
const uint8_t BLEANCS_UUID_CHR_NOTIFICATION[]
{
0xBD, 0x1D, 0xA2, 0x99, 0xE6, 0x25, 0x58, 0x8C,
0xD9, 0x42, 0x01, 0x63, 0x0D, 0x12, 0xBF, 0x9F
};
const uint8_t BLEANCS_UUID_CHR_CONTROL[] =
{
0xD9, 0xD9, 0xAA, 0xFD, 0xBD, 0x9B, 0x21, 0x98,
0xA8, 0x49, 0xE1, 0x45, 0xF3, 0xD8, 0xD1, 0x69
};
const uint8_t BLEANCS_UUID_CHR_NOTIFICATION[]
{
0xBD, 0x1D, 0xA2, 0x99, 0xE6, 0x25, 0x58, 0x8C,
0xD9, 0x42, 0x01, 0x63, 0x0D, 0x12, 0xBF, 0x9F
};
const uint8_t BLEANCS_UUID_CHR_DATA[] =
{
0xFB, 0x7B, 0x7C, 0xCE, 0x6A, 0xB3, 0x44, 0xBE,
@@ -67,20 +67,40 @@ const uint8_t BLEANCS_UUID_CHR_DATA[] =
};
BLEAncs::BLEAncs(void)
: BLECentralService(BLEANCS_UUID_SERVICE), _notification(BLEANCS_UUID_CHR_NOTIFICATION),
_control(BLEANCS_UUID_CHR_CONTROL), _data(BLEANCS_UUID_CHR_DATA)
: BLECentralService(BLEANCS_UUID_SERVICE), _control(BLEANCS_UUID_CHR_CONTROL),
_notification(BLEANCS_UUID_CHR_NOTIFICATION), _data(BLEANCS_UUID_CHR_DATA)
{
}
bool BLEAncs::begin(void)
{
// Invoke base class begin()
BLECentralService::begin();
// Initialize Discovery module if needed
if ( !Bluefruit.Discovery.begun() ) Bluefruit.Discovery.begin();
_control.begin();
_notification.begin();
_data.begin();
return true;
}
bool BLEAncs::discover(void)
bool BLEAncs::discover(uint16_t conn_handle)
{
// Call BLECentralService discover
VERIFY( BLECentralService::discover(conn_handle) );
_discovered = false;
// Discover characteristics
BLECentralCharacteristic* chr_arr[] = { &_control, &_notification, &_data };
VERIFY( 3 == Bluefruit.Discovery.discoverCharacteristic(conn_handle, chr_arr, 3) );
_discovered = true;
return true;
}
void BLEAncs::disconnect(void)
@@ -42,8 +42,8 @@
//#include "BLECentralService.h"
extern const uint8_t BLEANCS_UUID_SERVICE[];
extern const uint8_t BLEANCS_UUID_CHR_NOTIFICATION[];
extern const uint8_t BLEANCS_UUID_CHR_CONTROL[];
extern const uint8_t BLEANCS_UUID_CHR_NOTIFICATION[];
extern const uint8_t BLEANCS_UUID_CHR_DATA[];
class BLEAncs : public BLECentralService
@@ -52,14 +52,14 @@ class BLEAncs : public BLECentralService
BLEAncs(void);
virtual bool begin(void);
virtual bool discover(void);
virtual bool discover(uint16_t conn_handle);
protected:
virtual void disconnect(void);
private:
BLECentralCharacteristic _notification;
BLECentralCharacteristic _control;
BLECentralCharacteristic _notification;
BLECentralCharacteristic _data;
};
@@ -49,8 +49,17 @@ void setup()
// the loop function runs over and over again forever
void loop()
{
digitalToggle(LED_RED);
delay(1000);
if ( Serial.available() )
{
delay(10); // delay for all input arrived
while( Serial.available() ) Serial.read();
printTreeDir("/", 0);
// Print prompt
Serial.println();
Serial.println("Enter anything to print directory tree (again):");
}
}
/**************************************************************************/