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

Setting MFG data in for advertising #9

Open
Intellithings opened this issue Jul 19, 2021 · 6 comments
Open

Setting MFG data in for advertising #9

Intellithings opened this issue Jul 19, 2021 · 6 comments

Comments

@Intellithings
Copy link

I'm unable to set the manufacturer id of the manufacturer data in advertisingClass.js file.

I added:
this._iface1.addProperty('ManufacturerData', { type: { type: '{q(y)}' }, getter: (callback) => { callback(null, { 0xffff : [0x01, 0x02, 0x03, 0x04, 0x05] } ); } });

using nRFConnect, I can see the advertising as should, but the manufacturer id is incorrect.
I get a different id every time I run the app.

I also tried to play with the type with many other combinations ({qay} {say}, {sav} etc.)
I'm using BlueZ 5.50 on Raspberry PI Zero W

@JohnRucker
Copy link
Contributor

I'm curious, where did you get the type: '{q(y)}' description? I haven't used this module to change the manufacture data so not sure if that is the correct description to use. I would focus my efforts around that area. Also the data has to be in the correct format matching the description. The format for manufactureData is defined in the advertising-api.txt document. use dbusmon to see what this module is responding with when bluez requests information about the advertising packet.

@Intellithings
Copy link
Author

look at the table below:
https://github.com/dbusjs/node-dbus-next

I would go for {qay}
A dictionary from uint16 to array of bytes

@Intellithings
Copy link
Author

the doc says:

dict ManufacturerData
Manufactuer Data fields to include in the Advertising Data.
Keys are the Manufacturer ID to associate with the data.

(A dictionary from uint16 to array of bytes)
The command is not failing and does not return error. I can see the mfg data using nRFConnect.
I can even add 2 mfg records.
The only thing that is incorrect is the mfg-id.

Thanks!

@JohnRucker
Copy link
Contributor

Even though you are not getting an error I would still verify bluez is getting what it expects from the advertisingClass.js for mfg-id over dbus. I have seen bluez make a call over dbus and if the format is off at all it will simply reject the call and keep going without the data. I wonder if another approach would be to set the ID some how in the bluez configuration for your Raspberry Pi.

@Intellithings
Copy link
Author

Okay, I've logged the output from dbus-monitor and compared the outputs between using the code to start advertising and using bluetoothctl

ManufacturerData is a dictionary where the key is the mfg-id (uint16) and the value is the array of bytes.
When using code we get:
dict entry( string "ManufacturerData" variant array [ dict entry( string "65535" variant array of bytes [ 12 34 ] ) ] )

When using bluetoothctl we get:
dict entry( string "ManufacturerData" variant array [ dict entry( uint16 65535 variant array of bytes [ 12 34 ] ) ] )

See how the code incorrectly parsed the mfg-id to string instead of uint16.
in JavaScript I don't think you can have a numeric key of a dictionary.
Any idea how to build the dictionary in a way that the key would remain uint16?
callback(null, { 0xffff : [0x12, 0x34 ] } );
The code above is translated as:
{ '65535': [ 18, 52 ] }

@JohnRucker
Copy link
Contributor

I have a lot going on right now and not able to spend much time on this. You may want to look at the other classes I have created (I would start with the characteristicClass.js) and see if there is an example of using an array of bytes along with a definition. If not the next step is to try different combinations until you find one that works (trial and error). That is how I figured out all the definitions.

If you get it working please share your results. I would love to add this feature!

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

2 participants