[BC66] QNTP gives irregular response and disrupts sleep cycle

Hello,

I have an MCU connected to a BC66. In normal operation the MCU wakes up the BC66 from sleep. Then the time is synchronised via QNTP. After that a UDP message is sent, and then the BC66 is allowed to go to sleep.
See code below.
Usually the the +QNTP response comes immediately after doing the AT+QNTP command, but sometimes it is delay by 15 seconds or more. Additionaly it sometimes disrupts the sleep cycle (the BC66 can’t go to sleep because of it).
In the below example, the +QNTP response comes after having sent the UDP message.

So my question is: how should I deal with this? How long should I wait for a response from the AT+QNTP command? And is there I way to cancel the AT+QNTP process when it has already been started so that it doesn’t disrupt the sleep cycle of the BC66?

N.b. the AT manual tells us very little about this command.

# Wait for BC66 wake up --

Send interrupt to BC66 PSM_EINT pin

Wake up event!


 +CPIN: READY
 
 +QATWAKEUP
 

AT+QSCLK=0


 OK
 

Time to sleep / wake [ms]: 1212

# Wait for BC66 IP connection--

AT+CGPADDR?


 +CGPADDR: 1,XX.XXX.XXX.X
 

IP opbtained!

# Sync BC66 time with server pool --

AT+QNTP=1,"pool.ntp.org"


 OK
 



# Get date and time.

+QCCLK: 22/08/30,13:44:32+08
 
 OK
 

# Create Socket --


 OK
 
 +QIOPEN: 0,0
 

AT+QNBIOTRAI=1


 OK
 

AT+QISENDEX=0,51,38363739393730333235353834372C332C3232303833303135343432382C312E32352C3132352E30302C302E30302C302E3030


 +QNTP: 0,"22/08/30,13:44:33+08"
 
 OK
 
 SEND OK
 

# Closing socket --


 OK
 
 CLOSE OK
 

# Wait for BC66 sleep --

AT+QSCLK=1


 OK
 

Deep sleep event!

+QNBIOTEVENT: "ENTER DEEPSLEEP"

You are advised to set this parameter to 2. For disturbing sleep state, can not be seen through your log, please provide more logs

AT+QNBIOTRAI=2

Hi @herbert.pan-Q , why should this be 2? I am only sending one uplink packet am I not? Or does the +QNTP count as a downlink packet?

The NTP request you send belongs to the uplink packet, but the time result you get belongs to the downlink packet; If you set it to 1, fetching downlink packets may interrupt the function of RAI

Hello @herbert.pan-Q ,

I have implemented your suggestion, see below. After sending the AT+QSCLK=1 command, the BC66 takes about 50 seconds to get to sleep (which I think is a very long time).

Do you know why that could be happening? What is the BC66 doing in the background that is preventing it from going to sleep? Or are there any resources that you could point me to (manuals etc.), that explain why this is happening?

As a reference, I have also included the logs for when there is no QNTP request. As you can see, the BC66 goes to sleep immediately.

Long time to sleep:

[2023-02-14_16:17:33:884]+QATWAKEUP
[2023-02-14_16:17:34:038]AT+QSCLK=0

[2023-02-14_16:17:34:038]OK
[2023-02-14_16:19:07:842]AT+QNBIOTRAI=2

[2023-02-14_16:19:07:842]OK
[2023-02-14_16:19:38:391]AT+QNTP=1,"pool.ntp.org"

[2023-02-14_16:19:38:406]OK
[2023-02-14_16:19:38:498]
[2023-02-14_16:19:38:498]+CEREG: 2,"C2EF","0035B667",9,0,0,"00010000","11000001"
[2023-02-14_16:19:39:471]
[2023-02-14_16:19:39:471]+CEREG: 5,"C2EF","0035B667",9,0,0,"00010000","11000001"
[2023-02-14_16:19:47:367]
[2023-02-14_16:19:47:367]+QNTP: 0,"23/02/14,15:18:24+04"
[2023-02-14_16:19:53:228]AT+QSCLK=1

