Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/puara_filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void JSONSettings::update_variable_from_string(const std::string& field, const s
auto it = variables_fields.find(field);
if(it == variables_fields.end())
{
ESP_LOGW(PUARA_TAG,"Field not found in settings: %s", field);
ESP_LOGW(PUARA_TAG,"Field not found in settings: %s", field.c_str());
return;
}

Expand Down
8 changes: 4 additions & 4 deletions src/puara_littlefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ std::string PuaraFileSystem::read_file(std::string_view path)

void PuaraFileSystem::write_file(const std::string& path, const std::string& contents) {
mount();
ESP_LOGI(PUARA_TAG,"littleFS: Writing file %s", path);
ESP_LOGI(PUARA_TAG,"littleFS: Writing file %s", path.c_str());

File file = LittleFS.open(path.c_str(), FILE_WRITE);
if (!file) {
ESP_LOGE(PUARA_TAG,"LittleFS: failed to open file: %s", path);
ESP_LOGE(PUARA_TAG,"LittleFS: failed to open file: %s", path.c_str());
return;
}
if (file.print(contents.c_str())) {
ESP_LOGI(PUARA_TAG,"LittleFS: wrote %s", path);
ESP_LOGI(PUARA_TAG,"LittleFS: wrote %s", path.c_str());
} else {
ESP_LOGE(PUARA_TAG,"LittleFS: failed to write %s", path);
ESP_LOGE(PUARA_TAG,"LittleFS: failed to write %s", path.c_str());
}
ESP_LOGI(PUARA_TAG,"closing");
file.close();
Expand Down
2 changes: 1 addition & 1 deletion src/puara_mdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void MDNSService::start(std::string_view device_name, std::string_view instance_
ESP_ERROR_CHECK(mdns_hostname_set(device_name.data()));
// set default instance
ESP_ERROR_CHECK(mdns_instance_name_set(instance_name.data()));
ESP_LOGI(PUARA_TAG,"MDNS Init completed. Device name: %s", device_name);
ESP_LOGI(PUARA_TAG,"MDNS Init completed. Device name: %s", device_name.data());
std::cout << "Device wifi network : " << device_name << "\n"
<< "Open device network config/settings in browser with : http://" << device_name << ".local/"
<< std::endl;
Expand Down
10 changes: 5 additions & 5 deletions src/puara_spiffs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ std::string PuaraFileSystem::read_file(std::string_view path)
std::ifstream in(full_path);
if(!in)
{
ESP_LOGE(PUARA_TAG,"spiffs: Failed to open %s", full_path);
ESP_LOGE(PUARA_TAG,"spiffs: Failed to open %s", full_path.c_str());
return "";
}
ESP_LOGI(PUARA_TAG,"spiffs: Reading %s", full_path);
ESP_LOGI(PUARA_TAG,"spiffs: Reading %s", full_path.c_str());
std::string content((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
unmount();
return content;
Expand All @@ -99,16 +99,16 @@ std::string PuaraFileSystem::read_file(std::string_view path)
void PuaraFileSystem::write_file(const std::string& path, const std::string& contents)
{
mount();
ESP_LOGI(PUARA_TAG,"SPIFFS: Opening %s", path);
ESP_LOGI(PUARA_TAG,"SPIFFS: Opening %s", path.c_str());
FILE* f = fopen((spiffs_base_path + path).c_str(), "w");
if(!f)
{
ESP_LOGE(PUARA_TAG,"SPIFFS: Failed to open %s", path);
ESP_LOGE(PUARA_TAG,"SPIFFS: Failed to open %s", path.c_str());
return;
}

fprintf(f, "%s", contents.c_str());
ESP_LOGI(PUARA_TAG,"SPIFFS: wrote %s", path);
ESP_LOGI(PUARA_TAG,"SPIFFS: wrote %s", path.c_str());
ESP_LOGI(PUARA_TAG,"closing");
fclose(f);
unmount();
Expand Down
18 changes: 9 additions & 9 deletions src/puara_web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ esp_err_t Webserver::settings_post_handler(httpd_req_t* req)

// Decode the field name (key) to handle spaces/special chars
field = urlDecode(field);
ESP_LOGD(PUARA_TAG, "%s", field);
ESP_LOGD(PUARA_TAG, "%s", field.c_str());

// Change the value in the backend
settings.update_variable_from_string(field, str_token);

ESP_LOGD(PUARA_TAG, "%s", str_token);
ESP_LOGD(PUARA_TAG, "%s", str_token.c_str());
str_buf.erase(0, pos + delimiter.length());
}
ESP_LOGD(PUARA_TAG,"");
Expand All @@ -297,7 +297,7 @@ esp_err_t Webserver::get_handler(httpd_req_t* req)
{
const char* resp_str = (const char*)req->user_ctx;
std::string requested_path = std::string{resp_str};
ESP_LOGI(PUARA_TAG,"http : Reading requested file %s", requested_path);
ESP_LOGI(PUARA_TAG,"http : Reading requested file %s", requested_path.c_str());
std::string contents = fs.read_file(requested_path);
httpd_resp_sendstr(req, contents.c_str());

Expand Down Expand Up @@ -373,7 +373,7 @@ esp_err_t Webserver::index_post_handler(httpd_req_t* req)
switch(config_fields.at(field))
{
case 1:
ESP_LOGI(PUARA_TAG,"SSID: %s", str_token);
ESP_LOGI(PUARA_TAG,"SSID: %s", str_token.c_str());
if(!str_token.empty())
{
config.wifiSSID = urlDecode(str_token);
Expand All @@ -384,7 +384,7 @@ esp_err_t Webserver::index_post_handler(httpd_req_t* req)
}
break;
case 2:
ESP_LOGI(PUARA_TAG,"APpasswd: %s", str_token);
ESP_LOGI(PUARA_TAG,"APpasswd: %s", str_token.c_str());
if(!str_token.empty())
{
this->APpasswdVal1 = urlDecode(str_token);
Expand All @@ -396,7 +396,7 @@ esp_err_t Webserver::index_post_handler(httpd_req_t* req)
};
break;
case 3:
ESP_LOGI(PUARA_TAG,"APpasswdValidate: %s", str_token);
ESP_LOGI(PUARA_TAG,"APpasswdValidate: %s", str_token.c_str());
if(!str_token.empty())
{
this->APpasswdVal2 = urlDecode(str_token);
Expand All @@ -408,7 +408,7 @@ esp_err_t Webserver::index_post_handler(httpd_req_t* req)
};
break;
case 4:
ESP_LOGI(PUARA_TAG,"password: %s", str_token);
ESP_LOGI(PUARA_TAG,"password: %s", str_token.c_str());
if(!str_token.empty())
{
config.wifiPSK = urlDecode(str_token);
Expand All @@ -423,7 +423,7 @@ esp_err_t Webserver::index_post_handler(httpd_req_t* req)
ret_flag = true;
break;
case 6:
ESP_LOGI(PUARA_TAG,"persistentAP: %s", str_token);
ESP_LOGI(PUARA_TAG,"persistentAP: %s", str_token.c_str());
ESP_LOGI(PUARA_TAG,);
checkbox_persistentAP = true;
break;
Expand All @@ -434,7 +434,7 @@ esp_err_t Webserver::index_post_handler(httpd_req_t* req)
}
else
{
ESP_LOGE(PUARA_TAG,"Error, no match for config field to store received data: %s", field);
ESP_LOGE(PUARA_TAG,"Error, no match for config field to store received data: %s", field.c_str());
}
str_buf.erase(0, pos + delimiter.length());
}
Expand Down
10 changes: 5 additions & 5 deletions src/puara_wifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ void WiFi::wifi_init()
esp_err_t setname = esp_netif_set_hostname(ap_netif, config.dmiName.c_str());
if(setname != ESP_OK)
{
ESP_LOGE(PUARA_TAG,"wifi_init: failed to set hostname: %s", config.dmiName);
ESP_LOGE(PUARA_TAG,"wifi_init: failed to set hostname: %s", config.dmiName.c_str());
}
else
{
ESP_LOGI(PUARA_TAG,"wifi_init: hostname: %s", config.dmiName);
ESP_LOGI(PUARA_TAG,"wifi_init: hostname: %s", config.dmiName.c_str());
}

esp_event_handler_instance_t instance_any_id;
Expand Down Expand Up @@ -81,16 +81,16 @@ void WiFi::wifi_init()
* can test which event actually happened. */
if(bits & this->wifi_connected_bit)
{
ESP_LOGI(PUARA_TAG,"wifi_init: Connected to SSID: %s", config.wifiSSID);
ESP_LOGI(PUARA_TAG,"wifi_init: Connected to SSID: %s", config.wifiSSID.c_str());
currentSSID = config.wifiSSID;
this->StaIsConnected = true;
}
else if(bits & this->wifi_fail_bit)
{
ESP_LOGW(PUARA_TAG,"wifi_init: Failed to connect to SSID: %s", config.wifiSSID);
ESP_LOGW(PUARA_TAG,"wifi_init: Failed to connect to SSID: %s", config.wifiSSID.c_str());
if(!config.persistentAP)
{
ESP_LOGW(PUARA_TAG,"wifi_init: Failed to connect to SSID: %s", config.wifiSSID);
ESP_LOGW(PUARA_TAG,"wifi_init: Failed to connect to SSID: %s", config.wifiSSID.c_str());
ESP_LOGI(PUARA_TAG,"Switching to AP/STA mode");
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA));
ESP_LOGI(PUARA_TAG,"wifi_init: loading AP config");
Expand Down