您的位置:首页 > 移动开发 > Android开发

android通过蓝牙向低功耗蓝牙设备写数据

2018-01-19 17:08 330 查看

设备:

android 手机

BLE 蓝牙模块

Arduino Due

备注:

蓝牙连接暂时不写,等手机蓝牙连接BLE蓝牙模块和树莓派内置蓝牙模块2种方式程序写完后,在回来补充。

向BLE蓝牙设备写数据:

写字符串

currentcharac.setValue("test");
m_BT.writeCharacteristic(currentcharac);
//currentcharac是BluetoothGattCharacteristic类型
//m_BT是BluetoothGatt类型






写字节

byte[] bb1 = "12345".getBytes();
currentcharac.setValue(bb);
m_BT.writeCharacteristic(currentcharac);
//手机上回显
byte[] bb2 = currentcharac.getValue();
String str = new String(bb2);




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  BLE