Reconnect modem and restore connection in Openwrt.Uqmi and Modemmanager

Here's the problem scenario in the log:

Sat Apr 26 13:31:05 2025 daemon.warn [2262]: <wrn> [modem0] port cdc-wdm0 timed out 2 consecutive times
Sat Apr 26 13:31:05 2025 daemon.warn [2262]: <wrn> [modem0/bearer9] reloading stats failed: QMI operation failed: Transaction timed out
Sat Apr 26 13:31:14 2025 daemon.warn [2262]: <wrn> [modem0] port cdc-wdm0 timed out 3 consecutive times
Sat Apr 26 13:31:21 2025 daemon.err uhttpd[2118]: [info] luci: accepted login on / for root from 192.168.34.65
Sat Apr 26 13:31:35 2025 daemon.warn [2262]: <wrn> [modem0] port cdc-wdm0 timed out 4 consecutive times
Sat Apr 26 13:31:35 2025 daemon.warn [2262]: <wrn> [modem0/bearer9] reloading stats failed: QMI operation failed: Transaction timed out
Sat Apr 26 13:31:54 2025 daemon.warn [2262]: <wrn> [modem0] port cdc-wdm0 timed out 5 consecutive times
Sat Apr 26 13:32:04 2025 daemon.warn [2262]: <wrn> [modem0] port cdc-wdm0 timed out 6 consecutive times
Sat Apr 26 13:32:05 2025 daemon.warn [2262]: <wrn> [modem0] port cdc-wdm0 timed out 7 consecutive times
Sat Apr 26 13:32:05 2025 daemon.warn [2262]: <wrn> [modem0/bearer9] reloading stats failed: QMI operation failed: Transaction timed out
Sat Apr 26 13:32:35 2025 daemon.warn [2262]: <wrn> [modem0] port cdc-wdm0 timed out 8 consecutive times
Sat Apr 26 13:32:35 2025 daemon.warn [2262]: <wrn> [modem0/bearer9] reloading stats failed: QMI operation failed: Transaction timed out
Sat Apr 26 13:32:44 2025 daemon.warn [2262]: <wrn> [modem0] port cdc-wdm0 timed out 9 consecutive times
Sat Apr 26 13:32:54 2025 daemon.err [2262]: <err> [modem0] port cdc-wdm0 timed out 10 consecutive times, marking modem as invalid
Sat Apr 26 13:32:54 2025 daemon.notice netifd: Network device 'wwan0' link is down
Sat Apr 26 13:32:55 2025 daemon.notice netifd: wan (12479): stopping network
Sat Apr 26 13:32:55 2025 daemon.notice netifd: wan (12479): error: couldn't find modem
Sat Apr 26 13:32:55 2025 daemon.notice netifd: wan (12479): couldn't load bearer path: disconnecting anyway
Sat Apr 26 13:32:55 2025 daemon.notice netifd: Interface 'wan' is now down
Sat Apr 26 13:32:55 2025 daemon.err sing-box[5171]: e[31mERRORe[0m[17066] network: missing default interface

I'm not a programmer. I made a simple solution for this problem. Daemon modem-watchdog_qmi and daemon modem-watchdog for modemmanager.
This service is needed in a scenario where the modem hangs up and there is no connection. This can be due to ISP reconnections, due to modem overheating, due to modem firmware ....

I have an MF286D router with an MDM9250-2 modem. When the modem hangs hard, MODEMMANAGER tries to start it for a long time, it starts, but it works incorrectly. It is necessary to reboot the router.
UQMI works better - it doesn't try to start it! )) Need qmi-utils to work with modem. QMICLI can start the modem in many scenarios, but not in all!
The best, fastest and most reliable solution in both cases is to restart the modem: AT+CFUN=1,1.

Still my router is better and more stable via uqmi. On modemmanager after rebooting the modem the connection via vpn is not restored - it is necessary to reboot the router. On uqmi+qmicli everything works fine after rebooting the modem.