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.

CC2652P: reporting with Zstackapi_bdbRepChangedAttrValueReq() freezing the device

Part Number: CC2652P


Good morning, i'm trying to make my custom CC2652P devices (based on zr_genericapp and zed_genericapp) to report a presentValue attribute of the AnalogInput cluster of a Simple Sensor endpoint, which lies next to other Smart plug endpoints inside the device.

My devices are connected to a Zigbee2Mqtt instance, in which i have developed the correct custom converter to support onOff and Metering cluster attributes (not using with report, just polled and actuated).

From the Z2M frontend, if i send a configure report message with a non-zero minimum report interval as in figure, the report works perfectly.

But this is not the ideal scenario for my application, in which i'd like to report that attribute only when changed.

Some times ago, Ryan told me that using setting min and max intervals to NOPERIODIC and NOLIMIT as in figure (both zero as i see in bdb_interface.h) will enable the reporting only when triggered by Zstackapi_bdbRepChangedAttrValueReq().

So i created a periodic routine in my zcl_genericapp.c task which calls the following function emulating a change every 5 seconds, updating the presentValue attribute with a new ''rfid'' value (i will use that attribute to send to my server a new rfid tag, yes)

void zclGenericApp_updateRFIDPresentValueAttribute(uint32_t rfid)
{

    rfid_presentValue = rfid;

#ifdef BDB_REPORTING
        zstack_bdbRepChangedAttrValueReq_t Req;

        Req.attrID = ATTRID_IOV_BASIC_PRESENT_VALUE;
        Req.cluster = ZCL_CLUSTER_ID_GENERAL_ANALOG_INPUT_BASIC;
        Req.endpoint = RFID_ENDPOINT;

        Zstackapi_bdbRepChangedAttrValueReq(appServiceTaskId, &Req);
#endif
}

The problem is that the Zstackapi_bdbRepChangedAttrValueReq freezes my device.

This only happens after i sent a configure report message from the Z2M frontend, if i never send it, leaving the reporting disabled, the function just pass without report anything but not freezing.

I have tried to debug the function, and for now i can just say that it get stuck in "msgStatus = OsalPort_msgSend( stackServiceTaskId, (uint8_t*) pMsg );"

at row 140 of zstackapi.c.

How could i proceed?

Thank you sincerely for any help, i will really appreciate it.

Regards and have nice holidays

