public async Task <bool> SystemHello(int timeoutMs = 4000) { // This is a ping event. Return's true if device responds, // false if the valid response is not received before the given timeout var cmd = _bglib.BLECommandSystemHello(); await _bglib.SendCommandAsync(cmd).ConfigureAwait(false); bool didTimeout = false; using (var cts = new CancellationTokenSource(timeoutMs)) { try { await _cmdRespWaitHandle.WaitAsync(cts.Token).ConfigureAwait(false); } catch (OperationCanceledException) { didTimeout = true; } } return(!didTimeout && _lastResponseArgs is HelloEventArgs); }