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

Method SetConfigParam

cpp/src/Node.cpp:2204–2264  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Set a configuration parameter in a device -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2202// Set a configuration parameter in a device
2203//-----------------------------------------------------------------------------
2204bool Node::SetConfigParam
2205(
2206 uint8 const _param,
2207 int32 _value,
2208 uint8 const _size
2209)
2210{
2211 if( Configuration* cc = static_cast<Configuration*>( GetCommandClass( Configuration::StaticGetCommandClassId() ) ) )
2212 {
2213 // First try to find an existing value representing the parameter, and set that.
2214 if( Value* value = cc->GetValue( 1, _param ) )
2215 {
2216 switch( value->GetID().GetType() )
2217 {
2218 case ValueID::ValueType_Bool:
2219 {
2220 ValueBool* valueBool = static_cast<ValueBool*>( value );
2221 valueBool->Set( _value != 0 );
2222 break;
2223 }
2224 case ValueID::ValueType_Byte:
2225 {
2226 ValueByte* valueByte = static_cast<ValueByte*>( value );
2227 valueByte->Set( (uint8)_value );
2228 break;
2229 }
2230 case ValueID::ValueType_Short:
2231 {
2232 ValueShort* valueShort = static_cast<ValueShort*>( value );
2233 valueShort->Set( (uint16)_value );
2234 break;
2235 }
2236 case ValueID::ValueType_Int:
2237 {
2238 ValueInt* valueInt = static_cast<ValueInt*>( value );
2239 valueInt->Set( _value );
2240 break;
2241 }
2242 case ValueID::ValueType_List:
2243 {
2244 ValueList* valueList = static_cast<ValueList*>( value );
2245 valueList->SetByValue( _value );
2246 break;
2247 }
2248 default:
2249 {
2250 }
2251 }
2252
2253 return true;
2254 }
2255
2256 // Failed to find an existing value object representing this
2257 // configuration parameter, so we try using the default or
2258 // included size through the Configuration command class.
2259 cc->Set( _param, _value, _size );
2260 return true;
2261 }

Callers

nothing calls this directly

Calls 3

SetByValueMethod · 0.80
GetValueMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected