Bluetooth Android配对到自定义USB蓝牙适配器
在将android与自定义USB适配器(如DKBT111)配对时,是否可以强制输入传统的固定pin码。看看SSP和“Just works”配对,这似乎不能满足我正在处理的安全需求 我想保证,没有人可以尝试与USB设备配对,而它是没有固定的,预设的引脚发现。使用bluetoothctl和Bluez配置控制器时遇到问题。我能得到的最好的结果是6位数的密钥比较,但我不会在usb连接到的盒子上显示代码 我必须更改哪些设置才能为服务器设置PIN码,并且任何手机都需要输入PIN码才能配对Bluetooth Android配对到自定义USB蓝牙适配器,bluetooth,android-bluetooth,bluez,Bluetooth,Android Bluetooth,Bluez,在将android与自定义USB适配器(如DKBT111)配对时,是否可以强制输入传统的固定pin码。看看SSP和“Just works”配对,这似乎不能满足我正在处理的安全需求 我想保证,没有人可以尝试与USB设备配对,而它是没有固定的,预设的引脚发现。使用bluetoothctl和Bluez配置控制器时遇到问题。我能得到的最好的结果是6位数的密钥比较,但我不会在usb连接到的盒子上显示代码 我必须更改哪些设置才能为服务器设置PIN码,并且任何手机都需要输入PIN码才能配对 我在tinycor
我在tinycore上使用Bluez 要实现这种场景,您可能需要实现自定义代理。由于没有显示器,您必须从中选择设备的一种功能 Bluez始终希望至少有6位PIN码,如果您想将自己的PIN码限制为4位,则应按规定使用“0”进行填充 对于自定义代理,您需要实现返回固定PIN并使用“”注册的“”或“”方法 为了仅限制Android设备,您可以在DisplayPinCode/DisplayPasskey中比较设备的MAC地址,它将请求配对的设备的MAC地址作为“第一个参数对象设备” 注意,“对象设备”是作为对象路径的MAC地址,即/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;
}
#包括
#包括
#包括“agent.h”
#定义代理路径“/org/bluez/AutoPinAgent”
静态无效bluez_代理_方法_调用(GDBusConnection*conn,
const gchar*发送方,
常量gchar*路径,
常量gchar*接口,
常量gchar*方法,
GVariant*params,
GDBusMethodInvocation*调用,
void*用户数据)
{
g_print(“代理方法调用:%s.%s()”,接口,方法);
}
静态常量GDBusInterfaceVTable代理\u方法\u表={
.method\u call=bluez\u agent\u method\u call,
};
int bluez_寄存器_代理(GDBusConnection*con)
{
GError*error=NULL;
吉尼特id=0;
GDBusNodeInfo*info=NULL;
静态常量gchar bluez_agent_内省_xml[]=
""
" "
" "
" "
" "
“。添加它以供将来参考和完整