예제 #1
0
        private void Dio0Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge != GpioPinEdge.RisingEdge)
            {
                return;
            }

            LoraRegisterIrqFlags.FlagsEnum irqFlags = RegisterManager.Read <LoraRegisterIrqFlags>().Flags;
            if (irqFlags.HasFlag(LoraRegisterIrqFlags.FlagsEnum.TxDone))
            {
                TransmittedOkCount++;
                _transmissionCompletedEventSlim.Set();
            }

            if (irqFlags.HasFlag(LoraRegisterIrqFlags.FlagsEnum.RxDone))
            {
                ReceivedMessage message = GetReceivedMessage();

                OnMessageReceived?.Invoke(this, new ReceivedMessageEventArgs(message));
            }

            // Clear all IRQ flags
            RegisterManager.Write(new LoraRegisterIrqFlags(0xFF));
        }
 public ReceivedMessageEventArgs(ReceivedMessage message)
 {
     Message = message;
 }