-
philip.schell authoredphilip.schell authored
IC880ALora.cs 247.34 KiB
/*
* 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.Threading;
using BlubbFish.Utils;
using Fraunhofer.Fit.Iot.Lora.Events;
using Unosquare.RaspberryIO;
using Unosquare.RaspberryIO.Gpio;
namespace Fraunhofer.Fit.Iot.Lora.lib {
public class Ic880alora : LoraConnector {
#region Private Variables
private readonly GpioPin PinSlaveSelect;
private readonly GpioPin PinReset;
private readonly SpiChannel SpiChannel;
private Thread receiveThread;
#region Sending Correction
private readonly SByte[] cal_offset_a_i = new SByte[8];
private readonly SByte[] cal_offset_a_q = new SByte[8];
private readonly SByte[] cal_offset_b_i = new SByte[8];
private readonly SByte[] cal_offset_b_q = new SByte[8];
#endregion
#region RadioConstants
private readonly Boolean[] radioEnableTx = new Boolean[] { false, false };
private readonly Byte fskSyncWordSize = 3;
private readonly UInt64 fskSyncWord = 0xC194C1;
#endregion
#region Running Properties
private readonly Boolean[] radioEnabled = new Boolean[2];
private readonly UInt32[] radioFrequency = new UInt32[2];
private readonly Boolean[] interfaceEnabled = new Boolean[10];
private readonly Reciever[] interfaceChain = new Reciever[10];
private readonly Int32[] interfaceFrequency = new Int32[10];
private BW fskBandwidth = BW.BW_125KHZ;
private UInt32 fskDatarate = 50000;
private BW loraBandwidth = BW.BW_250KHZ;
private SF loraSpreadingFactor = SF.DR_LORA_SF7;
private Byte selectedPage;
private Boolean deviceStarted;
private Boolean CrcEnabled;
#endregion