public byte[] BleReadChar() { if (!IsConnected) { Error("BleWriteChar when no device is connect!"); } if (CsrBleDll.CsrBleClientReadCharByHandle(CurDevInfo.ConnHandle, (ushort)CurDevInfo.ReadHandle)) { if (_readEvent.WaitOne(5000)) { Debug("BleWriteChar SUCCESS!"); return(_readBytes); } } Debug("BleWriteChar FAIL!"); return(null); }
public async Task <byte[]> BleClientReadChar(BleGattCharacteristic character) { return(await Task.Run(() => { if (!character.Service.GattDevice.Connected) { Error("[CSR]:BleClientReadChar when device is not connect!"); return null; } if (CsrBleDll.CsrBleClientReadCharByHandle(character.Service.GattDevice.Handle, character.Handle)) { if (_readEvent.WaitOne(5000)) { Debug("[CSR]:BleClientReadChar Success!"); return _readBytes; } } Debug("[CSR]:BleClientReadChar Fail!"); return null; })); }