-
Notifications
You must be signed in to change notification settings - Fork 93
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
Use dbus-native to call NetworkManager #59
Comments
currently when you serialise/deserialise variant, it's always a struct no matter if underlying type is simple or compound. Examples: // sv where v is "ai
[ "string", [ "ai" [ [ 1, 2, 3 ] ] ]
// av , first is ai, second is "sai"
[ [ "ai", [ [1, 2, 3 ] ] ], [ "sai", [ "test", [ 1, 2, 3 ] ] ] so your code should be var dbus = require('dbus-native');
var systemBus = dbus.systemBus();
var uuid = require('uuid');
var stringToArrayOfBytes = function (str) {
var bytes = [];
for (var i = 0; i < str.length; ++i) {
bytes.push(str.charCodeAt(i));
}
return bytes;
};
con = [ //a
['802-11-wireless', [
['mode', ['s','infrastructure']],
['security', ['s','802-11-wireless-security']],
['ssid', ['ai', [ stringToArrayOfBytes('TP-LINK_10DC') ] ]] // note that array itself is element of struct
]],
['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']]
]]
]
systemBus.getService('org.freedesktop.NetworkManager').getInterface(
'/org/freedesktop/NetworkManager',
'org.freedesktop.NetworkManager', function(err, Device) {
// console.log(Device);
Device.AddAndActivateConnection(con,'/org/freedesktop/NetworkManager/Devices/0','/',function(err,id){
console.log(id);
});
}); |
The Ssid which I want to send to NetworkManager is a " GByteArray " data structure. |
I've meet some problem when I try to use dbus-native with nodejs to call to NetworkManager and let NetworkManager connect to a SSID(WIFI).
I use the connection is :
and my code is:
In my code,SSID is the name of WIFI,and psk is my password.ID is also the name of WIFI.But id can use the form of string,ssid should use the form of bytes.
What can I do to help me Connect to a SSID?
Thanks.
The text was updated successfully, but these errors were encountered: