Again, while doing some stress testing I noticed an odd message go past in the Visual Studio output window. I had multiple devices sending addressed messages (both individual and broadcast) to the Adafruit RFM69 HCW Radio Bonnet, on my Windows 10 IoT Core device while it was sending a message every 5 seconds.
Received From 102 a 15 byte message Hello World:161
23:42:33.343 RegIrqFlags2 01100110
23:42:33.356 RegIrqFlags1 11011001
23:42:33.374 Address 0X99 10011001
Received From 153 a 15 byte message Hello World:106
23:42:33.761 RegIrqFlags2 01100110
23:42:33.774 RegIrqFlags1 11011001
23:42:33.791 Address 0X66 01100110
Received From 102 a 15 byte message Hello World:162
The thread 0xd20 has exited with code 0 (0x0).
23:42:34.500 RegIrqFlags2 01100110
23:42:34.501 Send-hello world 11:42:34 PM
23:42:34.520 RegIrqFlags1 11011001
23:42:34.545 Send-Done
23:42:34.551 Address 0X10 00010000
Received From 16 a 15 byte message h WWWWWWWWoo
23:42:34.686 RegIrqFlags2 00001000
23:42:34.701 RegIrqFlags1 10110000
23:42:34.715 Transmit-Done
Transmit-Done
23:42:34.902 RegIrqFlags2 01100110
23:42:34.915 RegIrqFlags1 11011001
23:42:34.931 Address 0X66 01100110
Received From 102 a 15 byte message Hello World:163
23:42:35.626 RegIrqFlags2 01100110
23:42:35.640 RegIrqFlags1 11011001
23:42:35.659 Address 0X99 10011001
Received From 153 a 15 byte message Hello World:108
23:42:36.042 RegIrqFlags2 01100110
23:42:36.055 RegIrqFlags1 11011001
23:42:36.073 Address 0X66 01100110
The RegIrqFlags2 CrcOk (bit 1) was set and the message was corrupt.

I have added code to check the CRC on inbound messages if this functionality is enabled. So the library can be used with CRCs disabled I have added a flag to the OnDataReceivedEventArgs class to indicate whether the CRC on the inbound message was OK.
private readonly Object Rfm9XRegFifoLock = new object();
...
private void ProcessPayloadReady(RegIrqFlags1 irqFlags1, RegIrqFlags2 irqFlags2)
{
byte? address = null;
byte numberOfBytes;
byte[] messageBytes;
lock (Rfm9XRegFifoLock)
{
// Read the length of the buffer if variable length packets
if (PacketFormat == RegPacketConfig1PacketFormat.VariableLength)
{
numberOfBytes = RegisterManager.ReadByte((byte)Rfm69HcwDevice.Registers.RegFifo);
}
else
{
numberOfBytes = PayloadLength;
}
// Remove the address from start of the payload
if (AddressingEnabled)
{
address = RegisterManager.ReadByte((byte)Rfm69HcwDevice.Registers.RegFifo);
Debug.WriteLine("{0:HH:mm:ss.fff} Address 0X{1:X2} {2}", DateTime.Now, address, Convert.ToString((byte)address, 2).PadLeft(8, '0'));
numberOfBytes--;
}
// Allocate a buffer for the payload and read characters from the Fifo
messageBytes = new byte[numberOfBytes];
for (int i = 0; i < numberOfBytes; i++)
{
messageBytes[i] = RegisterManager.ReadByte((byte)Rfm69HcwDevice.Registers.RegFifo);
}
}
...
public void SendMessage(byte[] messageBytes)
{
#region Guard conditions
#endregion
lock (Rfm9XRegFifoLock)
{
SetMode(RegOpModeMode.StandBy);
if (PacketFormat == RegPacketConfig1PacketFormat.VariableLength)
{
RegisterManager.WriteByte((byte)Registers.RegFifo, (byte)messageBytes.Length);
}
foreach (byte b in messageBytes)
{
this.RegisterManager.WriteByte((byte)Registers.RegFifo, b);
}
SetMode(RegOpModeMode.Transmit);
}
}
I can most probably reduce the duration which I hold the lock for but that will require some more stress testing.
