博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android自带的示例程序 BluetoothChat 变蓝牙串口助手
阅读量:5889 次
发布时间:2019-06-19

本文共 4761 字,大约阅读时间需要 15 分钟。

bbs_sn=5289768&bbs_page_no=1&search_mode=4&search_text=duxingkei&bbs_id=9999,突然想到通过我的安卓手机蓝牙串口配合蓝牙串口模块可以实现许多有意思的应用:手机蓝牙遥控汽车 手机蓝牙转红外遥控器甚至遥控家电。

   在研究了网上的android蓝牙串口代码后发现其代码大部分内容与android系统自带的 示例程序 BluetoothChat 相似。于是我直接把示例程序导入eclipse项目中编译并行在手机上,尝试直接用此软件连接到电脑的蓝牙串口,但是始终不成功。我开始分析代码,发现有区别的地方是 BluetoothChatService.java的第49行         
    private static final UUID MY_UUID = UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");                        
中的字符串不同,于是把他替换成蓝牙串口服务 (SPP) 的 UUID                        
    private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
保存后运行程序到手机上,把电脑上的蓝牙打开,打开电脑上的串口助手,波特率随便设置就可以了
附图和资料

附csdn中的博客参考资料  

(原文件名:Android Service和Activity基于串口蓝牙模块的双向通信【第二篇】 - - 博客频道 - CSDN_NET.mht) 

