null terminate radio.DATA
This commit is contained in:
parent
999933b7bf
commit
3913d5689c
11
RFM69.cpp
11
RFM69.cpp
|
|
@ -27,7 +27,7 @@
|
||||||
#include <RFM69registers.h>
|
#include <RFM69registers.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
uint8_t RFM69::DATA[RF69_MAX_DATA_LEN];
|
uint8_t RFM69::DATA[RF69_MAX_DATA_LEN+1];
|
||||||
uint8_t RFM69::_mode; // current transceiver state
|
uint8_t RFM69::_mode; // current transceiver state
|
||||||
uint8_t RFM69::DATALEN;
|
uint8_t RFM69::DATALEN;
|
||||||
uint16_t RFM69::SENDERID;
|
uint16_t RFM69::SENDERID;
|
||||||
|
|
@ -361,9 +361,9 @@ void RFM69::interruptHandler() {
|
||||||
ACK_REQUESTED = CTLbyte & RFM69_CTL_REQACK; // extract ACK-requested flag
|
ACK_REQUESTED = CTLbyte & RFM69_CTL_REQACK; // extract ACK-requested flag
|
||||||
interruptHook(CTLbyte); // TWS: hook to derived class interrupt function
|
interruptHook(CTLbyte); // TWS: hook to derived class interrupt function
|
||||||
|
|
||||||
for (uint8_t i = 0; i < DATALEN; i++)
|
for (uint8_t i = 0; i < DATALEN; i++) DATA[i] = SPI.transfer(0);
|
||||||
DATA[i] = SPI.transfer(0);
|
|
||||||
if (DATALEN < RF69_MAX_DATA_LEN) DATA[DATALEN] = 0; // add null at end of string
|
DATA[DATALEN] = 0; // add null at end of string // add null at end of string
|
||||||
unselect();
|
unselect();
|
||||||
setMode(RF69_MODE_RX);
|
setMode(RF69_MODE_RX);
|
||||||
}
|
}
|
||||||
|
|
@ -393,8 +393,6 @@ void RFM69::receiveBegin() {
|
||||||
|
|
||||||
// checks if a packet was received and/or puts transceiver in receive (ie RX or listen) mode
|
// checks if a packet was received and/or puts transceiver in receive (ie RX or listen) mode
|
||||||
bool RFM69::receiveDone() {
|
bool RFM69::receiveDone() {
|
||||||
//ATOMIC_BLOCK(ATOMIC_FORCEON)
|
|
||||||
//{
|
|
||||||
if (_haveData) {
|
if (_haveData) {
|
||||||
_haveData = false;
|
_haveData = false;
|
||||||
interruptHandler();
|
interruptHandler();
|
||||||
|
|
@ -410,7 +408,6 @@ bool RFM69::receiveDone() {
|
||||||
}
|
}
|
||||||
receiveBegin();
|
receiveBegin();
|
||||||
return false;
|
return false;
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// To enable encryption: radio.encrypt("ABCDEFGHIJKLMNOP");
|
// To enable encryption: radio.encrypt("ABCDEFGHIJKLMNOP");
|
||||||
|
|
|
||||||
2
RFM69.h
2
RFM69.h
|
|
@ -168,7 +168,7 @@
|
||||||
|
|
||||||
class RFM69 {
|
class RFM69 {
|
||||||
public:
|
public:
|
||||||
static uint8_t DATA[RF69_MAX_DATA_LEN]; // recv/xmit buf, including header & crc bytes
|
static uint8_t DATA[RF69_MAX_DATA_LEN+1]; // RX/TX payload buffer, including end of string NULL char
|
||||||
static uint8_t DATALEN;
|
static uint8_t DATALEN;
|
||||||
static uint16_t SENDERID;
|
static uint16_t SENDERID;
|
||||||
static uint16_t TARGETID; // should match _address
|
static uint16_t TARGETID; // should match _address
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue