View Single Post
Posts: 15 | Thanked: 17 times | Joined on Sep 2019
#1
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);
            });
        }
    }

}
 

The Following User Says Thank You to crun For This Useful Post: