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

Method HandleMsg

cpp/src/command_classes/Battery.cpp:102–129  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

100// Handle a message from the Z-Wave network
101//-----------------------------------------------------------------------------
102bool Battery::HandleMsg
103(
104 uint8 const* _data,
105 uint32 const _length,
106 uint32 const _instance // = 1
107)
108{
109 if (BatteryCmd_Report == (BatteryCmd)_data[0])
110 {
111 // We have received a battery level report from the Z-Wave device.
112 // Devices send 0xff instead of zero for a low battery warning.
113 uint8 batteryLevel = _data[1];
114 if( batteryLevel == 0xff )
115 {
116 batteryLevel = 0;
117 }
118
119 Log::Write( LogLevel_Info, GetNodeId(), "Received Battery report from node %d: level=%d", GetNodeId(), batteryLevel );
120
121 if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, 0 ) ) )
122 {
123 value->OnValueRefreshed( batteryLevel );
124 value->Release();
125 }
126 return true;
127 }
128 return false;
129}
130
131//-----------------------------------------------------------------------------
132// <Battery::CreateVars>

Callers

nothing calls this directly

Calls 4

WriteFunction · 0.85
GetNodeIdFunction · 0.70
OnValueRefreshedMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected