----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------
| 126 | // Handle a message from the Z-Wave network |
| 127 | //----------------------------------------------------------------------------- |
| 128 | bool Version::HandleMsg |
| 129 | ( |
| 130 | uint8 const* _data, |
| 131 | uint32 const _length, |
| 132 | uint32 const _instance // = 1 |
| 133 | ) |
| 134 | { |
| 135 | if( Node* node = GetNodeUnsafe() ) |
| 136 | { |
| 137 | if( VersionCmd_Report == (VersionCmd)_data[0] ) |
| 138 | { |
| 139 | char library[8]; |
| 140 | char protocol[16]; |
| 141 | char application[16]; |
| 142 | |
| 143 | snprintf( library, sizeof(library), "%d", _data[1] ); |
| 144 | snprintf( protocol, sizeof(protocol), "%d.%.2d", _data[2], _data[3] ); |
| 145 | snprintf( application, sizeof(application), "%d.%.2d", _data[4], _data[5] ); |
| 146 | |
| 147 | Log::Write( LogLevel_Info, GetNodeId(), "Received Version report from node %d: Library=%s, Protocol=%s, Application=%s", GetNodeId(), library, protocol, application ); |
| 148 | ClearStaticRequest( StaticRequest_Values ); |
| 149 | |
| 150 | if( ValueString* libraryValue = static_cast<ValueString*>( GetValue( _instance, VersionIndex_Library ) ) ) |
| 151 | { |
| 152 | libraryValue->OnValueRefreshed( library ); |
| 153 | libraryValue->Release(); |
| 154 | } |
| 155 | if( ValueString* protocolValue = static_cast<ValueString*>( GetValue( _instance, VersionIndex_Protocol ) ) ) |
| 156 | { |
| 157 | protocolValue->OnValueRefreshed( protocol ); |
| 158 | protocolValue->Release(); |
| 159 | } |
| 160 | if( ValueString* applicationValue = static_cast<ValueString*>( GetValue( _instance, VersionIndex_Application ) ) ) |
| 161 | { |
| 162 | applicationValue->OnValueRefreshed( application ); |
| 163 | applicationValue->Release(); |
| 164 | } |
| 165 | |
| 166 | return true; |
| 167 | } |
| 168 | |
| 169 | if (VersionCmd_CommandClassReport == (VersionCmd)_data[0]) |
| 170 | { |
| 171 | if( CommandClass* pCommandClass = node->GetCommandClass( _data[1] ) ) |
| 172 | { |
| 173 | Log::Write( LogLevel_Info, GetNodeId(), "Received Command Class Version report from node %d: CommandClass=%s, Version=%d", GetNodeId(), pCommandClass->GetCommandClassName().c_str(), _data[2] ); |
| 174 | pCommandClass->ClearStaticRequest( StaticRequest_Version ); |
| 175 | pCommandClass->SetVersion( _data[2] ); |
| 176 | } |
| 177 | |
| 178 | return true; |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | return false; |
| 183 | } |
| 184 | |
| 185 | //----------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected