Skip to content

Commit 8f35e83

Browse files
authored
Merge pull request #303 from adafruit/develop
ready to release 0.11.1
2 parents a86e4ef + 17b8924 commit 8f35e83

File tree

7 files changed

+47
-34
lines changed

7 files changed

+47
-34
lines changed

changelog.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# Adafruit nRF52 Arduino Core Changelog
22

3-
# 0.11.1
3+
# 0.11.1 - 2019.07.10
44

5+
- Update tinyusb core to support USB MIDI
56
- Refactor Ada Callback, use ISCR to detect isr context. Use function instead of macro
67
- Implement #240 run travis test with all example sketches
7-
- Fix auto-start of advertising when central is connected, thanks to @ogatatsu PR #268
8+
- Fixed auto-start of advertising when central is connected, thanks to @ogatatsu PR #268
89
- Added Tone()/noTone() functions
10+
- Travis-ci builds all sketches when commit code
11+
- Fixed setAppearance/getAppearance() typo, thanks to @paulmand3l PR #292
12+
- Fixed rssi_proximity_peripheral sketch, thanks to @dicobrazz PR #295
13+
- Fixed doc typo, thanks to @yvadher PR #296
14+
- Fixed HID usage code location comment in exmaple sketch, thanks to @stefandz PR #297
15+
- Fixed #277 conn LED doesn't stop when scanner is time out
16+
- Added connection handle to Bluefruit.connParied()
917

1018
# 0.11.0
1119

libraries/Bluefruit52Lib/examples/Peripheral/client_cts/client_cts.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@ void startAdv(void)
9494

