Skip to content

Commit 28eba0c

Browse files
committed
enhance BLEService::setPermission(read,write)
1 parent a860206 commit 28eba0c

File tree

7 files changed

+77
-20
lines changed

7 files changed

+77
-20
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Following boards are also included but are not officially supported:
1616

1717
- [Nordic nRF52840DK PCA10056](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK)
1818
- [Particle Xenon](https://store.particle.io/products/xenon)
19+
- [Raytac MDBT50Q-RX Dongle](https://www.raytac.com/product/ins.php?index_id=89)
1920

2021
## BSP Installation
2122

@@ -49,7 +50,7 @@ There are two methods that you can use to install this BSP. We highly recommend
4950

5051
### Adafruit's nrfutil tools
5152

52-
[adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) (derived from Nordic pc-nrfutil) is needed to upload sketch via serial port.
53+
[adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) (derived from Nordic [pc-nrfutil](https://github.com/NordicSemiconductor/pc-nrfutil)) is needed to upload sketch via serial port.
5354

5455
- For Windows and macOS, pre-built executable binaries are included in the BSP at `tools/adafruit-nrfutil/`. It should work out of the box.
5556
- Linux user need to run follow command to install it from PyPi
@@ -117,8 +118,7 @@ which in turn is based on the [Arduino SAMD Core](https://github.com/arduino/Ard
117118

118119
The following libraries are used:
119120

120-
- adafruit-nrfutil is based on Nordic Semiconductor ASA's [pc-nrfutil](https://github.com/NordicSemiconductor/pc-nrfutil)
121-
- [freeRTOS](https://www.freertos.org/) as operating system
122-
- [tinyusb](https://github.com/hathach/tinyusb) as usb stack
121+
- [FreeRTOS](https://www.freertos.org/) as operating system
122+
- [LittleFS](https://github.com/ARMmbed/littlefs) for internal file system
123123
- [nrfx](https://github.com/NordicSemiconductor/nrfx) for peripherals driver
124-
- [littlefs](https://github.com/ARMmbed/littlefs) for internal file system
124+
- [TinyUSB](https://github.com/hathach/tinyusb) as usb stack

changelog.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,55 @@
11
# Adafruit nRF52 Arduino Core Changelog
22

3+
## 0.20.0
4+
5+
This version implement comprehensive pairing with LESC and Legacy using dynamic & staic Passkey.
6+
7+
- Support static passkey (Legacy only)
8+
- Support LESC on nRF52840 using hardware-accelerated ARM CryptoCell CC310 provided by [Adafruit_nRFCypto](https://github.com/adafruit/Adafruit_nRFCrypto), therefore nRFCrypto library must be installed
9+
- Rework bonding mechanism to use IRK for peer finding. It is advisable to run `clearbonds` example to clean up bond files of previous version
10+
11+
### BLESecurity
12+
13+
A new class BLESecurity (access with Bluefruit.Security) is added to handle security and pairing.
14+
15+
- **setPIN()** to set static passkey, this will force to use Legacy Pairing
16+
- **setIOCaps()** to congiure IO capacities
17+
- **setMITM()** to enable/disable Man in The Middle protection (passkey), it is auto-enabled when using passkey
18+
- **setPairPasskeyCallback()** to register callback for displaying pairing passkey to user
19+
- **setPairCompleteCallback()** to register callback for the result of pairing procedure (succeeded or failed)
20+
- **setSecuredCallback()** to register callback which invoked when connection is secured. This happens after he pairing procedure is complete, or we re-connect with preivously bonded peer device
21+
22+
### Other Changes
23+
24+
**BLECentral**
25+
26+
- will automatically use stored Long Term Key to secure connection if paired/bonded with device previously
27+
28+
**Bluefruit**
29+
30+
- Bluefruit::requestPairing() is removed, please use the BLEConnection::requestPairing() instead
31+
- Bluefruit::connPaired() is removed, please use BLEConnection::secure() instead
32+
- Default Device name is USB_PRODUCT if available e.g CLUE, Circuit Playground Bluefruit, Feather nRF52840 Express etc ...
33+
34+
**BLEService**
35+
36+
- Added setPermission()
37+
38+
**BLEConnection**
39+
40+
- BLEConnection::requestPairing() is now non-blocking, it will return right after sending request to peer device. Previously it is blocked until the pairing process is complete.
41+
- Added BLEConnection::secured() to check if the connection is secured/encrypted
42+
- Added BLEConnection::bonded() to check if we store Longterm Key with current peer
43+
- Removed BLEConnection:paried(), user should either use secured() or bonded() depending on the context
44+
- If bonded, getPeerAddr() will return peer public address instead of random address.
45+
46+
**New Example Sketches**
47+
48+
- **pairing_pin** to use static PIN for peripheral role
49+
- **pairing_passkey** to use dyanmic Passkey for pairing. On Arcada compatible device such as `CLUE` or `Circuit Playground Bluefruit`, TFT display will also be used to display passkey.
50+
- **cental_pairing** similar to pairing_passkey but for nRF running central role
51+
- **ancs_arcada** for displaying ancs on arcada such CLUE and/or CPB.
52+
353
## 0.19.0 - 2020.03.12
454

555
- Add BLECharacteristic::isFixedLen()

libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey/pairing_passkey.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void setup()
121121
// Set Permission to access BLE Uart is to require man-in-the-middle protection
122122
// This will cause central to perform pairing with static PIN we set above
123123
Serial.println("Configure BLE Uart to require man-in-the-middle protection for PIN pairing");
124-
bleuart.setPermission(SECMODE_ENC_WITH_MITM);
124+
bleuart.setPermission(SECMODE_ENC_WITH_MITM, SECMODE_ENC_WITH_MITM);
125125
bleuart.begin();
126126

127127
#ifdef USE_ARCADA

libraries/Bluefruit52Lib/examples/Peripheral/pairing_pin/pairing_pin.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void setup()
6060
// Set Permission to access BLE Uart is to require man-in-the-middle protection
6161
// This will cause central to perform pairing with static PIN we set above
6262
Serial.println("Configure BLE Uart to require man-in-the-middle protection for PIN pairing");
63-
bleuart.setPermission(SECMODE_ENC_WITH_MITM);
63+
bleuart.setPermission(SECMODE_ENC_WITH_MITM, SECMODE_ENC_WITH_MITM);
6464
bleuart.begin();
6565

6666
// Set up and start advertising

libraries/Bluefruit52Lib/src/BLECharacteristic.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,21 @@ err_t BLECharacteristic::begin(void)
245245

246246
// Correct Read/Write permission according to parent service
247247
// Use service permission if it has higher secure mode
248-
SecureMode_t svc_secmode = _service->getPermission();
249-
ble_gap_conn_sec_mode_t svc_perm;
250-
memcpy(&svc_perm, &svc_secmode, 1);
248+
SecureMode_t svc_rd_secmode, svc_wr_secmod;
249+
_service->getPermission(&svc_rd_secmode, &svc_wr_secmod);
250+
251+
ble_gap_conn_sec_mode_t svc_rd_perm, svc_wr_perm;
252+
memcpy(&svc_rd_perm, &svc_rd_secmode, 1);
253+
memcpy(&svc_wr_perm, &svc_wr_secmod , 1);
251254

252255
if ( _attr_meta.read_perm.sm != 0 ) // skip no access
253256
{
254-
_attr_meta.read_perm = max_secmode(_attr_meta.read_perm, svc_perm);
257+
_attr_meta.read_perm = max_secmode(_attr_meta.read_perm, svc_rd_perm);
255258
}
256259

257260
if ( _attr_meta.write_perm.sm != 0 ) // skip no access
258261
{
259-
_attr_meta.write_perm = max_secmode(_attr_meta.write_perm, svc_perm);
262+
_attr_meta.write_perm = max_secmode(_attr_meta.write_perm, svc_wr_perm);
260263
}
261264

262265
/* CCCD attribute metadata */

libraries/Bluefruit52Lib/src/BLEService.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ BLEService* BLEService::lastService = NULL;
4141
void BLEService::_init(void)
4242
{
4343
_handle = BLE_GATT_HANDLE_INVALID;
44-
_permission = SECMODE_OPEN;
44+
_read_perm = SECMODE_OPEN;
45+
_write_perm = SECMODE_OPEN;
4546
}
4647

4748
BLEService::BLEService(void)
@@ -61,14 +62,16 @@ void BLEService::setUuid(BLEUuid bleuuid)
6162
uuid = bleuuid;
6263
}
6364

64-
void BLEService::setPermission(SecureMode_t permission)
65+
void BLEService::setPermission(SecureMode_t read_perm, SecureMode_t write_perm)
6566
{
66-
_permission = permission;
67+
_read_perm = read_perm;
68+
_write_perm = write_perm;
6769
}
6870

69-
SecureMode_t BLEService::getPermission(void)
71+
void BLEService::getPermission(SecureMode_t* read_perm, SecureMode_t* write_perm)
7072
{
71-
return _permission;
73+
*read_perm = _read_perm;
74+
*write_perm = _write_perm;
7275
}
7376

7477
err_t BLEService::begin(void)

libraries/Bluefruit52Lib/src/BLEService.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class BLEService
4343
{
4444
protected:
4545
uint16_t _handle; // service gatt handle
46-
SecureMode_t _permission;
46+
SecureMode_t _read_perm;
47+
SecureMode_t _write_perm;
4748

4849
void _init(void);
4950

@@ -60,8 +61,8 @@ class BLEService
6061

6162
void setUuid(BLEUuid bleuuid);
6263

63-
void setPermission(SecureMode_t permission);
64-
SecureMode_t getPermission(void);
64+
void setPermission(SecureMode_t read_perm, SecureMode_t write_perm);
65+
void getPermission(SecureMode_t* read_perm, SecureMode_t* write_perm);
6566

6667
virtual err_t begin(void);
6768

0 commit comments

Comments
 (0)