Adding Timestamp

Hi,

I am developing an application (Peripheral Sensor device: Acceleration measurement), I have included the characteritsics for the measurement and I am trying to include three packets of data to this characteristics value Timestamp, Value and Flag. I have already done the part of Value and Flag and currently I am facing difficulty in adding time stamp (I wish to add unix timestamp in Seconds). My client device has the Synchronization characteristics which notifies the current time (unix timestamp in Seconds in milliseconds). But I am not aware of where to start in order to include the timestamp in to my characetristic value. I refered nordic example "ble_cts_c" but I could not understand how can I sync the readed current time with my RTC of my measurement. In short I have following challanges,

1. Can I duplicate the Nordic example of Current Time Service Client in order to read the current time from my master/client which provides the current time (unix time stamp in millisecond)?

2. How and Where should I synchronize the readed current time value with my app_timer for the acceleration measurement? Is there any public example/codes available to refer? Can anyone comment on the code procedure (I mean where to start)? 

        2.1 Where should I call the function to read the current time?

        2.2 If I use 20 ppm timer accuracy how often should I call this read current time function?

        2.3 what happens when the the device enters in to the idle state (sleep mode), do I need to synch the time again after wake?

3. Is there any another way to include unix time stamp? 

(I am using nRF5, development kit: nRF52840DK)

It would be really helpful, If i get some guidance on this topic.

Thanks and Regards,

Sreejith

Parents Reply Children
  • All together I need to include unix timestamp (in uint32_t Seconds) along with the Measurement data. This is my requirement. So that I have included the NRF_CALENDAR example to get time, it works only when comment the following lines in nrf_calendar.c

    NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos;
    NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos;
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);

    when I uncomment, it shows INVALID error, I could not get what is the problem here, when I comment it I am getting timetsamp but that lasts only for 60 seconds after that all measurements were stopped and no more reading....

  • What do you plan to use it for?

    I would like to add timestamp (32 bit Unix timestamp in seconds) along with my measured acceleration data. What I currently done is that I used the NRF CALENDAR example and the initial time I set manually and now it works perfectly. But I wish to include a new custom time service (in my peripheral device) which has one characteristic named as current time char which is possible to read and write. But I would like to read a value from the client characteristic and write to the above mentioned current time char. Is it possible? does the cts_c example helps here? I am little confused that a peripheral device (which has about 5 services) can act as client to read only time?

    I do really appreciate your help.

    Thanks and Regards,

    Sreejith  

  • You will have to solve this the best you see fit. Though from what I can understand this is a proprieatry application, this means that you can have proprieatry characteristics with a data format that fit your needs, e.g. a characteristic can be defined by you to hold both time data and measurements, and this combined data can be sent as one notification for each measurement. This is much effective than using many characteristics, since having more characteristics typically mean you will have to read/write/notify more packets on air, instead of one packet (notification) that can consist of a format that you define (code and decode as you best see fit).

    That said, there should be no problem to also have several services and characteristics, though it might be more difficult to possible know at what time a measurement have been performed in specific if you don't somehow combine the two into one packet as suggested.

    Kenneth

  • Thanks once again for your suggestion. Yes I am planning to send like wise. But my question here is something other, 

    I have to include timestamp without initializing or setting time manually. For this My client device has a service call as Current Time (So the client reads current time from some other device which is not my area), which do notifies when it reads current data.

    My device is peripheral role, but I would like to read the characteristic value of those Current Time Service of client. Is it possible? So that I would get current time withour setting manually then I can use this value to update my timestamp with help of RTC.

    in short, My peripheral device need to read one of the characteristic value from Client (which do notification once it get correct current time data). Is there any suggestion on it, I mean implementation of this logic possible or not?

    Thanks and Regards,

    Sreejith 

  • Hello,

    I am not entirely sure I understand, but it's only a server that can hold data, so a client can either write to the server or read from the server. 

    Best regards,
    Kenneth

Related