我想知道两个设备间数据的传输需要做哪些事情,能说明下大致的框架吗?
http://download.csdn.net/detail/hyb745250618/8922395可以语音传输,也可以文字聊天
public void GetOncePswList(BluetoothGatt gatt,BluetoothGattCharacteristic characteristicRead,int flah)
{
byte[] frame = new byte[5];
frame[0] = 0x7E;
frame[1] = 0x1d;
frame[2] = 0x0;
try
{
final boolean writeRequest = (mRXCharacteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0;
if (writeRequest) { // no WRITE REQUEST property
frame[3] = (byte)(GetCHSum(frame));
frame[4] = 0x7E;
mRXCharacteristic.setValue(frame);
} else { // there is WRITE REQUEST property
mRXCharacteristic.setValue(frame);
mBufferOffset = frame.length;
}
writeCharacteristic(mRXCharacteristic);
}
catch (Exception ex)
{
Toast.makeText(this, "异常!!!", Toast.LENGTH_SHORT).show();
}
}
可以参考google的sample:https://github.com/googlesamples/android-BluetoothChat
,已经实现了通过蓝牙进行聊天的功能了。