How to extract the current time from the calendar_example, i am not clear with the procedure
How to extract the current time from the calendar_example, i am not clear with the procedure
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
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
I tried this function 'nrf_cal_get_time_string(bool calibrated)'.
But the time , is very random and is wrong, it changes everytime i request for the time.
I use nRF toolbox app, i request for the current time using this current code I am working on , but the time keeps changing very drastically even if i just request for it the next second.
I appreciate your patience.
Hi
Have you been able to get the standard calendar example working, with the console terminal?
Are you able to share your code?
Best regards
Torbjørn
if (p_evt->params.rx_data.p_data[0]=='T') { int k, lendt = 16; k = nrf_cal_get_time_string(true); err_code = ble_nus_data_send(&m_nus, k, &lendt, m_conn_handle); }
Hi,
This is the code I use to send time to the nrfToolbox app.
Hi
nrf_cal_get_time_string(..) returns a char pointer, not an int. I am not sure how well that will work.
Do you have the NRF_LOG module working?
If so, can you try to log the time string to see what the value is locally, and try to compare it to what you receive on the phone side?
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);