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

Method HandleSetLearnModeRequest

cpp/src/Driver.cpp:3568–3633  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Process a request from the Z-Wave PC interface -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

3566// Process a request from the Z-Wave PC interface
3567//-----------------------------------------------------------------------------
3568void Driver::HandleSetLearnModeRequest
3569(
3570 uint8* _data
3571)
3572{
3573 uint8 nodeId = GetNodeNumber( m_currentMsg );
3574 if( m_currentControllerCommand == NULL )
3575 {
3576 return;
3577 }
3578 ControllerState state = m_currentControllerCommand->m_controllerState;
3579 Log::Write( LogLevel_Info, nodeId, "FUNC_ID_ZW_SET_LEARN_MODE:" );
3580
3581 switch( _data[3] )
3582 {
3583 case LEARN_MODE_STARTED:
3584 {
3585 Log::Write( LogLevel_Info, nodeId, "LEARN_MODE_STARTED" );
3586 state = ControllerState_Waiting;
3587 break;
3588 }
3589 case LEARN_MODE_DONE:
3590 {
3591 Log::Write( LogLevel_Info, nodeId, "LEARN_MODE_DONE" );
3592 state = ControllerState_Completed;
3593
3594 // Stop learn mode
3595 Msg* msg = new Msg( "End Learn Mode", 0xff, REQUEST, FUNC_ID_ZW_SET_LEARN_MODE, false, false );
3596 msg->Append( 0 );
3597 SendMsg( msg, MsgQueue_Command );
3598
3599 // Rebuild all the node info. Group and scene data that we stored
3600 // during replication will be applied as we discover each node.
3601 InitAllNodes();
3602 break;
3603 }
3604 case LEARN_MODE_FAILED:
3605 {
3606 Log::Write( LogLevel_Warning, nodeId, "WARNING: LEARN_MODE_FAILED" );
3607 state = ControllerState_Failed;
3608
3609 // Stop learn mode
3610 Msg* msg = new Msg( "End Learn Mode", 0xff, REQUEST, FUNC_ID_ZW_SET_LEARN_MODE, false, false );
3611 msg->Append( 0 );
3612 SendMsg( msg, MsgQueue_Command );
3613
3614 // Rebuild all the node info, since it may have been partially
3615 // updated by the failed command. Group and scene data that we
3616 // stored during replication will be applied as we discover each node.
3617 InitAllNodes();
3618 break;
3619 }
3620 case LEARN_MODE_DELETED:
3621 {
3622 Log::Write( LogLevel_Info, nodeId, "LEARN_MODE_DELETED" );
3623 state = ControllerState_Failed;
3624 // Stop learn mode
3625 Msg* msg = new Msg( "End Learn Mode", 0xff, REQUEST, FUNC_ID_ZW_SET_LEARN_MODE, false, false );

Callers

nothing calls this directly

Calls 2

WriteFunction · 0.85
AppendMethod · 0.45

Tested by

no test coverage detected