/// <summary> /// Sets address filter on Phy layer /// </summary> /// <param name="enable">true if enabled</param> /// <param name="shortAddr">local short addr, 0xFFFF for any</param> /// <param name="panId">local pan ID, 0xFFFF for any</param> /// <param name="panCoordinator">true if device is the PAN coordinator</param> public void SetAddressFilter( bool enable, UInt16 shortAddr, UInt16 panId, bool panCoordinator) { if (_phyCapAddressFilter) { _phy.SetAddressFilter(enable, shortAddr, panId, panCoordinator); _phy.SetAutoAck(enable); } else { _filterEnabled = enable; _filterShortAddr = shortAddr; _filterPanId = panId; _filterCoordinator = panCoordinator; } }
public void TestReceive() { phy.SetPower(true); phy.DataIndication = phy_DataIndicationDummy; // EDRequest { Debug.Print("EDRequest"); Status status; Byte energyLevel; phy.SetTrxStateRequest(State.TRxOff, out status); Assert(status == Status.TRxOff); phy.EDRequest(out status, out energyLevel); Assert(status == Status.TRxOff); phy.SetTrxStateRequest(State.RxOn, out status); Assert(status == Status.RxOn); for (int i = 0; i < 5; i++) { leds.color = Leds.Color.Blue; for (int channel = 11; channel <= 26; channel++) { PibValue value = new PibValue(); value.Int = channel; phy.SetRequest(PibAttribute.phyCurrentChannel, value, out status); Assert(status == Status.Success); phy.EDRequest(out status, out energyLevel); if (status == Status.Success) { String s = String.Empty; s += "ED: " + energyLevel + " on " + channel; Debug.Print(s); } } leds.color = Leds.Color.Off; System.Threading.Thread.Sleep(100); } } // CCARequest { Debug.Print("CCA"); PibValue value = new PibValue(); value.Int = 11; Status status; phy.SetRequest(PibAttribute.phyCurrentChannel, value, out status); Assert(status == Status.Success); phy.SetTrxStateRequest(State.RxOn, out status); Assert(status == Status.RxOn); DateTime start = DateTime.Now; TimeSpan duration = new TimeSpan(0, 0, 5); while (DateTime.Now - start < duration) { phy.CCARequest(out status); if (status == Status.Busy) { leds.color = Leds.Color.Yellow; } else { leds.color = Leds.Color.Off; } } leds.color = Leds.Color.Off; } // DataIndication phy.SetAutoFCS(true); phy.SetAddressFilter(true, 2, 1, false); // ok, no recv for other short addr/pan id phy.SetAutoAck(true); phy.DataIndication = phy_DataIndicationFlash; { Status status; phy.SetTrxStateRequest(State.RxOn, out status); Assert(status == Status.RxOn); Thread.Sleep(5000); } }