Hi. I'm facing issues while inserting SIM into mPCIe based modem. It is not automatically connected to the Internet. I either need to restart the router or to apply AT command to reset the modem.
Is there any hotplug.d event or any other way I can apply the AT+CFUN=0 and AT+CFUN=1 command when SIM is inserted to reset the modem so it will automatically connect without any user interference.
Hey, you can create a script in /etc/hotplug.d/ to do this.
If you are compiling your own image you can add this to target/linux/(arch) /base-files/etc/hotplug.d/
Are you sure your modem supports SIM hotplug with a dedicated pin in slot connected to the modem (inserting SIM when device is powered)? Usually, when modem is powered, SIM detection is performed only once. If SIM doesn't answer (see: https://en.wikipedia.org/wiki/Answer_to_reset), modem disables power supply in slot.
No.
Of course, you can write a small app which would listen on AT port (or MBIM/QMI) for SIM events sent by modem but still, if your modem doesn't support SIM hotplug it just won't work or you would need to (somehow) re-initialize SIM slot manually.
And you won't, you should look into modem and your host (where modem is plugged in) datasheets. And, as I can see now that you are using miniPCIe modems, you should be aware that they usually don't support SIM hotplug as the Mini Card interface doesn't define pin for SIM detection (SIM in slot).
And probably stop swapping SIM cards when device is running... if your platform lacks protection on SIM signal lines (yep, I have seen cheap solutions like that), you might break something with ESD.
This device is used to give remote site connectivity and have multiple SIM slots so if one stop working for whatever reason we cannot restart the device. So the hot swap functionality is very important there.
How do you switch between different SIM slots, GPIO? You might look at AT+CFUN command and use it between switching SIMs. For example, Quectel modems support SIM power down/up using QMI commands - you can switch SIM card quickly, without need for resetting whole modem.
I'm using AT+CFUN to reset the modem. In Luci interface, I've provided reset button so when someone insert the SIM, they will have to click the button. That's what I tried to automate if I able to found SIM hotplug.