📄 nocoordcfpp.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.7 $
* $Date: 2009/03/24 12:56:47 $
* @author Jan Hauer <hauer@tkn.tu-berlin.de>
* ========================================================================
*/
/**
* The contention free period (CFP) in beacon mode, a.k.a. GTS, is not yet
* implemented - this is only an empty placeholder. In contrast to the CAP
* component the GTS component for an incoming superframe will probably be very
* different from the GTS for an outgoing superframe. That is why there are two
* separate placeholder components (DeviceCfpP and CoordCfpP) instead of one
* generic CfpP component. This component would deal with the GTS for an
* outgoing superframe, i.e. from the perspective of a coordinator.
*/
#include "TKN154_MAC.h"
module NoCoordCfpP
{
provides {
interface Init;
interface WriteBeaconField as GtsInfoWrite;
interface FrameTx as CfpTx;
interface Purge;
} uses {
interface TransferableResource as RadioToken;
interface Alarm<TSymbolIEEE802154,uint32_t> as CfpSlotAlarm;
interface Alarm<TSymbolIEEE802154,uint32_t> as CfpEndAlarm;
interface SuperframeStructure as OutgoingSF;
interface RadioTx;
interface RadioRx;
interface RadioOff;
interface MLME_GET;
interface MLME_SET;
}
}
implementation
{
command error_t Init.init()
{
// initialize any module variables
return SUCCESS;
}
command ieee154_status_t CfpTx.transmit(ieee154_txframe_t *data)
{
// send a frame in a GTS slot (triggered by MCPS_DATA.request())
return IEEE154_INVALID_GTS;
}
command ieee154_status_t Purge.purge(uint8_t msduHandle)
{
// request to purge a frame (triggered by MCPS_DATA.purge())
return IEEE154_INVALID_HANDLE;
}
async event void RadioToken.transferredFrom(uint8_t fromClient)
{
// the CFP has started, this component now owns the token -
// because GTS is not implemented we pass it on
#ifndef IEEE154_BEACON_SYNC_DISABLED
call RadioToken.transferTo(RADIO_CLIENT_BEACONSYNCHRONIZE);
#else
call RadioToken.transferTo(RADIO_CLIENT_BEACONTRANSMIT);
#endif
}
async event void CfpEndAlarm.fired() {}
async event void CfpSlotAlarm.fired() {}
async event void RadioOff.offDone() {}
command uint8_t GtsInfoWrite.write(uint8_t *gtsSpecField, uint8_t maxlen)
{
// write the current GTS spec at the given address
if (call GtsInfoWrite.getLength() > maxlen)
return 0;
gtsSpecField[0] = 0;
return 1;
}
command uint8_t GtsInfoWrite.getLength()
{
// returns the length of the current GTS spec
// must return the same value as GtsInfoWrite.write
return 1;
}
async event void RadioTx.transmitDone(ieee154_txframe_t *frame, const ieee154_timestamp_t *timestamp, error_t result){}
async event void RadioRx.enableRxDone(){}
event message_t* RadioRx.received(message_t *frame, const ieee154_timestamp_t *timestamp){return frame;}
event void RadioToken.granted()
{
ASSERT(0); // should never happen, because we never call RadioToken.request()
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -