bool ESPSerialWiFiManager::_connect(String ssid, String pass){
    _disconnect();
    if(_temp_config.advanced){
        WiFi.config(_temp_config.ip,
                    _temp_config.gateway,
                    _temp_config.subnet,
                    _temp_config.dns1,
                    _temp_config.dns2);
    }
    else{
        WiFi.config(0U, 0U, 0U); //Clear out manual config
    }
    if(pass.length() > 0)
        WiFi.begin(ssid.c_str(), pass.c_str());
    else
        WiFi.begin(ssid.c_str());
    if(_wait_for_wifi(true)){
        _save_config(ssid, pass, pass.length() > 0,
                    _temp_config.advanced,
                    _temp_config.ip,
                    _temp_config.gateway,
                    _temp_config.subnet,
                    _temp_config.dns1,
                    _temp_config.dns2);
        return true;
    }
    else{
        return false;
    }
}
예제 #2
0
bool XbeeLink::hardwareConnect()
{
	emit tryConnectBegin(true);
	if(this->isConnected())
	{
		_disconnect();
	}
	if (*this->m_portName == '\0')
	{
		return false;
	}
	if (xbee_setupAPI(this->m_portName,this->m_baudRate,0x2B,0x3E8) == -1) 
		{
		  /* oh no... it failed */
			qDebug() <<"xbee_setup() failed...\n";
			emit tryConnectEnd(true);
			return false;
		}
	this->m_xbeeCon = xbee_newcon('A',xbee2_data,0x13A200,0x403D0935);
	emit tryConnectEnd(true);
	this->m_connected = true;
	emit connected();
	emit connected(true);
	return true;
}
예제 #3
0
void CIMExportClient::disconnect()
{
    PEG_METHOD_ENTER (TRC_EXPORT_CLIENT, "CIMExportClient::disconnect()");
    _disconnect();
    _authenticator.clear();
    _connectSSLContext.reset();
    PEG_METHOD_EXIT();
}
예제 #4
0
XbeeLink::~XbeeLink()
{
	if(m_portName)
	{
		delete m_portName;
		m_portName = NULL;
	}
	_disconnect();
}
예제 #5
0
void RealmConnection::_complete(const asio::error_code& e, std::size_t bytes_transferred, PacketPtr packet_ptr)
{
	UT_DEBUGMSG(("RealmConnection::_complete()\n"));
	if (e)
	{
		UT_DEBUGMSG(("Error reading message: %s\n", e.message().c_str()));
		_disconnect();		
		return;
	}	
	m_buf.commit(bytes_transferred);
	_complete_packet(packet_ptr);
}
예제 #6
0
파일: loader.cpp 프로젝트: yychao/chat
bool Loader::IsActivedUser(const QString& userName, const QString& password)
{
    pTcpSocket = new QTcpSocket(this);
    QObject::connect(pTcpSocket, SIGNAL(readyRead()), this, SLOT(_readMessage()));
    QObject::connect(pTcpSocket, SIGNAL(disconnected()), this, SLOT(_disconnect()));



    pTcpSocket->connectToHost(ipAddress, 4305);
    
    return true;
}
예제 #7
0
static int _freeConn(iFuseConn_t *iFuseConn) {
    assert(iFuseConn != NULL);

    iFuseRodsClientLog(LOG_DEBUG, "_freeConn: disconnecting - %lu", iFuseConn->connId);

    // disconnect first
    _disconnect(iFuseConn);

    pthread_mutex_destroy(&iFuseConn->lock);
    pthread_mutexattr_destroy(&iFuseConn->lockAttr);

    free(iFuseConn);
    return 0;
}
bool ESPSerialWiFiManager::_connect_manual(){
    OFL("Manual WiFi Config:");
    String ssid = _prompt(F("Enter SSID (Case Sensitive)"));
    String opt = _prompt(F("Encrypted Network? y/n"));
    String pass = "";
    if(CHAROPT(opt[0],'y')){
        pass = _prompt("Password", '*');
    }

    _get_advanced();

    _disconnect();
    return _connect(ssid, pass);
}
예제 #9
0
void ConnectionsDock::_connect_pressed() {

	TreeItem *item = tree->get_selected();
	if (!item) {
		connect_button->set_disabled(true);
		return;
	}

	if (_is_item_signal(*item)) {
		_open_connection_dialog(*item);
	} else {
		_disconnect(*item);
		update_tree();
	}
}
예제 #10
0
int
free_menu(MENU *m)
{
	if (!m) {
		return (E_BAD_ARGUMENT);
	}
	if (Posted(m)) {
		return (E_POSTED);
	}
	if (Items(m)) {
		_disconnect(m);
	}
	free(m);
	return (E_OK);
}
예제 #11
0
/*
Post-ConnectDialog callback for creating/editing connections.
Creates or edits connections based on state of the ConnectDialog when "Connect" is pressed.
*/
void ConnectionsDock::_make_or_edit_connection() {

	TreeItem *it = tree->get_selected();
	ERR_FAIL_COND(!it);

	NodePath dst_path = connect_dialog->get_dst_path();
	Node *target = selectedNode->get_node(dst_path);
	ERR_FAIL_COND(!target);

	Connection cToMake;
	cToMake.source = connect_dialog->get_source();
	cToMake.target = target;
	cToMake.signal = connect_dialog->get_signal_name();
	cToMake.method = connect_dialog->get_dst_method_name();
	cToMake.binds = connect_dialog->get_binds();
	bool defer = connect_dialog->get_deferred();
	bool oshot = connect_dialog->get_oneshot();
	cToMake.flags = CONNECT_PERSIST | (defer ? CONNECT_DEFERRED : 0) | (oshot ? CONNECT_ONESHOT : 0);

	//conditions to add function, must have a script and must have a method
	bool add_script_function = !target->get_script().is_null() && !ClassDB::has_method(target->get_class(), cToMake.method);
	PoolStringArray script_function_args;
	if (add_script_function) {
		// pick up args here before "it" is deleted by update_tree
		script_function_args = it->get_metadata(0).operator Dictionary()["args"];
		for (int i = 0; i < cToMake.binds.size(); i++) {
			script_function_args.append("extra_arg_" + itos(i));
		}
	}

	if (connect_dialog->is_editing()) {
		_disconnect(*it);
		_connect(cToMake);
	} else {
		_connect(cToMake);
	}

	// IMPORTANT NOTE: _disconnect and _connect cause an update_tree,
	// which will delete the object "it" is pointing to
	it = NULL;

	if (add_script_function) {
		editor->emit_signal("script_add_function_request", target, cToMake.method, script_function_args);
		hide();
	}

	update_tree();
}
예제 #12
0
/*
 * Reconnect
 */
