我正在研究一个通过蓝牙 LE 向其发送数据的 Android 应用程序。这里有两种方法我很困惑。有人可以解释这两种方法及其相互关系:
private String localmessage = null;
public void Send_Oe_Ef(BluetoothDevice device,String message)
{
localmessage= message;
Send_Oe_Ef(device);
}
public void Send_Oe_Ef(BluetoothDevice device)
{
boolean result = false;
Log.i(TAG, "Send_Oe_Ef ");
isNoti = true;
BluetoothGattService mCC2540 = mBluetoothGatt.getService(device, CC2540_SERVICE);
if (mCC2540 == null)
{
Log.e(TAG, "CC2540 service not found!");
return;
}
BluetoothGattCharacteristic mHRMcharac = mCC2540.getCharacteristic(CC2540_CHARACTERISTIC);
if (mHRMcharac == null) {
Log.e(TAG, "CC2540 charateristic not found!");
return;
}
byte[] value = new byte[14];
value[0] = (byte) 1;
value[1] = (byte) 2;
value[2] = (byte) 3;
value[3] = (byte) 4;
value[4] = (byte) 5;
value[5] = (byte) 6;
value[6] = (byte) 7;
value[7] = (byte) 8;
value[8] = (byte) 9;
value[9] = (byte) 10;
value[10] = (byte) 11;
value[11] = (byte) 12;
value[12] = (byte) 13;
value[13] = (byte) 14;
try
{
value = localmessage.getBytes("UTF-8");
} catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
mHRMcharac.setValue(value);
mBluetoothGatt.writeCharacteristic(mHRMcharac);
Log.e(TAG, "SetValue");
}
提前致谢