1 Reply Latest reply on Oct 4, 2016 8:42 AM by user_459156114

    Setup RTC time using unix timestamp

    user_459156114

      I'm attempting to set the current time of my RTC by sending a Unix timestamp from a smartphone to the device. I am successfully able to get the timestamp from my smartphone to the ble device. 

         

      If I try to just hardcode something to test like this: 

         

      uint64_t out = 1475591308;
      RTC_SetUnixTime(out);

         

      My RTC clock goes to 1/11/2372 ??  Am I not implementing this right? The method signature in the RTC.h is: 

         

      RTC_SetUnixTime(uint64 unixTime);

         

      And the docs say: 

         
          

      Sets the time in the Unix/Epoch time format - the number of seconds elapsed from January 1, 1970 UTC 00:00 hrs. 

         
         

      ===

         

      Update: I've changed nothing and now when setting the unix time it freezes....story of my life. 

         

      I'm trying to call RTC_SetUnixTime in my BleCallBack method if that helps at all. 

        • 1. Re: Setup RTC time using unix timestamp
          user_459156114

          So I was able to fix this by adding in a couple of variables and updating the RTC from the main method instead of my BleCallBack method. So in my main now I have: 

             

          if (!clockIsUpToDate) {
                RTC_SetUnixTime(newClockValue);
                clockIsUpToDate = 1;
          }

             

          I think my issue with this is not fully understanding the c run loop.