BluetoothGatt 踩坑
来源:互联网 发布:噪声测量记录软件 编辑:程序博客网 时间:2024/06/16 23:26
1.BluetoothGatt 超过20个字节,导致后面的数据丢了
注:与仪器通信,我们这里发送的是16进制的数据,发送的时候需要先将其装载到byte[]数组中,例如我发送 7e 14 00 00 00 aa这个指令,我需要把它转化为ew byte[] {0x7e, 0x14, 0x00, 0x00,0x00,(byte) 0xaa }这样去发送,因为BLE传输过程每次最大只能传输20个字节,所以如果发送的指令大于20字节的话要分包发送,例如现在要发送28个字节的,可以先write(前20个字节),开启线程sleep(几十毫秒)后在write(后面8个字节)。
WriteBytes = writeBytes; BluetoothGattCharacteristic gg; gg=mBluetoothGatt.getService(UUID.fromString(Service_uuid)).getCharacteristic(UUID.fromString(Characteristic_uuid_TX)); //byte t[]={51,1,2}; gg.setValue(WriteBytes); mBluetoothGatt.writeCharacteristic(gg); if (writeBytes.length>20) { byte[] secondBytes = new byte[writeBytes.length-20]; try { Thread.sleep(10); for (int i = 20,j=0; i < writeBytes.length; i++,j++) { secondBytes[j] = writeBytes[i]; } gg.setValue(secondBytes); mBluetoothGatt.writeCharacteristic(gg); } catch (InterruptedException e) { e.printStackTrace(); } }
阅读全文
0 0
- BluetoothGatt 踩坑
- BluetoothGatt﹕ android.os.DeadObjectException
- Android BLE开发之BluetoothGatt status 133
- Android BluetoothGatt和周边BluetoothGattServer的实现
- Android蓝牙4.0API-类-BluetoothGatt
- android BluetoothGatt.writeCharacteristic()写入返回false
- Android BLE开发之BluetoothGatt status 133
- Android 三星手机 4.3 BlueToothGatt Failed to register callback
- android 蓝牙 onServicesDiscovered 返回的BluetoothGatt中的特征未更新
- Android中BLE连接出现“BluetoothGatt status 133”的解决方法
- Android BLE 蓝牙低功耗教程,中央BluetoothGatt和周边BluetoothGattServer的实现
- Android BLE 蓝牙低功耗教程,中央BluetoothGatt和周边BluetoothGattServer的实现
- Android BLE 蓝牙低功耗教程,中央BluetoothGatt和周边BluetoothGattServer的实现
- Android蓝牙开发教程:中央BluetoothGatt和周边BluetoothGattServer的实现
- Android BLE 蓝牙低功耗教程,中央BluetoothGatt和周边BluetoothGattServer的实现
- Android BLE 蓝牙低功耗教程,中央BluetoothGatt和周边BluetoothGattServer的实现
- Android BLE 蓝牙低功耗教程,中央BluetoothGatt和周边BluetoothGattServer的实现
- Android BLE 蓝牙低功耗教程,中央BluetoothGatt和周边BluetoothGattServer的实现
- java中使用JXL对Excel文件进行数据的写入、导出操作
- 每个人都有很菜的时候--“高手”请尊重!
- MessageSource
- 源码剖析Fragment的Pause生命周期
- [HDU 6090]Rikka with Graph
- BluetoothGatt 踩坑
- Qt和槽机制
- 关于征集《全国NB-IOT产品手册》基础信息的函
- Gcd HYSBZ
- 随机获取一句话
- NSQ服务器及PHP客户端搭建
- LinkedList关键点分析
- 笔试题(LRU)算法之JAVA实现
- window系统对应默认IE浏览器版本