private static void OnRequestRemoteUnlock(bool isAuthorized) { // 効果音を再生 PlayDetectNFCTagSound(isAuthorized); if (isAuthorized) { Logger.Trace("REMOTE UNLOCK"); Gpio21.Value = 1; SetState(HostState.Unlocked); } else { SetState(HostState.Rejected); } UnlockTimer.Stop(); UnlockTimer.Start(); }
private static void TagtoolProc_OutputDataReceived(object sender, DataReceivedEventArgs e) { try { Logger.Trace("Detect tag: " + (e.Data ?? "").Substring(0, 9) + "..."); Debug.Trace("Raw data : " + e.Data); // 生の ID はデバッグ時のみ var hashedBytes = _MD5.ComputeHash(Encoding.ASCII.GetBytes(e.Data + ":" + AppSettings.Salt)); var hashedText = string.Join("", hashedBytes.Select(n => n.ToString("x2"))); Logger.Trace(hashedText); // 開錠許可されている、登録済の NFC タグかどうか判定 var isAuthorized = AppSettings.AuthorizedKeys .Split(',') .Any(key => key == hashedText); Logger.Trace($"IsAuthorized: {isAuthorized}"); // NFCタグ検出音を再生 PlayDetectNFCTagSound(isAuthorized); if (isAuthorized) { Logger.Trace("UNLOCK"); Gpio21.Value = 1; SetState(HostState.Unlocked); } else { Gpio21.Value = 0; SetState(HostState.Rejected); } UnlockTimer.Stop(); UnlockTimer.Start(); } catch (Exception exception) { Logger.Error(exception); } }