mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 20:46:52 +03:00
Bug fix, Hostname
This commit is contained in:
@@ -29,7 +29,12 @@ A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### Rolling - (2020-09-13)
|
##### Rolling - (2020-09-14)
|
||||||
|
|
||||||
|
* Implementation of hostname in wlan.ini (`hostname = "HOSTNAME")` - Parameter is optional
|
||||||
|
* Bug correction DecimalShift
|
||||||
|
|
||||||
|
2020-09-13
|
||||||
|
|
||||||
* Bug fixing DecimalShift (digits after comma)
|
* Bug fixing DecimalShift (digits after comma)
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialise_wifi(std::string _ssid, std::string _passphrase)
|
void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _hostname)
|
||||||
{
|
{
|
||||||
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL) );
|
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL) );
|
||||||
wifi_event_group = xEventGroupCreate();
|
wifi_event_group = xEventGroupCreate();
|
||||||
@@ -123,10 +123,11 @@ void initialise_wifi(std::string _ssid, std::string _passphrase)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase)
|
void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname)
|
||||||
{
|
{
|
||||||
string line = "";
|
string line = "";
|
||||||
std::vector<string> zerlegt;
|
std::vector<string> zerlegt;
|
||||||
|
_hostname = "iciruit";
|
||||||
|
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
fn = FormatFileName(fn);
|
fn = FormatFileName(fn);
|
||||||
@@ -146,12 +147,21 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
|
|||||||
zerlegt = ZerlegeZeile(line, "=");
|
zerlegt = ZerlegeZeile(line, "=");
|
||||||
zerlegt[0] = trim(zerlegt[0], " ");
|
zerlegt[0] = trim(zerlegt[0], " ");
|
||||||
zerlegt[1] = trim(zerlegt[1], " ");
|
zerlegt[1] = trim(zerlegt[1], " ");
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
|
||||||
|
_hostname = zerlegt[1];
|
||||||
|
if ((_hostname[0] == '"') && (_hostname[_hostname.length()-1] == '"')){
|
||||||
|
_hostname = _hostname.substr(1, _hostname.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "SSID")){
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "SSID")){
|
||||||
_ssid = zerlegt[1];
|
_ssid = zerlegt[1];
|
||||||
if ((_ssid[0] == '"') && (_ssid[_ssid.length()-1] == '"')){
|
if ((_ssid[0] == '"') && (_ssid[_ssid.length()-1] == '"')){
|
||||||
_ssid = _ssid.substr(1, _ssid.length()-2);
|
_ssid = _ssid.substr(1, _ssid.length()-2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "PASSWORD")){
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "PASSWORD")){
|
||||||
_passphrase = zerlegt[1];
|
_passphrase = zerlegt[1];
|
||||||
if ((_passphrase[0] == '"') && (_passphrase[_passphrase.length()-1] == '"')){
|
if ((_passphrase[0] == '"') && (_passphrase[_passphrase.length()-1] == '"')){
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
const int CONNECTED_BIT = BIT0;
|
const int CONNECTED_BIT = BIT0;
|
||||||
|
|
||||||
void initialise_wifi(std::string _ssid, std::string _passphrase);
|
void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _hostname);
|
||||||
|
|
||||||
void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase);
|
void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -230,7 +230,7 @@ std::string ClassFlowControll::UpdatePrevalue(std::string _newvalue)
|
|||||||
if (flowpostprocessing)
|
if (flowpostprocessing)
|
||||||
{
|
{
|
||||||
flowpostprocessing->SavePreValue(zw);
|
flowpostprocessing->SavePreValue(zw);
|
||||||
return _newvalue;
|
return to_string(zw);
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ string ClassFlowPostProcessing::GetPreValue()
|
|||||||
{
|
{
|
||||||
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
|
||||||
{
|
{
|
||||||
int AnzahlNachkomma = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
|
int AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
|
||||||
result = RundeOutput(PreValue, AnzahlNachkomma - DecimalShift);
|
result = RundeOutput(PreValue, AnzahlAnalog - DecimalShift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,8 +78,8 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
|
|||||||
{
|
{
|
||||||
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
|
||||||
{
|
{
|
||||||
int AnzahlNachkomma = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
|
int AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
|
||||||
ReturnValue = RundeOutput(Value, AnzahlNachkomma - DecimalShift);
|
ReturnValue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
|
||||||
ReturnValueNoError = ReturnValue;
|
ReturnValueNoError = ReturnValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,7 +262,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
string zwvalue;
|
string zwvalue;
|
||||||
bool isdigit = false;
|
bool isdigit = false;
|
||||||
bool isanalog = false;
|
bool isanalog = false;
|
||||||
int AnzahlNachkomma = 0;
|
int AnzahlAnalog = 0;
|
||||||
string zw;
|
string zw;
|
||||||
string error = "";
|
string error = "";
|
||||||
time_t imagetime = 0;
|
time_t imagetime = 0;
|
||||||
@@ -282,7 +282,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
{
|
{
|
||||||
isanalog = true;
|
isanalog = true;
|
||||||
analog = (*ListFlowControll)[i]->getReadout();
|
analog = (*ListFlowControll)[i]->getReadout();
|
||||||
AnzahlNachkomma = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
|
AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,6 +329,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (isdigit)
|
if (isdigit)
|
||||||
{
|
{
|
||||||
int lastanalog = -1;
|
int lastanalog = -1;
|
||||||
@@ -342,15 +343,19 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
zw = zw + ".";
|
zw = zw + ".";
|
||||||
if (isanalog)
|
if (isanalog)
|
||||||
zw = zw + analog;
|
zw = zw + analog;
|
||||||
|
zw = ShiftDecimal(zw, DecimalShift);
|
||||||
|
*/
|
||||||
|
|
||||||
|
zw = ErsetzteN(ReturnRawValue);
|
||||||
|
|
||||||
Value = std::stof(zw);
|
Value = std::stof(zw);
|
||||||
zwvalue = RundeOutput(Value, AnzahlNachkomma - DecimalShift);
|
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
|
||||||
|
|
||||||
if ((!AllowNegativeRates) && (Value < PreValue))
|
if ((!AllowNegativeRates) && (Value < PreValue))
|
||||||
{
|
{
|
||||||
error = "Negative Rate - Returned old value - read value: " + zwvalue;
|
error = "Negative Rate - Returned old value - read value: " + zwvalue;
|
||||||
Value = PreValue;
|
Value = PreValue;
|
||||||
zwvalue = RundeOutput(Value, AnzahlNachkomma - DecimalShift);
|
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -358,7 +363,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
{
|
{
|
||||||
error = "Rate too high - Returned old value - read value: " + zwvalue;
|
error = "Rate too high - Returned old value - read value: " + zwvalue;
|
||||||
Value = PreValue;
|
Value = PreValue;
|
||||||
zwvalue = RundeOutput(Value, AnzahlNachkomma - DecimalShift);
|
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,18 +399,27 @@ string ClassFlowPostProcessing::RundeOutput(float _in, int _anzNachkomma){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string ClassFlowPostProcessing::ErsetzteN(string input, int lastvalueanalog = -1)
|
string ClassFlowPostProcessing::ErsetzteN(string input)
|
||||||
{
|
{
|
||||||
int posN, posPunkt;
|
int posN, posPunkt;
|
||||||
int pot, ziffer;
|
int pot, ziffer;
|
||||||
float zw;
|
float zw;
|
||||||
|
|
||||||
posN = findDelimiterPos(input, "N");
|
posN = findDelimiterPos(input, "N");
|
||||||
|
posPunkt = findDelimiterPos(input, ".");
|
||||||
|
if (posPunkt == std::string::npos){
|
||||||
posPunkt = input.length();
|
posPunkt = input.length();
|
||||||
|
}
|
||||||
|
|
||||||
while (posN != std::string::npos)
|
while (posN != std::string::npos)
|
||||||
{
|
{
|
||||||
|
if (posN < posPunkt) {
|
||||||
pot = posPunkt - posN - 1;
|
pot = posPunkt - posN - 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pot = posPunkt - posN;
|
||||||
|
}
|
||||||
|
|
||||||
zw = PreValue / pow(10, pot);
|
zw = PreValue / pow(10, pot);
|
||||||
ziffer = ((int) zw) % 10;
|
ziffer = ((int) zw) % 10;
|
||||||
input[posN] = ziffer + 48;
|
input[posN] = ziffer + 48;
|
||||||
@@ -413,13 +427,11 @@ string ClassFlowPostProcessing::ErsetzteN(string input, int lastvalueanalog = -1
|
|||||||
posN = findDelimiterPos(input, "N");
|
posN = findDelimiterPos(input, "N");
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////// TestCode
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
string ClassFlowPostProcessing::checkDigitConsistency(string input, int _decilamshift, int lastvalueanalog){
|
||||||
/*
|
/*
|
||||||
input = "10";
|
|
||||||
posPunkt = input.length();
|
|
||||||
PreValue = 9.5;
|
|
||||||
lastvalueanalog = 7;
|
|
||||||
*/
|
|
||||||
if (checkDigitIncreaseConsistency && lastvalueanalog > -1)
|
if (checkDigitIncreaseConsistency && lastvalueanalog > -1)
|
||||||
{
|
{
|
||||||
int zifferIST;
|
int zifferIST;
|
||||||
@@ -450,7 +462,7 @@ string ClassFlowPostProcessing::ErsetzteN(string input, int lastvalueanalog = -1
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ protected:
|
|||||||
bool LoadPreValue(void);
|
bool LoadPreValue(void);
|
||||||
string ShiftDecimal(string in, int _decShift);
|
string ShiftDecimal(string in, int _decShift);
|
||||||
|
|
||||||
string ErsetzteN(string, int lastvalueanalog);
|
string ErsetzteN(string);
|
||||||
|
string checkDigitConsistency(string, int _decilamshift, int lastvalueanalog = -1);
|
||||||
string RundeOutput(float _in, int _anzNachkomma);
|
string RundeOutput(float _in, int _anzNachkomma);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -113,11 +113,13 @@ extern "C" void app_main()
|
|||||||
LogFile.WriteToFile("Startsequence 03");
|
LogFile.WriteToFile("Startsequence 03");
|
||||||
std::string ssid = "";
|
std::string ssid = "";
|
||||||
std::string password = "";
|
std::string password = "";
|
||||||
LoadWlanFromFile("/sdcard/wlan.ini", ssid, password);
|
std::string hostname = "";
|
||||||
|
|
||||||
|
LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname);
|
||||||
LogFile.WriteToFile("Startsequence 04");
|
LogFile.WriteToFile("Startsequence 04");
|
||||||
printf("WLan: %s, %s\n", ssid.c_str(), password.c_str());
|
printf("WLan: %s, %s\n", ssid.c_str(), password.c_str());
|
||||||
|
|
||||||
initialise_wifi(ssid, password);
|
initialise_wifi(ssid, password, hostname);
|
||||||
LogFile.WriteToFile("Startsequence 05");
|
LogFile.WriteToFile("Startsequence 05");
|
||||||
|
|
||||||
TickType_t xDelay;
|
TickType_t xDelay;
|
||||||
|
|||||||
Binary file not shown.
@@ -1,2 +1,4 @@
|
|||||||
ssid = "SSID"
|
ssid = "SSID"
|
||||||
password = "PASSWORD"
|
password = "PASSWORD"
|
||||||
|
hostname = "watermeter"
|
||||||
|
;hostname is optional
|
||||||
Reference in New Issue
Block a user