Loading Lora/LoraController.cs +10 −5 Original line number Diff line number Diff line Loading @@ -105,12 +105,17 @@ namespace Fraunhofer.Fit.Iot.Lora { } }); private void PanicUpdates(Object sender, PanicUpdateEvent e) => this.PanicUpdate?.Invoke(sender, e); private void StatusUpdates(Object sender, StatusUpdateEvent e) => this.StatusUpdate?.Invoke(sender, e); private async void PanicUpdates(Object sender, PanicUpdateEvent e) => await Task.Run(() => { this.PanicUpdate?.Invoke(sender, e); }); private void DataUpdates(Object sender, DataUpdateEvent e) => this.DataUpdate?.Invoke(sender, e); private async void StatusUpdates(Object sender, StatusUpdateEvent e) => await Task.Run(() => { this.StatusUpdate?.Invoke(sender, e); }); private async void DataUpdates(Object sender, DataUpdateEvent e) => await Task.Run(() => { this.DataUpdate?.Invoke(sender, e); }); #region IDisposable Support private Boolean disposedValue = false; Loading @@ -130,7 +135,7 @@ namespace Fraunhofer.Fit.Iot.Lora { } public void Dispose() { Dispose(true); this.Dispose(true); GC.SuppressFinalize(this); } #endregion Loading Lora/Properties/AssemblyInfo.cs +9 −6 Original line number Diff line number Diff line using System.Reflection; using System.Resources; using System.Runtime.InteropServices; // Allgemeine Informationen über eine Assembly werden über die folgenden // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, // die einer Assembly zugeordnet sind. [assembly: AssemblyTitle("Lora")] [assembly: AssemblyDescription("")] [assembly: AssemblyDescription("Library that connects to a radio device and recieves lora traffic")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyCompany("Fraunhofer FIT")] [assembly: AssemblyProduct("Lora")] [assembly: AssemblyCopyright("Copyright © 2018 - 22.04.2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2018 - 31.05.2019")] [assembly: AssemblyTrademark("Fraunhofer FIT, BlubbFish")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("de-DE")] // Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly // für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von Loading @@ -31,8 +33,8 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // indem Sie "*" wie unten gezeigt eingeben: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.8.2")] [assembly: AssemblyFileVersion("1.8.2")] [assembly: AssemblyVersion("1.8.3")] [assembly: AssemblyFileVersion("1.8.3")] /* * 1.1.0 Now awaiing Battery as Double and fix the sending twise issue Loading @@ -48,4 +50,5 @@ using System.Runtime.InteropServices; * 1.8.0 Add field that indicates when the last gps position was recieved, change all times to UTC * 1.8.1 Add Hostname to MQTT, so you can see from witch device the data is recieved * 1.8.2 Bugfix, create also an event for sending normal loradata when update panic * 1.8.3 Refactoring and make using threads on event occours */ Lora/lib/DraginoLora.cs +20 −58 Original line number Diff line number Diff line Loading @@ -135,9 +135,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib } } public override Boolean StartRadio() { return true; } public override Boolean StartRadio() => true; public override void ParseConfig() { if (!this.config.ContainsKey("frequency") || Loading Loading @@ -221,9 +219,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib return size; } public Byte Available() { return (Byte)(this.ReadRegister(Registers.RX_NB_BYTES) - this._packetIndex); } public Byte Available() => (Byte)(this.ReadRegister(Registers.RX_NB_BYTES) - this._packetIndex); public Int16 Read() { if (this.Available() == 0) { Loading Loading @@ -258,31 +254,19 @@ namespace Fraunhofer.Fit.Iot.Lora.lib this.WriteRegister(Registers.PREAMBLE_LSB, (Byte)(length >> 0)); } public void SetSyncWord(Byte sw) { this.WriteRegister(Registers.SYNC_WORD, sw); } public void SetSyncWord(Byte sw) => this.WriteRegister(Registers.SYNC_WORD, sw); public void EnableCrc() { this.WriteRegister(Registers.MODEM_CONFIG_2, (Byte)(this.ReadRegister(Registers.MODEM_CONFIG_2) | 0x04)); } public void EnableCrc() => this.WriteRegister(Registers.MODEM_CONFIG_2, (Byte)(this.ReadRegister(Registers.MODEM_CONFIG_2) | 0x04)); public void DisableCrc() { this.WriteRegister(Registers.MODEM_CONFIG_2, (Byte)(this.ReadRegister(Registers.MODEM_CONFIG_2) & 0xfb)); } public void DisableCrc() => this.WriteRegister(Registers.MODEM_CONFIG_2, (Byte)(this.ReadRegister(Registers.MODEM_CONFIG_2) & 0xfb)); #endregion #region RadioSettings public Byte Rssi() { return (Byte)(this.ReadRegister(Registers.RSSI_VALUE) - (this._frequency < 868E6 ? 164 : 157)); } public Byte Rssi() => (Byte)(this.ReadRegister(Registers.RSSI_VALUE) - (this._frequency < 868E6 ? 164 : 157)); public Byte PacketRssi() { return (Byte)(this.ReadRegister(Registers.PKT_RSSI_VALUE) - (this._frequency < 868E6 ? 164 : 157)); } public Byte PacketRssi() => (Byte)(this.ReadRegister(Registers.PKT_RSSI_VALUE) - (this._frequency < 868E6 ? 164 : 157)); public Double PacketSnr() { return ((SByte)this.ReadRegister(Registers.PKT_SNR_VALUE)) * 0.25; } public Double PacketSnr() => ((SByte)this.ReadRegister(Registers.PKT_SNR_VALUE)) * 0.25; public Int64 PacketFrequencyError() { Int32 freqError = 0; Loading @@ -307,9 +291,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib this.WriteRegister(Registers.FRF_LSB, (Byte)(frf >> 0)); } public Byte GetSpreadingFactor() { return (Byte)(this.ReadRegister(Registers.MODEM_CONFIG_2) >> 4); } public Byte GetSpreadingFactor() => (Byte)(this.ReadRegister(Registers.MODEM_CONFIG_2) >> 4); public void SetSpreadingFactor(Byte sf) { if(sf < 6) { Loading Loading @@ -382,9 +364,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib this.WriteRegister(Registers.MODEM_CONFIG_1, (Byte)((this.ReadRegister(Registers.MODEM_CONFIG_1) & 0xF1) | (cr << 1))); } public void SetPrePaRamp() { this.WriteRegister(Registers.PRE_PA_RAMP, (Byte)((this.ReadRegister(Registers.PRE_PA_RAMP) & 0xF0) | 0x08)); } public void SetPrePaRamp() => this.WriteRegister(Registers.PRE_PA_RAMP, (Byte)((this.ReadRegister(Registers.PRE_PA_RAMP) & 0xF0) | 0x08)); public void EnableInvertIQ() { this.WriteRegister(Registers.INVERTIQ, 0x66); Loading @@ -408,9 +388,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib #endregion #region Debug public Byte Random() { return this.ReadRegister(Registers.RSSI_WIDEBAND); } public Byte Random() => this.ReadRegister(Registers.RSSI_WIDEBAND); public String DumpRegisters() { String t = ""; Loading Loading @@ -496,13 +474,9 @@ namespace Fraunhofer.Fit.Iot.Lora.lib #endregion #region Powserusage public void Ilde() { this.WriteRegister(Registers.OP_MODE, (Byte)Modes.LONG_RANGE_MODE | (Byte)Modes.STDBY); } public void Ilde() => this.WriteRegister(Registers.OP_MODE, (Byte)Modes.LONG_RANGE_MODE | (Byte)Modes.STDBY); public void Sleep() { this.WriteRegister(Registers.OP_MODE, (Byte)Modes.LONG_RANGE_MODE | (Byte)Modes.SLEEP); } public void Sleep() => this.WriteRegister(Registers.OP_MODE, (Byte)Modes.LONG_RANGE_MODE | (Byte)Modes.SLEEP); public override void SetTxPower(Int32 level) { if (level > 17) { Loading @@ -525,21 +499,13 @@ namespace Fraunhofer.Fit.Iot.Lora.lib #endregion #region Communication private Byte ReadRegister(Byte address) { return this.SingleTransfer((Byte)(address & 0x7F), 0x00); } private Byte ReadRegister(Byte address) => this.SingleTransfer((Byte)(address & 0x7F), 0x00); private Byte ReadRegister(Registers reg) { return this.ReadRegister((Byte)reg); } private Byte ReadRegister(Registers reg) => this.ReadRegister((Byte)reg); private void WriteRegister(Byte address, Byte value) { this.SingleTransfer((Byte)(address | 0x80), value); } private void WriteRegister(Byte address, Byte value) => this.SingleTransfer((Byte)(address | 0x80), value); private void WriteRegister(Registers reg, Byte value) { this.WriteRegister((Byte)reg, value); } private void WriteRegister(Registers reg, Byte value) => this.WriteRegister((Byte)reg, value); private Byte SingleTransfer(Byte address, Byte value) { this.Selectreceiver(); Loading @@ -564,13 +530,9 @@ namespace Fraunhofer.Fit.Iot.Lora.lib this.PinReset.PinMode = GpioPinDriveMode.Output; } private void Selectreceiver() { this.PinSlaveSelect.Write(false); } private void Selectreceiver() => this.PinSlaveSelect.Write(false); private void Unselectreceiver() { this.PinSlaveSelect.Write(true); } private void Unselectreceiver() => this.PinSlaveSelect.Write(true); public override void AttachUpdateEvent() { if (this.HasAttachedUpdateEvent()) { Loading Lora/lib/IC880ALora.cs +38 −32 Original line number Diff line number Diff line using System; /* * Copyright (c) 2013, SEMTECH S.A. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Semtech corporation nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL SEMTECH S.A. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; using System.Collections.Generic; using System.Text; using System.Threading; using BlubbFish.Utils; using Fraunhofer.Fit.Iot.Lora.Events; Loading Loading @@ -493,9 +519,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { this.ReadonlyRegister = readonlyRegister; this.DefaultValue = defaultValue; } public override String ToString() { return "Reg: [P:" + this.RegisterPage + ",A:"+ this.Address +",O:"+ this.BitOffset +"]"; } public override String ToString() => "Reg: [P:" + this.RegisterPage + ",A:" + this.Address + ",O:" + this.BitOffset + "]"; }; public static class SX125X { Loading Loading @@ -2423,15 +2447,9 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { #endregion #region Packets, Read, Write public override Boolean BeginPacket(Boolean implictHeader = false) { throw new NotImplementedException(); } public override Boolean EndPacket(Boolean async = false) { throw new NotImplementedException(); } public override Byte Write(Byte[] buffer) { throw new NotImplementedException(); } public override Boolean BeginPacket(Boolean implictHeader = false) => throw new NotImplementedException(); public override Boolean EndPacket(Boolean async = false) => throw new NotImplementedException(); public override Byte Write(Byte[] buffer) => throw new NotImplementedException(); public override void Receive(Byte size) { Byte[] recieveregister = this.RegisterReadArray(Registers.RX_PACKET_DATA_FIFO_NUM_STORED, 5); Loading Loading @@ -2708,9 +2726,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { } } public void SetDatarate(UInt32 dr) { this.fskDatarate = dr; } public void SetDatarate(UInt32 dr) => this.fskDatarate = dr; public void SetSignalBandwith(Int64 sbw, RadioDataType @interface) { BW bw; Loading @@ -2736,19 +2752,13 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { } } public void EnableCrc() { this.CrcEnabled = true; } public void EnableCrc() => this.CrcEnabled = true; public void DisableCrc() { this.CrcEnabled = false; } public void DisableCrc() => this.CrcEnabled = false; #endregion #region Powserusage public override void SetTxPower(Int32 level) { throw new NotImplementedException(); } public override void SetTxPower(Int32 level) => throw new NotImplementedException(); #endregion #region Register Communication Loading Loading @@ -3188,13 +3198,9 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { this.PinReset.PinMode = GpioPinDriveMode.Output; } private void Selectreceiver() { this.PinSlaveSelect.Write(false); } private void Selectreceiver() => this.PinSlaveSelect.Write(false); private void Unselectreceiver() { this.PinSlaveSelect.Write(true); } private void Unselectreceiver() => this.PinSlaveSelect.Write(true); private Byte SingleSPI(Byte address, Byte value = 0) { this.Selectreceiver(); Loading Lora/lib/LoraConnector.cs +2 −6 Original line number Diff line number Diff line Loading @@ -10,9 +10,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { public delegate void DataUpdate(Object sender, LoraClientEvent e); public event DataUpdate Update; protected LoraConnector(Dictionary<String, String> settings) { this.config = settings; } protected LoraConnector(Dictionary<String, String> settings) => this.config = settings; public static LoraConnector GetInstance(Dictionary<String, String> settings) { if (settings.Count == 0) { Loading @@ -32,9 +30,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { return (LoraConnector)t.GetConstructor(new Type[] { typeof(Dictionary<String, String>) }).Invoke(new Object[] { settings }); } protected void RaiseUpdateEvent(LoraClientEvent data) { this.Update?.Invoke(this, data); } protected void RaiseUpdateEvent(LoraClientEvent data) => this.Update?.Invoke(this, data); protected Boolean HasAttachedUpdateEvent() { if(this.Update != null) { Loading Loading
Lora/LoraController.cs +10 −5 Original line number Diff line number Diff line Loading @@ -105,12 +105,17 @@ namespace Fraunhofer.Fit.Iot.Lora { } }); private void PanicUpdates(Object sender, PanicUpdateEvent e) => this.PanicUpdate?.Invoke(sender, e); private void StatusUpdates(Object sender, StatusUpdateEvent e) => this.StatusUpdate?.Invoke(sender, e); private async void PanicUpdates(Object sender, PanicUpdateEvent e) => await Task.Run(() => { this.PanicUpdate?.Invoke(sender, e); }); private void DataUpdates(Object sender, DataUpdateEvent e) => this.DataUpdate?.Invoke(sender, e); private async void StatusUpdates(Object sender, StatusUpdateEvent e) => await Task.Run(() => { this.StatusUpdate?.Invoke(sender, e); }); private async void DataUpdates(Object sender, DataUpdateEvent e) => await Task.Run(() => { this.DataUpdate?.Invoke(sender, e); }); #region IDisposable Support private Boolean disposedValue = false; Loading @@ -130,7 +135,7 @@ namespace Fraunhofer.Fit.Iot.Lora { } public void Dispose() { Dispose(true); this.Dispose(true); GC.SuppressFinalize(this); } #endregion Loading
Lora/Properties/AssemblyInfo.cs +9 −6 Original line number Diff line number Diff line using System.Reflection; using System.Resources; using System.Runtime.InteropServices; // Allgemeine Informationen über eine Assembly werden über die folgenden // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, // die einer Assembly zugeordnet sind. [assembly: AssemblyTitle("Lora")] [assembly: AssemblyDescription("")] [assembly: AssemblyDescription("Library that connects to a radio device and recieves lora traffic")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyCompany("Fraunhofer FIT")] [assembly: AssemblyProduct("Lora")] [assembly: AssemblyCopyright("Copyright © 2018 - 22.04.2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2018 - 31.05.2019")] [assembly: AssemblyTrademark("Fraunhofer FIT, BlubbFish")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("de-DE")] // Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly // für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von Loading @@ -31,8 +33,8 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // indem Sie "*" wie unten gezeigt eingeben: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.8.2")] [assembly: AssemblyFileVersion("1.8.2")] [assembly: AssemblyVersion("1.8.3")] [assembly: AssemblyFileVersion("1.8.3")] /* * 1.1.0 Now awaiing Battery as Double and fix the sending twise issue Loading @@ -48,4 +50,5 @@ using System.Runtime.InteropServices; * 1.8.0 Add field that indicates when the last gps position was recieved, change all times to UTC * 1.8.1 Add Hostname to MQTT, so you can see from witch device the data is recieved * 1.8.2 Bugfix, create also an event for sending normal loradata when update panic * 1.8.3 Refactoring and make using threads on event occours */
Lora/lib/DraginoLora.cs +20 −58 Original line number Diff line number Diff line Loading @@ -135,9 +135,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib } } public override Boolean StartRadio() { return true; } public override Boolean StartRadio() => true; public override void ParseConfig() { if (!this.config.ContainsKey("frequency") || Loading Loading @@ -221,9 +219,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib return size; } public Byte Available() { return (Byte)(this.ReadRegister(Registers.RX_NB_BYTES) - this._packetIndex); } public Byte Available() => (Byte)(this.ReadRegister(Registers.RX_NB_BYTES) - this._packetIndex); public Int16 Read() { if (this.Available() == 0) { Loading Loading @@ -258,31 +254,19 @@ namespace Fraunhofer.Fit.Iot.Lora.lib this.WriteRegister(Registers.PREAMBLE_LSB, (Byte)(length >> 0)); } public void SetSyncWord(Byte sw) { this.WriteRegister(Registers.SYNC_WORD, sw); } public void SetSyncWord(Byte sw) => this.WriteRegister(Registers.SYNC_WORD, sw); public void EnableCrc() { this.WriteRegister(Registers.MODEM_CONFIG_2, (Byte)(this.ReadRegister(Registers.MODEM_CONFIG_2) | 0x04)); } public void EnableCrc() => this.WriteRegister(Registers.MODEM_CONFIG_2, (Byte)(this.ReadRegister(Registers.MODEM_CONFIG_2) | 0x04)); public void DisableCrc() { this.WriteRegister(Registers.MODEM_CONFIG_2, (Byte)(this.ReadRegister(Registers.MODEM_CONFIG_2) & 0xfb)); } public void DisableCrc() => this.WriteRegister(Registers.MODEM_CONFIG_2, (Byte)(this.ReadRegister(Registers.MODEM_CONFIG_2) & 0xfb)); #endregion #region RadioSettings public Byte Rssi() { return (Byte)(this.ReadRegister(Registers.RSSI_VALUE) - (this._frequency < 868E6 ? 164 : 157)); } public Byte Rssi() => (Byte)(this.ReadRegister(Registers.RSSI_VALUE) - (this._frequency < 868E6 ? 164 : 157)); public Byte PacketRssi() { return (Byte)(this.ReadRegister(Registers.PKT_RSSI_VALUE) - (this._frequency < 868E6 ? 164 : 157)); } public Byte PacketRssi() => (Byte)(this.ReadRegister(Registers.PKT_RSSI_VALUE) - (this._frequency < 868E6 ? 164 : 157)); public Double PacketSnr() { return ((SByte)this.ReadRegister(Registers.PKT_SNR_VALUE)) * 0.25; } public Double PacketSnr() => ((SByte)this.ReadRegister(Registers.PKT_SNR_VALUE)) * 0.25; public Int64 PacketFrequencyError() { Int32 freqError = 0; Loading @@ -307,9 +291,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib this.WriteRegister(Registers.FRF_LSB, (Byte)(frf >> 0)); } public Byte GetSpreadingFactor() { return (Byte)(this.ReadRegister(Registers.MODEM_CONFIG_2) >> 4); } public Byte GetSpreadingFactor() => (Byte)(this.ReadRegister(Registers.MODEM_CONFIG_2) >> 4); public void SetSpreadingFactor(Byte sf) { if(sf < 6) { Loading Loading @@ -382,9 +364,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib this.WriteRegister(Registers.MODEM_CONFIG_1, (Byte)((this.ReadRegister(Registers.MODEM_CONFIG_1) & 0xF1) | (cr << 1))); } public void SetPrePaRamp() { this.WriteRegister(Registers.PRE_PA_RAMP, (Byte)((this.ReadRegister(Registers.PRE_PA_RAMP) & 0xF0) | 0x08)); } public void SetPrePaRamp() => this.WriteRegister(Registers.PRE_PA_RAMP, (Byte)((this.ReadRegister(Registers.PRE_PA_RAMP) & 0xF0) | 0x08)); public void EnableInvertIQ() { this.WriteRegister(Registers.INVERTIQ, 0x66); Loading @@ -408,9 +388,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib #endregion #region Debug public Byte Random() { return this.ReadRegister(Registers.RSSI_WIDEBAND); } public Byte Random() => this.ReadRegister(Registers.RSSI_WIDEBAND); public String DumpRegisters() { String t = ""; Loading Loading @@ -496,13 +474,9 @@ namespace Fraunhofer.Fit.Iot.Lora.lib #endregion #region Powserusage public void Ilde() { this.WriteRegister(Registers.OP_MODE, (Byte)Modes.LONG_RANGE_MODE | (Byte)Modes.STDBY); } public void Ilde() => this.WriteRegister(Registers.OP_MODE, (Byte)Modes.LONG_RANGE_MODE | (Byte)Modes.STDBY); public void Sleep() { this.WriteRegister(Registers.OP_MODE, (Byte)Modes.LONG_RANGE_MODE | (Byte)Modes.SLEEP); } public void Sleep() => this.WriteRegister(Registers.OP_MODE, (Byte)Modes.LONG_RANGE_MODE | (Byte)Modes.SLEEP); public override void SetTxPower(Int32 level) { if (level > 17) { Loading @@ -525,21 +499,13 @@ namespace Fraunhofer.Fit.Iot.Lora.lib #endregion #region Communication private Byte ReadRegister(Byte address) { return this.SingleTransfer((Byte)(address & 0x7F), 0x00); } private Byte ReadRegister(Byte address) => this.SingleTransfer((Byte)(address & 0x7F), 0x00); private Byte ReadRegister(Registers reg) { return this.ReadRegister((Byte)reg); } private Byte ReadRegister(Registers reg) => this.ReadRegister((Byte)reg); private void WriteRegister(Byte address, Byte value) { this.SingleTransfer((Byte)(address | 0x80), value); } private void WriteRegister(Byte address, Byte value) => this.SingleTransfer((Byte)(address | 0x80), value); private void WriteRegister(Registers reg, Byte value) { this.WriteRegister((Byte)reg, value); } private void WriteRegister(Registers reg, Byte value) => this.WriteRegister((Byte)reg, value); private Byte SingleTransfer(Byte address, Byte value) { this.Selectreceiver(); Loading @@ -564,13 +530,9 @@ namespace Fraunhofer.Fit.Iot.Lora.lib this.PinReset.PinMode = GpioPinDriveMode.Output; } private void Selectreceiver() { this.PinSlaveSelect.Write(false); } private void Selectreceiver() => this.PinSlaveSelect.Write(false); private void Unselectreceiver() { this.PinSlaveSelect.Write(true); } private void Unselectreceiver() => this.PinSlaveSelect.Write(true); public override void AttachUpdateEvent() { if (this.HasAttachedUpdateEvent()) { Loading
Lora/lib/IC880ALora.cs +38 −32 Original line number Diff line number Diff line using System; /* * Copyright (c) 2013, SEMTECH S.A. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Semtech corporation nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL SEMTECH S.A. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; using System.Collections.Generic; using System.Text; using System.Threading; using BlubbFish.Utils; using Fraunhofer.Fit.Iot.Lora.Events; Loading Loading @@ -493,9 +519,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { this.ReadonlyRegister = readonlyRegister; this.DefaultValue = defaultValue; } public override String ToString() { return "Reg: [P:" + this.RegisterPage + ",A:"+ this.Address +",O:"+ this.BitOffset +"]"; } public override String ToString() => "Reg: [P:" + this.RegisterPage + ",A:" + this.Address + ",O:" + this.BitOffset + "]"; }; public static class SX125X { Loading Loading @@ -2423,15 +2447,9 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { #endregion #region Packets, Read, Write public override Boolean BeginPacket(Boolean implictHeader = false) { throw new NotImplementedException(); } public override Boolean EndPacket(Boolean async = false) { throw new NotImplementedException(); } public override Byte Write(Byte[] buffer) { throw new NotImplementedException(); } public override Boolean BeginPacket(Boolean implictHeader = false) => throw new NotImplementedException(); public override Boolean EndPacket(Boolean async = false) => throw new NotImplementedException(); public override Byte Write(Byte[] buffer) => throw new NotImplementedException(); public override void Receive(Byte size) { Byte[] recieveregister = this.RegisterReadArray(Registers.RX_PACKET_DATA_FIFO_NUM_STORED, 5); Loading Loading @@ -2708,9 +2726,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { } } public void SetDatarate(UInt32 dr) { this.fskDatarate = dr; } public void SetDatarate(UInt32 dr) => this.fskDatarate = dr; public void SetSignalBandwith(Int64 sbw, RadioDataType @interface) { BW bw; Loading @@ -2736,19 +2752,13 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { } } public void EnableCrc() { this.CrcEnabled = true; } public void EnableCrc() => this.CrcEnabled = true; public void DisableCrc() { this.CrcEnabled = false; } public void DisableCrc() => this.CrcEnabled = false; #endregion #region Powserusage public override void SetTxPower(Int32 level) { throw new NotImplementedException(); } public override void SetTxPower(Int32 level) => throw new NotImplementedException(); #endregion #region Register Communication Loading Loading @@ -3188,13 +3198,9 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { this.PinReset.PinMode = GpioPinDriveMode.Output; } private void Selectreceiver() { this.PinSlaveSelect.Write(false); } private void Selectreceiver() => this.PinSlaveSelect.Write(false); private void Unselectreceiver() { this.PinSlaveSelect.Write(true); } private void Unselectreceiver() => this.PinSlaveSelect.Write(true); private Byte SingleSPI(Byte address, Byte value = 0) { this.Selectreceiver(); Loading
Lora/lib/LoraConnector.cs +2 −6 Original line number Diff line number Diff line Loading @@ -10,9 +10,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { public delegate void DataUpdate(Object sender, LoraClientEvent e); public event DataUpdate Update; protected LoraConnector(Dictionary<String, String> settings) { this.config = settings; } protected LoraConnector(Dictionary<String, String> settings) => this.config = settings; public static LoraConnector GetInstance(Dictionary<String, String> settings) { if (settings.Count == 0) { Loading @@ -32,9 +30,7 @@ namespace Fraunhofer.Fit.Iot.Lora.lib { return (LoraConnector)t.GetConstructor(new Type[] { typeof(Dictionary<String, String>) }).Invoke(new Object[] { settings }); } protected void RaiseUpdateEvent(LoraClientEvent data) { this.Update?.Invoke(this, data); } protected void RaiseUpdateEvent(LoraClientEvent data) => this.Update?.Invoke(this, data); protected Boolean HasAttachedUpdateEvent() { if(this.Update != null) { Loading