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

No ">" prompt following +CASEND after wakeup from sleep (DRX) #48

Open
btuysser opened this issue Mar 27, 2024 · 5 comments
Open

No ">" prompt following +CASEND after wakeup from sleep (DRX) #48

btuysser opened this issue Mar 27, 2024 · 5 comments
Labels

Comments

@btuysser
Copy link

btuysser commented Mar 27, 2024

My project is based on MinimalModemNBIOTExample. I am transmitting a ~28 byte UDP datagram every 60s and I want the modem to sleep. I am using DRX as opposed to eDRX or PSM due to future requirements.I added some UDP code (as that is not supported by TinyGSM), set +SCLKC=1 and I'm controlling DTR. The code was compiled with (-DARDUINO_USB_CDC_ON_BOOT=0) and the board is connected to a wall power supply. No UART connection.

In the setup function I acquire NB-IOT, register and open a UDP connection.

Here is my loop function and a modifed TinyGsmSim7080::modemSend :

 int16_t modemSend(const void* buff, size_t len, uint8_t mux) {

    while(waitResponse(5,GF(">")) != 1) {
      sendAT(GF("+CASEND="), mux, ',', (uint16_t)len);
    }

    stream.write(reinterpret_cast<const uint8_t*>(buff), len);
    stream.flush();

    // OK after posting data
    if (waitResponse() != 1) { return 0; }

    return len;
  }

void loop()
{
    static int cnt = 0;
    long t0 = millis();
    // pull DTR low in case we were sleeping
    digitalWrite(BOARD_MODEM_DTR_PIN, LOW);
    // send UDP datagram
    modem.modemSend(msg.c_str(), msg.length(), 0);
    // get to rrc idle asap
    modem.sendAT("+CRAI=1");
    modem.waitResponse(5);
    // we can go back to sleep now
    digitalWrite(BOARD_MODEM_DTR_PIN, HIGH);
    Serial.printf("\n\r--------------  SLEEP AFTER %d --------------\n\r", millis() - t0);
    delay(60000);
}

When I call +CASEND immediately after wakeup there is no ">" prompt in the modem serial stream. I added retries in the modemSend method and with a timeout of 5ms it takes 3 tries to get a ">" prompt. This results in an awake time of ~24ms instead of an ideal ~15ms. When increasing the waitResponse timeout to 50ms I would expect the number of tries to go down but it remains between 1 and 3 tries for an awake time of 65-117ms.

Another workaround is to add a 300ms delay after pulling DTR low but the impact on awake time is unacceptable.

Am I doing anything wrong or have others come across this issue?

Log :

AT+CPSI?
+CPSI: LTE NB-IOT,Online,310-260,0xF300,7573966,450,EUTRAN-BAND4,2038,0,0,-11,-98,-87,13
OK

AT+CSCLK=1
OK
AT+CACLOSE=0

AT+CACID=0
OK

AT+CAOPEN=0,0,"UDP","<IP>",<PORT>
OK

AT+CASEND=0,26
>012345678 UDP test Count 0 
OK
AT+CRAI=1
OK

--------------  SLEEP AFTER 21 ms --------------
AT+CASEND=0,26
AT+CASEND=0,26
AT+CASEND=0,26
>012345678 UDP test Count 1 
OK
AT+CRAI=1
OK
--------------  SLEEP AFTER 32 ms --------------
AT+CASEND=0,26
AT+CASEND=0,26
AT+CASEND=0,26
>012345678 UDP test Count 2 
OK
AT+CRAI=1
OK
--------------  SLEEP AFTER 32 ms --------------
.....

@btuysser btuysser changed the title No ">" prompt after +CASEND after wakeup from sleep (DRX) No ">" prompt following +CASEND after wakeup from sleep (DRX) Mar 27, 2024
@btuysser
Copy link
Author

Firmware Revision : 1951B12SIM7080

@lewisxhe
Copy link
Contributor

Are you referring to the wake-up reaction time being too long?

@btuysser
Copy link
Author

Since there is almost no information in the low power application note I hoped that the wakeup reaction time would be be transparent to the user. After pulling DTR low I expected the modem to execute any serial command after finishing its own internal wakeup sequence.

If that is not the case then how does a user determine the earliest time it's safe to interact with the modem (in this case sending a UDP packet via +CASEND)?

@btuysser
Copy link
Author

Would it be possible to extend the MinimalModemSleepMode.ino example by doing multiple sleeps?

My current sequence is

  • pull DTR low
  • send AT commands with a timeout of 1ms until OK is received or a threshold is exceeded
  • +CASEND
  • pull DTR high
  • .....

I just don't know if this is the optimal sequence.

Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants