gpt4 book ai didi

javascript - Node dbus-native - 使用 connMan 连接到 WiFi 服务时传递密码

转载 作者:太空宇宙 更新时间:2023-11-04 02:30:38 32 4
gpt4 key购买 nike

嗨,过去几天我在尝试使用 dbus 连接到 protected WiFi 网络时遇到了这个问题。所以到目前为止我开发的代码是:

注册代理

var dbus = require('dbus-native');
var bus = dbus.systemBus();
bus.invoke({
destination: 'net.connman',
path: '/',
'interface': 'net.connman.Manager',
member: 'RegisterAgent',
type: dbus.messageType.methodCall,
signature: 'o',
body: [
'/test/agent'
]
}, function(error, response) {
if (error) {
console.error('Error', error);
//process.exit(1);
} else {
console.info('Success', response);
// process.exit(0);
}
});

输出

> Success

扫描Wifi

var dbus = require('dbus-native');
var bus = dbus.systemBus();
bus.invoke({
destination: 'net.connman',
path: '/net/connman/technology/wifi',
'interface': 'net.connman.Technology',
member: 'Scan',
type: dbus.messageType.methodCall,
}, function(error, response) {
if (error) {
console.error('Error', error);
//process.exit(1);
} else {
console.info('Success', response);
//process.exit(0);
}
});

输出

> Success

连接到 WiFi 服务

var dbus = require('dbus-native');
var bus = dbus.systemBus();
bus.invoke({
destination: 'net.connman',
path: '/net/connman/service/wifi_00e04c81923e_4469676957494649_managed_psk',
'interface': 'net.connman.Service',
member: 'Connect',
type: dbus.messageType.methodCall,
}, function(error, response) {
if (error) {
console.error('Error', error);
//process.exit(1);
} else {
console.info('Success', response);
//process.exit(0);
}
});

输出

> Error ['Invalid Arguments']

从 connMan 日志输出

connmand[1899]: src/agent.c:agent_receive_message() agent 0x55640fe8 req 0x55644378

connmand[1899]: src/service.c:request_input_cb() RequestInput return, 0x55649ad0

connmand[1899]:src/service.c:request_input_cb()error:org.freedesktop.DBus.Error.UnknownService

connmand[1899]: src/service.c:__connman_service_return_error() service 0x55649ad0 error 22 user_data (nil)

connmand[1899]: src/service.c:__connman_service_set_hidden_data() service 0x55649ad0 pending (nil)

connmand[1899]: src/service.c:service_save() service 0x55649ad0 new 1

connmand[1899]: src/connection.c:update_order()

connmand[1899]: src/service.c:__connman_service_get_order() service 0x55640a08 name Wired order 1 split 0

connmand[1899]: src/connection.c:find_default_gateway() default 0x5563b250 order 1

connmand[1899]: src/connection.c:__connman_connection_update_gateway() default 0x5563b250

connmand[1899]: src/service.c:connman_service_unref_debug() 0x55649ad0 ref 1 by src/service.c:6945:agent_context_unref()

所以基本上,如果有人能告诉我如何传回包含 WiFi 网络密码的用户数据,我将不胜感激。

任何帮助将不胜感激? (connMan版本1.20)

谢谢

最佳答案

我无法让 dbus-native 工作。

我的解决方案是在/lib/connman/中创建一个 wifi.config 文件,其中包含每个服务的密码:

wifi.config示例

[service_wifi_00e04c819295_4469679972434649_managed_psk] 
Type = wifi
Security = wpa2
Name = [service_]
Type = wifi
Security = wpa2
Name = WiFiAP
Passphrase = 12345

然后简单地使用 dbus-native 连接到 WiFi 服务:

连接

var dbus = require('dbus-native');
var bus = dbus.systemBus();
bus.invoke({
destination: 'net.connman',
path: '/net/connman/service/wifi_48022aca514f_4469676957494649_managed_psk',
'interface': 'net.connman.Service',
member: 'Connect',
type: dbus.messageType.methodCall,
}, function(error, response) {
if (error) {
console.error('Error', error);
//process.exit(1);
} else {
console.info('Success', response);
//process.exit(0);
}
});

关于javascript - Node dbus-native - 使用 connMan 连接到 WiFi 服务时传递密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27059555/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com