[CC1101] Added PhysicalLayer overloads
This commit is contained in:
parent
16b3256073
commit
0ebe25521f
2 changed files with 5 additions and 28 deletions
|
@ -81,14 +81,6 @@ int16_t CC1101::begin(float freq, float br, float rxBw, float freqDev, int8_t po
|
|||
return(state);
|
||||
}
|
||||
|
||||
int16_t CC1101::transmit(String& str, uint8_t addr) {
|
||||
return(CC1101::transmit(str.c_str(), addr));
|
||||
}
|
||||
|
||||
int16_t CC1101::transmit(const char* str, uint8_t addr) {
|
||||
return(CC1101::transmit((uint8_t*)str, strlen(str), addr));
|
||||
}
|
||||
|
||||
int16_t CC1101::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||
// check packet length
|
||||
if(len > 63) {
|
||||
|
@ -137,20 +129,6 @@ int16_t CC1101::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
return(state);
|
||||
}
|
||||
|
||||
int16_t CC1101::receive(String& str, size_t len) {
|
||||
// create temporary array to store received data
|
||||
char* data = new char[len + 1];
|
||||
int16_t state = CC1101::receive((uint8_t*)data, len);
|
||||
|
||||
// if packet was received successfully, copy data into String
|
||||
if(state == ERR_NONE) {
|
||||
str = String(data);
|
||||
}
|
||||
|
||||
delete[] data;
|
||||
return(state);
|
||||
}
|
||||
|
||||
int16_t CC1101::receive(uint8_t* data, size_t len) {
|
||||
// set mode to standby
|
||||
standby();
|
||||
|
@ -199,9 +177,7 @@ int16_t CC1101::receive(uint8_t* data, size_t len) {
|
|||
_rawLQI = val & 0x7F;
|
||||
|
||||
// add terminating null
|
||||
if(len == 0) {
|
||||
data[length] = 0;
|
||||
}
|
||||
data[length] = 0;
|
||||
|
||||
// flush Rx FIFO
|
||||
SPIsendCommand(CC1101_CMD_FLUSH_RX);
|
||||
|
|
|
@ -496,15 +496,16 @@
|
|||
|
||||
class CC1101: public PhysicalLayer {
|
||||
public:
|
||||
// introduce PhysicalLayer overloads
|
||||
using PhysicalLayer::transmit;
|
||||
using PhysicalLayer::receive;
|
||||
|
||||
// constructor
|
||||
CC1101(Module* module);
|
||||
|
||||
// basic methods
|
||||
int16_t begin(float freq = 868.0, float br = 4.8, float rxBw = 325.0, float freqDev = 48.0, int8_t power = 0);
|
||||
int16_t transmit(String& str, uint8_t addr = 0);
|
||||
int16_t transmit(const char* str, uint8_t addr = 0);
|
||||
int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0);
|
||||
int16_t receive(String& str, size_t len = 0);
|
||||
int16_t receive(uint8_t* data, size_t len);
|
||||
int16_t standby();
|
||||
int16_t transmitDirect(uint32_t FRF = 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue