]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
- moved promiscuous mode into separate component
authorjanhauer <janhauer>
Tue, 21 Oct 2008 17:29:00 +0000 (17:29 +0000)
committerjanhauer <janhauer>
Tue, 21 Oct 2008 17:29:00 +0000 (17:29 +0000)
- separated association from disassociation component
- changed ResourceTransfer.tranfer to async
- added placeholders

29 files changed:
apps/tests/tkn154/TestPromiscuous/Makefile
tos/lib/mac/tkn154/AssociateP.nc
tos/lib/mac/tkn154/BeaconSynchronizeP.nc
tos/lib/mac/tkn154/BeaconTransmitP.nc
tos/lib/mac/tkn154/CoordBroadcastP.nc
tos/lib/mac/tkn154/CsmaP.nc
tos/lib/mac/tkn154/DataP.nc
tos/lib/mac/tkn154/DisassociateP.nc [new file with mode: 0644]
tos/lib/mac/tkn154/PibP.nc
tos/lib/mac/tkn154/PromiscuousModeP.nc [new file with mode: 0644]
tos/lib/mac/tkn154/RxEnableP.nc
tos/lib/mac/tkn154/TKN154.h
tos/lib/mac/tkn154/TKN154P.nc
tos/lib/mac/tkn154/TKN154_DEBUG.h
tos/lib/mac/tkn154/TKN154_PIB.h
tos/lib/mac/tkn154/TransferClientP.nc
tos/lib/mac/tkn154/dummies/NoAssociateP.nc [new file with mode: 0644]
tos/lib/mac/tkn154/dummies/NoBeaconSynchronizeP.nc
tos/lib/mac/tkn154/dummies/NoBeaconTransmitP.nc
tos/lib/mac/tkn154/dummies/NoCoordBroadcastP.nc [new file with mode: 0644]
tos/lib/mac/tkn154/dummies/NoCoordCfpP.nc
tos/lib/mac/tkn154/dummies/NoCoordRealignmentP.nc [new file with mode: 0644]
tos/lib/mac/tkn154/dummies/NoCsmaP.nc
tos/lib/mac/tkn154/dummies/NoDeviceCfpP.nc
tos/lib/mac/tkn154/dummies/NoDisassociateP.nc [new file with mode: 0644]
tos/lib/mac/tkn154/dummies/NoPromiscuousModeP.nc [new file with mode: 0644]
tos/lib/mac/tkn154/dummies/NoRxEnableP.nc [new file with mode: 0644]
tos/lib/mac/tkn154/interfaces/private/ResourceTransfer.nc
tos/lib/mac/tkn154/interfaces/private/ResourceTransferred.nc

index 1aabe6fb979e6c44d9127ccb4b6dc166e063dd0e..c3b7be818a930c88d59aaa6139b793d38d818b62 100644 (file)
@@ -2,4 +2,5 @@ COMPONENT=TestPromiscuousAppC
 PFLAGS += -DIEEE154_BEACON_TX_DISABLED -DIEEE154_BEACON_SYNC_DISABLED -DIEEE154_SCAN_DISABLED
 PFLAGS += -DPRINTF_BUFFER_SIZE=1000
 CFLAGS += -I$(TOSDIR)/lib/printf
+CFLAGS += -DIEEE154_SCAN_DISABLED -DIEEE154_BEACON_SYNC_DISABLED -DIEEE154_BEACON_TX_DISABLED -DIEEE154_RXENABLE_DISABLED -DIEEE154_ASSOCIATION_DISABLED -DIEEE154_DISASSOCIATION_DISABLED -DIEEE154_COORD_REALIGNMENT_DISABLED -DIEEE154_COORD_BROADCAST_DISABLED
 include ../Makefile.include
index fd8f34455cc1285880974019154ea3384fbf5df7..c420f3201700c61f53f21b63018705e22e5a9d54 100644 (file)
@@ -42,7 +42,6 @@ module AssociateP
   {
     interface Init;
     interface MLME_ASSOCIATE;
-    interface MLME_DISASSOCIATE;
     interface MLME_COMM_STATUS;
   }
   uses
@@ -52,14 +51,6 @@ module AssociateP
     interface FrameExtracted as AssociationResponseExtracted;
     interface FrameTx as AssociationResponseTx;
 
-    interface FrameTx as DisassociationIndirectTx;
-    interface FrameTx as DisassociationDirectTx;
-    interface FrameTx as DisassociationToCoord;
-
-    interface FrameRx as DisassociationDirectRxFromCoord;
-    interface FrameExtracted as DisassociationExtractedFromCoord;
-    interface FrameRx as DisassociationRxFromDevice;
-
     interface DataRequest;
     interface Timer<TSymbolIEEE802154> as ResponseTimeout;
     interface Pool<ieee154_txframe_t> as TxFramePool;
@@ -68,7 +59,6 @@ module AssociateP
     interface MLME_SET;
     interface FrameUtility;
     interface IEEE154Frame as Frame;
-    interface Leds;
     interface Get<uint64_t> as LocalExtendedAddress;
     interface Ieee802154Debug as Debug;
   }
@@ -79,23 +69,19 @@ implementation
     S_IDLE = 0xFF,
   };
   uint8_t m_payloadAssocRequest[2];
-  uint8_t m_payloadDisassocRequest[2];
   uint8_t m_payloadAssocResponse[MAX_PENDING_ASSOC_RESPONSES][4];
   uint8_t m_coordAddrMode;
   uint8_t m_assocRespStatus;
   uint16_t m_shortAddress;
   bool m_associationOngoing;
-  bool m_disAssociationOngoing;
 
   command error_t Init.init()
   {
     uint8_t i;
     call ResponseTimeout.stop();
     m_payloadAssocRequest[0] = S_IDLE;
-    m_payloadDisassocRequest[0] = S_IDLE;
     m_coordAddrMode = 0;
     m_associationOngoing = FALSE;
-    m_disAssociationOngoing = FALSE;
     for (i=0; i<MAX_PENDING_ASSOC_RESPONSES; i++)
       m_payloadAssocResponse[i][0] = S_IDLE;
     return SUCCESS;
@@ -302,154 +288,8 @@ implementation
                           status, 0);
   }
 
-
-/* ------------------- MLME_DISASSOCIATE (initiating) ------------------- */
-
-  command ieee154_status_t MLME_DISASSOCIATE.request  (
-                          uint8_t DeviceAddrMode,
-                          uint16_t DevicePANID,
-                          ieee154_address_t DeviceAddress,
-                          ieee154_disassociation_reason_t DisassociateReason,
-                          bool TxIndirect,
-                          ieee154_security_t *security
-                        )
-  {
-    ieee154_status_t status = IEEE154_SUCCESS;
-    ieee154_txframe_t *txFrame=0;
-    ieee154_txcontrol_t *txControl=0;
-    ieee154_address_t srcAddress;
-
-    if (security && security->SecurityLevel)
-      status = IEEE154_UNSUPPORTED_SECURITY;
-    else if (call MLME_GET.macPANId() != DevicePANID || 
-        (DeviceAddrMode != ADDR_MODE_SHORT_ADDRESS && DeviceAddrMode != ADDR_MODE_EXTENDED_ADDRESS))
-      status = IEEE154_INVALID_PARAMETER;
-    else if (m_disAssociationOngoing || !(txFrame = call TxFramePool.get()))
-      status = IEEE154_TRANSACTION_OVERFLOW;
-    else if (!(txControl = call TxControlPool.get())){
-      call TxFramePool.put(txFrame);
-      status = IEEE154_TRANSACTION_OVERFLOW;
-    } 
-    if (status == IEEE154_SUCCESS){
-      txFrame->header = &txControl->header;
-      txFrame->metadata = &txControl->metadata;
-      srcAddress.extendedAddress = call LocalExtendedAddress.get();
-      txFrame->headerLen = call FrameUtility.writeHeader(
-          txFrame->header->mhr,
-          DeviceAddrMode,
-          call MLME_GET.macPANId(),
-          &DeviceAddress,
-          ADDR_MODE_EXTENDED_ADDRESS,
-          call MLME_GET.macPANId(),
-          &srcAddress,
-          TRUE);
-      txFrame->header->mhr[MHR_INDEX_FC1] = FC1_ACK_REQUEST | FC1_FRAMETYPE_CMD | FC1_PAN_ID_COMPRESSION;
-      txFrame->header->mhr[MHR_INDEX_FC2] = FC2_SRC_MODE_EXTENDED |
-        (DeviceAddrMode == ADDR_MODE_SHORT_ADDRESS ? FC2_DEST_MODE_SHORT : FC2_DEST_MODE_EXTENDED);
-      m_payloadDisassocRequest[0] = CMD_FRAME_DISASSOCIATION_NOTIFICATION;
-      m_payloadDisassocRequest[1] = DisassociateReason;
-      txFrame->payload = m_payloadDisassocRequest;
-      txFrame->payloadLen = 2;
-      m_disAssociationOngoing = TRUE;
-      if ((DeviceAddrMode == ADDR_MODE_SHORT_ADDRESS &&
-            DeviceAddress.shortAddress == call MLME_GET.macCoordShortAddress()) ||
-          (DeviceAddrMode == ADDR_MODE_EXTENDED_ADDRESS &&
-           DeviceAddress.extendedAddress == call MLME_GET.macCoordExtendedAddress())){
-        status = call DisassociationToCoord.transmit(txFrame);
-      } else if (TxIndirect) {
-        status = call DisassociationIndirectTx.transmit(txFrame);
-      } else {
-        status = call DisassociationDirectTx.transmit(txFrame);
-      }
-      if (status != IEEE154_SUCCESS){
-        m_disAssociationOngoing = FALSE;
-        call TxFramePool.put(txFrame);
-        call TxControlPool.put(txControl);
-      }
-    }
-    call Debug.log(LEVEL_INFO, DISSASSOCIATE_REQUEST, status, 0, 0);
-    return status;
-  }
-
-  event void DisassociationToCoord.transmitDone(ieee154_txframe_t *data, ieee154_status_t status) 
-  { 
-    // transmitted a disassociation notification to our coordinator
-    uint8_t *mhr = MHR(data), srcAddrOffset = 7;
-    uint8_t DeviceAddrMode = (mhr[MHR_INDEX_FC2] & FC2_SRC_MODE_MASK) >> FC2_SRC_MODE_OFFSET;
-    uint16_t DevicePANID = *((nxle_uint16_t*) (&(mhr[MHR_INDEX_ADDRESS])));
-    ieee154_address_t DeviceAddress;
-    if ((mhr[MHR_INDEX_FC2] & FC2_DEST_MODE_MASK) == FC2_DEST_MODE_EXTENDED)
-      srcAddrOffset += 6;
-    call FrameUtility.convertToNative(&DeviceAddress.extendedAddress, &mhr[srcAddrOffset]);
-    call TxControlPool.put((ieee154_txcontrol_t*) ((uint8_t*) data->header - offsetof(ieee154_txcontrol_t, header)));
-    call TxFramePool.put(data);
-    call Debug.log(LEVEL_INFO, DISSASSOCIATE_TXDONE, status, 2, 0);
-    m_disAssociationOngoing = FALSE;
-    signal MLME_DISASSOCIATE.confirm(status, DeviceAddrMode, DevicePANID, DeviceAddress);
-  }
-
-  event void DisassociationIndirectTx.transmitDone(ieee154_txframe_t *data, ieee154_status_t status) 
-  {
-    signal DisassociationDirectTx.transmitDone(data, status);
-  }
-
-  event void DisassociationDirectTx.transmitDone(ieee154_txframe_t *data, ieee154_status_t status) 
-  { 
-    // transmitted a disassociation notification to a device
-    uint8_t *mhr = MHR(data), dstAddrOffset = 5;
-    uint8_t DeviceAddrMode = (mhr[1] & FC2_DEST_MODE_MASK) >> FC2_DEST_MODE_OFFSET;
-    uint16_t DevicePANID = *((nxle_uint16_t*) (&(mhr[MHR_INDEX_ADDRESS])));
-    ieee154_address_t DeviceAddress;
-    call FrameUtility.convertToNative(&DeviceAddress.extendedAddress, &mhr[dstAddrOffset]);
-    call Debug.log(LEVEL_INFO, DISSASSOCIATE_TXDONE, status, 1, 0);
-    call TxControlPool.put((ieee154_txcontrol_t*) ((uint8_t*) data->header - offsetof(ieee154_txcontrol_t, header)));
-    call TxFramePool.put(data);
-    call Debug.log(LEVEL_INFO, DISSASSOCIATE_TXDONE, status, 2, 0);
-    m_disAssociationOngoing = FALSE;
-    signal MLME_DISASSOCIATE.confirm(status, DeviceAddrMode, DevicePANID, DeviceAddress);
-  }
-
-/* ------------------- MLME_DISASSOCIATE (receiving) ------------------- */
-
-  event message_t* DisassociationDirectRxFromCoord.received(message_t* frame)
-  {
-    // received a disassociation notification from the coordinator (direct tx)
-    ieee154_address_t address;
-    address.extendedAddress = call LocalExtendedAddress.get();
-    signal MLME_DISASSOCIATE.indication(address.extendedAddress, frame->data[1], NULL);
-    return frame;
-  }
-
-  event message_t* DisassociationExtractedFromCoord.received(message_t* frame, ieee154_txframe_t *txFrame)
-  {
-    // received a disassociation notification from the coordinator (indirect transmission)
-    return signal DisassociationDirectRxFromCoord.received(frame);
-  }
-
-  event message_t* DisassociationRxFromDevice.received(message_t* frame)
-  {
-    // received a disassociation notification from the device
-    ieee154_address_t address;
-    call Debug.log(LEVEL_INFO, DISSASSOCIATE_RX, 0, 0, 0);
-    if (call Frame.getSrcAddrMode(frame) == ADDR_MODE_EXTENDED_ADDRESS && 
-        call Frame.getSrcAddr(frame, &address) == SUCCESS)
-      signal MLME_DISASSOCIATE.indication(address.extendedAddress, frame->data[1], NULL);
-    return frame;
-  }
-
 /* ------------------- Defaults ------------------- */
 
