diff --git a/inc/PacketBuffer.h b/inc/PacketBuffer.h index 7ef932f..a0c40ca 100644 --- a/inc/PacketBuffer.h +++ b/inc/PacketBuffer.h @@ -233,6 +233,8 @@ class PacketBuffer * @endcode */ void setRSSI(uint8_t rssi); + + static PacketBuffer EmptyPacket; }; #endif diff --git a/source/PacketBuffer.cpp b/source/PacketBuffer.cpp index 32cb783..54f8ca7 100644 --- a/source/PacketBuffer.cpp +++ b/source/PacketBuffer.cpp @@ -1,5 +1,8 @@ #include "MicroBit.h" +// Create the EmptyPacket reference. +PacketBuffer PacketBuffer::EmptyPacket = PacketBuffer(1); + /** * Default Constructor. * Creates an empty Packet Buffer. diff --git a/source/ble-services/MicroBitRadioDatagram.cpp b/source/ble-services/MicroBitRadioDatagram.cpp index c6727fd..8f96a73 100644 --- a/source/ble-services/MicroBitRadioDatagram.cpp +++ b/source/ble-services/MicroBitRadioDatagram.cpp @@ -57,6 +57,9 @@ int MicroBitRadioDatagram::recv(uint8_t *buf, int len) */ PacketBuffer MicroBitRadioDatagram::recv() { + if (rxQueue == NULL) + return PacketBuffer::EmptyPacket; + FrameBuffer *p = rxQueue; rxQueue = rxQueue->next;