Roberto

  • Hi Roberto,

    Has your zcl_genericapp.c application used Zstackapi_bdbRepAddAttrCfgRecordDefaultToListReq to add default configuration values for the reportable attribute record and does both this function and bdb_ProcessInConfigReportCmd return successfully?  Are you stating that the Zstackapi_bdbRepChangedAttrValueReq API is not able to enter bdb_RepChangedAttrValue (followed by bdb_RepReport) for further debugging?  What is the call stack when you end inside sendReqDefaultRsp?

    Regards,
    Ryan

  • Hi Ryan, thank you.

    I did not call Zstackapi_bdbRepAddAttrCfgRecordDefaultToListReq, which should not be useful for me if i send an explicit configure report message from the Z2M frontend with the correct parameters. Is it correct?

    I just called Zstackapi_bdbRepChangedAttrValueReq alone in my routine and was freezing the device, it enters sendReqDefaultRsp, then OsalPort_msgSend and at that point debugging was very hard for some reason, (debug pointer jumping not linearly and finishing in disassembly), so i just knew it never sends that message to the bdb task.

    So.. i changed the optimization level from z to 0 and it works perfectly, and debugging over there goes as expected and OsalPort_msgSend returns successfully. I double checked it returning to z and it freezes again, for now i'm not going to think about it.

    Now, i do not want to have to send manually a configure report from the Z2M frontend page, so (if i understood well enough) i need to use Zstackapi_bdbRepAddAttrCfgRecordDefaultToListReq to send myself a configure report message to the zstack task, is it true?

    If so, i'm using it in this way inside zclGenericApp_Init()

        //Make the attribute reportable
        uint8_t repChange[] = {0,0,0,0};
        OsalPort_memcpy(Req.reportableChange, repChange, BDBREPORTING_MAX_ANALOG_ATTR_SIZE /*4*/);
        Req.attrID = ATTRID_IOV_BASIC_PRESENT_VALUE;
        Req.cluster = ZCL_CLUSTER_ID_GENERAL_ANALOG_INPUT_BASIC;
        Req.endpoint = RFID_ENDPOINT;
        Req.maxReportInt = BDBREPORTING_NOPERIODIC;
        Req.minReportInt = BDBREPORTING_NOLIMIT;
    
        if (Zstackapi_bdbRepAddAttrCfgRecordDefaultToListReq(appServiceTaskId, &Req) != zstack_ZStatusValues_ZSuccess) {
            // Failed to make the attribute reportable
            LED_setOn(gRedLedHandle, LED_BRIGHTNESS_MAX);
        }

    and it returns successfully, but still no report is sent when Zstackapi_bdbRepChangedAttrValueReq is called. Until i send again an explicit configure report message from the Zigbee2Mqtt instance, in that case it finally starts to send them.

    I have put a breakpoint inside processBdbProcessInConfigReportReq which contains bdb_ProcessInConfigReportCmd, as i expected to enter there after Zstackapi_bdbRepAddAttrCfgRecordDefaultToListReq sent the message successfully to the zstack task.

    What am i missing?

    EDIT:

    Zstackapi_bdbRepAddAttrCfgRecordDefaultToListReq sends a message to the zstack task which enters

    processBdbRepAddAttrCfgRecordDefaultToListReq that enters

    bdb_RepAddAttrCfgRecordDefaultToList

    and that last function returns successfully, but still the reports are not sent until an explicit configure report from Z2M

    EDIT 2:

    debugging the Zstackapi_bdbRepChangedAttrValueReq called without effect, i see that it exits here inside bdb_RepChangedAttrValue

      if( bdb_reportingClusterEndpointArray[indexClusterEndpoint].consolidatedMaxReportInt == BDBREPORTING_REPORTOFF )
      {
        //reporting if off for this cluster
        return ZSuccess;
      }

    that consolidatedMaxReportInt is 0xFFFF... But in the Zstackapi_bdbRepAddAttrCfgRecordDefaultToListReq request i have maxInterval to 0

  • You should not have to call Zstackapi_bdbRepAddAttrCfgRecordDefaultToListReq if sending configure report messages from the zigbee2mqtt frontend.  Using Zstackapi_bdbRepAddAttrCfgRecordDefaultToListReq will only be effective if the cluster/attribute are correctly bound to an endpoint on the frontend.  Configure report messages from the zigbee2mqtt succeed since they provide the destination endpoint.  Thus you will need to perform a Bind Request on the sensor for attribute reporting to take effect, otherwise reporting will not be enabled.

    Regards,
    Ryan

  • Ok, thank you, could you please indicate the right Bind Request api to call to do such thing in order to avoid the need of zigbee2mqtt side configuration? I'm looking at this doc but it is not clear to me how to create the bind from my devices to the coordinator

  • The correct Monitor and Test API would be ZDO_BIND_REQ (ZNP), and for the Z-Stack API (application level) it is Zstackapi_ZdoBindReq.  This will require the nwk address of the target device, source endpoint & IEEE address, destination endpoint & IEEE address, and cluster ID.  Zigbee2MQTT has a forum which you could contact for further support using their software. 

    Regards,
    Ryan

  • Thank you Ryan, i solved this issue some minutes ago using the "configure" section of my Z2M custom converter configuration in order to send to the device the right configure report messages and bindings just after the pairing.

    Now, an rfid tag is detected, the device sends an attribute report and Z2M convert it in an MQTT message containing a field like this { ...., "rfid":3.9265504009152834e-40}.

    This is certainly not the most clean solution, ignoring the fact that presentValue attribute has float type.

    Do you have any advice on a better cluster attribute in which i can pass my rfid code in order to notify it to the server?

  • This will depend on your attribute's data type and how Zigbee2MQTT processes messages from each attribute.  I suggest contacting the Zigbee2MQTT developers for further assistance.

    Regards,
    Ryan