Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
common.cpp
- Committer:
- sbarzowski
- Date:
- 2017-01-17
- Revision:
- 40:40d4161fe1ad
- Parent:
- 8:1861d0eef60a
- Child:
- 44:d15530b37144
File content as of revision 40:40d4161fe1ad:
#include "common.h" #include <cstring> std::string Data::serialize() { std::string serialized; serialized.push_back(type); serialized.append((char*)&value, sizeof(value)); return serialized; }; bool Data::deserialize(std::string str) { if(str.length() < 1 + sizeof(value)) { return false; } type = str[0]; memcpy(&value, str.data() + 1, sizeof(value)); return true; } void radio_init(nRF24L01P* radio, unsigned long long rx_address, unsigned long long tx_address) { radio->powerDown(); radio->powerUp(); radio->setAirDataRate(DATA_RATE); radio->setRfOutputPower(POWER); radio->setRfFrequency(NRF24L01P_MIN_RF_FREQUENCY + 4 * CHANNEL); radio->setCrcWidth(NRF24L01P_CRC_8_BIT); radio->enableAutoAcknowledge(NRF24L01P_PIPE_P0); radio->enableAutoAcknowledge(NRF24L01P_PIPE_P1); radio->enableAutoRetransmit(0x0F, 0x0F); radio->setTxAddress(tx_address, 4); radio->setRxAddress(tx_address, 4, NRF24L01P_PIPE_P0); radio->setRxAddress(rx_address, 4, NRF24L01P_PIPE_P1); radio->setTransferSize(TRANSFER_SIZE, NRF24L01P_PIPE_P0); radio->setTransferSize(TRANSFER_SIZE, NRF24L01P_PIPE_P1); radio->setReceiveMode(); radio->enable(); }