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

Method HandleMsg

cpp/src/command_classes/Color.cpp:270–609  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

268// Handle a message from the Z-Wave network
269//-----------------------------------------------------------------------------
270bool Color::HandleMsg
271(
272 uint8 const* _data,
273 uint32 const _length,
274 uint32 const _instance // = 1
275)
276{
277 if (ColorCmd_Capability_Report == (ColorCmd)_data[0])
278 {
279 m_dom.SetFlagShort(STATE_FLAG_COLOR_CHANNELS, (_data[1] + (_data[2] << 8)));
280 uint16_t f_capabilities = m_dom.GetFlagShort(STATE_FLAG_COLOR_CHANNELS);
281 string helpstr = "#RRGGBB";
282 Log::Write(LogLevel_Info, GetNodeId(), "Received an Color Capability Report: Capability=%x", f_capabilities);
283 if (f_capabilities & 0x04)
284 Log::Write(LogLevel_Info, GetNodeId(), "Red (0x02)");
285 if (f_capabilities & 0x08)
286 Log::Write(LogLevel_Info, GetNodeId(), "Green (0x03)");
287 if (f_capabilities & 0x10)
288 Log::Write(LogLevel_Info, GetNodeId(), "Blue (0x04)");
289 if (f_capabilities & 0x01) {
290 Log::Write(LogLevel_Info, GetNodeId(), "Warm White (0x00)");
291 helpstr += "WW";
292 }
293 if (f_capabilities & 0x02) {
294 Log::Write(LogLevel_Info, GetNodeId(), "Cold White (0x01)");
295 helpstr += "CW";
296 }
297 if (f_capabilities & 0x20) {
298 Log::Write(LogLevel_Info, GetNodeId(), "Amber (0x05)");
299 helpstr += "AM";
300 }
301 if (f_capabilities & 0x40) {
302 Log::Write(LogLevel_Info, GetNodeId(), "Cyan (0x06)");
303 helpstr += "CY";
304 }
305 if (f_capabilities & 0x80) {
306 Log::Write(LogLevel_Info, GetNodeId(), "Purple (0x07)");
307 helpstr += "PR";
308 }
309 if (f_capabilities & 0x100)
310 Log::Write(LogLevel_Info, GetNodeId(), "Indexed Color (0x08)");
311 if( ValueInt* colorchannels = static_cast<ValueInt*>( GetValue( _instance, Value_Color_Channels_Capabilities ) ) )
312 {
313 colorchannels->OnValueRefreshed( f_capabilities );
314 colorchannels->Release();
315 }
316 if( Node* node = GetNodeUnsafe() )
317 {
318 if ( ValueString *color = static_cast<ValueString *>( GetValue( _instance, Value_Color ) ) )
319 {
320 color->SetUnits(helpstr);
321 }
322 else
323 {
324 node->CreateValueString( ValueID::ValueGenre_User, GetCommandClassId(), _instance, Value_Color, "Color", helpstr, false, false, "#000000", 0 );
325 }
326
327 /* always create the ColorIndex Value - If the device doesn't support Indexed Colors, we fake it up when sending */

Callers

nothing calls this directly

Calls 15

WriteFunction · 0.85
GetCommandClassIdFunction · 0.85
GetVersionFunction · 0.85
SetFlagShortMethod · 0.80
GetFlagShortMethod · 0.80
SetUnitsMethod · 0.80
CreateValueStringMethod · 0.80
CreateValueListMethod · 0.80
CreateValueByteMethod · 0.80
GetFlagBoolMethod · 0.80
clearMethod · 0.80
GetNodeIdFunction · 0.70

Tested by

no test coverage detected