Commit Graph

17 Commits

Author SHA1 Message Date
Ayke van Laethem
96a2be1571 Add //go:build lines for Go 1.18
This will be needed eventually, so add them now already.
2022-04-19 11:00:08 +02:00
Yurii Soldak
7f3b96cff9 adapter: address 2021-11-05 19:16:52 +01:00
Ayke van Laethem
bb8767730c nrf: add support for S113 SoftDevice
This SoftDevice is used by default on the BBC micro:bit v2 so it's a
good idea to add support here.

Unfortunately this SoftDevice does not support scanning and connecting
to other devices. This means that I unfortunately had to duplicate the
event handler. I managed to refactor most other code to avoid
duplicating much more. (This is when macros would have been useful in
Go...)
2021-04-15 15:37:36 +02:00
Ayke van Laethem
340f6985ca Use TinyGo __app_ram_base
This makes sure the SoftDevice start address is configured in only one
place, and thus avoid potential issues when it is changed. It also will
allow setting a different SoftDevice RAM size with a linker flag
starting with LLVM 11 (when expressions are allowed in the MEMORY part
of a linker script).
2021-04-15 15:37:36 +02:00
Ron Evans
266de9824a
gattc/*: DeviceCharacteristic Read() implementation
Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-10-22 19:04:47 +02:00
Ron Evans
ef90e5d337
gattc: use GetUUID() to allow for bare metal use of short UUID. (#14)
* gattc: use UUID() to allow for bare metal to permit clean use of short UUIDs

Signed-off-by: deadprogram <ron@hybridgroup.com>

* gattc/macos: correct usage of UUID wrapper type alias

Signed-off-by: Ron Evans <ron@hybridgroup.com>

* gattc/sd: correct usage of UUID wrapper type alias

Signed-off-by: Ron Evans <ron@hybridgroup.com>

* gattc/sd, uuid/sd: changes intended to reduce memory allocations for service and characteristic discovery

Signed-off-by: deadprogram <ron@hybridgroup.com>

* gattc/sd: partial improvements to DiscoverServices/DiscoverCharacteristics

Signed-off-by: deadprogram <ron@hybridgroup.com>

* gattc/sd: mostly getting uuid back for services in DiscoverServices

Signed-off-by: deadprogram <ron@hybridgroup.com>

* uuid/sd: correct way to calculate UUID from shortUUID

Signed-off-by: deadprogram <ron@hybridgroup.com>

* gattc/sd: able to discover services and characteristics

Signed-off-by: deadprogram <ron@hybridgroup.com>

* examples: updated discover example that can run with OS or bare metal

Signed-off-by: deadprogram <ron@hybridgroup.com>

* gattc/sd: ensure safe casts for length of returned struct when converting short UUID

Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-09-13 20:21:38 +02:00
Ron Evans
6dc1dff711
gap: add connection handler to be called on adapter connect/disconnect
Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-09-10 17:17:45 +02:00
deadprogram
c3aeaf040e nrf528xx: correct returned MAC address in struct with global scan result
Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-09-09 18:46:11 +02:00
Ron Evans
c1114ad708 all: use Addresser interface to handle fact that macOS uses UUID instead of MAC as the BLE address for a peripheral
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-09-02 08:37:04 +02:00
Ayke van Laethem
de824e1884
nrf52: use low-frequency crystal oscillator when available
I couldn't measure a difference in my setup, apparently my multimeter is
not able to handle the high-to-low current transition when entering
sleep mode. But it _should_ reduce current consumption a little bit.
2020-08-01 18:39:34 +02:00
Ayke van Laethem
d2228b9e79
nrf52: use internal RC oscillator
This saves around 0.3mA according to my multimeter.
2020-07-30 15:12:28 +02:00
Ayke van Laethem
15b3e8e3e2
nrf: add GATT client
This is not entirely complete (some errors are not handled properly) but
it's a start.
2020-06-28 00:21:40 +02:00
Ayke van Laethem
d07cf38d66
all: distinguish between public and random addresses
This is necessary when connecting to a device when using the SoftDevice.
The information is not set on Linux and Windows and is ignored on those
platform when connecting.
2020-06-04 14:12:14 +02:00
Ayke van Laethem
b568c93250
all: add support for sending notifications
This is done by enabling the Notify permission and writing to the
characteristics: writes will automatically notify connected centrals.
2020-06-03 19:42:21 +02:00
Ayke van Laethem
49f8082e4b
all: replace GAP events with auto-restarting advertisements
There used to be GAP events (connect/disconnect). The main purpose for
these events was to allow applications to re-start advertisement when a
connection was lost - on nrf. Unfortunately things work differently on
Linux, which already has this behavior and for which I haven't yet
implemented these events. Therefore I have removed these events and
instead added code to automatically restart advertisement on connection
loss.

Supporting multiple (incoming) connections as a peripheral would be
useful, but is not currently supported.
2020-06-01 23:29:31 +02:00
Ayke van Laethem
0474d7b750
all: change DefaultAdapter function to global
All initialization can be done in the Enable call. This makes the API a
bit simpler and a bit more consistent between Nordic chips and other BLE
interfaces.
2020-06-01 13:27:56 +02:00
Ayke van Laethem
f91f73ede2
Add S110 version 8.0.0 SoftDevice for nrf51822
The nrf51822 chip is still widely available, for example in the BBC
micro:bit. Therefore it's a good idea to support it too.

Unfortunately, Nordic decided to change the API in some significant ways
so many parts are not compatible between S110 for nrf51 and the other
nrf52* SoftDevices.
2020-05-31 15:40:57 +02:00