Commit Graph

40 Commits

Author SHA1 Message Date
Dan Halbert
a397af9bdf Round BLE timing values; fix timeout check 2021-01-10 13:16:19 -05:00
Dan Halbert
a11ad25727 BLE fixes 2020-12-23 16:39:27 -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
Dan Halbert
94ecf33a5c
Merge pull request #3281 from dhalbert/fix-spim3-buffer-location
SPIM3 buffer must be in first 64kB of RAM
2020-08-17 19:28:03 -04:00
Scott Shawcroft
377503e61c
Merge pull request #3284 from dhalbert/fix-3171-evt-handler
Remove event handler before setting it to NULL
2020-08-17 15:02:29 -07:00
Dan Halbert
ef40f83f99 Remove event handler before setting it to NULL 2020-08-15 14:39:53 -04:00
Dan Halbert
cf0f3d70b5 SPIM3 buffer must be in first 64kB of RAM 2020-08-15 10:31:56 -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
06f3b4048a fix #3228 for nrf; still needs to be fixed for HCI; tested 2020-08-11 16:21:16 -04:00
Sean Cross
c1bcc25b88 nrf: _bleio: clean up timeout calculation
The timeout value is calculated by the common-hal layer now, so we don't
need to be quite so clever about calculating it here.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-19 21:56:39 +08: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
Scott Shawcroft
755d404edf
Merge remote-tracking branch 'adafruit/master' into lower_power 2020-04-27 16:45:10 -07:00
Sean Cross
c04e6d6f52 nrf: bleio: parameterize softradio configuration
Allow for setting various softradio memory settings as part of a
board in order to support lower-memory configurations.  If a
parameter is unspecified then the previously-defined value is used.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-21 12:29:59 +08:00
Scott Shawcroft
6f60afe8c5
First try at lowering the power consumption 2020-03-13 11:12:30 -07:00
Scott Shawcroft
28c7a1e9c3
Fix crash after empty REPL session
We were trying to reset bluetooth when it was off and then trying
to raise an exception without the heap.
2020-02-24 16:11:17 -08:00
Scott Shawcroft
72a1bdab30
Add another error message for extended advertisements at the same
time as scan response. The SD can't do it.
2020-02-05 15:56:17 -08:00
Dan Halbert
4abd5f1f7b increase max connections from 2 to 5 2020-01-31 14:58:23 -05:00
Dan Halbert
87f73e2729 track vm_used_ble better 2020-01-30 09:52:06 -05:00
Dan Halbert
2a75196aa3 merge from adafruit/circuitpython 2020-01-13 18:15:32 -05:00
Dan Halbert
346ce3b73b wip: HID bonding works! 2020-01-10 23:55:45 -05:00
Dan Halbert
9c167af17a wip; redid flash writing to be compatible with SD 2020-01-09 17:40:02 -05:00
Dan Halbert
390337b9a5 wip; compiles 2020-01-05 23:33:42 -05:00
Scott Shawcroft
82fb761c0f
Add PacketBuffer and MTU negotiation support.
PacketBuffer facilitates packet oriented BLE protocols such as BLE
MIDI and the Apple Media Service.

This also adds PHY, MTU and connection event extension negotiation
to speed up data transfer when possible.
2020-01-03 17:29:54 -08:00
Dan Halbert
ae64a669dd address review comments 2019-12-11 15:43:06 -05:00
Dan Halbert
68ae47907c merge from upstream 2019-12-10 21:04:46 -05:00
Dan Halbert
f5e913101c
Merge pull request #2301 from tannewt/support_extended_advertising
Add support for extended (>31 byte) BLE advertisements.
2019-12-06 23:51:05 -05:00
Dan Halbert
40434d6919 wip 2019-12-05 22:45:53 -05:00
Scott Shawcroft
17c8356b8c
Add connection interval and debugging
This also sets TinyUSB to master and to not include its submodules.

It also fixes an old displayio example comment and retries gattc
reads.
2019-12-04 14:39:02 -08:00
Scott Shawcroft
3fc58cee38
Merge remote-tracking branch 'adafruit/master' into support_extended_advertising 2019-11-26 13:12:43 -08:00
Jeff Epler
77b78d7fb9 Merge remote-tracking branch 'origin/master' into tick-refactor 2019-11-22 14:28:51 -06:00
Scott Shawcroft
39f4046f70
Fix pairing when peripheral. Central untested. 2019-11-21 16:32:42 -08:00
Scott Shawcroft
5e857fdb67
Use BluetoothError in _bleio
This better differentiates errors than using OSError everywhere.
2019-11-20 14:02:15 -08:00
Scott Shawcroft
11c2c3443f
Add support for extended (>31 byte) BLE advertisements. 2019-11-19 13:55:58 -08:00
Jeff Epler
7f744a2369 Supervisor: move most of systick to the supervisor
This code is shared by most parts, except where not all the #ifdefs
inside the tick function were present in all ports.  This mostly would
have broken gamepad tick support on non-samd ports.

The "ms32" and "ms64" variants of the tick functions are introduced
because there is no 64-bit atomic read.  Disabling interrupts avoids
a low probability bug where milliseconds could be off by ~49.5 days
once every ~49.5 days (2^32 ms).

Avoiding disabling interrupts when only the low 32 bits are needed is a minor
optimization.

Testing performed: on metro m4 express, USB still works and
time.monotonic_ns() still counts up
2019-11-18 11:01:23 -06: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
7b79ac3739 Parameterize linker script 2019-10-20 23:50:12 -04:00
Dan Halbert
7a64af9280 rename bleio module to _bleio 2019-08-29 18:44:27 -04:00