Hi together,
thanks for the discussion and hints. Well, with that knowledge I was able to write my own solution based on an array:
String ArrayToString(byte *vAdressOfArray, int vPositionInArray)
{
int i = 0;
String vArrayContent;
while(i<vPositionInArray)
{
vArrayContent = vArrayContent +String("|")+ String(*(vAdressOfArray + i));
i++;
}
//Debugging
Serial.print("Read from vArrayContent: ");
Serial.println(vArrayContent);
return vArrayContent;
}
(Hint: Also the delimiter ("|") and the start position (i) could be easily included in the method parameters, if needed.)
I call the function on browser request:
server.on("/ArrayHistTemperature", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/plain", String(ArrayToString(HistTemperature, vHistTemperature_PositionInArray)).c_str());
});
HERE I would like to add the possibility to call different arrays. E.g. HistHumidity. Or even define the start and end position of the 'array reading' by the browser request.
e.g. server.on("/Array<HistTemperature><0><50>", HTTP_GET, ...
-> And the microcontroller Returns the Array from Position 0 till 50.
That's why I was asking the Question in "Posted by noyen
But if I can't split the name of the html request (currently: "/ArrayHistTemperature") I need to write several functions:
- one request, that returns the complete array (initial load)
- one for the incremente (delta load)
- and one read just the array header, to get several settings (data history start date and time, intervall, array length)
Currently I hace 3 data vales -> 3 Arrays -> 9 functions. Possible, but it's limited.
By the way, if someone would like to use this sketch: In the html file I just call that function in a 10s intervall:
setInterval(function ( )
{
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("ArrayHistTemperature").innerHTML = this.responseText;
}
};
xhttp.open("GET", "/ArrayHistTemperature", true);
xhttp.send();
}, 10000 ) ;
So still, if someone knows a hint, how to solve the issue I mentioned in my first post, it would help, to improve this method, wich could by used by a lot of projects I guess.
Best regards
Noyen