m_beaconFrame.headerLen = offset;
// Superframe-spec
- m_payload[0] = 0xff; // beacon- and superframe order always 15 in non-beaconenabled mode
- m_payload[1] = 0x00;
+ m_payload[BEACON_INDEX_SF_SPEC1] = 0xff; // beacon- and superframe order always 15 in nonbeacon-enabled mode
+ m_payload[BEACON_INDEX_SF_SPEC2] = 0x00;
if (call MLME_GET.macPanCoordinator() == TRUE)
- m_payload[1] |= 0x40;
+ m_payload[BEACON_INDEX_SF_SPEC2] |= SF_SPEC2_PAN_COORD;
if (call MLME_GET.macAssociationPermit() == TRUE)
- m_payload[1] |= 0x80;
+ m_payload[BEACON_INDEX_SF_SPEC2] |= SF_SPEC2_ASSOCIATION_PERMIT;
if (call MLME_GET.macBattLifeExt() == TRUE)
- m_payload[1] |= 0x10;
+ m_payload[BEACON_INDEX_SF_SPEC2] |= SF_SPEC2_BATT_LIFE_EXT;
// GTS-spec
- m_payload[2] = 0;
- // Pending-Address-spec
- m_payload[3] = 0;
+ m_payload[BEACON_INDEX_GTS_SPEC] = 0;
+ // Pending-Address-spec (behind empty single-byte GTS field)
+ m_payload[BEACON_INDEX_GTS_SPEC + 1] = 0;
signal IEEE154TxBeaconPayload.aboutToTransmit();
post sendBeaconTask();
}
// update superframe-related variables
- m_numGtsSlots = (frame->payload[2] & 0x07);
+ m_numGtsSlots =
+ (frame->payload[BEACON_INDEX_GTS_SPEC] & GTS_DESCRIPTOR_COUNT_MASK) >> GTS_DESCRIPTOR_COUNT_OFFSET;
gtsFieldLength = 1 + ((m_numGtsSlots > 0) ? 1 + m_numGtsSlots * 3: 0);
- m_numCapSlots = (frame->payload[1] & 0x0F) + 1;
- m_sfSlotDuration = (((uint32_t) 1) << ((frame->payload[0] & 0xF0) >> 4)) * IEEE154_aBaseSlotDuration;
+ m_numCapSlots =
+ ((frame->payload[BEACON_INDEX_SF_SPEC2] & SF_SPEC2_FINAL_CAPSLOT_MASK) >> SF_SPEC2_FINAL_CAPSLOT_OFFSET) + 1;
+ m_sfSlotDuration =
+ (((uint32_t) 1) << ((frame->payload[BEACON_INDEX_SF_SPEC1] & SF_SPEC1_SO_MASK) >> SF_SPEC1_SO_OFFSET)) *
+ IEEE154_aBaseSlotDuration;
- if (frame->header->mhr[0] & FC1_FRAME_PENDING)
+ if (frame->header->mhr[MHR_INDEX_FC1] & FC1_FRAME_PENDING)
m_framePendingBit = TRUE;
else
m_framePendingBit = FALSE;
- memcpy(m_gtsField, &frame->payload[2], gtsFieldLength);
- if (frame->payload[1] & 0x10) {
+ memcpy(m_gtsField, &frame->payload[BEACON_INDEX_GTS_SPEC], gtsFieldLength);
+ if (frame->payload[BEACON_INDEX_SF_SPEC2] & SF_SPEC2_BATT_LIFE_EXT) {
// BLE is active; calculate the time offset from slot 0
m_battLifeExtDuration = IEEE154_SHR_DURATION +
(frame->headerLen + frame->payloadLen + 2) * IEEE154_SYMBOLS_PER_OCTET;
uint8_t getNumGtsSlots(uint8_t *gtsInfoField)
{
uint8_t i, num=0;
- for (i=0; i<(gtsInfoField[0] & GTS_DESCRIPTOR_COUNT_MASK); i++)
+ for (i=0; i<((gtsInfoField[0] & GTS_DESCRIPTOR_COUNT_MASK) >> GTS_DESCRIPTOR_COUNT_OFFSET); i++)
num += ((gtsInfoField[4+i*3] & GTS_LENGTH_MASK) >> GTS_LENGTH_OFFSET);
return num;
}
// (3) update SF spec
beaconSpecs -= 2; // sizeof SF Spec
if (m_payloadState & MODIFIED_SF_SPEC) {
- beaconSpecs[0] = m_beaconOrder | (m_superframeOrder << 4);
- beaconSpecs[1] = 0;
+ beaconSpecs[BEACON_INDEX_SF_SPEC1] =
+ (m_beaconOrder << SF_SPEC1_BO_OFFSET) | (m_superframeOrder << SF_SPEC1_SO_OFFSET);
+ beaconSpecs[BEACON_INDEX_SF_SPEC2] = 0;
if (call MLME_GET.macAssociationPermit())
- beaconSpecs[1] |= SF_SPEC2_ASSOCIATION_PERMIT;
+ beaconSpecs[BEACON_INDEX_SF_SPEC2] |= SF_SPEC2_ASSOCIATION_PERMIT;
if (call MLME_GET.macPanCoordinator())
- beaconSpecs[1] |= SF_SPEC2_PAN_COORD;
- beaconSpecs[1] |= ((15-numGtsSlots) & 0x0F); // update FinalCAPSlot field
+ beaconSpecs[BEACON_INDEX_SF_SPEC2] |= SF_SPEC2_PAN_COORD;
+ beaconSpecs[BEACON_INDEX_SF_SPEC2] |=
+ ((15-numGtsSlots) & SF_SPEC2_FINAL_CAPSLOT_MASK);
}
m_beaconFrame.payloadLen = (m_pendingAddrLen + m_pendingGtsLen + 2) + m_beaconPayloadLen;
m_beaconFrame.payload = beaconSpecs;
BEACON_INDEX_SF_SPEC2 = 1,
BEACON_INDEX_GTS_SPEC = 2,
+ SF_SPEC1_BO_MASK = 0x0F,
+ SF_SPEC1_BO_OFFSET = 0,
+ SF_SPEC1_SO_MASK = 0xF0,
+ SF_SPEC1_SO_OFFSET = 4,
+
+ SF_SPEC2_FINAL_CAPSLOT_MASK = 0x0F,
+ SF_SPEC2_FINAL_CAPSLOT_OFFSET = 0,
+ SF_SPEC2_BATT_LIFE_EXT = 0x10,
SF_SPEC2_PAN_COORD = 0x40,
SF_SPEC2_ASSOCIATION_PERMIT = 0x80,
GTS_DESCRIPTOR_COUNT_MASK = 0x07,
+ GTS_DESCRIPTOR_COUNT_OFFSET = 0,
GTS_LENGTH_MASK = 0xF0,
GTS_LENGTH_OFFSET = 4,
GTS_SPEC_PERMIT = 0x80,