Commit graph

224 commits

Author SHA1 Message Date
BCG
f100ba6eb2 ninafw: Adding init options to enable customizing hardware 2024-01-17 20:17:00 -05:00
deadprogram
bf647ecd57 ninafw: this PR contains several fixes and improvements for the NINAFW implementation including:
- correctly return from read requests instead of returning spurious error
- move some steps previously being done during Configure() into Start() where they more
correctly belonged.
- use advertising display name as the correct default value for the generic access characteristic.
- speed up the polling for new notifications for Centrals

Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-17 10:21:32 +01:00
deadprogram
564b0ba58f all: use 'debug' variable protected by build tags for debug logging
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-16 17:25:37 +01:00
deadprogram
dc7d1b4d4c build: add nina-fw smoketest as peripheral
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-15 22:57:46 -05:00
deadprogram
5c62ee4645 docs: complete README info about nina-fw support
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-15 22:57:46 -05:00
deadprogram
10d1c71078 ninafw: implement BLE peripheral support
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-15 22:57:46 -05:00
Ayke van Laethem
b8c79250c7 softdevice: add support for connection timeout on connect
This adds support for the "connection supervision timeout", basically
the connection timeout while the connection is active (as opposed to
while connecting).
2024-01-12 14:56:32 +01:00
Ayke van Laethem
ecf09759ac softdevice: fix connect timeout
This fixes the connection timeout. Previously it would try to connect
for a time 16 times as much as specified by the user.
2024-01-12 14:56:32 +01:00
Ayke van Laethem
3f8f8a6622 softdevice: return an error on a connection timeout
This makes sure an error is reported on a connection timeout. Previously
it would just block forever.
2024-01-12 14:56:32 +01:00
Ayke van Laethem
d74f6a1009 all: add RequestConnectionParams to request new connection parameters
This allows changing the connection latency, slave latency, and
connection timeout of an active connection - whether in the central or
peripheral role. This is especially helpful on battery operated BLE
devices that don't have a lot of power and need to lower the connection
latency for improved speed. It might also be useful for devices that
need high speed, as the defaults might be too low.
2024-01-11 15:53:20 +01:00
Ayke van Laethem
5d805a929c all: use Device instead of Address in SetConnectHandler
This makes it possible to discover services on a connected central while
in peripheral mode, for example.
2024-01-11 15:53:20 +01:00
Ayke van Laethem
c9eafaff20 all: make Device a value instead of a pointer
This is a refactor that is necessary to make it easier to work with
connected central devices on a SoftDevice.
2024-01-11 15:53:20 +01:00
Ayke van Laethem
6e0df0ec3c softdevice: add address of connecting device
I thought it wasn't available, but in fact it is. So let's make it
available in the connect handler.
2024-01-11 15:53:20 +01:00
Ayke van Laethem
735333aa1a softdevice: print connection parameters when debug is enabled
This is very useful for debugging, though we should probably expose this
in some way to users of the bluetooth package without changing a
constant.
2024-01-11 15:53:20 +01:00
deadprogram
56e56f3647 build: add arduino-nano33 and pyportal to smoke tests
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-07 08:59:59 +01:00
deadprogram
f639d80012 ninafw: add support for software RTS/CTS flow control for boards where hardware support is not available
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-07 08:59:59 +01:00
Ayke van Laethem
cd3c0c4835 linux: fix characteristic value
I left in a debugging value. Oops. Let's fix that quickly.
2024-01-06 15:49:26 +01:00
deadprogram
c5ab6a9b65 ninafw: use NINA settings from board file in main TinyGo repo
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-05 20:09:54 +01:00
Ayke van Laethem
eb30760e41 ninafw: fix connection timeout
The break statement didn't actually break the for loop, it just exited
the switch case.

