Skip to content

Commit 1cda3b8

Browse files
authored
Documentation of PR: "Implemented configuration options for BLE security #360"
1 parent 14b97db commit 1cda3b8

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

content/firmwareapi/pycom/network/bluetooth/_index.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,18 @@ bluetooth = Bluetooth()
6060

6161
## Methods
6262

63-
#### bluetooth.init(id=0, mode=Bluetooth.BLE, antenna=None, modem\_sleep=True, secure=False, pin=123456)
63+
#### bluetooth.init(id=0, mode=Bluetooth.BLE, antenna=None, modem\_sleep=True, pin=None, privacy=True, secure\_connections=True, mtu=200)
6464

65-
* `id` Only one Bluetooth peripheral available so must always be 0
66-
* `mode` currently the only supported mode is `Bluetooth.BLE`
67-
* `modem_sleep` Enables or Disables BLE modem sleep, Disable modem sleep as a workaround when having Crashes due to flash cache being disabled, as this prevents BLE task saving data in external RAM while accesing external flash for R/W
68-
* `antenna` selects between the internal and the external antenna. Can be either `Bluetooth.INT_ANT`, `Bluetooth.EXT_ANT`
69-
* `secure` enables or disables the GATT Server security features
70-
* `pin` a six digit number to connect to the GATT Sever
65+
* `id` Only one Bluetooth peripheral available so must always be 0.
66+
* `mode` currently the only supported mode is `Bluetooth.BLE`.
67+
* `antenna` selects between the internal and the external antenna. Can be either `Bluetooth.INT_ANT`, `Bluetooth.EXT_ANT`.
68+
* `modem_sleep` Enables or Disables BLE modem sleep, Disable modem sleep as a workaround when having Crashes due to flash cache being disabled, as this prevents BLE task saving data in external RAM while accesing external flash for R/W.
69+
* `pin` a one to six digit number (`0`-`9`) to connect to the GATT Sever. Setting any valid pin, GATT Server security features are activated.
70+
* `privacy` Enables or Disables local privacy settings so address will be random or public.
71+
* `secure_connections` Enables or Disables Secure Connections and MITM Protection.
72+
* `mtu` Maximum Transmission Unit (MTU) is the maximum length of an ATT packet. Value must be between `23` and `200`.
7173

72-
With our development boards it defaults to using the internal antenna, but in the case of an OEM module, the antenna pin (`P12`) is not used, so it's free to be used for other things.
74+
With our development boards it defaults to using the internal antenna, but in the case of an OEM module, the antenna pin (`P12`) is not used, so it's free to be used for other things.
7375

7476
Initialises and enables the Bluetooth radio in BLE mode.
7577

@@ -156,6 +158,10 @@ while bluetooth.isscanning():
156158
print(ubinascii.hexlify(mfg_data))
157159
```
158160

161+
#### bluetooth.set\_pin()
162+
163+
Configures a new PIN to be used by the device. The PIN is a 1-6 digit length decimal number, if less than 6 digits are given the missing leading digits are considered as 0. E.g. 1234 becomes 001234. When a new PIN is configured, the information of all previously bonded device is removed and the current connection is terminated. To restart advertisement the advertise() must be called after PIN is changed.
164+
159165
#### bluetooth.connect(mac\_addr, timeout=None)
160166

161167
* `mac_addr` is the address of the remote device to connect

content/firmwareapi/pycom/network/bluetooth/gattsservice.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ Stops the service if previously started.
2727
Creates a new characteristic on the service. Returns an object of the class `GATTSCharacteristic`. The arguments are:
2828

2929
* `uuid` is the UUID of the service. Can take an integer or a 16 byte long string or bytes object.
30-
* `permissions` configures the permissions of the characteristic. Takes an integer with a combination of the flags.
30+
* `permissions` configures the permissions of the characteristic. Takes an integer with a combination of the flags. When bluetooth object is initialized with PIN, read and write permissions are set to encrypted. Setting PIN later with set_pin() call does not affect the permissions of the already existing characteristics, thus they will remain not secured.
3131
* `properties` sets the properties. Takes an integer with an OR-ed combination of the flags.
3232
* `value` sets the initial value. Can take an integer, a string or a bytes object.
3333

3434
```python
3535

3636
service.characteristic('temp', value=25)
3737
```
38-

0 commit comments

Comments
 (0)