Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
Updated example for cellular only: clearer eDRX outcome. (#1135)
Browse files Browse the repository at this point in the history
The E-DRX example for cellular expects that, once E-DRX has been set, the module will emit a URC indicating the assigned E-DRX settings. This works internally on the ubxlib test system however it doesn't seem to be a reliable indication for a live network: likely it depends on the network and when the radio connection is released. So as not to confuse customers, the example is now updated to call the uCellPwrGetEDrx() API to determine the truth if the callback happens not to be called.

Thanks to elektron314 for spotting this.
  • Loading branch information
RobMeades authored Mar 28, 2024
1 parent b7e8edc commit 3da65fc
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions example/cell/power_saving/cell_power_saving_e_drx_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ U_PORT_TEST_FUNCTION("[example]", "exampleCellPowerSavingEDrx")
bool onMyRat = true;
int32_t x = -1;
int32_t returnCode;
bool eDrxOnNotOff = false;
int32_t eDrxSeconds = -1;
int32_t pagingWindowSeconds = -1;

// Initialise the APIs we will need
uPortInit();
Expand Down Expand Up @@ -260,9 +263,32 @@ U_PORT_TEST_FUNCTION("[example]", "exampleCellPowerSavingEDrx")
}

if (gEDrxSet) {
uPortLog("### The E-DRX settings have been agreed.\n");
uPortLog("### Callback called, the E-DRX settings"
" have been agreed.\n");
} else {
uPortLog("### Unable to switch E-DRX on!\n");
// The callback has not been called, which might
// be the case, network dependent, dependent on
// the timing of RRC connections being dropped
// etc.; call the API instead
if (uCellPwrGetEDrx(devHandle, MY_RAT,
&eDrxOnNotOff, &eDrxSeconds,
&pagingWindowSeconds) == 0) {
if (eDrxOnNotOff) {
uPortLog("### The E-DRX settings have been agreed");
if (eDrxSeconds >= 0) {
uPortLog(", assigned E-DRX %d seconds", eDrxSeconds);
}
if (pagingWindowSeconds >= 0) {
uPortLog(", assigned paging window %d seconds",
pagingWindowSeconds);
}
uPortLog(".\n");
} else {
uPortLog("### Unable to switch E-DRX on!\n");
}
} else {
uPortLog("### Unable to get assigned E-DRX!\n");
}
}

// When finished with the network layer
Expand Down Expand Up @@ -295,7 +321,8 @@ U_PORT_TEST_FUNCTION("[example]", "exampleCellPowerSavingEDrx")
uPortLog("### Done.\n");

# ifndef U_CFG_CELL_DISABLE_UART_POWER_SAVING
// For u-blox internal testing only
// For u-blox internal testing only; in our test setup we
// can be sure that the callback should have been called
EXAMPLE_FINAL_STATE((x < 0) || gEDrxSet);
# ifdef U_PORT_TEST_ASSERT
// We don't want E-DRX on for our internal testing, so
Expand Down

0 comments on commit 3da65fc

Please sign in to comment.