bool MqttClient::connect(String clientName, String username, String password) { if (getConnectionState() != eTCS_Ready) { close(); debugf("MQTT closed previous connection"); } debugf("MQTT start connection"); mqtt_init(&broker, clientName.c_str()); if (clientName.length() > 0) mqtt_init_auth(&broker, username.c_str(), password.c_str()); if(server) { TcpClient::connect(server, port); } else { TcpClient::connect(serverIp, port); } mqtt_set_alive(&broker, keepAlive); broker.socket_info = (void*)this; broker.send = staticSendPacket; int res = mqtt_connect(&broker); setTimeOut(USHRT_MAX); return res > 0; }
///Constructor ConnectionLostTip::ConnectionLostTip(QWidget* parent) : Tip(i18n("There was a network error, trying to reconnect in 60 seconds."),parent),m_pTimer(nullptr),m_Counter(0), m_RenderCache(QSize(100,100),QImage::Format_ARGB32) { setTimeOut(60); loadSvg(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "ring-kde/tips/reload.svg")); connect(this,SIGNAL(visibilityChanged(bool)),this,SLOT(startAnimation(bool))); }
void HttpServerConnection::beginSendData() { if (!server->processRequest(*this, request, response)) { response.notFound(); sendError(); return; } if (!response.hasBody() && (response.getStatusCode() < 100 || response.getStatusCode() > 399)) { // Show default error message sendError(); return; } debugf("response sendHeader"); response.sendHeader(*this); if (request.isWebSocket()) { debugf("Switched to WebSocket Protocol"); state = eHCS_WebSocketFrames; // Stay opened setTimeOut(0xFFFF); } else state = eHCS_Sending; }
Sampler::Sampler( Sampler & input ) { setPortAddress( input.PortAddress() ); setNumPoints( input.NumPoints() ); setNumTriggerPoints( input.NumTriggerPoints() ); setTriggerLevel( input.TriggerLevel() ); setTimeOut( input.TimeOut() ); setSampleMethod( input.SampleMethod() ); setInterval( input.Interval() ); }
HttpServer::HttpServer() { defaultHandler = NULL; setTimeOut(90); // Default processing headers // Add more in you app! enableHeaderProcessing("Cookie"); enableHeaderProcessing("Host"); enableHeaderProcessing("Content-Type"); enableHeaderProcessing("Content-Length"); enableHeaderProcessing("Upgrade"); }
Sampler & Sampler::operator = ( Sampler & input ) { if( this == &input ) { setPortAddress( input.PortAddress() ); setNumPoints( input.NumPoints() ); setNumTriggerPoints( input.NumTriggerPoints() ); setTriggerLevel( input.TriggerLevel() ); setTimeOut( input.TimeOut() ); setSampleMethod( input.SampleMethod() ); setInterval( input.Interval() ); } return *this; }
/** * @brief ATcmd send AT common 发送AT指令通用函数 * @param cmd AT common string or null(send nothing) AT指令(字符串)或空(不发送任何东西) * @param timeOut_s time out 多少秒超时 * @param cmd_num The num of cmd which it exp 需要对比的命令(即"..."的参数个数) * @return 大于0时,表示收到和列表匹配的字符串 *cmd cmdLen *0 0 send nothing,wait exp 不发送任何东西,等待收到列表中的字符串 *!=0 0 send cmd string,wait exp 发送字符串,等待收到列表中的字符串 *!=0 !=0 send hex data,wait exp 发送十六进制数据,等待收到列表中的字符串 *0 !=0 send nothing,wait exp 不发送任何东西,等待收到列表中的字符串 */ s8 ATcmd(u8 *cmd,u8 cmdLen,u8 timeOut_s,u8 *pOut,u8 cmd_num,...) { static u8 sate=0; s8 ret=WAITING_EVENT; u8 i; va_list vap; u8 *pStr1; u8 *pStr2; if(sate!=0) goto wait; //send cmd if((cmd!=0)&&(cmdLen==0))IO_write_str((u8*)cmd); //if cmd is string then cmdlen can be set to zro else if((cmd!=0)&&(cmdLen!=0))IO_write(cmd,cmdLen); //this is use to send hex data //if timeOut_s is zro will return TIME_OUT if(timeOut_s==0) { ret=TIME_OUT; return ret; //@2015.6.18 时间设置为零时应该直接返回 } else setTimeOut(timeOut_s); sate=1; //set time out time //wait event wait: if((ATevent&EVENT_AT_FRAME)||(ATevent&EVENT_TIME_OUT)) { if(ATevent&EVENT_AT_FRAME) { ATevent&=~EVENT_AT_FRAME; //clear pending event va_start(vap , cmd_num); //set the last one parameter //get AT common string from buffer pStr1=GetATFrame(); for(i=0;i<cmd_num;i++) { pStr2=va_arg(vap , u8*); //get list's pointer ATAssert(pStr2!=0); if( StringCompare(pStr1,pStr2)) { if(pOut)StrCopy(pOut,pStr1);//if pOut not zro copy The string out break; //it is the same of list's string } } va_end(vap); //set vap to zro if(i==cmd_num) ret=UNEXPECT_CMD; //the string is unkown else ret=i+1; } else {
MusicPlayer::MusicPlayer(QObject *parent) : QObject(parent) { m_playlist = 0; m_music = 0; m_state = StoppedState; m_musicEnhanced = EnhancedOff; m_music = new SoundCore(this); m_posOnCircle = 0; m_volumeMusic3D = 0; setEnaleEffect(false); connect(&m_timer, SIGNAL(timeout()), SLOT(setTimeOut())); M_CONNECTION->setValue("MusicPlayer", this); }
bool ComPort::open(LPCTSTR port, DWORD baudRate, DWORD timeOut) { // Make sure that channel is closed if (m_hHandle != INVALID_HANDLE_VALUE) return false; // Open com port m_hHandle = CreateFile(port, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (m_hHandle == INVALID_HANDLE_VALUE) return false; // Communication buffers if (!SetupComm(m_hHandle, 1024, 1024)) { CloseHandle(m_hHandle); return false; } // Set up the serial communications device DCB dcb; ZeroMemory (&dcb, sizeof(DCB)); dcb.DCBlength = sizeof(DCB); dcb.BaudRate = baudRate; dcb.fBinary = 1; dcb.fDtrControl = DTR_CONTROL_DISABLE; dcb.fRtsControl = RTS_CONTROL_DISABLE; dcb.ByteSize = 8; dcb.Parity = EVENPARITY; dcb.StopBits = ONESTOPBIT; if (!::SetCommState(m_hHandle, &dcb)) { CloseHandle(m_hHandle); return false; } if (!setTimeOut(timeOut)) { CloseHandle(m_hHandle); return false; } return true; }
void StateMachine::update(int state, AnimationModuleInterface * _animation, int channel){ if(_prevChessState!=state){ GotoState(INTERACTIVE,true); _currentAnimation=(char *)GetNextAnimation().pszGetPointer(); _animation->PlayAnimation((char *)_currentAnimation.pszGetPointer() ,channel); } else { setTimeOut(getTimeOut() + 1); if (getState() == INTERACTIVE){ if (getTimeOut() > 300) GotoState(IDLE_LOOK_FRONT, true); } else if ((getState() == IDLE_LOOK_FRONT) || (getState() == IDLE_LOOK_LEFT) || (getState() == IDLE_LOOK_RIGHT)) if (getTimeOut() > 300) GotoState(SLEEPING_BY_NODDING, true); } _prevChessState=state; }
void CAlertUI::showEvent(QShowEvent * e) { Json::Value pObj; int itemCnt = 0; if (AppControl) { pObj = AppControl->getAlertJson(); setAlertText(0,""); setAlertText(1,""); setAlertText(2,""); setBtnText(0, "-", false); setBtnText(1, "-", false); setBtnText(2, "-", false); setBtnText(3, "-", false); if (pObj["params"].isMember("alertStrings")) { itemCnt = pObj["params"]["alertStrings"].size(); for(int i = 0; i < itemCnt; i++) { if (i < 3) { setAlertText(i, pObj["params"]["alertStrings"][i]["fieldText"].asString().c_str()); } else { break; } } } if (pObj["params"].isMember("softButtons")) { setTimeOut(pObj["params"]["duration"].asInt()+20000); itemCnt = pObj["params"]["softButtons"].size(); if(itemCnt == 2) { setBtnText(0,pObj["params"]["softButtons"][0]["text"].asString().c_str(),pObj["params"]["softButtons"][0]["isHighlighted"].asBool(), pObj["params"]["softButtons"][0]["softButtonID"].asInt()); setBtnText(3,pObj["params"]["softButtons"][1]["text"].asString().c_str(),pObj["params"]["softButtons"][1]["isHighlighted"].asBool(), pObj["params"]["softButtons"][1]["softButtonID"].asInt()); } else { for (int i = 0; i < itemCnt; i++) { if (i < 4) { setBtnText(i,pObj["params"]["softButtons"][i]["text"].asString().c_str(),pObj["params"]["softButtons"][i]["isHighlighted"].asBool(), pObj["params"]["softButtons"][i]["softButtonID"].asInt()); } else { break; } } } } else { setTimeOut(pObj["params"]["duration"].asInt()); } } updateLayout(); }
virtual err_t onConnected(err_t err) { //response(125, "Connected"); setTimeOut(300); // Update timeout return TcpConnection::onConnected(err); }
DeviceStatus sendLowLevelCommand(const char* cmd, int timeOut) { waitUntilReady(); setTimeOut(timeOut); formatLowLevelCommandString(cmd); return transmitToInstrument(); }
// Change the device address (unless it's not addressable) DeviceStatus sendCommand(const char* cmd) { waitUntilReady(); setTimeOut(); formatCommandString(cmd); return transmitToInstrument(); }