----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------
| 188 | // Handle a message from the Z-Wave network |
| 189 | //----------------------------------------------------------------------------- |
| 190 | bool SwitchMultilevel::HandleMsg |
| 191 | ( |
| 192 | uint8 const* _data, |
| 193 | uint32 const _length, |
| 194 | uint32 const _instance // = 1 |
| 195 | ) |
| 196 | { |
| 197 | if( SwitchMultilevelCmd_Report == (SwitchMultilevelCmd)_data[0] ) |
| 198 | { |
| 199 | Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchMultiLevel report: level=%d", _data[1] ); |
| 200 | |
| 201 | if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, SwitchMultilevelIndex_Level ) ) ) |
| 202 | { |
| 203 | value->OnValueRefreshed( _data[1] ); |
| 204 | value->Release(); |
| 205 | } |
| 206 | |
| 207 | if( GetVersion() >= 4) { |
| 208 | |
| 209 | // data[2] => target value |
| 210 | if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, SwitchMultilevelIndex_TargetValue ) ) ) |
| 211 | { |
| 212 | value->OnValueRefreshed( _data[2]); |
| 213 | value->Release(); |
| 214 | } |
| 215 | |
| 216 | // data[3] might be duration |
| 217 | if(_length > 3) { |
| 218 | if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, SwitchMultilevelIndex_Duration ) ) ) |
| 219 | { |
| 220 | value->OnValueRefreshed( _data[3] ); |
| 221 | value->Release(); |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | return true; |
| 227 | } |
| 228 | |
| 229 | if( SwitchMultilevelCmd_SupportedReport == (SwitchMultilevelCmd)_data[0] ) |
| 230 | { |
| 231 | uint8 switchType1 = _data[1] & 0x1f; |
| 232 | uint8 switchType2 = _data[2] & 0x1f; |
| 233 | uint8 switchtype1label = switchType1; |
| 234 | uint8 switchtype2label = switchType2; |
| 235 | if (switchtype1label > 7) /* size of c_switchLabelsPos, c_switchLabelsNeg */ |
| 236 | { |
| 237 | Log::Write (LogLevel_Warning, GetNodeId(), "switchtype1label Value was greater than range. Setting to Invalid"); |
| 238 | switchtype1label = 0; |
| 239 | } |
| 240 | if (switchtype2label > 7) /* sizeof c_switchLabelsPos, c_switchLabelsNeg */ |
| 241 | { |
| 242 | Log::Write (LogLevel_Warning, GetNodeId(), "switchtype2label Value was greater than range. Setting to Invalid"); |
| 243 | switchtype2label = 0; |
| 244 | } |
| 245 | |
| 246 | |
| 247 | Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchMultiLevel supported report: Switch1=%s/%s, Switch2=%s/%s", c_switchLabelsPos[switchtype1label], c_switchLabelsNeg[switchtype1label], c_switchLabelsPos[switchtype2label], c_switchLabelsNeg[switchtype2label] ); |
nothing calls this directly
no test coverage detected