This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

mktime() in nordic calendar example is not taking local time into account?

Given the info here and here...

1. Does this mean that the nordic example here is wrong, and that line 54 should be time_struct.tm_mon = month - 1;  to account for the indexing difference?

2. My understanding is that mktime() should convert a datetime given in local time to unix time based in UTC. However, when I call mktime() with code almost exactly like the above + the corrections you suggested, the value is always 4h early. My timezone is 4 hours behind UTC. I printed using current_time_print() to verify that the local time coming from the phone into the BLE device is correct, so my suspicion is that mktime() is not actually taking into account the local time / instead is treating the local time as if it were UTC. Can you give insight into this structure: 

p_evt->params.current_time.exact_time_256.day_date_time.date_time

to help me understand where the local time / timezone info is encoded in order for mktime() to access it to make a proper conversion? 

Thanks!

  • Hi,

    For extending the CTS with new characteristics, the existing implementation and other services in our SDK can be used for reference. Two examples of services in the SDK that has multiple characteristics are the Device Information Service (DIS) and the Nordic UART Service (NUS). DIS is a Bluetooth SIG specified service that uses 16 bit UUIDs, and NUS is a service specified by us (Nordic Semiconductor). I am most familiar with the NUS implementation, which uses both writing and notifications for its characteristics.

    For more on BLE characteristics and services, and how they tie into the nRF5 SDK, I suggest the following tutorials. They were updated two years ago to work with nRF5 SDK version 15, and should mostly work with the current nRF5 SDK version 17 as there has not been much change in the areas of the SDK that they cover:

    Regards,
    Terje

Related