9595
void loop()
9696
{
97-
// If service is not yet discovered
98-
if ( !bleCTime.discovered() && !Bluefruit.connPaired() ) return;
97+
// Skip if service is not yet discovered
98+
if ( !bleCTime.discovered() ) return;
99+
100+
// Skip if service connection is not paired/secured
101+
if ( !Bluefruit.connPaired( bleCTime.connHandle() ) ) return;
99102

100103
// Get Time from iOS once per second
101104
// Note it is not advised to update this quickly

libraries/Bluefruit52Lib/examples/Peripheral/client_cts_oled/client_cts_oled.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ void startAdv(void)
103103

104104
void loop()
105105
{
106-
// If service is not yet discovered
107-
if ( !bleCTime.discovered() && !Bluefruit.connPaired() ) return;
106+
// Skip if service is not yet discovered
107+
if ( !bleCTime.discovered() ) return;
108+
109+
// Skip if service connection is not paired/secured
110+
if ( !Bluefruit.connPaired( bleCTime.connHandle() ) ) return;
108111

109112
// Get Time from iOS once per second
110113
// Note it is not advised to update this quickly

libraries/Bluefruit52Lib/examples/Peripheral/hid_camerashutter/hid_camerashutter.ino

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
/*
1616
* This sketch uses the HID Consumer Key API to send the Volume Down
1717
* key when PIN_SHUTTER is grounded. This will cause your mobile device
18-
* to capture a photo when you are in the camera app
18+
* to capture a photo when you are in the camera app.
19+
*
20+
* For Feather nRF52840 PIN_SHUTTER is conveniently user switch.
1921
*/
2022
#include <bluefruit.h>
2123

2224
BLEDis bledis;
2325
BLEHidAdafruit blehid;
2426

25-
#define PIN_SHUTTER A0
27+
#define PIN_SHUTTER 7
2628

2729
void setup()
2830
{
@@ -101,30 +103,34 @@ void startAdv(void)
101103

102104
void loop()
103105
{
104-
// Make sure you are connected and bonded/paired
105-
if ( Bluefruit.connected() && Bluefruit.connPaired() )
106+
// Skip if shutter pin is not Ground
107+
if ( digitalRead(PIN_SHUTTER) == 1 ) return;
108+
109+
// Make sure we are connected and bonded/paired
110+
for (uint16_t conn_hdl=0; conn_hdl < BLE_MAX_CONNECTION; conn_hdl++)
106111
{
107-
// Check if pin GND'ed
108-
if ( digitalRead(PIN_SHUTTER) == 0 )
112+
BLEConnection* connection = Bluefruit.Connection(conn_hdl);
113+
114+
if ( connection && connection->connected() && connection->paired() )
109115
{
110116
// Turn on red LED when we start sending data
111117
digitalWrite(LED_RED, 1);
112118

113-
// Send the 'volume down' key press
114-
// Check hid.h for a list of valid consumer usage codes
115-
blehid.consumerKeyPress(HID_USAGE_CONSUMER_VOLUME_DECREMENT);
119+
// Send the 'volume down' key press to the peer
120+
// Check tinyusb/src/class/hid/hid.h for a list of valid consumer usage codes
121+
blehid.consumerKeyPress(conn_hdl, HID_USAGE_CONSUMER_VOLUME_DECREMENT);
116122

117123
// Delay a bit between reports
118124
delay(10);
119125

120126
// Send key release
121-
blehid.consumerKeyRelease();
127+
blehid.consumerKeyRelease(conn_hdl);
122128

123129
// Turn off the red LED
124130
digitalWrite(LED_RED, 0);
125-
126-
// Delay to avoid constant capturing
127-
delay(500);
128131
}
129132
}
133+
134+
// Delay to avoid constant capturing
135+
delay(500);
130136
}

libraries/Bluefruit52Lib/src/BLEScanner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ bool BLEScanner::stop(void)
138138
{
139139
VERIFY_STATUS( sd_ble_gap_scan_stop(), false );
140140

141-
Bluefruit._stopConnLed(); // stop blinking
142141
_runnning = false;
142+
Bluefruit._stopConnLed(); // stop blinking
143143

144144
return true;
145145
}
@@ -406,6 +406,7 @@ void BLEScanner::_eventHandler(ble_evt_t* evt)
406406
if (evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_SCAN)
407407
{
408408
_runnning = false;
409+
Bluefruit._stopConnLed();
409410
if (_stop_cb) ada_callback(NULL, 0, _stop_cb);
410411
}
411412
break;

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,9 @@ uint16_t AdafruitBluefruit::connHandle(void)
635635
return _conn_hdl;
636636
}
637637

638-
bool AdafruitBluefruit::connPaired(void)
638+
bool AdafruitBluefruit::connPaired(uint16_t conn_hdl)
639639
{
640-
BLEConnection* conn = Bluefruit.Connection(_conn_hdl);
640+
BLEConnection* conn = Bluefruit.Connection(conn_hdl);
641641
return conn && conn->paired();
642642
}
643643

@@ -826,16 +826,7 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
826826
LOG_LV2("GAP", "Disconnect Reason 0x%02X", evt->evt.gap_evt.params.disconnected.reason);
827827

828828
// Turn off Conn LED If not connected at all
829-
bool still_connected = false;
830-
for (uint8_t i=0; i<BLE_MAX_CONNECTION; i++)
831-
{
832-
if ( _connection[i] && _connection[i]->connected() )
833-
{
834-
still_connected = true;
835-
break;
836-
}
837-
}
838-
if ( !still_connected ) _setConnLed(false);
829+
if ( !this->connected() ) _setConnLed(false);
839830

840831
// Invoke disconnect callback
841832
if ( conn->getRole() == BLE_GAP_ROLE_PERIPH )
@@ -848,7 +839,6 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
848839

849840
delete _connection[conn_hdl];
850841
_connection[conn_hdl] = NULL;
851-
852842
}
853843
break;
854844

@@ -994,6 +984,8 @@ void AdafruitBluefruit::_startConnLed(void)
994984
void AdafruitBluefruit::_stopConnLed(void)
995985
{
996986
xTimerStop(_led_blink_th, 0);
987+
988+
_setConnLed( this->connected() );
997989
}
998990

999991
void AdafruitBluefruit::_setConnLed (bool on_off)

libraries/Bluefruit52Lib/src/bluefruit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class AdafruitBluefruit
173173
bool connected (uint16_t conn_hdl);
174174

175175
uint16_t connHandle (void);
176-
bool connPaired (void);
176+
bool connPaired (uint16_t conn_hdl);
177177

178178
// Alias to BLEConnection API()
179179
bool disconnect (uint16_t conn_hdl);

0 commit comments

Comments
 (0)