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

Method HandleMsg

cpp/src/command_classes/SoundSwitch.cpp:134–239  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

132// Handle a message from the Z-Wave network
133//-----------------------------------------------------------------------------
134bool SoundSwitch::HandleMsg
135(
136 uint8 const* _data,
137 uint32 const _length,
138 uint32 const _instance // = 1
139)
140{
141 if (SoundSwitchCmd_Tones_Number_Report == (SoundSwitchCmd)_data[0])
142 {
143 m_toneCount = _data[1];
144 Log::Write( LogLevel_Info, GetNodeId(), "Received SoundSwitch Tone Count report: %d", m_toneCount);
145 if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, SoundSwitchIndex_Tone_Count ) ) )
146 {
147 value->OnValueRefreshed( m_toneCount );
148 value->Release();
149 }
150 for (int i = 1; i <= m_toneCount; i++) {
151 Msg* msg = new Msg( "SoundSwitchCmd_Tones_Info_Get", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
152 msg->SetInstance( this, _instance );
153 msg->Append( GetNodeId() );
154 msg->Append( 3 );
155 msg->Append( GetCommandClassId() );
156 msg->Append( SoundSwitchCmd_Tones_Info_Get );
157 msg->Append( i );
158 msg->Append( GetDriver()->GetTransmitOptions() );
159 GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
160 }
161 return true;
162 }
163 if (SoundSwitchCmd_Tones_Info_Report == (SoundSwitchCmd)_data[0])
164 {
165 uint8 index = _data[1];
166 uint16 duration = (_data[2] << 8) + _data[3];
167 string name((const char *)&_data[5], _data[4]);
168 m_toneInfo[index].duration = duration;
169 m_toneInfo[index].name = name;
170 Log::Write( LogLevel_Info, GetNodeId(), "Received SoundSwitch Tone Info Report: %d - %s - %d sec", index, name.c_str(), duration);
171 if (index == m_toneCount) {
172 vector<ValueList::Item> items;
173 {
174 ValueList::Item item;
175 item.m_label = "Inactive";
176 item.m_value = 0;
177 items.push_back( item );
178 }
179 for( unsigned int i=1; i <= m_toneCount; i++)
180 {
181 ValueList::Item item;
182 char str[32];
183 snprintf( str, sizeof(str), "%s (%d sec)", m_toneInfo[i].name.c_str(), m_toneInfo[i].duration );
184 item.m_label = str;
185 item.m_value = i;
186 items.push_back( item );
187 }
188 {
189 ValueList::Item item;
190 item.m_label = "Default Tone";
191 item.m_value = 0xff;

Callers

nothing calls this directly

Calls 10

WriteFunction · 0.85
GetCommandClassIdFunction · 0.85
SendMsgMethod · 0.80
CreateValueListMethod · 0.80
GetNodeIdFunction · 0.70
OnValueRefreshedMethod · 0.45
ReleaseMethod · 0.45
SetInstanceMethod · 0.45
AppendMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected