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

Add support for advertising-only sensors #360

Merged
merged 45 commits into from
Aug 20, 2023
Merged

Add support for advertising-only sensors #360

merged 45 commits into from
Aug 20, 2023

Conversation

qwandor
Copy link
Collaborator

@qwandor qwandor commented Jul 17, 2023

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Jul 17, 2023

Codecov Report

Merging #360 (d456b15) into master (264d6a7) will increase coverage by 3.97%.
Report is 4 commits behind head on master.
The diff coverage is 77.05%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master     #360      +/-   ##
==========================================
+ Coverage   51.38%   55.36%   +3.97%     
==========================================
  Files          35       42       +7     
  Lines        5704     6750    +1046     
==========================================
+ Hits         2931     3737     +806     
- Misses       2773     3013     +240     
Files Changed Coverage Δ
btsensor/examples/scan.rs 0.00% <0.00%> (ø)
btsensor/src/bthome.rs 0.00% <0.00%> (ø)
btsensor/src/bthome/events.rs 56.60% <56.60%> (ø)
btsensor/src/bthome/v2.rs 67.82% <67.82%> (ø)
btsensor/src/bthome/v1.rs 76.10% <76.10%> (ø)
btsensor/src/lib.rs 79.38% <79.38%> (ø)
btsensor/src/atc.rs 98.00% <98.00%> (ø)

@qwandor qwandor force-pushed the btsensor branch 4 times, most recently from 3a2aad9 to de77dea Compare July 18, 2023 17:23
Copy link
Owner

@alsuren alsuren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am apparently watching this repo so closely that I even get notified about draft PRs. I gave it a skim and it looks good so far.

///
/// In other words, the value stored should be divided by 10 to the power of this number to get
/// the actual value.
fn decimal_point(self) -> i32 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably call this denominator or something, and make it return an integer or float (1.0 or 100.0 or 1000.0)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Cargo.toml Show resolved Hide resolved
@qwandor qwandor force-pushed the btsensor branch 2 times, most recently from d9d226c to 6a6f4ad Compare July 21, 2023 18:40
@qwandor qwandor force-pushed the btsensor branch 2 times, most recently from d2afe32 to b05902d Compare August 18, 2023 13:15
@qwandor qwandor force-pushed the btsensor branch 2 times, most recently from d9b7fa0 to b9f5389 Compare August 18, 2023 14:31
@qwandor qwandor marked this pull request as ready for review August 18, 2023 22:12
Copy link
Owner

@alsuren alsuren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔋📏💡⚖️⚡️🏎️🌡️💦🪫🥶🚪🎤🫨🪟🎛️

}

/// Attempts to decode the given service data as a BTHome v1 advertisement.
pub fn decode(mut data: &[u8]) -> Result<Vec<Element>, DecodeError> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(optional suggestion) move this onto Element and call it decode_all()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

{ 0x00, PacketId, u8, read_u8, "packet ID", "" },
{ 0x51, Acceleration, u16, read_u16, "acceleration", "m/s²" },
{ 0x01, Battery, u8, read_u8, "battery", "%"},
{ 0x12, Co2, u16, read_u16, "CO2", "ppm"},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what order are these in? Is that how they're listed in the spec?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the order from the spec.

@qwandor qwandor merged commit d398641 into master Aug 20, 2023
5 checks passed
@qwandor qwandor deleted the btsensor branch August 20, 2023 08:46
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

Successfully merging this pull request may close these issues.

3 participants