设备:
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);