[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/mac/tkn154 DisassociateP.nc, NONE, 1.1 PromiscuousModeP.nc, NONE, 1.1 AssociateP.nc, 1.2, 1.3 BeaconSynchronizeP.nc, 1.4, 1.5 BeaconTransmitP.nc, 1.3, 1.4 CoordBroadcastP.nc, 1.2, 1.3 CsmaP.nc, 1.1, 1.2 DataP.nc, 1.1, 1.2 PibP.nc, 1.2, 1.3 RxEnableP.nc, 1.2, 1.3 TKN154_DEBUG.h, 1.1, 1.2 TKN154.h, 1.1, 1.2 TKN154_PIB.h, 1.1, 1.2 TKN154P.nc, 1.3, 1.4 TransferClientP.nc, 1.2, 1.3

Jan-Hinrich Hauer janhauer at users.sourceforge.net
Tue Oct 21 10:29:02 PDT 2008


Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11326/tos/lib/mac/tkn154

Modified Files:
	AssociateP.nc BeaconSynchronizeP.nc BeaconTransmitP.nc 
	CoordBroadcastP.nc CsmaP.nc DataP.nc PibP.nc RxEnableP.nc 
	TKN154_DEBUG.h TKN154.h TKN154_PIB.h TKN154P.nc 
	TransferClientP.nc 
Added Files:
	DisassociateP.nc PromiscuousModeP.nc 
Log Message:
- moved promiscuous mode into separate component
- separated association from disassociation component
- changed ResourceTransfer.tranfer to async
- added placeholders

--- NEW FILE: DisassociateP.nc ---
/*
 * 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: 1.1 $
 * $Date: 2008/10/21 17:29:00 $
 * @author Jan Hauer <hauer at 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
                        ){}

}

--- NEW FILE: PromiscuousModeP.nc ---
/*
 * 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: 1.1 $
 * $Date: 2008/10/21 17:29:00 $
 * @author Jan Hauer <hauer at 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: AssociateP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/AssociateP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AssociateP.nc	18 Jun 2008 15:39:32 -0000	1.2
--- AssociateP.nc	21 Oct 2008 17:29:00 -0000	1.3
***************
*** 43,47 ****
      interface Init;
      interface MLME_ASSOCIATE;
-     interface MLME_DISASSOCIATE;
      interface MLME_COMM_STATUS;
    }
--- 43,46 ----
***************
*** 53,64 ****
      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;
--- 52,55 ----
***************
*** 69,73 ****
      interface FrameUtility;
      interface IEEE154Frame as Frame;
-     interface Leds;
      interface Get<uint64_t> as LocalExtendedAddress;
      interface Ieee802154Debug as Debug;
--- 60,63 ----
***************
*** 80,84 ****
    };
    uint8_t m_payloadAssocRequest[2];
-   uint8_t m_payloadDisassocRequest[2];
    uint8_t m_payloadAssocResponse[MAX_PENDING_ASSOC_RESPONSES][4];
    uint8_t m_coordAddrMode;
--- 70,73 ----
***************
*** 86,90 ****
    uint16_t m_shortAddress;
    bool m_associationOngoing;
-   bool m_disAssociationOngoing;
  
    command error_t Init.init()
--- 75,78 ----
***************
*** 93,100 ****
      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;
--- 81,86 ----
***************
*** 303,454 ****
    }
  
- 
- /* ------------------- 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,
--- 289,294 ----

Index: BeaconSynchronizeP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/BeaconSynchronizeP.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** BeaconSynchronizeP.nc	24 Jul 2008 11:06:24 -0000	1.4
--- BeaconSynchronizeP.nc	21 Oct 2008 17:29:00 -0000	1.5
***************
*** 76,79 ****
--- 76,80 ----
      interface FrameRx as CoordRealignmentRx;
      interface Resource as Token;
+     interface ResourceTransferred as TokenTransferred;
      interface ResourceTransfer as TokenToCap;
      interface TimeCalc;
***************
*** 97,101 ****
  
    norace bool m_tracking = FALSE;
!   bool m_updatePending = FALSE;
    uint8_t m_updateLogicalChannel;
    bool m_updateTrackBeacon;
--- 98,102 ----
  
    norace bool m_tracking = FALSE;
!   norace bool m_updatePending = FALSE;
    uint8_t m_updateLogicalChannel;
    bool m_updateTrackBeacon;
***************
*** 103,107 ****
    bool m_internalRequest = FALSE;
  
!   uint8_t m_numBeaconsLost;
    uint8_t m_coordAddress[8];
    message_t m_beaconBuffer;
--- 104,108 ----
    bool m_internalRequest = FALSE;
  
!   norace uint8_t m_numBeaconsLost;
    uint8_t m_coordAddress[8];
    message_t m_beaconBuffer;
***************
*** 120,124 ****
--- 121,128 ----
    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()
***************
*** 165,170 ****
        m_updateLogicalChannel = logicalChannel;
        m_updateTrackBeacon = trackBeacon;
-       m_updatePending = TRUE;
        m_internalRequest = FALSE;
        call Debug.log(LEVEL_INFO,SyncP_RESOURCE_REQUEST, 0, 0, 0);
        call Token.request();
--- 169,174 ----
        m_updateLogicalChannel = logicalChannel;
        m_updateTrackBeacon = trackBeacon;
        m_internalRequest = FALSE;
+       m_updatePending = TRUE;
        call Debug.log(LEVEL_INFO,SyncP_RESOURCE_REQUEST, 0, 0, 0);
        call Token.request();
***************
*** 188,192 ****
    event void Token.granted()
    {
-     bool missed = FALSE;
      call Debug.flush();
      call Debug.log(LEVEL_INFO,SyncP_GOT_RESOURCE, m_lastBeaconRxTime+m_beaconInterval, 
--- 192,195 ----
***************
*** 205,209 ****
        call Debug.log(LEVEL_INFO,SyncP_UPDATING, call MLME_GET.macCoordShortAddress(), 
            call MLME_GET.macPANId(), m_updateLogicalChannel);
!     } else {
        m_state = S_PREPARE;
        if (!m_tracking){
--- 208,220 ----
        call Debug.log(LEVEL_INFO,SyncP_UPDATING, call MLME_GET.macCoordShortAddress(), 
            call MLME_GET.macPANId(), m_updateLogicalChannel);
!     }
!     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){
***************
*** 213,220 ****
        }
        while (call TimeCalc.hasExpired(m_lastBeaconRxTime, m_dt)){ // missed a beacon
          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){
--- 224,231 ----
        }
        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++;
        }
        if (m_numBeaconsLost >= IEEE154_aMaxLostBeacons){
***************
*** 235,238 ****
--- 246,262 ----
    }
  
+   async event void TokenTransferred.transferred()
+   {
+     if (m_updatePending)
+       post signalGrantedTask();
+     else
+       getNextBeacon();
+   }
+ 
+   task void signalGrantedTask()
+   {
+     signal Token.granted();
+   }
+ 
    async event void TrackAlarm.fired()
    {

Index: BeaconTransmitP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/BeaconTransmitP.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** BeaconTransmitP.nc	25 Jun 2008 10:19:03 -0000	1.3
--- BeaconTransmitP.nc	21 Oct 2008 17:29:00 -0000	1.4
***************
*** 43,47 ****
      interface MLME_START;
      interface WriteBeaconField as SuperframeSpecWrite;
!     interface Get<bool> as IsSendingBeacons;
      interface GetNow<uint32_t> as CapStart; 
      interface GetNow<ieee154_reftime_t*> as CapStartRefTime; 
--- 43,47 ----
      interface MLME_START;
      interface WriteBeaconField as SuperframeSpecWrite;
!     interface GetNow<bool> as IsSendingBeacons;
      interface GetNow<uint32_t> as CapStart; 
      interface GetNow<ieee154_reftime_t*> as CapStartRefTime; 
***************
*** 71,74 ****
--- 71,75 ----
      interface MLME_SET;
      interface Resource as Token;
+     interface ResourceTransferred as TokenTransferred;
      interface ResourceTransfer as TokenToBroadcast;
      interface FrameTx as RealignmentBeaconEnabledTx;
***************
*** 159,163 ****
    uint8_t m_updateLogicalChannel;
    uint32_t m_updateStartTime;
!   uint8_t m_updateBeaconOrder;
    uint8_t m_updateSuperframeOrder;
    bool m_updatePANCoordinator;
--- 160,164 ----
    uint8_t m_updateLogicalChannel;
    uint32_t m_updateStartTime;
!   norace uint8_t m_updateBeaconOrder;
    uint8_t m_updateSuperframeOrder;
    bool m_updatePANCoordinator;
***************
*** 252,257 ****
        if (coordRealignment)
          m_requests |= REQUEST_REALIGNMENT;
!       if (!call IsSendingBeacons.get())
!         call Token.request();
      }
      return status;
--- 253,258 ----
        if (coordRealignment)
          m_requests |= REQUEST_REALIGNMENT;
!       if (m_beaconOrder == 15) // only request token if we're not already transmitting beacons
!         call Token.request(); 
      }
      return status;
***************
*** 283,287 ****
        realignmentFrame->payloadLen = 8;
        
!       if (call IsSendingBeacons.get()){
          // we're already transmitting beacons; the realignment frame
          // must be sent (broadcast) after the next beacon
--- 284,288 ----
        realignmentFrame->payloadLen = 8;
        
!       if (m_beaconOrder < 15){
          // we're already transmitting beacons; the realignment frame
          // must be sent (broadcast) after the next beacon
***************
*** 411,414 ****
--- 412,420 ----
    }
  
+   async event void TokenTransferred.transferred()
+   {
+     post grantedTask();
+   }  
+ 
    async event void RadioOff.offDone()
    {
***************
*** 761,765 ****
    event message_t* BeaconRequestRx.received(message_t* frame)
    {
!     if (!call IsSendingBeacons.get()){
        // transmit the beacon frame using unslotted CSMA-CA
        // TODO
--- 767,771 ----
    event message_t* BeaconRequestRx.received(message_t* frame)
    {
!     if (m_beaconOrder == 15){
        // transmit the beacon frame using unslotted CSMA-CA
        // TODO
***************
*** 775,779 ****
    }
  
!   command bool IsSendingBeacons.get(){ return m_beaconOrder < 15;}
  
    async command uint32_t BeaconInterval.getNow() { return m_beaconInterval; }
--- 781,788 ----
    }
  
!   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; }

Index: CoordBroadcastP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/CoordBroadcastP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CoordBroadcastP.nc	18 Jun 2008 15:39:32 -0000	1.2
--- CoordBroadcastP.nc	21 Oct 2008 17:29:00 -0000	1.3
***************
*** 107,111 ****
    }
  
!   event void TokenTransferred.transferred()
    {
      // CAP has started - are there any broadcast frames to be transmitted?
--- 107,111 ----
    }
  
!   async event void TokenTransferred.transferred()
    {
      // CAP has started - are there any broadcast frames to be transmitted?

Index: CsmaP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/CsmaP.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CsmaP.nc	2 Aug 2008 16:56:21 -0000	1.1
--- CsmaP.nc	21 Oct 2008 17:29:00 -0000	1.2
***************
*** 174,178 ****
    }
  
!   event void TokenTransferred.transferred()
    {
      // we got the token, i.e. CAP has just started    
--- 174,178 ----
    }
  
!   async event void TokenTransferred.transferred()
    {
      // we got the token, i.e. CAP has just started    
***************
*** 183,190 ****
        // -> transmit current frame using unslotted CSMA-CA
        m_numCCA = 1;
!       signal Token.granted();
!       return;
!     }
!     else if (actualCapLen < IEEE154_RADIO_GUARD_TIME){
        call Debug.log(LEVEL_IMPORTANT, CapP_TOO_SHORT, superframeDirection, actualCapLen, IEEE154_RADIO_GUARD_TIME);
        call TokenToCfp.transfer();
--- 183,187 ----
        // -> transmit current frame using unslotted CSMA-CA
        m_numCCA = 1;
!     } else if (actualCapLen < IEEE154_RADIO_GUARD_TIME){
        call Debug.log(LEVEL_IMPORTANT, CapP_TOO_SHORT, superframeDirection, actualCapLen, IEEE154_RADIO_GUARD_TIME);
        call TokenToCfp.transfer();
***************
*** 212,216 ****
      }
      updateState();
-     call Debug.flush();
    }
  
--- 209,212 ----
***************
*** 708,713 ****
    event void Token.granted()
    {
!     // the current frame should be transmitted using unslotted CSMA-CA
!     updateState();
    }
  
--- 704,708 ----
    event void Token.granted()
    {
!     // will not happen
    }
  
***************
*** 719,722 ****
--- 714,720 ----
    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()){

Index: DataP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/DataP.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DataP.nc	16 Jun 2008 18:00:27 -0000	1.1
--- DataP.nc	21 Oct 2008 17:29:00 -0000	1.2
***************
*** 43,47 ****
      interface MCPS_PURGE;
    } uses {
!     interface Get<bool> as IsSendingBeacons;
      interface FrameRx as CoordCapRx;
      interface FrameTx as DeviceCapTx;
--- 43,47 ----
      interface MCPS_PURGE;
    } uses {
!     interface GetNow<bool> as IsSendingBeacons;
      interface FrameRx as CoordCapRx;
      interface FrameTx as DeviceCapTx;
***************
*** 146,150 ****
        // indirect transmission?
        } else if ((txOptions & TX_OPTIONS_INDIRECT) && 
!           call IsSendingBeacons.get() && 
            (dstAddrMode >= ADDR_MODE_SHORT_ADDRESS)){
          if (dstAddrMode == ADDR_MODE_SHORT_ADDRESS && dstAddr.shortAddress == 0xFFFF){
--- 146,150 ----
        // indirect transmission?
        } else if ((txOptions & TX_OPTIONS_INDIRECT) && 
!           call IsSendingBeacons.getNow() && 
            (dstAddrMode >= ADDR_MODE_SHORT_ADDRESS)){
          if (dstAddrMode == ADDR_MODE_SHORT_ADDRESS && dstAddr.shortAddress == 0xFFFF){

Index: PibP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/PibP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PibP.nc	18 Jun 2008 15:39:32 -0000	1.2
--- PibP.nc	21 Oct 2008 17:29:00 -0000	1.3
***************
*** 556,560 ****
    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));
--- 556,559 ----

Index: RxEnableP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/RxEnableP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RxEnableP.nc	18 Jun 2008 15:39:32 -0000	1.2
--- RxEnableP.nc	21 Oct 2008 17:29:00 -0000	1.3
***************
*** 42,48 ****
      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;
--- 42,45 ----
***************
*** 50,57 ****
    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;
--- 47,50 ----
***************
*** 61,65 ****
      interface GetNow<uint32_t> as IncomingSfStart; 
      interface GetNow<uint32_t> as IncomingBeaconInterval; 
!     interface Get<bool> as IsSendingBeacons;
      interface GetNow<uint32_t> as OutgoingSfStart; 
      interface GetNow<uint32_t> as OutgoingBeaconInterval; 
--- 54,58 ----
      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; 
***************
*** 70,79 ****
  implementation
  {
-   enum promiscuous_state {
-     S_IDLE,
-     S_STARTING,
-     S_STARTED,
-     S_STOPPING,
-   } m_promiscuousState;
  
    uint32_t m_rxOnDuration;
--- 63,66 ----
***************
*** 83,89 ****
    bool m_isRxEnableConfirmPending;
  
-   task void prepareDoneTask();
-   task void radioOffDoneTask();
- 
    command error_t Init.init()
    {
--- 70,73 ----
***************
*** 113,117 ****
        return IEEE154_INVALID_PARAMETER;
      if (call IsBeaconEnabledPAN.get()){
!       if (call IsSendingBeacons.get() && call IsMacPanCoordinator.get()){
          // for OUTGOING SUPERFRAME
          lastBeaconTime = call OutgoingSfStart.getNow();
--- 97,101 ----
        return IEEE154_INVALID_PARAMETER;
      if (call IsBeaconEnabledPAN.get()){
!       if (call IsSendingBeacons.getNow() && call IsMacPanCoordinator.get()){
          // for OUTGOING SUPERFRAME
          lastBeaconTime = call OutgoingSfStart.getNow();
***************
*** 182,274 ****
    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){}
  }
--- 166,169 ----

Index: TKN154_DEBUG.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/TKN154_DEBUG.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TKN154_DEBUG.h	16 Jun 2008 18:00:29 -0000	1.1
--- TKN154_DEBUG.h	21 Oct 2008 17:29:00 -0000	1.2
***************
*** 198,211 ****
    PIBDATABASE_CLIENT = 8,
    ASSOCIATE_CLIENT = 9,
!   DEVICECAPQUEUE_CLIENT = 10,
!   INDIRECTTX_DEBUG_CLIENT = 11,
!   DATA_CLIENT = 12,
!   POLL_CLIENT = 13,
!   DISASSOCIATE_CLIENT = 14,
    RXENABLE_CLIENT = 15,
  
!   PHY_CLIENT = 16,
!   PHY_TXCLIENT = 17,
!   PHY_RXCLIENT = 18,
  };
  
--- 198,212 ----
    PIBDATABASE_CLIENT = 8,
    ASSOCIATE_CLIENT = 9,
!   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 = 17,
!   PHY_TXCLIENT = 18,
!   PHY_RXCLIENT = 19,
  };
  

Index: TKN154.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/TKN154.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TKN154.h	16 Jun 2008 18:00:29 -0000	1.1
--- TKN154.h	21 Oct 2008 17:29:00 -0000	1.2
***************
*** 37,41 ****
  #define __TKN154_H
  
- 
  /****************************************************
   * IEEE 802.15.4 Enumerations
--- 37,40 ----
***************
*** 232,235 ****
--- 231,265 ----
  
  /**************************************************** 
+  * 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: TKN154_PIB.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/TKN154_PIB.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TKN154_PIB.h	16 Jun 2008 18:00:29 -0000	1.1
--- TKN154_PIB.h	21 Oct 2008 17:29:00 -0000	1.2
***************
*** 29,33 ****
   * - Revision -------------------------------------------------------------
   * $Date$
!  * @author Torsten Halbhuebner <hhuebner.tu-berlin.de>
   * ========================================================================
   */
--- 29,34 ----
   * - Revision -------------------------------------------------------------
   * $Date$
!  * @author Torsten Halbhuebner <hhuebner at tkn.tu-berlin.de>
!  * @author Jan Hauer <hauer at tkn.tu-berlin.de>
   * ========================================================================
   */
***************
*** 123,165 ****
  
  // 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
  
  // 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
  
  #define IEEE154_INVALID_TIMESTAMP (0xffffffff)
--- 124,235 ----
  
  // PHY PIB default attributes
! #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
! #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: TKN154P.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/TKN154P.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TKN154P.nc	2 Aug 2008 16:56:21 -0000	1.3
--- TKN154P.nc	21 Oct 2008 17:29:00 -0000	1.4
***************
*** 110,114 ****
  implementation
  {
!   components
  #ifndef IEEE154_SCAN_DISABLED
               ScanP,
--- 110,119 ----
  implementation
  {
!   components DataP,
!              PibP,
!              RadioControlP,
!              IndirectTxP,
!              PollP,
! 
  #ifndef IEEE154_SCAN_DISABLED
               ScanP,
***************
*** 116,126 ****
               NoScanP as ScanP,
  #endif
!              DataP,
               AssociateP,
!              PollP,
!              RxEnableP,
!              IndirectTxP,
!              PibP,
!              RadioControlP,
  
  #ifndef IEEE154_BEACON_SYNC_DISABLED
--- 121,136 ----
               NoScanP as ScanP,
  #endif
! 
! #ifndef IEEE154_ASSOCIATION_DISABLED
               AssociateP,
! #else
!              NoAssociateP as AssociateP,
! #endif
! 
! #ifndef IEEE154_DISASSOCIATION_DISABLED
!              DisassociateP,
! #else
!              NoDisassociateP as DisassociateP,
! #endif
  
  #ifndef IEEE154_BEACON_SYNC_DISABLED
***************
*** 146,151 ****
--- 156,184 ----
               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,
***************
*** 163,171 ****
    MLME_START = BeaconTransmitP;
    MLME_ASSOCIATE = AssociateP;
    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;
--- 196,204 ----
    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_GET = PibP;
    MLME_ORPHAN = CoordRealignmentP;
***************
*** 180,184 ****
    IEEE154Frame = PibP;
    IEEE154BeaconFrame = PibP;
!   PromiscuousMode = RxEnableP;
    GetLocalExtendedAddress = PibP.GetLocalExtendedAddress;
    IEEE154TxBeaconPayload = BeaconTransmitP;
--- 213,217 ----
    IEEE154Frame = PibP;
    IEEE154BeaconFrame = PibP;
!   PromiscuousMode = PromiscuousModeP;
    GetLocalExtendedAddress = PibP.GetLocalExtendedAddress;
    IEEE154TxBeaconPayload = BeaconTransmitP;
***************
*** 208,212 ****
  /* ----------------- Beacon Transmission (MLME-START) ----------------- */
    
!   components new RadioClientC() as StartRadioClient;
    PibP.MacReset -> BeaconTransmitP;
    BeaconTransmitP.PIBUpdate[IEEE154_macAssociationPermit] -> PibP.PIBUpdate[IEEE154_macAssociationPermit];
--- 241,245 ----
  /* ----------------- Beacon Transmission (MLME-START) ----------------- */
    
!   components new RadioClientC() as BeaconTxRadioClient;
    PibP.MacReset -> BeaconTransmitP;
    BeaconTransmitP.PIBUpdate[IEEE154_macAssociationPermit] -> PibP.PIBUpdate[IEEE154_macAssociationPermit];
***************
*** 214,220 ****
    BeaconTransmitP.BeaconTxAlarm = Alarm1;
    BeaconTransmitP.BeaconPayloadUpdateTimer = Timer2;
!   BeaconTransmitP.RadioOff -> StartRadioClient;
    BeaconTransmitP.IsBeaconEnabledPAN -> PibP.IsBeaconEnabledPAN;
!   BeaconTransmitP.BeaconTx -> StartRadioClient;
    BeaconTransmitP.MLME_SET -> PibP.MLME_SET;
    BeaconTransmitP.MLME_GET -> PibP;
--- 247,253 ----
    BeaconTransmitP.BeaconTxAlarm = Alarm1;
    BeaconTransmitP.BeaconPayloadUpdateTimer = Timer2;
!   BeaconTransmitP.RadioOff -> BeaconTxRadioClient;
    BeaconTransmitP.IsBeaconEnabledPAN -> PibP.IsBeaconEnabledPAN;
!   BeaconTransmitP.BeaconTx -> BeaconTxRadioClient;
    BeaconTransmitP.MLME_SET -> PibP.MLME_SET;
    BeaconTransmitP.MLME_GET -> PibP;
***************
*** 222,227 ****
    BeaconTransmitP.SetMacBeaconTxTime -> PibP.SetMacBeaconTxTime;
    BeaconTransmitP.SetMacPanCoordinator -> PibP.SetMacPanCoordinator;
!   BeaconTransmitP.Token -> StartRadioClient;
!   BeaconTransmitP.TokenToBroadcast -> StartRadioClient;
    BeaconTransmitP.RealignmentBeaconEnabledTx -> CoordBroadcastP.RealignmentTx;
    BeaconTransmitP.RealignmentNonBeaconEnabledTx -> CoordCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
--- 255,261 ----
    BeaconTransmitP.SetMacBeaconTxTime -> PibP.SetMacBeaconTxTime;
    BeaconTransmitP.SetMacPanCoordinator -> PibP.SetMacPanCoordinator;
!   BeaconTransmitP.Token -> BeaconTxRadioClient;
!   BeaconTransmitP.TokenTransferred -> BeaconTxRadioClient;
!   BeaconTransmitP.TokenToBroadcast -> BeaconTxRadioClient;
    BeaconTransmitP.RealignmentBeaconEnabledTx -> CoordBroadcastP.RealignmentTx;
    BeaconTransmitP.RealignmentNonBeaconEnabledTx -> CoordCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
***************
*** 239,245 ****
    BeaconTransmitP.Leds = Leds;
    BeaconTransmitP.Debug = Ieee802154Debug[START_CLIENT];
!   StartRadioClient.TransferTo -> CoordBroadcastRadioClient.TransferFrom;
  
! /* ---------------- Beacon Synchronization (MLME-SYNC) ---------------- */
  
    components new RadioClientC() as SyncRadioClient;
--- 273,279 ----
    BeaconTransmitP.Leds = Leds;
    BeaconTransmitP.Debug = Ieee802154Debug[START_CLIENT];
!   BeaconTxRadioClient.TransferTo -> CoordBroadcastRadioClient.TransferFrom;
  
! /* ------------------ Beacon Tracking (MLME-SYNC) ------------------ */
  
    components new RadioClientC() as SyncRadioClient;
***************
*** 258,261 ****
--- 292,296 ----
    BeaconSynchronizeP.DataRequest -> PollP.DataRequest[SYNC_CLIENT];
    BeaconSynchronizeP.Token -> SyncRadioClient;
+   BeaconSynchronizeP.TokenTransferred -> SyncRadioClient;
    BeaconSynchronizeP.TokenToCap -> SyncRadioClient;
    BeaconSynchronizeP.TimeCalc -> PibP;
***************
*** 265,269 ****
    SyncRadioClient.TransferTo -> DeviceCapRadioClient.TransferFrom;
  
! /* --------------- Dis/Association (MLME-DIS/ASSOCIATE) --------------- */
  
    PibP.MacReset -> AssociateP;
--- 300,304 ----
    SyncRadioClient.TransferTo -> DeviceCapRadioClient.TransferFrom;
  
! /* -------------------- Association (MLME-ASSOCIATE) -------------------- */
  
    PibP.MacReset -> AssociateP;
***************
*** 272,284 ****
    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;
--- 307,310 ----
***************
*** 289,296 ****
    AssociateP.FrameUtility -> PibP;
    AssociateP.Frame -> PibP;
-   AssociateP.Leds = Leds;
    AssociateP.LocalExtendedAddress -> PibP.GetLocalExtendedAddress;
    AssociateP.Debug = Ieee802154Debug[ASSOCIATE_CLIENT];
  
  /* ------------------ Data Transmission (MCPS-DATA) ------------------- */
  
--- 315,341 ----
    AssociateP.FrameUtility -> PibP;
    AssociateP.Frame -> PibP;
    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) ------------------- */
  
***************
*** 301,305 ****
    DataP.CoordCapTx -> CoordCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
    DataP.DeviceCapRx -> PollP.DataRx;        // indirect
!   DataP.DeviceCapRx -> RxEnableP.FrameRx;   // promiscuous
    DataP.DeviceCapRx -> DeviceCap.FrameRx[FC1_FRAMETYPE_DATA]; // broadcast
    DataP.TxFramePool -> TxFramePoolP;
--- 346,350 ----
    DataP.CoordCapTx -> CoordCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
    DataP.DeviceCapRx -> PollP.DataRx;        // indirect
!   DataP.DeviceCapRx -> PromiscuousModeP.FrameRx;   // promiscuous
    DataP.DeviceCapRx -> DeviceCap.FrameRx[FC1_FRAMETYPE_DATA]; // broadcast
    DataP.TxFramePool -> TxFramePoolP;
***************
*** 451,455 ****
--- 496,502 ----
    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; 
***************
*** 463,466 ****
--- 510,514 ----
    DeviceCfp.MLME_GET -> PibP;
    DeviceCfp.MLME_SET -> PibP.MLME_SET; 
+   DeviceCfpRadioClient.TransferTo -> SyncRadioClient.TransferFrom;
  
  /* -------------------- GTS (outgoing superframe) --------------------- */
***************
*** 471,474 ****
--- 519,524 ----
    CoordCfp.TokenTransferred -> CoordCfpRadioClient;
    CoordCfp.TokenRequested -> CoordCfpRadioClient;
+   CoordCfp.TokenToBeaconTransmit -> CoordCfpRadioClient;
+   CoordCfp.IsTrackingBeacons -> BeaconSynchronizeP.IsTrackingBeacons;
    CoordCfp.CfpEnd -> BeaconTransmitP.CfpEnd; 
    CoordCfp.GtsField -> BeaconTransmitP.GtsField; 
***************
*** 482,492 ****
    CoordCfp.MLME_GET -> PibP;
    CoordCfp.MLME_SET -> PibP.MLME_SET;
  
! /* ------------------ MLME-RX-ENABLE / promiscuous mode --------------- */
  
-   components new RadioClientC() as RxEnableRadioClient;
    PibP.MacReset -> RxEnableP;
-   RxEnableP.Token -> RxEnableRadioClient;
-   RxEnableP.PromiscuousRx -> RxEnableRadioClient;
    RxEnableP.IncomingSfStart -> BeaconSynchronizeP.CapStart;
    RxEnableP.OutgoingSfStart -> BeaconTransmitP.CapStart;
--- 532,550 ----
    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  ------------------------ */
  
    PibP.MacReset -> RxEnableP;
    RxEnableP.IncomingSfStart -> BeaconSynchronizeP.CapStart;
    RxEnableP.OutgoingSfStart -> BeaconTransmitP.CapStart;
***************
*** 498,503 ****
    RxEnableP.IsBeaconEnabledPAN -> PibP.IsBeaconEnabledPAN;
    RxEnableP.TimeCalc -> PibP.TimeCalc;
-   RxEnableP.RadioOff -> RxEnableRadioClient;
-   RxEnableP.RadioPromiscuousMode = RadioPromiscuousMode;
    RxEnableP.WasRxEnabled -> DeviceCap.WasRxEnabled;
    RxEnableP.WasRxEnabled -> CoordCap.WasRxEnabled;
--- 556,559 ----
***************
*** 512,516 ****
    PibP.RadioControl = PhySplitControl;
    PibP.Random = Random; 
!   PibP.PromiscuousModeGet -> RxEnableP; 
    PibP.LocalTime = LocalTime;
    PibP.Token -> PibRadioClient;
--- 568,572 ----
    PibP.RadioControl = PhySplitControl;
    PibP.Random = Random; 
!   PibP.PromiscuousModeGet -> PromiscuousModeP; 
    PibP.LocalTime = LocalTime;
    PibP.Token -> PibRadioClient;
***************
*** 522,526 ****
    RadioControlP.PhyRx = RadioRx;
    RadioControlP.PhyRadioOff = RadioOff;
!   RadioControlP.RadioPromiscuousMode -> RxEnableP;
    RadioControlP.Leds = Leds;
    RadioControlP.Debug = Ieee802154Debug[RADIORXTX_CLIENT];
--- 578,582 ----
    RadioControlP.PhyRx = RadioRx;
    RadioControlP.PhyRadioOff = RadioOff;
!   RadioControlP.RadioPromiscuousMode -> PromiscuousModeP;
    RadioControlP.Leds = Leds;
    RadioControlP.Debug = Ieee802154Debug[RADIORXTX_CLIENT];

Index: TransferClientP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/TransferClientP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TransferClientP.nc	18 Jun 2008 15:39:32 -0000	1.2
--- TransferClientP.nc	21 Oct 2008 17:29:00 -0000	1.3
***************
*** 62,76 ****
    async command uint8_t TransferredFrom.getUserId(){ return myUserId;}
  
-   task void TransferredTask()
-   {
-     signal ResourceTransferred.transferred();
-   }
- 
    async command void TransferredFrom.transfer()
    {
!     post TransferredTask();
    }
    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(){}
  }
--- 62,71 ----
    async command uint8_t TransferredFrom.getUserId(){ return myUserId;}
  
    async command void TransferredFrom.transfer()
    {
!     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 async event void ResourceTransferred.transferred(){}
  }



More information about the Tinyos-2-commits mailing list