begin

wayland/esp32-preferences/begin

Opens storage with specified namespace. If RO (read only) is set to false, then storage will be opened in read/write mode. If namespace does not exist, then it will be created if RO is set to False. If namespace does not exist and RO is set to True, then the node will raise an error.
begin
@/begin
Opens storage with specified namespace. If RO (read only) is set to false, then storage will be opened in read/write mode. If namespace does not exist, then it will be created if RO is set to False. If namespace does not exist and RO is set to True, then the node will raise an error.
Prefs@/preferences
A preferences object.
Namestring
Namespace name. Limited to 15 chars.
ROboolean
Open storage read only.
UPDpulse
Update.
begin
Prefs
Name
RO
UPD
Done
Donepulse
Pulse when namespace opened.
To use the node in your project you should have the wayland/esp32-preferences library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD

node {

    void evaluate(Context ctx) {
        // The node responds only if there is an input pulse
        if (!isInputDirty<input_UPD>(ctx))
            return;
        auto prefs = getValue<input_Prefs>(ctx);
        auto xStringName = getValue<input_Name>(ctx);
        auto ro = getValue<input_RO>(ctx);

        int N=length(xStringName);
        if (N>15 || N<1) {
            raiseError(ctx);
            return;
        }
        N +=1;
        char cStringName[N];
        for(int i=0;i<N;i++)
            cStringName[i]=0;
        dump(xStringName, cStringName);

        if (!prefs -> begin(cStringName, ro)) {
            raiseError(ctx);
            return;
        }
        
        emitValue<output_Done>(ctx, 1);

    }
}