Skip to content

Commit

Permalink
[v1.7.1] Fixing binary data transmission & fixing Scral Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
blubbfish committed Feb 11, 2019
1 parent 73efe37 commit 13482c3
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 6 deletions.
23 changes: 19 additions & 4 deletions Lora-Bot/Moduls/Scral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
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;

Expand All @@ -16,13 +14,26 @@ public class Scral : AModul<LoraController> {
private readonly List<String> nodes = new List<String>();
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");
}
Expand All @@ -41,6 +52,7 @@ public class Scral : AModul<LoraController> {
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() {
Expand Down Expand Up @@ -118,6 +130,9 @@ public class Scral : AModul<LoraController> {
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;
Expand Down
5 changes: 3 additions & 2 deletions Lora-Bot/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
// 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
Expand All @@ -46,4 +46,5 @@
* 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
*/
Binary file modified Lora-Bot/bin/Release/Bot-Utils.dll
Binary file not shown.
Binary file modified Lora-Bot/bin/Release/ConnectorDataMqtt.dll
Binary file not shown.
Binary file modified Lora-Bot/bin/Release/Iot-Interfaces.dll
Binary file not shown.
Binary file modified Lora-Bot/bin/Release/Lora-Bot.exe
Binary file not shown.
Binary file modified Lora-Bot/bin/Release/Lora.dll
Binary file not shown.
Binary file modified Lora-Bot/bin/Release/M2Mqtt.dll
Binary file not shown.
Binary file modified Lora-Bot/bin/Release/Utils-IoT.dll
Binary file not shown.
Binary file modified Lora-Bot/bin/Release/Utils.dll
Binary file not shown.
Binary file modified Lora-Bot/bin/Release/litjson.dll
Binary file not shown.

0 comments on commit 13482c3

Please sign in to comment.