diff --git a/Lora-Bot/Moduls/Scral.cs b/Lora-Bot/Moduls/Scral.cs index d59f687..0123645 100644 --- a/Lora-Bot/Moduls/Scral.cs +++ b/Lora-Bot/Moduls/Scral.cs @@ -4,10 +4,8 @@ using System.IO; using System.Net; using System.Text; using BlubbFish.Utils; -using BlubbFish.Utils.IoT.Bots; using BlubbFish.Utils.IoT.Bots.Moduls; using Fraunhofer.Fit.Iot.Lora; -using Fraunhofer.Fit.Iot.Lora.Trackers; using Fraunhofer.Fit.Iot.Lora.Events; using LitJson; @@ -16,13 +14,26 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls { private readonly List nodes = new List(); public override event ModulEvent Update; private readonly Object getLock = new Object(); + private readonly Boolean authRequired; + private String auth; + public Scral(LoraController lib, InIReader settings) : base(lib, settings) { - if(!this.config.ContainsKey("general")) { + if (!this.config.ContainsKey("general")) { throw new ArgumentException("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls.Scral: Config section [general] not exist"); } - if(!this.config["general"].ContainsKey("server")) { + if (!this.config["general"].ContainsKey("server")) { throw new ArgumentException("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls.Scral: In config section [general] value server not exist"); } + if (!this.config["general"].ContainsKey("user") && !this.config["general"].ContainsKey("pass")) { + this.authRequired = false; + } else if (!this.config["general"].ContainsKey("user")) { + throw new ArgumentException("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls.Scral: In config section [general] value user not exist"); + } else if (!this.config["general"].ContainsKey("pass")) { + throw new ArgumentException("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls.Scral: In config section [general] value pass not exist"); + } else { + this.auth = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(this.config["general"]["user"] + ":" + this.config["general"]["pass"])); + this.authRequired = true; + } if (!this.config.ContainsKey("update")) { throw new ArgumentException("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls.Scral: Config section [update] not exist"); } @@ -41,6 +52,7 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls { if (!this.config["register"].ContainsKey("method")) { throw new ArgumentException("Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls.Scral: In config section [register] value method not exist"); } + } public override void EventLibSetter() { @@ -118,6 +130,9 @@ namespace Fraunhofer.Fit.IoT.Bots.LoraBot.Moduls { lock (this.getLock) { HttpWebRequest request = WebRequest.CreateHttp(this.config["general"]["server"] + address); request.Timeout = 2000; + if (this.authRequired) { + request.Headers.Add(HttpRequestHeader.Authorization, this.auth); + } if (method == RequestMethod.POST || method == RequestMethod.PUT) { Byte[] requestdata = Encoding.ASCII.GetBytes(json); request.ContentLength = requestdata.Length; diff --git a/Lora-Bot/Properties/AssemblyInfo.cs b/Lora-Bot/Properties/AssemblyInfo.cs index 952004d..9006830 100644 --- a/Lora-Bot/Properties/AssemblyInfo.cs +++ b/Lora-Bot/Properties/AssemblyInfo.cs @@ -32,8 +32,8 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.0")] -[assembly: AssemblyFileVersion("1.7.0")] +[assembly: AssemblyVersion("1.7.1")] +[assembly: AssemblyFileVersion("1.7.1")] /* * 1.1.0 Update Scral addresses * 1.2.0 Run Module Events in threads so that one Module can not block others, TXTOut now appends to the logfile @@ -46,4 +46,5 @@ using System.Runtime.InteropServices; * 1.6.1 Fixing parsing bug with linebreaks in Lora * 1.6.2 Adding a test for LoraBinary * 1.7.0 Adding IC800A Lora-Reciever + * 1.7.1 Fixing binary data transmission & fixing Scral Plugin */ diff --git a/Lora-Bot/bin/Release/Bot-Utils.dll b/Lora-Bot/bin/Release/Bot-Utils.dll index 89311a1..192ce56 100644 Binary files a/Lora-Bot/bin/Release/Bot-Utils.dll and b/Lora-Bot/bin/Release/Bot-Utils.dll differ diff --git a/Lora-Bot/bin/Release/ConnectorDataMqtt.dll b/Lora-Bot/bin/Release/ConnectorDataMqtt.dll index a6e2197..64455cb 100644 Binary files a/Lora-Bot/bin/Release/ConnectorDataMqtt.dll and b/Lora-Bot/bin/Release/ConnectorDataMqtt.dll differ diff --git a/Lora-Bot/bin/Release/Iot-Interfaces.dll b/Lora-Bot/bin/Release/Iot-Interfaces.dll index 83e6515..f280c52 100644 Binary files a/Lora-Bot/bin/Release/Iot-Interfaces.dll and b/Lora-Bot/bin/Release/Iot-Interfaces.dll differ diff --git a/Lora-Bot/bin/Release/Lora-Bot.exe b/Lora-Bot/bin/Release/Lora-Bot.exe index 40eb480..0f185d1 100644 Binary files a/Lora-Bot/bin/Release/Lora-Bot.exe and b/Lora-Bot/bin/Release/Lora-Bot.exe differ diff --git a/Lora-Bot/bin/Release/Lora.dll b/Lora-Bot/bin/Release/Lora.dll index 9a90fde..d88fddd 100644 Binary files a/Lora-Bot/bin/Release/Lora.dll and b/Lora-Bot/bin/Release/Lora.dll differ diff --git a/Lora-Bot/bin/Release/M2Mqtt.dll b/Lora-Bot/bin/Release/M2Mqtt.dll index ce4acd7..fef2030 100644 Binary files a/Lora-Bot/bin/Release/M2Mqtt.dll and b/Lora-Bot/bin/Release/M2Mqtt.dll differ diff --git a/Lora-Bot/bin/Release/Utils-IoT.dll b/Lora-Bot/bin/Release/Utils-IoT.dll index 5ac1f76..be84863 100644 Binary files a/Lora-Bot/bin/Release/Utils-IoT.dll and b/Lora-Bot/bin/Release/Utils-IoT.dll differ diff --git a/Lora-Bot/bin/Release/Utils.dll b/Lora-Bot/bin/Release/Utils.dll index feeddc7..956603a 100644 Binary files a/Lora-Bot/bin/Release/Utils.dll and b/Lora-Bot/bin/Release/Utils.dll differ diff --git a/Lora-Bot/bin/Release/litjson.dll b/Lora-Bot/bin/Release/litjson.dll index 6431e01..f0a3790 100644 Binary files a/Lora-Bot/bin/Release/litjson.dll and b/Lora-Bot/bin/Release/litjson.dll differ