I have observed that the eCLD_LevelControlSetLevel(…) implementation provided in build 1840 of the JN-SW-4170 JN516x ZigBee 3.0 SDK incorrectly calculates the psCommon->sTransition.iStepSize.
This issue may be trivially observed when the "JN-SW-4170/Components/ZCL/Clusters/General/Source/LevelControl.c" sources are compiled with the DEBUG_CLD_LEVEL_CONTROL pre-processor definition specified. An example of the resultant output is provided below:
--------
LC: Set Level=1 Time=3 Level=1 Time=3 Step*100=8433
LC: Updating EP:1 Target=100 Cur=25400 Step=8433 Time=3 OnOff=1
LC: Updating EP:1 Target=100 Cur=25400 Step=8433 Time=2 OnOff=1
LC: Updating EP:1 Target=100 Cur=25400 Step=8433 Time=1 OnOff=1
LC: Updating EP:1 Target=100 Cur=25400 Step=8433 Time=0 OnOff=1
--------
where it can be seen that the "Target" level is 100, the "Cur"rent level is 25400, and the "Step" is 8433, where the step value is subsequently added to the current value within the eCLD_LevelControlUpdate(…) function:
--------
PUBLIC teZCL_Status eCLD_LevelControlUpdate(uint8 u8SourceEndPointId)
{
…
psCommon->sTransition.iCurrentLevel += psCommon->sTransition.iStepSize;
…
}
--------
The attached "JN-SW-4170 eCLD_LevelControlSetLevel().patch" addresses this issue by modifying the calculation of the psCommon->sTransition.iStepSize value so that the current value moves towards the target value when the step value is added iteratively.