Not more, Bluetooth Communication
1:1 Translate Data
Not 1:N
-
permission check
-
Initialize BT Class
/// Activity = Current Activity or Target Activity, Interval = On Read Interval Time (ms),
/// RWBufferSize = I/O Buffer Size, read = OnRead Method
public BT(Activity activity, int Interval, int RWBufferSize, OnReadMethod read)
for example
BT bt = new BT(MainActivity.this, 500, 1024,new BT.OnReadMethod() {
@Override
public void OnRead(byte[] data) {
///Do Something
}
});
///device = target device for connection, _flagIO = bitflag (INPUT, OUTPUT) for Open Stream
public synchronized void Connect(BluetoothDevice device, char _FlagIO)
for example
//For Input
bt.Connect(device, BT.INPUT);
//For Output(
bt.Connect(device, BT.OUTPUT);
//For Input/Output
bt.Connect(device, BT.OUTPUT | BT.INPUT);
public synchronized void Write(byte[] data)
getDeviceList : return Set < BluetoothDevice >
CheckWithEnableBluetooth : Activate Bluetooth
Disconnect : Disconnect Connection
public interface OnReadMethod
{
void OnRead(byte[] data);
}
-
전송측과 수신측의 전송 속도가 같아야 데이터가 온전함(데이터가 누락되지 않음) -> 추후 개선 가능함
-
오가는 데이터가 클수록 전송과 수신측의 Interval이 길수록 안정적임. (1번의 이유 때문에) -> 개선 가능함