Return a boolean to indiciate if a packet was sent to the radio successfully
This commit is contained in:
@@ -24,7 +24,7 @@ public:
|
|||||||
void loop();
|
void loop();
|
||||||
|
|
||||||
void setPacketCallback(std::function<void(const Packet*)> callback);
|
void setPacketCallback(std::function<void(const Packet*)> callback);
|
||||||
void sendPacket(const Packet* packet);
|
bool sendPacket(const Packet* packet);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RF24 radio;
|
RF24 radio;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
RFPowerView::RFPowerView(uint8_t cePin, uint8_t csPin, uint8_t irqPin, uint16_t rfID) :
|
RFPowerView::RFPowerView(uint8_t cePin, uint8_t csPin, uint8_t irqPin, uint16_t rfID) :
|
||||||
radio(cePin, csPin),
|
radio(cePin, csPin),
|
||||||
packetReceiver(&radio),
|
packetReceiver(&radio),
|
||||||
bufferFiller(0x00, 0x00, 0x05),
|
bufferFiller(0x3D, 0x96, 0x05),
|
||||||
irqPin(irqPin),
|
irqPin(irqPin),
|
||||||
rfID{static_cast<uint8_t>(rfID & 0xFF), static_cast<uint8_t>(rfID >> 8)},
|
rfID{static_cast<uint8_t>(rfID & 0xFF), static_cast<uint8_t>(rfID >> 8)},
|
||||||
packetCallback(nullptr) {}
|
packetCallback(nullptr) {}
|
||||||
@@ -77,7 +77,7 @@ void RFPowerView::setPacketCallback(std::function<void(const Packet*)> callback)
|
|||||||
packetCallback = callback;
|
packetCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RFPowerView::sendPacket(const Packet* packet) {
|
bool RFPowerView::sendPacket(const Packet* packet) {
|
||||||
if (bufferFiller.fill(sendBuffer, packet)) {
|
if (bufferFiller.fill(sendBuffer, packet)) {
|
||||||
startTransmitting();
|
startTransmitting();
|
||||||
|
|
||||||
@@ -93,5 +93,8 @@ void RFPowerView::sendPacket(const Packet* packet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startListening();
|
startListening();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user