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.
Diff: common.cpp
- Revision:
- 56:065bd3a75d97
- Parent:
- 51:090149c4aa28
--- a/common.cpp Thu Jan 19 02:42:15 2017 +0100
+++ b/common.cpp Thu Jan 19 11:26:38 2017 +0100
@@ -1,11 +1,5 @@
#include "common.h"
#include <cstring>
-#include <vector>
-
-using std::vector;
-
-const int pipes[] = {NRF24L01P_PIPE_P1, NRF24L01P_PIPE_P2, NRF24L01P_PIPE_P3, NRF24L01P_PIPE_P4};
-const unsigned long long addresses[] = {0x42424201, 0x42424202, 0x42424203};
std::string Data::serialize() {
std::string serialized;
@@ -32,7 +26,8 @@
return ss.str();
}
-void radio_init_sensor_board(nRF24L01P* radio, unsigned long long tx_address) {
+void radio_init(nRF24L01P* radio, unsigned long long rx_address,
+ unsigned long long tx_address) {
radio->powerDown();
radio->powerUp();
@@ -41,9 +36,13 @@
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);
@@ -51,36 +50,3 @@
radio->setReceiveMode();
radio->enable();
}
-
-void radio_init_master(nRF24L01P* radio, const std::vector<unsigned long long> &rx_addresses) {
- 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);
-
- int pipe_nr = 0;
- for (vector<unsigned long long>::const_iterator address = rx_addresses.begin(); address != rx_addresses.end(); ++address) {
- int pipe = pipes[pipe_nr];
- radio->setRxAddress(*address, 4, pipe);
- radio->enableAutoAcknowledge(pipe);
- radio->setTransferSize(TRANSFER_SIZE, pipe);
- ++pipe_nr;
- }
-
- // 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();
-}