/// <summary> /// Resets the nRF8001 by toggling its RST pin. /// </summary> public void Reset() { State = Nrf8001State.Resetting; _rst.Write(false); Thread.Sleep(10); _eventQueue.Clear(); _rst.Write(true); }
/// <summary> /// Activates Sleep mode. /// </summary> /// <remarks>Section 24.4</remarks> public void Sleep() { if (State != Nrf8001State.Standby) throw new InvalidOperationException("nRF8001 is not in Standby mode."); AciSend(AciOpCode.Sleep); // Sleep does not return a CommandResponse event. State = Nrf8001State.Sleep; }
/// <summary> /// Handles the first event in the nRF8001's event queue. Call this method as often as possible from the application controller. /// </summary> /// <returns>The first event in the event queue.</returns> public AciEvent HandleEvent() { if (_eventQueue.Count == 0) return null; var nrfEvent = (AciEvent)_eventQueue.Dequeue(); // Device events switch (nrfEvent.EventType) { case Nrf8001EventType.DeviceStarted: State = (Nrf8001State)nrfEvent.Data[1]; DataCreditsAvailable = nrfEvent.Data[3]; break; case Nrf8001EventType.Connected: State = Nrf8001State.Connected; break; case Nrf8001EventType.PipeStatus: OpenPipesBitmap = nrfEvent.Data.ToUnsignedLong(1); ClosedPipesBitmap = nrfEvent.Data.ToUnsignedLong(9); Debug.Print("PipeStatus o = " + OpenPipesBitmap + " c = " + ClosedPipesBitmap); break; case Nrf8001EventType.Disconnected: State = Nrf8001State.Standby; break; case Nrf8001EventType.DataCredit: DataCreditsAvailable = nrfEvent.Data[1]; break; } #if DEBUG Debug.Print("Event: " + nrfEvent.EventType); #endif return nrfEvent; }