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

Cell Network Up Keep Going Callback Fails at Tick Wrap-Around #207

Closed
warasilapm opened this issue Feb 28, 2024 · 2 comments
Closed

Cell Network Up Keep Going Callback Fails at Tick Wrap-Around #207

warasilapm opened this issue Feb 28, 2024 · 2 comments
Assignees

Comments

@warasilapm
Copy link

warasilapm commented Feb 28, 2024

Problem Description

The root of this issue seems to be that the stop time is stored as a 64-bit integer in the cell context.

typedef struct {
int32_t uart;
uAtClientHandle_t at;
int64_t stopTimeMs;
int32_t pinPwrOn;
} uDeviceCellContext_t;

When the stop time is calculated, if the tick is within the timeout window of INT32_MAX (by default, 60 seconds), the stop time will be set beyond the range of int32_t.

pContext->stopTimeMs = uPortGetTickTimeMs() +
(((int64_t) timeoutSeconds) * 1000);

Additionally, even if it were wrapped around correctly, this buggy check in the default keep going callback means that it would immediately time out.

static bool keepGoingCallback(uDeviceHandle_t devHandle)
{
uDeviceCellContext_t *pContext;
uDeviceInstance_t *pDevInstance = NULL;
bool keepGoing = false;
if (uDeviceGetInstance(devHandle, &pDevInstance) == 0) {
pContext = (uDeviceCellContext_t *) pDevInstance->pContext;
if ((pContext == NULL) ||
(uPortGetTickTimeMs() < pContext->stopTimeMs)) {
keepGoing = true;
}
}
return keepGoing;
}

Proposed Solution

  1. Change the stop time value to use int32_t to match the portable API.
  2. Fix the check used in the keep going callback to calculate a difference.

See attached example patch

@RobMeades
Copy link
Contributor

Hi, and thanks for spotting this; your proposed fix looks good. We will integrate it but, unfortunately, at the moment the cellular side of our test system is down, as the equipment we use as our cellular test network lost its hard disk at the weekend.

Once we have put the pieces back together again, so that we are able to regression test cellular stuff, we will get the change tested/reviewed and pushed to master here. I will update this issue when that occurs.

[Also talk later I understand].

@RobMeades
Copy link
Contributor

The fix for his issue is included in the rather larger fix of commit 79e808e.

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

No branches or pull requests

2 participants