使用 SIM800C 设备配置 Ofono

使用 SIM800C 设备配置 Ofono

我正在尝试(作为一个完全的新手)使用ofono操纵我的 SIMCOM 800C 设备。我已经从源代码编译了它并配置了所有必要的服务(D-bus 和 udev)。文档中的 udev 规则对我不起作用,我正在使用自定义规则,它能够检测设备并将OFONO_DRIVER属性设置为sim900.我遇到的问题是似乎没有任何效果。我使用测试脚本执行的所有测试ofono都导致错误。有关于如何正确设置的指南吗?例如,该online-modem脚本返回以下错误:

Setting modem /sim900_0 online...
Traceback (most recent call last):
  File "/home/.../ofono/test/./online-modem", line 17, in <module>
    modem.SetProperty("Online", dbus.Boolean(1), timeout = 120)
  File "/usr/lib/python3.11/site-packages/dbus/proxies.py", line 72, in __call__
    return self._proxy_method(*args, **keywords)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/dbus/proxies.py", line 141, in __call__
    return self._connection.call_blocking(self._named_service,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/dbus/connection.py", line 652, in call_blocking
    reply_message = self.send_message_with_reply_and_block(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dbus.exceptions.DBusException: org.ofono.Error.NotAvailable: Operation currently not available

这是脚本的输出list-modems


[ /sim900_0 ]
    Online = 0
    Powered = 0
    Lockdown = 0
    Emergency = 0
    SystemPath = /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2
    Interfaces = 
    Features = 
    Type = hardware

[ /stktest ]
    Online = 0
    Powered = 0
    Lockdown = 0
    Emergency = 0
    Interfaces = 
    Features = 
    Type = test

我没有更改默认的 D 总线配置。下面是我正在使用的udev

DRIVERS=="ch341", ENV{OFONO_DRIVER}="sim900"

日志sudo ofonod -nd显示检测到我的设备:

ofonod[3141]: oFono version 2.1
ofonod[3141]: src/plugin.c:__ofono_plugin_init() 
ofonod[3141]: src/gprs-provision.c:ofono_gprs_provision_driver_register() driver: 0x558ba57afe20 name: GPRS context provisioning
ofonod[3141]: plugins/push-notification.c:push_notification_init() 
ofonod[3141]: plugins/smart-messaging.c:smart_messaging_init() 
ofonod[3141]: plugins/emulator_fuzz.c:emulator_fuzz_init() 
ofonod[3141]: src/modem.c:ofono_modem_driver_register() driver: 0x558ba57b0080, name: stktest
ofonod[3141]: src/modem.c:ofono_modem_create() name: stktest, type: stktest
ofonod[3141]: src/modem.c:ofono_modem_register() 0x558ba6c64c20
ofonod[3141]: plugins/stktest.c:stktest_probe() 0x558ba6c64c20
ofonod[3141]: src/modem.c:emit_modem_added() 0x558ba6c64c20
ofonod[3141]: src/modem.c:get_modem_property() modem 0x558ba6c64c20 property SystemPath
ofonod[3141]: src/modem.c:call_modemwatches() 0x558ba6c64c20 added:1
ofonod[3141]: plugins/udevng.c:udev_start() 
ofonod[3141]: plugins/udevng.c:enumerate_devices() 
ofonod[3141]: plugins/udevng.c:check_usb_device() usb [1d6b:0002]
ofonod[3141]: plugins/udevng.c:check_usb_device() ch341 [1a86:7523]
ofonod[3141]: plugins/udevng.c:add_device() /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2
ofonod[3141]: plugins/udevng.c:add_device() /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/ttyUSB0/tty/ttyUSB0
...
ofonod[3141]: plugins/udevng.c:create_modem() /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2
ofonod[3141]: plugins/udevng.c:create_modem() driver=sim900
ofonod[3141]: src/modem.c:ofono_modem_create() name: (null), type: sim900
ofonod[3141]: src/modem.c:set_modem_property() modem 0x558ba6c942b0 property Device
ofonod[3141]: src/modem.c:set_modem_property() modem 0x558ba6c942b0 property SystemPath
ofonod[3141]: src/modem.c:ofono_modem_register() 0x558ba6c942b0
ofonod[3141]: plugins/sim900.c:sim900_probe() 0x558ba6c942b0
ofonod[3141]: src/modem.c:emit_modem_added() 0x558ba6c942b0
ofonod[3141]: src/modem.c:get_modem_property() modem 0x558ba6c942b0 property SystemPath
ofonod[3141]: src/modem.c:call_modemwatches() 0x558ba6c942b0 added:1
ofonod[3141]: plugins/dun_gw_bluez5.c:modem_watch() modem: 0x558ba6c942b0, added: 1
ofonod[3141]: plugins/hfp_ag_bluez5.c:modem_watch() modem: 0x558ba6c942b0, added: 1
ofonod[3141]: examples/emulator.c:modem_watch() modem: 0x558ba6c942b0, added: 1
ofonod[3141]: plugins/smart-messaging.c:modem_watch() modem: 0x558ba6c942b0, added: 1
ofonod[3141]: plugins/push-notification.c:modem_watch() modem: 0x558ba6c942b0, added: 1
...
ofonod[3141]: src/modem.c:get_modem_property() modem 0x558ba6c64c20 property SystemPath
ofonod[3141]: src/modem.c:get_modem_property() modem 0x558ba6c942b0 property SystemPath
ofonod[3141]: src/modem.c:get_modem_property() modem 0x558ba6c64c20 property SystemPath
...
ofonod[3141]: plugins/upower.c:modemwatch() modem: /sim900_0, added: 1
ofonod[3141]: plugins/upower.c:modemwatch() modem: /stktest, added: 1
...

以下是脚本的内容online-modem

#!/usr/bin/python3

import dbus, sys

bus = dbus.SystemBus()

if len(sys.argv) == 2:
    path = sys.argv[1]
else:
    manager = dbus.Interface(bus.get_object('org.ofono', '/'),
            'org.ofono.Manager')
    modems = manager.GetModems()
    path = modems[0][0]

print("Setting modem %s online..." % path)
modem = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.Modem')
modem.SetProperty("Online", dbus.Boolean(1), timeout = 120)

如何使用我的设备正确配置 ofono 并能够使用 D-bus API?

相关内容