But I have this answer:
error: command failed: ‘GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Unauthorized: Cannot send AT command to modem: operation only allowed in debug mode’
I think the Modem can’t switch to debug mode, I don’t understand why
The above error just means that there is already a ModemManager service running, so you cannot run it manually. How did you attempt to stop the MM sevice? in a systemd-based distribution you would do “sudo systemctl stop ModemManager” for example, although it could also be that you’re not using systemd and then MM is being DBus-autostarted by some other process, and if so it would be a bit more complex. What distribution are you using?
Oh, so what you need to do is actually change the initial EPS bearer settings. If you have a new enough ModemManager you could probably do that without needing to use --command, e.g. the equivalent command would be using `mmcli --3gpp-set-initial-eps-bearer-settings=“apn=,iptype=ipv4” (apn string empty and ip-type ipv4 equivalent to the “IP” in the CGDCONT command). MM 1.14 supports this for MBIM modems and MM 1.16 for QMI modems.
That error means you cannot use the --command option in mmcli while ModemManager is not running with --debug. It has nothing to do with the modem being put in debug mode or anything like that, this is exclusively a ModemManager limitation imposed artificially to avoid having users run AT commands without care
If you do want to use the CGDCONT command, make sure you stop ModemManager completely first in your setup. E.g. once you stop it, mmcli would fail like this:
$ mmcli -L
error: couldn't find the ModemManager process in the bus
Then, you should be able to run MM in debug mode, e.g.:
sudo /usr/sbin/ModemManager --debug
And while MM is running like this, in another terminal, you could try to run the mmcli --command actions.