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

Lora-Bot 1.3.0 Scral now get its config from configfile, make the GW more stable

Lora 1.1.0 Now awaiing Battery as Double and fix the sending twise issue
parent b4742794
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,7 @@ namespace Fraunhofer.Fit.Iot.Lora.Devices {
public Boolean Fix { get; private set; }
public override String ToString() {
return "Lat: " + this.Latitude + " Lon: " + this.Longitude + "\nTime: " + this.Time + " HDOP: " + this.Hdop + " Fix: " + this.Fix;
return "Lat: " + this.Latitude + " Lon: " + this.Longitude + " -- Time: " + this.Time + " HDOP: " + this.Hdop + " Fix: " + this.Fix;
}
}
}
......@@ -17,22 +17,9 @@ namespace Fraunhofer.Fit.Iot.Lora.Devices {
public String Name { get; private set; }
public ReadOnlyDictionary<String, WlanNetwork> Wifi { get; private set; }
public GpsInfo Gps { get; private set; }
public Int32 BatteryLevel { get; private set; }
public Double BatteryLevel { get; private set; }
public LoraClient(LoraClientEvent e) {
this.PacketRssi = e.Packetrssi;
this.Rssi = e.Rssi;
this.Snr = e.Snr;
this.Receivedtime = e.UpdateTime;
}
public LoraClient(LoraClientEvent e, String data) : this(e) {
this.Parse(data);
}
public LoraClient(LoraClientEvent e, Byte[] data) : this(e) {
this.Parse(data);
}
public LoraClient() { }
private void Parse(Byte[] data) {
if (data.Length == 28) {
......@@ -77,7 +64,7 @@ namespace Fraunhofer.Fit.Iot.Lora.Devices {
}
this.Wifi = new ReadOnlyDictionary<String, WlanNetwork>(wifis);
String[] infos = texts[texts.Length - 1].Split(',');
if (infos.Length >= 5 && Int32.TryParse(infos[4], out Int32 batteryLevel)) {
if (infos.Length >= 5 && Double.TryParse(infos[4], out Double batteryLevel)) {
this.BatteryLevel = batteryLevel;
}
this.Gps = new GpsInfo(texts[texts.Length - 1]);
......@@ -85,12 +72,12 @@ namespace Fraunhofer.Fit.Iot.Lora.Devices {
}
public override String ToString() {
String ret = this.Name + "\n" + "Packet: PRssi: "+this.PacketRssi+" Rssi: "+this.Rssi+" SNR: "+this.Snr+" Time: "+this.Receivedtime.ToString() + " Battery: " + this.BatteryLevel+"\n";
ret += "WLAN:\n";
String ret = this.Name + " -- " + "Packet: PRssi: "+this.PacketRssi+" Rssi: "+this.Rssi+" SNR: "+this.Snr+" Time: "+this.Receivedtime.ToString() + " Battery: " + this.BatteryLevel+" -- ";
/*ret += "WLAN:\n";
foreach (KeyValuePair<String, WlanNetwork> item in this.Wifi) {
ret += item.ToString() + "\n";
}
ret += "GPS:\n" + this.Gps.ToString();
}*/
ret += "GPS: " + this.Gps.ToString();
return ret;
}
......@@ -133,7 +120,7 @@ namespace Fraunhofer.Fit.Iot.Lora.Devices {
return false;
}
}
if (!Regex.Match(m[4], "[0-9]+.[0-9]{5,10},[0-9]+.[0-9]{5,10},[0-9]{6},[0-9]+.[0-9]{2},[0-9]+").Success) {
if (!Regex.Match(m[4], "[0-9]+.[0-9]{5,10},[0-9]+.[0-9]{5,10},[0-9]{6},[0-9]+.[0-9]{2},[0-9].[0-9]{2}").Success) {
return false;
}
return true;
......@@ -144,7 +131,7 @@ namespace Fraunhofer.Fit.Iot.Lora.Devices {
//Console.WriteLine("Name Match Fail");
return false;
}
if (!Regex.Match(m[1], "[0-9]+.[0-9]{5,10},[0-9]+.[0-9]{5,10},[0-9]{6},[0-9]+.[0-9]{2},[0-9]+").Success) {
if (!Regex.Match(m[1], "[0-9]+.[0-9]{5,10},[0-9]+.[0-9]{5,10},[0-9]{6},[0-9]+.[0-9]{2},[0-9].[0-9]{2}").Success) {
//Console.WriteLine("GPS Match Fail");
return false;
}
......
......@@ -53,29 +53,33 @@ namespace Fraunhofer.Fit.Iot.Lora {
}
}
private void ReceivePacket(Object sender, Events.LoraClientEvent e) {
Console.WriteLine(e.Text.Length);
private void ReceivePacket(Object sender, LoraClientEvent e) {
Console.WriteLine("Fraunhofer.Fit.Iot.Lora.LoraController.ReceivePacket: " + e.Text.Length.ToString());
if (e.Text.StartsWith("b") && e.Text.Length == 27) {
Byte[] data = System.Text.Encoding.ASCII.GetBytes(e.Text);
Console.WriteLine("|" + BitConverter.ToString(data).Replace("-", " ") + "| PRSSI: " + e.Packetrssi + " RSSI:" + e.Rssi + " SNR:" + e.Snr);
Console.WriteLine("Fraunhofer.Fit.Iot.Lora.LoraController.ReceivePacket: |" + BitConverter.ToString(data).Replace("-", " ") + "| PRSSI: " + e.Packetrssi + " RSSI:" + e.Rssi + " SNR:" + e.Snr);
String deviceName = LoraClient.GetName(data);
if (this.devices.ContainsKey(deviceName)) {
this.devices[deviceName].SetUpdate(e, data);
} else {
this.devices.Add(deviceName, new LoraClient(e, data));
this.devices.Add(deviceName, new LoraClient());
this.devices[deviceName].Update += this.AllUpdate;
this.devices[deviceName].SetUpdate(e, data);
}
} else {
Console.WriteLine("|" + e.Text + "| PRSSI: " + e.Packetrssi + " RSSI:" + e.Rssi + " SNR:" + e.Snr);
Console.WriteLine("Fraunhofer.Fit.Iot.Lora.LoraController.ReceivePacket: |" + e.Text + "| PRSSI: " + e.Packetrssi + " RSSI:" + e.Rssi + " SNR:" + e.Snr);
if (LoraClient.CheckPacket(e.Text)) {
String deviceName = LoraClient.GetName(e.Text);
if (this.devices.ContainsKey(deviceName)) {
this.devices[deviceName].SetUpdate(e, e.Text);
} else {
this.devices.Add(deviceName, new LoraClient(e, e.Text));
this.devices.Add(deviceName, new LoraClient());
this.devices[deviceName].Update += this.AllUpdate;
this.devices[deviceName].SetUpdate(e, e.Text);
}
} else {
Console.WriteLine("Fraunhofer.Fit.Iot.Lora.LoraController.ReceivePacket: Packet not Match!");
}
}
}
......
......@@ -32,5 +32,9 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0")]
[assembly: AssemblyFileVersion("1.1.0")]
/*
* 1.1.0 Now awaiing Battery as Double and fix the sending twise issue
*/
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