----------------------------------------------------------------------------- Set a value in the Z-Wave device -----------------------------------------------------------------------------
| 243 | // Set a value in the Z-Wave device |
| 244 | //----------------------------------------------------------------------------- |
| 245 | bool SoundSwitch::SetValue |
| 246 | ( |
| 247 | Value const& _value |
| 248 | ) |
| 249 | { |
| 250 | bool ret = false; |
| 251 | uint8 instance = _value.GetID().GetInstance(); |
| 252 | uint16 index = _value.GetID().GetIndex(); |
| 253 | if (index == SoundSwitchIndex_Tones) { |
| 254 | if (ValueList const* value = static_cast<ValueList const*>(&_value)) { |
| 255 | ValueList::Item const *item = value->GetItem(); |
| 256 | if (item == NULL) |
| 257 | return false; |
| 258 | Msg* msg = new Msg( "SoundSwitchCmd_Tones_Play_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); |
| 259 | msg->SetInstance( this, instance ); |
| 260 | msg->Append( GetNodeId() ); |
| 261 | msg->Append( 3 ); |
| 262 | msg->Append( GetCommandClassId() ); |
| 263 | msg->Append( SoundSwitchCmd_Tones_Play_Set ); |
| 264 | msg->Append( item->m_value ); |
| 265 | msg->Append( GetDriver()->GetTransmitOptions() ); |
| 266 | GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); |
| 267 | } |
| 268 | ret = true; |
| 269 | } |
| 270 | if (index == SoundSwitchIndex_Volume || index == SoundSwitchIndex_Default_Tone) { |
| 271 | uint8 volume = 0xff; |
| 272 | uint8 defaulttone = 0x01; |
| 273 | if( ValueByte const* value = static_cast<ValueByte const*>( GetValue( instance, SoundSwitchIndex_Volume ) ) ) |
| 274 | { |
| 275 | volume = value->GetValue(); |
| 276 | } |
| 277 | if (ValueList const* value = static_cast<ValueList const*>( GetValue( instance, SoundSwitchIndex_Default_Tone ) ) ) |
| 278 | { |
| 279 | ValueList::Item const *item = value->GetItem(); |
| 280 | if (item == NULL) |
| 281 | return false; |
| 282 | defaulttone = item->m_value; |
| 283 | /* 0 means dont update the Default Tone 0xFF is the Default tone! */ |
| 284 | if (defaulttone == 0xFF) |
| 285 | defaulttone = 1; |
| 286 | } |
| 287 | Msg* msg = new Msg( "SoundSwitchCmd_Tones_Config_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); |
| 288 | msg->SetInstance( this, instance ); |
| 289 | msg->Append( GetNodeId() ); |
| 290 | msg->Append( 4 ); |
| 291 | msg->Append( GetCommandClassId() ); |
| 292 | msg->Append( SoundSwitchCmd_Tones_Config_Set ); |
| 293 | msg->Append( volume ); |
| 294 | msg->Append( defaulttone ); |
| 295 | msg->Append( GetDriver()->GetTransmitOptions() ); |
| 296 | GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); |
| 297 | ret = true; |
| 298 | } |
| 299 | |
| 300 | return ret; |
| 301 | } |
| 302 |
nothing calls this directly
no test coverage detected