bluetooth icon indicating copy to clipboard operation
bluetooth copied to clipboard

AdvertisementPayload.Bytes() is nil on linux

Open ecksun opened this issue 5 years ago • 5 comments
trafficstars

It appears as if AdvertisementPayload.Bytes() is nil on linux.

What I specifically need is the ManufacturerData however I'm not sure how to fit that into the AdvertisementPayload.Bytes() interface.

ecksun avatar Oct 15 '20 10:10 ecksun

You mean you want to publish this data? AdvertisementPayload is for when you want to act as a peripheral.

deadprogram avatar Oct 15 '20 17:10 deadprogram

You mean you want to publish this data?

No, i want the ManufacturerData which from the advertisement of other peripherals

AdvertisementPayload is for when you want to act as a peripheral.

Are you sure about that?

Adapter.Scan takes a func(*Adapter, ScanResult) which contains an AdvertisementPayload.

Obviously I can be mistaken but I couldn't find how to get the manufacturerdata when trying earlier today.

ecksun avatar Oct 15 '20 20:10 ecksun

AdvertisementPayload.Bytes() will always be nil on Linux, because BlueZ does not expose this information.

That said, adding manufacturer data to the AdvertisementPayload should not be very difficult to do, as BlueZ does expose this information. It's just not implemented yet.

aykevl avatar Oct 25 '20 15:10 aykevl

AdvertisementPayload.Bytes() will always be nil on Linux, because BlueZ does not expose this information.

Alright, good to know.

That said, adding manufacturer data to the AdvertisementPayload should not be very difficult to do, as BlueZ does expose this information. It's just not implemented yet.

Are you suggesting doing something like this:

type AdvertisementPayload interface {
	LocalName() string
	HasServiceUUID(UUID) bool
	Bytes() []byte
	ManufacturerData() map[uint16]interface{} // map[uint16][]byte ?
}

ecksun avatar Oct 25 '20 22:10 ecksun

Yes something like that (with map[uint16][]byteinstead ofmap[uint16]interface{}`), or maybe even this:

type AdvertisementPayload interface {
	LocalName() string
	HasServiceUUID(UUID) bool
	ManufacturerData(key uint16) []byte
	Bytes() []byte
}

aykevl avatar Oct 25 '20 22:10 aykevl