The reason for RFM9XLoRaNet was so that I could build a field gateway to upload telemetry data from “cheap n cheerful” *duino devices to Azure IoT Hubs and AdaFruit.IO.
I have extended the Windows10IoTCore sample application and library to show how the conditional compilation directive ADDRESSED_MESSAGES_PAYLOAD controls the configuration.
When the application is started the RFM9X is in sleep mode, then when the Receive method is called the device is set to ReceiveContinuous.
public void Run(IBackgroundTaskInstance taskInstance) { rfm9XDevice.Initialise(915000000.0, paBoost: true, rxPayloadCrcOn : true); #if DEBUG rfm9XDevice.RegisterDump(); #endif #if ADDRESSED_MESSAGES_PAYLOAD rfm9XDevice.OnReceive += Rfm9XDevice_OnReceive; rfm9XDevice.Receive(UTF8Encoding.UTF8.GetBytes(Environment.MachineName)); #else rfm9XDevice.Receive(); #endif rfm9XDevice.OnTransmit += Rfm9XDevice_OnTransmit; Task.Delay(10000).Wait(); while (true) { string messageText = string.Format("Hello from {0} ! {1}", Environment.MachineName, NessageCount); MessageCount -= 1; byte[] messageBytes = UTF8Encoding.UTF8.GetBytes(messageText); Debug.WriteLine("{0:HH:mm:ss}-TX {1} byte message {2}", DateTime.Now, messageBytes.Length, messageText); #if ADDRESSED_MESSAGES_PAYLOAD this.rfm9XDevice.Send(UTF8Encoding.UTF8.GetBytes("AddressGoesHere"), messageBytes); #else this.rfm9XDevice.Send(messageBytes); #endif Task.Delay(10000).Wait(); } }
On receipt of a message, the message is parsed and the to/from addresses and payload extracted (ADDRESSED_MESSAGES defined) or passed to the client application for processing.
private void Rfm9XDevice_OnReceive(object sender, Rfm9XDevice.OnDataReceivedEventArgs e) { try { string messageText = UTF8Encoding.UTF8.GetString(e.Data); #if ADDRESSED_MESSAGES_PAYLOAD string addressText = UTF8Encoding.UTF8.GetString(e.Address); Debug.WriteLine(@"{0:HH:mm:ss}-RX From {1} PacketSnr {2:0.0} Packet RSSI {3}dBm RSSI {4}dBm = {5} byte message ""{6}""", DateTime.Now, addressText, e.PacketSnr, e.PacketRssi, e.Rssi, e.Data.Length, messageText); #else Debug.WriteLine(@"{0:HH:mm:ss}-RX PacketSnr {1:0.0} Packet RSSI {2}dBm RSSI {3}dBm = {4} byte message ""{5}""", DateTime.Now, e.PacketSnr, e.PacketRssi, e.Rssi, e.Data.Length, messageText); #endif } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
The addressing implementation needs further testing and I’m building sample .NetMF and *duino clients.
Pingback: RFM9X.NetMF Payload Addressing | devMobile's blog
Pingback: Arduino Payload Addressing Client | devMobile's blog
Pingback: Dragino LoRaMiniDev Payload Addressing Client | devMobile's blog
Pingback: Maduino LoRa Radio 868MHz | devMobile's blog
Pingback: Netduino LoRa Radio 433/868MHz Payload Addressing client | devMobile's blog
Pingback: Netduino LoRa Radio 433/868/915 MHz Payload Addressing client | devMobile's blog
Pingback: LoRa Radio Node v1.0 868/915MHz Payload Addressing Client | devMobile's blog
Pingback: 32u4 with Lora RFM95 IOT Board-868MHz/915MHz Payload Addressing Client | devMobile's blog
Pingback: IoT.Net LoRa Radio 915 MHz Payload Addressing client | devMobile's blog
Pingback: Adafruit Feather M0 RFM95 LoRa Radio (433 or 900 MHz) Payload Addressing Client | devMobile's blog
Pingback: Wisen Whisper Node – LoRa 915 MHz Payload Addressing Client | devMobile's blog
Pingback: RFM69 hat library Part12 | devMobile's blog