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.h
- Revision:
- 2:6541a391bdbd
- Child:
- 4:aa25f65395e3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common.h Thu Jan 05 11:31:12 2017 +0100 @@ -0,0 +1,38 @@ +#include <stdint.h> +#include <string> +#include "nRF24L01P.h" + +#define DATA_RATE NRF24L01P_DATARATE_250_KBPS +#define POWER NRF24L01P_TX_PWR_ZERO_DB +#define CHANNEL 2 +#define TRANSFER_SIZE 32 + +const unsigned long long MASTER_ADDRESS = 0xABCDEF00; +const unsigned long long PIR1_ADDRESS = 0xABCDEF01; +const unsigned long long PIR2_ADDRESS = 0xABCDEF02; +const unsigned long long DISTANCE_SENSOR_ADDRESS = 0xABCDEF02; +const unsigned long long SOUND_SENSOR_ADDRESS = 0xABCDEF03; + +enum SENSOR_TYPE { + PIR1, + PIR2, + DISTANCE, + SOUND, +}; + +struct Data { + Data(uint8_t type_, uint8_t counter_) + : type(type_), counter(counter_) {} + + // TODO correct? + Data(std::string serialized) + : type(serialized[0]), counter(serialized[1]) {} + + std::string serialize(); + + uint8_t type; + uint8_t counter; +}; + +void radio_init(nRF24L01P* radio, unsigned long long rx_address, + unsigned long long tx_address);