-  default event void MLME_DISASSOCIATE.indication (
-                          uint64_t DeviceAddress,
-                          ieee154_disassociation_reason_t DisassociateReason,
-                          ieee154_security_t *security
-                        ){}
-  default event void MLME_DISASSOCIATE.confirm    (
-                          ieee154_status_t status,
-                          uint8_t DeviceAddrMode,
-                          uint16_t DevicePANID,
-                          ieee154_address_t DeviceAddress
-                        ){}
   default event void MLME_ASSOCIATE.indication (
                           uint64_t DeviceAddress,
                           ieee154_CapabilityInformation_t CapabilityInformation,
index e7c39110a2a2f6cba0bc48281ddebd4e3dd0b6f9..db92fd9b5e2d6d5648c144e1a742b2c33bd3c502 100644 (file)
@@ -75,6 +75,7 @@ module BeaconSynchronizeP
     interface DataRequest;
     interface FrameRx as CoordRealignmentRx;
     interface Resource as Token;
+    interface ResourceTransferred as TokenTransferred;
     interface ResourceTransfer as TokenToCap;
     interface TimeCalc;
     interface IEEE154Frame as Frame;
@@ -96,13 +97,13 @@ implementation
   };
 
   norace bool m_tracking = FALSE;
-  bool m_updatePending = FALSE;
+  norace bool m_updatePending = FALSE;
   uint8_t m_updateLogicalChannel;
   bool m_updateTrackBeacon;
   bool m_stopTracking = FALSE;
   bool m_internalRequest = FALSE;
 
-  uint8_t m_numBeaconsLost;
+  norace uint8_t m_numBeaconsLost;
   uint8_t m_coordAddress[8];
   message_t m_beaconBuffer;
   norace message_t *m_beaconBufferPtr = &m_beaconBuffer;
@@ -119,7 +120,10 @@ implementation
   norace uint16_t m_BLELen;
   norace bool m_broadcastPending;
   uint8_t m_gtsField[1+1+3*7];
+
   task void processBeaconTask();
+  void getNextBeacon();
+  task void signalGrantedTask();
 
   command error_t Reset.init()
   {
@@ -164,8 +168,8 @@ implementation
       m_stopTracking = FALSE;
       m_updateLogicalChannel = logicalChannel;
       m_updateTrackBeacon = trackBeacon;
-      m_updatePending = TRUE;
       m_internalRequest = FALSE;
+      m_updatePending = TRUE;
       call Debug.log(LEVEL_INFO,SyncP_RESOURCE_REQUEST, 0, 0, 0);
       call Token.request();
     }
