This commit is contained in:
jomjol
2020-10-26 18:30:45 +01:00
14 changed files with 144 additions and 20 deletions

View File

@@ -22,6 +22,7 @@ static const char *MAIN_TAG = "connect_wlan";
std::string ssid;
std::string passphrase;
std::string hostname;
std::string ipaddress;
std::string std_hostname = "watermeter";
@@ -123,6 +124,7 @@ void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _ho
xEventGroupWaitBits(wifi_event_group,CONNECTED_BIT,true,true,portMAX_DELAY);
tcpip_adapter_ip_info_t ip_info;
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
ipaddress = std::string(ip4addr_ntoa(&ip_info.ip));
printf("IPv4 : %s\n", ip4addr_ntoa(&ip_info.ip));
printf("HostName : %s\n", hostname.c_str());
}
@@ -191,3 +193,14 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
}
std::string getHostname(){
return hostname;
}
std::string getIPAddress(){
return ipaddress;
}
std::string getSSID(){
return ssid;
}

View File

@@ -10,4 +10,8 @@ void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _ho
void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname);
std::string getHostname();
std::string getIPAddress();
std::string getSSID();
#endif

View File

@@ -10,6 +10,8 @@
#include "camera_define.h"
#include "driver/ledc.h"
CCamera Camera;
@@ -20,6 +22,42 @@ typedef struct {
size_t len;
} jpg_chunking_t;
///////////////////////////////////////////////////////////////////////////////////////////////////////
#define LEDC_LS_CH2_GPIO (4)
#define LEDC_LS_CH2_CHANNEL LEDC_CHANNEL_2
#define LEDC_LS_TIMER LEDC_TIMER_1
#define LEDC_LS_MODE LEDC_LOW_SPEED_MODE
#define LEDC_TEST_DUTY (4000)
void test(){
ledc_channel_config_t ledc_channel = { };
ledc_channel.channel = LEDC_LS_CH2_CHANNEL;
ledc_channel.duty = 0;
ledc_channel.gpio_num = FLASH_GPIO;
ledc_channel.speed_mode = LEDC_LS_MODE;
ledc_channel.hpoint = 0;
ledc_channel.timer_sel = LEDC_LS_TIMER;
ledc_channel_config(&ledc_channel);
ledc_set_duty(ledc_channel.speed_mode, ledc_channel.channel, LEDC_TEST_DUTY);
ledc_update_duty(ledc_channel.speed_mode, ledc_channel.channel);
vTaskDelay(1000 / portTICK_PERIOD_MS);
};
////////////////////////////////////////////////////////////////////////////////////////////////////////
static size_t jpg_encode_stream(void * arg, size_t index, const void* data, size_t len){
jpg_chunking_t *j = (jpg_chunking_t *)arg;
if(!index){

View File

@@ -404,6 +404,9 @@ void doReboot(){
LogFile.WriteToFile("Reboot - now");
KillTFliteTasks();
xTaskCreate(&task_reboot, "reboot", configMINIMAL_STACK_SIZE * 64, NULL, 10, NULL);
vTaskDelay(5000 / portTICK_PERIOD_MS);
esp_restart();
hard_restart();
}

View File

@@ -335,25 +335,23 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
Value = std::stof(zw);
if (checkDigitIncreaseConsistency)
{
// Value = checkDigitConsistency(Value, DecimalShift, isanalog);
Value = checkDigitConsistency(Value, DecimalShift, isanalog);
}
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
if ((!AllowNegativeRates) && (Value < PreValue))
{
error = "Negative Rate - Returned old value - read value: " + zwvalue;
error = error + "Negative Rate - Returned old value - read value: " + zwvalue + " ";
Value = PreValue;
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
}
else
if (useMaxRateValue && (abs(Value - PreValue) > MaxRateValue))
{
if (useMaxRateValue && (abs(Value - PreValue) > MaxRateValue))
{
error = "Rate too high - Returned old value - read value: " + zwvalue;
Value = PreValue;
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
}
error = error + "Rate too high - Returned old value - read value: " + zwvalue + " ";
Value = PreValue;
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
}
ReturnValueNoError = zwvalue;
@@ -426,7 +424,7 @@ float ClassFlowPostProcessing::checkDigitConsistency(float input, int _decilamsh
float zw;
pot = _decilamshift;
if (!_isanalog) // falls es keine analogwerte gibt, kann die letzte nicht bewerte werden
if (!_isanalog) // falls es keine analogwerte gibt, kann die letzte nicht bewertet werden
{
pot++;
}

View File

@@ -7,6 +7,8 @@
#include "time_sntp.h"
#include "connect_wlan.h"
#include "version.h"
#include "esp_wifi.h"
@@ -94,6 +96,34 @@ esp_err_t info_get_handler(httpd_req_t *req)
return ESP_OK;
}
if (_task.compare("Hostname") == 0)
{
std::string zw;
zw = std::string(getHostname());
httpd_resp_sendstr_chunk(req, zw.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
}
if (_task.compare("IP") == 0)
{
std::string zw;
zw = std::string(getIPAddress());
httpd_resp_sendstr_chunk(req, zw.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
}
if (_task.compare("SSID") == 0)
{
std::string zw;
zw = std::string(getSSID());
httpd_resp_sendstr_chunk(req, zw.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
}
return ESP_OK;
}