----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------
| 100 | // Handle a message from the Z-Wave network |
| 101 | //----------------------------------------------------------------------------- |
| 102 | bool 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> |
nothing calls this directly
no test coverage detected