Closed potto216 closed 8 months ago
Yes, sounds good to me!
Great I'll fork the repo and make the changes on master unless the changes should be in a branch
@surban here is a prototype to save advertisements to a file. The prototype does not yet have the command line switches. The basic idea is to call the append method to add a new json record of the advertisement when it is received. Recorded advertisments look like:
{
"adv_name": {
"RSSI": -47,
"address": "5D:2D:65:3D:3B:66",
"address_type": "random",
"last_seen": 8,
"local_name": "",
"manufacturer_data": "0x004C: [0x16 0x08 0x00 0x54(T) 0xDD 0x5A(Z) 0xB5 0x9E 0xC2 0xE2]",
"service_data": ""
},
"time_recorded": "2024-02-09T19:09:21.337408427+00:00"
},
{
"adv_name": {
"RSSI": -34,
"address": "00:15:A3:00:3E:D3",
"address_type": "public",
"last_seen": 3,
"local_name": "UM34C",
"manufacturer_data": "0x050E: [0xD3 0x3E(>) 0x00 0xA3 0x15 0x00]",
"service_data": ""
},
"time_recorded": "2024-02-09T19:09:21.353514634+00:00"
},
A couple issues to resolve.
bluemon
is with CTRL-C the program currently ends without writing the closing array bracket ]
. Possible solutions I thought of around this are:
]
. Also in this case the logger could write out the entire file or large chunks of the file so it doesn't slow down the I/O by flushing each advertisement to disk. logger.append
statement in the event loop appropriate? Is there a better design pattern to use.Once the code changes are done I'll merge this branch into my master for the PR.
Looks good to me in general.
However, due to the problems with invalid JSON, I would suggest using JSON lines instead. You will not always be able to catch process termination and thus might end up with invalid JSON data on disk.
Please send a PR. It's easier to review when a diff is available.
Created PR https://github.com/bluez/bluer/pull/133 for review
Merge complete, the issue can be closed.
It would be useful for one of the bluer-tools to have a command line option to save advertising reports for future analysis and comparisons. Currently I modified
blumon
to save the reports in a JSON array with an example given below:Is there interest in accepting a PR for either modifying an existing bluer-tools program or creating a new one to include this functionality? I think having bluer-tools that can run at the command line by users not familiar with Rust will increase the adoption of BlueR and fill a gap in BlueZ command line tool capability, especially since the hci tools are deprecated.
The requirements of the feature would be:
@surban what are your thoughts?