README for tkn154 test applications
-Author/Contact: tinyos-help@millennium.berkeley.edu
+Author/Contact: Jan Hauer <hauer@tkn.tu-berlin.de>
Description:
mode are located in the "beacon-enabled" folder, applications that use the
nonbeacon-enabled mode are in the "nonbeacon-enabled" folder. Every test
application resides in a separate subdirectory which includes a README.txt
-describing what it does and how it can be installed, respectively.
+describing what it does and how it can be installed.
The TKN15.4 implementation can be found in tinyos-2.x/tos/lib/mac/tkn154.
Note: TEP3 recommends that interface names "should be mixed case, starting
README for TestAssociate
-Author/Contact: tinyos-help@millennium.berkeley.edu
+Author/Contact: Jan Hauer <hauer@tkn.tu-berlin.de>
Description:
beacon-enabled 802.15.4 PAN, it transmits periodic beacons and waits for
devices to request association to its PAN. Whenever a device tries to
associate, the PAN coordinator accepts the association and assigns to the
-device a unique short address (starting from zero, incremented for every device
-new association). A second node acts as a device, it first scans the
+device a unique short address (starting from zero, incremented for every new
+association request). A second node acts as a device, it first scans the
pre-defined channel for beacons from the coordinator and once it finds a beacon
-it tries to associate to the PAN and synchronize to and track all future
-beacons. A short time after association the device then disassociates from the
-PAN.
+it tries to associate to the PAN. A short time after association the device
+then disassociates from the PAN.
Criteria for a successful test:
-Assuming one coordinator and one device has been installed, both should
-simultaneously toggle (only) the second LED, about once every 5 seconds.
+Both, coordinator and device, should toggle LED1 in unison about once every 5
+seconds. The coordinator should also toggle LED2 every second.
Tools: NONE
}
} implementation {
- ieee154_address_t m_lastDevice;
- uint16_t m_shortAddress;
+ uint16_t m_assignedShortAddress;
event void Boot.booted() {
call MLME_RESET.request(TRUE);
ieee154_security_t *security
)
{
- call MLME_ASSOCIATE.response(DeviceAddress, m_shortAddress++, IEEE154_ASSOCIATION_SUCCESSFUL, 0);
+ call MLME_ASSOCIATE.response(DeviceAddress, m_assignedShortAddress++, IEEE154_ASSOCIATION_SUCCESSFUL, 0);
}
event void MLME_DISASSOCIATE.indication (
if (status == IEEE154_SUCCESS){
// association was successful
call Leds.led1On();
- m_lastDevice.extendedAddress = DstAddr.extendedAddress;
} else {
call Leds.led1Off();
}
ieee154_CapabilityInformation_t m_capabilityInformation;
ieee154_PANDescriptor_t m_PANDescriptor;
- bool m_isPANDescriptorValid;
+ bool m_wasScanSuccessful;
void startApp();
event void Boot.booted() {
ieee154_phyChannelsSupported_t channel;
uint8_t scanDuration = BEACON_ORDER;
- m_isPANDescriptorValid = FALSE;
-
- // scan only one channel
+ // scan only one channel (to save time)
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);
- m_isPANDescriptorValid = FALSE;
+ m_wasScanSuccessful = FALSE;
call MLME_SCAN.request (
PASSIVE_SCAN, // ScanType
channel, // ScanChannels
{
// received a beacon frame
ieee154_phyCurrentPage_t page = call MLME_GET.phyCurrentPage();
- ieee154_macBSN_t beaconSequenceNumber = call BeaconFrame.getBSN(frame);
-
- if (beaconSequenceNumber & 1)
- call Leds.led2On();
- else
- call Leds.led2Off();
- if (!m_isPANDescriptorValid && call BeaconFrame.parsePANDescriptor(
- frame, RADIO_CHANNEL, page, &m_PANDescriptor) == SUCCESS){
- // let's see if the beacon is from the coordinator we expect...
- if (m_PANDescriptor.CoordAddrMode == ADDR_MODE_SHORT_ADDRESS &&
- m_PANDescriptor.CoordPANId == PAN_ID &&
- m_PANDescriptor.CoordAddress.shortAddress == COORDINATOR_ADDRESS){
- // yes - wait until SCAN is finished, then syncronize to beacons
- m_isPANDescriptorValid = TRUE;
+
+ if (!m_wasScanSuccessful) {
+ if (call BeaconFrame.parsePANDescriptor(
+ frame, RADIO_CHANNEL, page, &m_PANDescriptor) == SUCCESS){
+ // let's see if the beacon is from the coordinator we expect...
+ if (m_PANDescriptor.CoordAddrMode == ADDR_MODE_SHORT_ADDRESS &&
+ m_PANDescriptor.CoordPANId == PAN_ID &&
+ m_PANDescriptor.CoordAddress.shortAddress == COORDINATOR_ADDRESS){
+ // yes - wait until SCAN is finished, then syncronize to beacons
+ m_wasScanSuccessful = TRUE;
+ }
}
}
+
return frame;
}
ieee154_PANDescriptor_t* PANDescriptorList
)
{
- if (m_isPANDescriptorValid){
+ if (m_wasScanSuccessful) {
call MLME_SET.macPANId(m_PANDescriptor.CoordPANId);
call MLME_SET.macCoordShortAddress(m_PANDescriptor.CoordAddress.shortAddress);
call MLME_SYNC.request(m_PANDescriptor.LogicalChannel, m_PANDescriptor.ChannelPage, TRUE);
ieee154_security_t *security
)
{
- if ( status == IEEE154_SUCCESS ){
+ if ( status == IEEE154_SUCCESS ) {
// we are now associated - set a timer for disassociation
call Leds.led1On();
call DisassociateTimer.startOneShot(312500U);
README for TestData
-Author/Contact: tinyos-help@millennium.berkeley.edu
+Author/Contact: Jan Hauer <hauer@tkn.tu-berlin.de>
Description:
Criteria for a successful test:
-Assuming a clear channel and one coordinator and one device has been installed,
-both should toggle (only) the second LED fast, about 5 times per second. They
-don't have to toggle the LED simultaneously.
+Coordinator and device should both toggle LED2 about twice per second in
+unison. They should also each toggle LED1 about 5 times per second (but
+not necessarily in unison). Note: the nodes should be close to each other,
+because the transmission power is reduced to -20 dBm.
Tools: NONE
COORDINATOR_ADDRESS = 0x4331,
BEACON_ORDER = 5,
SUPERFRAME_ORDER = 5,
+ TX_POWER = -20, // in dBm
};
-//#define IEEE154_DEFAULT_TRANSMITPOWER_dBm -25
#endif
{
if (status != IEEE154_SUCCESS)
return;
+ call MLME_SET.phyTransmitPower(TX_POWER);
call MLME_SET.macShortAddress(COORDINATOR_ADDRESS);
call MLME_SET.macAssociationPermit(FALSE);
call MLME_START.request(
uint8_t m_payloadLen;
ieee154_PANDescriptor_t m_PANDescriptor;
bool m_ledCount;
- bool m_isPANDescriptorValid;
- bool m_sending;
+ bool m_wasScanSuccessful;
void startApp();
task void packetSendTask();
ieee154_phyChannelsSupported_t channelMask;
uint8_t scanDuration = BEACON_ORDER;
- m_isPANDescriptorValid = FALSE;
+ call MLME_SET.phyTransmitPower(TX_POWER);
call MLME_SET.macShortAddress(TOS_NODE_ID);
- // scan only one channel
+ // scan only the channel where we expect the coordinator
channelMask = ((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);
+ m_wasScanSuccessful = FALSE;
call MLME_SCAN.request (
PASSIVE_SCAN, // ScanType
channelMask, // ScanChannels
0 // security
);
}
- bool m_ready;
event message_t* MLME_BEACON_NOTIFY.indication (message_t* frame)
{
ieee154_phyCurrentPage_t page = call MLME_GET.phyCurrentPage();
ieee154_macBSN_t beaconSequenceNumber = call BeaconFrame.getBSN(frame);
- if (m_ready)
- post packetSendTask();
- if (beaconSequenceNumber & 1)
- call Leds.led2On();
- else
- call Leds.led2Off();
- 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){
- // yes! wait until SCAN is finished, then syncronize to the beacons
- m_isPANDescriptorValid = TRUE;
+ if (!m_wasScanSuccessful) {
+ // received a beacon during channel scanning
+ if (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){
+ // yes! wait until SCAN is finished, then syncronize to the beacons
+ m_wasScanSuccessful = TRUE;
+ }
}
+ } else {
+ // received a beacon during synchronization, toggle LED2
+ if (beaconSequenceNumber & 1)
+ call Leds.led2On();
+ else
+ call Leds.led2Off();
}
+
return frame;
}
ieee154_PANDescriptor_t* PANDescriptorList
)
{
- if (m_isPANDescriptorValid){
+ if (m_wasScanSuccessful) {
+ // we received a beacon from the coordinator before
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);
NULL // security
);
post packetSendTask();
- m_ready = TRUE;
} else
startApp();
}
task void packetSendTask()
{
- if (!m_sending && m_isPANDescriptorValid &&
- call MCPS_DATA.request (
+ if (!m_wasScanSuccessful)
+ return;
+ else if (call MCPS_DATA.request (
&m_frame, // frame,
m_payloadLen, // payloadLength,
0, // msduHandle,
TX_OPTIONS_ACK // TxOptions,
- ) == IEEE154_SUCCESS)
- m_sending = TRUE;
+ ) != IEEE154_SUCCESS)
+ call Leds.led0On();
}
- uint8_t m_useLeds = TRUE;
event void MCPS_DATA.confirm (
message_t *msg,
uint8_t msduHandle,
uint32_t timestamp
)
{
- m_sending = FALSE;
- if (status == IEEE154_SUCCESS && m_ledCount++ == 20){
+ if (status == IEEE154_SUCCESS && m_ledCount++ >= 20) {
m_ledCount = 0;
- if (m_useLeds)
- call Leds.led1Toggle();
+ call Leds.led1Toggle();
}
post packetSendTask();
}
uint8_t ChannelPage,
ieee154_security_t *security)
{
- m_useLeds = FALSE;
+ m_wasScanSuccessful = FALSE;
call Leds.led1Off();
- //startApp();
+ call Leds.led2Off();
}
event message_t* MCPS_DATA.indication (message_t* frame)
README for TestIndirect
-Author/Contact: tinyos-help@millennium.berkeley.edu
+Author/Contact: Jan Hauer <hauer@tkn.tu-berlin.de>
Description:
Criteria for a successful test:
-Both nodes should simultaneously toggle (only) the second LED, about once every
-half second.
+Both nodes should toggle the LED1 in unison, about once every half second.
+The coordinator should also toggle LED2 with the same frequency.
Tools: NONE
uint8_t m_payloadLen;
event void Boot.booted() {
- char payload[] = "Hello Device!";
- uint8_t *payloadRegion;
- ieee154_address_t deviceShortAddress;
-
- // construct the frame
- m_payloadLen = strlen(payload);
- payloadRegion = call Packet.getPayload(&m_frame, m_payloadLen);
- deviceShortAddress.shortAddress = DEVICE_ADDRESS; // destination
- if (m_payloadLen <= call Packet.maxPayloadLength()){
- memcpy(payloadRegion, payload, m_payloadLen);
- call Frame.setAddressingFields(
- &m_frame,
- ADDR_MODE_SHORT_ADDRESS, // SrcAddrMode,
- ADDR_MODE_SHORT_ADDRESS, // DstAddrMode,
- PAN_ID, // DstPANId,
- &deviceShortAddress, // DstAddr,
- NULL // security
- );
- call MLME_RESET.request(TRUE);
- }
+ call MLME_RESET.request(TRUE);
}
event void MLME_RESET.confirm(ieee154_status_t status)
{
if (status != IEEE154_SUCCESS)
return;
+
call MLME_SET.macShortAddress(COORDINATOR_ADDRESS);
call MLME_SET.macAssociationPermit(FALSE);
call MLME_START.request(
event void MLME_START.confirm(ieee154_status_t status)
{
- if (status == IEEE154_SUCCESS)
+ char payload[] = "Hello Device!";
+ uint8_t *payloadRegion;
+ ieee154_address_t deviceShortAddress;
+
+ // construct the frame
+ m_payloadLen = strlen(payload);
+ payloadRegion = call Packet.getPayload(&m_frame, m_payloadLen);
+ deviceShortAddress.shortAddress = DEVICE_ADDRESS; // destination
+ if (status == IEEE154_SUCCESS && m_payloadLen <= call Packet.maxPayloadLength()) {
+ memcpy(payloadRegion, payload, m_payloadLen);
+ call Frame.setAddressingFields(
+ &m_frame,
+ ADDR_MODE_SHORT_ADDRESS, // SrcAddrMode,
+ ADDR_MODE_SHORT_ADDRESS, // DstAddrMode,
+ PAN_ID, // DstPANId,
+ &deviceShortAddress, // DstAddr,
+ NULL // security
+ );
dataRequest();
+ }
}
event void MCPS_DATA.confirm(
uint8_t m_coordAddressMode;
ieee154_macPANId_t m_coordPANID;
ieee154_PANDescriptor_t m_PANDescriptor;
- bool m_isPANDescriptorValid;
+ bool m_wasScanSuccessful;
void startApp();
event void Boot.booted() {
// through the MLME_BEACON_NOTIFY interface, i.e.
// we set the macAutoRequest attribute to FALSE
call MLME_SET.macAutoRequest(FALSE);
+ m_wasScanSuccessful = FALSE;
call MLME_SCAN.request (
PASSIVE_SCAN, // ScanType
channel, // ScanChannels
{
// received a beacon frame during SCAN
ieee154_phyCurrentPage_t page = call MLME_GET.phyCurrentPage();
- ieee154_macBSN_t beaconSequenceNumber = call BeaconFrame.getBSN(frame);
- if (beaconSequenceNumber & 1)
- call Leds.led2On();
- else
- call Leds.led2Off();
-
- if (!m_isPANDescriptorValid && call BeaconFrame.parsePANDescriptor(
+ if (!m_wasScanSuccessful && 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;
+ m_wasScanSuccessful = TRUE;
}
}
return frame;
ieee154_PANDescriptor_t* PANDescriptorList
)
{
- if (m_isPANDescriptorValid){
+ if (m_wasScanSuccessful){
// set the macAutoRequest attribute to TRUE, so indirect
// transmissions are automatically carried through
call MLME_SET.macAutoRequest(TRUE);
ieee154_security_t *security)
{
call Leds.led1Off();
- startApp();
}
event message_t* MCPS_DATA.indication (message_t* frame)
README for TestStartSync
-Author/Contact: tinyos-help@millennium.berkeley.edu
+Author/Contact: Jan Hauer <hauer@tkn.tu-berlin.de>
Description:
Criteria for a successful test:
-After a few seconds all nodes should have (only) their second LED turned on.
+After a few seconds all nodes should have the LED1 turned on and LED2
+toggling in unison every second.
Tools: NONE
README for TestActiveScan
-Author/Contact: tinyos-help@millennium.berkeley.edu
+Author/Contact: Jan Hauer <hauer@tkn.tu-berlin.de>
Description:
Criteria for a successful test:
-On the coordinator node (only) the second LED should toggle once every 2
-seconds. On the device the second and third LED should toggle once every 2
-seconds, but with a small offset of half a second. On the device the first
-LED may toggle, but this should happen very rarely.
+The coordinator should toggle LED1 once every 2 seconds. The device should
+toggle LED1 and LED2 every 2 seconds (not necessarily simultaneously).
Tools: NONE
}
}
if(rightCoordFound == FALSE) {
- call Leds.led0On();
- call Led0Timer.startOneShot(62500U);
+ // call Leds.led0On();
+ // call Led0Timer.startOneShot(62500U);
}
}
README for TestAssociate
-Author/Contact: tinyos-help@millennium.berkeley.edu
+Author/Contact: Jan Hauer <hauer@tkn.tu-berlin.de>
Description:
Criteria for a successful test:
Assuming one coordinator and one device has been installed, both should
-simultaneously switch on (only) the second LED. About 5 seconds later
-both should switch off the second LED.
+simultaneously switch on LED1. About 5 seconds later both should switch LED1
+off. That's all.
Tools: NONE
README for TestIndirectData
-Author/Contact: tinyos-help@millennium.berkeley.edu
+Author/Contact: Jan Hauer <hauer@tkn.tu-berlin.de>
Description:
Criteria for a successful test:
Assuming one coordinator and one device has been installed, the coordinator
-should briefly flash the second LED every 3 seconds. The device should briefly
-flash its third LED every 1 second.
+should briefly flash LED1 every 3 seconds. The device should briefly flash
+LED2 every 1 second.
Tools: NONE
README for TestPromiscuous
-Author/Contact: tinyos-help@millennium.berkeley.edu
+Author/Contact: Jan Hauer <hauer@tkn.tu-berlin.de>
Description:
Criteria for a successful test:
-A successful test means that for every received frame the second LED is toggled
+A successful test means that for every received frame LED1 is toggled
and the java application outputs some text. To see this effect you need a
-second node sending a packet. The TestPromiscuous application does not send
-packets, but you can, for example, use the
+second node sending a packet, for example, use the
../../beacon-enabled/TestStartSync/coordinator application to send periodic
-beacon packets. In this case you should see some new text and the second LED
-should toggle every half second.
+beacon packets. In this case LED1 should toggle every half second and
+printf java client should output some text on the frame content.
Tools: The printf java client in $TOSDIR/../apps/tests/TestPrintf