[v1.7.1] Fixing binary data transmission & fixing Scral Plugin

This commit is contained in:
BlubbFish 2019-02-11 16:41:29 +00:00
parent 73efe37c61
commit 13482c32c9
11 changed files with 22 additions and 6 deletions

View File

@ -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<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");
}
@ -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;

View File

@ -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
*/

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.