Skip to content

Conversation

@dinayuil
Copy link

This pull request fixes issue #200

Proposed Changes

  • Add an OFF PHY state
  • Set a depletion call back to switch off (like Wifi module)
  • Auto schedule to switch off based on the remaining energy (like Wifi module)
  • Add a test for energy depletion
  • Some refactoring for getting current value of a state

@dinayuil dinayuil force-pushed the enhance-energy-model branch from 2bde98c to 1832f9a Compare October 13, 2025 22:33
@dinayuil

This comment was marked as resolved.

@non-det-alle non-det-alle self-requested a review October 17, 2025 11:20
@non-det-alle
Copy link
Collaborator

Hi, thank you for the contribution. I like the general idea this PR, I'll get to reviewing it as soon as I have addressed the previous PRs in the backlog.

I merged the latest changes and I have hidden your comment with test results: we have a CI pipeline to take care of that without polluting the PR msg history. In the meantime you can update this PR by fixing eventual errors detected by the CI pipeline.

@dinayuil
Copy link
Author

Merged code with recent changes from @maribu

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 80.99174% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.60%. Comparing base (0c073e7) to head (fe730d1).

Files with missing lines Patch % Lines
model/lora-radio-energy-model.cc 77.50% 9 Missing ⚠️
model/end-device-lora-phy.cc 0.00% 8 Missing ⚠️
model/class-a-end-device-lorawan-mac.cc 0.00% 4 Missing ⚠️
model/simple-end-device-lora-phy.cc 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #201      +/-   ##
===========================================
+ Coverage    84.47%   84.60%   +0.13%     
===========================================
  Files           67       68       +1     
  Lines         7016     7115      +99     
===========================================
+ Hits          5927     6020      +93     
- Misses        1089     1095       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…g ScheduleSwitchToOff inside HandleEnergyChanged to avoid nested calls
@dinayuil
Copy link
Author

I find one problem but not sure how to deal with it:
If the radio is in RX or TX, and the energy source depletes, we want to change the radio to OFF state. However, before switch, we also need to stop the RX or TX events.
A work-around might be add a Tag info marking the packet being incomplete.

I put a TODO comment in SwitchToOff function. Please let me know if you have ideas.

@dinayuil
Copy link
Author

dinayuil commented Oct 29, 2025

Removed the 'Auto schedule to switch off based on remaining energy' feature.

Reason: Encountered floating-point comparison issues when reaching to 0 energy, which could lead to an assert failure due to subtle inaccuracies.

This removal should not affect normal use cases because the BasicEnergySource class already includes a minimum energy threshold parameter (default value: 0.1×initialEnergy). Therefore, during normal simulation runs, the energy level will not typically reach a value close enough to zero to trigger the assert issue, and the simulation will stop safely beforehand.

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.

2 participants