Get date and Power saving whit anycloud mqtt client

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Frank-Lin
Level 4
Level 4
5 solutions authored 50 sign-ins 10 questions asked

Hi,
I am testing mqtt client and have some question.
  1. How to get date time?
        Using default code, i can connect to aws iot core. So it seems already get the date time from network.
        How do i get it? I try Cy_RTC_GetDateAndTime() but i get 1970/1/1.
  2. Keepalive failed after calling cyhal_system_deepsleep.
        To save more power, i add a task checking a bool value(true after mqtt connect).
        But after calling cyhal_system_deepsleep, mcu seems won't wakeup to send keepalive package.
        How do i that mcu deepsleep and still sending keepalive package.
        

0 Likes
6 Replies
Aditi_B
Moderator
Moderator
Moderator
500 replies posted 5 questions asked 250 replies posted

Hi,

Can you share your code with me so that I can reproduce this issue on my side or provide us with the steps to reproduce it?

Thanks

Aditi

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Aditi,
This is the code come from my cypress agent.
As agent said, this code will listen to ap every second. (saving 43012 power)
I only add code in mqtt_subscription_callback to show the date.
If i remove the line 385 in publisher_task.c, it won't lost connection between server.

The thing i am trying to do is:
  1. 43012 listen to ap every one second.  (saving 43012 power)
  2. mcu go to deepsleep (saving mcu power)
  3. it shouldn't lost connection
There is a object file without  source file.
It is fine if you have your own solution could achieve the same purpose.

 
0 Likes
lock attach
Attachments are accessible only for community members.

Hi, 
Any update?

The thing i am trying to do is:
  1. 43012 listen to ap every one second  (saving 43012 power, it works as wifi.jpg)
  2. mcu go to deepsleep
       wake up at
          1. 43012 received subscribe package
          2. time to send keep alive package

 
0 Likes

Hi @Aditi_B ,
Sorry but do you have some idea?

0 Likes
Aditi_B
Moderator
Moderator
Moderator
500 replies posted 5 questions asked 250 replies posted

Hi,

So, in summary there are 2 issues-

1. As soon as the packet is received via subscription callback, you try to print the date and time which gets printed incorrect.

2. After the subscribe package is received, the MQTT disconnection happens and this disconnection happens before the keep alive sendout, right?

Thanks

Aditi

0 Likes

Hi aditi,
Sorry for forget to updata information.
1. I still can't get correct date by using Cy_RTC_GetDateAndTime() after connect to aws iot core. So before connect to it, i get network time by asking NTP server and set to RTC.
2. Using cyhal_system_deepsleep() is a bad idea. After including LPA library and setting deepsleep in FreeRTOS, power consumption drops.

0 Likes