@@ -187,7 +191,6 @@ implementation
 
   event void Token.granted()
   {
-    bool missed = FALSE;
     call Debug.flush();
     call Debug.log(LEVEL_INFO,SyncP_GOT_RESOURCE, m_lastBeaconRxTime+m_beaconInterval, 
         m_beaconInterval, (m_updatePending<<1)+m_tracking);
@@ -204,7 +207,15 @@ implementation
       m_numBeaconsLost = IEEE154_aMaxLostBeacons;  // will be reset when beacon is received
       call Debug.log(LEVEL_INFO,SyncP_UPDATING, call MLME_GET.macCoordShortAddress(), 
           call MLME_GET.macPANId(), m_updateLogicalChannel);
-    } else {
+    }
+    getNextBeacon();
+  }
+
+  void getNextBeacon()
+  {
+    bool missed = FALSE;
+    if (m_state != S_FIRST_SCAN){
+      // we have received at least one previous beacon
       m_state = S_PREPARE;
       if (!m_tracking){
         call Debug.log(LEVEL_INFO,SyncP_RELEASE_RESOURCE, 0, 0, 0);
@@ -212,10 +223,10 @@ implementation
         return;
       }
       while (call TimeCalc.hasExpired(m_lastBeaconRxTime, m_dt)){ // missed a beacon
+        missed = TRUE;
         call Debug.log(LEVEL_INFO,SyncP_BEACON_MISSED_1, m_lastBeaconRxTime, m_dt, missed);
         m_dt += m_beaconInterval;
         m_numBeaconsLost++;
-        missed = TRUE;
       }
       if (m_numBeaconsLost >= IEEE154_aMaxLostBeacons){
         post processBeaconTask();
@@ -234,6 +245,19 @@ implementation
       signal RadioOff.offDone();
   }
 
+  async event void TokenTransferred.transferred()
+  {
+    if (m_updatePending)
+      post signalGrantedTask();
+    else
+      getNextBeacon();
+  }
+
+  task void signalGrantedTask()
+  {
+    signal Token.granted();
+  }
+
   async event void TrackAlarm.fired()
   {
     call Debug.log(LEVEL_IMPORTANT,SyncP_TRACK_ALARM, m_state,m_lastBeaconRxTime,m_dt);
index 3d0dd438868e2ffc290d7b6aa36890e5ed3b52f5..c7b88333a50d14396a83d60eef2366d170296985 100644 (file)
@@ -42,7 +42,7 @@ module BeaconTransmitP
     interface Init as Reset;
     interface MLME_START;
     interface WriteBeaconField as SuperframeSpecWrite;
-    interface Get<bool> as IsSendingBeacons;
+    interface GetNow<bool> as IsSendingBeacons;
     interface GetNow<uint32_t> as CapStart; 
     interface GetNow<ieee154_reftime_t*> as CapStartRefTime; 
     interface GetNow<uint32_t> as CapLen; 
@@ -70,6 +70,7 @@ module BeaconTransmitP
     interface MLME_GET;
     interface MLME_SET;
     interface Resource as Token;
+    interface ResourceTransferred as TokenTransferred;
     interface ResourceTransfer as TokenToBroadcast;
     interface FrameTx as RealignmentBeaconEnabledTx;
     interface FrameTx as RealignmentNonBeaconEnabledTx;
@@ -158,7 +159,7 @@ implementation
   uint16_t m_updatePANId;
   uint8_t m_updateLogicalChannel;
   uint32_t m_updateStartTime;
-  uint8_t m_updateBeaconOrder;
+  norace uint8_t m_updateBeaconOrder;
   uint8_t m_updateSuperframeOrder;
   bool m_updatePANCoordinator;
   bool m_updateBatteryLifeExtension;
@@ -251,8 +252,8 @@ implementation
       m_requests = (REQUEST_CONFIRM_PENDING | REQUEST_UPDATE_SF); // lock
       if (coordRealignment)
         m_requests |= REQUEST_REALIGNMENT;
-      if (!call IsSendingBeacons.get())
-        call Token.request();
+      if (m_beaconOrder == 15) // only request token if we're not already transmitting beacons
+        call Token.request(); 
     }
     return status;
   }
@@ -282,7 +283,7 @@ implementation
       *((nxle_uint16_t*) &realignmentFrame->payload[6]) = 0xFFFF;
       realignmentFrame->payloadLen = 8;
       
-      if (call IsSendingBeacons.get()){
+      if (m_beaconOrder < 15){
         // we're already transmitting beacons; the realignment frame
         // must be sent (broadcast) after the next beacon
         if (call RealignmentBeaconEnabledTx.transmit(realignmentFrame) != IEEE154_SUCCESS){
@@ -410,6 +411,11 @@ implementation
       call RadioOff.off();
   }
 
+  async event void TokenTransferred.transferred()
+  {
+    post grantedTask();
+  }  
+
   async event void RadioOff.offDone()
   {
     prepareNextBeaconTransmission();
@@ -760,7 +766,7 @@ implementation
 
   event message_t* BeaconRequestRx.received(message_t* frame)
   {
-    if (!call IsSendingBeacons.get()){
+    if (m_beaconOrder == 15){
       // transmit the beacon frame using unslotted CSMA-CA
       // TODO
     }
@@ -774,7 +780,10 @@ implementation
     signal MLME_START.confirm(SUCCESS);
   }
 
-  command bool IsSendingBeacons.get(){ return m_beaconOrder < 15;}
+  async command bool IsSendingBeacons.getNow()
+  { 
+    return (m_beaconOrder < 15) || ((m_requests & REQUEST_CONFIRM_PENDING) && m_updateBeaconOrder < 15);
+  }
 
   async command uint32_t BeaconInterval.getNow() { return m_beaconInterval; }
   async command uint32_t CapStart.getNow() { return m_lastBeaconTxTime; }
index 8ba9c136e5849a801d9456bcbe930def5d68eadf..3046a12de71935c74ea76d7c39f65c2e34f159a6 100644 (file)
@@ -106,7 +106,7 @@ implementation
       return (m_realignmentFrame != NULL || m_queueHead != NULL);
   }
 
-  event void TokenTransferred.transferred()
+  async event void TokenTransferred.transferred()
   {
     // CAP has started - are there any broadcast frames to be transmitted?
     if (call BeaconFramePendingBit.getNow()){
index b32714cb28c79799477c5eec7e37cd855fc52c05..18354816aa39060dbac0fd508b389d932bd16198 100644 (file)
@@ -173,7 +173,7 @@ implementation
     return SUCCESS;
   }
 
-  event void TokenTransferred.transferred()
+  async event void TokenTransferred.transferred()
   {
     // we got the token, i.e. CAP has just started    
     uint32_t actualCapLen = call CapLen.getNow();
@@ -182,10 +182,7 @@ implementation
       // and didn't find a beacon for aBaseSuperframeDuration*(2n+1) symbols
       // -> transmit current frame using unslotted CSMA-CA
       m_numCCA = 1;
-      signal Token.granted();
-      return;
-    }
-    else if (actualCapLen < IEEE154_RADIO_GUARD_TIME){
+    } else if (actualCapLen < IEEE154_RADIO_GUARD_TIME){
       call Debug.log(LEVEL_IMPORTANT, CapP_TOO_SHORT, superframeDirection, actualCapLen, IEEE154_RADIO_GUARD_TIME);
       call TokenToCfp.transfer();
       return;
@@ -211,7 +208,6 @@ implementation
           actualCapLen, call CapStart.getNow()+ actualCapLen);
     }
     updateState();
-    call Debug.flush();
   }
 
   command ieee154_status_t FrameTx.transmit(ieee154_txframe_t *frame)
@@ -707,8 +703,7 @@ implementation
 
   event void Token.granted()
   {
-    // the current frame should be transmitted using unslotted CSMA-CA
-    updateState();
+    // will not happen
   }
 
   task void tokenRequestedTask()
@@ -718,6 +713,9 @@ implementation
 
   async event void TokenRequested.requested() 
   {
+    // TODO: this event can be generated by the BeaconTransmitP or
+    // BeaconSynchronizeP component - in this case the Token should
+    // probably not be released!
     atomic {
       if (call Token.isOwner()){
         if (!m_lock && !(DEVICE_ROLE && m_indirectTxPending) && !(COORD_ROLE && m_bcastFrame))
index 4e951b0ea9398495eb46c5481c10ac92c99c9c11..e20f9ffa3b5a1a49a10bceb92ee0027924aa9d76 100644 (file)
@@ -42,7 +42,7 @@ module DataP
     interface MCPS_DATA; 
     interface MCPS_PURGE;
   } uses {
-    interface Get<bool> as IsSendingBeacons;
+    interface GetNow<bool> as IsSendingBeacons;
     interface FrameRx as CoordCapRx;
     interface FrameTx as DeviceCapTx;
     interface FrameTx as CoordCapTx;
@@ -145,7 +145,7 @@ implementation
 
       // indirect transmission?
       } else if ((txOptions & TX_OPTIONS_INDIRECT) && 
-          call IsSendingBeacons.get() && 
+          call IsSendingBeacons.getNow() && 
           (dstAddrMode >= ADDR_MODE_SHORT_ADDRESS)){
         if (dstAddrMode == ADDR_MODE_SHORT_ADDRESS && dstAddr.shortAddress == 0xFFFF){
           mhr[MHR_INDEX_FC1] &= ~FC1_ACK_REQUEST;
diff --git a/tos/lib/mac/tkn154/DisassociateP.nc b/tos/lib/mac/tkn154/DisassociateP.nc
new file mode 100644 (file)
index 0000000..5eddab1
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in the 
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names 
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+
+#include "TKN154_MAC.h"
+
+module DisassociateP
+{
+  provides
+  {
+    interface Init;
+    interface MLME_DISASSOCIATE;
+  } uses {
+
+    interface FrameTx as DisassociationIndirectTx;
+    interface FrameTx as DisassociationDirectTx;
+    interface FrameTx as DisassociationToCoord;
+
+    interface FrameRx as DisassociationDirectRxFromCoord;
+    interface FrameExtracted as DisassociationExtractedFromCoord;
+    interface FrameRx as DisassociationRxFromDevice;
+
+    interface Pool<ieee154_txframe_t> as TxFramePool;
+    interface Pool<ieee154_txcontrol_t> as TxControlPool;
+    interface MLME_GET;
+    interface FrameUtility;
+    interface IEEE154Frame as Frame;
+    interface Get<uint64_t> as LocalExtendedAddress;
+    interface Ieee802154Debug as Debug;
+  }
+}
+implementation
+{
+  enum {
+    S_IDLE = 0xFF,
+  };
+  uint8_t m_payloadDisassocRequest[2];
+  uint8_t m_coordAddrMode;
+  bool m_disAssociationOngoing;
+
+  command error_t Init.init()
+  {
+    m_payloadDisassocRequest[0] = S_IDLE;
+    m_coordAddrMode = 0;
+    m_disAssociationOngoing = FALSE;
+    return SUCCESS;
+  }
+
+/* ------------------- MLME_DISASSOCIATE (initiating) ------------------- */
+
+  command ieee154_status_t MLME_DISASSOCIATE.request  (
+                          uint8_t DeviceAddrMode,
+                          uint16_t DevicePANID,
+                          ieee154_address_t DeviceAddress,
+                          ieee154_disassociation_reason_t DisassociateReason,
+                          bool TxIndirect,
+                          ieee154_security_t *security
+                        )
+  {
+    ieee154_status_t status = IEEE154_SUCCESS;
+    ieee154_txframe_t *txFrame=0;
+    ieee154_txcontrol_t *txControl=0;
+    ieee154_address_t srcAddress;
+
+    if (security && security->SecurityLevel)
+      status = IEEE154_UNSUPPORTED_SECURITY;
+    else if (call MLME_GET.macPANId() != DevicePANID || 
+        (DeviceAddrMode != ADDR_MODE_SHORT_ADDRESS && DeviceAddrMode != ADDR_MODE_EXTENDED_ADDRESS))
+      status = IEEE154_INVALID_PARAMETER;
+    else if (m_disAssociationOngoing || !(txFrame = call TxFramePool.get()))
+      status = IEEE154_TRANSACTION_OVERFLOW;
+    else if (!(txControl = call TxControlPool.get())){
+      call TxFramePool.put(txFrame);
+      status = IEEE154_TRANSACTION_OVERFLOW;
+    } 
+    if (status == IEEE154_SUCCESS){
+      txFrame->header = &txControl->header;
+      txFrame->metadata = &txControl->metadata;
+      srcAddress.extendedAddress = call LocalExtendedAddress.get();
+      txFrame->headerLen = call FrameUtility.writeHeader(
+          txFrame->header->mhr,
+          DeviceAddrMode,
+          call MLME_GET.macPANId(),
+          &DeviceAddress,
+          ADDR_MODE_EXTENDED_ADDRESS,
+          call MLME_GET.macPANId(),
+          &srcAddress,
+          TRUE);
+      txFrame->header->mhr[MHR_INDEX_FC1] = FC1_ACK_REQUEST | FC1_FRAMETYPE_CMD | FC1_PAN_ID_COMPRESSION;
+      txFrame->header->mhr[MHR_INDEX_FC2] = FC2_SRC_MODE_EXTENDED |
+        (DeviceAddrMode == ADDR_MODE_SHORT_ADDRESS ? FC2_DEST_MODE_SHORT : FC2_DEST_MODE_EXTENDED);
+      m_payloadDisassocRequest[0] = CMD_FRAME_DISASSOCIATION_NOTIFICATION;
+      m_payloadDisassocRequest[1] = DisassociateReason;
+      txFrame->payload = m_payloadDisassocRequest;
+      txFrame->payloadLen = 2;
+      m_disAssociationOngoing = TRUE;
+      if ((DeviceAddrMode == ADDR_MODE_SHORT_ADDRESS &&
+            DeviceAddress.shortAddress == call MLME_GET.macCoordShortAddress()) ||
+          (DeviceAddrMode == ADDR_MODE_EXTENDED_ADDRESS &&
+           DeviceAddress.extendedAddress == call MLME_GET.macCoordExtendedAddress())){
+        status = call DisassociationToCoord.transmit(txFrame);
+      } else if (TxIndirect) {
+        status = call DisassociationIndirectTx.transmit(txFrame);
+      } else {
+        status = call DisassociationDirectTx.transmit(txFrame);
+      }
+      if (status != IEEE154_SUCCESS){
+        m_disAssociationOngoing = FALSE;
+        call TxFramePool.put(txFrame);
+        call TxControlPool.put(txControl);
+      }
+    }
+    call Debug.log(LEVEL_INFO, DISSASSOCIATE_REQUEST, status, 0, 0);
+    return status;
+  }
+
+  event void DisassociationToCoord.transmitDone(ieee154_txframe_t *data, ieee154_status_t status) 
+  { 
+    // transmitted a disassociation notification to our coordinator
+    uint8_t *mhr = MHR(data), srcAddrOffset = 7;
+    uint8_t DeviceAddrMode = (mhr[MHR_INDEX_FC2] & FC2_SRC_MODE_MASK) >> FC2_SRC_MODE_OFFSET;
+    uint16_t DevicePANID = *((nxle_uint16_t*) (&(mhr[MHR_INDEX_ADDRESS])));
+    ieee154_address_t DeviceAddress;
+    if ((mhr[MHR_INDEX_FC2] & FC2_DEST_MODE_MASK) == FC2_DEST_MODE_EXTENDED)
+      srcAddrOffset += 6;
+    call FrameUtility.convertToNative(&DeviceAddress.extendedAddress, &mhr[srcAddrOffset]);
+    call TxControlPool.put((ieee154_txcontrol_t*) ((uint8_t*) data->header - offsetof(ieee154_txcontrol_t, header)));
+    call TxFramePool.put(data);
+    call Debug.log(LEVEL_INFO, DISSASSOCIATE_TXDONE, status, 2, 0);
+    m_disAssociationOngoing = FALSE;
+    signal MLME_DISASSOCIATE.confirm(status, DeviceAddrMode, DevicePANID, DeviceAddress);
+  }
+
+  event void DisassociationIndirectTx.transmitDone(ieee154_txframe_t *data, ieee154_status_t status) 
+  {
+    signal DisassociationDirectTx.transmitDone(data, status);
+  }
+
+  event void DisassociationDirectTx.transmitDone(ieee154_txframe_t *data, ieee154_status_t status) 
+  { 
+    // transmitted a disassociation notification to a device
+    uint8_t *mhr = MHR(data), dstAddrOffset = 5;
+    uint8_t DeviceAddrMode = (mhr[1] & FC2_DEST_MODE_MASK) >> FC2_DEST_MODE_OFFSET;
+    uint16_t DevicePANID = *((nxle_uint16_t*) (&(mhr[MHR_INDEX_ADDRESS])));
+    ieee154_address_t DeviceAddress;
+    call FrameUtility.convertToNative(&DeviceAddress.extendedAddress, &mhr[dstAddrOffset]);
+    call Debug.log(LEVEL_INFO, DISSASSOCIATE_TXDONE, status, 1, 0);
+    call TxControlPool.put((ieee154_txcontrol_t*) ((uint8_t*) data->header - offsetof(ieee154_txcontrol_t, header)));
+    call TxFramePool.put(data);
+    call Debug.log(LEVEL_INFO, DISSASSOCIATE_TXDONE, status, 2, 0);
+    m_disAssociationOngoing = FALSE;
+    signal MLME_DISASSOCIATE.confirm(status, DeviceAddrMode, DevicePANID, DeviceAddress);
+  }
+
+/* ------------------- MLME_DISASSOCIATE (receiving) ------------------- */
+
+  event message_t* DisassociationDirectRxFromCoord.received(message_t* frame)
+  {
+    // received a disassociation notification from the coordinator (direct tx)
+    ieee154_address_t address;
+    address.extendedAddress = call LocalExtendedAddress.get();
+    signal MLME_DISASSOCIATE.indication(address.extendedAddress, frame->data[1], NULL);
+    return frame;
+  }
+
+  event message_t* DisassociationExtractedFromCoord.received(message_t* frame, ieee154_txframe_t *txFrame)
+  {
+    // received a disassociation notification from the coordinator (indirect transmission)
+    return signal DisassociationDirectRxFromCoord.received(frame);
+  }
+
+  event message_t* DisassociationRxFromDevice.received(message_t* frame)
+  {
+    // received a disassociation notification from the device
+    ieee154_address_t address;
+    call Debug.log(LEVEL_INFO, DISSASSOCIATE_RX, 0, 0, 0);
+    if (call Frame.getSrcAddrMode(frame) == ADDR_MODE_EXTENDED_ADDRESS && 
+        call Frame.getSrcAddr(frame, &address) == SUCCESS)
+      signal MLME_DISASSOCIATE.indication(address.extendedAddress, frame->data[1], NULL);
+    return frame;
+  }
+
+/* ------------------- Defaults ------------------- */
+
+  default event void MLME_DISASSOCIATE.indication (
+                          uint64_t DeviceAddress,
+                          ieee154_disassociation_reason_t DisassociateReason,
+                          ieee154_security_t *security
+                        ){}
+  default event void MLME_DISASSOCIATE.confirm    (
+                          ieee154_status_t status,
+                          uint8_t DeviceAddrMode,
+                          uint16_t DevicePANID,
+                          ieee154_address_t DeviceAddress
+                        ){}
+
+}
index e1c6219e35967171bf94d937bfec45ec94d5a71d..eb2f9bd0d2cbb7c780112b39dd658f33eb8e3dda 100644 (file)
@@ -555,7 +555,6 @@ implementation
 
   command void Packet.clear(message_t* msg)
   {
-    uint8_t i;
     memset(msg->header, 0, sizeof(message_header_t));
     memset(msg->metadata, 0, sizeof(message_metadata_t));
   }
diff --git a/tos/lib/mac/tkn154/PromiscuousModeP.nc b/tos/lib/mac/tkn154/PromiscuousModeP.nc
new file mode 100644 (file)
index 0000000..4cba26c
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in the 
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names 
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+#include "TKN154_PHY.h"
+#include "TKN154_MAC.h"
+module PromiscuousModeP 
+{
+  provides {
+    interface Init;
+    interface SplitControl as PromiscuousMode;
+    interface Get<bool> as PromiscuousModeGet;
+    interface FrameRx;
+  } uses {
+    interface Resource as Token;
+    interface RadioRx as PromiscuousRx;
+    interface RadioOff;
+    interface Set<bool> as RadioPromiscuousMode;
+    interface Ieee802154Debug as Debug;
+  }
+}
+implementation
+{
+  enum promiscuous_state {
+    S_IDLE,
+    S_STARTING,
+    S_STARTED,
+    S_STOPPING,
+  } m_promiscuousState;
+
+  task void prepareDoneTask();
+  task void radioOffDoneTask();
+
+  command error_t Init.init()
+  {
+    m_promiscuousState = S_IDLE;
+    return SUCCESS;
+  }
+
+/* ----------------------- Promiscuous Mode ----------------------- */
+
+  command bool PromiscuousModeGet.get()
+  {
+    return (m_promiscuousState == S_STARTED);
+  }
+
+  command error_t PromiscuousMode.start()
+  {
+    if (m_promiscuousState != S_IDLE)
+      return FAIL;
+    m_promiscuousState = S_STARTING;
+    call Token.request();
+    call Debug.log(LEVEL_INFO, EnableRxP_PROMISCUOUS_REQUEST, m_promiscuousState, 0, 0);
+    call Debug.flush();
+    return SUCCESS;
+  }
+
+  event void Token.granted()
+  {
+    if (m_promiscuousState != S_STARTING){
+      call Token.release();
+      return;
+    }
+    call RadioPromiscuousMode.set(TRUE);
+    if (call PromiscuousRx.prepare() != IEEE154_SUCCESS){
+      m_promiscuousState = S_IDLE;
+      call Token.release();
+      call Debug.log(LEVEL_IMPORTANT, EnableRxP_RADIORX_ERROR, 0, 0, 0);
+      signal PromiscuousMode.startDone(FAIL);
+    }
+  }
+
+  async event void PromiscuousRx.prepareDone()
+  {
+    post prepareDoneTask();
+  }
+
+  task void prepareDoneTask()
+  {
+    if (m_promiscuousState != S_STARTING){
+      call Token.release();
+      return;
+    }    
+    m_promiscuousState = S_STARTED;
+    call PromiscuousRx.receive(NULL, 0);
+    signal PromiscuousMode.startDone(SUCCESS);
+    call Debug.log(LEVEL_INFO, EnableRxP_PROMISCUOUS_ON, m_promiscuousState, 0, 0);
+  }
+
+  event message_t* PromiscuousRx.received(message_t *frame, ieee154_reftime_t *timestamp)
+  {
+    if (m_promiscuousState == S_STARTED){
+      ((ieee154_header_t*) frame->header)->length |= FRAMECTL_PROMISCUOUS;
+      return signal FrameRx.received(frame);
+    } else
+      return frame;
+  }
+
+  command error_t PromiscuousMode.stop()
+  {
+    if (m_promiscuousState != S_STARTED)
+      return FAIL;
+    m_promiscuousState = S_STOPPING;
+    call RadioOff.off();
+    return SUCCESS;
+  }
+
+  async event void RadioOff.offDone()
+  {
+    post radioOffDoneTask();
+  }
+
+  task void radioOffDoneTask()
+  {
+    if (m_promiscuousState != S_STOPPING){
+      call Token.release();
+      return;
+    }
+    m_promiscuousState = S_IDLE;
+    call RadioPromiscuousMode.set(FALSE);
+    call Token.release();
+    signal PromiscuousMode.stopDone(SUCCESS);
+    call Debug.log(LEVEL_INFO, EnableRxP_PROMISCUOUS_OFF, m_promiscuousState, 0, 0);
+  }
+
+  default event void PromiscuousMode.startDone(error_t error){}
+  default event void PromiscuousMode.stopDone(error_t error){}
+}
index 6835bed8ae845b454253e3b6717c2967f086edde..b7dad3a8573d3a32994d536369032bea9d5baaa9 100644 (file)
@@ -41,18 +41,11 @@ module RxEnableP
   {
     interface Init;
     interface MLME_RX_ENABLE;
-    interface SplitControl as PromiscuousMode;
-    interface FrameRx;
-    interface Get<bool> as PromiscuousModeGet;
     interface GetNow<bool> as IsRxEnableActive; 
     interface Notify<bool> as RxEnableStateChange;
   }
   uses
   {
-    interface Resource as Token;
-    interface RadioRx as PromiscuousRx;
-    interface RadioOff;
-    interface Set<bool> as RadioPromiscuousMode;
     interface Ieee802154Debug as Debug;
     interface Timer<TSymbolIEEE802154> as RxEnableTimer;
     interface Get<bool> as IsBeaconEnabledPAN;
@@ -60,7 +53,7 @@ module RxEnableP
     interface GetNow<bool> as IsTrackingBeacons;
     interface GetNow<uint32_t> as IncomingSfStart; 
     interface GetNow<uint32_t> as IncomingBeaconInterval; 
-    interface Get<bool> as IsSendingBeacons;
+    interface GetNow<bool> as IsSendingBeacons;
     interface GetNow<uint32_t> as OutgoingSfStart; 
     interface GetNow<uint32_t> as OutgoingBeaconInterval; 
     interface Notify<bool> as WasRxEnabled;
@@ -69,12 +62,6 @@ module RxEnableP
 }
 implementation
 {
-  enum promiscuous_state {
-    S_IDLE,
-    S_STARTING,
-    S_STARTED,
-    S_STOPPING,
-  } m_promiscuousState;
 
   uint32_t m_rxOnDuration;
   uint32_t m_rxOnOffset;
@@ -82,9 +69,6 @@ implementation
   norace bool m_isRxEnabled;
   bool m_isRxEnableConfirmPending;
 
-  task void prepareDoneTask();
-  task void radioOffDoneTask();
-
   command error_t Init.init()
   {
     if (m_isRxEnableConfirmPending){
@@ -112,7 +96,7 @@ implementation
     if (RxOnTime > 0xFFFFFF || RxOnDuration > 0xFFFFFF)
       return IEEE154_INVALID_PARAMETER;
     if (call IsBeaconEnabledPAN.get()){
-      if (call IsSendingBeacons.get() && call IsMacPanCoordinator.get()){
+      if (call IsSendingBeacons.getNow() && call IsMacPanCoordinator.get()){
         // for OUTGOING SUPERFRAME
         lastBeaconTime = call OutgoingSfStart.getNow();
         beaconInterval = call OutgoingBeaconInterval.getNow();
@@ -181,94 +165,5 @@ implementation
 
   command error_t RxEnableStateChange.enable(){return FAIL;}
   command error_t RxEnableStateChange.disable(){return FAIL;}
-
-/* ----------------------- Promiscuous Mode ----------------------- */
-
-  command bool PromiscuousModeGet.get()
-  {
-    return (m_promiscuousState == S_STARTED);
-  }
-
-  command error_t PromiscuousMode.start()
-  {
-    if (m_promiscuousState != S_IDLE)
-      return FAIL;
-    m_promiscuousState = S_STARTING;
-    call Token.request();
-    call Debug.log(LEVEL_INFO, EnableRxP_PROMISCUOUS_REQUEST, m_promiscuousState, 0, 0);
-    call Debug.flush();
-    return SUCCESS;
-  }
-
-  event void Token.granted()
-  {
-    if (m_promiscuousState != S_STARTING){
-      call Token.release();
-      return;
-    }
-    call RadioPromiscuousMode.set(TRUE);
-    if (call PromiscuousRx.prepare() != IEEE154_SUCCESS){
-      m_promiscuousState = S_IDLE;
-      call Token.release();
-      call Debug.log(LEVEL_IMPORTANT, EnableRxP_RADIORX_ERROR, 0, 0, 0);
-      signal PromiscuousMode.startDone(FAIL);
-    }
-  }
-
-  async event void PromiscuousRx.prepareDone()
-  {
-    post prepareDoneTask();
-  }
-
-  task void prepareDoneTask()
-  {
-    if (m_promiscuousState != S_STARTING){
-      call Token.release();
-      return;
-    }    
-    m_promiscuousState = S_STARTED;
-    call PromiscuousRx.receive(NULL, 0);
-    signal PromiscuousMode.startDone(SUCCESS);
-    call Debug.log(LEVEL_INFO, EnableRxP_PROMISCUOUS_ON, m_promiscuousState, 0, 0);
-  }
-
-  event message_t* PromiscuousRx.received(message_t *frame, ieee154_reftime_t *timestamp)
-  {
-    if (m_promiscuousState == S_STARTED){
-      ((ieee154_header_t*) frame->header)->length |= FRAMECTL_PROMISCUOUS;
-      return signal FrameRx.received(frame);
-    } else
-      return frame;
-  }
-
-  command error_t PromiscuousMode.stop()
-  {
-    if (m_promiscuousState != S_STARTED)
-      return FAIL;
-    m_promiscuousState = S_STOPPING;
-    call RadioOff.off();
-    return SUCCESS;
-  }
-
-  async event void RadioOff.offDone()
-  {
-    post radioOffDoneTask();
-  }
-
-  task void radioOffDoneTask()
-  {
-    if (m_promiscuousState != S_STOPPING){
-      call Token.release();
-      return;
-    }
-    m_promiscuousState = S_IDLE;
-    call RadioPromiscuousMode.set(FALSE);
-    call Token.release();
-    signal PromiscuousMode.stopDone(SUCCESS);
-    call Debug.log(LEVEL_INFO, EnableRxP_PROMISCUOUS_OFF, m_promiscuousState, 0, 0);
-  }
-
-  default event void PromiscuousMode.startDone(error_t error){}
-  default event void PromiscuousMode.stopDone(error_t error){}
   default event void MLME_RX_ENABLE.confirm(ieee154_status_t status){}
 }
index 9889b7eb97a9ba3882ffe6fecfd164dcc4ecdc04..50b0d681c028617dfdc183eec08b47bdb346fb41 100644 (file)
@@ -36,7 +36,6 @@
 #ifndef __TKN154_H
 #define __TKN154_H
 
-
 /****************************************************
  * IEEE 802.15.4 Enumerations
  */
@@ -230,6 +229,37 @@ typedef bool                ieee154_macPanCoordinator_t;
 // When security is implemented the following line should be commented out
 #define IEEE154_SECURITY_DISABLED
 
+/**************************************************** 
+ * Flags for disabling MAC functionality (to save program memory)
+ */
+
+// Disable scanning (MLME_SCAN will not work):
+// #define IEEE154_SCAN_DISABLED
+//
+// Disable beacon tracking (MLME_SYNC will not work):
+// #define IEEE154_BEACON_SYNC_DISABLED
+//
+// Disable beacon transmission (MLME_START will not work):
+// #define IEEE154_BEACON_TX_DISABLED
+//
+// Disable promiscuous mode (PromiscuousMode.start() will not work):
+// #define IEEE154_PROMISCUOUS_MODE_DISABLED
+//
+// Disallow next higher layer to switch to receive mode (MLME_RX_ENABLE will not work):
+// #define IEEE154_RXENABLE_DISABLED
+//
+// Disable association (MLME_ASSOCIATE will not work):
+// #define IEEE154_ASSOCIATION_DISABLED
+//
+// Disable association (MLME_DISASSOCIATE will not work):
+// #define IEEE154_DISASSOCIATION_DISABLED
+//
+// Disable coordinator realignment (MLME_ORPHAN will not work):
+// #define IEEE154_COORD_REALIGNMENT_DISABLED
+//
+// Disable transmission of broadcasts from coordinator to devices:
+// #define IEEE154_COORD_BROADCAST_DISABLED
+
 /**************************************************** 
  * Static memory allocation for Queue/Pool
  */
index 057ff220f3b80a9be8e79e5c03ffe39e1a10bb1a..0f838375d0e23567143b0fe025d4ed0c48d66674 100644 (file)
@@ -109,19 +109,29 @@ configuration TKN154P
 }
 implementation
 {
-  components
+  components DataP,
+             PibP,
+             RadioControlP,
+             IndirectTxP,
+             PollP,
+
 #ifndef IEEE154_SCAN_DISABLED
              ScanP,
 #else
              NoScanP as ScanP,
 #endif
-             DataP,
+
+#ifndef IEEE154_ASSOCIATION_DISABLED
              AssociateP,
-             PollP,
-             RxEnableP,
-             IndirectTxP,
-             PibP,
-             RadioControlP,
+#else
+             NoAssociateP as AssociateP,
+#endif
+
+#ifndef IEEE154_DISASSOCIATION_DISABLED
+             DisassociateP,
+#else
+             NoDisassociateP as DisassociateP,
+#endif
 
 #ifndef IEEE154_BEACON_SYNC_DISABLED
              BeaconSynchronizeP,
@@ -145,8 +155,31 @@ implementation
 #endif
              NoCoordCfpP as CoordCfp,
 
+#ifndef IEEE154_RXENABLE_DISABLED
+             RxEnableP,
+#else
+             NoRxEnableP as RxEnableP,
+#endif
+
+
+#ifndef IEEE154_PROMISCUOUS_MODE_DISABLED
+             PromiscuousModeP,
+#else
+             NoPromiscuousModeP as PromiscuousModeP,
+#endif
+
+#ifndef IEEE154_COORD_REALIGNMENT_DISABLED
              CoordRealignmentP,
+#else
+             NoCoordRealignmentP as CoordRealignmentP,
+#endif
+
+#ifndef IEEE154_COORD_BROADCAST_DISABLED
              CoordBroadcastP,
+#else
+             NoCoordBroadcastP as CoordBroadcastP,
+#endif
+
              new PoolC(ieee154_txframe_t, TXFRAME_POOL_SIZE) as TxFramePoolP,
              new PoolC(ieee154_txcontrol_t, TXCONTROL_POOL_SIZE) as TxControlPoolP,
              new QueueC(ieee154_txframe_t*, CAP_TX_QUEUE_SIZE) as DeviceCapQueueC,
@@ -162,11 +195,11 @@ implementation
   //MLME
   MLME_START = BeaconTransmitP;
   MLME_ASSOCIATE = AssociateP;
+  MLME_DISASSOCIATE = DisassociateP;
   MLME_BEACON_NOTIFY = BeaconSynchronizeP;
   MLME_BEACON_NOTIFY = ScanP;
   MLME_COMM_STATUS = AssociateP;
   MLME_COMM_STATUS = CoordRealignmentP;
-  MLME_DISASSOCIATE = AssociateP;
   MLME_GET = PibP;
   MLME_ORPHAN = CoordRealignmentP;
 /*  MLME_GTS = CfpTransmitP;*/
@@ -179,7 +212,7 @@ implementation
   MLME_SYNC_LOSS = BeaconSynchronizeP;
   IEEE154Frame = PibP;
   IEEE154BeaconFrame = PibP;
-  PromiscuousMode = RxEnableP;
+  PromiscuousMode = PromiscuousModeP;
   GetLocalExtendedAddress = PibP.GetLocalExtendedAddress;
   IEEE154TxBeaconPayload = BeaconTransmitP;
   Packet = PibP; 
@@ -207,22 +240,23 @@ implementation
 
 /* ----------------- Beacon Transmission (MLME-START) ----------------- */
   
-  components new RadioClientC() as StartRadioClient;
+  components new RadioClientC() as BeaconTxRadioClient;
   PibP.MacReset -> BeaconTransmitP;
   BeaconTransmitP.PIBUpdate[IEEE154_macAssociationPermit] -> PibP.PIBUpdate[IEEE154_macAssociationPermit];
   BeaconTransmitP.PIBUpdate[IEEE154_macGTSPermit] -> PibP.PIBUpdate[IEEE154_macGTSPermit];
   BeaconTransmitP.BeaconTxAlarm = Alarm1;
   BeaconTransmitP.BeaconPayloadUpdateTimer = Timer2;
-  BeaconTransmitP.RadioOff -> StartRadioClient;
+  BeaconTransmitP.RadioOff -> BeaconTxRadioClient;
   BeaconTransmitP.IsBeaconEnabledPAN -> PibP.IsBeaconEnabledPAN;
-  BeaconTransmitP.BeaconTx -> StartRadioClient;
+  BeaconTransmitP.BeaconTx -> BeaconTxRadioClient;
   BeaconTransmitP.MLME_SET -> PibP.MLME_SET;
   BeaconTransmitP.MLME_GET -> PibP;
   BeaconTransmitP.SetMacSuperframeOrder -> PibP.SetMacSuperframeOrder;
   BeaconTransmitP.SetMacBeaconTxTime -> PibP.SetMacBeaconTxTime;
   BeaconTransmitP.SetMacPanCoordinator -> PibP.SetMacPanCoordinator;
-  BeaconTransmitP.Token -> StartRadioClient;
-  BeaconTransmitP.TokenToBroadcast -> StartRadioClient;
+  BeaconTransmitP.Token -> BeaconTxRadioClient;
+  BeaconTransmitP.TokenTransferred -> BeaconTxRadioClient;
+  BeaconTransmitP.TokenToBroadcast -> BeaconTxRadioClient;
   BeaconTransmitP.RealignmentBeaconEnabledTx -> CoordBroadcastP.RealignmentTx;
   BeaconTransmitP.RealignmentNonBeaconEnabledTx -> CoordCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
   BeaconTransmitP.BeaconRequestRx -> CoordCap.FrameRx[FC1_FRAMETYPE_CMD + CMD_FRAME_BEACON_REQUEST];
@@ -238,9 +272,9 @@ implementation
   BeaconTransmitP.TimeCalc -> PibP;
   BeaconTransmitP.Leds = Leds;
   BeaconTransmitP.Debug = Ieee802154Debug[START_CLIENT];
-  StartRadioClient.TransferTo -> CoordBroadcastRadioClient.TransferFrom;
+  BeaconTxRadioClient.TransferTo -> CoordBroadcastRadioClient.TransferFrom;
 
-/* ---------------- Beacon Synchronization (MLME-SYNC) ---------------- */
+/* ------------------ Beacon Tracking (MLME-SYNC) ------------------ */
 
   components new RadioClientC() as SyncRadioClient;
   PibP.MacReset -> BeaconSynchronizeP;
@@ -257,6 +291,7 @@ implementation
   BeaconSynchronizeP.IsBeaconEnabledPAN -> PibP.IsBeaconEnabledPAN;
   BeaconSynchronizeP.DataRequest -> PollP.DataRequest[SYNC_CLIENT];
   BeaconSynchronizeP.Token -> SyncRadioClient;
+  BeaconSynchronizeP.TokenTransferred -> SyncRadioClient;
   BeaconSynchronizeP.TokenToCap -> SyncRadioClient;
   BeaconSynchronizeP.TimeCalc -> PibP;
   BeaconSynchronizeP.CoordRealignmentRx -> DeviceCap.FrameRx[FC1_FRAMETYPE_CMD + CMD_FRAME_COORDINATOR_REALIGNMENT];
@@ -264,22 +299,13 @@ implementation
   BeaconSynchronizeP.Debug = Ieee802154Debug[SYNC_CLIENT];
   SyncRadioClient.TransferTo -> DeviceCapRadioClient.TransferFrom;
 
-/* --------------- Dis/Association (MLME-DIS/ASSOCIATE) --------------- */
+/* -------------------- Association (MLME-ASSOCIATE) -------------------- */
 
   PibP.MacReset -> AssociateP;
   AssociateP.AssociationRequestRx -> CoordCap.FrameRx[FC1_FRAMETYPE_CMD + CMD_FRAME_ASSOCIATION_REQUEST];
   AssociateP.AssociationRequestTx -> DeviceCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
   AssociateP.AssociationResponseExtracted -> DeviceCap.FrameExtracted[FC1_FRAMETYPE_CMD + CMD_FRAME_ASSOCIATION_RESPONSE];
   AssociateP.AssociationResponseTx -> IndirectTxP.FrameTx[unique(INDIRECT_TX_CLIENT)];
-  AssociateP.DisassociationIndirectTx -> IndirectTxP.FrameTx[unique(INDIRECT_TX_CLIENT)];
-  AssociateP.DisassociationDirectTx -> CoordCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
-  AssociateP.DisassociationToCoord -> DeviceCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
-  AssociateP.DisassociationDirectRxFromCoord -> 
-    DeviceCap.FrameRx[FC1_FRAMETYPE_CMD + CMD_FRAME_DISASSOCIATION_NOTIFICATION];
-  AssociateP.DisassociationExtractedFromCoord -> 
-    DeviceCap.FrameExtracted[FC1_FRAMETYPE_CMD + CMD_FRAME_DISASSOCIATION_NOTIFICATION];
-  AssociateP.DisassociationRxFromDevice -> 
-    CoordCap.FrameRx[FC1_FRAMETYPE_CMD + CMD_FRAME_DISASSOCIATION_NOTIFICATION];
   AssociateP.DataRequest -> PollP.DataRequest[ASSOCIATE_CLIENT];
   AssociateP.ResponseTimeout = Timer3;
   AssociateP.TxFramePool -> TxFramePoolP;
@@ -288,10 +314,29 @@ implementation
   AssociateP.MLME_SET -> PibP.MLME_SET;
   AssociateP.FrameUtility -> PibP;
   AssociateP.Frame -> PibP;
-  AssociateP.Leds = Leds;
   AssociateP.LocalExtendedAddress -> PibP.GetLocalExtendedAddress;
   AssociateP.Debug = Ieee802154Debug[ASSOCIATE_CLIENT];
 
+/* --------------- Disassociation (MLME-DISASSOCIATE) --------------- */
+
+  PibP.MacReset -> DisassociateP;
+  DisassociateP.DisassociationIndirectTx -> IndirectTxP.FrameTx[unique(INDIRECT_TX_CLIENT)];
+  DisassociateP.DisassociationDirectTx -> CoordCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
+  DisassociateP.DisassociationToCoord -> DeviceCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
+  DisassociateP.DisassociationDirectRxFromCoord -> 
+    DeviceCap.FrameRx[FC1_FRAMETYPE_CMD + CMD_FRAME_DISASSOCIATION_NOTIFICATION];
+  DisassociateP.DisassociationExtractedFromCoord -> 
+    DeviceCap.FrameExtracted[FC1_FRAMETYPE_CMD + CMD_FRAME_DISASSOCIATION_NOTIFICATION];
+  DisassociateP.DisassociationRxFromDevice -> 
+    CoordCap.FrameRx[FC1_FRAMETYPE_CMD + CMD_FRAME_DISASSOCIATION_NOTIFICATION];
+  DisassociateP.TxFramePool -> TxFramePoolP;
+  DisassociateP.TxControlPool -> TxControlPoolP;
+  DisassociateP.MLME_GET -> PibP;
+  DisassociateP.FrameUtility -> PibP;
+  DisassociateP.Frame -> PibP;
+  DisassociateP.LocalExtendedAddress -> PibP.GetLocalExtendedAddress;
+  DisassociateP.Debug = Ieee802154Debug[DISASSOCIATE_CLIENT];
+
 /* ------------------ Data Transmission (MCPS-DATA) ------------------- */
 
   PibP.MacReset -> DataP;
@@ -300,7 +345,7 @@ implementation
   DataP.DeviceCapTx -> DeviceCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
   DataP.CoordCapTx -> CoordCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
   DataP.DeviceCapRx -> PollP.DataRx;        // indirect
-  DataP.DeviceCapRx -> RxEnableP.FrameRx;   // promiscuous
+  DataP.DeviceCapRx -> PromiscuousModeP.FrameRx;   // promiscuous
   DataP.DeviceCapRx -> DeviceCap.FrameRx[FC1_FRAMETYPE_DATA]; // broadcast
   DataP.TxFramePool -> TxFramePoolP;
   DataP.BroadcastTx -> CoordBroadcastP.BroadcastDataFrame;
@@ -450,7 +495,9 @@ implementation
   DeviceCfp.Token -> DeviceCfpRadioClient;
   DeviceCfp.TokenTransferred -> DeviceCfpRadioClient;
   DeviceCfp.TokenRequested -> DeviceCfpRadioClient;
+  DeviceCfp.TokenToBeaconSync -> DeviceCfpRadioClient;
   DeviceCfp.CapStartRefTime -> BeaconSynchronizeP.CapStartRefTime; 
+  DeviceCfp.IsSendingBeacons -> BeaconTransmitP.IsSendingBeacons;
   DeviceCfp.CfpEnd -> BeaconSynchronizeP.CfpEnd; 
   DeviceCfp.GtsField -> BeaconSynchronizeP.GtsField; 
   DeviceCfp.SfSlotDuration -> BeaconSynchronizeP.SfSlotDuration; 
@@ -462,6 +509,7 @@ implementation
   DeviceCfp.RadioOff -> DeviceCfpRadioClient;
   DeviceCfp.MLME_GET -> PibP;
   DeviceCfp.MLME_SET -> PibP.MLME_SET; 
+  DeviceCfpRadioClient.TransferTo -> SyncRadioClient.TransferFrom;
 
 /* -------------------- GTS (outgoing superframe) --------------------- */
 
@@ -470,6 +518,8 @@ implementation
   CoordCfp.Token -> CoordCfpRadioClient;
   CoordCfp.TokenTransferred -> CoordCfpRadioClient;
   CoordCfp.TokenRequested -> CoordCfpRadioClient;
+  CoordCfp.TokenToBeaconTransmit -> CoordCfpRadioClient;
+  CoordCfp.IsTrackingBeacons -> BeaconSynchronizeP.IsTrackingBeacons;
   CoordCfp.CfpEnd -> BeaconTransmitP.CfpEnd; 
   CoordCfp.GtsField -> BeaconTransmitP.GtsField; 
   CoordCfp.SfSlotDuration -> BeaconTransmitP.SfSlotDuration; 
@@ -481,13 +531,21 @@ implementation
   CoordCfp.RadioOff -> CoordCfpRadioClient;
   CoordCfp.MLME_GET -> PibP;
   CoordCfp.MLME_SET -> PibP.MLME_SET;
+  CoordCfpRadioClient.TransferTo -> BeaconTxRadioClient.TransferFrom;
+
+/* -------------------------- promiscuous mode ------------------------ */
+
+  components new RadioClientC() as PromiscuousModeRadioClient;
+  PibP.MacReset -> PromiscuousModeP;
+  PromiscuousModeP.Token -> PromiscuousModeRadioClient;
+  PromiscuousModeP.PromiscuousRx -> PromiscuousModeRadioClient;
+  PromiscuousModeP.RadioOff -> PromiscuousModeRadioClient;
+  PromiscuousModeP.RadioPromiscuousMode = RadioPromiscuousMode;
+  PromiscuousModeP.Debug = Ieee802154Debug[PROMISCUOUS_MODE_CLIENT];
 
-/* ------------------ MLME-RX-ENABLE / promiscuous mode --------------- */
+/* --------------------------- MLME-RX-ENABLE  ------------------------ */
 
-  components new RadioClientC() as RxEnableRadioClient;
   PibP.MacReset -> RxEnableP;
-  RxEnableP.Token -> RxEnableRadioClient;
-  RxEnableP.PromiscuousRx -> RxEnableRadioClient;
   RxEnableP.IncomingSfStart -> BeaconSynchronizeP.CapStart;
   RxEnableP.OutgoingSfStart -> BeaconTransmitP.CapStart;
   RxEnableP.IncomingBeaconInterval -> BeaconSynchronizeP.BeaconInterval;
@@ -497,8 +555,6 @@ implementation
   RxEnableP.IsMacPanCoordinator -> PibP.IsMacPanCoordinator;
   RxEnableP.IsBeaconEnabledPAN -> PibP.IsBeaconEnabledPAN;
   RxEnableP.TimeCalc -> PibP.TimeCalc;
-  RxEnableP.RadioOff -> RxEnableRadioClient;
-  RxEnableP.RadioPromiscuousMode = RadioPromiscuousMode;
   RxEnableP.WasRxEnabled -> DeviceCap.WasRxEnabled;
   RxEnableP.WasRxEnabled -> CoordCap.WasRxEnabled;
   RxEnableP.RxEnableTimer = Timer5;
@@ -511,7 +567,7 @@ implementation
   MainC.SoftwareInit -> PibP.LocalInit;
   PibP.RadioControl = PhySplitControl;
   PibP.Random = Random; 
-  PibP.PromiscuousModeGet -> RxEnableP; 
+  PibP.PromiscuousModeGet -> PromiscuousModeP; 
   PibP.LocalTime = LocalTime;
   PibP.Token -> PibRadioClient;
   PibP.RadioOff -> PibRadioClient;
@@ -521,7 +577,7 @@ implementation
   RadioControlP.PhyTx = RadioTx;
   RadioControlP.PhyRx = RadioRx;
   RadioControlP.PhyRadioOff = RadioOff;
-  RadioControlP.RadioPromiscuousMode -> RxEnableP;
+  RadioControlP.RadioPromiscuousMode -> PromiscuousModeP;
   RadioControlP.Leds = Leds;
   RadioControlP.Debug = Ieee802154Debug[RADIORXTX_CLIENT];
 }
index 9ca3d90867f3b4d930ee6009d120934b77256053..117ededfed345e0d5d1e926a35d711b6c6d8fdec 100644 (file)
@@ -197,16 +197,17 @@ enum {
   RADIORXTX_CLIENT = 7,
   PIBDATABASE_CLIENT = 8,
   ASSOCIATE_CLIENT = 9,
-  DEVICECAPQUEUE_CLIENT = 10,
-  INDIRECTTX_DEBUG_CLIENT = 11,
-  DATA_CLIENT = 12,
-  POLL_CLIENT = 13,
-  DISASSOCIATE_CLIENT = 14,
+  DISASSOCIATE_CLIENT = 10,
+  DEVICECAPQUEUE_CLIENT = 11,
+  INDIRECTTX_DEBUG_CLIENT = 12,
+  DATA_CLIENT = 13,
+  POLL_CLIENT = 14,
   RXENABLE_CLIENT = 15,
+  PROMISCUOUS_MODE_CLIENT = 16,
 
-  PHY_CLIENT = 16,
-  PHY_TXCLIENT = 17,
-  PHY_RXCLIENT = 18,
+  PHY_CLIENT = 17,
+  PHY_TXCLIENT = 18,
+  PHY_RXCLIENT = 19,
 };
 
 typedef nx_struct serial_debug_msg {
index 224815396d37e92085c143d06e2b8105397d690e..f90d6b02e35e7dc75380e516240ba8423ad0f42e 100644 (file)
@@ -28,7 +28,8 @@
  *
  * - Revision -------------------------------------------------------------
  * $Date$
- * @author Torsten Halbhuebner <hhuebner.tu-berlin.de>
+ * @author Torsten Halbhuebner <hhuebner@tkn.tu-berlin.de>
+ * @author Jan Hauer <hauer@tkn.tu-berlin.de>
  * ========================================================================
  */
 
@@ -122,45 +123,114 @@ typedef struct ieee154_PIB_t {
 } ieee154_PIB_t;
 
 // PHY PIB default attributes
-
-#define IEEE154_DEFAULT_CURRENTCHANNEL          26
-#define IEEE154_DEFAULT_CHANNELSSUPPORTED_PAGE0 0x07FFF800
-#define IEEE154_DEFAULT_CHANNELSSUPPORTED_PAGE1 0
-#define IEEE154_DEFAULT_CHANNELSSUPPORTED_PAGE2 0
-#define IEEE154_DEFAULT_CCAMODE                 3
-#define IEEE154_DEFAULT_CURRENTPAGE             0
-#define IEEE154_DEFAULT_TRANSMITPOWER_dBm       0
+#ifndef IEEE154_DEFAULT_CURRENTCHANNEL          
+  #define IEEE154_DEFAULT_CURRENTCHANNEL          26
+#endif
+#ifndef IEEE154_DEFAULT_CHANNELSSUPPORTED_PAGE0 
+  #define IEEE154_DEFAULT_CHANNELSSUPPORTED_PAGE0 0x07FFF800
+#endif
+#ifndef IEEE154_DEFAULT_CHANNELSSUPPORTED_PAGE1 
+  #define IEEE154_DEFAULT_CHANNELSSUPPORTED_PAGE1 0
+#endif
+#ifndef IEEE154_DEFAULT_CHANNELSSUPPORTED_PAGE2 
+  #define IEEE154_DEFAULT_CHANNELSSUPPORTED_PAGE2 0
+#endif
+#ifndef IEEE154_DEFAULT_CCAMODE                 
+  #define IEEE154_DEFAULT_CCAMODE                 3
+#endif
+#ifndef IEEE154_DEFAULT_CURRENTPAGE             
+  #define IEEE154_DEFAULT_CURRENTPAGE             0
+#endif
+#ifndef IEEE154_DEFAULT_TRANSMITPOWER_dBm       
+  #define IEEE154_DEFAULT_TRANSMITPOWER_dBm       0
+#endif
 
 // MAC PIB default attributes
-#define IEEE154_DEFAULT_ASSOCIATEDPANCOORD      FALSE
-#define IEEE154_DEFAULT_ASSOCIATIONPERMIT       FALSE
-#define IEEE154_DEFAULT_AUTOREQUEST             TRUE
-#define IEEE154_DEFAULT_BATTLIFEEXT             FALSE
-#define IEEE154_DEFAULT_BATTLIFEEXTPERIODS      6
-#define IEEE154_DEFAULT_BEACONPAYLOAD           NULL
-#define IEEE154_DEFAULT_BEACONPAYLOADLENGTH     0
-#define IEEE154_DEFAULT_BEACONORDER             15
-#define IEEE154_DEFAULT_BEACONTXTIME            0
-#define IEEE154_DEFAULT_COORDSHORTADDRESS       0xFFFF
-#define IEEE154_DEFAULT_GTSPERMIT               TRUE
-#define IEEE154_DEFAULT_MAXBE                   5
-#define IEEE154_DEFAULT_MAXCSMABACKOFFS         4
-#define IEEE154_DEFAULT_MAXFRAMETOTALWAITTIME   2626
-#define IEEE154_DEFAULT_MAXFRAMERETRIES         3
-#define IEEE154_DEFAULT_MINBE                   3
-#define IEEE154_DEFAULT_MINLIFSPERIOD           40
-#define IEEE154_DEFAULT_MINSIFSPERIOD           12
-#define IEEE154_DEFAULT_PANID                   0xFFFF
-#define IEEE154_DEFAULT_PROMISCUOUSMODE         FALSE
-#define IEEE154_DEFAULT_RESPONSEWAITTIME        32
-#define IEEE154_DEFAULT_RXONWHENIDLE            FALSE
-#define IEEE154_DEFAULT_SECURITYENABLED         FALSE
-#define IEEE154_DEFAULT_SHORTADDRESS            0xFFFF
-
-#define IEEE154_DEFAULT_SUPERFRAMEORDER         15
-#define IEEE154_DEFAULT_SYNCSYMBOLOFFSET        0
-#define IEEE154_DEFAULT_TIMESTAMPSUPPORTED      TRUE
-#define IEEE154_DEFAULT_TRANSACTIONPERSISTENCETIME  0x01F4
+#ifndef IEEE154_DEFAULT_ASSOCIATEDPANCOORD      
+  #define IEEE154_DEFAULT_ASSOCIATEDPANCOORD      FALSE
+#endif
+#ifndef IEEE154_DEFAULT_ASSOCIATIONPERMIT       
+  #define IEEE154_DEFAULT_ASSOCIATIONPERMIT       FALSE
+#endif
+#ifndef IEEE154_DEFAULT_AUTOREQUEST             
+  #define IEEE154_DEFAULT_AUTOREQUEST             TRUE
+#endif
+#ifndef IEEE154_DEFAULT_BATTLIFEEXT             
+  #define IEEE154_DEFAULT_BATTLIFEEXT             FALSE
+#endif
+#ifndef IEEE154_DEFAULT_BATTLIFEEXTPERIODS      
+  #define IEEE154_DEFAULT_BATTLIFEEXTPERIODS      6
+#endif
+#ifndef IEEE154_DEFAULT_BEACONPAYLOAD           
+  #define IEEE154_DEFAULT_BEACONPAYLOAD           NULL
+#endif
+#ifndef IEEE154_DEFAULT_BEACONPAYLOADLENGTH     
+  #define IEEE154_DEFAULT_BEACONPAYLOADLENGTH     0
+#endif
+#ifndef IEEE154_DEFAULT_BEACONORDER             
+  #define IEEE154_DEFAULT_BEACONORDER             15
+#endif
+#ifndef IEEE154_DEFAULT_BEACONTXTIME            
+  #define IEEE154_DEFAULT_BEACONTXTIME            0
+#endif
+#ifndef IEEE154_DEFAULT_COORDSHORTADDRESS       
+  #define IEEE154_DEFAULT_COORDSHORTADDRESS       0xFFFF
+#endif
+#ifndef IEEE154_DEFAULT_GTSPERMIT               
+  #define IEEE154_DEFAULT_GTSPERMIT               TRUE
+#endif
+#ifndef IEEE154_DEFAULT_MAXBE                   
+  #define IEEE154_DEFAULT_MAXBE                   5
+#endif
+#ifndef IEEE154_DEFAULT_MAXCSMABACKOFFS         
+  #define IEEE154_DEFAULT_MAXCSMABACKOFFS         4
+#endif
+#ifndef IEEE154_DEFAULT_MAXFRAMETOTALWAITTIME   
+  #define IEEE154_DEFAULT_MAXFRAMETOTALWAITTIME   2626
+#endif
+#ifndef IEEE154_DEFAULT_MAXFRAMERETRIES         
+  #define IEEE154_DEFAULT_MAXFRAMERETRIES         3
+#endif
+#ifndef IEEE154_DEFAULT_MINBE                   
+  #define IEEE154_DEFAULT_MINBE                   3
+#endif
+#ifndef IEEE154_DEFAULT_MINLIFSPERIOD           
+  #define IEEE154_DEFAULT_MINLIFSPERIOD           40
+#endif
+#ifndef IEEE154_DEFAULT_MINSIFSPERIOD           
+  #define IEEE154_DEFAULT_MINSIFSPERIOD           12
+#endif
+#ifndef IEEE154_DEFAULT_PANID                   
+  #define IEEE154_DEFAULT_PANID                   0xFFFF
+#endif
+#ifndef IEEE154_DEFAULT_PROMISCUOUSMODE         
+  #define IEEE154_DEFAULT_PROMISCUOUSMODE         FALSE
+#endif
+#ifndef IEEE154_DEFAULT_RESPONSEWAITTIME        
+  #define IEEE154_DEFAULT_RESPONSEWAITTIME        32
+#endif
+#ifndef IEEE154_DEFAULT_RXONWHENIDLE            
+  #define IEEE154_DEFAULT_RXONWHENIDLE            FALSE
+#endif
+#ifndef IEEE154_DEFAULT_SECURITYENABLED         
+  #define IEEE154_DEFAULT_SECURITYENABLED         FALSE
+#endif
+#ifndef IEEE154_DEFAULT_SHORTADDRESS            
+  #define IEEE154_DEFAULT_SHORTADDRESS            0xFFFF
+#endif
+
+#ifndef IEEE154_DEFAULT_SUPERFRAMEORDER         
+  #define IEEE154_DEFAULT_SUPERFRAMEORDER         15
+#endif
+#ifndef IEEE154_DEFAULT_SYNCSYMBOLOFFSET        
+  #define IEEE154_DEFAULT_SYNCSYMBOLOFFSET        0
+#endif
+#ifndef IEEE154_DEFAULT_TIMESTAMPSUPPORTED      
+  #define IEEE154_DEFAULT_TIMESTAMPSUPPORTED      TRUE
+#endif
+#ifndef IEEE154_DEFAULT_TRANSACTIONPERSISTENCETIME  
+  #define IEEE154_DEFAULT_TRANSACTIONPERSISTENCETIME  0x01F4
+#endif
 
 #define IEEE154_INVALID_TIMESTAMP (0xffffffff)
 
index 8a780c05f17c62277c422d6e0881a5bbcc6b95e8..9273f001adea931c0d8c70f15ad573c49e48e39a 100644 (file)
@@ -61,16 +61,11 @@ implementation
 
   async command uint8_t TransferredFrom.getUserId(){ return myUserId;}
 
-  task void TransferredTask()
-  {
-    signal ResourceTransferred.transferred();
-  }
-
   async command void TransferredFrom.transfer()
   {
-    post TransferredTask();
+    signal ResourceTransferred.transferred();
   }
   default async command uint8_t TransferTo.getUserId(){ call Leds.led0On(); return 0xFF;}
   default async command void TransferTo.transfer(){ call Leds.led0On(); }
-  default event void ResourceTransferred.transferred(){}
+  default async event void ResourceTransferred.transferred(){}
 }
diff --git a/tos/lib/mac/tkn154/dummies/NoAssociateP.nc b/tos/lib/mac/tkn154/dummies/NoAssociateP.nc
new file mode 100644 (file)
index 0000000..aa4ac65
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in the 
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names 
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+
+#include "TKN154_MAC.h"
+
+module NoAssociateP
+{
+  provides
+  {
+    interface Init;
+    interface MLME_ASSOCIATE;
+    interface MLME_COMM_STATUS;
+  }
+  uses
+  {
+    interface FrameRx as AssociationRequestRx;
+    interface FrameTx as AssociationRequestTx;
+    interface FrameExtracted as AssociationResponseExtracted;
+    interface FrameTx as AssociationResponseTx;
+
+    interface DataRequest;
+    interface Timer<TSymbolIEEE802154> as ResponseTimeout;
+    interface Pool<ieee154_txframe_t> as TxFramePool;
+    interface Pool<ieee154_txcontrol_t> as TxControlPool;
+    interface MLME_GET;
+    interface MLME_SET;
+    interface FrameUtility;
+    interface IEEE154Frame as Frame;
+    interface Get<uint64_t> as LocalExtendedAddress;
+    interface Ieee802154Debug as Debug;
+  }
+}
+implementation
+{
+
+  command error_t Init.init() { return SUCCESS; }
+
+/* ------------------- MLME_ASSOCIATE Request ------------------- */
+
+  command ieee154_status_t MLME_ASSOCIATE.request  (
+                          uint8_t LogicalChannel,
+                          uint8_t ChannelPage,
+                          uint8_t CoordAddrMode,
+                          uint16_t CoordPANID,
+                          ieee154_address_t CoordAddress,
+                          ieee154_CapabilityInformation_t CapabilityInformation,
+                          ieee154_security_t *security
+                        )
+  {
+    return IEEE154_TRANSACTION_OVERFLOW;
+  }
+
+  event void AssociationRequestTx.transmitDone(ieee154_txframe_t *txFrame, ieee154_status_t status) { }
+  
+  event void ResponseTimeout.fired() { }
+
+  event message_t* AssociationResponseExtracted.received(message_t* frame, ieee154_txframe_t *txFrame) { return frame; }
+
+  event void DataRequest.pollDone() { }
+
+/* ------------------- MLME_ASSOCIATE Response ------------------- */
+
+  event message_t* AssociationRequestRx.received(message_t* frame) { return frame; }
+
+  command ieee154_status_t MLME_ASSOCIATE.response (
+                          uint64_t deviceAddress,
+                          uint16_t assocShortAddress,
+                          ieee154_association_status_t status,
+                          ieee154_security_t *security
+                        )
+  {
+    return IEEE154_TRANSACTION_OVERFLOW;
+  }
+
+  event void AssociationResponseTx.transmitDone(ieee154_txframe_t *txFrame, ieee154_status_t status) { }
+
+/* ------------------- Defaults ------------------- */
+
+  default event void MLME_ASSOCIATE.indication (
+                          uint64_t DeviceAddress,
+                          ieee154_CapabilityInformation_t CapabilityInformation,
+                          ieee154_security_t *security
+                        ){}
+  default event void MLME_ASSOCIATE.confirm    (
+                          uint16_t AssocShortAddress,
+                          uint8_t status,
+                          ieee154_security_t *security
+                        ){}
+  default event void MLME_COMM_STATUS.indication (
+                          uint16_t PANId,
+                          uint8_t SrcAddrMode,
+                          ieee154_address_t SrcAddr,
+                          uint8_t DstAddrMode,
+                          ieee154_address_t DstAddr,
+                          ieee154_status_t status,
+                          ieee154_security_t *security
+                        ){}
+}
index 92e8bb4819eefcc1b73cfe5232964911bf306a77..be14b1bc6f8a5907a4ba2c55239c48da1132affa 100644 (file)
@@ -100,7 +100,7 @@ implementation
 
   event void Token.granted() { }
 
-  event void TokenTransferred.transferred() { call Token.release(); }
+  async event void TokenTransferred.transferred() { call Token.release(); }
 
   async event void TrackAlarm.fired() {}
 
index 69b02085a778071443b6d389139480634c2308ea..16c443e9db2c143a971372757da130170686ff34 100644 (file)
@@ -42,7 +42,7 @@ module NoBeaconTransmitP
     interface Init;
     interface MLME_START;
     interface WriteBeaconField as SuperframeSpecWrite;
-    interface Get<bool> as IsSendingBeacons;
+    interface GetNow<bool> as IsSendingBeacons;
     interface GetNow<uint32_t> as CapStart; 
     interface GetNow<ieee154_reftime_t*> as CapStartRefTime; 
     interface GetNow<uint32_t> as CapLen; 
@@ -71,6 +71,7 @@ module NoBeaconTransmitP
     interface MLME_SET;
     interface Resource as Token;
     interface ResourceTransfer as TokenToBroadcast;
+    interface ResourceTransferred as TokenTransferred;
     interface FrameTx as RealignmentBeaconEnabledTx;
     interface FrameTx as RealignmentNonBeaconEnabledTx;
     interface FrameRx as BeaconRequestRx;
@@ -114,6 +115,8 @@ implementation
 
   event void Token.granted() { }
 
+  async event void TokenTransferred.transferred() { call Token.release(); }
+
   async event void RadioOff.offDone() { }
 
   async event void BeaconTxAlarm.fired() {}
@@ -173,7 +176,7 @@ implementation
     return frame;
   }
 
-  command bool IsSendingBeacons.get(){ return FALSE;}
+  async command bool IsSendingBeacons.getNow(){ return FALSE;}
 
   async command uint32_t CapStart.getNow() { return 0; }
   async command ieee154_reftime_t* CapStartRefTime.getNow() { return NULL; }
diff --git a/tos/lib/mac/tkn154/dummies/NoCoordBroadcastP.nc b/tos/lib/mac/tkn154/dummies/NoCoordBroadcastP.nc
new file mode 100644 (file)
index 0000000..2cf63e2
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in the 
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names 
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+#include "TKN154_MAC.h"
+module NoCoordBroadcastP
+{
+  provides
+  {
+    interface Init as Reset;
+    interface FrameTx as BroadcastDataFrame;
+    interface FrameTx as RealignmentTx;
+    interface GetNow<bool> as IsBroadcastReady; 
+  } uses {
+    interface Queue<ieee154_txframe_t*>; 
+    interface FrameTxNow as CapTransmitNow;
+    interface ResourceTransfer as TokenToCap;
+    interface ResourceTransferred as TokenTransferred;
+    interface GetNow<bool> as BeaconFramePendingBit;
+    interface Leds;
+  }
+}
+implementation
+{
+
+  command error_t Reset.init() { return SUCCESS; }
+
+  command ieee154_status_t BroadcastDataFrame.transmit(ieee154_txframe_t *txFrame)
+  {
+    return IEEE154_TRANSACTION_OVERFLOW;
+  }
+
+  command ieee154_status_t RealignmentTx.transmit(ieee154_txframe_t *frame)
+  {
+    return IEEE154_TRANSACTION_OVERFLOW;
+  }
+
+  async command bool IsBroadcastReady.getNow()
+  {
+    return FALSE;
+  }
+
+  async event void TokenTransferred.transferred()
+  {
+    call TokenToCap.transfer();
+  }
+
+  async event void CapTransmitNow.transmitNowDone(ieee154_txframe_t *txFrame, ieee154_status_t status)
+  {
+  }
+}
index f805fa1aa1298c71e25ff35eaaaf6da0ea4ab9a9..e142bf62f94b6390fe39e820787fe741c927c052 100644 (file)
@@ -55,6 +55,8 @@ module NoCoordCfpP
     interface Resource as Token;
     interface ResourceTransferred as TokenTransferred;
     interface ResourceRequested as TokenRequested;
+    interface ResourceTransfer as TokenToBeaconTransmit;
+    interface GetNow<bool> as IsTrackingBeacons; 
     interface GetNow<uint32_t> as CfpEnd; 
     interface GetNow<ieee154_reftime_t*> as CapStartRefTime; 
     interface GetNow<uint8_t*> as GtsField; 
@@ -89,23 +91,23 @@ implementation
     return IEEE154_INVALID_HANDLE; 
   } 
 
-  event void TokenTransferred.transferred()
+  async event void TokenTransferred.transferred()
   {
     // the CFP has started, this component now owns the token -  
     // because GTS is not implemented we release the token
-    // immediately; the general rule is: as long as a component
-    // owns the token it has exclusive access to the radio
-    call Token.release();
+    // (or pass it back to BeaconTransmitP if 
+    // we are not tracking beacons)
+    if (call IsTrackingBeacons.getNow())
+      call Token.release();  
+    else
+      call TokenToBeaconTransmit.transfer();
   }
 
-  async event void CfpEndAlarm.fired() { }
+  async event void CfpEndAlarm.fired() {}
 
   async event void CfpSlotAlarm.fired() {}
 
-  async event void RadioOff.offDone()
-  {
-    call Token.release();
-  }
+  async event void RadioOff.offDone() {}
     
   command uint8_t GtsInfoWrite.write(uint8_t *gtsSpecField, uint8_t maxlen)
   {
diff --git a/tos/lib/mac/tkn154/dummies/NoCoordRealignmentP.nc b/tos/lib/mac/tkn154/dummies/NoCoordRealignmentP.nc
new file mode 100644 (file)
index 0000000..cbe178e
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in the 
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names 
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+#include "TKN154_MAC.h"
+module NoCoordRealignmentP
+{
+  provides
+  {
+    interface Init;
+    interface MLME_ORPHAN;
+    interface MLME_COMM_STATUS;
+    interface GetSet<ieee154_txframe_t*> as GetSetRealignmentFrame;
+  }
+  uses
+  {
+    interface FrameTx as CoordRealignmentTx;
+    interface FrameRx as OrphanNotificationRx;
+    interface FrameUtility;
+    interface MLME_GET;
+    interface IEEE154Frame as Frame;
+    interface Pool<ieee154_txframe_t> as TxFramePool;
+    interface Pool<ieee154_txcontrol_t> as TxControlPool;
+    interface Get<uint64_t> as LocalExtendedAddress;
+  }
+}
+implementation
+{
+
+  command error_t Init.init() { return SUCCESS; }
+
+  command ieee154_txframe_t* GetSetRealignmentFrame.get() { return NULL; }
+
+  command void GetSetRealignmentFrame.set(ieee154_txframe_t*  frame) { }
+
+  event message_t* OrphanNotificationRx.received(message_t* frame) { return frame; }
+
+  command ieee154_status_t MLME_ORPHAN.response (
+                          uint64_t OrphanAddress,
+                          uint16_t ShortAddress,
+                          bool AssociatedMember,
+                          ieee154_security_t *security
+                        )
+  {
+    return IEEE154_TRANSACTION_OVERFLOW;
+  }
+  
+  event void CoordRealignmentTx.transmitDone(ieee154_txframe_t *txFrame, ieee154_status_t status)
+  {
+  }
+
+  default event void MLME_COMM_STATUS.indication (
+                          uint16_t PANId,
+                          uint8_t SrcAddrMode,
+                          ieee154_address_t SrcAddr,
+                          uint8_t DstAddrMode,
+                          ieee154_address_t DstAddr,
+                          ieee154_status_t status,
+                          ieee154_security_t *security
+                        ){}
+
+  default event void MLME_ORPHAN.indication (
+                          uint64_t OrphanAddress,
+                          ieee154_security_t *security
+                        ){}
+}
index 7f47303cbde741516c61f2d97aa2de2274919224..790fb7e231a3683452d1f30c9a9165433cc8fa6c 100644 (file)
@@ -90,7 +90,7 @@ implementation
     return SUCCESS;
   }
 
-  event void TokenTransferred.transferred()
+  async event void TokenTransferred.transferred()
   {
     call TokenToCfp.transfer();
   }
index 4cbc46899c272456afc97e91abd322c6f15983d6..0d672ce6bc0ac8c5b63f6e847811c70073e41297 100644 (file)
@@ -54,7 +54,9 @@ module NoDeviceCfpP
     interface Resource as Token;
     interface ResourceTransferred as TokenTransferred;
     interface ResourceRequested as TokenRequested;
+    interface ResourceTransfer as TokenToBeaconSync;
     interface GetNow<ieee154_reftime_t*> as CapStartRefTime; 
+    interface GetNow<bool> as IsSendingBeacons; 
     interface GetNow<uint32_t> as CfpEnd; 
     interface GetNow<uint8_t*> as GtsField; 
     interface GetNow<uint32_t> as SfSlotDuration; 
@@ -88,23 +90,23 @@ implementation
     return IEEE154_INVALID_HANDLE; 
   } 
 
-  event void TokenTransferred.transferred()
+  async event void TokenTransferred.transferred()
   { 
-    // the CFP has started, this component now owns the token -  
+    // the CFP has started, this component now owns the token. 
     // because GTS is not implemented we release the token
-    // immediately; the general rule is: as long as a component
-    // owns the token it has exclusive access to the radio
-    call Token.release();
+    // (or pass it back to BeaconSynchronizeP if 
+    // we are not transmitting beacons)
+    if (call IsSendingBeacons.getNow())
+      call Token.release();  
+    else
+      call TokenToBeaconSync.transfer();
   }
 
-  async event void CfpEndAlarm.fired() { }
+  async event void CfpEndAlarm.fired() {}
 
   async event void CfpSlotAlarm.fired() {}
 
-  async event void RadioOff.offDone()
-  {
-    call Token.release();
-  }
+  async event void RadioOff.offDone() {}
 
   async event void RadioTx.loadDone(){}
   async event void RadioTx.transmitDone(ieee154_txframe_t *frame, 
diff --git a/tos/lib/mac/tkn154/dummies/NoDisassociateP.nc b/tos/lib/mac/tkn154/dummies/NoDisassociateP.nc
new file mode 100644 (file)
index 0000000..6b3b836
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in the 
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names 
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+
+#include "TKN154_MAC.h"
+
+module NoDisassociateP
+{
+  provides
+  {
+    interface Init;
+    interface MLME_DISASSOCIATE;
+  } uses {
+
+    interface FrameTx as DisassociationIndirectTx;
+    interface FrameTx as DisassociationDirectTx;
+    interface FrameTx as DisassociationToCoord;
+
+    interface FrameRx as DisassociationDirectRxFromCoord;
+    interface FrameExtracted as DisassociationExtractedFromCoord;
+    interface FrameRx as DisassociationRxFromDevice;
+
+    interface Pool<ieee154_txframe_t> as TxFramePool;
+    interface Pool<ieee154_txcontrol_t> as TxControlPool;
+    interface MLME_GET;
+    interface FrameUtility;
+    interface IEEE154Frame as Frame;
+    interface Get<uint64_t> as LocalExtendedAddress;
+    interface Ieee802154Debug as Debug;
+  }
+}
+implementation
+{
+
+  command error_t Init.init() { return SUCCESS; }
+
+/* ------------------- MLME_DISASSOCIATE (initiating) ------------------- */
+
+  command ieee154_status_t MLME_DISASSOCIATE.request  (
+                          uint8_t DeviceAddrMode,
+                          uint16_t DevicePANID,
+                          ieee154_address_t DeviceAddress,
+                          ieee154_disassociation_reason_t DisassociateReason,
+                          bool TxIndirect,
+                          ieee154_security_t *security
+                        )
+  {
+    return IEEE154_TRANSACTION_OVERFLOW;
+  }
+
+  event void DisassociationToCoord.transmitDone(ieee154_txframe_t *data, ieee154_status_t status) { }
+
+  event void DisassociationIndirectTx.transmitDone(ieee154_txframe_t *data, ieee154_status_t status) { }
+
+  event void DisassociationDirectTx.transmitDone(ieee154_txframe_t *data, ieee154_status_t status) { }
+
+/* ------------------- MLME_DISASSOCIATE (receiving) ------------------- */
+
+  event message_t* DisassociationDirectRxFromCoord.received(message_t* frame) { return frame; }
+
+  event message_t* DisassociationExtractedFromCoord.received(message_t* frame, ieee154_txframe_t *txFrame) { return frame;
+  }
+
+  event message_t* DisassociationRxFromDevice.received(message_t* frame) { return frame; }
+
+/* ------------------- Defaults ------------------- */
+
+  default event void MLME_DISASSOCIATE.indication (
+                          uint64_t DeviceAddress,
+                          ieee154_disassociation_reason_t DisassociateReason,
+                          ieee154_security_t *security
+                        ){}
+  default event void MLME_DISASSOCIATE.confirm    (
+                          ieee154_status_t status,
+                          uint8_t DeviceAddrMode,
+                          uint16_t DevicePANID,
+                          ieee154_address_t DeviceAddress
+                        ){}
+
+}
diff --git a/tos/lib/mac/tkn154/dummies/NoPromiscuousModeP.nc b/tos/lib/mac/tkn154/dummies/NoPromiscuousModeP.nc
new file mode 100644 (file)
index 0000000..4ac6c85
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in the 
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names 
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+#include "TKN154_PHY.h"
+#include "TKN154_MAC.h"
+module NoPromiscuousModeP 
+{
+  provides {
+    interface Init;
+    interface SplitControl as PromiscuousMode;
+    interface Get<bool> as PromiscuousModeGet;
+    interface FrameRx;
+  } uses {
+    interface Resource as Token;
+    interface RadioRx as PromiscuousRx;
+    interface RadioOff;
+    interface Set<bool> as RadioPromiscuousMode;
+    interface Ieee802154Debug as Debug;
+  }
+}
+implementation
+{
+
+  command error_t Init.init() { return SUCCESS; }
+
+/* ----------------------- Promiscuous Mode ----------------------- */
+
+  command bool PromiscuousModeGet.get() { return FALSE; }
+
+  command error_t PromiscuousMode.start() { return FAIL; }
+
+  event void Token.granted() { call Token.release(); }
+
+  async event void PromiscuousRx.prepareDone() { }
+
+  event message_t* PromiscuousRx.received(message_t *frame, ieee154_reftime_t *timestamp) { return frame; }
+
+  command error_t PromiscuousMode.stop() { return FAIL; }
+
+  async event void RadioOff.offDone() { }
+
+  default event void PromiscuousMode.startDone(error_t error){}
+  default event void PromiscuousMode.stopDone(error_t error){}
+}
diff --git a/tos/lib/mac/tkn154/dummies/NoRxEnableP.nc b/tos/lib/mac/tkn154/dummies/NoRxEnableP.nc
new file mode 100644 (file)
index 0000000..97ad43b
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in the 
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names 
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+#include "TKN154_PHY.h"
+#include "TKN154_MAC.h"
+module NoRxEnableP
+{
+  provides
+  {
+    interface Init;
+    interface MLME_RX_ENABLE;
+    interface GetNow<bool> as IsRxEnableActive; 
+    interface Notify<bool> as RxEnableStateChange;
+  }
+  uses
+  {
+    interface Ieee802154Debug as Debug;
+    interface Timer<TSymbolIEEE802154> as RxEnableTimer;
+    interface Get<bool> as IsBeaconEnabledPAN;
+    interface Get<ieee154_macPanCoordinator_t> as IsMacPanCoordinator;
+    interface GetNow<bool> as IsTrackingBeacons;
+    interface GetNow<uint32_t> as IncomingSfStart; 
+    interface GetNow<uint32_t> as IncomingBeaconInterval; 
+    interface GetNow<bool> as IsSendingBeacons;
+    interface GetNow<uint32_t> as OutgoingSfStart; 
+    interface GetNow<uint32_t> as OutgoingBeaconInterval; 
+    interface Notify<bool> as WasRxEnabled;
+    interface TimeCalc;
+  }
+}
+implementation
+{
+
+  command error_t Init.init() { return SUCCESS; }
+
+/* ----------------------- MLME-RX-ENABLE ----------------------- */
+
+  command ieee154_status_t MLME_RX_ENABLE.request  ( 
+                          bool DeferPermit,
+                          uint32_t RxOnTime,
+                          uint32_t RxOnDuration
+                        )
+  {
+    return IEEE154_TRANSACTION_OVERFLOW;
+  }
+
+  event void RxEnableTimer.fired() {}
+
+  async command bool IsRxEnableActive.getNow() { return FALSE; }
+
+  event void WasRxEnabled.notify( bool val ) { }
+
+  command error_t RxEnableStateChange.enable(){return FAIL;}
+  command error_t RxEnableStateChange.disable(){return FAIL;}
+  default event void MLME_RX_ENABLE.confirm(ieee154_status_t status){}
+}
index ac224e9f0797e056422f82654569cd15d951dd6b..812c6b951c64c008fe131d003695e64c1666d60c 100644 (file)
@@ -35,24 +35,16 @@ interface ResourceTransfer
 {
 
   /** 
-   * Transfer control of a resource to another client. Conceptually, this
-   * command is similar to calling Resource.release() and then forcing the
-   * arbiter to signal the Resource.granted() event to the target client. But
-   * there is one difference: when a resource that was transferred through this
-   * command is released, it is released on behalf of the "original" client,
-   * i.e. who was last signalled the Resource.granted() event.  Releasing a
-   * transferred resource is thus equivalent to first transferring it back to
-   * the original client and then forcing the latter to release the resource
-   * through a call to Resource.release() -- this ensures that the arbitration
-   * policy can continue properly (and avoids possible starvation).
+   * Transfers ownership of a resource to another client, which will in turn
+   * be signalled a ResourceTransferred.transferred() event. 
    *
-   * Note that a resource may be transferred multiple times, before it is
-   * released. Then the current owner will change, but the "original" client
-   * will stay the same.
+   * When a resource that was transferred through this command is released, it
+   * is released on behalf of the "original" client, i.e. who was last
+   * signalled the Resource.granted() event and it then depends on the original
+   * queueing policy which component will be granted the resource next.
    *
    * @return SUCCESS If ownership has been transferred.<br> FAIL ownership has
    * not been transferred, because the caller is not owner of the resource
    */
-
-  async command error_t transfer();
+  async command error_t transfer(); 
 }
index 14a5b59a7ce31e4d56964bd581ac6cf03b91ccbc..1e9ccd7f74e9e7c029ce1c60bf8653fda3565913 100644 (file)
@@ -35,12 +35,12 @@ interface ResourceTransferred
 {
 
   /** 
-   * Control of a resource was transferred to this component from another
-   * client. This event is similar to the Resource.granted() event, but when a
-   * the resource is released, it is released on behalf of the client who was
-   * last signalled the Resource.granted() event.
+   * Ownership of a resource is transferred, possibly overriding the default
+   * queueing policy. This event is similar to an async Resource.granted()
+   * event, but when a the resource is released, it is released on behalf of
+   * the client who was last signalled the Resource.granted() event.
    *
    * @see ResourceTransfer interface
    */
-  event void transferred();
+  async event void transferred(); 
 }