Does emberAfReadAttributeCallback or something similar exist?
04/93/2021 | 02:47 PM
Hi,
I want to use time cluster server and client to get the network synchronized. The Z3gatewayhost is the time cluster server and the nodes the client side. This is my plan:
-The nodes send the attribute server read command to get the time and the value is obtained in emberAfReadAttributesResponseCallback, true?
-Using the time cluster server plugin in Z3GatewayHost, the only thing I have to do is to enable emberAfSetTimeCallback and return the unix time, true?
But the mechanism to mantain the time attribute updated is by means a periodic tick where this attribute is update calling emberAfSetTimeCallback. It is not a synchronous process and it can produce errors. For example, is this tick is executed every 0.99 seconds, it is possible to sample twice the same second and the attribute is not updated correctly. Instead of this, I want to get the unix time and respond to the nodes with this time when the read server attribute mensaje is received. But I cannot find this callback. Does this callback exist? Where is processed the read server attribute command in Z3GatewayHost?
Thank you in advance,
Jose
Discussion Forums
ZigBee and Thread
Unanswered
1. Yes, it's correct to send attribute server read command to get the time and the value is obtained in emberAfReadAttributesResponseCallback.
2. emberAfSetTimeCallback is for accessing to real time clock to update that clock. I suppose you should use emberAfWriteAttribute to update time cluster/attributes.
0
Hi Yk
Related to question 1, it works fine.
The problem related to question 2 is that the local atribute is updated every second (Time Server plugin). It means, that every second the emberAfSetTimeCallback is called and store the value in local attribute table. I can set the unix time in is this callback, but when the attribute read commnad is received, the gateway sends the local attribute, It means that the gateway sends a value that it was updated in the last second, not the exact time mark in this moment. So this could contain an error between [0, 1) senconds. Closer to 0 error second means that the value was update jut before of receiving the attribute read command, and a error closer to 1 second means that the value is about to be updated and the momment of receiving the read attribute command.
The solution I want to test is to declare the Time Attribute as External instead of Singleton. And using the emberAfExternalAttributeReadCallback to store the unix time in the attributeMetadata argument variable. I think it should work.
Thank you,
Jose
0
Hi Jose,
That assumption should be correct. That way once the emberAfExternalAttributeReadCallback is called, you can just check for the cluster/attribute IDs to ensure they match with the Time Attribute and then you can set the value as you wish. Note however that by defining the attribute as external, you will have to manually manage the storage of this attribute.
Does emberAfReadAttributeCallback or something similar exist?
Hi,
I want to use time cluster server and client to get the network synchronized. The Z3gatewayhost is the time cluster server and the nodes the client side. This is my plan:
-The nodes send the attribute server read command to get the time and the value is obtained in emberAfReadAttributesResponseCallback, true?
-Using the time cluster server plugin in Z3GatewayHost, the only thing I have to do is to enable emberAfSetTimeCallback and return the unix time, true?
But the mechanism to mantain the time attribute updated is by means a periodic tick where this attribute is update calling emberAfSetTimeCallback. It is not a synchronous process and it can produce errors. For example, is this tick is executed every 0.99 seconds, it is possible to sample twice the same second and the attribute is not updated correctly. Instead of this, I want to get the unix time and respond to the nodes with this time when the read server attribute mensaje is received. But I cannot find this callback. Does this callback exist? Where is processed the read server attribute command in Z3GatewayHost?
Thank you in advance,
Jose
1. Yes, it's correct to send attribute server read command to get the time and the value is obtained in emberAfReadAttributesResponseCallback.
2. emberAfSetTimeCallback is for accessing to real time clock to update that clock. I suppose you should use emberAfWriteAttribute to update time cluster/attributes.
Hi Yk
Related to question 1, it works fine.
The problem related to question 2 is that the local atribute is updated every second (Time Server plugin). It means, that every second the emberAfSetTimeCallback is called and store the value in local attribute table. I can set the unix time in is this callback, but when the attribute read commnad is received, the gateway sends the local attribute, It means that the gateway sends a value that it was updated in the last second, not the exact time mark in this moment. So this could contain an error between [0, 1) senconds. Closer to 0 error second means that the value was update jut before of receiving the attribute read command, and a error closer to 1 second means that the value is about to be updated and the momment of receiving the read attribute command.
The solution I want to test is to declare the Time Attribute as External instead of Singleton. And using the emberAfExternalAttributeReadCallback to store the unix time in the attributeMetadata argument variable. I think it should work.
Thank you,
Jose
Hi Jose,
That assumption should be correct. That way once the emberAfExternalAttributeReadCallback is called, you can just check for the cluster/attribute IDs to ensure they match with the Time Attribute and then you can set the value as you wish. Note however that by defining the attribute as external, you will have to manually manage the storage of this attribute.