Skip to content

Conversation

@fschrempf
Copy link
Contributor

I was a bit disappointed to see the loads of duplicated code and seemingly nobody being bothered by the increasing amount of copy and paste when adding new hardware variants.

So I tried to "be the change I want to see" and started to deduplicate the NRF52 board code. Except for the last commit, these changes are intended to be purely refactoring and not change the functional behavior.

The last commit enables the DC/DC converter for the RAK4631 hardware. The documentation says that the DC/DC converter can be used and it was tested to decrease the power consumption significantly.

@IoTThinks
Copy link

I have created a common NRF52Board when I tried to add in built-in temperature.

When merged, we can remove duplicated code.

Copy and paste code is not a way to go.

#1163

@fschrempf
Copy link
Contributor Author

fschrempf commented Dec 11, 2025

Force-pushed some clang-format fixes in the changed code and rebased to current dev.

@fschrempf fschrempf force-pushed the nrf52-board-deduplication branch from 4ad9903 to ebfbad4 Compare December 11, 2025 13:49
The reboot() method is the same for all NRF52 boards. Use a shared
implementation.

Signed-off-by: Frieder Schrempf <[email protected]>
Use a common begin() method that can be called from derived classes
to contain the shared initialization code.

Signed-off-by: Frieder Schrempf <[email protected]>
Some NRF52 boards are able to use the internal power-efficient DC/DC
regulator. Add a new class that can be inherited by board classes to
enable this feature and reduce the power consumption.

Signed-off-by: Frieder Schrempf <[email protected]>
The startOTAUpdate() is the same for all NRF52 boards. Use a common
implementation for all boards that currently have a specific
implementation.

The following boards currently have an empty startOTAUpdate() for
whatever reasons and therefore are not inheriting NRF52BoardOTA to
keep the same state: Nano G2 Ultra, Seeed SenseCAP T1000-E,
Wio WM1110.

Signed-off-by: Frieder Schrempf <[email protected]>
@fschrempf fschrempf force-pushed the nrf52-board-deduplication branch from ebfbad4 to aeab413 Compare December 17, 2025 09:34
The function in the derived class is virtual per definition. Mark it
to make this clearer to the reader.

Signed-off-by: Frieder Schrempf <[email protected]>
The RAK4631/RAK4630 module are able to use the DC/DC converter. Enable
it to reduce power consumption.

Signed-off-by: Frieder Schrempf <[email protected]>
@fschrempf fschrempf force-pushed the nrf52-board-deduplication branch from 2040a24 to 8eb229b Compare December 17, 2025 09:40
@fschrempf
Copy link
Contributor Author

Now rebased to current dev.

@ripplebiz @recrof @fdlamotte May I kindly ask if this could be considered for reviewing and merging? Keeping this up to date with dev as it is evolving is a bit tedious and I think everyone would benefit from removing the redundant code soon. Thanks!

@recrof
Copy link
Collaborator

recrof commented Dec 17, 2025

Now rebased to current dev.

@ripplebiz @recrof @fdlamotte May I kindly ask if this could be considered for reviewing and merging?

would love to, but only @liamcottle @ripplebiz and @fdlamotte have merge rights.

@fdlamotte fdlamotte merged commit 9b13106 into meshcore-dev:dev Dec 17, 2025
@fschrempf
Copy link
Contributor Author

@fdlamotte Thanks a lot!

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.

4 participants