int iFuseConnReconnect(iFuseConn_t *iFuseConn) {
    int status = 0;
    assert(iFuseConn != NULL);

    pthread_mutex_lock(&iFuseConn->lock);

    iFuseRodsClientLog(LOG_DEBUG, "iFuseConnReconnect: disconnecting - %lu", iFuseConn->connId);
    _disconnect(iFuseConn);

    iFuseRodsClientLog(LOG_DEBUG, "iFuseConnReconnect: connecting - %lu", iFuseConn->connId);
    status = _connect(iFuseConn);

    pthread_mutex_unlock(&iFuseConn->lock);

    return status;
}
예제 #13
0
bool XbeeLink::setBaudRate(int rate)
{
	bool reconnect(false);
	if(this->m_connected)
	{
		_disconnect();
		reconnect = true;
	}
	bool retVal(true);
	this->m_baudRate = rate;
	if(reconnect)
	{
		retVal = _connect();
	}
	return retVal;
}
예제 #14
0
void RealmConnection::_message(const asio::error_code& e, std::size_t /*bytes_transferred*/, boost::shared_ptr<std::string> msg_ptr)
{
	UT_DEBUGMSG(("RealmConnection::_message()\n"));
	if (e)
	{
		UT_DEBUGMSG(("Error reading message: %s\n", e.message().c_str()));
		_disconnect();		
		return;
	}	
	UT_DEBUGMSG(("Constructing packet of type: 0x%x\n", (*msg_ptr)[0]));
	PacketPtr packet_ptr = realm::protocolv1::Packet::construct(static_cast<rpv1::packet_type>((*msg_ptr)[0]));
	if (!packet_ptr) {
		UT_DEBUGMSG(("Error constructing packet for type 0x%x\n", (*msg_ptr)[0]));
		return;
	}
	_complete_packet(packet_ptr);
}
예제 #15
0
void XbeeLink::writeBytes(const char *bytes, qint64 length)  // TO DO: delete the data array
{
	char *data;
	data = new char[length];
	for(long i=0;i<length;i++)
	{
		data[i] = bytes[i];
	}
	if(!xbee_nsenddata(this->m_xbeeCon,data,length)) // return value of 0 is successful written
	{
		_logOutputDataRate(length, QDateTime::currentMSecsSinceEpoch());
	}
	else
	{
		_disconnect();
		emit communicationError(tr("Link Error"), QString("Error on link: %1. Could not send data - link is disconnected!").arg(getName()));
	}
}
예제 #16
0
void XbeeLink::writeBytes(const char *bytes, qint64 length)  // TO DO: delete the data array
{
	char *data;
	data = new char[length];
	for(long i=0;i<length;i++)
	{
		data[i] = bytes[i];
	}
	if(!xbee_nsenddata(this->m_xbeeCon,data,length)) // return value of 0 is successful written
	{
        // Log the amount and time written out for future data rate calculations.
        QMutexLocker dataRateLocker(&dataRateMutex);
        logDataRateToBuffer(outDataWriteAmounts, outDataWriteTimes, &outDataIndex, length, QDateTime::currentMSecsSinceEpoch());
	}
	else
	{
		_disconnect();
		emit communicationError(this->getName(), tr("Could not send data - link %1 is disconnected!").arg(this->getName()));
	}
}
bool ESPSerialWiFiManager::_connect_wps(){
    _disconnect();
    OFL("Push the WPS button on your access point now.");
    String opt = _prompt("Press Enter when complete (q to abort)");
    if(CHAROPT(opt[0], 'q')) return false;
    OFL("Attempting WPS connection. May take some time...");
    if(WiFi.beginWPSConfig()){
        String ssid = WiFi.SSID();
        if(ssid.length() > 0){
            OL("\nSuccess! Connected to network " + ssid);
            NL();
            _disp_network_details();
            NL();
            _save_config(ssid, WiFi.psk(), true);
            return true;
        }
        else{
            return false;
        }
    }
}
예제 #18
0
void ConnectionsDock::_handle_slot_menu_option(int option) {

	TreeItem *item = tree->get_selected();

	if (!item)
		return;

	switch (option) {
		case EDIT: {
			Connection c = item->get_metadata(0);
			_open_connection_dialog(c);
		} break;
		case GO_TO_SCRIPT: {
			_go_to_script(*item);
		} break;
		case DISCONNECT: {
			_disconnect(*item);
			update_tree();
		} break;
	}
}
예제 #19
0
bool XbeeLink::setPortName(QString portName)
{
	bool reconnect(false);
	if(this->m_connected)
	{
		_disconnect();
		reconnect = true;
	}
	if(m_portName)
	{
		delete m_portName;
		m_portName = NULL;
	}
	QStringList list = portName.split(QRegExp("\\s+"),QString::SkipEmptyParts);
	if(list.size()>0)
	{
		this->m_portNameLength = list[0].size()+1;
		m_portName = new char[this->m_portNameLength];
		for(int i=0;i<list[0].size();i++)
		{
			this->m_portName[i]=list[0][i].toLatin1();
		}
		this->m_portName[list[0].size()] = '\0';
	}
	else
	{
		this->m_portNameLength = 1;
		m_portName = new char[this->m_portNameLength];
		this->m_portName[0] = '\0';
	}
	
	bool retVal(true);
	if(reconnect)
	{
		retVal = _connect();
	}

	return retVal;
}
bool ESPSerialWiFiManager::_connect_from_config(){
    _disconnect();
    if(_network_config.advanced){
        WiFi.config(_network_config.ip,
                    _network_config.gateway,
                    _network_config.subnet,
                    _network_config.dns1,
                    _network_config.dns2);
    }
    else{
        WiFi.config(0U, 0U, 0U); //Clear out manual config
    }
    if(_network_config.encrypted){
        WiFi.begin(_network_config.ssid, _network_config.password);
    }
    else{
        WiFi.begin(_network_config.ssid);
    }

    bool res = _wait_for_wifi(true);
    if(res) _disp_network_details();
    return res;
}
예제 #21
0
TransferFunctionEditor::TransferFunctionEditor( livre::Controller& controller, QWidget* tfParentWidget )
    : QWidget( tfParentWidget )
    , _controller( controller )
    , ui( new Ui::TransferFunctionEditor )
    , _isConnected( false )
    , _redWidget( new ColorMapWidget( ColorMapWidget::RED_SHADE, this ))
    , _greenWidget( new ColorMapWidget( ColorMapWidget::GREEN_SHADE, this ))
    , _blueWidget( new ColorMapWidget( ColorMapWidget::BLUE_SHADE, this ))
    , _alphaWidget( new ColorMapWidget( ColorMapWidget::ARGB_SHADE, this ))
    , _gradientRenderer( new GradientRenderer( this ))
{
    ui->setupUi( this );

    // Add the widgets to the layouts to match the exact positions on the TransferFunctionEditor.
    ui->redLayout->addWidget( _redWidget );
    ui->greenLayout->addWidget( _greenWidget );
    ui->blueLayout->addWidget( _blueWidget );
    ui->rgbaLayout->addWidget( _alphaWidget );
    ui->rgbGradientLayout->addWidget( _gradientRenderer );

    connect( _redWidget, SIGNAL( colorsChanged()),
            this, SLOT( _pointsUpdated()));
    connect( _greenWidget, SIGNAL( colorsChanged()),
            this, SLOT( _pointsUpdated()));
    connect( _blueWidget, SIGNAL( colorsChanged()),
            this, SLOT( _pointsUpdated()));
    connect( _alphaWidget, SIGNAL( colorsChanged()),
            this, SLOT( _pointsUpdated()));

    connect( ui->resetButton, SIGNAL( clicked()), this, SLOT( _setDefault()));
    connect( ui->clearButton, SIGNAL( clicked()), this, SLOT( _clear()));
    connect( ui->btnConnect, SIGNAL( pressed()), this, SLOT( _connect( )));
    connect( ui->btnDisconnect, SIGNAL( pressed()), this, SLOT( _disconnect()));

    QTimer::singleShot( 50, this, SLOT( _setDefault()));
}
예제 #22
0
	Joystick::Joystick()
	{
		_disconnect();
	}
