[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/tkn154/TestINDIRECT/device Makefile, NONE, 1.1 TestDeviceReceiverC.nc, NONE, 1.1 TestIndirectAppC.nc, NONE, 1.1
Jan-Hinrich Hauer
janhauer at users.sourceforge.net
Mon Jun 16 11:22:48 PDT 2008
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/tkn154/TestINDIRECT/coordinator Makefile, NONE, 1.1 TestCoordSenderC.nc, NONE, 1.1 TestIndirectAppC.nc, NONE, 1.1
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/tkn154/TestPROMISCUOUS Makefile, NONE, 1.1 README.txt, NONE, 1.1 TestPromiscuousAppC.nc, NONE, 1.1 TestPromiscuousC.nc, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/tkn154/TestINDIRECT/device
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv7768/tkn154/TestINDIRECT/device
Added Files:
Makefile TestDeviceReceiverC.nc TestIndirectAppC.nc
Log Message:
Example applications for TKN15.4 (see tinyos-2.x/tos/lib/mac/tkn154)
--- NEW FILE: Makefile ---
COMPONENT=TestIndirectAppC
PFLAGS += -DIEEE154_BEACON_TX_DISABLED
CFLAGS += -I$(shell pwd)/..
include ../../Makefile.include
--- NEW FILE: TestDeviceReceiverC.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/06/16 18:22:46 $
* @author: Jan Hauer <hauer at tkn.tu-berlin.de>
* ========================================================================
*/
#include "TKN154.h"
#include "app_profile.h"
module TestDeviceReceiverC
{
uses {
interface Boot;
interface MCPS_DATA;
interface MLME_RESET;
interface MLME_SET;
interface MLME_GET;
interface MLME_SCAN;
interface MLME_SYNC;
interface MLME_BEACON_NOTIFY;
interface MLME_SYNC_LOSS;
interface IEEE154BeaconFrame as BeaconFrame;
interface Leds;
}
} implementation {
ieee154_address_t m_coordAddress;
uint8_t m_coordAddressMode;
ieee154_macPANId_t m_coordPANID;
ieee154_PANDescriptor_t m_PANDescriptor;
bool m_isPANDescriptorValid;
void startApp();
event void Boot.booted() {
call MLME_RESET.request(TRUE, BEACON_ENABLED_PAN);
}
event void MLME_RESET.confirm(ieee154_status_t status)
{
if (status == IEEE154_SUCCESS)
startApp();
}
void startApp()
{
ieee154_phyChannelsSupported_t channel;
uint8_t scanDuration = BEACON_ORDER;
// in this application the coordinator assumes that
// the device has a certain short address
call MLME_SET.macShortAddress(DEVICE_ADDRESS);
channel = ((uint32_t) 1) << RADIO_CHANNEL;
// we want all received beacons to be signalled
// through the MLME_BEACON_NOTIFY interface, i.e.
// we set the macAutoRequest attribute to FALSE
call MLME_SET.macAutoRequest(FALSE);
call MLME_SCAN.request (
PASSIVE_SCAN, // ScanType
channel, // ScanChannels
scanDuration, // ScanDuration
0x00, // ChannelPage
0, // EnergyDetectListNumEntries
NULL, // EnergyDetectList
0, // PANDescriptorListNumEntries
NULL, // PANDescriptorList
0 // security
);
}
event message_t* MLME_BEACON_NOTIFY.indication (message_t* frame)
{
// received a beacon frame during SCAN
ieee154_phyCurrentPage_t page = call MLME_GET.phyCurrentPage();
if (!m_isPANDescriptorValid && call BeaconFrame.parsePANDescriptor(
frame, RADIO_CHANNEL, page, &m_PANDescriptor) == SUCCESS){
// let's see if the beacon is from our coordinator...
if (m_PANDescriptor.CoordAddrMode == ADDR_MODE_SHORT_ADDRESS &&
m_PANDescriptor.CoordPANId == PAN_ID &&
m_PANDescriptor.CoordAddress.shortAddress == COORDINATOR_ADDRESS){
// wait until SCAN is finished, then syncronize to beacons
m_isPANDescriptorValid = TRUE;
}
}
return frame;
}
event void MLME_SCAN.confirm (
ieee154_status_t status,
uint8_t ScanType,
uint8_t ChannelPage,
uint32_t UnscannedChannels,
uint8_t EnergyDetectListNumEntries,
int8_t* EnergyDetectList,
uint8_t PANDescriptorListNumEntries,
ieee154_PANDescriptor_t* PANDescriptorList
)
{
if (m_isPANDescriptorValid){
// set the macAutoRequest attribute to TRUE, so indirect
// transmissions are automatically carried through
call MLME_SET.macAutoRequest(TRUE);
call MLME_SET.macCoordShortAddress(m_PANDescriptor.CoordAddress.shortAddress);
call MLME_SET.macPANId(m_PANDescriptor.CoordPANId);
call MLME_SYNC.request(m_PANDescriptor.LogicalChannel, m_PANDescriptor.ChannelPage, TRUE);
} else
startApp();
}
event void MCPS_DATA.confirm(
message_t *msg,
uint8_t msduHandle,
ieee154_status_t status,
uint32_t Timestamp
)
{
}
event void MLME_SYNC_LOSS.indication(
ieee154_status_t lossReason,
uint16_t PANId,
uint8_t LogicalChannel,
uint8_t ChannelPage,
ieee154_security_t *security)
{
call Leds.led1Off();
startApp();
}
event message_t* MCPS_DATA.indication (message_t* frame)
{
call Leds.led1Toggle();
return frame;
}
}
--- NEW FILE: TestIndirectAppC.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/06/16 18:22:46 $
* @author: Jan Hauer <hauer at tkn.tu-berlin.de>
* ========================================================================
*/
configuration TestIndirectAppC
{
} implementation {
components MainC, LedsC, Ieee802154MacC;
components TestDeviceReceiverC as App;
MainC.Boot <- App;
App.Leds -> LedsC;
App.MLME_RESET -> Ieee802154MacC;
App.MLME_SET -> Ieee802154MacC;
App.MLME_GET -> Ieee802154MacC;
App.MLME_SCAN -> Ieee802154MacC;
App.MLME_SYNC -> Ieee802154MacC;
App.MLME_BEACON_NOTIFY -> Ieee802154MacC;
App.MLME_SYNC_LOSS -> Ieee802154MacC;
App.MCPS_DATA -> Ieee802154MacC;
App.BeaconFrame -> Ieee802154MacC;
}
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/tkn154/TestINDIRECT/coordinator Makefile, NONE, 1.1 TestCoordSenderC.nc, NONE, 1.1 TestIndirectAppC.nc, NONE, 1.1
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/tkn154/TestPROMISCUOUS Makefile, NONE, 1.1 README.txt, NONE, 1.1 TestPromiscuousAppC.nc, NONE, 1.1 TestPromiscuousC.nc, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list