Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use dbus.Byte in python like in dbus-native #62

Closed
zhangtianye opened this issue Mar 29, 2015 · 5 comments
Closed

How to use dbus.Byte in python like in dbus-native #62

zhangtianye opened this issue Mar 29, 2015 · 5 comments
Labels

Comments

@zhangtianye
Copy link

Hi,
Can you give me some way to use dbus-native as I can use "dbus.Byte" and " dbus.ByteArray " in python?
Some data I can use "dbus.ByteArray" in python to communicate with application like NetworkManager,
but failed in dbus-native.
Here is a link to dbus.ByteArray:
http://dbus.freedesktop.org/doc/dbus-python/api/dbus.ByteArray-class.html
And here is my python code:

import dbus
con = {
    '802-11-wireless':{
        'ssid':dbus.ByteArray('homewifi'),
    },
    'connection':{
        'type':'802-11-wireless',
        'uuid':'7371bb78-c1f7-42a3-a9db-5b9566e8ca07',
        'id':'My_need_wifi'
    },
    'ipv4':{'method':'auto'},
    'ipv6':{'method':'auto'}
}
bus = dbus.SystemBus()
proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings")
settings = dbus.Interface(proxy, "org.freedesktop.NetworkManager.Settings")
settings.AddConnection(con)

Is there any way I can use like dbus.Byte or dbus.ByteArray in dbus-native like in python-dbus ?
Thanks.

@zhangtianye
Copy link
Author

2015-03-29 10 30 44
Here is some message about dbus.ByteArray

@sidorares
Copy link
Owner

just use 'ay' signature and array of numbers as value. I'll try to see what messages exactly python script sends

@zhangtianye
Copy link
Author

Hi,
Thanks for your "ay" signature, I have solve my problem eventhough the process looks so foolish.
I use Buffer in nodejs to replace dbus.ByteArray and it makes me succeed.
Here is my new code:

a = 'TP-LINK_10DC';
var buffer = Buffer(a);
con = [
  ['802-11-wireless', [
    ['mode', ['s','infrastructure']],
    ['security', ['s','802-11-wireless-security']],
      ['ssid', ['ay', [buffer]]]
  ]],
  ['802-11-wireless-security', [
    ['auth-alg', ['s','open']], 
    ['key-mgmt', ['s','wpa-psk']],
    ['psk', ['s','0123456789']]
  ]],
  ['connection',[
    ['id', ['s','TP-LINK_10DC']],
    ['type', ['s','802-11-wireless']],
    ['uuid', ['s',uuid.v1().toString()]]
  ]],
 ['ipv4', [
 ['method', ['s','auto']]
 ]],
 ['ipv6', [
    ['method', ['s','auto']]
        ]]
]

I use it to replace dbus.ByteArray in python.
In my opinion,you can integrate these functions(which looks simple but difficult to realize) in python in dbus-native to make it easier to use.
Thanks for your help.

@sidorares
Copy link
Owner

@zhangtianye buffer should work same way as array of numbers, just make sure that ay is serialised as [array], not array. See also comments in #52

@sidorares
Copy link
Owner

closing this as the main issue is known ( complex types, especially variants are very verbose and there should be easier way to read/write them + documentation )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants