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,
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);
Hi
How do you reset the time to start with?
I will try to merge the calendar example with the ble_app_uart example to see if I can reproduce your issue. You should hear from me soon ;)
Best regards
Torbjørn
Hi,
I don't know how to reset the time, But i did try the following function from the same library :
uint32_t year = 2020; uint32_t month = 8; uint32_t day = 14; uint32_t hour = 20; uint32_t minute = 5; uint32_t second = 55; nrf_cal_set_time(year, month, day, hour, minute, second);
But this gave me an error.
Thank you , I am awaiting for your reply
Hi again
I was able to merge the calendar functionality into ble_app_uart, and seem to be able to send time strings successfully.
The critical change I had to do was to modify nrf_calendar.h to use RTC2 instead of RTC0, since RTC0 is used by the SoftDevice and RTC1 is used by the app_timer module.
Here is the code for reference:
Best regards
Torbjørn
Hi again
I was able to merge the calendar functionality into ble_app_uart, and seem to be able to send time strings successfully.
The critical change I had to do was to modify nrf_calendar.h to use RTC2 instead of RTC0, since RTC0 is used by the SoftDevice and RTC1 is used by the app_timer module.
Here is the code for reference:
Best regards
Torbjørn
Hi, Thanks a lot i am able to get the right output now !!
I had another question, so does this time change real time? or does it remain constant?
Hi
Good to hear you got it working
codebreaker176 said:I had another question, so does this time change real time? or does it remain constant?
The time is supposed to be updated every second, yes.
Is this not happening for you?
In the example I sent you can try to request several updates, and you should see the time increase.
Best regards
Torbjørn
Hi,
Yess it works, thanks a lot, Grateful for your help!!
That's good to hear, glad I could help
Hello again,
I proabably misread the output,
but now i checked, the time does not get updated at all , it remains constant, can you please help