How to detect that connection got lost? Disconnected USB connection as well as disconnected mobile connection...
Martin Maurer
martin.maurer at mmeacs.de
Wed Nov 1 20:07:49 UTC 2023
Hello,
I am using the Python API. I allocate CIDs (e.g. for WDS) and keep them
till python program is finished.
Does someone know how I can detect that established connection got
disconnected?
I think there are at least two cases: USB got disconnected (1) and
mobile connection got disconnected (2).
(1) (e.g. by removing USB cable)
(process:8148): Qmi-WARNING **: 19:54:05.330: Cannot read from istream:
connection broken
(2)
Via WDS get_packet_service_status
get_connection_status
<enum QMI_WDS_CONNECTION_STATUS_CONNECTED of type Qmi.WdsConnectionStatus>
Details here:
https://lazka.github.io/pgi-docs/Qmi-1.0/classes/MessageWdsGetPacketServiceStatusOutput.html#Qmi.MessageWdsGetPacketServiceStatusOutput
and
https://lazka.github.io/pgi-docs/Qmi-1.0/enums.html#Qmi.WdsConnectionStatus
I want to get informed via Python code.
(1) I can perhaps detect via Linux calls (when USB device goes away),
but I assume there is also a mechanism with libqmi,
because I assume "QMI-WARNING" comes from inside libqmi.
There is
https://lazka.github.io/pgi-docs/Qmi-1.0/classes/ClientWds.html#Qmi.ClientWds.indication_register
Does it help me for the case (1) and (2)?
I was not yet able to use indication_register for this task...I am
registering it but callback is never called (at least for (1)).
Or only polling possible (e.g. every 1s), call (WDS)
get_packet_service_status in a loop to see if still connected?
Best regards,
Martin
More information about the libqmi-devel
mailing list