-
Notifications
You must be signed in to change notification settings - Fork 2.1k
BTHome: New feature #20996
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
base: master
Are you sure you want to change the base?
BTHome: New feature #20996
Conversation
After talking to @BOZHENG001, I think the problem is that Skald is implementing an older BLE version than BTHome expects and thus fields (such as TXAdd which is used as part of the nonce for encryption) are not in the place Home Assistant expects them to be. Will try to confirm this somehow. |
adea8cd to
5d6f27b
Compare
| /* start advertising */ | ||
| _sched_next(ctx); | ||
| #if IS_USED(MODULE_SKALD_UPDATE_PKT_CB) | ||
| event_loop(&ctx->queue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the rationale for introducing an event queue here? This will prevent the skald_adv_start function from returning, which should at least be documented somewhere for the user.
But I would rather call the user-provided callback within ISR context and shift thread-safety and the onus of having an event queue to the user side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of starting and running a queue exclusiv for skald a already exiting one might be used either given by parameter to skald_adv_start or CONFIG_SKALD_QUEUE or just depending on event_thread
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just depending on
event_thread
That'd sound more sensible to me. Also, I think this dependence would then only be needed for skald_bthome_saul and not for skald_update_pkt_cb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I just copied that behavior from the other skald “daemons” (that's what I see them as). I can have a look, if I find some time.
f2afd01 to
5f22fdb
Compare
|
Rebased to current master |
2a68e3b to
eed3e65
Compare
433bfca to
462222a
Compare
Co-authored-by: crasbe <[email protected]>
Co-authored-by: crasbe <[email protected]>
b907d14 to
7bf991b
Compare
|
I think I addressed all your comments now. What I will now do, to get this in a mergeable state:
|
9a1845a to
e31af82
Compare
|
Encryption part is now in #21699 |
e31af82 to
f24fbc4
Compare
|
Added a test, it is still WIP though (did not check if the output is actually correct and I also want to increase the coverage). |
802e09c to
4b47bbf
Compare
| // if ((res = skald_bthome_add_int8_measurement( | ||
| // &_ctx, BTHOME_ID_TEMPERATURE_FACTOR_1, 0x12 | ||
| // )) < 0) { | ||
| // printf("Unable to add temperature factor 1 measurement: %s\n", strerror(res)); | ||
| // return 1; | ||
| // } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // if ((res = skald_bthome_add_int8_measurement( | |
| // &_ctx, BTHOME_ID_TEMPERATURE_FACTOR_1, 0x12 | |
| // )) < 0) { | |
| // printf("Unable to add temperature factor 1 measurement: %s\n", strerror(res)); | |
| // return 1; | |
| // } | |
| /* if ((res = skald_bthome_add_int8_measurement( | |
| * &_ctx, BTHOME_ID_TEMPERATURE_FACTOR_1, 0x12 | |
| * )) < 0) { | |
| * printf("Unable to add temperature factor 1 measurement: %s\n", strerror(res)); | |
| * return 1; | |
| * } | |
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any reason to keep this, actually (in case the test output is correct). However, it also serves as a test if the overflow protection works. So keeping as is ftm.
Co-authored-by: crasbe <[email protected]>
Contribution description
Little weekend (or rather Thursday and Friday night) project of mine. This extends Skald, who advertises to the world with BTHome, "an energy efficient but flexible BLE format for devices to broadcast their sensor data and button presses". The main use case is to integrate BLE-powered devices into Home Assistant.
Most of the spec is supported, except "Trigger based advertisements" (since Skald at the moment only advertises periodically). For encryption, I was able to confirm with the spec examples that at least from the generated output
is the expected one, given the example input, but Home Assistant is for some reason not able to decrypt the message (even the one in the examples)... So further investigation is needed.
TODOs:
Testing procedure
So far only tested by flashing a node and seeing the device pop-up in Home Assistant:
Issues/PRs references
None