Skip to content
Snippets Groups Projects
Commit 13482c32 authored by philip.schell's avatar philip.schell
Browse files

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

parent 73efe37c
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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
*/
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment