/// @details /// The timing of this function is relatively coarse, because SPI transfers are /// used to enable / disable the transmitter. This will add some jitter to the /// signal, probably in the order of 10 µsec. /// /// If the result is true, then a packet has been received and is available for /// processing. The following global variables will be set: /// /// * volatile byte rf12_hdr - /// Contains the header byte of the received packet - with flag bits and /// node ID of either the sender or the receiver. /// * volatile byte rf12_len - /// The number of data bytes in the packet. A value in the range 0 .. 66. /// * volatile byte rf12_data - /// A pointer to the received data. /// * volatile byte rf12_crc - /// CRC of the received packet, zero indicates correct reception. If != 0 /// then rf12_hdr, rf12_len, and rf12_data should not be relied upon. /// /// To send an acknowledgement, call rf12_sendStart() - but only right after /// rf12_recvDone() returns true. This is commonly done using these macros: /// /// if(RF12_WANTS_ACK){ /// rf12_sendStart(RF12_ACK_REPLY,0,0); /// } /// @see http://jeelabs.org/2010/12/11/rf12-acknowledgements/ uint8_t rf12_recvDone () { if (rxstate == TXRECV && (rxfill >= rf12_len + 5 || rxfill >= RF_MAX)) { rxstate = TXIDLE; if (rf12_len > RF12_MAXDATA) rf12_crc = 1; // force bad crc if packet length is invalid if (!(rf12_hdr & RF12_HDR_DST) || (nodeid & NODE_ID) == 31 || (rf12_hdr & RF12_HDR_MASK) == (nodeid & NODE_ID)) { if (rf12_crc == 0 && crypter != 0) crypter(0); else rf12_seq = -1; return 1; // it's a broadcast packet or it's addressed to this node } } if (rxstate == TXIDLE) rf12_recvStart(); return 0; }
bool _encodeDecode(unsigned char *&pDataCripted, size_t &szOfDataCripted, char *&pDataDecripted, size_t &szOfDataDecripted) { WalterTools::CCrypter crypter(m_strKey); if (!crypter.encrypt((unsigned char *)m_strCommonData.c_str(), m_strCommonData.size()+1, //with zerro end string pDataCripted, szOfDataCripted)) return false; if (!crypter.decrypt(pDataCripted, szOfDataCripted, pDataDecripted, szOfDataDecripted)) return false; return true; }
QString GrooveRequest::generateCacheKey() const { QVariantMap request = buildRequest(); bool hasKey = false; QCryptographicHash crypter(QCryptographicHash::Sha1); if (m_method == QLatin1String("getSearchResults")) { // hash is: // parameters/type // parameters/query crypter.addData(request["parameters"].toMap()["type"].toByteArray()); crypter.addData(request["parameters"].toMap()["query"].toByteArray()); qDebug() << Q_FUNC_INFO << "Search cache key: " << crypter.result().toHex(); hasKey = true; } if (!hasKey) return QString(); return crypter.result().toHex(); }