Skip to content

Commit

Permalink
add connection status info
Browse files Browse the repository at this point in the history
  • Loading branch information
SK21 committed Feb 14, 2024
1 parent a0821e7 commit 69d2170
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Modules/Teensy Rate/RCteensy/RCteensy.vcxproj

Large diffs are not rendered by default.

21 changes: 15 additions & 6 deletions Modules/Teensy Rate/RCteensy/Send.ino
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ void SendData()
// status
// bit 0 - sensor 0 receiving rate controller data
// bit 1 - sensor 1 receiving rate controller data
// bit 2 wifi signal < -80
// bit 3 wifi signal < -70
// bit 4 wifi signal > -80
// bit 5 wifi connected
// bit 6 ethernet connected

Data[11] = 0;
if (millis() - Sensor[0].CommTime < 4000) Data[11] |= 0b00000001;
if (millis() - Sensor[1].CommTime < 4000) Data[11] |= 0b00000010;
Expand All @@ -74,8 +80,11 @@ void SendData()
{
Data[11] |= 0b00010000;
}
Data[11] |= 0b00100000;
}

if (Ethernet.linkStatus() == LinkON) Data[11] |= 0b01000000;

// crc
Data[12] = CRC(Data, 12, 0);

Expand All @@ -88,21 +97,21 @@ void SendData()
}
else
{
// send wifi
SerialESP->write(Data, 13);

if (millis() - ESPtime > 4000)
{
// send serial, wifi not connected
//if (millis() - ESPtime > 4000)
//{
// // send serial, wifi not connected
Serial.print(Data[0]);
for (int i = 1; i < 13; i++)
{
Serial.print(",");
Serial.print(Data[i]);
}
Serial.println("");
}
//}
}
// send wifi
SerialESP->write(Data, 13);
}

//PGN32401, module, analog info from module to RC
Expand Down
6 changes: 6 additions & 0 deletions Modules/Wifi/WifiRC/WifiRC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ void Blink()
Serial.print("Micros: ");
Serial.print(MaxLoopTime);

Serial.print(", ");
Serial.print(WiFi.RSSI());

Serial.print(", ");
Serial.print(WiFi.status() == WL_CONNECTED);

Serial.println("");

if (ResetRead++ > 10)
Expand Down
2 changes: 1 addition & 1 deletion Modules/Wifi/WifiRC/WifiRC.vcxproj

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions RateAppSource/RateController/Classes/clsTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -518,17 +518,27 @@ public string VersionDate()
return cVersionDate;
}

public void WriteActivityLog(string Message, bool Newline = false)
public void WriteActivityLog(string Message, bool Newline = false, bool NoDate=false)
{
string Line = "";
string DF;
try
{
string FileName = cSettingsDir + "\\Activity Log.txt";
TrimFile(FileName);

if (Newline) Line = "\r\n";

File.AppendAllText(FileName, Line + DateTime.Now.ToString("MMM-dd hh:mm:ss") + " - " + Message + "\r\n");
if(NoDate)
{
DF = "hh:mm:ss";
}
else
{
DF = "MMM-dd hh:mm:ss";
}

File.AppendAllText(FileName, Line + DateTime.Now.ToString(DF) + " - " + Message + "\r\n");
}
catch (Exception ex)
{
Expand Down
2 changes: 2 additions & 0 deletions RateAppSource/RateController/FormStart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ private void FormRateControl_FormClosed(object sender, FormClosedEventArgs e)
timerMain.Enabled = false;
timerNano.Enabled = false;
timerPIDs.Enabled = false;
Tls.WriteActivityLog("Stopped", true);
}
catch (Exception)
{
Expand Down Expand Up @@ -885,6 +886,7 @@ private void FormStart_Load(object sender, EventArgs e)
Close();
}
SetLanguage();
Tls.WriteActivityLog("Started", true);
}

