maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   Using DBus QML interface (https://talk.maemo.org/showthread.php?t=101218)

crun 2021-06-14 11:48

Using DBus QML interface
 
I am trying to use the DBus QML interface
https://nemo-qml-plugin-dbus.readthedocs.io/en/latest/

to monitor the cellular signal levels etc, using these apis:
https://github.com/rilmodem/ofono/bl...etwork-api.txt
https://git.sailfishos.org/mer-core/...onitor-api.txt


I can get signals from ofono.NetworkRegistration OK, but I can't work out how to use "getProperty" and "call" .
In the example below in "function xx" they both return "undefined"


or how to connect to "servingCellInformationChanged" of the ofono.NetworkMonitorAgent, (which doesn't seem to have any signals.)

In this case


Code:

import QtQuick 2.0
import org.nemomobile.dbus 2.0

Item {
    id: dBusX
    property string cellName:""
    property string cellStatus: ""
    property int dBmStrength: 0
    property int rawStrength: 0
    property string technology: ""
    property int cellStrength: 0

    function xx(){
        var R=ooNR.getProperty('Status')
        console.log(R)
        R=ooNR.call('GetProperties',[])
        console.log(R)
        R=ooNM.call('GetServingCellInformation',[])
                console.log(R)

    }

    DBusInterface {
        id: ooNR
        bus:DBus.SystemBus
        service: 'org.ofono'
        path: '/ril_0'
        iface: 'org.ofono.NetworkRegistration'
        signalsEnabled: true

        function propertyChanged(name, value) {  //on signal...
            //console.log("NR Property Changed "+ name + "  " + value)
            switch (name) {
                case "Strength":
                    rawStrength = value
                    dBmStrength = (value-113)/2 //2 * value - 113;
                break;
                case "Name" : cellName = value; break;
                case "Technology" : technology = value; break;
                case "Status" : cellStatus = value; break;

                default: console.log("NR Property Changed "+ name + "  " + value)
            }
        }
    }
//----------
    DBusInterface {
        id: ooNM
        bus:DBus.SystemBus
        service: 'org.ofono'
        path: '/ril_0'
        iface: 'org.ofono.NetworkMonitor'
        signalsEnabled: true
    }
//--------------
    DBusInterface {
        id: ooNMA
        bus:DBus.SystemBus
        service: 'org.ofono'
        path: '/ril_0'
        iface: 'org.ofono.NetworkMonitorAgent'
        signalsEnabled: true

//        function servingCellInformationChanged(a) {
//            console.log(a)
//    }

// Error message when below runs is:
// TypeError: Property 'typedCallWithReturn' of object DeclarativeDBusInterface(0x10548530) is not a function
        Component.onCompleted: {
            ooNMA.typedCallWithReturn('ServingCellInformationChanged', [], function (result) {
                // This will be called when the result is available
                console.log('ServingCellInformationChanged: ' + result);
            });
        }
    }

}


crun 2021-06-14 22:20

Re: Using DBus QML interface
 
I realised that TypedCallWithReturn has been replaced by TypedCall.

So now I get error message:
Quote:

[W] unknown:60 - file:///usr/share/CellMon/qml/components/DBus.qml:60:5: QML DBusInterface: QDBusError("org.freedesktop.DBus.Error.UnknownMeth od", "Method \"ServingCellInformationChanged\" with signature \"\" on interface \"org.ofono.NetworkMonitorAgent\" doesn't exist\n")
Code:

Component.onCompleted: {
            ooNMA.typedCall('ServingCellInformationChanged',[],
              function (result) {                  console.log('ServingCellInformationChanged: ' + result);                    }            );
        }

I still don't know if "ServingCellInformationChanged" is to setup a callback , as above. OR is it supposed to be signal type function that will just be called if it is provided?

coderus 2021-06-15 18:40

Re: Using DBus QML interface
 
for ofono you can use corresponding qml bindings insead of direct dbus calls

crun 2021-06-21 12:01

Re: Using DBus QML interface
 
Quote:

Originally Posted by coderus (Post 1572078)
for ofono you can use corresponding qml bindings insead of direct dbus calls

I found this: https://git.sailfishos.org/mer-core/...ugins.qmltypes

Do you have any idea if this is just calling the dbus, or does it directly access the ofono libs some other way?

I see NetworkMonitor doesn't appear to be in there, which I am using.

I have typedcalls working now, but I have not worked out a way to get callbacks/events/signals from NetworkMonitor, and I am left doing timer polling of getServingNetworkProperties.

There is a NetworkMonitorAgent , but does not seem to be in dbus on sfos. There is a call to RegisterAgent in NetworkMonitor, but I cannot see what to do with it.


All times are GMT. The time now is 16:38.

vBulletin® Version 3.8.8