Hi,
Ilias, I would like your opinion on my approach
I want to use the ESP32 in AP mode to initialize STA mode. So I synchronize text variables (conversions of char SSID and char password).
As Virtuino 6 allows to declare text variables T[], to synchronyse them i have declared an array of String :
String T[10]; // array for 10 text values
This allows enums, easy to use in the code than V40, V41... as text :
enum ePinsAP {
eButtonValid = 0, // Virtuino virtual V Memory V[0]
eSsidNetwork = 1, // Virtuino virtual T Memory T[1]
ePwNetWork = 2,
};
... Setup ...
V[eButtonValid] = 0; // Valid SSID_STA
T[eSsidNetwork] = "";
T[ePwNetWork] = "";
So I added an "if (variableType == 'T')" test in the onReceived and onRequested functions :
void onReceived(char variableType, uint8_t variableIndex, String valueAsText) {
if (variableType == 'V') {
// Modified to take case of text values
// float value = valueAsText.toFloat(); // convert the value to float. The valueAsText have to be numerical
if (variableIndex < V_memory_count) {
float value = valueAsText.toFloat(); // convert the value to float. The valueAsText have to be numerical
V[variableIndex] = value; // copy the received value to arduino V memory array
}
// else if (variableIndex == 40) V40 = valueAsText;
// ..
}
if (variableType == 'T') {
T[variableIndex] = valueAsText;
}
}
String onRequested(char variableType, uint8_t variableIndex) {
if (variableType == 'V') {
if (variableIndex < V_memory_count) return String(V[variableIndex]); // return the value of the arduino V memory array
// else if (variableIndex == 40) return V40; // return the value of the V0 variable
//..
}
if (variableType == 'T') {
return T[variableIndex];
}
return "";
}
It works well. But I read that you don't recommend using T[] variables.
Will you remove them in future versions of virtuino 6 ?
For this use, i would be disappointed.
Thanks for your opinion.
Denis
Ilias, I would like your opinion on my approach
I want to use the ESP32 in AP mode to initialize STA mode. So I synchronize text variables (conversions of char SSID and char password).
As Virtuino 6 allows to declare text variables T[], to synchronyse them i have declared an array of String :
String T[10]; // array for 10 text values
This allows enums, easy to use in the code than V40, V41... as text :
enum ePinsAP {
eButtonValid = 0, // Virtuino virtual V Memory V[0]
eSsidNetwork = 1, // Virtuino virtual T Memory T[1]
ePwNetWork = 2,
};
... Setup ...
V[eButtonValid] = 0; // Valid SSID_STA
T[eSsidNetwork] = "";
T[ePwNetWork] = "";
So I added an "if (variableType == 'T')" test in the onReceived and onRequested functions :
void onReceived(char variableType, uint8_t variableIndex, String valueAsText) {
if (variableType == 'V') {
// Modified to take case of text values
// float value = valueAsText.toFloat(); // convert the value to float. The valueAsText have to be numerical
if (variableIndex < V_memory_count) {
float value = valueAsText.toFloat(); // convert the value to float. The valueAsText have to be numerical
V[variableIndex] = value; // copy the received value to arduino V memory array
}
// else if (variableIndex == 40) V40 = valueAsText;
// ..
}
if (variableType == 'T') {
T[variableIndex] = valueAsText;
}
}
String onRequested(char variableType, uint8_t variableIndex) {
if (variableType == 'V') {
if (variableIndex < V_memory_count) return String(V[variableIndex]); // return the value of the arduino V memory array
// else if (variableIndex == 40) return V40; // return the value of the V0 variable
//..
}
if (variableType == 'T') {
return T[variableIndex];
}
return "";
}
It works well. But I read that you don't recommend using T[] variables.
Will you remove them in future versions of virtuino 6 ?
For this use, i would be disappointed.
Thanks for your opinion.
Denis