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

How to use the calendar_example to extract the current time

How to extract the current time from the calendar_example, i am not clear with the procedure

Parents
  • Hi 

    You would use the nrf_cal_get_time(void) function for this. 

    It returns a pointer to a tm struct which contains the current time in seconds, minutes, hours and so on. 

    You can also use the nrf_cal_get_time_string(bool calibrated) function if you just want a string representation of the current time. 

    Best regards
    Torbjørn

  • Hi,

    nrf_log module doesnt work now.. I am working on it, mean while can you please check this out..

    this was the output when i used int datatype

    EDIT : I am getting the same result using the character array pointer as well

    below is the code i used for character array

     char k[16];
            for(int i = 0; i < sizeof(nrf_cal_get_time_string(true)); i++) {
            k[i] = nrf_cal_get_time_string(true)[i];
            }
          err_code = ble_nus_data_send(&m_nus, k, &lendt, m_conn_handle);

Reply
  • Hi,

    nrf_log module doesnt work now.. I am working on it, mean while can you please check this out..

    this was the output when i used int datatype

    EDIT : I am getting the same result using the character array pointer as well

    below is the code i used for character array

     char k[16];
            for(int i = 0; i < sizeof(nrf_cal_get_time_string(true)); i++) {
            k[i] = nrf_cal_get_time_string(true)[i];
            }
          err_code = ble_nus_data_send(&m_nus, k, &lendt, m_conn_handle);

Children
Related