Skip to content

Conversation

@thedjnK
Copy link
Contributor

@thedjnK thedjnK commented Oct 20, 2024

Adds a transport that uses LoRaWAN for receiving and responding to messages

Showing transport in action:
image

@thedjnK thedjnK added this to the v4.0.0 milestone Oct 20, 2024
@zephyrbot zephyrbot added area: mcumgr Release Notes To be mentioned in the release notes labels Oct 20, 2024
@thedjnK thedjnK force-pushed the mcumgrlora branch 2 times, most recently from cf92709 to 2dd4473 Compare October 20, 2024 10:03
Copy link
Contributor

@kartben kartben left a comment

Choose a reason for hiding this comment

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

Very cool!
This needs a global search and replace s/LoRa/LoRaWAN/g though as it actually is a LoRaWAN transport, not "LoRa" or "LoRa (LoRaWAN)" one. Related, referring to things like e.g. "LoRa frame port" is incorrect.

@thedjnK
Copy link
Contributor Author

thedjnK commented Oct 20, 2024

Very cool! This needs a global search and replace s/LoRa/LoRaWAN/g though as it actually is a LoRaWAN transport, not "LoRa" or "LoRa (LoRaWAN)" one. Related, referring to things like e.g. "LoRa frame port" is incorrect.

Renamed

@thedjnK thedjnK requested a review from kartben October 20, 2024 10:45
@thedjnK thedjnK changed the title mgmt: mcumgr: transport: Add LoRa MCUmgr SMP transport mgmt: mcumgr: transport: Add LoRaWAN MCUmgr SMP transport Oct 20, 2024
Copy link
Contributor

Choose a reason for hiding this comment

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

If data_size > size, then data = NULL then the lorawan_send will return -EINVAL, this will be counted as -- to 'tries', that is correct yes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spotted a mistake where the final packet might have been too large. data will only be null if there is nothing to transmit (which in LoRaWAN is allowed, there is still a transmission but the optional payload is not present), if a message is queued for sending then it will send the full thing chunk by chunk

de-nordic
de-nordic previously approved these changes Oct 23, 2024
Copy link
Contributor

@de-nordic de-nordic left a comment

Choose a reason for hiding this comment

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

One stupid question, otherwise looks ok.

Comment on lines 38 to 39
Copy link
Contributor

Choose a reason for hiding this comment

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

for my own education, why ; here? Or maybe it's a typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typo, should be ,, fixed

@kartben kartben dismissed their stale review October 23, 2024 14:51

dismiss as my comment re: renaming LoRA --> LoRaWAN has been addressed. Thanks!

@thedjnK thedjnK requested review from de-nordic and kartben October 23, 2024 17:02
de-nordic
de-nordic previously approved these changes Oct 23, 2024
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Enables handling of SMP commands received over LoRa.
Enables handling of SMP commands received over LoRaWAN.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

Choose a reason for hiding this comment

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

Port 0 is not allowed for applications, it's reserved for MAC commands. The allowed range for applications is 1-223, see here.

Suggested change
range 0 120
range 1 223

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

Choose a reason for hiding this comment

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

Suggestion to clarify that we are talking about uplinks:

Suggested change
config MCUMGR_TRANSPORT_LORAWAN_CONFIRMED_PACKETS
config MCUMGR_TRANSPORT_LORAWAN_CONFIRMED_UPLINKS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines +46 to +55
Copy link
Member

Choose a reason for hiding this comment

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

There is an FPending flag for downlink messages for exactly this purpose. Can we not use that instead?

Quote from the spec:

4.3.1.4 Frame pending bit (FPending in FCtrl, downlink only)
The frame pending bit (FPending) is only used in downlink communication, indicating that
the network has more data pending to be sent and therefore asking the end-device to open
another receive window as soon as possible by sending another uplink message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see how that would work any differently? If the flag is set, you still all the same code, the way it is right now means it only sends an empty frame if there is outstanding data for the current MCUmgr packet which in my mind is all this should handle, something non-MCUmgr can be retrieved by the application code

Copy link
Member

Choose a reason for hiding this comment

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

I thought the LoRaWAN stack would handle the FPending flag automatically, but it doesn't seem to be the case. I agree your implementation makes sense.

Copy link
Member

Choose a reason for hiding this comment

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

This would probably please the clang-format check.

Suggested change
.cb = smp_lorawan_downlink
.cb = smp_lorawan_downlink,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

clang-format is completely broken in most checks which is why it does not fail CI, the suggestion from clang-format here is + .port = CONFIG_MCUMGR_TRANSPORT_LORAWAN_FRAME_PORT, .cb = smp_lorawan_downlink}; which looks ghastly. Later on it suggest this + K_KERNEL_STACK_SIZEOF(smp_lorawan_stack), smp_lorawan_uplink_thread, NULL, which is funny because the suggestion would be a CI failure as that line is 102 characters

Copy link
Member

Choose a reason for hiding this comment

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

Sending confirmed uplinks is discouraged by TheThingsNetwork as the gateway downlink traffic bandwidth is very limited. Should we use unconfirmed messages by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This only applies to the (public) things network because they're trying to get you to pay for their commercial offering (the things industries), it does not have any relation to anything in the spec or LoRa in general

Adds a transport that uses LoRaWAN for receiving and responding
to messages

Signed-off-by: Jamie McCrae <[email protected]>
Adds a test to ensure that the LoRaWAN MCUmgr transport builds with
all options enabled and all options disabled

Signed-off-by: Jamie McCrae <[email protected]>
Adds a note that this transport has been added

Signed-off-by: Jamie McCrae <[email protected]>
@aescolar aescolar merged commit efd60df into zephyrproject-rtos:main Oct 25, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mcumgr Release Notes To be mentioned in the release notes

Projects

Status: Done in release 4.0

Development

Successfully merging this pull request may close these issues.

6 participants