Merge branch 'master' into develop

This commit is contained in:
hathach committed 2020-01-31 11:08:53 +07:00
commit a724c718f6
10 files changed
+93 -16

No files matched your search

@@ -41,7 +41,7 @@ void setup()
Bluefruit.setName("Bluefruit52 Central");
// Init BLE Central Uart Serivce
// Init BLE Central Hid Serivce
hid.begin();
#if POLLING == 0
@@ -126,7 +126,7 @@ void connect_callback(uint16_t conn_handle)
{
Serial.println("Found NONE");
// disconnect since we couldn't find bleuart service
// disconnect since we couldn't find blehid service
Bluefruit.disconnect(conn_handle);
}
}
@@ -0,0 +1,51 @@
/*
Blink_sleep
Turns on an LED on for one second, then off for one second, until the time to go to sleep runs out.
You can wake up the feather by pressing a key/switch connecting the WAKE_LOW_PIN to GND and the WAKE_HIGH_PIN to 3.3V (VCC)
Based on the blinky arduino example
This example code is in the public domain.
created 19 Jan 2010
by Pierre Constantineau
*/
#include <bluefruit.h>
#define WAKE_LOW_PIN PIN_A0
#define WAKE_HIGH_PIN PIN_A1
#define SLEEPING_DELAY 30000 // sleep after 30 seconds of blinking
void gotoSleep(unsigned long time)
{
// shutdown when time reaches SLEEPING_DELAY ms
if ((time>SLEEPING_DELAY))
{
// to reduce power consumption when sleeping, turn off all your LEDs (and other power hungry devices)
digitalWrite(LED_BUILTIN, LOW);
// setup your wake-up pins.
pinMode(WAKE_LOW_PIN, INPUT_PULLUP_SENSE); // this pin (WAKE_LOW_PIN) is pulled up and wakes up the feather when externally connected to ground.
pinMode(WAKE_HIGH_PIN, INPUT_PULLDOWN_SENSE); // this pin (WAKE_HIGH_PIN) is pulled down and wakes up the feather when externally connected to 3.3v.
// power down nrf52.
sd_power_system_off(); // this function puts the whole nRF52 to deep sleep (no Bluetooth). If no sense pins are setup (or other hardware interrupts), the nrf52 will not wake up.
}
}
// the setup function runs once when you press reset or power the board
void setup() {
Bluefruit.begin(); // Sleep functions need the softdevice to be active.
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalToggle(LED_BUILTIN); // turn the LED on (HIGH is the voltage level)
gotoSleep(millis()); // call millis() and pass it to the sleep function. On wake-up, millis will start at 0 again.
delay(1000); // wait for a second
}
@@ -155,6 +155,8 @@ bool BLEClientCharacteristic::_discoverDescriptor(uint16_t conn_handle, ble_gatt
{
LOG_LV2("DISC", "Found CCDD: handle = %d", disc_rsp.descs[i].handle);
_cccd_handle = disc_rsp.descs[i].handle;
break;
}
}
@@ -134,6 +134,9 @@ uint8_t BLEDiscovery::discoverCharacteristic(uint16_t conn_handle, BLEClientChar
{
for (uint8_t i=0; i<count; i++)
{
if ( chr[i]->discovered() )
continue;
if ( chr[i]->uuid == disc_chr->chars[d].uuid )
{
LOG_LV2("DISC", "[CHR] Found 0x%04X, handle = %d\n-----------------", disc_chr->chars[d].uuid.uuid, disc_chr->chars[d].handle_value);
+9 -9
View File
@@ -184,15 +184,6 @@ void BLEGatt::_eventHandler(ble_evt_t* evt)
if ( evt_id == BLE_GAP_EVT_DISCONNECTED )
{
// Client
for(uint8_t i=0; i<_client.svc_count; i++)
{
if ( evt_conn_hdl == _client.svc_list[i]->_conn_hdl)
{
_client.svc_list[i]->disconnect();
}
}
// TODO merge to above loop
for(uint8_t i=0; i<_client.chr_count; i++)
{
if ( evt_conn_hdl == _client.chr_list[i]->connHandle() )
@@ -200,6 +191,15 @@ void BLEGatt::_eventHandler(ble_evt_t* evt)
_client.chr_list[i]->disconnect();
}
}
// TODO merge to above loop
for(uint8_t i=0; i<_client.svc_count; i++)
{
if ( evt_conn_hdl == _client.svc_list[i]->_conn_hdl)
{
_client.svc_list[i]->disconnect();
}
}
}
// GATTC Read Characteristic by UUID procedure