Merge pull request #205 from fleinze/patch-1
Channel and Datarate in MyTransportNRF24 constructor
This commit is contained in:
@@ -20,11 +20,13 @@
|
|||||||
#include "MyTransport.h"
|
#include "MyTransport.h"
|
||||||
#include "MyTransportNRF24.h"
|
#include "MyTransportNRF24.h"
|
||||||
|
|
||||||
MyTransportNRF24::MyTransportNRF24(uint8_t ce, uint8_t cs, uint8_t paLevel)
|
MyTransportNRF24::MyTransportNRF24(uint8_t ce, uint8_t cs, uint8_t paLevel, uint8_t channel, rf24_datarate_e datarate)
|
||||||
:
|
:
|
||||||
MyTransport(),
|
MyTransport(),
|
||||||
rf24(ce, cs),
|
rf24(ce, cs),
|
||||||
_paLevel(paLevel)
|
_paLevel(paLevel),
|
||||||
|
_channel(channel),
|
||||||
|
_datarate(datarate)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,9 +40,9 @@ bool MyTransportNRF24::init() {
|
|||||||
rf24.setAutoAck(1);
|
rf24.setAutoAck(1);
|
||||||
rf24.setAutoAck(BROADCAST_PIPE,false); // Turn off auto ack for broadcast
|
rf24.setAutoAck(BROADCAST_PIPE,false); // Turn off auto ack for broadcast
|
||||||
rf24.enableAckPayload();
|
rf24.enableAckPayload();
|
||||||
rf24.setChannel(RF24_CHANNEL);
|
rf24.setChannel(_channel);
|
||||||
rf24.setPALevel(_paLevel);
|
rf24.setPALevel(_paLevel);
|
||||||
rf24.setDataRate(RF24_DATARATE);
|
rf24.setDataRate(_datarate);
|
||||||
rf24.setRetries(5,15);
|
rf24.setRetries(5,15);
|
||||||
rf24.setCRCLength(RF24_CRC_16);
|
rf24.setCRCLength(RF24_CRC_16);
|
||||||
rf24.enableDynamicPayloads();
|
rf24.enableDynamicPayloads();
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
class MyTransportNRF24 : public MyTransport
|
class MyTransportNRF24 : public MyTransport
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyTransportNRF24(uint8_t ce=RF24_CE_PIN, uint8_t cs=RF24_CS_PIN, uint8_t paLevel=RF24_PA_LEVEL);
|
MyTransportNRF24(uint8_t ce=RF24_CE_PIN, uint8_t cs=RF24_CS_PIN, uint8_t paLevel=RF24_PA_LEVEL, uint8_t channel=RF24_CHANNEL, rf24_datarate_e datarate=RF24_DATARATE);
|
||||||
bool init();
|
bool init();
|
||||||
void setAddress(uint8_t address);
|
void setAddress(uint8_t address);
|
||||||
uint8_t getAddress();
|
uint8_t getAddress();
|
||||||
@@ -47,6 +47,8 @@ private:
|
|||||||
RF24 rf24;
|
RF24 rf24;
|
||||||
uint8_t _address;
|
uint8_t _address;
|
||||||
uint8_t _paLevel;
|
uint8_t _paLevel;
|
||||||
|
uint8_t _channel;
|
||||||
|
rf24_datarate_e _datarate;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user