[LoRaWAN] Accept const uint8_t*
on public API
#1302
Merged
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.
The goal of this PR is allowing the caller to pass
const uint8_t*
parameters to the public methods ofLoRaWANNode
.Some
LoRaWANNode
methods, such asbeginOTAA
, take buffers as parameters (in this case, the AppKey and NwkKey) with typeuint8_t*
. However, in many cases, the buffers are not modified and could be specified asconst
. Not usingconst
makes the caller unable to pass aconst uint8_t APP_KEY[16]
, for example, resulting in a compilation error such as:In this PR, I focused just on public methods, but there may be other opportunities to use pointers to
const
elsewhere in the file. Unfortunately, the change leaked into Utils.cpp, asRADIOLIB_DEBUG_PROTOCOL_HEXDUMP
callsrlb_hexdump
, which also takes a non-const parameter despite not modifying it. It should not change behavior, but if you'd rather avoid changing it, I can undo theconst
change insetBufferNonces
.