[2023-02-14_16:19:53:228]OK
[2023-02-14_16:20:43:318]+QNBIOTEVENT: "ENTER DEEPSLEEP"

Short time to sleep:

[2023-02-14_16:35:47:796]+CPIN: READY

[2023-02-14_16:35:47:796]+QATWAKEUP
[2023-02-14_16:35:47:948]AT+QSCLK=0

[2023-02-14_16:35:47:978]OK
[2023-02-14_16:36:00:662]AT+QSCLK=1

[2023-02-14_16:36:00:662]OK
[2023-02-14_16:36:00:662]+QNBIOTEVENT: "ENTER DEEPSLEEP"

Many thanks


AT+QNBIOTRAI=2
AT+QPING=1,8.8.8.8,4,1
AT+QSCLK=1

00010000 indicates that the T3324 timer time is 32s

Hi @herbert.pan-Q , thank you for that diagram :slight_smile:

I have now tried the same procedure using a value for the T3324 timer of 0 seconds, so the “idle” phase should now be non-existent. In that procedure, it takes about 8 seconds for the BC66 to go to sleep after receiving the AT+QSCLK=1 command.

So that time duration of 8 seconds is part of the “connection” phase, correct (see image)? And what is happening during those 8 seconds? Is there any way to make the BC66 enter sleep faster, e.g. within 1 to 2 seconds after the AT+QSCLK=1 command has been sent to the BC66 (instead of 8 sec)?

Many thanks!

[2023-02-15_11:36:14:681]+QATWAKEUP
[2023-02-15_11:36:15:046]AT+QSCLK=0

[2023-02-15_11:36:15:046]OK

[2023-02-15_11:36:18:557]AT+CSCON=1

[2023-02-15_11:36:18:557]OK
[2023-02-15_11:38:22:105]AT+QNBIOTEVENT=1,1

[2023-02-15_11:38:22:105]OK
[2023-02-15_11:38:30:853]AT+QNBIOTRAI=2

[2023-02-15_11:38:30:853]OK
[2023-02-15_11:38:36:113]AT+QNTP=1,"pool.ntp.org"

[2023-02-15_11:38:36:144]OK
[2023-02-15_11:38:36:266]
[2023-02-15_11:38:36:266]+CEREG: 2,"C2EF","0035B667",9,0,0,"00000000","11000001"

[2023-02-15_11:38:36:266]+QNBIOTEVENT: "EXIT PSM"
[2023-02-15_11:38:37:249]
[2023-02-15_11:38:37:249]+CEREG: 5,"C2EF","0035B667",9,0,0,"00000000","11000001"
[2023-02-15_11:38:38:851]
[2023-02-15_11:38:38:851]+CSCON: 1
[2023-02-15_11:38:40:106]
[2023-02-15_11:38:40:106]+CSCON: 0

[2023-02-15_11:38:40:106]+QNBIOTEVENT: "ENTER PSM"
[2023-02-15_11:38:40:291]
[2023-02-15_11:38:40:291]+CEREG: 2,"C2EF","0035B667",9,0,0,"00000000","11000001"

[2023-02-15_11:38:40:291]+QNBIOTEVENT: "EXIT PSM"
[2023-02-15_11:38:40:584]
[2023-02-15_11:38:40:584]+CEREG: 5,"C2EF","0035B667",9,0,0,"00000000","11000001"
[2023-02-15_11:38:41:290]
[2023-02-15_11:38:41:290]+CSCON: 1
[2023-02-15_11:39:16:150]
[2023-02-15_11:39:16:150]+QNTP: 550
[2023-02-15_11:39:18:250]AT+QSCLK=1

[2023-02-15_11:39:18:250]OK
[2023-02-15_11:39:26:469]
[2023-02-15_11:39:26:469]+CSCON: 0

[2023-02-15_11:39:26:469]+QNBIOTEVENT: "ENTER PSM"
[2023-02-15_11:39:26:561]+QNBIOTEVENT: "ENTER DEEPSLEEP"


pls try again

AT+QNBIOTRAI=2
AT+QPING=1,8.8.8.8,4,1
AT+QSCLK=1