Skip to content
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

Fix freertos_lorawan downlink #187

Open
elsalahy opened this issue May 19, 2021 · 12 comments
Open

Fix freertos_lorawan downlink #187

elsalahy opened this issue May 19, 2021 · 12 comments
Assignees
Labels
bug Something isn't working Firmware Anything related to code and SW on the HW prio/medium

Comments

@elsalahy
Copy link
Contributor

Summary:

The downlink handling of freertos_lorawan app is broken.

Steps to Reproduce:

  1. Flash freertos_lorawan app
  2. Send a downlink after OTAA
  3. Observe logs and node output

What do you see now?

The received downlinks is not passed correctly from the mac layer to the application layer

What do you want to see instead?

A functional application that is able to receive downlinks

How do you propose to implement this?

  • Debug the cause of the issue
  • Test and fix Queue allocation and message handling

Environment:

FreeRTOS

What can you do yourself and what do you need help with?

ALL

@elsalahy elsalahy added the bug Something isn't working label May 19, 2021
@elsalahy elsalahy added this to the 2021 Q2 milestone May 19, 2021
@elsalahy elsalahy self-assigned this May 19, 2021
@elsalahy
Copy link
Contributor Author

elsalahy commented May 31, 2021

@marnixcro I think this issue is a good start for you on the FreeRTOS side, can you undertake this one?

@elsalahy
Copy link
Contributor Author

This is a medium priority

@mcserved mcserved assigned mcserved and unassigned elsalahy May 31, 2021
@elsalahy elsalahy added the Firmware Anything related to code and SW on the HW label May 31, 2021
@mcserved
Copy link
Contributor

mcserved commented Jun 2, 2021

The issue seems to be a bit easier than queue allocation. I was able to have downlinks working by simply multiplying the wait time of the downlink task receive window (and by having a breakpoint during debugging which lenghtened the downlink time). I'll try to find if improper timing was indeed the cause and, if so, why this occurs. For reference, the dirty fix:

BaseType_t LoRaWAN_Receive( LoRaWANMessage_t * pMessage,
                            uint32_t timeoutMS )
{
    TickType_t ticksToWait;

    if( timeoutMS > 0 )
    {
        ticksToWait = pdMS_TO_TICKS( timeoutMS );
    }
    else
    {
        ticksToWait = 1;
    }
    ticksToWait *= 2;

    return xQueueReceive( xDownlinkQueue, pMessage, ticksToWait );
}

Unrelated but may be good to know: downlinks can be retrieved during the join procedure and the power consumption shows that the windows were opened (as the device would temporarily consume more twice after transmitting). So downlink does seem to 'run' even if it didn't function properly.

@elsalahy
Copy link
Contributor Author

elsalahy commented Jun 2, 2021

@marnixcro great finding, feel free to open a PR with the fix and glad it's a simple fix

@elsalahy
Copy link
Contributor Author

What is the status on this?

@mcserved
Copy link
Contributor

What is the status on this?

The dirty fix seemed to have fixed it differently than I thought initially. At first I thought that editing this line would be sufficient:

#define CLASSA_RECEIVE_WINDOW_DURATION_MS ( 6000 )

But that did not solve the issue. I debugged it further and it seems that it always jumps into RX timeout (instaed of RX done, or RX error) so I would need to look into why these are triggered occasionally (as it seems that even the regular configuration will sometimes work normally for some time).

@mcserved
Copy link
Contributor

Rx windows are always timed out, a test should be made if the correct timing is reached in the freertos, this can be compared to the timing on the basic_lorawan application to see if the downlink receive time is off.

@elsalahy
Copy link
Contributor Author

@marnixcro yes indeed, as we discussed, we can adjust the window offsets and timings to ensure the FreeRTOS layer downlink handling is correct.

We need:
1- One power analysis snapshot of bare-metal uplink and downlink
2- One snapshot of power analysis of freertos uplink and downlink (missing a downlink would be preferable)

we can align theses snapshots and see if we can find the root cause of the issue

@mcserved
Copy link
Contributor

mcserved commented Jun 30, 2021

I made a graph showing the downlink retrieval times (no downlink was set, but the two retrieval times where added):

basic_lorawan freertos_lorawan Delta
5s14ms 5s129ms +115ms
218ms 271ms +53ms
781ms 754ms -27ms
218ms 271ms +53ms

Both were done with the ADR off and at DR_0

This picture also shows that the downlinks retrieval times do touch briefly, but the freertos application's downlink starts and ends later
image

@mcserved mcserved linked a pull request Jul 1, 2021 that will close this issue
@mcserved
Copy link
Contributor

mcserved commented Jul 5, 2021

Blocked by #203

@elsalahy elsalahy modified the milestones: 2021 Q2, 2021 Q3 Jul 12, 2021
@elsalahy
Copy link
Contributor Author

Moved this to Q3

@NicolasMrad NicolasMrad modified the milestones: 2021 Q3, 2021 Q4 Oct 4, 2021
@elsalahy elsalahy assigned elsalahy and unassigned mcserved Oct 5, 2021
@elsalahy elsalahy removed the s/blocked label Oct 5, 2021
@NicolasMrad NicolasMrad assigned azerimaker and unassigned elsalahy Dec 13, 2021
@NicolasMrad NicolasMrad modified the milestones: 2021 Q4, 2022 Q1 Jan 3, 2022
@NicolasMrad NicolasMrad modified the milestones: 2022 Q1, 2022 Q2 Mar 29, 2022
@NicolasMrad
Copy link

is this still relevant?

@NicolasMrad NicolasMrad modified the milestones: 2022 Q2, 2022 Q3 Jul 4, 2022
@NicolasMrad NicolasMrad modified the milestones: 2022 Q3, 2022 Q4 Oct 10, 2022
@NicolasMrad NicolasMrad modified the milestones: 2022 Q4, 2023 Q1 Dec 12, 2022
@NicolasMrad NicolasMrad modified the milestones: 2023 Q1, 2023 Q2 Apr 13, 2023
@KrishnaIyer KrishnaIyer removed this from the 2023 Q2 milestone Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Firmware Anything related to code and SW on the HW prio/medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants