User:TravMurav/Dual-Sim QMI draft

Some dual-sim devices may have a problem where the modem will not select your SIM automatically. When it happens you may need to manually select an application that will handle authentification on your SIM.

This guide happens to work in general but sometimes vendor (like Motorolla on harpia) may change modem firmware and you will need another solution

(Examples provided for wileyfox-crackling)

Preparation
We don't need custom libqmi anymore, but this instruction is saved for reference

Get working libqmi (at the time of writing libqmi from Alpine crashes with segfault on attempt of communicating with modem):

(This is done with pmbootstrap on your local machine)

cd ~/.local/var/pmbootstrap/cache_git/pmaports/temp mkdir libqmi cd libqmi wget https://gist.githubusercontent.com/Minecrell/eddea99e7c7b17c2a723d8ea657d56ea/raw/cf7a7e1467c062fce459a94ec9d479bb8a22712c/APKBUILD pmbootstrap build libqmi --arch aarch64

You need to install all the necessary components on the device: (Assuming that you have local repo and Internet connection configured)

(This is done on your device) sudo apk add libqmi

Make sure you have,   and   installed. Also make sure you have selected proper kernel variant (with ) and enabled nonfree-firmware during.

Making dual-sim QMI modem work
Boot device with working SIM inserted.

Make sure oFono services are stopped:

Check that your modem is working and detected SIM in slot:
Note that neither of four provisioning applications is present: On harpia it wasn't the case, application was already selected but modem didn't go online anyway.

You also can see list of your slots and state of cards in them. You may have more than one application though, for now we only need USIM one.

If you have an application selected already, please check if you have

This shows a (suspected) bug in firmware where it reports the wrong state if the application was selected too early (Some kind of race condition in the modem). You need to clear selected application by doing this:

Now you can try to select an application on your SIM:
In the following command you may need to change slot that you are using and you should replace  with Application ID that you got from previous command. (note that applications have different IDs)

Error like this may mean that either you did something wrong or that you need a different approach. (The message in qmicli for this error is wrong and only means that modem didn't like something)

If the command would succeed you will have application sellected:

Now you can send an SMS!
Using ofono test scripts:

Or you can try to make a call!
Or using :

Automating this process
Install the package with

At some point I wrote a hacky script that does all of that automatically as a system service. If this guide works for you, you could try installing it from this page Ideally it should be replaced with something less fragile but at least it works as PoC.

Notes:
"valid" session-type values are: