I can filter manufacturer data using bluetooth API for JS but I can not find the manufacturer data through JS

71 Views Asked by At

I am trying to obtain the manufacturer data of my device from Windows using web bluetooth api. I am using filters in the navigator.bluetooth.requestDevice(filters) with the specified manufacturer data which gives the correct device. Now I want to get the manufacturer data of that device in the javascript but I am not being able to get that.

I have tried using the advertisementreceived event call, but that event returns manufacturerData as BluetoothManufacturerDataMap with size:0

this.manufacturerDataSat.companyIdentifier = parseInt('0x6969');
        this.manufacturerDataIphone.companyIdentifier = parseInt('0x004C');

        this.requestOptions = { filters: [{ manufacturerData: [this.manufacturerDataSat] }, { manufacturerData: [this.manufacturerDataIphone] }]}

const device = await navigator.bluetooth.requestDevice(this.requestOptions).then((device)=>{
                    console.log(device);
                    return device
                })
                device.addEventListener('advertisementreceived', (event) => {
                    console.log(event.manufacturerData)
                });

The picture shows the output that i get for event.manufacturerData. Please can anyone tell how to get the manufacturerData (https://i.stack.imgur.com/e3mW8.png)

0

There are 0 best solutions below