我看了MAP SPEC
,以便从我的PC
向我的手机发送x-bt /消息,我正在使用JAVA blucove API
。
我能够通过OBEX protocol
成功连接但我没有从手机返回,并且没有发送消息。
我的OBEX标题:
HeaderSet hsOperation = clientSession.createHeaderSet();
hsOperation.setHeader(HeaderSet.TYPE, "x-bt/message");
hsOperation.setHeader(HeaderSet.LENGTH,new Long(sMessage.length()));
hsOperation.setHeader(HeaderSet.NAME, "TELECOM/MSG/OUTBOX");
我的bMessage和OutputStream:
private final static String CRLF = "\r\n";
static String sMessage = "BEGIN:BMSG"+CRLF
+ "VERSION:1.0"+CRLF
+ "STATUS:UNREAD"+CRLF
+ "TYPE:SMS_GSM"+CRLF
+ " FOLDER:TELECOM/MSG/OUTBOX"+CRLF
+ "BEGIN:VCARD"+CRLF
+ " VERSION:2.1"+CRLF
+ " N:Souza,Ricardo"+CRLF
+ " TEL:+5511666666666"+CRLF
+ "END:VCARD"+CRLF
+ "BEGIN:BENV"+CRLF
+ " BEGIN:VCARD"+CRLF
+ " VERSION:2.1"+CRLF
+ " N:Souza,Ricardo"+CRLF
+ " TEL:+5511666666666"+CRLF
+ " END:VCARD"+CRLF
+ " BEGIN:BBODY"+CRLF
+ " ENCODING:G-7BIT"+CRLF
+ " LENGTH:47"+CRLF
+ " BEGIN:MSG"+CRLF
+ " This is a short message"+CRLF
+ " END:MSG"+CRLF
+ " END:BBODY"+CRLF
+ "END:BENV"+CRLF
+ "END:BMSG"+CRLF;
OutputStream os = putOperation.openOutputStream();
os.write(sMessage.getBytes());
os.close();
有人可以帮我看看出了什么问题吗?如果有人已与Java OBEX
合作,以便将SMS
(MAP堆栈)从PC发送到移动设备,请。 (如carkits handsfree
)。
提前谢谢你们。
答案 0 :(得分:0)
删除空格:替换
之类的行...
+ " VERSION:2.1"+CRLF
...
通过
...
+ "VERSION:2.1"+CRLF
...
此外,该消息预期为7位编码,但在上面的代码中只提供了一个ASCII字符串。 例如。下面的块包含文本"让我们去钓鱼!"
...
"BEGIN:BBODY\r\n" +
"ENCODING:G-7BIT\r\n" +
"LENGTH:82\r\n" +
"BEGIN:MSG\r\n" + /*Length 11 */
"0001000E8100949821436587000011CC32FD34079DDF20737A8E4EBBCF21\r\n" + /* Length 62 */
"END:MSG\r\n" + /* Length 9 */
"END:BBODY\r\n" +
...
此示例是从测试套件https://android.googlesource.com/platform/packages/apps/Bluetooth/
复制而来的