Discovered because VS Code flagged the code after the loop as dead code.
2024-01-05 18:13:33 +01:00
Fabianexe
190c4be423
darwin: add Write command to the gattc implementation 2024-01-05 14:03:30 +01:00
Ayke van Laethem
5746ccfb60 all: don't use a pointer receiver for many method calls
This is unnecessary because the values are passed by value in other
cases, and can in some cases lead to more (heap or stack) allocation
than is necessary.
2024-01-04 20:43:16 +01:00
Anton Onipko
83fba1b809
Release AsyncOperationCompletedHandler (#208)
windows: release AsyncOperationCompletedHandler
2024-01-04 20:28:49 +01:00
deadprogram
b8a4a54d5f build: add some ninafw examples to smoketest
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-04 14:35:20 +01:00
deadprogram
30138095e1 ninafw: implement GetMTU()
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-04 14:35:20 +01:00
deadprogram
044320ea69 ninafw: remove some pointer receivers from method calls
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-04 14:35:20 +01:00
deadprogram
930a5c7a88 docs: a small mention of the NINA BLE support
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-04 14:35:20 +01:00
deadprogram
92c12af54f ninafw: BLE central implementation on nina-fw co-processors
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-04 14:35:20 +01:00
Ayke van Laethem
1860e505b9 examples/discover: add MTU
This is useful for testing.
2024-01-03 22:08:13 +01:00
Ayke van Laethem
d77521461d linux: rewrite everything to use DBus directly
This is a big rewrite to use DBus calls directly instead of going
through go-bluetooth first.

This is a big change, but I believe it is an improvement. While the
go-bluetooth works for many cases, it's a layer in between that I
believe hurts more than it helps. Without it, we can just program
directly against the BlueZ D-Bus API. The end result is about 10% more
code.

With this rewrite, I fixed the following issues:

  * All MapToStruct warnings are gone, like in
    https://github.com/tinygo-org/bluetooth/issues/193.
  * Advertisements can be restarted after they were stopped. Previously
    this resulted in a panic.
  * Looking at the source code of go-bluetooth, it appears that it
    includes devices from a different Bluetooth adapter than the one
    that's currently scanning. This is fixed with the rewrite.
  * Fix a bug in Adapter.AddService where it would only allow adding a
    single service. Multiple services can now be added.
    This was actually the motivating bug that led me down to rewrite the
    whole thing because I couldn't figure out where the bug was in
    go-bluetooth (it's many layers deep).
  * The `WriteEvent` callback in a characteristic now also gets the
    'offset' parameter which wasn't provided by go-bluetooth.

This rewrite also avoids go-bluetooth specific workarounds like
https://github.com/tinygo-org/bluetooth/pull/74 and
https://github.com/tinygo-org/bluetooth/pull/121.

I have tested all examples in the smoketest-linux Makefile target. They
all still work with this rewrite.
2024-01-03 20:40:48 +01:00
Ayke van Laethem
b278e2b932 go fmt 2024-01-03 20:33:10 +01:00
deadprogram
8f92747a18 examples: update MCU central examples to use ldflags to pass the desired device to connect to
Signed-off-by: deadprogram <ron@hybridgroup.com>
2024-01-03 16:12:16 +01:00
Ayke van Laethem
ec80e0111e softdevice: don't send a notify/indicate without a CCCD
sd_ble_gatts_hvx_noescape can only be called when the notify/indicate
permission is set (and therefore a CCCD has been added). Without it, it
will just return an error.

This fixes a problem I found on the PineTime, while implementing the
battery service.
2023-12-25 12:48:31 +01:00
Ayke van Laethem
b5d4e3f82a softdevice: fix writing to a characteristic
This seems to have been broken since
https://github.com/tinygo-org/bluetooth/pull/192, I suspect it's a
problem with the struct calling convention (which most certainly is a
TinyGo CGo bug, but at least this works around the problem).
2023-12-25 12:41:39 +01:00
Ayke van Laethem
01243181c3 sd: update to prepare for changes in the TinyGo CGo implementation
For details, see: https://github.com/tinygo-org/tinygo/pull/3927

I ran the smoke tests and the binaries are exactly identical to what
they were before, so this change cannot have had an effect on these
smoke tests (which is expected, as this is mostly just changing some
types without changing the machine data type).
2023-10-05 19:11:46 +02:00
deadprogram
d0c7887b81 Update for release 0.8.0
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-09-21 13:45:40 +02:00
deadprogram
195d418876 build: remove CGo dependencies for Windows cross-compiler tests
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-09-21 12:54:07 +02:00
deadprogram
0cc860c018 docs: update README to remove CGo requirement for Windows
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-09-21 12:54:07 +02:00
deadprogram
1f58ec1fb4 windows: update github.com/saltosystems/winrt-go to no longer require CGo
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-09-21 12:54:07 +02:00
Filip Vranesevic
d34d15d830 Noescape workaround 2023-09-01 20:01:24 +02:00
deadprogram
20ccbeb113 build: add Windows to GH actions build jobs
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-08-29 22:57:42 +02:00
deadprogram
0403d51c8a build: add macOS 12 to GH actions build jobs
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-08-29 21:41:43 +02:00
Hari Bhaskaran
4da7f58124 Include WriteWithoutResponse permission, for examples, where Write exists 2023-08-11 14:26:37 +02:00
Erik de Vries
d9490f73ea Update dependencies - add documentation to heartrate-monitor 2023-08-11 12:49:03 +02:00
Binozo
d5276e5aed added manufacturer data support on SoftDevices 2023-08-11 11:52:12 +02:00
Binozo
da2032de42 Added option to add ManufacturerData to Advertisement 2023-08-11 11:52:12 +02:00
Ayke van Laethem
c3f9d593de sd: test creation of raw BLE advertisement packets
I realized we didn't have any tests for this yet, which we really should
have. So here they are.
2023-08-05 23:09:52 +02:00
Yurii Soldak
f9436906c1 all: go 1.18 and remove old-style build tags 2023-07-31 15:54:58 +02:00
Baden Parr
3c9cf83de2 macos: enable support for duplicate chars by moving from a map to a slice 2023-07-16 20:53:17 +02:00
Jagoba Gascón
4d067bc2b3 winrt-go: bump to latest
This version fixes critical bugs that caused random errors at runtime.
For more details see saltosystems/winrt-go/issues#71 and
saltosystems/winrt-go/issues#72. Diff:
e096b9a...c792451
2023-06-14 08:42:31 +02:00
deadprogram
1c44c024fd modules: update to latest TinyGo drivers and friends
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-06-12 01:46:46 +02:00