public TaskGetRequest( PibAttribute attribute, int attributeIndex, GetConfirmHandler handler) : base(TaskType.GetRequest) { this.attribute = attribute; this.attributeIndex = attributeIndex; this.handler = handler; }
public TaskSetRequest( PibAttribute attribute, int index, PibValue value, SetConfirmHandler handler) : base(TaskType.SetRequest) { this.attribute = attribute; this.index = index; this.value = value; this.handler = handler; }
public void GetRequest( PibAttribute attribute, int attributeIndex, GetConfirmHandler handler) { TaskGetRequest task = new TaskGetRequest( attribute, attributeIndex, handler); if (!_taskQueue.Add(task) && handler != null) { handler.Invoke(this, MacEnum.Congested, attribute, attributeIndex, new PibValue()); } }
public void SetRequest( PibAttribute attribute, int index, PibValue value, SetConfirmHandler handler) { TaskSetRequest task = new TaskSetRequest( attribute, index, value, handler); if (!_taskQueue.Add(task) && handler != null) { handler.Invoke(this, MacEnum.Congested, attribute, index); } }
// handler for MacGetRequest for supported channels private void HandlerChannelsSupported( IMacMgmtSap sender, MacEnum status, PibAttribute attribute, int attributeIndex, PibValue value) { if (!_scanning || attribute != PibAttribute.phyChannelsSupported) { return; } if (status != MacEnum.Success) { FinishScanning(Status.Error); return; } _scanChannels = value.IntArray; _scanChannelsCurrent = 0; ScanNextPage(); }
public void GetRequest( PibAttribute attribute, int attributeIndex, GetConfirmHandler handler) { TaskGetRequest task = new TaskGetRequest( attribute, attributeIndex, handler); if (!_taskQueue.Add(task) && handler != null) { handler.Invoke(this, MacEnum.Congested, attribute, attributeIndex, new PibValue()); } }
public void SetRequest( PibAttribute attribute, int index, PibValue value, SetConfirmHandler handler) { TaskSetRequest task = new TaskSetRequest( attribute, index, value, handler); if (!_taskQueue.Add(task) && handler != null) { handler.Invoke(this, MacEnum.Congested, attribute, index); } }
/// <summary> /// (6.2.2.9-10) The PLME-SET.request primitive attempts to set the indicated PHY PIB attribute to the given value. /// </summary> /// <param name="attribute">The identifier of the PIB attribute to set.</param> /// <param name="attributeValue">The value of the indicated PIB attribute to set.</param> /// <param name="status">The status of the attempt to set the requested PIB attribute.</param> public void SetRequest( PibAttribute attribute, PibValue attributeValue, out Status status) { switch (attribute) { case PibAttribute.phyCurrentChannel: { if (attributeValue.Type != PibValue.ValueType.Int) { status = Status.InvalidParam; } else { int value = attributeValue.Int; if (value < HALCC2420.MinChannel || value > HALCC2420.MaxChannel) { status = Status.InvalidParam; } else { Channel = (byte)value; status = Status.Success; } } break; } case PibAttribute.phyTransmitPower: { if (attributeValue.Type != PibValue.ValueType.Int) { status = Status.InvalidParam; } else { int value = attributeValue.Int; if (value < -32 || value > 31) // dBm { status = Status.InvalidParam; } else { Power = value; status = Status.Success; } } break; } case PibAttribute.phyCurrentPage: { if (attributeValue.Type != PibValue.ValueType.Int) { status = Status.InvalidParam; } else { int value = attributeValue.Int; if (value == 0) status = Status.Success; else status = Status.InvalidParam; } break; } case PibAttribute.phyChannelsSupported: case PibAttribute.phyCCAMode: case PibAttribute.phyMaxFrameDuration: case PibAttribute.phySHRDuration: case PibAttribute.phySymbolsPerOctet: status = Status.ReadOnly; break; default: status = Status.InvalidParam; break; } }
// handler for MacGetRequest for supported channels private void HandlerChannelsSupported( IMacMgmtSap sender, MacEnum status, PibAttribute attribute, int attributeIndex, PibValue value) { if (!_scanning || attribute != PibAttribute.phyChannelsSupported) return; if (status != MacEnum.Success) { FinishScanning(Status.Error); return; } _scanChannels = value.IntArray; _scanChannelsCurrent = 0; ScanNextPage(); }
/// <summary> /// (6.2.2.5-6) The PLME-GET.request primitive requests information about a given PHY PIB attribute. /// </summary> /// <param name="attribute">The identifier of the PHY PIB attribute to get.</param> /// <param name="status">The result of the request for PHY PIB attribute information.</param> /// <param name="attributeValue">The value of the indicated PHY PIB attribute that was requested. This /// parameter has zero length when the status parameter is set to UNSUPPORTED_ATTRIBUTE.</param> public void GetRequest( PibAttribute attribute, out Status status, out PibValue attributeValue) { attributeValue = new PibValue(); switch (attribute) { case PibAttribute.phyCurrentChannel: status = Status.Success; attributeValue.Int = Channel; break; case PibAttribute.phyChannelsSupported: { int res = 0; for (int i = HALCC2420.MinChannel; i <= HALCC2420.MaxChannel; i++) res |= (1 << i); // CC2420 only supports channel page 0 int[] channels = new int[1]; channels[0] = res; status = Status.Success; attributeValue.IntArray = channels; break; } case PibAttribute.phyTransmitPower: status = Status.Success; attributeValue.Int = Power; break; case PibAttribute.phyCCAMode: status = Status.Success; attributeValue.Int = 3; // hard-coded in hal, could be changed break; case PibAttribute.phyCurrentPage: status = Status.Success; attributeValue.Int = 0; break; case PibAttribute.phyMaxFrameDuration: // see 6.4.2 and below status = Status.Success; attributeValue.Int = 1064; break; case PibAttribute.phySHRDuration: // SHR is 4+1 byte, BPSK (5*8) status = Status.Success; attributeValue.Int = 40; break; case PibAttribute.phySymbolsPerOctet: status = Status.Success; attributeValue.Float = 8; // BPSK only break; default: status = Status.UnsupportedAttr; break; } }
public TaskSetRequest( PibAttribute attribute, int index, PibValue value, SetConfirmHandler handler) : base(TaskType.SetRequest) { this.attribute = attribute; this.index = index; this.value = value; this.handler = handler; }
public TaskGetRequest( PibAttribute attribute, int attributeIndex, GetConfirmHandler handler) : base(TaskType.GetRequest) { this.attribute = attribute; this.attributeIndex = attributeIndex; this.handler = handler; }
/// <summary> /// (6.2.2.5-6) The PLME-GET.request primitive requests information about a given PHY PIB attribute. /// </summary> /// <param name="attribute">The identifier of the PHY PIB attribute to get.</param> /// <param name="status">The result of the request for PHY PIB attribute information.</param> /// <param name="attributeValue">The value of the indicated PHY PIB attribute that was requested. This /// parameter has zero length when the status parameter is set to UNSUPPORTED_ATTRIBUTE.</param> public void GetRequest( PibAttribute attribute, out Status status, out PibValue attributeValue) { attributeValue = new PibValue(); switch (attribute) { case PibAttribute.phyCurrentChannel: status = Status.Success; attributeValue.Int = Channel; break; case PibAttribute.phyChannelsSupported: { int res = 0; for (int i = HALCC2420.MinChannel; i <= HALCC2420.MaxChannel; i++) { res |= (1 << i); } // CC2420 only supports channel page 0 int[] channels = new int[1]; channels[0] = res; status = Status.Success; attributeValue.IntArray = channels; break; } case PibAttribute.phyTransmitPower: status = Status.Success; attributeValue.Int = Power; break; case PibAttribute.phyCCAMode: status = Status.Success; attributeValue.Int = 3; // hard-coded in hal, could be changed break; case PibAttribute.phyCurrentPage: status = Status.Success; attributeValue.Int = 0; break; case PibAttribute.phyMaxFrameDuration: // see 6.4.2 and below status = Status.Success; attributeValue.Int = 1064; break; case PibAttribute.phySHRDuration: // SHR is 4+1 byte, BPSK (5*8) status = Status.Success; attributeValue.Int = 40; break; case PibAttribute.phySymbolsPerOctet: status = Status.Success; attributeValue.Float = 8; // BPSK only break; default: status = Status.UnsupportedAttr; break; } }
/// <summary> /// (6.2.2.9-10) The PLME-SET.request primitive attempts to set the indicated PHY PIB attribute to the given value. /// </summary> /// <param name="attribute">The identifier of the PIB attribute to set.</param> /// <param name="attributeValue">The value of the indicated PIB attribute to set.</param> /// <param name="status">The status of the attempt to set the requested PIB attribute.</param> public void SetRequest( PibAttribute attribute, PibValue attributeValue, out Status status) { switch (attribute) { case PibAttribute.phyCurrentChannel: { if (attributeValue.Type != PibValue.ValueType.Int) { status = Status.InvalidParam; } else { int value = attributeValue.Int; if (value < HALCC2420.MinChannel || value > HALCC2420.MaxChannel) { status = Status.InvalidParam; } else { Channel = (byte)value; status = Status.Success; } } break; } case PibAttribute.phyTransmitPower: { if (attributeValue.Type != PibValue.ValueType.Int) { status = Status.InvalidParam; } else { int value = attributeValue.Int; if (value < -32 || value > 31) // dBm { status = Status.InvalidParam; } else { Power = value; status = Status.Success; } } break; } case PibAttribute.phyCurrentPage: { if (attributeValue.Type != PibValue.ValueType.Int) { status = Status.InvalidParam; } else { int value = attributeValue.Int; if (value == 0) { status = Status.Success; } else { status = Status.InvalidParam; } } break; } case PibAttribute.phyChannelsSupported: case PibAttribute.phyCCAMode: case PibAttribute.phyMaxFrameDuration: case PibAttribute.phySHRDuration: case PibAttribute.phySymbolsPerOctet: status = Status.ReadOnly; break; default: status = Status.InvalidParam; break; } }