예제 #23
0
	void WebSocket::_async_read( usr_ptr u, char* request, const boost::system::error_code& error, size_t bytes_transferred )
	{
		if( !error )
		{
			if( u->handshaken )
			{ // bitch has handshaken. Lets process him :)
				size_t start = 0;
				size_t offset = 0;
				
				while( offset < bytes_transferred )
				offset += u->ftype->unpackFrame( (unsigned char*)(request + offset), bytes_transferred - offset );
				if( u->ftype->disconnect( ) )
				{
					log( "Request from client " + itoa( u->uid ) + " to disconnect" );
					
					_disconnect( u );
					delete[ ] request;
					
					return;
				}
				else
				{
					std::string response;
					std::string req = u->ftype->data( );
					
					size_t b;
					switch( _processable->process( req, response ) )
					{
					case RESPOND:
						unsigned char* frame;
						b = u->ftype->packFrame( response, frame, false );
						_async_send( u, std::string( (char*)frame, b ) );
						delete[ ] frame;
					
						break;
					case BROADCAST:
						_async_broadcast( response );
						break;
					default:
						break;
					}
				}
				
				// std::cout << "Frames in request: " << framecount << std::endl;
			}
			else
			{// lets shake hands, mr client
				log( "Handshaking with client " + itoa( u->uid ) );
				_handshake( u, std::string( request, bytes_transferred ) );
			}
		
			// request = new char[ _maxBytes ];
			u->sock->async_receive( boost::asio::buffer( request, _maxBytes ), boost::bind( &WebSocket::_async_read, this, u, request, _1, _2 ) );
		}
		else if( error == boost::asio::error::eof )
		{
			delete[ ] request;
			
			log( "Client " + itoa( u->uid ) + " closed the connection (eof)." );
			// u->sock->close( );
			_disconnect( u );
		}
		else
		{
			delete[ ] request;
			log( "Error: " + error.message( ) );
		}
	}