关于UUID
ServiceDiscoveryServerServiceClassID_UUID = '{00001000-0000-1000-8000-00805F9B34FB}' 
BrowseGroupDescriptorServiceClassID_UUID = '{00001001-0000-1000-8000-00805F9B34FB}' 
PublicBrowseGroupServiceClass_UUID = '{00001002-0000-1000-8000-00805F9B34FB}' 
#蓝牙串口服务 
SerialPortServiceClass_UUID = '{00001101-0000-1000-8000-00805F9B34FB}' 
LANAccessUsingPPPServiceClass_UUID = '{00001102-0000-1000-8000-00805F9B34FB}' 
#拨号网络服务 
DialupNetworkingServiceClass_UUID = '{00001103-0000-1000-8000-00805F9B34FB}' 
#信息同步服务 
IrMCSyncServiceClass_UUID = '{00001104-0000-1000-8000-00805F9B34FB}' 
SDP_OBEXObjectPushServiceClass_UUID = '{00001105-0000-1000-8000-00805F9B34FB}' 
#文件传输服务 
OBEXFileTransferServiceClass_UUID = '{00001106-0000-1000-8000-00805F9B34FB}' 
IrMCSyncCommandServiceClass_UUID = '{00001107-0000-1000-8000-00805F9B34FB}' 
SDP_HeadsetServiceClass_UUID = '{00001108-0000-1000-8000-00805F9B34FB}' 
CordlessTelephonyServiceClass_UUID = '{00001109-0000-1000-8000-00805F9B34FB}' 
SDP_AudioSourceServiceClass_UUID = '{0000110A-0000-1000-8000-00805F9B34FB}' 
SDP_AudioSinkServiceClass_UUID = '{0000110B-0000-1000-8000-00805F9B34FB}' 
SDP_AVRemoteControlTargetServiceClass_UUID = '{0000110C-0000-1000-8000-00805F9B34FB}' 
SDP_AdvancedAudioDistributionServiceClass_UUID = '{0000110D-0000-1000-8000-00805F9B34FB}' 
SDP_AVRemoteControlServiceClass_UUID = '{0000110E-0000-1000-8000-00805F9B34FB}' 
VideoConferencingServiceClass_UUID = '{0000110F-0000-1000-8000-00805F9B34FB}' 
IntercomServiceClass_UUID = '{00001110-0000-1000-8000-00805F9B34FB}' 
#蓝牙传真服务 
FaxServiceClass_UUID = '{00001111-0000-1000-8000-00805F9B34FB}' 
HeadsetAudioGatewayServiceClass_UUID = '{00001112-0000-1000-8000-00805F9B34FB}' 
WAPServiceClass_UUID = '{00001113-0000-1000-8000-00805F9B34FB}' 
WAPClientServiceClass_UUID = '{00001114-0000-1000-8000-00805F9B34FB}' 
#个人局域网服务 
PANUServiceClass_UUID = '{00001115-0000-1000-8000-00805F9B34FB}' 
#个人局域网服务 
NAPServiceClass_UUID = '{00001116-0000-1000-8000-00805F9B34FB}' 
#个人局域网服务 
GNServiceClass_UUID = '{00001117-0000-1000-8000-00805F9B34FB}' 
DirectPrintingServiceClass_UUID = '{00001118-0000-1000-8000-00805F9B34FB}' 
ReferencePrintingServiceClass_UUID = '{00001119-0000-1000-8000-00805F9B34FB}' 
ImagingServiceClass_UUID = '{0000111A-0000-1000-8000-00805F9B34FB}' 
ImagingResponderServiceClass_UUID = '{0000111B-0000-1000-8000-00805F9B34FB}' 
ImagingAutomaticArchiveServiceClass_UUID = '{0000111C-0000-1000-8000-00805F9B34FB}' 
ImagingReferenceObjectsServiceClass_UUID = '{0000111D-0000-1000-8000-00805F9B34FB}' 
SDP_HandsfreeServiceClass_UUID = '{0000111E-0000-1000-8000-00805F9B34FB}' 
HandsfreeAudioGatewayServiceClass_UUID = '{0000111F-0000-1000-8000-00805F9B34FB}' 
DirectPrintingReferenceObjectsServiceClass_UUID = '{00001120-0000-1000-8000-00805F9B34FB}' 
ReflectedUIServiceClass_UUID = '{00001121-0000-1000-8000-00805F9B34FB}' 
BasicPringingServiceClass_UUID = '{00001122-0000-1000-8000-00805F9B34FB}' 
PrintingStatusServiceClass_UUID = '{00001123-0000-1000-8000-00805F9B34FB}' 
#人机输入服务 
HumanInterfaceDeviceServiceClass_UUID = '{00001124-0000-1000-8000-00805F9B34FB}' 
HardcopyCableReplacementServiceClass_UUID = '{00001125-0000-1000-8000-00805F9B34FB}' 
#蓝牙打印服务 
HCRPrintServiceClass_UUID = '{00001126-0000-1000-8000-00805F9B34FB}' 
HCRScanServiceClass_UUID = '{00001127-0000-1000-8000-00805F9B34FB}' 
CommonISDNAccessServiceClass_UUID = '{00001128-0000-1000-8000-00805F9B34FB}' 
VideoConferencingGWServiceClass_UUID = '{00001129-0000-1000-8000-00805F9B34FB}' 
UDIMTServiceClass_UUID = '{0000112A-0000-1000-8000-00805F9B34FB}' 
UDITAServiceClass_UUID = '{0000112B-0000-1000-8000-00805F9B34FB}' 
AudioVideoServiceClass_UUID = '{0000112C-0000-1000-8000-00805F9B34FB}' 
SIMAccessServiceClass_UUID = '{0000112D-0000-1000-8000-00805F9B34FB}' 
PnPInformationServiceClass_UUID = '{00001200-0000-1000-8000-00805F9B34FB}' 
GenericNetworkingServiceClass_UUID = '{00001201-0000-1000-8000-00805F9B34FB}' 
GenericFileTransferServiceClass_UUID = '{00001202-0000-1000-8000-00805F9B34FB}' 
GenericAudioServiceClass_UUID = '{00001203-0000-1000-8000-00805F9B34FB}' 
GenericTelephonyServiceClass_UUID = '{00001204-0000-1000-8000-00805F9B34FB}'

 

 

转载地址:http://wpysx.baihongyu.com/

你可能感兴趣的文章
js判断checkbox是否选中
查看>>
Eclipse中修改代码格式
查看>>
关于 error: LINK1123: failure during conversion to COFF: file invalid or corrupt 错误的解决方案...
查看>>
Linux 进程中 Stop, Park, Freeze【转】
查看>>
PHP盛宴——经常使用函数集锦
查看>>
重写 Ext.form.field 扩展功能
查看>>
Linux下的搜索查找命令的详解(locate)
查看>>
安装gulp及相关插件
查看>>
如何在Linux用chmod来修改所有子目录中的文件属性?
查看>>
Hyper-V 2016 系列教程30 机房温度远程监控方案
查看>>
笔记:认识.NET平台
查看>>
cocos2d中CCAnimation的使用(cocos2d 1.0以上版本)
查看>>
【吉光片羽】短信验证
查看>>
gitlab 完整部署实例
查看>>
GNS关于IPS&ASA&PIX&Junos的配置
查看>>
影响企业信息化成败的几点因素
查看>>
SCCM 2016 配置管理系列(Part8)
查看>>
struts中的xwork源码下载地址
查看>>
ABP理论学习之仓储
查看>>
我的友情链接
查看>>