[英]How to send SMS from PC to mobile using Java bluetooth OBEX (bluecove api)?
[英]send files from pc to mobile via bluetooth in java without pairing
我正在使用java開發一個桌面應用程序來向周圍的設備發送文件。 已經完成但是我遇到了問題,當發送操作嘗試開始時,移動設備中會出現配對消息。我的應用程序使用bluecove庫.Bluecove在其網站上有一個示例應用程序,通過藍牙發送文件,發送時不需要配對files.download從這里http://www.bluecove.org/bluecove-examples/obex-install/push.jnlp
這是我的代碼,它將文件發送到藍牙設備:
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();
我的網址是:btgoep:// 001FDF08DEEC:9; authenticate = false; encrypt = false; master = false
我想知道我的應用程序和bluecove示例應用程序之間有什么區別。 Thanx提前。
基於此,您可以在.net中進行自動身份驗證!
根據我在bluecove的經驗,您需要覆蓋RemoteDevice.authenticate()函數並為服務器提供硬編碼的密碼,並使客戶端可以輸入該號碼進行身份驗證! 使用這種方法,您可以進行配對,但無需在服務器端手動輸入!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.