After a month of posts the source code of V0.9 of my RFM9X/SX127X library is on GitHub. I included all of the source for my test harness and proof of concept(PoC) applications so other people can follow along with “my learning experience”.
I started wanting a library to for a LoRa telemetry field gateway and ended up writing one (which is usually not a good idea). My use case was a device that was configured, then run for long periods of time, was not battery powered, and if settings were changed could be restarted. I need to trial with some more hardware, frequency bands, variety of clients, initialisation configurations and backport the last round of fixes to my .NetMF library.
I am also looking at writing an RFM69 library using a pair of shields (434MHz & 915MHz) from seegel-systeme.
The simplest possible application using the new library (a fair bit of the code is to support the different supported shields)
//--------------------------------------------------------------------------------- // Copyright (c) August 2018, devMobile Software // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //--------------------------------------------------------------------------------- namespace devMobile.IoT.Rfm9x.LoRaDeviceClient { using System; using System.Diagnostics; using System.Text; using System.Threading.Tasks; using devMobile.IoT.Rfm9x; using Windows.ApplicationModel.Background; public sealed class StartupTask : IBackgroundTask { private byte NessageCount = Byte.MaxValue; #if DRAGINO private const byte ChipSelectLine = 25; private const byte ResetLine = 17; private const byte InterruptLine = 4; private Rfm9XDevice rfm9XDevice = new Rfm9XDevice(ChipSelectPin.CS0, ChipSelectLine, ResetLine, InterruptLine); #endif #if M2M private const byte ChipSelectLine = 25; private const byte ResetLine = 17; private const byte InterruptLine = 4; private Rfm9XDevice rfm9XDevice = new Rfm9XDevice(ChipSelectPin.CS0, ChipSelectLine, ResetLine, InterruptLine); #endif #if ELECROW private const byte ResetLine = 22; private const byte InterruptLine = 25; private Rfm9XDevice rfm9XDevice = new Rfm9XDevice(ChipSelectPin.CS1, ResetLine, InterruptLine); #endif #if ELECTRONIC_TRICKS private const byte ResetLine = 22; private const byte InterruptLine = 25; private Rfm9XDevice rfm9XDevice = new Rfm9XDevice(ChipSelectPin.CS0, 22, 25); #endif public void Run(IBackgroundTaskInstance taskInstance) { rfm9XDevice.Initialise(Rfm9XDevice.RegOpModeMode.ReceiveContinuous, 915000000.0, paBoost: true); #if DEBUG rfm9XDevice.RegisterDump(); #endif rfm9XDevice.OnReceive += Rfm9XDevice_OnReceive; rfm9XDevice.OnTransmit += Rfm9XDevice_OnTransmit; Task.Delay(10000).Wait(); while (true) { string messageText = string.Format("Hello W10 IoT Core LoRa! {0}", NessageCount); NessageCount -= 1; byte[] messageBytes = UTF8Encoding.UTF8.GetBytes(messageText); Debug.WriteLine("{0:HH:mm:ss}-TX {1} byte message {2}", DateTime.Now, messageBytes.Length, messageText); this.rfm9XDevice.Send(messageBytes); Task.Delay(10000).Wait(); } } private void Rfm9XDevice_OnReceive(object sender, Rfm9XDevice.OnDataReceivedEventArgs e) { try { string messageText = UTF8Encoding.UTF8.GetString(e.Data); Debug.WriteLine("{0:HH:mm:ss}-RX {1} byte message {2}", DateTime.Now, e.Data.Length, messageText); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } private void Rfm9XDevice_OnTransmit(object sender, Rfm9XDevice.OnDataTransmitedEventArgs e) { Debug.WriteLine("{0:HH:mm:ss}-TX Done", DateTime.Now); } } }
I have a shield from uputronics on order which should arrive from the UK in roughly a week. This shield has two RFM9X devices onboard (In my case 434MHz & 915MHz) so it will be interesting to see how my library copes with two instances of the stack running together.
I need to do more testing (especially of the initialisation options) and will add basic device addressing soon so my field gateway will only see messages which it is interested in.
Pingback: RFM69 shield library Part1 | devMobile's blog
Pingback: RFM69 hat library Part3 | devMobile's blog
Pingback: .Net Meadow LoRa library Part1 | devMobile's blog
Pingback: .Net Meadow RFM95/96/97/98 LoRa library Part6 | devMobile's blog
Pingback: .Net Meadow RFM95/96/97/98 LoRa library Part7 | devMobile's blog
Pingback: .Net Meadow RFM95/96/97/98 LoRa library Part8 | devMobile's blog
Pingback: TinyCLR OS LoRa library Part6 | devMobile's blog
Pingback: TinyCLR OS LoRa library Part8 | devMobile's blog