当android与定制的USB适配器(如DKBT111 )配对时,是否有可能强制使用传统的固定引脚项。从SSP和"Just works“配对来看,这似乎不能满足我所使用的安全需求。
我想保证,没有人可以尝试与USB设备配对,而它是可发现的,没有一个固定的,预设的PIN。我有问题配置控制器使用蓝光和蓝光。我能得到的最好的是6位密码的比较,但是我不会显示usb连接到的盒子上的代码。
我需要更改哪些设置才能为服务器设置一个PIN,而任何电话都需要键入它才能配对?
我用的是蓝光。
发布于 2018-09-01 13:53:01
要实现这样的场景,您可能需要实现自定义代理。由于您没有显示器,所以您必须从选项中选择设备的功能之一。
蓝光总是期望最少6位PIN键,如果你想限制自己的4位PIN,那么你应该使用“0”作为指定的这里。
对于自定义代理,您需要实现"DisplayPinCode“或"DisplayPasskey”方法,返回固定的PIN并使用"RegisterAgent“注册它。
为了只限制您的Android设备,您可以比较DisplayPinCode/DisplayPasskey中的设备MAC地址,这将获取请求配对为"First参数object device“的设备的MAC地址。
注意,“对象设备”是作为对象路径的MAC地址,即E /org/bluez/hciX/dev_AA_BB_CC_XX_YY_ZZ格式。
#include <glib.h>
#include <gio/gio.h>
#include "agent.h"
#define AGENT_PATH "/org/bluez/AutoPinAgent"
static void bluez_agent_method_call(GDBusConnection *conn,
const gchar *sender,
const gchar *path,
const gchar *interface,
const gchar *method,
GVariant *params,
GDBusMethodInvocation *invocation,
void *userdata)
{
g_print("Agent method call: %s.%s()", interface, method);
}
static const GDBusInterfaceVTable agent_method_table = {
.method_call = bluez_agent_method_call,
};
int bluez_register_agent(GDBusConnection *con)
{
GError *error = NULL;
guint id = 0;
GDBusNodeInfo *info = NULL;
static const gchar bluez_agent_introspection_xml[] =
"<node name='/org/bluez/SampleAgent'>"
" <interface name='org.bluez.Agent1'>"
" <method name='Release'>"
" </method>"
" <method name='RequestPinCode'>"
" <arg type='o' name='device' direction='in' />"
" <arg type='s' name='pincode' direction='out' />"
" </method>"
" <method name='DisplayPinCode'>"
" <arg type='o' name='device' direction='in' />"
" <arg type='s' name='pincode' direction='in' />"
" </method>"
" <method name='RequestPasskey'>"
" <arg type='o' name='device' direction='in' />"
" <arg type='u' name='passkey' direction='out' />"
" </method>"
" <method name='DisplayPasskey'>"
" <arg type='o' name='device' direction='in' />"
" <arg type='u' name='passkey' direction='in' />"
" <arg type='q' name='entered' direction='in' />"
" </method>"
" <method name='RequestConfirmation'>"
" <arg type='o' name='device' direction='in' />"
" <arg type='u' name='passkey' direction='in' />"
" </method>"
" <method name='RequestAuthorization'>"
" <arg type='o' name='device' direction='in' />"
" </method>"
" <method name='AuthorizeService'>"
" <arg type='o' name='device' direction='in' />"
" <arg type='s' name='uuid' direction='in' />"
" </method>"
" <method name='Cancel'>"
" </method>"
" </interface>"
"</node>";
info = g_dbus_node_info_new_for_xml(bluez_agent_introspection_xml, &error);
if(error) {
g_printerr("Unable to create node: %s\n", error->message);
g_clear_error(&error);
return 0;
}
id = g_dbus_connection_register_object(con,
AGENT_PATH,
info->interfaces[0],
&agent_method_table,
NULL, NULL, &error);
g_dbus_node_info_unref(info);
//g_dbus_connection_unregister_object(con, id);
return id;
}上面的示例是不完整的模板,没有任何特定的方法。您需要在"bluez_agent_method_call“中实现"DisplayPinCode/DisplayPasskey”,该名称是作为参数的“方法”名称。
编辑:与固定PIN相同的示例,并在此问题中回答了更多细节。为了将来的参考和完整性而添加它。
https://stackoverflow.com/questions/52121497
复制相似问题