bluetooth
bluetooth copied to clipboard
BLE advertisement length error
Hi!
I am trying to send a BLE advertisement with manufacturer specific data. My understanding is that when you do this, you have 27 bytes to play with for the actual data after the 2-byte company identifier.
However, I do not seem to be able to advertise anything beyond a 23-byte payload in the manufacturer data; anything above 23 bytes throws a FATA[0000] Failed to parse advertisement error. Am I doing something wrong?
MWE on Raspbery Pi 4, bluez 5.55, Raspbian w/kernel 6.1.21-v8
package main
import (
log "github.com/sirupsen/logrus"
"tinygo.org/x/bluetooth"
)
func main() {
var adapter = bluetooth.DefaultAdapter
adapter.Enable()
advMap := make(map[uint16]interface{})
//Works fine!
//advMap[0x0000] = []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}
//Throws "Failed to parse advertisement" error
advMap[0x0000] = []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a}
options := bluetooth.AdvertisementOptions{
ManufacturerData: advMap,
}
adv := adapter.DefaultAdvertisement()
if err := adv.Configure(options); err != nil {
log.Fatalf("Error configuring advertisement: %v\n", err)
}
if err := adv.Start(); err != nil {
log.Fatal(err)
}
select {}
}