Commit graph

203 commits

Author SHA1 Message Date
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
deadprogram
ba63457646 release: preparing for v0.7.0 release
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-06-12 01:46:46 +02:00
deadprogram
7f67fa0275 Update LICENSE year
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-06-12 01:46:46 +02:00
Baden Parr
eb782c5841 macos: remove unnecessary pointer indirection on service and char maps 2023-06-06 21:02:06 +02:00
Baden Parr
a341e8f543 macos: fixed reentrant service discovery 2023-06-06 21:02:06 +02:00
Ayke van Laethem
74e8f86261 nrf: clean up code after CGo improvements
Make use of a few new features in TinyGo:

  * Functions and globals in header files are supported.
  * Static functions are supported.

This allows us to remove workarounds specifically used for the lack of
support for static functions.
2023-06-06 16:59:23 +02:00
Ayke van Laethem
47d53464e4 sd: use constants from C instead of magic numbers 2023-06-03 08:21:59 +02:00
Sebastien Binet
f844306136 linux: properly close goroutines started by EnableNotifications
Fixes #168.

Signed-off-by: Sebastien Binet <binet@cern.ch>
2023-06-02 14:30:22 +02:00
Ayke van Laethem
87d24926c4 CONTRIBUTING: add note on new APIs 2023-05-15 13:04:23 +02:00
A.J. Lucas
cf51caa6ad gap/windows: Scan should set scanning mode to active to match other platforms 2023-05-11 13:54:22 +02:00
Ayke van Laethem
8260f2fb93 linux: do not randomize order of returned discovered services/chars
Previously the list of services and characteristics wasn't sorted, and
because of the way Go maps work they were in fact randomized.
This commit fixes the sorting for services and characteristics, which
both suffered from the same lack of sorting.

This fixes https://github.com/tinygo-org/bluetooth/issues/135.
2023-05-07 12:38:34 +02:00
Ayke van Laethem
5717af56e0 linux: fix characteristic scan order
This is very much like https://github.com/tinygo-org/bluetooth/pull/161,
but for Linux instead. In fact, I've copied the structure of the code
because it works for macOS.

I have tested that the scan order is now as requested. I also verified
that multiple characteristics with the same UUID are now supported, but
support is still a bit buggy: they appear in a random order (due to Go
map iteration order). I will fix this in the next commit.
2023-05-07 12:38:34 +02:00
Ayke van Laethem
7b36b3035c darwin: fix characteristic scan order
This fixes two bugs actually:

 1. The returned characteristics weren't in the order as given in the
    UUID slice.
 2. Duplicate characteristics weren't handled correctly.

I tested the first point, and it now works correctly.
I did not fully test the second point, it probably doesn't work
correctly yet because of the Device.characteristics map that is indexed
by UUID. This should be fixed in a separate change.
2023-05-07 12:32:40 +02:00
Baden Parr
51dff6faa7 linux: implement disconnect handeling
linux: remove unnecessary sending of nil prop change  

linux: first pass at watching connection events


linux: remove unneeded debug prints


linux: fix spelling

linux: fix pointer address references
2023-05-04 14:02:39 +02:00
Baden Parr
3523e14bfc macos: implement disconnect handeling
macos: add disconnect handler

macos: add default timeout and params.ConnectionTimeout handling


macos: add central manager CancelConnect call on connection timeout


macos: added address to connectHanndler call upon successful connection


macos: remove printing error on peripheral disconnection


macos: move and rename default connection timeout


macos: wait for disconnection upon timed out connection attempt
2023-05-04 14:02:39 +02:00
Yurii Soldak
e5b9a898ad nrf528xx: handle BLE_GAP_EVT_PHY_UPDATE_REQUEST
and explicitly ignore some other events
2023-05-02 12:04:01 +02:00
deadprogram
113f5fa503 build: switch to ghcr.io for docker container
Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-04-30 01:06:44 +02:00
Ayke van Laethem
71f17598be gap: Set and SetRandom methods should have a pointer receiver
Without it, these calls are a no-op.

Fixes: https://github.com/tinygo-org/bluetooth/issues/144

In particular, this fixes a problem where IsRandom() would always return
false on Linux. With this fix, it correctly returns whether the address
is a random address.
2023-04-29 22:13:00 +02:00
Ayke van Laethem
d4bca3e97f README: add note on macOS Big Sur and iTerm2
Also see: https://github.com/tinygo-org/bluetooth/issues/48
2023-04-27 17:14:19 +02:00
Ayke van Laethem
b06d666dbf all: remove Addresser
Remove the Addresser type. It isn't really necessary (the Address type
can change between OSes) and makes it difficult to fix a heap allocation
in interrupts (on the Nordic SoftDevices).

This is a backwards incompatible change, but only programs that use
SetConnectHandler should notice this.
2023-04-26 23:37:36 +02:00
Ayke van Laethem
03d77ace1c Makefile: add examples/stop-advertisement
This example wasn't included in the smoke tests, and because of that I
initially missed the use of Addresser here.
2023-04-26 23:37:36 +02:00
Ayke van Laethem
e0e261e166 softdevice: avoid a heap allocation in the SoftDevice event handler
Events are delivered using interrupts. But there was an accidental heap
allocation in the interrupt.

Fix it by using a global instead. This is safe (and doesn't need
volatile accesses), as the global is only ever accessed from that
particular interrupt.
2023-04-26 23:37:36 +02:00