Functions
The following Level Control cluster functions are provided in the NXP implementation of the ZCL:
eCLD_LevelControlCreateLevelControl
teZCL_Status eCLD_LevelControlCreateLevelControl(
tsZCL_ClusterInstance *psClusterInstance,
bool_t bIsServer,
tsZCL_ClusterDefinition *psClusterDefinition,
void *pvEndPointSharedStructPtr,
uint8 *pu8AttributeControlBits,
tsCLD_LevelControlCustomDataStructure
*psCustomDataStructure);
Description
This function creates an instance of the Level Control cluster on an endpoint. The cluster instance is created on the endpoint which is associated with the supplied tsZCL_ClusterInstance structure and can act as a server or a client, as specified.
Call the function when setting up a custom endpoint containing one or more selected clusters (rather than the whole set of clusters supported by a standard ZigBee device). This function creates a Level Control cluster instance on the endpoint, but instances of other clusters may also be created on the same endpoint by calling their corresponding creation functions.
Note: This function must not be called for an endpoint on which a standard ZigBee device is used. In this case, the device and its supported clusters must be registered on the endpoint using the relevant device registration function.
When used, this function must be the first Level Control cluster function called in the application, and must be called after the stack has been started and after the ZCL has been initialized.
The function requires an array to be declared for internal use, which contains one element (of type uint8) for each attribute of the cluster. The array length should therefore equate to the total number of attributes supported by the Level Control cluster. The function initializes the array elements to zero.
Parameters
psClusterInstance: Pointer to structure containing information about the cluster instance to be created (see Section 6.1.16). This structure is updated by the function by initializing individual structure fields.
bIsServer Type of cluster instance (server or client) to be created:
TRUE - server
FALSE - client
psClusterDefinition: Pointer to structure indicating the type of cluster to be created (see Section 6.1.2). In this case, this structure must contain the details of the Level Control cluster. This parameter can refer to a pre-filled structure called
sCLD_LevelControlwhich is provided in the LevelControl.h file.pvEndPointSharedStructPtr: Pointer to the shared structure used for attribute storage. This parameter should be the address of the structure of type
tsCLD_LevelControl, which defines the attributes of Level Control cluster. The function initializes the attributes with default values.pu8AttributeControlBits: Pointer to an array of uint8 values, with one element for each attribute in the cluster (see above)
psCustomDataStructure: Pointer to a structure containing the storage for internal functions of the cluster (see Section 16.8.2)
Returns
E_ZCL_SUCCESS
E_ZCL_ERR_PARAMETER_NULL
Parent topic:Functions
eCLD_LevelControlSetLevel
teZCL_Status eCLD_LevelControlSetLevel(
uint8 u8SourceEndPointId,
uint8 u8Level,
uint16 u16TransitionTime);
Description
This function sets the level on the device on the specified (local) endpoint by writing the specified value to the ‘current level’ attribute. The new level is implemented over the specified transition time by gradually changing the level.
The specified target level must be within the range 0x01 to 0xFE or a more restricted range imposed by the device manufacturer and/or user/installer (see Section 16.6.1).
This operation is performed with the On/Off cluster (if enabled), in which case:
If the operation is to increase the current level, the OnOff attribute of the On/Off cluster is set to ‘on’.
If the operation is to decrease the current level to the minimum permissible level for the device, the OnOff attribute of the On/Off cluster is set to ‘off’.
Parameters
u8SourceEndPointId: Number of the local endpoint on which level is to be changed
u8Level: New level to be set, within the range 0x01 to 0xFE or within a more restricted range (see above)
u16TransitionTime: Time to be taken, in units of tenths of a second, to reach the target level (0xFFFF means move to the level as fast as possible)
Returns
E_ZCL_SUCCESS
E_ZCL_ERR_PARAMETER_NULL
E_ZCL_ERR_EP_RANGE
E_ZCL_ERR_EP_UNKNOWN
E_ZCL_ERR_CLUSTER_NOT_FOUND
E_ZCL_ERR_ZBUFFER_FAIL
E_ZCL_ERR_ZTRANSMIT_FAIL
If an error is returned by the ZigBee PRO stack function which is invoked by this function to transmit the data, this error may be obtained by calling eZCL_GetLastZpsError().
Parent topic:Functions
eCLD_LevelControlGetLevel
teZCL_Status eCLD_LevelControlGetLevel(
uint8 u8SourceEndPointId,
uint8 *pu8Level);
Description
This function obtains the current level on the device on the specified (local) endpoint by reading the ‘current level’ attribute.
Parameters
u8SourceEndPointId Number of the local endpoint from which the level is to be read
pu8Level Pointer to location to receive obtained level
Returns
E_ZCL_SUCCESS
E_ZCL_ERR_PARAMETER_NULL
E_ZCL_ERR_EP_RANGE
E_ZCL_ERR_EP_UNKNOWN
E_ZCL_ERR_CLUSTER_NOT_FOUND
E_ZCL_ERR_ZBUFFER_FAIL
E_ZCL_ERR_ZTRANSMIT_FAIL
If an error is returned by the ZigBee PRO stack function which is invoked by this function to transmit the data, this error may be obtained by calling eZCL_GetLastZpsError().
Parent topic:Functions
eCLD_LevelControlCommandMoveToLevelCommandSend
eCLD_LevelControlCommandMoveToLevelCommandSend
teZCL_Status eCLD_LevelControlCommandMoveToLevelCommandSend(
uint8 u8SourceEndPointId,
uint8 u8DestinationEndPointId,
tsZCL_Address *psDestinationAddress,
uint8 *pu8TransactionSequenceNumber,
bool_t bWithOnOff,
tsCLD_LevelControl_MoveToLevelCommandPayload
*psPayload);
Description
This function sends a Move to Level command to instruct a device to move its ‘current level’ attribute to the specified level over a specified time. The new level and the transition time are specified in the payload of the command (see Section 16.8.3). The target level must be within the range 0x01 to 0xFE or a more restricted range imposed by the device manufacturer and/or user/installer (see Section 16.5.1).
The device receiving this message generates a callback event on the endpoint on which the Level Control cluster is registered and transition the ‘current level’ attribute to the new value.
The option is provided to use this command in association with the On/Off cluster. In this case:
If the command is to increase the current level, the OnOff attribute of the On/Off cluster is set to ‘on’.
If the command is to decrease the current level to the minimum permissible level for the device, the OnOff attribute of the On/Off cluster is set to ‘off’.
You are required to provide a pointer to a location to receive a Transaction Sequence Number (TSN) for the request. The TSN in the response is set to match the TSN in the request, allowing an incoming response to be paired with a request. This is useful when sending more than one request to the same destination endpoint.
Parameters
u8SourceEndPointId: Number of the local endpoint through which to send the request. This parameter is used both to send the message and to identify the instance of the shared structure holding the required attribute values
u8DestinationEndPointId: Number of the endpoint on the remote node to which the request is sent. This parameter is ignored when sending to address types eZCL_AMBOUND and eZCL_AMGROUP
psDestinationAddress: Pointer to a structure holding the address of the node to which the request is sent
pu8TransactionSequenceNumber: Pointer to a location to receive the Transaction Sequence Number (TSN) of the request
bWithOnOff: Specifies whether this cluster interacts with the On/Off cluster:
TRUE - interaction
FALSE - no interaction
psPayloadPointer to a structure containing the payload for this message (see Section 16.8.3)
Returns
E_ZCL_SUCCESS
E_ZCL_ERR_PARAMETER_NULL
E_ZCL_ERR_EP_RANGE
E_ZCL_ERR_EP_UNKNOWN
E_ZCL_ERR_CLUSTER_NOT_FOUND
E_ZCL_ERR_ZBUFFER_FAIL
E_ZCL_ERR_ZTRANSMIT_FAIL
If an error is returned by the ZigBee PRO stack function which is invoked by this function to transmit the data, this error may be obtained by calling eZCL_GetLastZpsError().
Parent topic:Functions
eCLD_LevelControlCommandMoveCommandSend
teZCL_Status eCLD_LevelControlCommandMoveCommandSend(
uint8 u8SourceEndPointId,
uint8 u8DestinationEndPointId,
tsZCL_Address *psDestinationAddress,
uint8 *pu8TransactionSequenceNumber,
bool_t bWithOnOff,
tsCLD_LevelControl_MoveCommandPayload
*psPayload);
Description
This function sends a Move command to instruct a device to move its ‘current level’ attribute either up or down in a continuous manner at a specified rate. The direction and rate are specified in the payload of the command (see Section 16.8.3).
If the current level reaches the maximum or minimum permissible level for the device, the level change stops.
The device receiving this message generates a callback event on the endpoint on which the Level Control cluster is registered, and move the current level in the direction and at the rate specified.
The option is provided to use this command in association with the On/Off cluster. In this case:
If the command is to increase the current level, the OnOff attribute of the On/Off cluster is set to ‘on’.
If the command decreases the current level to the minimum permissible level for the device, the OnOff attribute of the On/Off cluster is set to ‘off’.
You are required to provide a pointer to a location to receive a Transaction Sequence Number (TSN) for the request. The TSN in the response is set to match the TSN in the request, allowing an incoming response to be paired with a request. This is useful when sending more than one request to the same destination endpoint.
Parameters
u8SourceEndPointId: Number of the local endpoint through which to send the request. This parameter is used both to send the message and to identify the instance of the shared structure holding the required attribute values
u8DestinationEndPointId: Number of the endpoint on the remote node to which the request is sent. This parameter is ignored when sending to address types eZCL_AMBOUND and eZCL_AMGROUP
psDestinationAddress: Pointer to a structure holding the address of the node to which the request is sent
pu8TransactionSequenceNumber: Pointer to a location to receive the Transaction Sequence Number (TSN) of the request
bWithOnOff: Specifies whether this cluster interacts with the On/Off cluster:
TRUE - interaction
FALSE - no interaction
psPayload: Pointer to a structure containing the payload for this message (see Section 16.8.3)
Returns
E_ZCL_SUCCESS
E_ZCL_ERR_PARAMETER_NULL
E_ZCL_ERR_EP_RANGE
E_ZCL_ERR_EP_UNKNOWN
E_ZCL_ERR_CLUSTER_NOT_FOUND
E_ZCL_ERR_ZBUFFER_FAIL
E_ZCL_ERR_ZTRANSMIT_FAIL
If an error is returned by the ZigBee PRO stack function which is invoked by this function to transmit the data, this error may be obtained by calling eZCL_GetLastZpsError().
Parent topic:Functions
eCLD_LevelControlCommandStepCommandSend
teZCL_Status eCLD_LevelControlCommandStepCommandSend(
uint8 u8SourceEndPointId,
uint8 u8DestinationEndPointId,
tsZCL_Address *psDestinationAddress,
uint8 *pu8TransactionSequenceNumber,
bool_t bWithOnOff,
tsCLD_LevelControl_StepCommandPayload
*psPayload);
Description
This function sends a Step command to instruct a device to move its ‘current level’ attribute either up or down in a step of the specified step size over the specified time. The direction, step size and, transition time are specified in the payload of the command (see Section 16.8.3).
If the target level is above the maximum or below the minimum permissible level for the device, the stepped change is limited to this level, and the transition time is cut short.
The device receiving this message generates a callback event on the endpoint on which the Level Control cluster is registered and move the current level according to the specified direction, step size and transition time.
The option is provided to use this command in association with the On/Off cluster. In this case:
If the command is to increase the current level, the OnOff attribute of the On/Off cluster is set to ‘on’.
If the command decreases the current level to the minimum permissible level for the device, the OnOff attribute of the On/Off cluster is set to ‘off’.
You are required to provide a pointer to a location to receive a Transaction Sequence Number (TSN) for the request. The TSN in the response is set to match the TSN in the request, allowing an incoming response to be paired with a request. This is useful when sending more than one request to the same destination endpoint.
Parameters
u8SourceEndPointId: Number of the local endpoint through which to send the request. This parameter is used both to send the message and to identify the instance of the shared structure holding the required attribute values
u8DestinationEndPointId: Number of the endpoint on the remote node to which the request is sent. This parameter is ignored when sending to address types eZCL_AMBOUND and eZCL_AMGROUP
psDestinationAddress: Pointer to a structure holding the address of the node to which the request is sent
pu8TransactionSequenceNumber: Pointer to a location to receive the Transaction Sequence Number (TSN) of the request
bWithOnOff: Specifies whether this cluster interacts with the On/Off cluster:
TRUE - interaction
FALSE - no interaction
psPayload: Pointer to a structure containing the payload for this message (see Section 16.8.3)
Returns
E_ZCL_SUCCESS
E_ZCL_ERR_PARAMETER_NULL
E_ZCL_ERR_EP_RANGE
E_ZCL_ERR_EP_UNKNOWN
E_ZCL_ERR_CLUSTER_NOT_FOUND
E_ZCL_ERR_ZBUFFER_FAIL
E_ZCL_ERR_ZTRANSMIT_FAIL
If an error is returned by the ZigBee PRO stack function which is invoked by this function to transmit the data, this error may be obtained by calling eZCL_GetLastZpsError().
Parent topic:Functions
eCLD_LevelControlCommandStopCommandSend
teZCL_Status eCLD_LevelControlCommandStopCommandSend(
uint8 u8SourceEndPointId,
uint8 u8DestinationEndPointId,
tsZCL_Address *psDestinationAddress,
uint8 *pu8TransactionSequenceNumber,
bool_t bWithOnOff,
tsCLD_LevelControl_StopCommandPayload
*psPayload);*
Description
This function sends a Stop command to instruct a device to halt any transition to a new level. If necessary, the command can be sent as the ‘with On/Off’ version, used when the Level Control cluster interacts with the On/Off cluster, but the result on the target device is the same.
The device receiving this message generates a callback event on the endpoint on which the Level Control cluster is registered and stop any in progress transition.
You are required to provide a pointer to a location to receive a Transaction Sequence Number (TSN) for the request. The TSN in the response is set to match the TSN in the request, allowing an incoming response to be paired with a request. This is useful when sending more than one request to the same destination endpoint.
Parameters
u8SourceEndPointId Number of the local endpoint through which to send the request. This parameter is used both to send the message and to identify the instance of the shared structure holding the required attribute values
u8DestinationEndPointId Number of the endpoint on the remote node to which the request is sent. This parameter is ignored when sending to address types eZCL_AMBOUND and eZCL_AMGROUP
psDestinationAddress Pointer to a structure holding the address of the node to which the request is sent
pu8TransactionSequenceNumber Pointer to a location to receive the Transaction Sequence Number (TSN) of the request
bWithOnOff Specifies whether this cluster interacts with the On/Off cluster:
TRUE - interaction
FALSE - no interaction
psPayload Pointer to a structure containing the payload for this message (see Section 16.8.3.4)
Returns
E_ZCL_SUCCESS
E_ZCL_ERR_PARAMETER_NULL
E_ZCL_ERR_EP_RANGE
E_ZCL_ERR_EP_UNKNOWN
E_ZCL_ERR_CLUSTER_NOT_FOUND
E_ZCL_ERR_ZBUFFER_FAIL
E_ZCL_ERR_ZTRANSMIT_FAIL
If an error is returned by the ZigBee PRO stack function which is invoked by this function to transmit the data, this error may be obtained by calling eZCL_GetLastZpsError().
Parent topic:Functions
Parent topic:Level Control Cluster