Repository navigation
fix(beacon): repair the MeshBeacon radio switch/restore regression from #11573 #11596
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b0612d3
fix(radio): put the beacon restore back inside completeSending's if (p)
NomDeTom 4a55801
fix(radio): bound the payload at the radio queue, not mid-transmit
NomDeTom 9cb7b96
fix(beacon): guard the radio switch/restore against re-entry and earl…
NomDeTom 1b2942f
Merge branch 'develop' into maple-beacon
thebentern d4f3db3
fix(beacon,radio): address review findings on #11596
NomDeTom 004c35b
Merge branch 'develop' into maple-beacon
NomDeTom 03e0231
fix(beacon): route the invalid-target drop through abandonBeaconTarget
NomDeTom de2c854
fix(radio): take the abandoned packet as a pointer to const
NomDeTom f3e1552
refactor(radio): drive the beacon radio switch through TX hooks
NomDeTom d84583a
fix(beacon): restore the home config for a packet that jumps the queue
NomDeTom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #include "RadioTxHook.h" | ||
|
|
||
| RadioTxHook *RadioTxHook::hookList = nullptr; | ||
|
|
||
| RadioTxHook::RadioTxHook() | ||
| { | ||
| nextHook = hookList; | ||
| hookList = this; | ||
| } | ||
|
|
||
| RadioTxHook::~RadioTxHook() | ||
| { | ||
| for (RadioTxHook **slot = &hookList; *slot; slot = &(*slot)->nextHook) { | ||
| if (*slot == this) { | ||
| *slot = nextHook; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| RadioTxHook::PreTxAction RadioTxHooks::beforeTransmit(RadioInterface *iface, meshtastic_MeshPacket *p) | ||
| { | ||
| for (RadioTxHook *h = RadioTxHook::hookList; h; h = h->nextHook) { | ||
| const RadioTxHook::PreTxAction action = h->beforeTransmit(iface, p); | ||
| if (action != RadioTxHook::PRETX_SEND) | ||
| return action; | ||
| } | ||
| return RadioTxHook::PRETX_SEND; | ||
| } | ||
|
|
||
| bool RadioTxHooks::holdsRadio(const meshtastic_MeshPacket *p) | ||
| { | ||
| for (RadioTxHook *h = RadioTxHook::hookList; h; h = h->nextHook) | ||
| if (h->holdsRadio(p)) | ||
| return true; | ||
| return false; | ||
| } | ||
|
|
||
| void RadioTxHooks::packetReleased(RadioInterface *iface, const meshtastic_MeshPacket *p) | ||
| { | ||
| for (RadioTxHook *h = RadioTxHook::hookList; h; h = h->nextHook) | ||
| h->packetReleased(iface, p); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #pragma once | ||
|
|
||
| #include "MeshTypes.h" | ||
|
|
||
| class RadioInterface; | ||
|
|
||
| /** | ||
| * A module's hook into the radio driver's per-packet TX lifecycle. | ||
| * | ||
| * The driver knows this interface and nothing about who implements it: a module needing per-packet | ||
| * radio state (MeshBeacon's preset switch) subclasses this, and one instance registers itself for | ||
| * the life of the program. | ||
| */ | ||
| class RadioTxHook | ||
| { | ||
| friend class RadioTxHooks; | ||
|
|
||
| RadioTxHook *nextHook = nullptr; | ||
| static RadioTxHook *hookList; | ||
|
|
||
| public: | ||
| /// What the driver should do with the packet at the head of the TX queue. | ||
| enum PreTxAction { | ||
| PRETX_SEND, ///< nothing pending, transmit as usual | ||
| PRETX_DEFER, ///< the radio config changed, re-run the transmit delay before sending | ||
| PRETX_DROP ///< this packet must not go out on the current radio config | ||
| }; | ||
|
|
||
| RadioTxHook(); | ||
| virtual ~RadioTxHook(); | ||
|
|
||
| /// The driver is about to transmit p (NULL when the queue is empty): set up any state it needs. | ||
| virtual PreTxAction beforeTransmit(RadioInterface *iface, meshtastic_MeshPacket *p) { return PRETX_SEND; } | ||
|
|
||
| /// True while p needs the radio left on its own config, so the driver must not listen instead. | ||
| virtual bool holdsRadio(const meshtastic_MeshPacket *p) { return false; } | ||
|
|
||
| /// The driver is done with p - sent, cancelled or dropped. Release anything held for it. | ||
| virtual void packetReleased(RadioInterface *iface, const meshtastic_MeshPacket *p) {} | ||
| }; | ||
|
|
||
| /// Driver-side fan-out over the registered hooks; every call is a no-op when none are registered. | ||
| class RadioTxHooks | ||
| { | ||
| public: | ||
| /// The first hook not returning PRETX_SEND decides, and the rest are not consulted. | ||
| static RadioTxHook::PreTxAction beforeTransmit(RadioInterface *iface, meshtastic_MeshPacket *p); | ||
| static bool holdsRadio(const meshtastic_MeshPacket *p); | ||
| static void packetReleased(RadioInterface *iface, const meshtastic_MeshPacket *p); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.