Is it possible to use a script to check what cards are installed in a Flexy? If so, can I load one of two configuration files from the SD card based on that?

My customer has this question:

Is there a way through scripting to see what cards are available? The reason I’m asking is we are going to offer Wi-Fi only or LAN only? We are going to be programming them through SD card. What I don’t want is an SD card for Wi-Fi and a separate one for LAN. What I want to do is on the init check for all cards and based on which one is available activate it and then start running.

Something else to think about is we could have a lot of these eventually in the field once we roll out the new product at the end of the month. If we had to update the scripting to all machines is there a way I could do it all at once instead of needing to connect to the machine, then download new file, and then disconnect? What would be my other options?

Edit: Sorry, I suppose I combined two questions into one…

@tomgiorgio

My apologies on a previously incorrect response. After some digging I was actually able to get this working just fine. We need to actually use the INF SYS section of the eWON scripting. Below you will see a script running on my Flexy201 doing exactly what you are asking for.

Once again, apologies on the previously incorrect information.

INIT SECTION:
GOTO "CheckCards"

//This is the most important part for your direct question. This is the script section that actually loads the card types.
CheckCards:
FOR x% = 1 TO 4 STEP 1
    //Format the card numbers so we can easily cycle through them all.
    cardName$ = "Xb" + STR$ x% + "PartNum"
    SETSYS INF, "LOAD"
    installedCard$ = GETSYS INF, cardName$
    @printCardType(installedCard$, "Slot #" + STR$ x%)
NEXT x%
END

//This function takes in the returned part number and prints the corresponding card type. It also takes the slot so we can see what slots have what. 
//Now additioanlly here, you can update this function to change your internet method if the card is found. 
FUNCTION printCardType($partNumber$, $slot$)
    IF($partNumber$ = "") THEN
        PRINT "No card installed"
    ENDIF
    
    //Here you can say set internet instead of a print statement. 
    IF($partNumber$ = "FLX3101_00") THEN
        PRINT $slot$ + " Ethernet Card"
    ENDIF

    IF($partNumber$ = "FLB3271_00/S") THEN
        PRINT $slot$ + " Wireless Card"
    ENDIF

   IF($partNumber$ = "FLB3202_00") THEN
       PRINT $slot$ + " GSM Card"
   ENDIF
ENDFN

End Results

After executing this on my Flexy 201 with Ethernet and Wifi installed, my prints were:

@admin-jordan
From the customer:

I thought about that option below but wanted to make the process streamlined. The approach I am trying right now is that on power up I turn on the wifi wait and check for an ip address. If this fails then turn on the LAN connection wait and check for an ip address. Is there any problems you see going this route? Below is a failover example I found on the website and this is what I am basing it off of. The only concern I have is if the card is not available then how will the Flexy react when I tell it to turn it on? Will it do nothing and return an ip address of 0.0.0.0 or will it reset the Flexy. I haven’t gotten that far in the scripting yet to see what happens.

Rem — eWON start section: Init Section
ewon_init_section:
Rem — eWON user (start)
ONTIMER 1,“goto TestVPN”
TSET 1,900
REM — WAN_ON is a MEM tag used to store the state of the Ethernet connection
WAN_ON@=1
ONTIMER 2,“goto ReturnToWAN”
TSET 2,0
Rem — eWON user (end)
End
Rem — eWON end section: Init Section

Rem — eWON start section: Fallback
Rem — eWON user (start)
TestVPN:
SETSYS INF,“load”
A$ = GETSYS INF,“VPNIP”
PRINT Time$;" “;A$
IF (A$=“0.0.0.0”) THEN
REM WAN is broken, activate Fallback
WAN_ON@=0
TSET 1,0
TSET 2,7200
SETSYS COM,“load”
SETSYS COM,“WanCnx”,1
SETSYS COM,“save”
PRINT Time$;” Fallback activated"
LOGEVENT “Fallback activated”
ELSE
WAN_ON@=1
ENDIF
END

ReturnToWAN:
TSET 2,0
SETSYS COM,“load”
SETSYS COM,“WanCnx”,2
SETSYS COM,“save”
PRINT Time$;“Fallback deactivated”
LOGEVENT “Fallback deactivated”
TSET 1,900
END
Rem — eWON user (end)
End
Rem — eWON end section: Fallback

@tomgiorgio

Please see my edit of my original post. (Post #2)

@tomgiorgio

Here is a slightly more edited version that actually switches the WAN based on the results.

Note: This may provide different results if both are installed.

CheckCards:
FOR x% = 1 TO 4 STEP 1
    //Format the card numbers so we can easily cycle through them all.
    cardName$ = "Xb" + STR$ x% + "PartNum"
    SETSYS INF, "LOAD"
    installedCard$ = GETSYS INF, cardName$
    @changeWan(installedCard$)
    NEXT x%
END

FUNCTION changeWan($partNumber$)
    i% = 0
    IF($partNumber$ = "") THEN
        PRINT "No card installed"
    ENDIF

    IF($partNumber$ = "FLX3101_00") THEN
         i% = 2
    ENDIF

    IF($partNumber$ = "FLB3271_00/S") THEN
        i% = 4

    IF($partNumber$ = "FLB3202_00") THEN
        i% = 1
    ENDIF

    SETSYS COM,"load"
    SETSYS COM,“WanCnx”,i%
    SETSYS COM, "WanPermCnx", 1
    SETSYS COM,"save"
ENDFN