using pcf85263a RTC chip. and i'd like track clock object by this chip. server samples has clock1 object. do you have guide for this type adoption? for reading i'd made changes like:
uint32_t time_current(void)
{
struct rtc_time tmUtc;
//return time_toUnixTime2(&clock1.time) + (time_elapsed() - started) / 1000;
rtc_get_time(rtcMeter, &tmUtc);
return decode_rtc(tmUtc);
Hello,
I can update RTC chip in pre_write as you've advised. but how make changes on cosem_setValue( ... which is called in origin code. it managed clock & date logic too.
BR,
Ulzii
My bad. :-)
What I meant is that you don't need to call cosem_setValue for time if you read it on pre-read from RTC. You can, but there is no need for that.
Hi,
I'd like to set server time to new time (click on "current time" button.), then i'd like to call settime() function - setting new time on rtc. And Clock object has many feature like DTS or Time zone... I do not know best possible adopt to origin code with RTC chip conversation.
BR,
Ulzii
Hi, I believe that you are…
Hi,
I believe that you are making a meter and we are talking from the server side.
Handle write in pre_write and update clock like this.
if (e->target == BASE(clock1) && e->index == 2)
{
gxtime value;
if (cosem_getDateTimeFromOctetString(e->value.byteArr, &value) == 0)
{
//Update RTC.
time_toUTC(value);
}
}
BR,
Mikko
using pcf85263a RTC chip…
using pcf85263a RTC chip. and i'd like track clock object by this chip. server samples has clock1 object. do you have guide for this type adoption? for reading i'd made changes like:
uint32_t time_current(void)
{
struct rtc_time tmUtc;
//return time_toUnixTime2(&clock1.time) + (time_elapsed() - started) / 1000;
rtc_get_time(rtcMeter, &tmUtc);
return decode_rtc(tmUtc);
}
and for setting, not sure about changes
Hi, Are you using VS Code or…
Hi,
Are you using VS Code or Arduino?
BR,
Mikko
VSC. Nordic server
Hi,
VSC. Nordic server.
Thanks for kind support!
Hello, I can update RTC…
Hello,
I can update RTC chip in pre_write as you've advised. but how make changes on cosem_setValue( ... which is called in origin code. it managed clock & date logic too.
BR,
Ulzii
Hi, You don't need to update…
Hi,
You don't need to update the date time if you are using RTC. It's better to read value from RTC in pre_read and use that value. Something like this:
if (e->target == BASE(clock1) && e->index == 2)
{
gxtime dt;
time_now(&dt, 1);
e->error = (DLMS_ERROR_CODE) cosem_setDateTimeAsOctetString(e->value.byteArr, &dt);
e->value.vt = DLMS_DATA_TYPE_DATETIME;
e->handled = 1;
}
BR,
Mikko
Hi, Our meter HES will need…
Hi,
Our meter HES will need update datetime at least for deploy etc, so i need to write for update our RTC chip's datetime.
BR,
Ulzii
Hi, My bad. :-) What I meant…
Hi,
My bad. :-)
What I meant is that you don't need to call cosem_setValue for time if you read it on pre-read from RTC. You can, but there is no need for that.
BR,
Mikko
Hi, I'd like to set server…
Hi,
I'd like to set server time to new time (click on "current time" button.), then i'd like to call settime() function - setting new time on rtc. And Clock object has many feature like DTS or Time zone... I do not know best possible adopt to origin code with RTC chip conversation.
BR,
Ulzii
Hi, You can do it in pre…
Hi,
You can do it in pre_write like described here:
https://www.gurux.fi/comment/27237#comment-27237
When you have time in UTC you can update it using a method like rtc_set_time.
BR,
Mikko