MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / SetMapping

Method SetMapping

cpp/src/command_classes/Basic.cpp:258–309  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Map COMMAND_CLASS_BASIC messages to another command class -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

256// Map COMMAND_CLASS_BASIC messages to another command class
257//-----------------------------------------------------------------------------
258bool Basic::SetMapping
259(
260 uint8 const _commandClassId,
261 bool const _doLog
262)
263{
264 bool res = false;
265
266 if( _commandClassId != NoOperation::StaticGetCommandClassId() )
267 {
268 if( _doLog )
269 {
270 char str[16];
271 snprintf( str, sizeof(str), "0x%02x", _commandClassId );
272 string ccstr = str;
273 if( Node const* node = GetNodeUnsafe() )
274 {
275 if( CommandClass* cc = node->GetCommandClass( _commandClassId ) )
276 {
277 ccstr = cc->GetCommandClassName();
278 }
279 }
280 if( m_com.GetFlagBool(COMPAT_FLAG_BASIC_IGNOREREMAPPING) )
281 {
282 Log::Write( LogLevel_Info, GetNodeId(), " COMMAND_CLASS_BASIC will not be mapped to %s (ignored)", ccstr.c_str() );
283 }
284 else
285 {
286 Log::Write( LogLevel_Info, GetNodeId(), " COMMAND_CLASS_BASIC will be mapped to %s", ccstr.c_str() );
287 }
288 }
289 m_com.SetFlagByte(COMPAT_FLAG_BASIC_MAPPING, _commandClassId);
290 RemoveValue( 1, 0 );
291 res = true;
292 }
293
294 if( m_com.GetFlagByte(COMPAT_FLAG_BASIC_MAPPING) == 0 )
295 {
296 if (_doLog )
297 Log::Write( LogLevel_Info, GetNodeId(), " COMMAND_CLASS_BASIC is not mapped" );
298 if( Node* node = GetNodeUnsafe() )
299 {
300 if (m_instances.size() > 0) {
301 for (unsigned int i = 0; i < m_instances.size(); i++)
302 node->CreateValueByte( ValueID::ValueGenre_Basic, GetCommandClassId(), m_instances[i], 0, "Basic", "", false, false, 0, 0 );
303 } else {
304 node->CreateValueByte( ValueID::ValueGenre_Basic, GetCommandClassId(), 0, 0, "Basic", "", false, false, 0, 0 );
305 }
306 }
307 }
308 return res;
309}

Callers 1

SetDeviceClassesMethod · 0.80

Calls 11

WriteFunction · 0.85
GetCommandClassIdFunction · 0.85
GetCommandClassMethod · 0.80
GetFlagBoolMethod · 0.80
SetFlagByteMethod · 0.80
GetFlagByteMethod · 0.80
CreateValueByteMethod · 0.80
GetNodeIdFunction · 0.70
GetCommandClassNameMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected