This was my attempt to figure out why scanning doesn't work on my
system. Sadly it still doesn't work, but at least I know there's no
error in this place.
(Note: I'm doing this on Windows ARM in a VM, so it's a rather special
setup).
* gap: fix comment
* gap: expose ServiceData() in AdvertisementFields
* macos: include ServiceData in AdvertisementFields
* gap/linux: include ServiceData in AdvertisementFields
* gap: add unimplemented ServiceData() to raw advertisement
* added ServiceData advertising element also to the sending pieces
* more explicitly use the ad element type ids
* added a test case for ServiceData
* linux: added ServiceData advertising element
* sd: fix: handle no servicedata present
* linux: bluez uses string uuids for service data
* linux: fix: correct datatype for advertise with ServiceData
* uuid: add 32-Bit functions
* ServiceData now also uses a slice instead of a map as in #244
* Revert unnessesary changes
* formatting
* remove extra check
---------
Co-authored-by: William Johansson <radar@radhuset.org>
This is a breaking change, but I believe it is necessary for
correctness. Because maps have an undefined iteration order, the actual
advertised packet could change each time which I think is a bad thing.
In addition to that, using a slice should be much more lightweight than
using a map.
I've also added some tests (that should have been there in the first
place) and added some manufacturer data to the advertisement example.
Furthermore, I've optimized the code that constructs manufacturer data
for raw advertisement payloads, it should now be entirely free of heap
allocations.
- add l2cap signaling support
- implement evtNumCompPkts to count in-flight packets
- correct implementation for WriteWithoutReponse
- speed up time waiting for hardware
- corrections to MTU exchange
Signed-off-by: deadprogram <ron@hybridgroup.com>
- 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>
This adds support for the "connection supervision timeout", basically
the connection timeout while the connection is active (as opposed to
while connecting).
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.
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.
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.
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.
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.
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).
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).