华为荣耀7蓝牙版本6蓝牙是4.0ble吗

分享emui4.0整套的包【华为荣耀6吧】_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:169,980贴子:
分享emui4.0整套的包收藏
因为没进第五批内侧,所以昨天想刷emui4.0,发现竟然没有一整套的开发板回退的包,自己一个一个找起来挺麻烦,现在找到分享出来,给有需要的节省点时间...
正版授权奇迹MU页游,奇迹重生!原汁原味还原奇迹,十年轮回!
这是开发板回退包,几k
这是稳定版535的完整包
说错了,这才是稳定版完整包,上个是升级4.0的包
emui4.0蓝牙能用了吗
楼主是联通的,不知道移动版能不能用
移动版有么
刷泄露包,后还会推送升级吗
奇迹重生,重铸辉煌,新版魔剑士归来!海量钻石,众多好礼,你敢拿我就送!
有没有l01 6.2.1的回退包?
我明明放到这个文件夹里了,怎么回事啊
不会用电脑解压,需要什么工具从电脑上找的手机这个包么
现在是b316,可以直接下载最新6.2.1完整包升级手机吗???
6.2.1的中转包吗
楼主我是l02 b532,给说下升级4.0的教程呗
楼主我这怎么升级4.0是直接下载还是
楼主刷完 怎么升级811
4.0的不能解压那怎么升级?
4.0一键锁屏还在吗?
请问为什么没收到809或811的推送?就停在807了
都更新啥了?
楼主我现在是b535,这样弄对吗,为啥点本地更新没有用……
能帮我看看?么,为什么这么卡~!!!!!
感谢了,留着备用,同联通标配,主要手机东西多杂,刷机弄着麻烦
登录百度帐号推荐应用匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。后使用快捷导航没有帐号?
平板/笔记本
云服务专区
荣耀6蓝牙BT4.0BLE连接不稳定,时常断线
&初窥门径&
来自:浏览器
本帖最后由 渺小公民 于
10:15 编辑
因信赖华为大品牌且支持国货,买了荣耀6并看中蓝牙BT4.0BLE低功耗蓝牙功能。
传输功能DLNA不支持Wi-Fi功能支持2.4G/5G,802.11 a/b/g/nWi-Fi热点支持8个设备接入WiFi Display支持WLAN Direct支持GPSGPS/Glonass/AGPS导航软件内置“驾驶模式”支持地图导航、语音控制接打电话、播放音乐;内置“指路精灵”实现实景导航;预装高德地图蜂窝网络定位支持WLAN网络定位支持蓝牙BT4.0 BLE网卡USB tetheringUSBUSB 2.0 HS,MicroUSB接口,支持对外充电
2014年10月份收到蓝牙防丢器,支持BT4.0BLE,连接荣耀6出现不稳定现象。自带蓝牙打开搜索不到蓝牙防丢器,首次安装软件后可以找到,但经常丢失信号(两个设备间的距离只有10公分左右),关闭软件再连接就查找不到设备。利用Iphone4s、三星Galaxy S4、华为mate7、华为荣耀X1分别测试后,发现问题只出现在华为手机。Iphone4S、Galaxy S4都能正常查找到该蓝牙防丢器,安装软件按后连接成功并不掉线,使用正常。华为mate7自带蓝牙无法搜索到该设备,安装软件后也无法查找到该设备;荣耀X1自带蓝牙能搜索到设备名,但该设备软件不支持X1,所以有理由怀疑华为的BT4.0BLE存在BUG。已经联系华为技术支持和售后两周,至今未给出处理方案。送华为南通华为客户服务中心艺丰环城南路店检测,告之无故障,本人要求提供测试蓝牙的版本,至今提供不出,只是一口咬定手机无故障,蓝牙无故障,并且蓝牙防丢器非华为产品(试问华为手机只是针对自家设备而生产吗?BT4.0的协议是华为自家的吗?)。已投诉该部门到华为官方N次,没有任何处理,对华为的态度十分的失望,作为国内的大品牌居然纵容授权维修部如此不负责任的对客户手机进行检测,居心何在?作为华为的忠实用户,bug不可怕,可怕的是华为对待用户提出问题的处理态度,如华为不重视客户的使用体验及提出的问题,势必迫使我们谨而远之。以上并非无中生有,每次电话都有录音为证,希望华为认真审视此问题,拿出必要的姿态。
(103.04 KB, 下载次数: 16)
09:44 上传
width:100%">
&已臻大成&
来自:浏览器
楼主您好,因为硬件方面的确需要售后出具检测报告,论坛是无法通过您的描述给出硬件的解决办法的。不过我自己的一点认识是此蓝牙防丢器配套的手机应用对荣耀6或其他华为手机是否完全适配存在疑问。如果对售后的服务有疑问可以在此帖跟帖回复,有专人负责跟进的。
width:100%">
&略有小成&
来自:浏览器
BLE设备要在apk中配对和使用,在蓝牙设置界面搜不到的,因为就算能搜到连接了也不稳定,可能就是因为这个华为才把设置界面搜到BLE设备的功能关了
width:100%">
&新学乍练&
来自:浏览器
我的MT7也出现过类似的问题,买了个华为手环连接后每天都会出现3-4次信号中断问题,连接蓝牙耳机打电话时也是经常会出现通话过程中,信号断断续续的杂音!
width:100%">
&已臻大成&
来自:浏览器
width:100%">
&新学乍练&
来自:浏览器
可以仔细看看是不是会有蓝牙授权提示干扰,我的cookoo手表连p7就是如此,每次都是因为授权问题,导致连接不稳定,不过C8817e完全没问题,可见不是硬件问题,只能说华为的UI实在*。
width:100%">
&新学乍练&
来自:浏览器
我的华为6 也是这样,每次连接蓝牙4.0 都要重启手机,才能收到数据,如果这些问题不解决,对客户提出的bug 不管不问,那就一个字*,就连个论坛也做不了,我登录了五次都不能评论 让我登录。
width:100%">
&新学乍练&
来自:浏览器
真心 希望你们好好做,把这些bug 解决了,很恶心的,这些低级的bug 就能区别*产品和高端产品的区别,我就想问每次连接蓝牙4.0都要重启手机,这种*手机 你们怎么敢卖 1000多!
width:100%">
&新学乍练&
来自:浏览器
华为BLE BUG真多,希望新版本可以改善,你是要搞死我们开发app的么
width:100%">
&登堂入室&
来自:浏览器
楼主&&我连蓝牙耳机 和 蓝牙音箱 播放 很卡,像磁带卡主那种感觉,是不是蓝牙的问题
width:100%">
花粉特种部队荣耀勋章
好基友勋章
花粉好机友,注册时间大于99天
老茶馆众生随拍:黑煤球的业余生活红枫《川西高原》潜伏墨荷墨荷
花粉客户端
Make it Possible
Make your device special
华为云服务
Huawei cloud services
音乐播放器
Huawei Music
Huawei Vmall
没有最新动态
关注花粉俱乐部
举报邮箱:
|关注花粉俱乐部:
Copyright (C)
华为软件技术有限公司 版权所有 保留一切权利华为荣耀6 在android6.0版本 调用蓝牙时无法扫描到设备
代码如下(基本跟github的一样&但是已经无法扫描到设备)
这里没有调动ListView的adpater
只是简单的进行扫描
将扫描结果放到Textview
&&&&&uses-permission&android:name="android.permission.BLUETOOTH"&/&
&&&&&uses-permission&android:name="android.permission.BLUETOOTH_ADMIN"&/&
&&&&&uses-feature&android:name="android.hardware.bluetooth_le"&android:required="true"&/&
public&class&MainActivity&extends&Activity&{
private&static&final&int&OPENBLUETOOTH&=&1001;
private&BluetoothAdapter&blueToothA
private&Handler&mHandler&=&new&Handler();
private&boolean&mS
private&BlueAdapter&
private&TextView&
private&ListView&
protected&void&onCreate(Bundle&savedInstanceState)&{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv&=&(TextView)&findViewById(R.id.tv1);
lv&=&(ListView)&findViewById(R.id.listview);
Button&c1&=&(Button)&findViewById(R.id.click1);
Button&c2&=&(Button)&findViewById(R.id.click2);
adapt&=&new&BlueAdapter();
lv.setAdapter(adapt);
BluetoothManager&bluetoothManager&=&(BluetoothManager)&getSystemService(Context.BLUETOOTH_SERVICE);
blueToothAdapter&=&bluetoothManager.getAdapter();
c1.setOnClickListener(new&OnClickListener()&{
public&void&onClick(View&v)&{
//&TODO&Auto-generated&method&stub
c2.setOnClickListener(new&OnClickListener()&{
public&void&onClick(View&v)&{
//&blueToothAdapter&=&BluetoothAdapter.getDefaultAdapter();
if&(blueToothAdapter&==&null&||&!blueToothAdapter.isEnabled())&{
Intent&enableBtIntent&=&new&Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent,&OPENBLUETOOTH);
scanLeDevice(true);
//&getDeviceInfo();
protected&void&onActivityResult(int&requestCode,&int&resultCode,&Intent&data)&{
if&(requestCode&==&OPENBLUETOOTH&&&&resultCode&==&RESULT_OK)&{
Toast.makeText(this,&"开启成功",&Toast.LENGTH_SHORT).show();
scanLeDevice(true);
//&getDeviceInfo();
private&void&Check()&{
if&(!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE))&{
Toast.makeText(this,&"不支持BLE",&Toast.LENGTH_SHORT).show();
Toast.makeText(this,&"支持BLE",&Toast.LENGTH_SHORT).show();
&*&@param&enable
private&void&scanLeDevice(final&boolean&enable)&{
if&(enable)&{
//&Stops&scanning&after&a&pre-defined&scan&period.
mHandler.postDelayed(new&Runnable()&{
public&void&run()&{
mScanning&=&
Toast.makeText(getApplicationContext(),&"暂停扫描",&Toast.LENGTH_SHORT).show();
blueToothAdapter.stopLeScan(testBlueCallBack);
},&60000);
mScanning&=&
blueToothAdapter.startLeScan(testBlueCallBack);
Toast.makeText(getApplicationContext(),&"开始扫描",&Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),&"暂停扫描",&Toast.LENGTH_SHORT).show();
mScanning&=&
blueToothAdapter.stopLeScan(testBlueCallBack);
&*&获取已经配对的列表
private&void&getDeviceInfo()&{
Set&BluetoothDevice&&devices&=&blueToothAdapter.getBondedDevices();
if&(devices.size()&==&0)&{
Map&String,&String&&list&=&new&HashMap&String,&String&();
int&i&=&0;
for&(Iterator&iterator&=&devices.iterator();&iterator.hasNext();)&{
BluetoothDevice&device&=&(BluetoothDevice)&iterator.next();
device.getUuids();
list.put("key"&+&i,&device.getAddress()&+&"&"&+&device.getName());
Log.d("mytag",&device.getAddress()&+&"----"&+&device.getName());
adapt.setList(list);
adapt.notifyDataSetChanged();
&*&是通过startLeScan(BlueToothAdapter.LeScanCallback)函数调用之后&,&会初始化一个device对象&;
&*&当一个LE设备被发现的时候&,&这个对象device作为参数传递进来
private&BluetoothAdapter.LeScanCallback&testBlueCallBack&=&new&LeScanCallback()&{
&*&device&:&识别的远程设备&rssi&:&RSSI的值作为对远程蓝牙设备的报告;&0代表没有蓝牙设备;&scanRecode:
&*&远程设备提供的配对号(公告)
public&void&onLeScan(BluetoothDevice&device,&int&rssi,&byte[]&scanRecord)&{
//&Toast.makeText(getApplicationContext(),&device.getName(),
//&Toast.LENGTH_SHORT).show();
final&BluetoothDevice&dev&=&
final&String&record&=&String.valueOf(scanRecord);
runOnUiThread(new&Runnable()&{
public&void&run()&{
//只是将扫描到的终端的名字跟地址写到Textview
tv.setText("蓝牙地址:"&+&dev.getName()&+&"-----蓝牙配对号:"&+&record);
private&BluetoothGattCallback&bgc&=&new&BluetoothGattCallback()&{
public&void&onConnectionStateChange(BluetoothGatt&gatt,&int&status,&int&newState)&{
-------------------------------
来个&高人&来看看啊
-------------------------------
那你有Ble的设备吗?
-------------------------------
我手提电脑有蓝牙&我身边有3台开了蓝牙的手机(可发现状态)
-------------------------------
引用&3&楼&GW10964&的回复:
我手提电脑有蓝牙&我身边有3台开了蓝牙的手机(可发现状态)
就是说你能确定你的手提电脑上的是Ble吗?&一般不是Ble就是普通的蓝牙呢
-------------------------------
蓝牙4.0&我可以确定是BLE
-------------------------------
那你蓝牙4.0的手机能找到它吗?
-------------------------------
你程序有这么多Log.d,你查下不就可以了,至少知道到哪步了
-------------------------------
android&6.0&扫描蓝牙设备需要权限
&uses-permission-sdk-23&android:name="android.permission.ACCESS_COARSE_LOCATION"/&
再在代码中请求
&&&&&&&&if&(Build.VERSION.SDK_INT&=23)
&&&&&&&&&&&&if&(ContextCompat.checkSelfPermission(this,&Manifest.permission.ACCESS_COARSE_LOCATION)&!=&PackageManager.PERMISSION_GRANTED)&{
&&&&&&&&&&&&&&&&ActivityCompat.requestPermissions(this,&new&String[]{Manifest.permission.ACCESS_COARSE_LOCATION},&10);&&&}
&&&&&&&&&&&&}
-------------------------------
朋友你这个问题解决了吗,如果解决了,能分享下解决方法吗,最近在学习蓝牙4.0编程中也遇到你这个问题了。方便交流一下吗,
Android之获取网络数据并且用lis
android如何预置txt文件
Adapter万能适配器,只要3行
Android 实现卸载应用的相关问题,
Android实现ImageView加边
系统升级成win10 后,eclipse
调用webservice查询手机号码归属
关于Android复制项目改名
求助!!自定义控件中其中一个命名空间无法
Android读取一个已经安装的包的权限
Android ScrollView用法
listview内嵌套edittext,
handler空指针问题
如何在android studio中用J
GirdView 的问题
地区选择器
Android编译安卓源码 找不到c++
android tv测试可以用模拟器吗
发布图片 选择好了图片后,全屏大图预览
android Twitter shar
webView 获取H5界面的全局变量
变态需求导致程序异常退出的问题
利用EventBus来实现通信遇到的问题
怎样用 HttpURLConnectio
《Android开发从零开始》13.Ta
Android6.0 执行shell命令
解决Android获取网络图片过大的问题
大神们,本人想自己闲余时间开发一个自己的
Android判断sdcard是否存在以
Android简易UDP通信模型
Android涂鸦毛笔的效果
类似这种效果的画笔怎么实现的?-----...
安卓开发,圆形头像里面是怎么播放视频的?
有没有大神知道
那个直播 圆形头...
pull方法解析复杂的xml文件 (有重
第一张图是xml文件,按照红字看就明白了...
使用aar包,出现java.lang.C
将自己的一个module打包成aar文件...
安卓开发,点击左边分类listView的
问题一:如图,点击左边的分类listVi...
【定时器中为什么不能放toast???】
除了toast以外,如果是在定时器里面更...
eclipse加载SDK时报错
这是报错的内容:这是我下载的SDK里的内...
APK Signature Scheme
以这个形式打包的APK,手机不能安装。模...
安卓开发看不到button
本帖最后由SakuraSamura1于2...
Android WebView调用加载w
我用angularJS+ionic做了个...
在webform中,我们可以通过usercontrol将多个控件集合做成一个组件...
.....<span style=...
将窗体1中的DataGreadView中的数据在窗体2刷新,并且不需要关闭窗体1...
在C#中,动态创建的标准Button按钮和鼠标绘制的图元,想在程序运行后能一起操...
private void button8_Click(object sende...
@"^http://www.myd.net/ddd.php?id=(\d+)$"...
定义private System.Timers.Timer 每10秒钟遍历c:\...
项目需要需要通过工控机控制PLC,进而控制连接在PLC上的设备根据这个情况一开始...
select CarNo from [A] where CarMMID=133...
本帖最后由leang22于7:03:36编辑各位好ASP....
我使用foreach(DataColumn col in ds1.Tables[...
本人在做项目时,需要写一些小插件来辅助建库,查询数据时候,动态添加t选项卡和数据...
  在很多新手在做搜刮引擎优化优化的时间,都不晓得有效户体验这一种说法,只晓得能...
本帖最后由u于5:57:52编辑UTF-...
  这两天的网站蜘蛛日志还有文章的收录情况来看。百度蜘蛛现在天天都会抓取网站的内...
  做网站优化的最终目的就是为了不断提升网站的排名,于是开始不断采用各种方法来达...
VS2013不显示引用次数, 只显示“-引用,求大神指教!”以下是关于本问题的解...
良多SEOER为了能够让网站获得更好的排名,猛的添加某关键词的锚文本链接,可是锚...
事情是这样的:我在 GitHub 发现了 Shiqi.Yu 的人脸检测算法的 d...
外链也是做好SEO一大关键因素,甚至可以理解为:大家都有做原创时,SEO竞争所在...分享Android 蓝牙4.0(ble)开发的解决方案
作者:请叫我小东子
字体:[ ] 类型:转载 时间:
这篇文章主要为大家分享了Android 蓝牙4.0(ble)开发的解决方案,感兴趣的小伙伴们可以参考一下
最近,随着智能穿戴式设备、智能医疗以及智能家居的普及,蓝牙开发在移动开中显得非常的重要。由于公司需要,研究了一下,蓝牙4.0在Android中的应用。
以下是我的一些总结。
1.先介绍一下关于蓝牙4.0中的一些名词吧:&&&
(1)、GATT(Gneric Attibute& Profile)
通过ble连接,读写属性类小数据Profile通用的规范。现在所有的ble应用Profile& 都是基于GATT
(2)、ATT(Attribute Protocal)
GATT是基于ATT Potocal的ATT针对BLE设备专门做的具体就是传输过程中使用尽量少的数据,每个属性都有个唯一的UUID,属性chartcteristics and Service的形式传输。
(3)、Service是Characteristic的集合。
(4)、Characteristic 特征类型。
比如,有个蓝牙ble的血压计。他可能包括多个Servvice,每个Service有包括多个Characteristic
注意:蓝牙ble只能支持Android 4.3以上的系统 SDK&=18
2.以下是开发的步骤:
2.1首先获取BluetoothManager&
代码如下:BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);&
2.2获取BluetoothAdapter
代码如下:BluetoothAdapter mBluetoothAdapter = bluetoothManager.getAdapter();&
2.3创建BluetoothAdapter.LeScanCallback
private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
public void onLeScan(final BluetoothDevice device, int rssi, final byte[] scanRecord) {
runOnUiThread(new Runnable() {
public void run() {
String struuid = NumberUtils.bytes2HexString(NumberUtils.reverseBytes(scanRecord)).replace("-", "").toLowerCase();
if (device!=null && struuid.contains(DEVICE_UUID_PREFIX.toLowerCase())) {
mBluetoothDevices.add(device);
} catch (Exception e) {
e.printStackTrace();
2.4.开始搜索设备。
代码如下:mBluetoothAdapter.startLeScan(mLeScanCallback);&
2.5.BluetoothDevice& 描述了一个蓝牙设备 提供了getAddress()设备Mac地址,getName()设备的名称。
2.6开始连接设备
* Connects to the GATT server hosted on the Bluetooth LE device.
* @param address
The device address of the destination device.
* @return Return true if the connection is initiated successfully. The
connection result is reported asynchronously through the
{@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)}
public boolean connect(final String address) {
if (mBluetoothAdapter == null || address == null) {
Log.w(TAG, "BluetoothAdapter not initialized or unspecified address.");
// Previously connected device. Try to reconnect. (先前连接的设备。 尝试重新连接)
if (mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress) && mBluetoothGatt != null) {
Log.d(TAG, "Trying to use an existing mBluetoothGatt for connection.");
if (mBluetoothGatt.connect()) {
mConnectionState = STATE_CONNECTING;
final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
if (device == null) {
Log.w(TAG, "Device not found. Unable to connect.");
// We want to directly connect to the device, so we are setting the
// autoConnect
// parameter to false.
mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
Log.d(TAG, "Trying to create a new connection.");
mBluetoothDeviceAddress =
mConnectionState = STATE_CONNECTING;
2.7连接到设备之后获取设备的服务(Service)和服务对应的Characteristic。
// Demonstrates how to iterate through the supported GATT
// Services/Characteristics.
// In this sample, we populate the data structure that is bound to the
// ExpandableListView
// on the UI.
private void displayGattServices(List&BluetoothGattService& gattServices) {
if (gattServices == null)
String uuid =
ArrayList&HashMap&String, String&& gattServiceData = new ArrayList&&();
ArrayList&ArrayList&HashMap&String, String&&& gattCharacteristicData = new ArrayList&&();
mGattCharacteristics = new ArrayList&&();
// Loops through available GATT Services.
for (BluetoothGattService gattService : gattServices) {
HashMap&String, String& currentServiceData = new HashMap&&();
uuid = gattService.getUuid().toString();
if (uuid.contains("ba11f08c-5f14-0b0d-1080")) {//服务的uuid
//System.out.println("this gattService UUID is:" + gattService.getUuid().toString());
currentServiceData.put(LIST_NAME, "Service_OX100");
currentServiceData.put(LIST_UUID, uuid);
gattServiceData.add(currentServiceData);
ArrayList&HashMap&String, String&& gattCharacteristicGroupData = new ArrayList&&();
List&BluetoothGattCharacteristic& gattCharacteristics = gattService.getCharacteristics();
ArrayList&BluetoothGattCharacteristic& charas = new ArrayList&&();
// Loops through available Characteristics.
for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
charas.add(gattCharacteristic);
HashMap&String, String& currentCharaData = new HashMap&&();
uuid = gattCharacteristic.getUuid().toString();
if (uuid.toLowerCase().contains("cd01")) {
currentCharaData.put(LIST_NAME, "cd01");
} else if (uuid.toLowerCase().contains("cd02")) {
currentCharaData.put(LIST_NAME, "cd02");
} else if (uuid.toLowerCase().contains("cd03")) {
currentCharaData.put(LIST_NAME, "cd03");
} else if (uuid.toLowerCase().contains("cd04")) {
currentCharaData.put(LIST_NAME, "cd04");
currentCharaData.put(LIST_NAME, "write");
currentCharaData.put(LIST_UUID, uuid);
gattCharacteristicGroupData.add(currentCharaData);
mGattCharacteristics.add(charas);
gattCharacteristicData.add(gattCharacteristicGroupData);
mCharacteristicCD01 = gattService.getCharacteristic(UUID.fromString("0-805f9b34fb"));
mCharacteristicCD02 = gattService.getCharacteristic(UUID.fromString("0-805f9b34fb"));
mCharacteristicCD03 = gattService.getCharacteristic(UUID.fromString("0-805f9b34fb"));
mCharacteristicCD04 = gattService.getCharacteristic(UUID.fromString("0-805f9b34fb"));
mCharacteristicWrite = gattService.getCharacteristic(UUID.fromString("0-805f9b34fb"));
//System.out.println("=======================Set Notification==========================");
// 开始顺序监听,第一个:CD01
mBluetoothLeService.setCharacteristicNotification(mCharacteristicCD01, true);
mBluetoothLeService.setCharacteristicNotification(mCharacteristicCD02, true);
mBluetoothLeService.setCharacteristicNotification(mCharacteristicCD03, true);
mBluetoothLeService.setCharacteristicNotification(mCharacteristicCD04, true);
2.8获取到特征之后,找到服务中可以向下位机写指令的特征,向该特征写入指令。
public void wirteCharacteristic(BluetoothGattCharacteristic characteristic) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
mBluetoothGatt.writeCharacteristic(characteristic);
2.9写入成功之后,开始读取设备返回来的数据。
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
String intentA
//System.out.println("=======status:" + status);
if (newState == BluetoothProfile.STATE_CONNECTED) {
intentAction = ACTION_GATT_CONNECTED;
mConnectionState = STATE_CONNECTED;
broadcastUpdate(intentAction);
Log.i(TAG, "Connected to GATT server.");
// Attempts to discover services after successful connection.
Log.i(TAG, "Attempting to start service discovery:" + mBluetoothGatt.discoverServices());
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
intentAction = ACTION_GATT_DISCONNECTED;
mConnectionState = STATE_DISCONNECTED;
Log.i(TAG, "Disconnected from GATT server.");
broadcastUpdate(intentAction);
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
Log.w(TAG, "onServicesDiscovered received: " + status);
//从特征中读取数据
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
//System.out.println("onCharacteristicRead");
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
//向特征中写入数据
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
//System.out.println("--------write success----- status:" + status);
* when connected successfully will callback this method this method can
* dealwith send password or data analyze
*当连接成功将回调该方法
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
if (characteristic.getValue() != null) {
//System.out.println(characteristic.getStringValue(0));
//System.out.println("--------onCharacteristicChanged-----");
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
//System.out.println("onDescriptorWriteonDescriptorWrite = " + status + ", descriptor =" + descriptor.getUuid().toString());
UUID uuid = descriptor.getCharacteristic().getUuid();
if (uuid.equals(UUID.fromString("0-805f9b34fb"))) {
broadcastUpdate(ACTION_CD01NOTIDIED);
} else if (uuid.equals(UUID.fromString("0-805f9b34fb"))) {
broadcastUpdate(ACTION_CD02NOTIDIED);
} else if (uuid.equals(UUID.fromString("0-805f9b34fb"))) {
broadcastUpdate(ACTION_CD03NOTIDIED);
} else if (uuid.equals(UUID.fromString("0-805f9b34fb"))) {
broadcastUpdate(ACTION_CD04NOTIDIED);
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
//System.out.println("rssi = " + rssi);
----------------------------------------------
//从特征中读取数据
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
//System.out.println("onCharacteristicRead");
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
2.10、断开连接
* Disconnects an existing connection or cancel a pending connection. The
* disconnection result is reported asynchronously through the
* {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)}
* callback.
public void disconnect() {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
mBluetoothGatt.disconnect();
2.11、数据的转换方法
// byte转十六进制字符串
public static String bytes2HexString(byte[] bytes) {
String ret = "";
for (byte aByte : bytes) {
String hex = Integer.toHexString(aByte & 0xFF);
if (hex.length() == 1) {
hex = '0' +
ret += hex.toUpperCase(Locale.CHINA);
* 将16进制的字符串转换为字节数组
* @param message
* @return 字节数组
public static byte[] getHexBytes(String message) {
int len = message.length() / 2;
char[] chars = message.toCharArray();
String[] hexStr = new String[len];
byte[] bytes = new byte[len];
for (int i = 0, j = 0; j & i += 2, j++) {
hexStr[j] = "" + chars[i] + chars[i + 1];
bytes[j] = (byte) Integer.parseInt(hexStr[j], 16);
大概整体就是如上的步骤,但是也是要具体根据厂家的协议来实现通信的过程。
就拿一个我们项目中的demo说一下。
一个蓝牙ble的血压计。 上位机---手机& 下位机 -- 血压计
1.血压计与手机连接蓝牙之后。
2.上位机主动向下位机发送一个身份验证指令,下位机收到指令后开始给上位做应答,
3.应答成功,下位机会将测量的血压数据传送到上位机。
4.最后断开连接。
希望本文对大家学习Android蓝牙技术有所帮助。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具

我要回帖

更多关于 华为荣耀5x蓝牙版本 的文章

 

随机推荐