예제 #24
0
int c_winsock::_connect(const char * ipaddr, int16 port, bool asyn)
{
	int result = 0;
	struct hostent *hp;  
	unsigned int addr;  
	memset( &m_addr, 0, sizeof( sockaddr));

	m_addrip = ipaddr;
	m_port = port;
	m_asyn = asyn;
	if ( m_sock != NULL )
	{
		_disconnect();
		return -1;
		//_disconnect();
	}
	
	/*WSADATA  wsadata = {0};
	result = WSAStartup(MAKEWORD(2,2), &wsadata);
	*/
	m_sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP);
	if( m_sock == INVALID_SOCKET)
	{
		m_sock = NULL;
		return -1;
	}

	//决定服务器地址  
	if(inet_addr(ipaddr)==INADDR_NONE)  
	{  
		hp=gethostbyname(ipaddr);  
		if (hp == NULL)
		{
			create_thead();
			closesocket(m_sock);
			m_sock = NULL;
			return -1;
		}
		m_addr.sin_addr.s_addr =  *((unsigned long*)hp->h_addr); 
	}  
	else  
	{  
		addr = inet_addr(ipaddr);  
		m_addr.sin_addr.s_addr = addr;
		//hp=gethostbyaddr((char*)&addr,sizeof(addr),AF_INET);  
	}  
	

	m_addr.sin_family = AF_INET;
	m_addr.sin_port = htons(port);
	//m_addr.sin_addr.s_addr =  *((unsigned long*)hp->h_addr);  

	/////////////////////////////////////////////////////////////////

	//1.设置非阻塞模式
	if (asyn)
	{
		unsigned long ulFlag = 1;
		if ( ioctlsocket(m_sock, FIONBIO, &ulFlag) != 0 )  
		{ 
			closesocket(m_sock); 
			m_sock = NULL;
			return -1; 
		} 
	}

	//2.连接服务器
	result = connect(m_sock, ( SOCKADDR*)&m_addr, sizeof(m_addr));
	if (result == SOCKET_ERROR)
	{
		if (!asyn)
		{
			result = WSAGetLastError();
			closesocket(m_sock); 
			m_sock = NULL;
			return -1;
		}

	}

	FD_ZERO(&m_fdset);
	FD_SET( m_sock, &m_fdset );
	m_dwtick = GetTickCount();

	if (create_thead() != 0)
	{
		m_sock = NULL;
		return -1; 
	}

	//3.等待连接
	//if (!asyn)  //同步
	//{
	//	if ( !WaitForSingleObject(m_henvet, INFINITE) )
	//	{
	//		closesocket(m_sock); 
	//		m_sock = NULL;
	//		close_thead();
	//		return -1;
	//	}
	//
	//}
	
	return 0;
}
예제 #25
0
Message* CIMExportClient::_doRequest(
    CIMRequestMessage* pRequest,
    MessageType expectedResponseMessageType)
{
    PEG_METHOD_ENTER (TRC_EXPORT_CLIENT, "CIMExportClient::_doRequest()");

    AutoPtr<CIMRequestMessage> request(pRequest);

    if (!_connected && !_doReconnect)
    {
        PEG_METHOD_EXIT();
        throw NotConnectedException();
    }

    if (_doReconnect)
    {
        try
        {
            _connect();
            _doReconnect = false;
        }
        catch (const Exception& e)
        {
            PEG_TRACE((TRC_EXPORT_CLIENT, Tracer::LEVEL1,
                "Failed to connect to indication listener: %s",
                (const char*)e.getMessage().getCString()));
            PEG_METHOD_EXIT();
            throw;
        }
        catch (...)
        {
            PEG_TRACE_CSTRING(TRC_EXPORT_CLIENT, Tracer::LEVEL1,
                "Failed to connect to indication listener.");
            PEG_METHOD_EXIT();
            throw;
        }
    }


    String messageId = XmlWriter::getNextMessageId();
    const_cast<String &>(request->messageId) = messageId;

    _authenticator.setRequestMessage(0);

    // ATTN-RK-P2-20020416: We should probably clear out the queue first.
    PEGASUS_ASSERT(getCount() == 0);  // Shouldn't be any messages in our queue

    //
    //  Set HTTP method in request to POST
    //
    request->setHttpMethod(HTTP_METHOD__POST);

    _requestEncoder->enqueue(request.release());

    Uint64 startMilliseconds = TimeValue::getCurrentTime().toMilliseconds();
    Uint64 nowMilliseconds = startMilliseconds;
    Uint64 stopMilliseconds = nowMilliseconds + _timeoutMilliseconds;

    while (nowMilliseconds < stopMilliseconds)
    {
        //
        // Wait until the timeout expires or an event occurs:
        //
        _monitor->run(Uint32(stopMilliseconds - nowMilliseconds));

        //
        // Check to see if incoming queue has a message
        //

        AutoPtr<Message> response(dequeue());

        if (response.get() != 0)
        {
            // Shouldn't be any more messages in our queue
            PEGASUS_ASSERT(getCount() == 0);

            //
            // Close the connection if response contained a "Connection: Close"
            // header (e.g. at authentication challenge)
            //
            if (response->getCloseConnect() == true)
            {
                _disconnect();
                _doReconnect = true;
                response->setCloseConnect(false);
            }

            //
            //  Future:  If M-POST is used and HTTP response is 501 Not
            //  Implemented or 510 Not Extended, retry with POST method
            //

            if (response->getType() == CLIENT_EXCEPTION_MESSAGE)
            {
                Exception* clientException =
                    ((ClientExceptionMessage*)response.get())->clientException;

                PEG_TRACE_CSTRING(TRC_EXPORT_CLIENT, Tracer::LEVEL2,
                    "Client Exception Message received.");

                AutoPtr<Exception> d(clientException);

                //
                // Determine and throw the specific class of client exception
                //

                CIMClientMalformedHTTPException* malformedHTTPException =
                    dynamic_cast<CIMClientMalformedHTTPException*>(
                    clientException);
                if (malformedHTTPException)
                {
                    PEG_METHOD_EXIT();
                    throw *malformedHTTPException;
                }

                CIMClientHTTPErrorException* httpErrorException =
                    dynamic_cast<CIMClientHTTPErrorException*>(
                    clientException);
                if (httpErrorException)
                {
                    PEG_METHOD_EXIT();
                    throw *httpErrorException;
                }

                CIMClientXmlException* xmlException =
                    dynamic_cast<CIMClientXmlException*>(clientException);
                if (xmlException)
                {
                    PEG_METHOD_EXIT();
                    throw *xmlException;
                }

                CIMClientResponseException* responseException =
                    dynamic_cast<CIMClientResponseException*>(clientException);
                if (responseException)
                {
                    PEG_METHOD_EXIT();
                    throw *responseException;
                }

                PEG_METHOD_EXIT();
                throw *clientException;
            }
            else if (response->getType() == expectedResponseMessageType)
            {
                PEG_TRACE_CSTRING(TRC_EXPORT_CLIENT, Tracer::LEVEL4,
                    "Received expected indication response message.");
                CIMResponseMessage* cimResponse =
                    (CIMResponseMessage*)response.get();
                if (cimResponse->messageId != messageId)
                {
                    MessageLoaderParms mlParms(
                        "ExportClient.CIMExportClient.MISMATCHED_RESPONSE_ID",
                        "Mismatched response message ID:  Got \"$0\", "
                            "expected \"$1\".",
                        cimResponse->messageId, messageId);
                    String mlString(MessageLoader::getMessage(mlParms));

                    CIMClientResponseException responseException(mlString);

                    PEG_METHOD_EXIT();
                    throw responseException;
                }
                if (cimResponse->cimException.getCode() != CIM_ERR_SUCCESS)
                {
                    PEG_TRACE_CSTRING(TRC_EXPORT_CLIENT, Tracer::LEVEL1,
                        "Received indication failure message.");
                    CIMException cimException(
                        cimResponse->cimException.getCode(),
                        cimResponse->cimException.getMessage());
                    PEG_METHOD_EXIT();
                    throw cimException;
                }
                PEG_METHOD_EXIT();
                return response.release();
            }
            else if (dynamic_cast<CIMRequestMessage*>(response.get()) != 0)
            {
                //
                // Respond to an authentication challenge.
                // Reconnect if the connection was closed.
                //
                if (_doReconnect)
                {
                    _connect();
                }

                _requestEncoder->enqueue(response.release());

                nowMilliseconds = TimeValue::getCurrentTime().toMilliseconds();
                stopMilliseconds = nowMilliseconds + _timeoutMilliseconds;
                continue;
            }
            else
            {
                MessageLoaderParms mlParms(
                    "ExportClient.CIMExportClient.MISMATCHED_RESPONSE",
                    "Mismatched response message type.");
                String mlString(MessageLoader::getMessage(mlParms));

                CIMClientResponseException responseException(mlString);

                PEG_TRACE((TRC_EXPORT_CLIENT, Tracer::LEVEL1,
                           (const char*)mlString.getCString()));

                PEG_METHOD_EXIT();
                throw responseException;
            }
        }

        nowMilliseconds = TimeValue::getCurrentTime().toMilliseconds();
    }

    //
    // Reconnect to reset the connection (disregard late response)
    //

    PEG_TRACE_CSTRING(TRC_EXPORT_CLIENT, Tracer::LEVEL2,
        "Connection to the listener timed out.");

    _disconnect();
    _authenticator.resetChallengeStatus();
    _doReconnect = true;

    //
    // Throw timed out exception:
    //
    PEG_METHOD_EXIT();
    throw ConnectionTimeoutException();
}
예제 #26
0
void CIMClientRep::_reconnect()
{
    _disconnect();
    _authenticator.setRequestMessage(0);
    _connect();
}
예제 #27
0
void CIMClientRep::disconnect()
{
    _disconnect();
    _authenticator.clear();
    _connectSSLContext.reset();
}
예제 #28
0
bool XbeeLink::_connect(void)
{
	if (this->isRunning()) _disconnect();
    this->start(LowPriority);
    return true;
}
void ESPSerialWiFiManager::run_menu(int timeout){
    bool first_run = true;
    static const uint8_t _main_menu_size = 7;
    static String _main_menu[_main_menu_size] = {
        F("Scan"),
        F("Enter SSID"),
        F("WPS Connect"),
        F("Disconnect"),
        F("Commit Config"),
        F("Display Network Details"),
        F("Quit")
        //"Disconnect"
    };

    static int i;
    NL();
    OFL("ESP Serial WiFi Manager");
    OFL("=======================");

    while(true){
        NL();
        OFL("================");
        OFL("MAIN MENU");
        OFL("================");
        i = _print_menu(_main_menu, _main_menu_size, first_run ? timeout : 0);
        if(i == -1) return; //timeout ocurred, exit
        first_run = false;
        switch(i){
            case 1:
                _scan_for_networks();
                break;
            case 2:
                if(_connect_manual())
                    _disp_network_details();
                break;
            case 3: //WPS Connect
                _connect_wps();
                break;
            case 4:
                if(WiFi.status() == WL_CONNECTED){
                    _disconnect();
                    OFL("Complete");
                    _reset_config();
                    _write_config();
                    OFL("Choose Commit Config to prevent reconnect on reboot.");
                }
                else{
                    OFL("Not currently connected...");
                }
                break;
            case 5:
                _commit_config();
                break;
            case 6:
                _disp_network_details();
                break;
            case 7:
                if(_dirty_config){
                    OFL("Your current config is unsaved.");
                    String opt = _prompt("Save Before Quit? y/n");
                    if(CHAROPT(opt[0], 'y')) _commit_config();
                }
                return;
        }
        delay(1);
    }
}
예제 #30
0
int VEditDLL::EDITDisconnect( void ) {
    if( _disconnect == NULL ) return( TRUE );
    return( _disconnect() );
}