DBus async response. Correct way.
Unsolved
General and Desktop
-
Hello.
I have module UartGateway, which is wrapper on uart interface. It send messages via uart. This module has dbus interface to communicate with other modules.
Also I have module UartClient which can use UartGateway interface to get some data via uart.
In my UartClient I can call something like this:auto pendingCall = UartGatewayInterface->getVoltage(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this); connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher *call){ QDBusPendingReply<quint32> reply = *call; if (reply.isError()) { qWarning() << "Error occured"; } else { processResult(reply.argumentAt<0>()); } }
in UartGateway method getVoltage() is called (by adapter)
quint32 UartGateway::getVoltage(){ // need to send request by uart and return result }
Method getVoltage() works syncrounosly.
As I need to send request via uart and process responce asyncrounosly, what is correct way to do it?