This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ZCL Attribute Write Validation

Other Parts Discussed in Thread: CC2538

Using Z Stack on a CC2538 for a Home Automation project.  I'm a module attached to the device so I communicate to the device (read/write attributes' values)  I'm trying to be notified when the network writes to an attribute so I can pass the change down to the device.  I believe I want to use Attribute Write Validation but I don't see any examples showing how to do this.

Can you please point me in the right direction.

Thanks.

  • As I know, there is no write attribute validation. When a device receives attribute write, there is a callback function only.

  • Yeah, I understand. How do I register that callback. I've been trying to make it happen for a few hours.
  • I figured out my issue (well one of my many issues)...I was calling the zcl_registerReadWriteCB() before I called zcl_registerAttrList().

    I should have called it after:

    // Register the application's attribute list
    zcl_registerAttrList( MY_APP_ENDPOINT, MY_APP_MAX_ATTRIBUTES, zcl_myApp_Attrs );

    zcl_registerReadWriteCB(MY_APP_ENDPOINT,AttributeReadWriteCB,AttributeReadWriteValidationCB);


    The other thing to do is to not give the address of your variable when defining that attribute in your attribute list. This makes zcl call you callback function.

    Thanks for you help.
  • Try to check zclProcessInWriteCmd() in zcl.c.

  • I was already looking at that function...that is how I figured out that I had to set the attribute's dataptr to NULL:

            // Write the new attribute value
            if ( attrRec.attr.dataPtr != NULL )
            {
              status = zclWriteAttrData( pInMsg->msg->endPoint, &(pInMsg->msg->srcAddr),
                                         &attrRec, statusRec );
            }
            else // Use CB
            {
              status = zclWriteAttrDataUsingCB( pInMsg->msg->endPoint, &(pInMsg->msg->srcAddr),
                                                &attrRec, statusRec->attrData );
            }

    I have the stack calling my callback on write but it is not passing the value correctly.  As I follow the calls to my callback I see that the "statusRec->attrData" pointer gets way out of whack is not pointing to the data when it gets to my callback. 

    Have you used this callback before?