inline u8 getChar(void) { _bfs.start(_id); _bfs.putChar(Protocol::INST_READ); _bfs.putChar(_cursor); _bfs.putChar(1); _bfs.end(); u8 buff[7]; if(readTimeout(buff, 7) != 7) { return 0; } move(1); return buff[5]; }
bool NT3HReadUserData(uint8_t page) { uint8_t reg = USER_START_REG+page; // if the requested page is out of the register exit with error if (reg > USER_END_REG) { errNo = NT3HERROR_INVALID_USER_MEMORY_PAGE; return false; } bool ret = readTimeout(reg, nfcPageBuffer); if (ret == false) { errNo = NT3HERROR_READ_USER_MEMORY_PAGE; } return ret; }
inline u16 write(u8* data, u16 length) { _bfs.start(_id); _bfs.putChar(Protocol::INST_WRITE); _bfs.putChar(_cursor); for(u16 i = 0 ; i < length ; i++) { _bfs.putChar(data[i]); } _bfs.end(); u8 buff[6]; if(readTimeout(buff, 6) != 6) { return 0; } move(length); return length; }
void NetworkReply::finished() { // qDebug() << "Finished" << networkReply->url(); QUrl redirection = networkReply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); if (redirection.isValid()) { // qDebug() << "Redirect!"; // << redirection; QNetworkReply *redirectReply = The::http()->simpleGet(redirection, networkReply->operation()); setParent(redirectReply); networkReply->deleteLater(); networkReply = redirectReply; // when the request is finished we'll invoke the target method connect(networkReply, SIGNAL(finished()), this, SLOT(finished()), Qt::UniqueConnection); // monitor downloadProgress to impl timeout connect(networkReply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(downloadProgress(qint64,qint64)), Qt::UniqueConnection); readTimeoutTimer->start(); // error signal connect(networkReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(requestError(QNetworkReply::NetworkError)), Qt::UniqueConnection); connect(readTimeoutTimer, SIGNAL(timeout()), SLOT(readTimeout()), Qt::UniqueConnection); readTimeoutTimer->start(); return; } emit data(networkReply->readAll()); emit finished(networkReply); #ifndef QT_NO_DEBUG_OUTPUT if (!networkReply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool()) { qDebug() << networkReply->url().toEncoded(); } #endif // bye bye my reply // this will also delete this NetworkReply as the QNetworkReply is its parent networkReply->deleteLater(); }
HttpConnectionHandler::HttpConnectionHandler(QSettings* settings, HttpRequestHandler* requestHandler) : QThread() { Q_ASSERT(settings!=0); Q_ASSERT(requestHandler!=0); this->settings=settings; this->requestHandler=requestHandler; currentRequest=0; busy = false; // execute signals in my own thread moveToThread(this); socket.moveToThread(this); readTimer.moveToThread(this); connect(&socket, SIGNAL(readyRead()), SLOT(read())); connect(&socket, SIGNAL(disconnected()), SLOT(disconnected())); connect(&readTimer, SIGNAL(timeout()), SLOT(readTimeout())); readTimer.setSingleShot(true); qDebug("HttpConnectionHandler (%p): constructed", this); this->start(); }
inline u16 read(u8* data, u16 length) { _bfs.start(_id); _bfs.putChar(Protocol::INST_READ); _bfs.putChar(_cursor); _bfs.putChar(length); _bfs.end(); u8 buff[BUFFER_SIZE]; u16 msg_len = length + 6; if(readTimeout(buff, msg_len) != msg_len) { return 0; } for(u16 i = 0 ; i < length ; i++) { data[i] = buff[i+5]; } move(length); return length; }
bool getSessionReg(void) { return readTimeout(SESSION_REG, nfcPageBuffer); }
bool NT3HReadConfiguration(configS *configuration){ return readTimeout(CONFIG_REG, configuration); }
bool NT3HReaddManufactoringData(manufS *manuf) { return readTimeout(MANUFACTORING_DATA_REG, manuf); }
void WiFlyDevice::flushRx(int timeout) { char ch; while (readTimeout(&ch,timeout)); }
int readTIMEOUT(int fd,PVStr(b),int z) { alertVStr(b,z); return readTimeout(fd,BVStr(b),z,IO_TIMEOUT); }