/*---------------------------------------------------------------------------*/ int sendRadioMessage(int serialPort, uint8_t* buf, int len) { int rc; int timeoutCounter; uint8_t rxBuff[32]; write(serialPort,buf,len); readRawBytes(serialPort,dataBuffer,1,20000); if(dataBuffer[0] != 0xAA) { printf("[sendRadioMessage]: ACK error!\n"); return -1; } timeoutCounter = 0; while(isSending(serialPort) && (timeoutCounter < TIMEOUT)) { timeoutCounter++; } if(!(timeoutCounter < TIMEOUT)) { // printf("[sendRadioMessage]: Timeout err!\n"); return -1; } if(getTransmissionResult(serialPort) == 0) { timeoutCounter = 0; while((getRxFifoCount(serialPort) == 0) && (timeoutCounter < TIMEOUT)) { timeoutCounter++; } if(!(timeoutCounter < TIMEOUT)) { // printf("[sendRadioMessage]: Timeout err!\n"); return -1; } pullDataFromFifo(serialPort,32,rxBuff); return 0; } else { // printf("[sendRadioMessage]: Missing message?\n"); return -1; } }
void STTweetViewNetwork::sendTweet(const QString &text, STAccount *account, STObjectManager::StatusRef inReplyTo){ Q_ASSERT(!isSending()); KQOAuthParameters param; param.insert("status", text); if(inReplyTo) param.insert("in_reply_to_status_id", QString::number(inReplyTo->id)); QUrl url("https://api.twitter.com/1.1/statuses/update.json"); m_request=new KQOAuthRequest(this); m_request->initRequest(KQOAuthRequest::AuthorizedRequest, url); m_request->setAdditionalParameters(param); m_request->setHttpMethod(KQOAuthRequest::POST); m_request->setConsumerKey(account->consumerKey()); m_request->setConsumerSecretKey(account->consumerSecret()); m_request->setToken(account->accessToken()); m_request->setTokenSecret(account->accessTokenSecret()); m_manager->executeRequest(m_request); Q_ASSERT(isSending()); }
void send_rf(uint8_t * value) // Sends a data package to the default address. Be sure to send the correct // amount of bytes as configured as payload on the receiver. { uint8_t status; status = getStatus(); while (PTX) { status = getStatus(); if((status & ((1 << TX_DS) | (1 << MAX_RT)))){ PTX = 0; break; } } // Wait until last paket is send ceLow(); powerUpTx(); // Set to transmitter mode , Power up csnLow(); uint8_t result = FLUSH_TX; SSPSend(&result, 1); csnHi(); uint8_t* rx = (uint8_t*)malloc(sizeof(uint8_t)*(payload+1)); rx[0] = W_TX_PAYLOAD; uint8_t a; for(a = 1; a < payload+1; a++){ rx[a] = value[a-1]; } csnLow(); SSPSend(rx, payload+1); free(rx); csnHi(); ceHi(); // Start transmission while(isSending()); }
void STTweetViewNetwork::endRequest(const QByteArray &res, int code){ m_request->deleteLater(); m_request=NULL; QVariant var=STJsonParser().parse(res); Q_ASSERT(!isSending()); if(var.isNull()){ if(code){ qWarning()<<"STTweetViewNetwork::endRequest: code="<<code; emit tweetErrorSending(STNetworkReplyErrorParser::parseError(code)); return; } qWarning()<<"STTweetViewNetwork::endRequest: returned object is null or unparsable."; emit tweetErrorSending(tr("Invalid response")); return; } if(!var.canConvert(QVariant::Map)){ qWarning()<<"STTweetViewNetwork::endRequest: returned object is not a dictionary."; emit tweetErrorSending(tr("Invalid response")); return; } if(STObjectManager::sharedManager()->status(var, false)){ emit tweetSent(); return; } QVariantMap map=var.toMap(); if(map.contains("errors")){ QVariantList lst=map["errors"].toList(); if(!lst.isEmpty()){ map=lst[0].toMap(); if(map.contains("message")){ qWarning()<<"STTweetViewNetwork::endRequest: errors[0].message = "<<map["message"]; if(map.contains("code")){ qWarning()<<"STTweetViewNetwork::endRequest: errors[0].code = "<<map["code"]; int code=map["code"].toInt(); if(code==170){ // tweet empty emit tweetErrorSending(tr("Tweet is empty.")); return; }else if(code==187){ // duplicate emit tweetErrorSending(tr("Tweet is a duplicate.")); return; }else if(code==88){ // rate limit emit tweetErrorSending(tr("Rate limit exceeded.")); return; }else if(code==135){ // unauthorized emit tweetErrorSending(tr("Login failed.")); return; } } emit tweetErrorSending(map["message"].toString()); return; } } } qWarning()<<"STTweetViewNetwork::endRequest: unknown error: "<<var; emit tweetErrorSending(tr("Invalid response")); return; }