Radio communication with NRF24

Dependents:   F030

Committer:
gume
Date:
Fri Oct 06 20:17:36 2017 +0000
Revision:
0:9f5a444886a8
Initial release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gume 0:9f5a444886a8 1 #ifndef __NODECONFIG_H_
gume 0:9f5a444886a8 2 #define __NODECONFIG_H_
gume 0:9f5a444886a8 3
gume 0:9f5a444886a8 4 //#include <Arduino.h>
gume 0:9f5a444886a8 5 #include "RF24.h"
gume 0:9f5a444886a8 6
gume 0:9f5a444886a8 7
gume 0:9f5a444886a8 8 #define DEFAULT_NETWORK_PREFIX 0x424D45L // All network node has a common 3 byte address prefix
gume 0:9f5a444886a8 9 #define DEFAULT_NODE_ADDRESS 0x424D455555L
gume 0:9f5a444886a8 10 #define DEFAULT_SYNC_ADDRESS 0x3333333333L
gume 0:9f5a444886a8 11 #define DEFAULT_GW_ID 0x0000
gume 0:9f5a444886a8 12 #define DEFAULT_RADIO_CHANNEL 96
gume 0:9f5a444886a8 13 #define DEFAULT_PA_LEVEL RF24_PA_MAX
gume 0:9f5a444886a8 14 #define DEFAULT_DATA_RATE RF24_2MBPS
gume 0:9f5a444886a8 15
gume 0:9f5a444886a8 16 class SSRadio;
gume 0:9f5a444886a8 17
gume 0:9f5a444886a8 18 class NodeConfig {
gume 0:9f5a444886a8 19 friend class SSRadio;
gume 0:9f5a444886a8 20
gume 0:9f5a444886a8 21 private:
gume 0:9f5a444886a8 22 uint32_t netPrefix;
gume 0:9f5a444886a8 23 uint16_t nodeId;
gume 0:9f5a444886a8 24 uint16_t gwId;
gume 0:9f5a444886a8 25 uint64_t syncAddress;
gume 0:9f5a444886a8 26
gume 0:9f5a444886a8 27 uint8_t channel; // Radio channel
gume 0:9f5a444886a8 28 rf24_pa_dbm_e paLevel; // PA level
gume 0:9f5a444886a8 29 rf24_datarate_e dataRate; // The transmission speed
gume 0:9f5a444886a8 30
gume 0:9f5a444886a8 31 PinName cePin; // CE pin
gume 0:9f5a444886a8 32 PinName csnPin; // CS pin
gume 0:9f5a444886a8 33
gume 0:9f5a444886a8 34 public:
gume 0:9f5a444886a8 35 NodeConfig(PinName _cepin, PinName _cspin);
gume 0:9f5a444886a8 36
gume 0:9f5a444886a8 37 void setNodeId(uint16_t nodeId);
gume 0:9f5a444886a8 38 void setGwId(uint16_t gwId);
gume 0:9f5a444886a8 39 void setNetPrefix(uint32_t netPrefix);
gume 0:9f5a444886a8 40 void setSyncAddress(uint64_t syncAddress);
gume 0:9f5a444886a8 41 void setChannel(uint8_t channel);
gume 0:9f5a444886a8 42 void setSpeed(rf24_datarate_e dataRate);
gume 0:9f5a444886a8 43
gume 0:9f5a444886a8 44 uint16_t getNodeId(); // Returns ID from EEPROM or UinqID. If no ID in EEPROM, then create one
gume 0:9f5a444886a8 45 };
gume 0:9f5a444886a8 46
gume 0:9f5a444886a8 47 #endif // NODECONFIG_H