configure-otaa

wayland/m5stack-unit-lorawan/configure-otaa

Configure Over The Air Authentication (OTAA).
configure-otaa
@/configure-otaa
Configure Over The Air Authentication (OTAA).
DEV@/lorawan-device
A lorawan-device.
D_EUIstring
Device EUI
J_EUIstring
Join EUI (formerly called Application EUI).
A_Keystring
Application Key.
Modestring
Upload/download same/different frequency. 1 = same frequency mode; 2 = different frequency mode.
UPDpulse
Update
configure-otaa
DEV
D_EUI
J_EUI
A_Key
Mode
UPD
Done
Donepulse
Pulse on configuration completed.
To use the node in your project you should have the wayland/m5stack-unit-lorawan 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) {
        if (!isInputDirty<input_UPD>(ctx))
            return;

        auto LoRaWAN = getValue<input_DEV>(ctx);
        auto xDevEUI = getValue<input_D_EUI>(ctx);
        auto xAppEUI = getValue<input_J_EUI>(ctx);
        auto xAppKey = getValue<input_A_Key>(ctx);
        auto xMode = getValue<input_Mode>(ctx);

        int N=length(xDevEUI)+1;
        char cDevEUI[N];
        for(int i=0;i<N;i++)
            cDevEUI[i]=0;
        dump(xDevEUI, cDevEUI);

        N=length(xAppEUI)+1;
        char cAppEUI[N];
        for(int i=0;i<N;i++)
            cAppEUI[i]=0;
        dump(xAppEUI, cAppEUI);

        N=length(xAppKey)+1;
        char cAppKey[N];
        for(int i=0;i<N;i++)
            cAppKey[i]=0;
        dump(xAppKey, cAppKey);

        N=length(xMode)+1;
        char cMode[N];
        for(int i=0;i<N;i++)
            cMode[i]=0;
        dump(xMode, cMode);

        LoRaWAN->configOTTA(cDevEUI, cAppEUI, cAppKey, cMode);

        emitValue<output_Done>(ctx, 1);
    }
}