Community discussions

MikroTik App
 
User avatar
Amm0
Forum Guru
Forum Guru
Topic Author
Posts: 4531
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Interactively parsing eSIM Activation from LPA in QRCode...

Fri Feb 21, 2025 9:36 pm

In 7.18, there are new eSIM commands & new serialize/deserialize fixes. While I have no idea what modems or hardware supports them. But from a discussion in another thread about eSIM support, I cleaned the example to using "ask" to prompt for the needed information.

eSIM prompted activation code

:global activateEsimFromQr do={
    :local samplelpa "LPA:1\$EXAMPLE.COM\$XYZ123\$\$1\$\$"
    :local qrlpa [/terminal/ask "eSIM activation code (decoded from QR):" preinput=$samplelpa]
    :local activationcode
    :local parsedlpa ([:deserialize from=dsv delimiter="\$" $qrlpa options=dsv.plain]->0)
    :if ([:len $parsedlpa]<3) do={ :error "ERROR - invalid eSIM activation code" }
    :put "\tparsed:"
    :put [:serialize to=json $parsedlpa options=json.pretty]
    :if (($parsedlpa->4) = 1) do={
        :set activationcode [/terminal/ask "Confirmation Code Required (provided by eSIM carrier):" ]
        :put "The esim provision (no confirmation code required) command should be:"
        :put "/interface/lte/esim/provision interface=[find] sm-dp-plus=\"$($parsedlpa->1)\" matching-id=\"$($parsedlpa->2)\" confirmation-code=\"$activationcode\""
    } else={
        :put "The esim provision with confirmation code command should be:"
        :put "/interface/lte/esim/provision interface=[find] sm-dp-plus=\"$($parsedlpa->1)\" matching-id=\"$($parsedlpa->2)\""
    }
}
[amm0@bigdude] > $activateEsimFromQr
eSIM activation code (decoded from QR):
LPA:1$EXAMPLE.COM$XYZ123$$1$$
parsed:
[
"LPA:1",
"EXAMPLE.COM",
"XYZ123",
"",
1,
"",
""
]
Confirmation Code Required (provided by eSIM carrier):
jhjhkhd
The esim provision (no confirmation code required) command should be:
/interface/lte/esim/provision interface=[find] sm-dp-plus="EXAMPLE.COM" matching-id="XYZ123" confirmation-code="jhjhkhd"
[amm0@bigdude] > $activateEsimFromQr
eSIM activation code (decoded from QR):
LPA:1$EXAMPLE.COM$XYZ123$
parsed:
[
"LPA:1",
"EXAMPLE.COM",
"XYZ123",
""
]
The esim provision with confirmation code command should be:
/interface/lte/esim/provision interface=[find] sm-dp-plus="EXAMPLE.COM" matching-id="XYZ123"

Now what modem support those commands, IDK. And annoyed about that part. But the [:serialize] / [:deserialize] / [/terminal/ask] do make quick work of the, theoretical, problem — especially using a CLI with strings that contain $ — which eSIM activations do. i.e. "LPA:1$example.com$abc$123", and the spec uses a dollar sign $ as a separator, instead of a , comma or something normal.