I use this function to send some info to online DB : void SendLogToOnlineDB (const…
- User
I use this function to send some info to online DB :
void Send_Log_To_Online_DB (const String& msg_type, const String& PIR_id){
is_server_log_sending = true; if ((millis() - start_log_sending_millis) > 10000){ start_log_sending_millis = millis();
codeWiFiClientSecure clientSecure; clientSecure.setInsecure(); if (clientSecure.connect(serverAddress, serverPort)) { String content = ""; String http_url = ""; if (msg_type == "socket_problem" || msg_type == "security_problem" || msg_type == "therm_problem"){ http_url = "/Feriot/api/insert_error_log.php"; content = "api_key="; content += String(api_key_value); content += "&master_id="; content += id; if (msg_type == "security_problem"){ content += "&sensor_id="; content += PIR_id.substring(0,4); content += "&error_code="; content += "1"; } else if (msg_type == "socket_problem"){ content += "&sensor_id="; content += "Socket"; content += "&error_code="; content += "1"; } else if (msg_type == "therm_problem"){ content += "&sensor_id="; content += "Thermostat"; content += "&error_code="; content += "1"; } } else if (msg_type == "motion" || msg_type == "door_open"){ http_url = "/Feriot/api/insert_motion_log.php"; content = "api_key="; content += String(api_key_value); content += "&master_id="; content += id; content += "&pir_id="; content += PIR_id.substring(0,4); } HTTPClient http; http.begin(clientSecure, serverAddress, serverPort, http_url); http.addHeader(F("Content-Type"), F("application/x-www-form-urlencoded")); //http.addHeader("Content-Type", "application/json"); //http.addHeader("Content-Length", String(strlen(content))); //http.setTimeout(15000); int httpResponseCode = http.POST(content); if (httpResponseCode > 0) { task_buffer[task_index].is_log_send = true; Serial2.println("<Log Send Successfully>"); } else { Serial2.println("<Send_Log_To_Online_DB_Error_Response : " + String(httpResponseCode) + " " + http.getString() + ">"); } http.end(); } else { Serial2.println("<Send_Log_To_Online_DB - clientSecure.connect failed>"); } clientSecure.stop(); - Assistant
- User
clientSecure.lastError RETURNS -32512
- Assistant
- User
how can free up resources or reduce memory usage to ensure there’s enough free heap for SSL/TLS operations?
- Assistant
- User
if i send my sketch, can you convert all string variables to char[]?
- Assistant
- User
my sketch is about 4000 lines and convert can be difficult. can you convert it?
- Assistant