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.

LAUNCHXL-CC26X2R1: Display temperature values and toggle the light

Part Number: LAUNCHXL-CC26X2R1
Other Parts Discussed in Thread: SYSCONFIG, Z-STACK

Hi,

I am starting with the project zr_sw. I added the code for a OMROM d6t-8l temperature sensor which I will use as a occupancy sensor. I created a submenu option where I want to see the temperature at the moment, so while I am in this submenu, I can see the temperature updating itself displayed in the CUI.

In zcl_sampleapps_ui.c I created this function called uiActionSetSensorPresencia. I call readSensor and it gets the temperature. Then I call checkOccupancy and it return "1" if it detects a person or "0" if not.

This is what I am trying to do:

1. When I enter this submenu, on the first line I want the temperature to be shown until I get off this submenu. At this moment, when I get into this submenu I just see the temperature value once.

2. As it is reading the temperature value and checking if there is occupied, if it detects "occupied" I want to toggle the light. I should not use "zclGeneral_SendOnOff_CmdToggle" in there but I do not know how to do it.

I tried adding while loops but it does not work like that.

Thank you.

static void uiActionSetSensorPresencia(const char _input, char* _pLines[3], CUI_cursorInfo_t* _pCurInfo);

CUI_MENU_ITEM_INT_ACTION("< READ SENSOR >", (CUI_pFnIntercept_t) uiActionSetSensorPresencia)

static void uiActionSetSensorPresencia(const char _input, char* _pLines[3], CUI_cursorInfo_t* _pCurInfo)
{
    if (CUI_ITEM_INTERCEPT_START == _input) {

        char tmpPtat[8] = ""; char tmp1[8] = ""; char tmpInt[8] = "";
        
        zstack_getZCLFrameCounterRsp_t Rsp;
        //Zstackapi_getZCLFrameCounterReq(appServiceTaskId, &Rsp);

        char tmpEntera[8] = ".";char tmpDouble[8];
        
        double *value = readSensor();
        int occupied = checkOccupancy();
        
        if (occupied == 1) {
            strcpy(tmpInt, "OCUPADO");
        } else {
            strcpy(tmpInt, "NO_OCUP");
        }
        doubleToString(value[0], tmpPtat, tmpEntera, tmpDouble);
        doubleToString(value[1], tmp1, tmpEntera, tmpDouble);

        strncpy(_pLines[0], "Mostrando valores:", MAX_MENU_LINE_LEN);
        strncpy(_pLines[1], value[0], MAX_MENU_LINE_LEN);
        strncpy(_pLines[2], tmpInt, MAX_MENU_LINE_LEN);
        
        if (occupied == 1) {
            zclGeneral_SendOnOff_CmdToggle( SAMPLESW_ENDPOINT, &listBulbs[FBBulbsFound-1], TRUE, Rsp.zclFrameCounter );
        }


    }

}

  • Hi Dani,

    1. I recommend learning to use CUI_statusLinePrintf as demonstrated in the sample projects to update the value as necessary.  This should be performed from the zcl application code file, not the modified UI code.

    2. The sample projects also demonstrate using zclGeneral_SendOnOff_CmdToggle which should be handled from the zcl application code.  I am not sure what you are attempting to accomplish if this API is not to be used.

    Regards,
    Ryan 

  • Hi Ryan,

    1. Yes, I did something similiar that you suggested me months ago. But I'm not asking for a new info line like Bind info or App info, I want to know if I can get a submenu where all I display is the temperature. For example: menu parent "Set Config Sensor Presencia", submenu "Read sensor" and in that submenu just display the temperature values. I am trying that now on zcl_samplesw.c instead of ui file.

    2. Yes, my bad. I created a new function inside zcl_samplesw.c to handle that.

    Thank you.

  • In this case, changing the UI for a new menu item will require adding a CUI_SUB_MENU around the CUI_MENU_ITEM_INT_ACTION.  There are examples available from the cui.h comments concerning how to approach this.  You can also choose to create new CUI_INPUT_* which are not based on key presses and refresh the existing display with CUI_dispMenu.

    Regards,
    Ryan\

  • Hello, I am a bit lost, I created the menu. I don't know how can I use a new CUI_INPUT_* to refresh the existing display.

    I can create in cui.h a new #define CUI_INPUT_something 0xDD (for example). uiActionSetSensorPresencia is on zcl_samplesw.c. So inside this function should I use CUI_dispMenu(false) and the new CUI_INPUT?

    I am sorry but I don't know how to check occupancy at every moment. I created zcl_occupancy_data.c in order to get that information but I don't know how to attach it to my code.

    I attach the application folder in case you can guide me a bit. Thank you.

    CUI_SUB_MENU(zclSubmenuSensor, "<   SET CONFIG SENSOR DE PRESENCIA   >", SENSOR_SUBMENUS, zclMenuMain)
        CUI_MENU_ITEM_INT_ACTION("< READ SENSOR >", (CUI_pFnIntercept_t) uiActionSetSensorPresencia)
        CUI_MENU_ITEM_INT_ACTION("< OPTION 2 >", (CUI_pFnIntercept_t) uiActionListDevices)
        CUI_MENU_ITEM_INT_ACTION("< OPTION 3 >", (CUI_pFnIntercept_t) uiActionListDevices)
    CUI_SUB_MENU_END
    
    
    6102.Application.zip

  • Do you recommend starting from zr_temperaturesensor instead of zr_switch? I started with zr_sw because first I had just to toggle the light from the zr. I mean, at this point, restart everything and use zr_temperaturesensor project.

    Thank you.

  • It does not even have to be a CUI_INPUT_* specifically, given the refresh typically occurs from receiving UART characters.  It was provided as a common example and you could use CUI_dispMenu during an event triggered by the timer callback after it expires.  You could start with zr_temperaturesensor instead but you may also need to carry over zr_samplesw_data.c and create multiple endpoints if you plan on using this device to also toggle a remote light.

    Regards,
    Ryan

  • Thank you. I should not ask more than 2 non-related questions. I am going to center now on the occupancy sensing.

    I am following the temperature sensor project. I created a new endpoint

    Should I make it reportable like the temperaturesensor example? (  uint8_t reportableChange[] = {0x2C, 0x01, 0x00, 0x00}; // 0x2C01 is 300 in int16_t)

    I understand that the value I want to check is the ATTRID_OCCUPANCY_SENSING_OCCUPANCY. But I don't know how to attach the value given by the sensor. In the project example it does not call any function in order to get the temperature or something like that.

    Thank you.

      // *** Temperature Measurement Attriubtes ***
      {
        ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING,
        { // Attribute record
          ATTRID_OCCUPANCY_SENSING_OCCUPANCY,
          ZCL_DATATYPE_BITMAP8,
          ACCESS_CONTROL_READ | ACCESS_REPORTABLE,
          (void *)&zclSampleOccupancy_sensor_occupancy
        }
      },

  • You can import the zr_sampleapp project and change the SysConfig -> Z-STack -> Zigbee Application Endpoint -> Zigbee Device Type to Occupancy Sensor, then view the generated zcl_config.c/h files for a better idea of how the Occupancy Sensor should be initialized.  You can also reference the ZCL Specification (ZCL v6 for reference) to better understand the reportable Occupancy Attribute details.  

    4.8.2.1.1.1 Occupancy Attribute
    The Occupancy attribute is a bitmap.
    Bit 0 specifies the sensed occupancy as follows: 1 = occupied, 0 = unoccupied.
    All other bits are reserved.

    Regards,
    Ryan

  • Yes, I have a better idea but I still have some doubts. I think I know now enough of endpoints, bind and that stuff to implement this.

    I have a zcl_occupancy_data.c similar to zcl_config.c which is attached. With that file should I be able to detect occupancy with my OMROM d6t-8l? I don't need d6t-8l code? (I am talking about code just for the sensor)PD: this file could have errors, I am talking to the idea of the file.

    /**************************************************************************************************
      Filename:       zcl_sampletemperaturesensor_data.c
      Revised:        $Date: 2014-09-25 13:20:41 -0700 (Thu, 25 Sep 2014) $
      Revision:       $Revision: 40295 $
    
    
      Description:    Zigbee Cluster Library - sample device application.
    
    
      Copyright 2013-2014 Texas Instruments Incorporated. All rights reserved.
    
      IMPORTANT: Your use of this Software is limited to those specific rights
      granted under the terms of a software license agreement between the user
      who downloaded the software, his/her employer (which must be your employer)
      and Texas Instruments Incorporated (the "License").  You may not use this
      Software unless you agree to abide by the terms of the License. The License
      limits your use, and you acknowledge, that the Software may not be modified,
      copied or distributed unless embedded on a Texas Instruments microcontroller
      or used solely and exclusively in conjunction with a Texas Instruments radio
      frequency transceiver, which is integrated into your product.  Other than for
      the foregoing purpose, you may not use, reproduce, copy, prepare derivative
      works of, modify, distribute, perform, display or sell this Software and/or
      its documentation for any purpose.
    
      YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
      PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
      INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
      NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
      TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
      NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
      LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
      INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
      OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
      OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
      (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    
      Should you have any questions regarding your right to use this Software,
      contact Texas Instruments Incorporated at www.TI.com.
    **************************************************************************************************/
    
    /*********************************************************************
     * INCLUDES
     */
    #include "zcomdef.h"
    #include "zcl.h"
    #include "zcl_general.h"
    #include "zcl_ha.h"
    #include "zcl_ms.h"
    #include "zcl_samplesw.h"
    
    //#include "zcl_sampletemperaturesensor.h"
    
    /*********************************************************************
     * CONSTANTS
     */
    
    
    #define SAMPLEOCCUPANCY_DEVICE_VERSION     0
    #define SAMPLEOCCUPANCY_FLAGS              0
    
    #define SAMPLEOCCUPANCY_HWVERSION          1
    #define SAMPLEOCCUPANCY_ZCLVERSION         BASIC_ZCL_VERSION
    
    // todo
    #define SAMPLETEMPERATURESENSOR_MAX_MEASURED_VALUE  2700  // 27.00C
    #define SAMPLETEMPERATURESENSOR_MIN_MEASURED_VALUE  1700  // 17.00C
    
    /*********************************************************************
     * TYPEDEFS
     */
    
    /*********************************************************************
     * MACROS
     */
    
    /*********************************************************************
     * GLOBAL VARIABLES
     */
    
    // Global attributes
    const uint16_t zclSampleOccupancy_basic_clusterRevision = 0x0002;
    const uint16_t zclSampleOccupancy_identify_clusterRevision = 0x0001;
    const uint16_t zclSampleOccupancy_temperaturems_clusterRevision = 0x0001;
    
    // Basic Cluster
    const uint8_t zclSampleOccupancy_HWRevision = SAMPLEOCCUPANCY_HWVERSION;
    const uint8_t zclSampleOccupancy_ZCLVersion = SAMPLEOCCUPANCY_ZCLVERSION;
    const uint8_t zclSampleOccupancy_ManufacturerName[] = { 16, 'T','e','x','a','s','I','n','s','t','r','u','m','e','n','t','s' };
    const uint8_t zclSampleOccupancy_PowerSource = POWER_SOURCE_MAINS_1_PHASE;
    uint8_t zclSampleOccupancy_PhysicalEnvironment = PHY_UNSPECIFIED_ENV;
    
    // Identify Cluster
    uint16_t zclSampleOccupancy_IdentifyTime;
    
    // Occupancy Cluster
    uint16_t zclSampleOccupancy_clusterRevision = 0x0001;
    uint16_t zclSampleOccupancy_sensor_occupancy = 0x0000;
    uint16_t zclSampleOccupancy_sensor_type = 0x0000;
    uint16_t zclSampleOccupancy_sensor_type_bitmap = 0x0000;
    
    /*********************************************************************
     * ATTRIBUTE DEFINITIONS - Uses REAL cluster IDs
     */
    
    // NOTE: The attributes listed in the AttrRec must be in ascending order
    // per cluster to allow right function of the Foundation discovery commands
    
    CONST zclAttrRec_t zclSampleOccupancy_Attrs[] =
    {
      // *** General Basic Cluster Attributes ***
      {
        ZCL_CLUSTER_ID_GENERAL_BASIC,
        { // Attribute record
          ATTRID_BASIC_ZCL_VERSION,
          ZCL_DATATYPE_UINT8,
          ACCESS_CONTROL_READ,
          (void *)&zclSampleOccupancy_ZCLVersion
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_BASIC,             // Cluster IDs - defined in the foundation (ie. zcl.h)
        {  // Attribute record
          ATTRID_BASIC_HW_VERSION,            // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
          ZCL_DATATYPE_UINT8,                 // Data Type - found in zcl.h
          ACCESS_CONTROL_READ,                // Variable access control - found in zcl.h
          (void *)&zclSampleOccupancy_HWRevision  // Pointer to attribute variable
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_BASIC,
        { // Attribute record
          ATTRID_BASIC_MANUFACTURER_NAME,
          ZCL_DATATYPE_CHAR_STR,
          ACCESS_CONTROL_READ,
          (void *)zclSampleOccupancy_ManufacturerName
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_BASIC,
        { // Attribute record
          ATTRID_BASIC_POWER_SOURCE,
          ZCL_DATATYPE_ENUM8,
          ACCESS_CONTROL_READ,
          (void *)&zclSampleOccupancy_PowerSource
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_BASIC,
        { // Attribute record
          ATTRID_BASIC_PHYSICAL_ENVIRONMENT,
          ZCL_DATATYPE_ENUM8,
          (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
          (void *)&zclSampleOccupancy_PhysicalEnvironment
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_BASIC,
        {  // Attribute record
          ATTRID_CLUSTER_REVISION,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          (void *)&zclSampleOccupancy_basic_clusterRevision
        }
      },
      // *** Identify Cluster Attribute ***
      {
        ZCL_CLUSTER_ID_GENERAL_IDENTIFY,
        { // Attribute record
          ATTRID_IDENTIFY_IDENTIFY_TIME,
          ZCL_DATATYPE_UINT16,
          (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
          (void *)&zclSampleOccupancy_IdentifyTime
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_IDENTIFY,
        {  // Attribute record
          ATTRID_CLUSTER_REVISION,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_GLOBAL,
          (void *)&zclSampleOccupancy_identify_clusterRevision
        }
      },
    
      // *** Temperature Measurement Attriubtes ***
      {
        ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING,
        { // Attribute record
          ATTRID_OCCUPANCY_SENSING_OCCUPANCY,
          ZCL_DATATYPE_BITMAP8,
          ACCESS_CONTROL_READ | ACCESS_REPORTABLE,
          (void *)&zclSampleOccupancy_sensor_occupancy
        }
      },
      {
        ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING,
        { // Attribute record
          ATTRID_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE,
          ZCL_DATATYPE_ENUM8,
          ACCESS_CONTROL_READ,
          (void *)&zclSampleOccupancy_sensor_type
        }
      },
      {
        ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING,
        { // Attribute record
          ATTRID_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_BITMAP,
          ZCL_DATATYPE_BITMAP8,
          ACCESS_CONTROL_READ,
          (void *)&zclSampleOccupancy_sensor_type_bitmap
        }
      },
    
      {
        ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING,
        {  // Attribute record
          ATTRID_CLUSTER_REVISION,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_GLOBAL,
          (void *)&zclSampleOccupancy_clusterRevision
        }
      },
    };
    
    uint8_t CONST zclSampleOccupancy_NumAttributes = ( sizeof(zclSampleOccupancy_Attrs) / sizeof(zclSampleOccupancy_Attrs[0]) );
    
    /*********************************************************************
     * SIMPLE DESCRIPTOR
     */
    // This is the Cluster ID List and should be filled with Application
    // specific cluster IDs.
    #define ZCLSAMPLEOCCUPANCY_MAX_INCLUSTERS       3
    const cId_t zclSampleOccupancy_InClusterList[ZCLSAMPLEOCCUPANCY_MAX_INCLUSTERS] =
    {
      ZCL_CLUSTER_ID_GENERAL_BASIC,
      ZCL_CLUSTER_ID_GENERAL_IDENTIFY,
      ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING
    };
    
    #define ZCLSAMPLEOCCUPANCY_MAX_OUTCLUSTERS       1
    const cId_t zclSampleOccupancy_OutClusterList[ZCLSAMPLEOCCUPANCY_MAX_OUTCLUSTERS] =
    {
      ZCL_CLUSTER_ID_GENERAL_IDENTIFY
    };
    
    SimpleDescriptionFormat_t zclSampleOccupancy_SimpleDesc =
    {
      SAMPLEOCCUPANCY_ENDPOINT,                  //  int Endpoint;
      ZCL_HA_PROFILE_ID,                                 //  uint16_t AppProfId[2];
      ZCL_DEVICEID_OCCUPANCY_SENSOR ,                //  uint16_t AppDeviceId[2]; TODO: ???
      SAMPLEOCCUPANCY_DEVICE_VERSION,            //  int   AppDevVer:4;
      SAMPLEOCCUPANCY_FLAGS,                     //  int   AppFlags:4;
      ZCLSAMPLEOCCUPANCY_MAX_INCLUSTERS,         //  byte  AppNumInClusters;
      (cId_t *)zclSampleOccupancy_InClusterList, //  byte *pAppInClusterList;
      ZCLSAMPLEOCCUPANCY_MAX_OUTCLUSTERS,        //  byte  AppNumInClusters;
      (cId_t *)zclSampleOccupancy_OutClusterList //  byte *pAppInClusterList;
    };
    
    /*********************************************************************
     * GLOBAL FUNCTIONS
     */
    
    /*********************************************************************
     * LOCAL FUNCTIONS
     */
    
    /*********************************************************************
     * @fn      zclSampleLight_ResetAttributesToDefaultValues
     *
     * @brief   Reset all writable attributes to their default values.
     *
     * @param   none
     *
     * @return  none
     */
    void zclSampleOccupancy_ResetAttributesToDefaultValues(void)
    {
    
      zclSampleOccupancy_PhysicalEnvironment = PHY_UNSPECIFIED_ENV;
    
    #ifdef ZCL_IDENTIFY
      zclSampleOccupancy_IdentifyTime = 0;
    #endif
    
    }
    
    /****************************************************************************
    ****************************************************************************/
    
    

    Thank you.

  • With the file you've included and registering the endpoint correctly, you should be capable of sending ATTRID_OCCUPANCY_SENSING_* attributes for the ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING cluster.  Your application (ex. manual binds) and commissioning process (i.e. Finding & Binding) will determine how the OMROM d6t-8l communicates with the CC26X2R1 device and prepares to send occupancy data.  You should contact the product manufacturer to learn more about the expected operation of this device.

    Regards,
    Ryan

  • All right. If i set up a packet sniffer, when the CC26X2R1 with the endpoint registered joins the network, could I see if there are all the endpoints and clusters well defined?

    With the bulb, when it joins the network I can see his info in the log, but the way a d6t-8l joins the network is by I2C with one CC26X2R1, right?

    Thank you.

  • You could perform device discovery on joining devices to find out more about the endpoints and simple descriptors supported.  This is demonstrated in the Zigbee Fundamentals SimpleLink Academy Lab.  I've edited my previous post for clarity.  Your destination node receiving ATTRID_OCCUPANCY_SENSING_* will require a ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING stored in the *_OutClusterList of an endpoint registered on that device.  This Cluster Type relationship is further explained in Section 6.2 of SWRA615.

    Regards,
    Ryan

  • Yes, I hadn't realized that I had to modify the cluster list on the coordinator node for example. As I found in the ZCL especification, in the destination node (the client) I just have to add ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING  in the OutClusterList, I don't need to add any attribute, right? Only in the server side.

    Thank you.

  • You should add the desired ATTRID_OCCUPANCY_SENSING_* as ACCESS_CONTROL_READ in the ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING  attribute record for your zc as well.

    Regards,
    Ryan

  • I tried to add the attributes to the zc but the error "error #20: identifier "ATTRID_OCCUPANCY_SENSING_OCCUPANCY" is undefined" is shown. I added zcl_ms.h so I don't know why it can't find it.

    /**************************************************************************************************
      Filename:       zcl_samplesw_data.c
      Revised:        $Date: 2014-07-30 12:57:37 -0700 (Wed, 30 Jul 2014) $
      Revision:       $Revision: 39591 $
    
    
      Description:    Zigbee Cluster Library - sample device application.
    
    
      Copyright 2006-2014 Texas Instruments Incorporated. All rights reserved.
    
      IMPORTANT: Your use of this Software is limited to those specific rights
      granted under the terms of a software license agreement between the user
      who downloaded the software, his/her employer (which must be your employer)
      and Texas Instruments Incorporated (the "License").  You may not use this
      Software unless you agree to abide by the terms of the License. The License
      limits your use, and you acknowledge, that the Software may not be modified,
      copied or distributed unless embedded on a Texas Instruments microcontroller
      or used solely and exclusively in conjunction with a Texas Instruments radio
      frequency transceiver, which is integrated into your product.  Other than for
      the foregoing purpose, you may not use, reproduce, copy, prepare derivative
      works of, modify, distribute, perform, display or sell this Software and/or
      its documentation for any purpose.
    
      YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
      PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
      INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
      NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
      TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
      NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
      LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
      INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
      OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
      OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
      (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    
      Should you have any questions regarding your right to use this Software,
      contact Texas Instruments Incorporated at www.TI.com.
    **************************************************************************************************/
    
    /*********************************************************************
     * INCLUDES
     */
    #include "zcomdef.h"
    #include "zcl.h"
    #include "zcl_general.h"
    #include "zcl_ha.h"
    #include "zcl_poll_control.h"
    #include "zcl_electrical_measurement.h"
    #include "zcl_diagnostic.h"
    #include "zcl_meter_identification.h"
    #include "zcl_appliance_identification.h"
    #include "zcl_appliance_events_alerts.h"
    #include "zcl_power_profile.h"
    #include "zcl_appliance_control.h"
    #include "zcl_appliance_statistics.h"
    #include "zcl_hvac.h"
    #include "zcl_ll.h"
    #include "zcl_ms.h"
    
    
    #ifdef OTA_CLIENT_INTEGRATED
    #include "ota_client.h"
    #include "zcl_ota.h"
    #endif
    
    #include "zcl_samplesw.h"
    
    /*********************************************************************
     * CONSTANTS
     */
    
    #define SAMPLESW_DEVICE_VERSION     1
    #define SAMPLESW_FLAGS              0
    
    #define SAMPLESW_HWVERSION          0
    #define SAMPLESW_ZCLVERSION         BASIC_ZCL_VERSION
    
    #define DEFAULT_IDENTIFY_TIME 0
    
    /*********************************************************************
     * TYPEDEFS
     */
    
    /*********************************************************************
     * MACROS
     */
    
    /*********************************************************************
     * GLOBAL VARIABLES
     */
    
    //global attributes
    const uint16_t zclSampleSw_basic_clusterRevision = 0x0002;
    const uint16_t zclSampleSw_identify_clusterRevision = 0x0001;
    const uint16_t zclSampleSw_onoff_clusterRevision = 0x0001;
    const uint16_t zclSampleSw_onoffswconfig_clusterRevision = 0x0001;
    const uint16_t zclSampleSw_onoff_onoff = 0x0000;
    
    // Basic Cluster
    const uint8_t zclSampleSw_HWRevision = SAMPLESW_HWVERSION;
    const uint8_t zclSampleSw_ZCLVersion = SAMPLESW_ZCLVERSION;
    const uint8_t zclSampleSw_ManufacturerName[] = { 16, 'T','e','x','a','s','I','n','s','t','r','u','m','e','n','t','s' };
    const uint8_t zclSampleSw_PowerSource = POWER_SOURCE_MAINS_1_PHASE;
    uint8_t zclSampleSw_PhysicalEnvironment = PHY_UNSPECIFIED_ENV;
    
    // Identify Cluster
    uint16_t zclSampleSw_IdentifyTime = 0;
    
    // Occupancy Cluster
    uint16_t zclSampleOccupancy_clusterRevision = 0x0001;
    uint16_t zclSampleOccupancy_sensor_occupancy = 0x0000;
    uint16_t zclSampleOccupancy_sensor_type = 0x0000;
    uint16_t zclSampleOccupancy_sensor_type_bitmap = 0x0000;
    
    #ifdef OTA_CLIENT_INTEGRATED
    // global attributes
    const uint16_t zclSampleSw_ota_clusterRevision = 0x0001;
    // OTA Client Cluster
    static uint16_t zclSampleSw_ImageType = OTA_TYPE_ID;
    static uint8_t  zclSampleSw_ImageUpgradeStatus = 0;
    static uint8_t  zclSampleSw_UpgradeServerID[Z_EXTADDR_LEN] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
    static uint16_t zclSampleSw_MinBlockReqDelay = 0;
    static uint32_t zclSampleSw_FileOffset = 0xFFFFFFFF;
    static uint32_t zclSampleSw_CurrentFileVersion = OTA_APP_VERSION;
    static uint16_t zclSampleSw_CurrentZigBeeStackVersion = OTA_STACK_VER_PRO;
    static uint32_t zclSampleSw_DownloadedFileVersion = 0xFFFFFFFF;
    static uint16_t zclSampleSw_DownloadedZigBeeStackVersion = 0xFFFF;
    static uint16_t zclSampleSw_ManufacturerID = OTA_MANUFACTURER_ID;
    #endif
    
    /*********************************************************************
     * ATTRIBUTE DEFINITIONS - Uses REAL cluster IDs
     */
    
      // NOTE: The attributes listed in the AttrRec must be in ascending order
      // per cluster to allow right function of the Foundation discovery commands
    
    CONST zclAttrRec_t zclSampleSw_Attrs[] =
    {
      // *** General Basic Cluster Attributes ***
      {
        ZCL_CLUSTER_ID_GENERAL_BASIC,
        { // Attribute record
          ATTRID_BASIC_ZCL_VERSION,
          ZCL_DATATYPE_UINT8,
          ACCESS_CONTROL_READ,
          (void *)&zclSampleSw_ZCLVersion
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_BASIC,             // Cluster IDs - defined in the foundation (ie. zcl.h)
        {  // Attribute record
          ATTRID_BASIC_HW_VERSION,            // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
          ZCL_DATATYPE_UINT8,                 // Data Type - found in zcl.h
          ACCESS_CONTROL_READ,                // Variable access control - found in zcl.h
          (void *)&zclSampleSw_HWRevision  // Pointer to attribute variable
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_BASIC,
        { // Attribute record
          ATTRID_BASIC_MANUFACTURER_NAME,
          ZCL_DATATYPE_CHAR_STR,
          ACCESS_CONTROL_READ,
          (void *)zclSampleSw_ManufacturerName
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_BASIC,
        { // Attribute record
          ATTRID_BASIC_POWER_SOURCE,
          ZCL_DATATYPE_ENUM8,
          ACCESS_CONTROL_READ,
          (void *)&zclSampleSw_PowerSource
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_BASIC,
        { // Attribute record
          ATTRID_BASIC_PHYSICAL_ENVIRONMENT,
          ZCL_DATATYPE_ENUM8,
          (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
          (void *)&zclSampleSw_PhysicalEnvironment
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_BASIC,
        {  // Attribute record
          ATTRID_CLUSTER_REVISION,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          (void *)&zclSampleSw_basic_clusterRevision
        }
      },
    
      // *** Identify Cluster Attribute ***
      {
        ZCL_CLUSTER_ID_GENERAL_IDENTIFY,
        { // Attribute record
          ATTRID_IDENTIFY_IDENTIFY_TIME,
          ZCL_DATATYPE_UINT16,
          (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
          (void *)&zclSampleSw_IdentifyTime
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_IDENTIFY,
        {  // Attribute record
          ATTRID_CLUSTER_REVISION,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_GLOBAL,
          (void *)&zclSampleSw_identify_clusterRevision
        }
      },
      // *** On / Off Cluster *** //
      {
        ZCL_CLUSTER_ID_GENERAL_ON_OFF,
        {  // Attribute record
          ATTRID_CLUSTER_REVISION,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_CLIENT,
          (void *)&zclSampleSw_onoff_clusterRevision
        }
      },
      {
        ZCL_CLUSTER_ID_GENERAL_ON_OFF,
        {  // Attribute record
          ATTRID_ON_OFF_ON_OFF,
          ZCL_DATATYPE_BOOLEAN,
          ACCESS_CONTROL_READ | ACCESS_REPORTABLE,
          (void *)&zclSampleSw_onoff_onoff
        }
      },
      // *** Temperature Measurement Attriubtes ***
       {
         ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING,
         { // Attribute record
           ATTRID_OCCUPANCY_SENSING_OCCUPANCY,
           ZCL_DATATYPE_BITMAP8,
           ACCESS_CONTROL_READ | ACCESS_REPORTABLE,
           (void *)&zclSampleOccupancy_sensor_occupancy
         }
       },
       {
         ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING,
         { // Attribute record
           ATTRID_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE,
           ZCL_DATATYPE_ENUM8,
           ACCESS_CONTROL_READ,
           (void *)&zclSampleOccupancy_sensor_type
         }
       },
       {
         ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING,
         { // Attribute record
           ATTRID_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_BITMAP,
           ZCL_DATATYPE_BITMAP8,
           ACCESS_CONTROL_READ,
           (void *)&zclSampleOccupancy_sensor_type_bitmap
         }
       },
    
       {
         ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING,
         {  // Attribute record
           ATTRID_CLUSTER_REVISION,
           ZCL_DATATYPE_UINT16,
           ACCESS_CONTROL_READ | ACCESS_GLOBAL,
           (void *)&zclSampleOccupancy_clusterRevision
         }
       }
    #if defined (OTA_CLIENT_INTEGRATED)
      ,{
        ZCL_CLUSTER_ID_OTA,
        {
          ATTRID_OTA_UPGRADE_UPGRADE_SERVER_ID,
          ZCL_DATATYPE_IEEE_ADDR ,
          ACCESS_CONTROL_READ | ACCESS_CLIENT,
          ( void * ) &zclSampleSw_UpgradeServerID
        }
      },
      {
        ZCL_CLUSTER_ID_OTA,
        {
          ATTRID_OTA_UPGRADE_FILE_OFFSET,
          ZCL_DATATYPE_UINT32,
          ACCESS_CONTROL_READ | ACCESS_CLIENT,
          ( void * ) &zclSampleSw_FileOffset
        }
      },
      {
        ZCL_CLUSTER_ID_OTA,
        {
          ATTRID_OTA_UPGRADE_CURRENT_FILE_VERSION,
          ZCL_DATATYPE_UINT32,
          ACCESS_CONTROL_READ | ACCESS_CLIENT,
          ( void * ) &zclSampleSw_CurrentFileVersion
        }
      },
      {
        ZCL_CLUSTER_ID_OTA,
        {
          ATTRID_OTA_UPGRADE_CURRENT_ZIG_BEE_STACK_VERSION,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_CLIENT,
          ( void * ) &zclSampleSw_CurrentZigBeeStackVersion
        }
      },
      {
        ZCL_CLUSTER_ID_OTA,
        {
          ATTRID_OTA_UPGRADE_DOWNLOADED_FILE_VERSION,
          ZCL_DATATYPE_UINT32,
          ACCESS_CONTROL_READ | ACCESS_CLIENT,
          ( void * ) &zclSampleSw_DownloadedFileVersion
        }
      },
      {
        ZCL_CLUSTER_ID_OTA,
        {
          ATTRID_OTA_UPGRADE_DOWNLOADED_ZIG_BEE_STACK_VERSION,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_CLIENT,
          ( void * ) &zclSampleSw_DownloadedZigBeeStackVersion
        }
      },
      {
        ZCL_CLUSTER_ID_OTA,
        {
          ATTRID_OTA_UPGRADE_IMAGE_UPGRADE_STATUS,
          ZCL_DATATYPE_ENUM8,
          ACCESS_CONTROL_READ | ACCESS_CLIENT,
          ( void * ) &zclSampleSw_ImageUpgradeStatus
        }
      },
      {
        ZCL_CLUSTER_ID_OTA,
        {
          ATTRID_OTA_UPGRADE_MANUFACTURER_ID,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_CLIENT,
          ( void * ) &zclSampleSw_ManufacturerID
        }
      },
      {
        ZCL_CLUSTER_ID_OTA,
        {
          ATTRID_OTA_UPGRADE_IMAGE_TYPE_ID,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_CLIENT,
          ( void * ) &zclSampleSw_ImageType
        }
      },
      {
        ZCL_CLUSTER_ID_OTA,
        {
          ATTRID_OTA_UPGRADE_MINIMUM_BLOCK_PERIOD,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_CLIENT,
          ( void * ) &zclSampleSw_MinBlockReqDelay
        }
      },
      {
        ZCL_CLUSTER_ID_OTA,
        {
          ATTRID_CLUSTER_REVISION,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_CLIENT,
          ( void * ) &zclSampleSw_ota_clusterRevision
        }
      }
    #endif
    };
    
    uint8_t CONST zclSampleSw_NumAttributes = ( sizeof(zclSampleSw_Attrs) / sizeof(zclSampleSw_Attrs[0]) );
    
    /*********************************************************************
     * SIMPLE DESCRIPTOR
     */
    // This is the Cluster ID List and should be filled with Application
    // specific cluster IDs.
    const cId_t zclSampleSw_InClusterList[] =
    {
      ZCL_CLUSTER_ID_GENERAL_BASIC,
      ZCL_CLUSTER_ID_GENERAL_IDENTIFY,
    };
    
    #define ZCLSAMPLESW_MAX_INCLUSTERS    ( sizeof( zclSampleSw_InClusterList ) / sizeof( zclSampleSw_InClusterList[0] ))
    
    const cId_t zclSampleSw_OutClusterList[] =
    {
      ZCL_CLUSTER_ID_GENERAL_IDENTIFY,
      ZCL_CLUSTER_ID_GENERAL_ON_OFF,
      ZCL_CLUSTER_ID_GENERAL_GROUPS,
      ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING,
    #if defined (OTA_CLIENT_INTEGRATED)
      ZCL_CLUSTER_ID_OTA
    #endif
    };
    
    #define ZCLSAMPLESW_MAX_OUTCLUSTERS   ( sizeof( zclSampleSw_OutClusterList ) / sizeof( zclSampleSw_OutClusterList[0] ))
    
    SimpleDescriptionFormat_t zclSampleSw_SimpleDesc =
    {
      SAMPLESW_ENDPOINT,                  //  int Endpoint;
      //ZLL_PROFILE_ID,                  //  uint16_t AppProfId[2];
      ZCL_HA_PROFILE_ID,                  //  uint16_t AppProfId[2];
      ZCL_DEVICEID_ON_OFF_LIGHT_SWITCH,//  uint16_t AppDeviceId[2];
      SAMPLESW_DEVICE_VERSION,            //  int   AppDevVer:4;
      SAMPLESW_FLAGS,                     //  int   AppFlags:4;
      ZCLSAMPLESW_MAX_INCLUSTERS,         //  byte  AppNumInClusters;
      (cId_t *)zclSampleSw_InClusterList, //  byte *pAppInClusterList;
      ZCLSAMPLESW_MAX_OUTCLUSTERS,        //  byte  AppNumInClusters;
      (cId_t *)zclSampleSw_OutClusterList //  byte *pAppInClusterList;
    };
    
    /*********************************************************************
     * GLOBAL FUNCTIONS
     */
    
    /*********************************************************************
     * LOCAL FUNCTIONS
     */
    
    /*********************************************************************
     * @fn      zclSampleLight_ResetAttributesToDefaultValues
     *
     * @brief   Reset all writable attributes to their default values.
     *
     * @param   none
     *
     * @return  none
     */
    void zclSampleSw_ResetAttributesToDefaultValues(void)
    {
    
      zclSampleSw_PhysicalEnvironment = PHY_UNSPECIFIED_ENV;
      zclSampleSw_IdentifyTime = DEFAULT_IDENTIFY_TIME;
    
    #ifdef OTA_CLIENT_INTEGRATED
      zclSampleSw_ImageUpgradeStatus = 0;
      memset(zclSampleSw_UpgradeServerID, 0xFF, Z_EXTADDR_LEN);
      zclSampleSw_MinBlockReqDelay = 0;
      zclSampleSw_FileOffset = 0xFFFFFFFF;
      zclSampleSw_DownloadedFileVersion = 0xFFFFFFFF;
      zclSampleSw_DownloadedZigBeeStackVersion = 0xFFFF;
    #endif
    }
    
    /****************************************************************************
    ****************************************************************************/
    
    
    

  • Open the Common/zcl folder from your CCS project workspace, the right-click on zcl_ms.c/h and select Resource Configurations -> Exclude from Build to remove the exclusion (or delete and copy/paste from sdk directory's source\ti\zstack\stack\zcl), and have ZCL_MS defined either in Stack/Config/f8wrouter.opts or in the Project Properties -> Build -> Arm Compiler -> Predefined Symbols.  Then clean and re-build your project.

    Regards,
    Ryan

  • I tried that and the are no errors now. I want to open a packet sniffer to see the coordinator endpoints but in Wireshark I can't found that information. Once I see that info on Ubiqua but my free trial expired and I cannot aford it. Wireshark don't show that info or I have anything bad?

    I followed the documentation and I can see info but not that kind of info.

    Thank you.

    1907.zip

  • The packets are encrypted, have you loaded the Zigbee TC Link Key (5a6967426565416c6c69616e63653039) at Edit > Preferences > Protocols > Zigbee before sniffing?  The packets captured are valid and can be interpreted in Ubiqua.  At any rate, the only Active Endpoint and Simple Descriptor Responses come from the router, not coordinator, although maybe this is your intent.

    Regards,
    Ryan

  • Yes, I have loaded the Zigbee TC Link Key, I don't know if I have to change the Security Level.

    How is that the Active Enpoint and Simple Descriptor Responses come from the router? I only have 2 launchpads, 1 of them is used as a packet sniffer and the other one I have to use it as a coordinator although I would want to use it as a router.

    Thank you.

  • I suppose you need another launchpad to act as device to join network so coordinator can request endpoint from the device.

  • Security level is fine as-is.  https://dev.ti.com/tirex/content/simplelink_cc13xx_cc26xx_sdk_6_10_00_29/docs/zigbee/html/zigbee/packet_sniffer.html#id6 

    I don't know what your router device is if not a LaunchPad, however it does not seem to be requesting information like the coordinator is.  So it is a matter of device discovery per each node's application requirements.

    Regards,
    Ryan

  • I could get another launchpad so I had one acting as a router, another acting as a coordinator and the last one which is the packet sniffer.

    I'm still unable to see the log properly like the way I see it in Ubiqua. The link key is introduced as I showed previously though.

    File is attached.

    2007.zip

    Now I see that in the router's terminal, I can see cluster 0x406 which corresponds to ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING. But the endpoint shown is the ON_OFF one, the endpoint used for occupancy is endpoint 9.

    In the router I checked step by step Yikai's guide to add another endpoint and it seems like I did it properly.

    Could you tell me by the log of the packet sniffer if everything is correct?

    Thank you.

  • The ZC now sends a Simple Descriptor Response:

    Only endpoint 0x08 is requested.  Here is the Simple Descriptor Response for 0x09 of the router:

    You need to be capable of interpreting your own sniffer logs.  Are you using Wireshark 3.0.X?  Consider contacting Wireshark support to resolve your issues.

    Regards,
    Ryan

  • Thank you!

    So my guess is in the coordinator the cluster is added correctly because there is only one endpoint but with the latest cluster added. But in the router, there are 2 endpoints, I think the endpoint of the occupancy is well registered but it should have shown the endpoint 8 too, right?

    So at this point the next step is being able to report the occupancy data, right? I should see how can I send ATTRID_OCCUPANCY_SENSING_* attributes and how to get them in the coordinator?

    I am using Wireshark 3.0.14. I started with this issue a few months ago and you suggested me to install 3.0.X version. I think I also contacted Wireshark and they couldn't help. I'll try to configure again everything from Wireshark.

    Thank you.

  • Simple Descriptor Requests are made per endpoint.  You were asking for the Occupancy endpoint which I provided.  There was a Simple Descriptor Request for the 0x08 endpoint as well which I didn't provide.  If your router Occupancy Sensor server (Input Cluster List for Type 2 clusters) has the attribute set to ACCESS_REPORTABLE, initializes the functionality with Zstackapi_bdbRepAddAttrCfgRecordDefaultToListReq, and has BDB Finding and Binding enabled during commissioning then reporting should occur automatically.  You can refer to the Temperature Sensor examples for a demonstration.  You could also attempt manual binding as discussed in the aforementioned Zigbee Fundamentals SLA.

    Regards,
    Ryan

  • Ah, all right. I think that attribute is set to ACCESS_REPORTABLE, I am trying the next suggestion but this error appears:

    "ATTRID_OCCUPANCY_SENSING_OCCUPANCY" is undefined. I tried to imitate the temperature sensor project but I don't know what I have to define in predefined symbols (if that is the problem).

    #ifdef BDB_REPORTING
      //Adds the default configuration values for the temperature attribute of the ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT cluster, for endpoint SAMPLETEMPERATURESENSOR_ENDPOINT
      //Default maxReportingInterval value is 10 seconds
      //Default minReportingInterval value is 3 seconds
      //Default reportChange value is 300 (3 degrees)
      Req.attrID = ATTRID_OCCUPANCY_SENSING_OCCUPANCY;
      Req.cluster = ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING;
      Req.endpoint = SAMPLEOCCUPANCY_ENDPOINT;
      Req.maxReportInt = 10;
      Req.minReportInt = 3;
      OsalPort_memcpy(Req.reportableChange,reportableChange,BDBREPORTING_MAX_ANALOG_ATTR_SIZE);
    
      Zstackapi_bdbRepAddAttrCfgRecordDefaultToListReq(appServiceTaskId,&Req);
    #endif

    Thank you.

  • You probably need to #include "zcl_ms.h" in your zcl_sample*.c since that's where ATTRID_OCCUPANCY_SENSING_OCCUPANCY is defined.

    Regards,
    Ryan

  • Yes, I had to clean project in order to be able to run the program.

    I sniffed the connection between my zc_sw, zr_sw (connected to the occupancy sensor via I2C) and a bulb. Could you give me some information about the log just one more time? There are some moments where I touched the sensor so it could give an "occupied", I don't know if that is reflected on the log.

    Thank you.

    2207.zip

  • Your ZR is Reporting Sensed Occupancy Attributes to which the ZC is responding with Success to an Unknown Cluster Command.  You should make sure that your ZC application has BDB_REPORTING and ZCL_REPORT_DESTINATION_DEVICE defined.

    Regards,
    Ryan

  • ZCL_REPORT_DESTINATION_DEVICE was not defined so I did. Now both attributes are defined. At this moment the router should send the attribute so I don't know if the application can't detect if occupied or not. Thank you.16082022.zip

  • Behavior does not appear to have changed in the sniffer log.  You should be able to receive the report inside zclSample*_ProcessInReportCmd.

    Regards,
    Ryan