----------------------------------------------------------------------------- Initialize the controller -----------------------------------------------------------------------------
| 586 | // Initialize the controller |
| 587 | //----------------------------------------------------------------------------- |
| 588 | bool Driver::Init |
| 589 | ( |
| 590 | uint32 _attempts |
| 591 | ) |
| 592 | { |
| 593 | m_initMutex->Lock(); |
| 594 | |
| 595 | if (m_exit) |
| 596 | { |
| 597 | m_initMutex->Unlock(); |
| 598 | return false; |
| 599 | } |
| 600 | |
| 601 | m_Controller_nodeId = -1; |
| 602 | m_waitingForAck = false; |
| 603 | |
| 604 | // Open the controller |
| 605 | Log::Write( LogLevel_Info, " Opening controller %s", m_controllerPath.c_str() ); |
| 606 | |
| 607 | if( !m_controller->Open( m_controllerPath ) ) |
| 608 | { |
| 609 | Log::Write( LogLevel_Warning, "WARNING: Failed to init the controller (attempt %d)", _attempts ); |
| 610 | m_initMutex->Unlock(); |
| 611 | return false; |
| 612 | } |
| 613 | |
| 614 | // Controller opened successfully, so we need to start all the worker threads |
| 615 | m_pollThread->Start( Driver::PollThreadEntryPoint, this ); |
| 616 | |
| 617 | // Send a NAK to the ZWave device |
| 618 | uint8 nak = NAK; |
| 619 | m_controller->Write( &nak, 1 ); |
| 620 | |
| 621 | // Get/set ZWave controller information in its preferred initialization order |
| 622 | m_controller->PlayInitSequence( this ); |
| 623 | |
| 624 | //If we ever want promiscuous mode uncomment this code. |
| 625 | //Msg* msg = new Msg( "FUNC_ID_ZW_SET_PROMISCUOUS_MODE", 0xff, REQUEST, FUNC_ID_ZW_SET_PROMISCUOUS_MODE, false, false ); |
| 626 | //msg->Append( 0xff ); |
| 627 | //SendMsg( msg ); |
| 628 | |
| 629 | m_initMutex->Unlock(); |
| 630 | |
| 631 | // Init successful |
| 632 | return true; |
| 633 | } |
| 634 | |
| 635 | //----------------------------------------------------------------------------- |
| 636 | // <Driver::RemoveQueues> |
no test coverage detected