I had been planning this for a while, then the code broke when I tried to build a version for my SparkFun LoRa Gateway-1-Channel (ESP32). There was a namespace (static configuration class in configuration.cs) collision and the length of SX127XDevice.cs file was getting silly.
This refactor took a couple of days and really changed the structure of the library.
I went through the SX127XDevice.cs extracting the enumerations, masks and defaults associated with the registers the library supports.
The RegOpMode.cs file is a good example…
namespace devMobile.IoT.SX127xLoRaDevice
{
using System;
// RegOpMode bit flags from Semtech SX127X Datasheet
[Flags]
internal enum RegOpModeModeFlags : byte
{
LongRangeModeLoRa = 0b10000000,
LongRangeModeFskOok = 0b00000000,
LongRangeModeDefault = LongRangeModeFskOok,
AcessSharedRegLoRa = 0b00000000,
AcessSharedRegFsk = 0b01000000,
AcessSharedRegDefault = AcessSharedRegLoRa,
LowFrequencyModeOnHighFrequency = 0b00000000,
LowFrequencyModeOnLowFrequency = 0b00001000,
LowFrequencyModeOnDefault = LowFrequencyModeOnLowFrequency
}
internal enum RegOpModeMode : byte
{
Sleep = 0b00000000,
StandBy = 0b00000001,
FrequencySynthesisTX = 0b00000010,
Transmit = 0b00000011,
FrequencySynthesisRX = 0b00000100,
ReceiveContinuous = 0b00000101,
ReceiveSingle = 0b00000110,
ChannelActivityDetection = 0b00000111,
};
}
The library is designed to be a approximate .NET nanoFramework equivalent of Arduino-LoRa so it doesn’t support/implement all of the functionality of the Semtech SX127X. Still got a bit of refactoring to go but the structure is slowly improving.
I use Fork to manage my Github repositories, it’s an excellent product especially as it does a pretty good job of keeping me from screwing up.