NetworkManager StatusChanged D-Bus signal not being received.
-
I'm trying to put together some code to check the NetworkManager status. The final goal is to run this on an embedded system, but for testing I am running this on Ubuntu 24, where I think it should be working.
I am trying to connect to the StateChanged D-Bus signal, with the following code :-
const QString s_NMService( "org.freedesktop.NetworkManager" ); const QString s_NMObjectPath( "/org/freedesktop/NetworkManager" ); const QString s_NMInterface( "org.freedesktop.NetworkManager" ); CNetworkManager::CNetworkManager(QObject *parent) : QObject(parent), //QDBusInterface's constructor makes a non-obvious blocking call to introspect the D-Bus service m_NM( s_NMService, s_NMObjectPath, s_NMInterface, QDBusConnection::systemBus() ) { const QVariant VarState( m_NM.property( "State" ) ); m_NMState = static_cast<ENMState>( VarState.toUInt() ); m_bWasConnected = QDBusConnection::systemBus().connect( s_NMService, s_NMObjectPath, s_NMInterface, "StateChanged", "(u)", this, SLOT(SetNMState(uint)) ); m_Connect = connect( &m_NM, SIGNAL(StateChanged(uint)), this, SLOT(SetNMState(uint)) );However, my debugger tells me that, although the State is correctly fetched initially, the slot function is not called (it should be called twice, of course, since I tried to connect in 2 different ways).
I have noticed this so in some sense I am in a better situation ;-)
Clearly networkmanager is not the problem :-
~$ nmcli monitor NetworkManager is running enp0s3: deactivating enp0s3: disconnected There's no primary connection Networkmanager is now in the 'connected (local only)' state Connectivity is now 'limited' enp0s3: using connection 'netplan-enp0s3' enp0s3: connecting (prepare) Networkmanager is now in the 'connecting' state enp0s3: connecting (configuring) enp0s3: connecting (getting IP configuration) 'netplan-enp0s3' is now the primary connection enp0s3: connecting (checking IP connectivity) enp0s3: connecting (starting secondary connections) enp0s3: connected Networkmanager is now in the 'connected (site only)' state Networkmanager is now in the 'connected' state Connectivity is now 'full'I've checked the names and variable types using D-Feet.
I also tried running with sudo privileges.
Now I've run out of ideas.
Qt v6.8.3
If anyone with experience can spot my mistake, it would be appreciated, otherwise I will have to revert to the ugly polling option.
TIA
Tim
-
I will check to see if it's due to this bug
-
Or, more likely it was the dumb mistake of doing a quick hack for testing, which deleted my test object...
-
V Vaquita Tim has marked this topic as solved