Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE advertisement length error #197

Open
gigaryte opened this issue Sep 26, 2023 · 0 comments
Open

BLE advertisement length error #197

gigaryte opened this issue Sep 26, 2023 · 0 comments

Comments

@gigaryte
Copy link

gigaryte commented Sep 26, 2023

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 {}

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant