Sharing Cluster Instances Across Endpoints

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sharing Cluster Instances Across Endpoints

650 Views
davidlythge
Contributor I

What is the best way to share various cluster instances across multiple endpoints?

Im working on a device with three endpoints, to save work and make better use of ram I want to share the instances of Basic, Identify, Power Configuration and Commissioning across the three endpoints.

JN-UG-3115 r1.2 (D.1) Describes two solutions to implement the Basic cluster across multiple endpoints:
      A) A single cluster instance on a dedicated ‘physical device’ endpoint
      B) A separate cluster instance on each ‘logical device’ endpoint, but each
            cluster instance must use the same tsZCL_ClusterInstance structure
            (and the same attribute values)

(A) sounds like what Im trying to achieve, but dont want an additional endpoint containing Basic, Identify, Power Configuration and Commissioning - unless there's an existing and corresponding application device id I can use.

(B) sounds like what I have at present, each endpoint having its own instance of Basic.

Any information would be greatly appreciated.

1 Reply

525 Views
davidlythge
Contributor I


In zcl_options.h:

/* Create a shared device - a container for clusters shared between multiple
* endpoints, including basic, identify, power configuration, commissioning etc.
*/
#define SHARED_CLUSTERS
#define BASIC_SHARED
#define POWER_CONFIGURATION_SHARED
#define COMMISSIONING_SHARED

In your application, dont forget if you need to reset the cluster using 'memset' like
in various NXP examples, dont forget to set/preserve the devices pointer to the shared cluster instance...

memset(&sDevices.sTemperatureDevice,0,sizeof(tsHA_TemperatureSensorDevice));
#if (defined SHARED_CLUSTERS) && (defined POWER_CONFIGURATION_SHARED )
sDevices.sTemperatureDevice.psPowerConfigServerCluster = &sShared.sPowerConfigServerCluster;
#endif

Apart from the small gotcha above, it works really well.

Using shared clusters are an option, reduce overall flash size and memory size, and saves work because
now you don't need to populate identical clusters on other endpoints. Everything else works as normal.

If you don't want to use shared clusters just remove the define statements from zcl_options mentioned
above and it will work as originally intended by NXP.

I've included a .zip containing a directory structure for JN-SW-4170/Components. It includes the
small Shared.h file and modified NXP temperature_sensor.h/.c files as examples.

Components\ZCL\Clusters\General\Include\Shared.h
Components\ZCL\Devices\ZHA\HVAC\Include\temperature_sensor.h
Components\ZCL\Devices\ZHA\HVAC\Source\temperature_sensor.c

Hope it helps!