private void frenchToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down
37 changes: 33 additions & 4 deletions RateAppSource/RateController/PGNs/PGN32400.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public class PGN32400
private bool LastModuleSending;
private bool LastModuleReceiving;
private DateTime ReceiveTime;
private bool cEthernetConnected;
private bool cWifiConnected;
private bool LastEthernetConnected;
private bool LastWifiConnected;
private byte cWifiStrength;
private byte cLastStrength;

public PGN32400(clsProduct CalledFrom)
{
Expand All @@ -48,19 +54,40 @@ public double AccumulatedQuantity()
{
return cQuantity;
}

public bool EthernetConnected { get { return cEthernetConnected; } }
public bool WifiConnected { get { return cWifiConnected; } }
public void CheckModuleComm()
{
string Mes;
if (LastModuleSending != ModuleSending())
{
LastModuleSending = ModuleSending();
Prod.mf.Tls.WriteActivityLog("Module: " + Prod.ModuleID + " Sensor: " + Prod.SensorID + " Sending: " + ModuleSending().ToString(),true);
Mes = "Module:" + Prod.ModuleID + " Sensor:" + Prod.SensorID + " Sending: " + ModuleSending().ToString();

Prod.mf.Tls.WriteActivityLog(Mes, false, true);
}

if(LastModuleReceiving != ModuleReceiving())
{
LastModuleReceiving= ModuleReceiving();
Prod.mf.Tls.WriteActivityLog("Module: " + Prod.ModuleID + " Sensor: " + Prod.SensorID + " Receiving: " + ModuleReceiving().ToString(), true);
Mes = "Module:" + Prod.ModuleID + " Sensor:" + Prod.SensorID + " Receiving: " + ModuleReceiving().ToString();

Prod.mf.Tls.WriteActivityLog(Mes, false, true);
}

if(LastEthernetConnected!=cEthernetConnected)
{
LastEthernetConnected= cEthernetConnected;
Mes = "Ethernet connected: " + cEthernetConnected.ToString();
Prod.mf.Tls.WriteActivityLog(Mes, false, true);
}

if (LastWifiConnected != cWifiConnected || cLastStrength!=cWifiStrength)
{
LastWifiConnected = cWifiConnected;
cLastStrength = cWifiStrength;
Mes = "Wifi connected: " + cWifiConnected.ToString() + " Strength: " + cWifiStrength.ToString();
Prod.mf.Tls.WriteActivityLog(Mes, false, true);
}
}

Expand Down Expand Up @@ -105,7 +132,6 @@ public bool ModuleSending()
public bool ParseByteData(byte[] Data)
{
bool Result = false;
byte cWifiStrength;

if (Data[1] == HeaderHi && Data[0] == HeaderLo &&
Data.Length >= cByteCount && Prod.mf.Tls.GoodCRC(Data))
Expand Down Expand Up @@ -142,6 +168,9 @@ public bool ParseByteData(byte[] Data)
if ((Data[11] & 0b00010000) == 0b00010000) cWifiStrength = 3;
Prod.WifiStrength = cWifiStrength;

cWifiConnected = ((Data[11] & 0b00100000) == 0b00100000);
cEthernetConnected = ((Data[11] & 0b01000000) == 0b01000000);

ReceiveTime = DateTime.Now;
Result = true;
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified RateAppSource/RateController/obj/Debug/RateController.exe
Binary file not shown.
Binary file modified RateAppSource/RateController/obj/Debug/RateController.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified RateControllerApp/RateController.exe
Binary file not shown.
Binary file modified RateControllerApp/de/RateController.resources.dll
Binary file not shown.
Binary file modified RateControllerApp/fr/RateController.resources.dll
Binary file not shown.
Binary file modified RateControllerApp/hu/RateController.resources.dll
Binary file not shown.
Binary file modified RateControllerApp/nl/RateController.resources.dll
Binary file not shown.
Binary file modified RateControllerApp/pl/RateController.resources.dll
Binary file not shown.
Binary file modified RateControllerApp/ru/RateController.resources.dll
Binary file not shown.

0 comments on commit 69d2170

Please sign in to comment.