----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------
| 108 | // Handle a message from the Z-Wave network |
| 109 | //----------------------------------------------------------------------------- |
| 110 | bool SwitchBinary::HandleMsg |
| 111 | ( |
| 112 | uint8 const* _data, |
| 113 | uint32 const _length, |
| 114 | uint32 const _instance // = 1 |
| 115 | ) |
| 116 | { |
| 117 | if (SwitchBinaryCmd_Report == (SwitchBinaryCmd)_data[0]) |
| 118 | { |
| 119 | Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchBinary report from node %d: level=%s", GetNodeId(), _data[1] ? "On" : "Off" ); |
| 120 | |
| 121 | // data[1] => Switch state |
| 122 | if( ValueBool* value = static_cast<ValueBool*>( GetValue( _instance, SwitchBinaryIndex_Level ) ) ) |
| 123 | { |
| 124 | value->OnValueRefreshed( _data[1] != 0 ); |
| 125 | value->Release(); |
| 126 | } |
| 127 | |
| 128 | if ( GetVersion() >= 2) { |
| 129 | |
| 130 | // data[2] => target state |
| 131 | if( ValueBool* value = static_cast<ValueBool*>( GetValue( _instance, SwitchBinaryIndex_TargetState ) ) ) |
| 132 | { |
| 133 | value->OnValueRefreshed( _data[2] != 0 ); |
| 134 | value->Release(); |
| 135 | } |
| 136 | |
| 137 | // data[3] might be duration |
| 138 | if (_length > 3) { |
| 139 | if ( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, SwitchBinaryIndex_Duration ) ) ) |
| 140 | { |
| 141 | value->OnValueRefreshed( _data[3] ); |
| 142 | value->Release(); |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | return true; |
| 148 | } |
| 149 | |
| 150 | return false; |
| 151 | } |
| 152 | |
| 153 | //----------------------------------------------------------------------------- |
| 154 | // <SwitchBinary::SetValue> |
nothing calls this directly
no test coverage detected