Reply
Posts: 2
Registered: ‎03-09-2017

Byte order for emberAfWriteAttribute() and friends

I'm having trouble finding a direct answer to this.  When I call emberAfWriteAttribute() and related functions, should byte 0 of the provided buffer be the MSB or the LSB of my value?  I am using a lot of attributes that are 24- and 48-bit, and just can't seem to find the answer.  

 

Also, are there any built-in functions for working with these values?  For example, built in math or packaging functions that I can use?  

 

Thanks for any tips.

Posts: 129
Registered: ‎11-06-2014

Re: Byte order for emberAfWriteAttribute() and friends

Hi,

 

If you look at emAfWriteAttribute() in attribute-table.c and emAfReadOrWriteAttribute() in attribute-storage.c, you can see that the data is simply copied as bytes from the buffer to the location of the attribute.

 

If you compare what you write to what you read back, what discrepancy do you see? I'm not sure what you meant by built-in functions for working with these values, but perhaps you could try our CLI: "read" and "write" to read/write a local attribute, or "zcl global read" and "zcl global write" to read/write attributes globally. For example, this CLI command:

read 2 6 0 1

reads the server attribute ID 0x0000 on cluster 0x0006 on endpoint 2 of the local device. Perhaps you could use this command to verify that the attribute is what you expect. I suspect that there's indeed something to do with the data type and how it's stored.

 

Best regards,

Yuping