Commit Graph

21 Commits

Author SHA1 Message Date
Scott Shawcroft
dc76306cfa
Enable a BLE workflow
nRF CircuitPython boards will now provide the file transfer
service defined here: https://github.com/adafruit/Adafruit_CircuitPython_BLE_File_Transfer

USB capable boards will only advertise if previously bonded to a
device or if the reset button is pressed during the fast blue
flashes on start up. When pressed, the board will restart again but
the blue period will not flash.

Boards without USB will always advertise.

When previously bonded, the advertisement is private so that no
other peers can connect. If advertising publicly, the tx power is
lowered to reduce the likelihood of bonding from a distance.

This PR also fixes issues with loading identities of bonded peers
so that our address can now be resolved and we can resolve others'
addresses when scanning.
2021-06-24 12:59:14 -07:00
Scott Shawcroft
ee7a701487
Switch to start_advertising arg 2021-05-19 12:21:48 -07:00
gabewillen
7dee378ade
Update Adapter.h
Added support for setting transmitter power
2021-05-19 11:55:01 -07:00
microDev
a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Dan Halbert
6dbd369272 merge from upstream 2020-08-30 14:39:03 -04:00
Dan Halbert
b27d511251 address review; use constructor for HCI Adapter 2020-08-30 14:06:48 -04:00
Scott Shawcroft
644d2ba7a2 Add more "extern" declarations for gcc10 compat
gcc has tightened the restrictions on forward declarations that lack
"extern".  Fix them up.
2020-08-21 14:39:37 -05:00
Dan Halbert
0e30dd8bcc merge from upstream; working; includes debug_out code for debugging via Saleae for posterity 2020-08-20 20:29:57 -04:00
Yihui Xiong
52990a332d fix 2020-08-14 17:48:15 +08:00
Yihui Xiong
e7da652711 able to change ble mac address 2020-08-13 16:54:29 +08:00
Dan Halbert
f03045b97e address working; improved pkt dump 2020-07-08 23:15:48 -04:00
Dan Halbert
a5ab2829eb use zephyr include files; wip: compiles 2020-07-08 09:33:41 -04:00
Dan Halbert
f879114c43 do HCI pin init in Python, not here 2020-06-26 19:27:05 -04:00
Dan Halbert
1bc2e979eb wip; compiles; much commented out 2020-06-26 17:23:20 -04:00
Sean Cross
34f91f01c6 bleio: adapter: add advertising timeout and status
Add a field to allow specifying a timeout when initiating advertising.
As part of this, add a new property to determine if the device is still
advertising.

Additionally, have the `anonymous` property require a timeout, and set
the timeout to the maximum possible value if no timeout is specified.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-19 15:01:19 +08:00
Sean Cross
cfe65742a3 _bleio: support anonymous advertising
Add a new parameter to the `start_advertising()` function to enable
anonymous advertising.  This forces a call to `sd_ble_gap_privacy_set()`
with `privacy_mode` set to `BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY` and
`private_addr_type` set to
`BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE`.

With this, addresses will cycle at a predefined rate (currently once
every 15 minutes).

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-19 15:01:18 +08:00
Dan Halbert
346ce3b73b wip: HID bonding works! 2020-01-10 23:55:45 -05:00
Scott Shawcroft
39f4046f70
Fix pairing when peripheral. Central untested. 2019-11-21 16:32:42 -08:00
Scott Shawcroft
91c9d519ae
Refine comments and switch prefix_len to size_t 2019-10-22 23:09:56 -07:00
Scott Shawcroft
ae30a1e5aa
Refine _bleio
This PR refines the _bleio API. It was originally motivated by
the addition of a new CircuitPython service that enables reading
and modifying files on the device. Moving the BLE lifecycle outside
of the VM motivated a number of changes to remove heap allocations
in some APIs.

It also motivated unifying connection initiation to the Adapter class
rather than the Central and Peripheral classes which have been removed.
Adapter now handles the GAP portion of BLE including advertising, which
has moved but is largely unchanged, and scanning, which has been enhanced
to return an iterator of filtered results.

Once a connection is created (either by us (aka Central) or a remote
device (aka Peripheral)) it is represented by a new Connection class.
This class knows the current connection state and can discover and
instantiate remote Services along with their Characteristics and
Descriptors.

Relates to #586
2019-10-21 18:57:03 -07:00
Dan Halbert
7a64af9280 rename bleio module to _bleio 2019-08-29 18:44:27 -04:00