简体   繁体   English

在没有配对的情况下通过蓝牙在java中将文件从pc发送到移动设备

[英]send files from pc to mobile via bluetooth in java without pairing

I'm developing a desktop application using java to send a file to devices around. 我正在使用java开发一个桌面应用程序来向周围的设备发送文件。 It's done but I have a problem, a pairing message appears in mobile device when a send operation tries to begin.My app uses bluecove library.Bluecove has an example application in its website to send files via Bluetooth that doesn't need pairing while sending files.download it from here http://www.bluecove.org/bluecove-examples/obex-install/push.jnlp 已经完成但是我遇到了问题,当发送操作尝试开始时,移动设备中会出现配对消息。我的应用程序使用bluecove库.Bluecove在其网站上有一个示例应用程序,通过蓝牙发送文件,发送时不需要配对files.download从这里http://www.bluecove.org/bluecove-examples/obex-install/push.jnlp

Here is my code which sends file to a Bluetooth device : 这是我的代码,它将文件发送到蓝牙设备:

Connection connection = Connector.open(btConnectionURL);
// connection obtained

// now, let's create a session and a headerset objects
ClientSession cs = (ClientSession) connection;

HeaderSet hsConnectReply = cs.connect(null);
if (hsConnectReply.getResponseCode() != ResponseCodes.OBEX_HTTP_OK) {
System.out.println("Error while connecting device");
    return;
}   
HeaderSet hs = cs.createHeaderSet();
hs.setHeader(HeaderSet.NAME, filename);
hs.setHeader(HeaderSet.TYPE,
        new MimetypesFileTypeMap().getContentType(new File(filen)));
hs.setHeader(HeaderSet.LENGTH, new Long(file.length));

Operation putOperation = cs.put(hs);

OutputStream outputStream = putOperation.openOutputStream();
outputStream.write(file);
// file push complete

outputStream.close();
putOperation.close();

cs.disconnect(null);

connection.close();

the url in my case is : btgoep://001FDF08DEEC:9;authenticate=false;encrypt=false;master=false 我的网址是:btgoep:// 001FDF08DEEC:9; authenticate = false; encrypt = false; master = false

I wonder what is the difference between my app and bluecove example app. 我想知道我的应用程序和bluecove示例应用程序之间有什么区别。 Thanx in advance. Thanx提前。

based on this you can do automated authentication in .net! 基于此,您可以在.net中进行自动身份验证!

based on my experience in bluecove you need to override the RemoteDevice.authenticate() function and provide a hard coded pin number for server and make the number available to clients to enter for authentication! 根据我在bluecove的经验,您需要覆盖RemoteDevice.authenticate()函数并为服务器提供硬编码的密码,并使客户端可以输入该号码进行身份验证! with this approach you do pairing but without need to enter manually in server side! 使用这种方法,您可以进行配对,但无需在服务器端手动输入!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM