From: rarseverino Date: Fri, 18 Sep 2009 16:55:49 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: rc_6_tinyos_2_1_1~237 X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=commitdiff_plain;h=a9ecb58717494a8e6d5c72f9372a41510880a460;p=tinyos-2.x.git *** empty log message *** --- diff --git a/tos/lib/net/zigbee/apps/AssociationExample/AssociationExample.nc b/tos/lib/net/zigbee/apps/AssociationExample/AssociationExample.nc deleted file mode 100644 index 75aa75fc..00000000 --- a/tos/lib/net/zigbee/apps/AssociationExample/AssociationExample.nc +++ /dev/null @@ -1,61 +0,0 @@ -/* - * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise - * @author Andre Cunha - * - */ -#include - -#include "associationexample.h" -#include "phy_const.h" -#include "phy_enumerations.h" -#include "mac_const.h" -#include "mac_enumerations.h" -#include "mac_func.h" - - -configuration AssociationExample { -} -implementation { - - components MainC; - components LedsC; - components AssociationExampleM; - - AssociationExampleM.Boot -> MainC; - - components Mac; - - AssociationExampleM.Leds -> LedsC; - - components new TimerMilliC() as Timer0; - AssociationExampleM.Timer0 -> Timer0; - - components new TimerMilliC() as Timer_Send; - AssociationExampleM.Timer_Send ->Timer_Send; - - - //MAC interfaces - - AssociationExampleM.MLME_START -> Mac.MLME_START; - - AssociationExampleM.MLME_GET ->Mac.MLME_GET; - AssociationExampleM.MLME_SET ->Mac.MLME_SET; - - AssociationExampleM.MLME_BEACON_NOTIFY ->Mac.MLME_BEACON_NOTIFY; - AssociationExampleM.MLME_GTS -> Mac.MLME_GTS; - - AssociationExampleM.MLME_ASSOCIATE->Mac.MLME_ASSOCIATE; - AssociationExampleM.MLME_DISASSOCIATE->Mac.MLME_DISASSOCIATE; - - AssociationExampleM.MLME_ORPHAN->Mac.MLME_ORPHAN; - AssociationExampleM.MLME_SYNC->Mac.MLME_SYNC; - AssociationExampleM.MLME_SYNC_LOSS->Mac.MLME_SYNC_LOSS; - AssociationExampleM.MLME_RESET->Mac.MLME_RESET; - - AssociationExampleM.MLME_SCAN->Mac.MLME_SCAN; - - - AssociationExampleM.MCPS_DATA->Mac.MCPS_DATA; - - -} diff --git a/tos/lib/net/zigbee/apps/AssociationExample/AssociationExampleC.nc b/tos/lib/net/zigbee/apps/AssociationExample/AssociationExampleC.nc new file mode 100644 index 00000000..bebb5067 --- /dev/null +++ b/tos/lib/net/zigbee/apps/AssociationExample/AssociationExampleC.nc @@ -0,0 +1,61 @@ +/* + * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise + * @author Andre Cunha + * + */ +#include + +#include "associationexample.h" +#include "phy_const.h" +#include "phy_enumerations.h" +#include "mac_const.h" +#include "mac_enumerations.h" +#include "mac_func.h" + + +configuration AssociationExampleC { +} +implementation { + + components MainC; + components LedsC; + components AssociationExampleP; + + AssociationExampleP.Boot -> MainC; + + components MacC; + + AssociationExampleP.Leds -> LedsC; + + components new TimerMilliC() as Timer0; + AssociationExampleP.Timer0 -> Timer0; + + components new TimerMilliC() as Timer_Send; + AssociationExampleP.Timer_Send ->Timer_Send; + + + //MAC interfaces + + AssociationExampleP.MLME_START -> MacC.MLME_START; + + AssociationExampleP.MLME_GET ->MacC.MLME_GET; + AssociationExampleP.MLME_SET ->MacC.MLME_SET; + + AssociationExampleP.MLME_BEACON_NOTIFY ->MacC.MLME_BEACON_NOTIFY; + AssociationExampleP.MLME_GTS -> MacC.MLME_GTS; + + AssociationExampleP.MLME_ASSOCIATE->MacC.MLME_ASSOCIATE; + AssociationExampleP.MLME_DISASSOCIATE->MacC.MLME_DISASSOCIATE; + + AssociationExampleP.MLME_ORPHAN->MacC.MLME_ORPHAN; + AssociationExampleP.MLME_SYNC->MacC.MLME_SYNC; + AssociationExampleP.MLME_SYNC_LOSS->MacC.MLME_SYNC_LOSS; + AssociationExampleP.MLME_RESET->MacC.MLME_RESET; + + AssociationExampleP.MLME_SCAN->MacC.MLME_SCAN; + + + AssociationExampleP.MCPS_DATA->MacC.MCPS_DATA; + + +} diff --git a/tos/lib/net/zigbee/apps/AssociationExample/AssociationExampleM.nc b/tos/lib/net/zigbee/apps/AssociationExample/AssociationExampleM.nc deleted file mode 100644 index 99e4c799..00000000 --- a/tos/lib/net/zigbee/apps/AssociationExample/AssociationExampleM.nc +++ /dev/null @@ -1,489 +0,0 @@ -/* - * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise - * @author Andre Cunha - * - */ -#include -#include "printfUART.h" - -module AssociationExampleM { - - uses interface Boot; - uses interface Leds; - - uses interface Timer as Timer0; - - uses interface Timer as Timer_Send; - //MAC interfaces - - uses interface MLME_START; - - uses interface MLME_GET; - uses interface MLME_SET; - - uses interface MLME_BEACON_NOTIFY; - uses interface MLME_GTS; - - uses interface MLME_ASSOCIATE; - uses interface MLME_DISASSOCIATE; - - uses interface MLME_ORPHAN; - - uses interface MLME_SYNC; - uses interface MLME_SYNC_LOSS; - - uses interface MLME_RESET; - - uses interface MLME_SCAN; - - - uses interface MCPS_DATA; - -} -implementation { - - - //number of data frames sent after association and before dissassociation - uint16_t frame_counter=0; - - //associated devices - uint16_t address_poll = 0x0003; - - neighbour_table associated_devices[4]; - - uint16_t search_associated_devices(uint32_t ext1, uint32_t ext2); - - uint8_t number_associations =0; - - PANDescriptor pan_des; - - void try_disassociation(); - - uint16_t my_short_address= 0xffff; - - uint8_t received_beacon_count=0; - uint32_t coordinator_addr[2]; - - uint8_t go_associate =0; - - event void Boot.booted() { - - printfUART_init(); - - if (TYPE_DEVICE == COORDINATOR) - { - //assign the short address of the device - my_short_address = 0x0000; - call Timer0.startOneShot(3000); - } - else - { - call Timer0.startOneShot(8000); - } - - } - - - -event void Timer0.fired() { - - uint8_t v_temp[2]; - uint32_t c_addr[2]; - - if (TYPE_DEVICE == COORDINATOR) - { - - associated_devices[0].extended1=0x00000002; - associated_devices[0].extended2=0x00000002; - associated_devices[0].assigned_short=0x0004; - - //set the MAC short address variable - v_temp[0] = (uint8_t)(my_short_address >> 8); - v_temp[1] = (uint8_t)(my_short_address ); - - call MLME_SET.request(MACSHORTADDRESS,v_temp); - - //set the MAC PANID variable - v_temp[0] = (uint8_t)(MAC_PANID >> 8); - v_temp[1] = (uint8_t)(MAC_PANID ); - - call MLME_SET.request(MACPANID,v_temp); - - //start sending beacons - call MLME_START.request(MAC_PANID, LOGICAL_CHANNEL, BEACON_ORDER, SUPERFRAME_ORDER,1,0,0,0,0); - - //call Timer_Send.startPeriodic(3000); - } - else - { - //the device will try to scan all the channels looking for a suitable PAN coordinator - //only the ACTIVE SCAN/ED SCAN and a full channel scan is implemented - //call MLME_SCAN.request(PASSIVE_SCAN,0xFFFFFFFF,7); - //call MLME_SCAN.request(ED_SCAN,0xFFFFFFFF,0x10); - - c_addr[0] = 0x00000000; - c_addr[1] = 0x00000000; - - call MLME_ASSOCIATE.request(0x15,SHORT_ADDRESS,0x1234,c_addr,0x00,0x00); - - //call Leds.redOn(); - call Timer0.stop(); - } -} - -event void Timer_Send.fired() { - - uint32_t SrcAddr[2]; - uint32_t DstAddr[2]; - - uint8_t msdu_payload[4]; - - frame_counter++; - - if (frame_counter == 5) - { - //after sending 5 data frames the device tries to dissassociate from the PAN - call Timer_Send.stop(); - try_disassociation(); - - } - else - { - if (my_short_address == 0x0000ffff) - return; - - SrcAddr[0]=0x00000000; - SrcAddr[1]=my_short_address; - - DstAddr[0]=0x00000000; - DstAddr[1]=0x00000000; - - call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SrcAddr, SHORT_ADDRESS, MAC_PANID, DstAddr, 4, msdu_payload,1,set_txoptions(1,0,0,0)); - } -} - -/*****************************************************************************************************/ -/**************************************MLME-SCAN*******************************************************/ -/*****************************************************************************************************/ -event error_t MLME_SCAN.confirm(uint8_t status,uint8_t ScanType, uint32_t UnscannedChannels, uint8_t ResultListSize, uint8_t EnergyDetectList[], SCAN_PANDescriptor PANDescriptorList[]) -{ -//the device channel scan ends with a scan confirm containing a list of the PANs (beacons received during the scan) - - int i; - uint8_t max_lqi=0; - uint8_t best_pan_index=0; - - //call Leds.redOff(); - - printfUART("MLME_SCAN.confirm %i\n", ScanType); - - if (ScanType == ORPHAN_SCAN) - { - printfUART("new scan \n", ""); - - call MLME_SCAN.request(PASSIVE_SCAN,0xFFFFFFFF,7); - return SUCCESS; - } - - - - if(ScanType == ED_SCAN) - { - for(i=0;i> 8); - v_temp[1] = my_short_address; - - //call Leds.redOn(); - call MLME_SET.request(MACSHORTADDRESS,v_temp); - - call Timer_Send.startPeriodic(3000); - - call Timer0.stop(); - } - return SUCCESS; -} -/*****************************************************************************************************/ -/**************************************MLME-DISASSOCIATE**********************************************/ -/*****************************************************************************************************/ -event error_t MLME_DISASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t DisassociateReason, bool SecurityUse, uint8_t ACLEntry) -{ - return SUCCESS; -} - -event error_t MLME_DISASSOCIATE.confirm(uint8_t status) -{ - return SUCCESS; -} -/*****************************************************************************************************/ -/*****************************************************************************************************/ -/**************** MCPS EVENTS *************************************/ -/*****************************************************************************************************/ -/*****************************************************************************************************/ - - -/*****************************************************************************************************/ -/********************* MCPS-DATA ***************************************/ -/*****************************************************************************************************/ -event error_t MCPS_DATA.confirm(uint8_t msduHandle, uint8_t status) -{ - -return SUCCESS; -} -event error_t MCPS_DATA.indication(uint16_t SrcAddrMode, uint16_t SrcPANId, uint32_t SrcAddr[2], uint16_t DstAddrMode, uint16_t DestPANId, uint32_t DstAddr[2], uint16_t msduLength,uint8_t msdu[100],uint16_t mpduLinkQuality, uint16_t SecurityUse, uint16_t ACLEntry) -{ - //call Leds.led1Toggle(); - -return SUCCESS; -} - - - -void try_disassociation() -{ - - uint32_t coordinator_addr1[2]; - - coordinator_addr1[0] = 0x00000001; - - coordinator_addr1[1] = 0x00000001; - - call MLME_DISASSOCIATE.request(coordinator_addr1,MAC_PAN_DEVICE_LEAVE,0x00); - - -return; -} - -} - diff --git a/tos/lib/net/zigbee/apps/AssociationExample/AssociationExampleP.nc b/tos/lib/net/zigbee/apps/AssociationExample/AssociationExampleP.nc new file mode 100644 index 00000000..6ba8d550 --- /dev/null +++ b/tos/lib/net/zigbee/apps/AssociationExample/AssociationExampleP.nc @@ -0,0 +1,489 @@ +/* + * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise + * @author Andre Cunha + * + */ +#include +#include "printfUART.h" + +module AssociationExampleP { + + uses interface Boot; + uses interface Leds; + + uses interface Timer as Timer0; + + uses interface Timer as Timer_Send; + //MAC interfaces + + uses interface MLME_START; + + uses interface MLME_GET; + uses interface MLME_SET; + + uses interface MLME_BEACON_NOTIFY; + uses interface MLME_GTS; + + uses interface MLME_ASSOCIATE; + uses interface MLME_DISASSOCIATE; + + uses interface MLME_ORPHAN; + + uses interface MLME_SYNC; + uses interface MLME_SYNC_LOSS; + + uses interface MLME_RESET; + + uses interface MLME_SCAN; + + + uses interface MCPS_DATA; + +} +implementation { + + + //number of data frames sent after association and before dissassociation + uint16_t frame_counter=0; + + //associated devices + uint16_t address_poll = 0x0003; + + neighbour_table associated_devices[4]; + + uint16_t search_associated_devices(uint32_t ext1, uint32_t ext2); + + uint8_t number_associations =0; + + PANDescriptor pan_des; + + void try_disassociation(); + + uint16_t my_short_address= 0xffff; + + uint8_t received_beacon_count=0; + uint32_t coordinator_addr[2]; + + uint8_t go_associate =0; + + event void Boot.booted() { + + printfUART_init(); + + if (TYPE_DEVICE == COORDINATOR) + { + //assign the short address of the device + my_short_address = 0x0000; + call Timer0.startOneShot(3000); + } + else + { + call Timer0.startOneShot(8000); + } + + } + + + +event void Timer0.fired() { + + uint8_t v_temp[2]; + uint32_t c_addr[2]; + + if (TYPE_DEVICE == COORDINATOR) + { + + associated_devices[0].extended1=0x00000002; + associated_devices[0].extended2=0x00000002; + associated_devices[0].assigned_short=0x0004; + + //set the MAC short address variable + v_temp[0] = (uint8_t)(my_short_address >> 8); + v_temp[1] = (uint8_t)(my_short_address ); + + call MLME_SET.request(MACSHORTADDRESS,v_temp); + + //set the MAC PANID variable + v_temp[0] = (uint8_t)(MAC_PANID >> 8); + v_temp[1] = (uint8_t)(MAC_PANID ); + + call MLME_SET.request(MACPANID,v_temp); + + //start sending beacons + call MLME_START.request(MAC_PANID, LOGICAL_CHANNEL, BEACON_ORDER, SUPERFRAME_ORDER,1,0,0,0,0); + + //call Timer_Send.startPeriodic(3000); + } + else + { + //the device will try to scan all the channels looking for a suitable PAN coordinator + //only the ACTIVE SCAN/ED SCAN and a full channel scan is implemented + //call MLME_SCAN.request(PASSIVE_SCAN,0xFFFFFFFF,7); + //call MLME_SCAN.request(ED_SCAN,0xFFFFFFFF,0x10); + + c_addr[0] = 0x00000000; + c_addr[1] = 0x00000000; + + call MLME_ASSOCIATE.request(0x15,SHORT_ADDRESS,0x1234,c_addr,0x00,0x00); + + //call Leds.redOn(); + call Timer0.stop(); + } +} + +event void Timer_Send.fired() { + + uint32_t SrcAddr[2]; + uint32_t DstAddr[2]; + + uint8_t msdu_payload[4]; + + frame_counter++; + + if (frame_counter == 5) + { + //after sending 5 data frames the device tries to dissassociate from the PAN + call Timer_Send.stop(); + try_disassociation(); + + } + else + { + if (my_short_address == 0x0000ffff) + return; + + SrcAddr[0]=0x00000000; + SrcAddr[1]=my_short_address; + + DstAddr[0]=0x00000000; + DstAddr[1]=0x00000000; + + call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SrcAddr, SHORT_ADDRESS, MAC_PANID, DstAddr, 4, msdu_payload,1,set_txoptions(1,0,0,0)); + } +} + +/*****************************************************************************************************/ +/**************************************MLME-SCAN*******************************************************/ +/*****************************************************************************************************/ +event error_t MLME_SCAN.confirm(uint8_t status,uint8_t ScanType, uint32_t UnscannedChannels, uint8_t ResultListSize, uint8_t EnergyDetectList[], SCAN_PANDescriptor PANDescriptorList[]) +{ +//the device channel scan ends with a scan confirm containing a list of the PANs (beacons received during the scan) + + int i; + uint8_t max_lqi=0; + uint8_t best_pan_index=0; + + //call Leds.redOff(); + + printfUART("MLME_SCAN.confirm %i\n", ScanType); + + if (ScanType == ORPHAN_SCAN) + { + printfUART("new scan \n", ""); + + call MLME_SCAN.request(PASSIVE_SCAN,0xFFFFFFFF,7); + return SUCCESS; + } + + + + if(ScanType == ED_SCAN) + { + for(i=0;i> 8); + v_temp[1] = my_short_address; + + //call Leds.redOn(); + call MLME_SET.request(MACSHORTADDRESS,v_temp); + + call Timer_Send.startPeriodic(3000); + + call Timer0.stop(); + } + return SUCCESS; +} +/*****************************************************************************************************/ +/**************************************MLME-DISASSOCIATE**********************************************/ +/*****************************************************************************************************/ +event error_t MLME_DISASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t DisassociateReason, bool SecurityUse, uint8_t ACLEntry) +{ + return SUCCESS; +} + +event error_t MLME_DISASSOCIATE.confirm(uint8_t status) +{ + return SUCCESS; +} +/*****************************************************************************************************/ +/*****************************************************************************************************/ +/**************** MCPS EVENTS *************************************/ +/*****************************************************************************************************/ +/*****************************************************************************************************/ + + +/*****************************************************************************************************/ +/********************* MCPS-DATA ***************************************/ +/*****************************************************************************************************/ +event error_t MCPS_DATA.confirm(uint8_t msduHandle, uint8_t status) +{ + +return SUCCESS; +} +event error_t MCPS_DATA.indication(uint16_t SrcAddrMode, uint16_t SrcPANId, uint32_t SrcAddr[2], uint16_t DstAddrMode, uint16_t DestPANId, uint32_t DstAddr[2], uint16_t msduLength,uint8_t msdu[100],uint16_t mpduLinkQuality, uint16_t SecurityUse, uint16_t ACLEntry) +{ + //call Leds.led1Toggle(); + +return SUCCESS; +} + + + +void try_disassociation() +{ + + uint32_t coordinator_addr1[2]; + + coordinator_addr1[0] = 0x00000001; + + coordinator_addr1[1] = 0x00000001; + + call MLME_DISASSOCIATE.request(coordinator_addr1,MAC_PAN_DEVICE_LEAVE,0x00); + + +return; +} + +} + diff --git a/tos/lib/net/zigbee/apps/AssociationExample/Makefile b/tos/lib/net/zigbee/apps/AssociationExample/Makefile index 61dcca8f..3d1ca3b4 100644 --- a/tos/lib/net/zigbee/apps/AssociationExample/Makefile +++ b/tos/lib/net/zigbee/apps/AssociationExample/Makefile @@ -1,4 +1,4 @@ -COMPONENT=AssociationExample +COMPONENT=AssociationExampleC PFLAGS += -I$(TOSROOT)/tos/lib/net/zigbee/ieee802154/includes \ -I$(TOSROOT)/tos/lib/net/zigbee/ieee802154/mac \ diff --git a/tos/lib/net/zigbee/apps/DataSendExample/DataSendExample.nc b/tos/lib/net/zigbee/apps/DataSendExample/DataSendExample.nc deleted file mode 100644 index 1463b31c..00000000 --- a/tos/lib/net/zigbee/apps/DataSendExample/DataSendExample.nc +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise - * @author Andre Cunha - */ -#include - -#include "datasendexample.h" -#include "phy_const.h" -#include "phy_enumerations.h" -#include "mac_const.h" -#include "mac_enumerations.h" -#include "mac_func.h" - -configuration DataSendExample { -} - -implementation -{ - components MainC; - components LedsC; - components DataSendExampleM; - - DataSendExampleM.Boot -> MainC; - - components Mac; - - DataSendExampleM.Leds -> LedsC; - - components new TimerMilliC() as Timer0; - DataSendExampleM.Timer0 -> Timer0; - - components new TimerMilliC() as Timer_Send; - DataSendExampleM.Timer_Send ->Timer_Send; - - - //MAC interfaces - - DataSendExampleM.MLME_START -> Mac.MLME_START; - - DataSendExampleM.MLME_GET ->Mac.MLME_GET; - DataSendExampleM.MLME_SET ->Mac.MLME_SET; - - DataSendExampleM.MLME_BEACON_NOTIFY ->Mac.MLME_BEACON_NOTIFY; - DataSendExampleM.MLME_GTS -> Mac.MLME_GTS; - - DataSendExampleM.MLME_ASSOCIATE->Mac.MLME_ASSOCIATE; - DataSendExampleM.MLME_DISASSOCIATE->Mac.MLME_DISASSOCIATE; - - DataSendExampleM.MLME_ORPHAN->Mac.MLME_ORPHAN; - DataSendExampleM.MLME_SYNC->Mac.MLME_SYNC; - DataSendExampleM.MLME_SYNC_LOSS->Mac.MLME_SYNC_LOSS; - DataSendExampleM.MLME_RESET->Mac.MLME_RESET; - - DataSendExampleM.MLME_SCAN->Mac.MLME_SCAN; - - DataSendExampleM.MCPS_DATA->Mac.MCPS_DATA; - - -} - diff --git a/tos/lib/net/zigbee/apps/DataSendExample/DataSendExampleC.nc b/tos/lib/net/zigbee/apps/DataSendExample/DataSendExampleC.nc new file mode 100644 index 00000000..d4ee637f --- /dev/null +++ b/tos/lib/net/zigbee/apps/DataSendExample/DataSendExampleC.nc @@ -0,0 +1,60 @@ +/** + * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise + * @author Andre Cunha + */ +#include + +#include "datasendexample.h" +#include "phy_const.h" +#include "phy_enumerations.h" +#include "mac_const.h" +#include "mac_enumerations.h" +#include "mac_func.h" + +configuration DataSendExampleC { +} + +implementation +{ + components MainC; + components LedsC; + components DataSendExampleP; + + DataSendExampleP.Boot -> MainC; + + components MacC; + + DataSendExampleP.Leds -> LedsC; + + components new TimerMilliC() as Timer0; + DataSendExampleP.Timer0 -> Timer0; + + components new TimerMilliC() as Timer_Send; + DataSendExampleP.Timer_Send ->Timer_Send; + + + //MAC interfaces + + DataSendExampleP.MLME_START -> MacC.MLME_START; + + DataSendExampleP.MLME_GET ->MacC.MLME_GET; + DataSendExampleP.MLME_SET ->MacC.MLME_SET; + + DataSendExampleP.MLME_BEACON_NOTIFY ->MacC.MLME_BEACON_NOTIFY; + DataSendExampleP.MLME_GTS -> MacC.MLME_GTS; + + DataSendExampleP.MLME_ASSOCIATE->MacC.MLME_ASSOCIATE; + DataSendExampleP.MLME_DISASSOCIATE->MacC.MLME_DISASSOCIATE; + + DataSendExampleP.MLME_ORPHAN->MacC.MLME_ORPHAN; + DataSendExampleP.MLME_SYNC->MacC.MLME_SYNC; + DataSendExampleP.MLME_SYNC_LOSS->MacC.MLME_SYNC_LOSS; + DataSendExampleP.MLME_RESET->MacC.MLME_RESET; + + DataSendExampleP.MLME_SCAN->MacC.MLME_SCAN; + + DataSendExampleP.MCPS_DATA->MacC.MCPS_DATA; + + +} + diff --git a/tos/lib/net/zigbee/apps/DataSendExample/DataSendExampleM.nc b/tos/lib/net/zigbee/apps/DataSendExample/DataSendExampleM.nc deleted file mode 100644 index fd8760b8..00000000 --- a/tos/lib/net/zigbee/apps/DataSendExample/DataSendExampleM.nc +++ /dev/null @@ -1,315 +0,0 @@ -/* - * - * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise - * @author Andre Cunha - * - */ - -#include -#include "printfUART.h" - -module DataSendExampleM { - - uses interface Boot; - uses interface Leds; - - uses interface Timer as Timer0; - - uses interface Timer as Timer_Send; - //MAC interfaces - - uses interface MLME_START; - - uses interface MLME_GET; - uses interface MLME_SET; - - uses interface MLME_BEACON_NOTIFY; - uses interface MLME_GTS; - - uses interface MLME_ASSOCIATE; - uses interface MLME_DISASSOCIATE; - - uses interface MLME_ORPHAN; - - uses interface MLME_SYNC; - uses interface MLME_SYNC_LOSS; - - uses interface MLME_RESET; - - uses interface MLME_SCAN; - - uses interface MCPS_DATA; - -} -implementation { - - uint8_t beacon_present=0; - uint8_t on_sync=0; - - PANDescriptor pan_des; - - uint32_t my_short_address=0x00000000; - uint32_t my_pan_id=0x00001234; - - uint32_t DestinationMote[2]; - - - event void Boot.booted() { - - printfUART_init(); - - printfUART("i_am_pan: %i\n", TYPE_DEVICE); - - DestinationMote[0]=0x00000000; - DestinationMote[1]=0x00000002; - - if (TYPE_DEVICE == COORDINATOR) - { - my_short_address = 0x0000; - call Timer0.startOneShot(3000); - } - else - { - call Timer0.startOneShot(8000); - } - - } - - - event void Timer0.fired() { - - uint8_t v_temp[2]; - - - if (TYPE_DEVICE == END_DEVICE) - { - - my_short_address = TOS_NODE_ID; - - //set the MAC short address variable - v_temp[0] = (uint8_t)(my_short_address >> 8); - v_temp[1] = (uint8_t)(my_short_address ); - - call MLME_SET.request(MACSHORTADDRESS,v_temp); - - //set the MAC PANID variable - v_temp[0] = (uint8_t)(MAC_PANID >> 8); - v_temp[1] = (uint8_t)(MAC_PANID ); - - call MLME_SET.request(MACPANID,v_temp); - - call Timer_Send.startPeriodic(3000); - - } - else - { - //set the MAC short address variable - v_temp[0] = (uint8_t)(my_short_address >> 8); - v_temp[1] = (uint8_t)(my_short_address ); - - call MLME_SET.request(MACSHORTADDRESS,v_temp); - - //set the MAC PANID variable - v_temp[0] = (uint8_t)(MAC_PANID >> 8); - v_temp[1] = (uint8_t)(MAC_PANID ); - - call MLME_SET.request(MACPANID,v_temp); - - //start sending beacons - call MLME_START.request(MAC_PANID, LOGICAL_CHANNEL, BEACON_ORDER, SUPERFRAME_ORDER,1,0,0,0,0); - - //call Timer_send.start(TIMER_REPEAT,8000); - } - - - - - } - -event void Timer_Send.fired() { - - - uint32_t SrcAddr[2]; - - uint8_t msdu_payload[4]; - - SrcAddr[0]=0x00000000; - SrcAddr[1]=TOS_NODE_ID; - - //DestinationMote[0]=0x00000000; - //DestinationMote[1]=0x0000FFFF; - - - - if(TYPE_DEVICE == COORDINATOR) - { - - SrcAddr[0]=0x00000000; - SrcAddr[1]=TOS_NODE_ID; - - if (DestinationMote[1]==0x00000002) - { - DestinationMote[1]=0x00000003; - }else{ - DestinationMote[1]=0x00000002; - } - //printfUART("send to: %i\n", DestinationMote[1]); - //call Leds.greenToggle(); - //set_txoptions(ack, gts, indirect_transmission, security) - call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SrcAddr, SHORT_ADDRESS, MAC_PANID, DestinationMote, 4, msdu_payload,1,set_txoptions(1,0,0,0)); - } - else - { - - DestinationMote[0]=0x00000000; - DestinationMote[1]=0x00000000; - //set_txoptions(ack, gts, indirect_transmission, security) - call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SrcAddr, SHORT_ADDRESS, MAC_PANID, DestinationMote, 4, msdu_payload,1,set_txoptions(1,0,0,0)); - } - - - } -/*****************************************************************************************************/ -/**************************************MLME-SCAN*******************************************************/ -/*****************************************************************************************************/ -event error_t MLME_SCAN.confirm(uint8_t status,uint8_t ScanType, uint32_t UnscannedChannels, uint8_t ResultListSize, uint8_t EnergyDetectList[], SCAN_PANDescriptor PANDescriptorList[]) -{ - - - return SUCCESS; -} - -/*****************************************************************************************************/ -/**************************************MLME-ORPHAN*******************************************************/ -/*****************************************************************************************************/ - -event error_t MLME_ORPHAN.indication(uint32_t OrphanAddress[1], uint8_t SecurityUse, uint8_t ACLEntry) -{ - -return SUCCESS; -} - -/*****************************************************************************************************/ -/**************************************MLME-RESET*******************************************************/ -/*****************************************************************************************************/ -event error_t MLME_RESET.confirm(uint8_t status) -{ - -return SUCCESS; -} - - - /*****************************************************************************************************/ -/**************************************MLME-SYNC-LOSS*******************************************************/ -/*****************************************************************************************************/ -event error_t MLME_SYNC_LOSS.indication(uint8_t LossReason) -{ - -return SUCCESS; -} - - - /*****************************************************************************************************/ -/**************************************MLME-GTS*******************************************************/ -/*****************************************************************************************************/ - -event error_t MLME_GTS.confirm(uint8_t GTSCharacteristics, uint8_t status) -{ - - return SUCCESS; -} - -event error_t MLME_GTS.indication(uint16_t DevAddress, uint8_t GTSCharacteristics, bool SecurityUse, uint8_t ACLEntry) -{ - return SUCCESS; -} - /*****************************************************************************************************/ -/**************************************MLME-BEACON NOTIFY*********************************************/ -/*****************************************************************************************************/ - -event error_t MLME_BEACON_NOTIFY.indication(uint8_t BSN,PANDescriptor pan_descriptor, uint8_t PenAddrSpec, uint8_t AddrList, uint8_t sduLength, uint8_t sdu[]) -{ - - return SUCCESS; -} -/*****************************************************************************************************/ -/**************************************MLME-START*****************************************************/ -/*****************************************************************************************************/ - event error_t MLME_START.confirm(uint8_t status) - { - - - return SUCCESS; - } - /*****************************************************************************************************/ -/********************** MLME-SET ******************************************/ -/*****************************************************************************************************/ - - event error_t MLME_SET.confirm(uint8_t status,uint8_t PIBAttribute) - { - - - return SUCCESS; - } - /*****************************************************************************************************/ -/************************* MLME-GET ******************************************/ -/*****************************************************************************************************/ - event error_t MLME_GET.confirm(uint8_t status,uint8_t PIBAttribute, uint8_t PIBAttributeValue[]) - { - - - return SUCCESS; - } - - - /*****************************************************************************************************/ -/**************************************MLME-ASSOCIATE*************************************************/ -/*****************************************************************************************************/ -event error_t MLME_ASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t CapabilityInformation, bool SecurityUse, uint8_t ACLEntry) -{ - - return SUCCESS; -} - -event error_t MLME_ASSOCIATE.confirm(uint16_t AssocShortAddress, uint8_t status) -{ - - return SUCCESS; -} - /*****************************************************************************************************/ -/**************************************MLME-DISASSOCIATE**********************************************/ -/*****************************************************************************************************/ -event error_t MLME_DISASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t DisassociateReason, bool SecurityUse, uint8_t ACLEntry) -{ - return SUCCESS; -} - -event error_t MLME_DISASSOCIATE.confirm(uint8_t status) -{ - return SUCCESS; -} - /*****************************************************************************************************/ -/*****************************************************************************************************/ -/**************** MCPS EVENTS *************************************/ -/*****************************************************************************************************/ -/*****************************************************************************************************/ - - -/*****************************************************************************************************/ -/********************* MCPS-DATA ***************************************/ -/*****************************************************************************************************/ -event error_t MCPS_DATA.confirm(uint8_t msduHandle, uint8_t status) -{ - -return SUCCESS; -} -event error_t MCPS_DATA.indication(uint16_t SrcAddrMode, uint16_t SrcPANId, uint32_t SrcAddr[2], uint16_t DstAddrMode, uint16_t DestPANId, uint32_t DstAddr[2], uint16_t msduLength,uint8_t msdu[100],uint16_t mpduLinkQuality, uint16_t SecurityUse, uint16_t ACLEntry) -{ - //call Leds.led1Toggle(); - -return SUCCESS; -} - - -} - diff --git a/tos/lib/net/zigbee/apps/DataSendExample/DataSendExampleP.nc b/tos/lib/net/zigbee/apps/DataSendExample/DataSendExampleP.nc new file mode 100644 index 00000000..f9c38353 --- /dev/null +++ b/tos/lib/net/zigbee/apps/DataSendExample/DataSendExampleP.nc @@ -0,0 +1,315 @@ +/* + * + * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise + * @author Andre Cunha + * + */ + +#include +#include "printfUART.h" + +module DataSendExampleP { + + uses interface Boot; + uses interface Leds; + + uses interface Timer as Timer0; + + uses interface Timer as Timer_Send; + //MAC interfaces + + uses interface MLME_START; + + uses interface MLME_GET; + uses interface MLME_SET; + + uses interface MLME_BEACON_NOTIFY; + uses interface MLME_GTS; + + uses interface MLME_ASSOCIATE; + uses interface MLME_DISASSOCIATE; + + uses interface MLME_ORPHAN; + + uses interface MLME_SYNC; + uses interface MLME_SYNC_LOSS; + + uses interface MLME_RESET; + + uses interface MLME_SCAN; + + uses interface MCPS_DATA; + +} +implementation { + + uint8_t beacon_present=0; + uint8_t on_sync=0; + + PANDescriptor pan_des; + + uint32_t my_short_address=0x00000000; + uint32_t my_pan_id=0x00001234; + + uint32_t DestinationMote[2]; + + + event void Boot.booted() { + + printfUART_init(); + + printfUART("i_am_pan: %i\n", TYPE_DEVICE); + + DestinationMote[0]=0x00000000; + DestinationMote[1]=0x00000002; + + if (TYPE_DEVICE == COORDINATOR) + { + my_short_address = 0x0000; + call Timer0.startOneShot(3000); + } + else + { + call Timer0.startOneShot(8000); + } + + } + + + event void Timer0.fired() { + + uint8_t v_temp[2]; + + + if (TYPE_DEVICE == END_DEVICE) + { + + my_short_address = TOS_NODE_ID; + + //set the MAC short address variable + v_temp[0] = (uint8_t)(my_short_address >> 8); + v_temp[1] = (uint8_t)(my_short_address ); + + call MLME_SET.request(MACSHORTADDRESS,v_temp); + + //set the MAC PANID variable + v_temp[0] = (uint8_t)(MAC_PANID >> 8); + v_temp[1] = (uint8_t)(MAC_PANID ); + + call MLME_SET.request(MACPANID,v_temp); + + call Timer_Send.startPeriodic(3000); + + } + else + { + //set the MAC short address variable + v_temp[0] = (uint8_t)(my_short_address >> 8); + v_temp[1] = (uint8_t)(my_short_address ); + + call MLME_SET.request(MACSHORTADDRESS,v_temp); + + //set the MAC PANID variable + v_temp[0] = (uint8_t)(MAC_PANID >> 8); + v_temp[1] = (uint8_t)(MAC_PANID ); + + call MLME_SET.request(MACPANID,v_temp); + + //start sending beacons + call MLME_START.request(MAC_PANID, LOGICAL_CHANNEL, BEACON_ORDER, SUPERFRAME_ORDER,1,0,0,0,0); + + //call Timer_send.start(TIMER_REPEAT,8000); + } + + + + + } + +event void Timer_Send.fired() { + + + uint32_t SrcAddr[2]; + + uint8_t msdu_payload[4]; + + SrcAddr[0]=0x00000000; + SrcAddr[1]=TOS_NODE_ID; + + //DestinationMote[0]=0x00000000; + //DestinationMote[1]=0x0000FFFF; + + + + if(TYPE_DEVICE == COORDINATOR) + { + + SrcAddr[0]=0x00000000; + SrcAddr[1]=TOS_NODE_ID; + + if (DestinationMote[1]==0x00000002) + { + DestinationMote[1]=0x00000003; + }else{ + DestinationMote[1]=0x00000002; + } + //printfUART("send to: %i\n", DestinationMote[1]); + //call Leds.greenToggle(); + //set_txoptions(ack, gts, indirect_transmission, security) + call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SrcAddr, SHORT_ADDRESS, MAC_PANID, DestinationMote, 4, msdu_payload,1,set_txoptions(1,0,0,0)); + } + else + { + + DestinationMote[0]=0x00000000; + DestinationMote[1]=0x00000000; + //set_txoptions(ack, gts, indirect_transmission, security) + call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SrcAddr, SHORT_ADDRESS, MAC_PANID, DestinationMote, 4, msdu_payload,1,set_txoptions(1,0,0,0)); + } + + + } +/*****************************************************************************************************/ +/**************************************MLME-SCAN*******************************************************/ +/*****************************************************************************************************/ +event error_t MLME_SCAN.confirm(uint8_t status,uint8_t ScanType, uint32_t UnscannedChannels, uint8_t ResultListSize, uint8_t EnergyDetectList[], SCAN_PANDescriptor PANDescriptorList[]) +{ + + + return SUCCESS; +} + +/*****************************************************************************************************/ +/**************************************MLME-ORPHAN*******************************************************/ +/*****************************************************************************************************/ + +event error_t MLME_ORPHAN.indication(uint32_t OrphanAddress[1], uint8_t SecurityUse, uint8_t ACLEntry) +{ + +return SUCCESS; +} + +/*****************************************************************************************************/ +/**************************************MLME-RESET*******************************************************/ +/*****************************************************************************************************/ +event error_t MLME_RESET.confirm(uint8_t status) +{ + +return SUCCESS; +} + + + /*****************************************************************************************************/ +/**************************************MLME-SYNC-LOSS*******************************************************/ +/*****************************************************************************************************/ +event error_t MLME_SYNC_LOSS.indication(uint8_t LossReason) +{ + +return SUCCESS; +} + + + /*****************************************************************************************************/ +/**************************************MLME-GTS*******************************************************/ +/*****************************************************************************************************/ + +event error_t MLME_GTS.confirm(uint8_t GTSCharacteristics, uint8_t status) +{ + + return SUCCESS; +} + +event error_t MLME_GTS.indication(uint16_t DevAddress, uint8_t GTSCharacteristics, bool SecurityUse, uint8_t ACLEntry) +{ + return SUCCESS; +} + /*****************************************************************************************************/ +/**************************************MLME-BEACON NOTIFY*********************************************/ +/*****************************************************************************************************/ + +event error_t MLME_BEACON_NOTIFY.indication(uint8_t BSN,PANDescriptor pan_descriptor, uint8_t PenAddrSpec, uint8_t AddrList, uint8_t sduLength, uint8_t sdu[]) +{ + + return SUCCESS; +} +/*****************************************************************************************************/ +/**************************************MLME-START*****************************************************/ +/*****************************************************************************************************/ + event error_t MLME_START.confirm(uint8_t status) + { + + + return SUCCESS; + } + /*****************************************************************************************************/ +/********************** MLME-SET ******************************************/ +/*****************************************************************************************************/ + + event error_t MLME_SET.confirm(uint8_t status,uint8_t PIBAttribute) + { + + + return SUCCESS; + } + /*****************************************************************************************************/ +/************************* MLME-GET ******************************************/ +/*****************************************************************************************************/ + event error_t MLME_GET.confirm(uint8_t status,uint8_t PIBAttribute, uint8_t PIBAttributeValue[]) + { + + + return SUCCESS; + } + + + /*****************************************************************************************************/ +/**************************************MLME-ASSOCIATE*************************************************/ +/*****************************************************************************************************/ +event error_t MLME_ASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t CapabilityInformation, bool SecurityUse, uint8_t ACLEntry) +{ + + return SUCCESS; +} + +event error_t MLME_ASSOCIATE.confirm(uint16_t AssocShortAddress, uint8_t status) +{ + + return SUCCESS; +} + /*****************************************************************************************************/ +/**************************************MLME-DISASSOCIATE**********************************************/ +/*****************************************************************************************************/ +event error_t MLME_DISASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t DisassociateReason, bool SecurityUse, uint8_t ACLEntry) +{ + return SUCCESS; +} + +event error_t MLME_DISASSOCIATE.confirm(uint8_t status) +{ + return SUCCESS; +} + /*****************************************************************************************************/ +/*****************************************************************************************************/ +/**************** MCPS EVENTS *************************************/ +/*****************************************************************************************************/ +/*****************************************************************************************************/ + + +/*****************************************************************************************************/ +/********************* MCPS-DATA ***************************************/ +/*****************************************************************************************************/ +event error_t MCPS_DATA.confirm(uint8_t msduHandle, uint8_t status) +{ + +return SUCCESS; +} +event error_t MCPS_DATA.indication(uint16_t SrcAddrMode, uint16_t SrcPANId, uint32_t SrcAddr[2], uint16_t DstAddrMode, uint16_t DestPANId, uint32_t DstAddr[2], uint16_t msduLength,uint8_t msdu[100],uint16_t mpduLinkQuality, uint16_t SecurityUse, uint16_t ACLEntry) +{ + //call Leds.led1Toggle(); + +return SUCCESS; +} + + +} + diff --git a/tos/lib/net/zigbee/apps/DataSendExample/Makefile b/tos/lib/net/zigbee/apps/DataSendExample/Makefile index f9e6b4b5..24d32aba 100644 --- a/tos/lib/net/zigbee/apps/DataSendExample/Makefile +++ b/tos/lib/net/zigbee/apps/DataSendExample/Makefile @@ -1,4 +1,4 @@ -COMPONENT=DataSendExample +COMPONENT=DataSendExampleC PFLAGS += -I$(TOSROOT)/tos/lib/net/zigbee/ieee802154/includes \ -I$(TOSROOT)/tos/lib/net/zigbee/ieee802154/mac \ diff --git a/tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExample.nc b/tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExample.nc deleted file mode 100644 index fda840ee..00000000 --- a/tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExample.nc +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise - * @author Andre Cunha - */ -#include - -#include "gtsmanagementexample.h" -#include "phy_const.h" -#include "phy_enumerations.h" -#include "mac_const.h" -#include "mac_enumerations.h" -#include "mac_func.h" - - -configuration GTSManagementExample { -} -implementation { - - components MainC; - components LedsC; - components GTSManagementExampleM; - - GTSManagementExampleM.Boot -> MainC; - - components Mac; - - GTSManagementExampleM.Leds -> LedsC; - - components new TimerMilliC() as Timer0; - GTSManagementExampleM.Timer0 -> Timer0; - - components new TimerMilliC() as Timer_Send; - GTSManagementExampleM.Timer_Send ->Timer_Send; - - - //MAC interfaces - - GTSManagementExampleM.MLME_START -> Mac.MLME_START; - - GTSManagementExampleM.MLME_GET ->Mac.MLME_GET; - GTSManagementExampleM.MLME_SET ->Mac.MLME_SET; - - GTSManagementExampleM.MLME_BEACON_NOTIFY ->Mac.MLME_BEACON_NOTIFY; - GTSManagementExampleM.MLME_GTS -> Mac.MLME_GTS; - - GTSManagementExampleM.MLME_ASSOCIATE->Mac.MLME_ASSOCIATE; - GTSManagementExampleM.MLME_DISASSOCIATE->Mac.MLME_DISASSOCIATE; - - GTSManagementExampleM.MLME_ORPHAN->Mac.MLME_ORPHAN; - GTSManagementExampleM.MLME_SYNC->Mac.MLME_SYNC; - GTSManagementExampleM.MLME_SYNC_LOSS->Mac.MLME_SYNC_LOSS; - GTSManagementExampleM.MLME_RESET->Mac.MLME_RESET; - - GTSManagementExampleM.MLME_SCAN->Mac.MLME_SCAN; - - - GTSManagementExampleM.MCPS_DATA->Mac.MCPS_DATA; - - -} - diff --git a/tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExampleC.nc b/tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExampleC.nc new file mode 100644 index 00000000..dd5a929f --- /dev/null +++ b/tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExampleC.nc @@ -0,0 +1,61 @@ +/** + * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise + * @author Andre Cunha + */ +#include + +#include "gtsmanagementexample.h" +#include "phy_const.h" +#include "phy_enumerations.h" +#include "mac_const.h" +#include "mac_enumerations.h" +#include "mac_func.h" + + +configuration GTSManagementExampleC { +} +implementation { + + components MainC; + components LedsC; + components GTSManagementExampleP; + + GTSManagementExampleP.Boot -> MainC; + + components MacC; + + GTSManagementExampleP.Leds -> LedsC; + + components new TimerMilliC() as Timer0; + GTSManagementExampleP.Timer0 -> Timer0; + + components new TimerMilliC() as Timer_Send; + GTSManagementExampleP.Timer_Send ->Timer_Send; + + + //MAC interfaces + + GTSManagementExampleP.MLME_START -> MacC.MLME_START; + + GTSManagementExampleP.MLME_GET ->MacC.MLME_GET; + GTSManagementExampleP.MLME_SET ->MacC.MLME_SET; + + GTSManagementExampleP.MLME_BEACON_NOTIFY ->MacC.MLME_BEACON_NOTIFY; + GTSManagementExampleP.MLME_GTS -> MacC.MLME_GTS; + + GTSManagementExampleP.MLME_ASSOCIATE->MacC.MLME_ASSOCIATE; + GTSManagementExampleP.MLME_DISASSOCIATE->MacC.MLME_DISASSOCIATE; + + GTSManagementExampleP.MLME_ORPHAN->MacC.MLME_ORPHAN; + GTSManagementExampleP.MLME_SYNC->MacC.MLME_SYNC; + GTSManagementExampleP.MLME_SYNC_LOSS->MacC.MLME_SYNC_LOSS; + GTSManagementExampleP.MLME_RESET->MacC.MLME_RESET; + + GTSManagementExampleP.MLME_SCAN->MacC.MLME_SCAN; + + + GTSManagementExampleP.MCPS_DATA->MacC.MCPS_DATA; + + +} + diff --git a/tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExampleM.nc b/tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExampleM.nc deleted file mode 100644 index 5ba55566..00000000 --- a/tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExampleM.nc +++ /dev/null @@ -1,339 +0,0 @@ -/* - * - * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise - * @author Andre Cunha - * - */ -/* - * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise - * @author Andre Cunha - * - */ -#include -#include "printfUART.h" - -module GTSManagementExampleM { - - uses interface Boot; - uses interface Leds; - - uses interface Timer as Timer0; - - uses interface Timer as Timer_Send; - //MAC interfaces - - uses interface MLME_START; - - uses interface MLME_GET; - uses interface MLME_SET; - - uses interface MLME_BEACON_NOTIFY; - uses interface MLME_GTS; - - uses interface MLME_ASSOCIATE; - uses interface MLME_DISASSOCIATE; - - uses interface MLME_ORPHAN; - - uses interface MLME_SYNC; - uses interface MLME_SYNC_LOSS; - - uses interface MLME_RESET; - - uses interface MLME_SCAN; - - uses interface MCPS_DATA; - -} -implementation { - - - uint8_t beacon_present=0; - uint8_t on_sync=0; - uint8_t gts_allocated=0; - - uint8_t gts_superframe_count=0; - - PANDescriptor pan_des; - - uint32_t my_short_address=0x00000000; - uint32_t my_pan_id=0x00000001; - - - - event void Boot.booted() { - - printfUART_init(); - - if (TYPE_DEVICE == COORDINATOR) - { - //assign the short address of the device - my_short_address = 0x0000; - call Timer0.startOneShot(5000); - } - else - { - call Timer0.startOneShot(8000); - } - - } - - - - event void Timer0.fired() { - - uint8_t v_temp[2]; - - - - if (TYPE_DEVICE == COORDINATOR) - { - - //set the MAC short address variable - v_temp[0] = (uint8_t)(my_short_address >> 8); - v_temp[1] = (uint8_t)(my_short_address ); - - call MLME_SET.request(MACSHORTADDRESS,v_temp); - - //set the MAC PANID variable - v_temp[0] = (uint8_t)(MAC_PANID >> 8); - v_temp[1] = (uint8_t)(MAC_PANID ); - - call MLME_SET.request(MACPANID,v_temp); - - //start sending beacons - call MLME_START.request(MAC_PANID, LOGICAL_CHANNEL, BEACON_ORDER, SUPERFRAME_ORDER,1,0,0,0,0); - - //call Timer_Send.startPeriodic(3000); - } - else - { - my_short_address = TOS_NODE_ID; - v_temp[0] = (uint8_t)(my_short_address >> 8); - v_temp[1] = (uint8_t)(my_short_address ); - - call MLME_SET.request(MACSHORTADDRESS,v_temp); - - //call Leds.greenOn(); - gts_superframe_count=0; - - - printfUART("GTS req: %i\n", TYPE_DEVICE); - - - //allocate a transmission GTS - enables a GTS time slot allocation for the device transmission to the PAN Coordinator - call MLME_GTS.request(set_gts_characteristics(1, GTS_TX_ONLY,1),0x00); - - //allocate a transmission GTS - enables a GTS time slot allocation for the PAN coordinator transmission to the device - //call MLME_GTS.request(set_gts_characteristics(1, GTS_RX_ONLY,1),0x00); - - - //enable the transmission of the device to the PAN coordinator in the allocated transmit GTS - call Timer_Send.startPeriodic(1000); - - } - - } - -event void Timer_Send.fired() { - - - uint32_t SrcAddr[2]; - uint32_t DstAddr[2]; - uint8_t msdu_payload[4]; - - if (TYPE_DEVICE == COORDINATOR) - { - SrcAddr[0]=0x00000000; - SrcAddr[1]=TOS_NODE_ID; - - DstAddr[0]=0x00000000; - DstAddr[1]=0x00000002; - - call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SrcAddr, SHORT_ADDRESS, MAC_PANID, DstAddr, 4, msdu_payload,1,set_txoptions(1,1,0,0)); - } - else - { - call Leds.led1Toggle(); - - - SrcAddr[0]=0x00000000; - SrcAddr[1]=TOS_NODE_ID; - - DstAddr[0]=0x00000000; - DstAddr[1]=0x00000000; - - call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SrcAddr, SHORT_ADDRESS, MAC_PANID, DstAddr, 4, msdu_payload,1,set_txoptions(1,1,0,0)); - } - -} - - -/*****************************************************************************************************/ -/**************************************MLME-SCAN*******************************************************/ -/*****************************************************************************************************/ -event error_t MLME_SCAN.confirm(uint8_t status,uint8_t ScanType, uint32_t UnscannedChannels, uint8_t ResultListSize, uint8_t EnergyDetectList[], SCAN_PANDescriptor PANDescriptorList[]) -{ - - return SUCCESS; -} - -/*****************************************************************************************************/ -/**************************************MLME-ORPHAN****************************************************/ -/*****************************************************************************************************/ -event error_t MLME_ORPHAN.indication(uint32_t OrphanAddress[1], uint8_t SecurityUse, uint8_t ACLEntry) -{ - - return SUCCESS; -} -/*****************************************************************************************************/ -/**************************************MLME-RESET*****************************************************/ -/*****************************************************************************************************/ -event error_t MLME_RESET.confirm(uint8_t status) -{ - - - - return SUCCESS; -} -/*****************************************************************************************************/ -/**************************************MLME-SYNC-LOSS*************************************************/ -/*****************************************************************************************************/ -event error_t MLME_SYNC_LOSS.indication(uint8_t LossReason) -{ - - return SUCCESS; -} - -/*****************************************************************************************************/ -/**************************************MLME-GTS*******************************************************/ -/*****************************************************************************************************/ - -event error_t MLME_GTS.confirm(uint8_t GTSCharacteristics, uint8_t status) -{ - switch(status) - { - case MAC_SUCCESS: gts_allocated=1; - call Leds.led1Toggle(); - break; - - case MAC_DENIED: gts_allocated=0; - break; - - case MAC_NO_SHORT_ADDRESS: gts_allocated=0; - break; - - case MAC_CHANNEL_ACCESS_FAILURE: gts_allocated=0; - break; - - case MAC_NO_ACK: gts_allocated=0;break; - - case MAC_NO_DATA: gts_allocated=0;break; - - - default: break; - - } - - return SUCCESS; -} - -event error_t MLME_GTS.indication(uint16_t DevAddress, uint8_t GTSCharacteristics, bool SecurityUse, uint8_t ACLEntry) -{ - return SUCCESS; -} - /*****************************************************************************************************/ -/**************************************MLME-BEACON NOTIFY*********************************************/ -/*****************************************************************************************************/ - -event error_t MLME_BEACON_NOTIFY.indication(uint8_t BSN,PANDescriptor pan_descriptor, uint8_t PenAddrSpec, uint8_t AddrList, uint8_t sduLength, uint8_t sdu[]) -{ - gts_superframe_count++; - if (gts_superframe_count==30) - { - //call Leds.greenOff(); - call MLME_GTS.request(set_gts_characteristics(1, GTS_TX_ONLY,0),0x00); - } - return SUCCESS; -} -/*****************************************************************************************************/ -/**************************************MLME-START*****************************************************/ -/*****************************************************************************************************/ - event error_t MLME_START.confirm(uint8_t status) - { - - - return SUCCESS; - } - /*****************************************************************************************************/ -/********************** MLME-SET ******************************************/ -/*****************************************************************************************************/ - - event error_t MLME_SET.confirm(uint8_t status,uint8_t PIBAttribute) - { - - - return SUCCESS; - } - /*****************************************************************************************************/ -/************************* MLME-GET ******************************************/ -/*****************************************************************************************************/ - event error_t MLME_GET.confirm(uint8_t status,uint8_t PIBAttribute, uint8_t PIBAttributeValue[]) - { - - - return SUCCESS; - } - - - /*****************************************************************************************************/ -/**************************************MLME-ASSOCIATE*************************************************/ -/*****************************************************************************************************/ -event error_t MLME_ASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t CapabilityInformation, bool SecurityUse, uint8_t ACLEntry) -{ - - return SUCCESS; -} - -event error_t MLME_ASSOCIATE.confirm(uint16_t AssocShortAddress, uint8_t status) -{ - - return SUCCESS; -} - /*****************************************************************************************************/ -/**************************************MLME-DISASSOCIATE**********************************************/ -/*****************************************************************************************************/ -event error_t MLME_DISASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t DisassociateReason, bool SecurityUse, uint8_t ACLEntry) -{ - return SUCCESS; -} - -event error_t MLME_DISASSOCIATE.confirm(uint8_t status) -{ - return SUCCESS; -} - /*****************************************************************************************************/ -/*****************************************************************************************************/ -/**************** MCPS EVENTS *************************************/ -/*****************************************************************************************************/ -/*****************************************************************************************************/ - - -/*****************************************************************************************************/ -/********************* MCPS-DATA ***************************************/ -/*****************************************************************************************************/ -event error_t MCPS_DATA.confirm(uint8_t msduHandle, uint8_t status) -{ - -return SUCCESS; -} -event error_t MCPS_DATA.indication(uint16_t SrcAddrMode, uint16_t SrcPANId, uint32_t SrcAddr[2], uint16_t DstAddrMode, uint16_t DestPANId, uint32_t DstAddr[2], uint16_t msduLength,uint8_t msdu[100],uint16_t mpduLinkQuality, uint16_t SecurityUse, uint16_t ACLEntry) -{ - - -return SUCCESS; -} - - -} - diff --git a/tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExampleP.nc b/tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExampleP.nc new file mode 100644 index 00000000..ff859d01 --- /dev/null +++ b/tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExampleP.nc @@ -0,0 +1,339 @@ +/* + * + * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise + * @author Andre Cunha + * + */ +/* + * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise + * @author Andre Cunha + * + */ +#include +#include "printfUART.h" + +module GTSManagementExampleP { + + uses interface Boot; + uses interface Leds; + + uses interface Timer as Timer0; + + uses interface Timer as Timer_Send; + //MAC interfaces + + uses interface MLME_START; + + uses interface MLME_GET; + uses interface MLME_SET; + + uses interface MLME_BEACON_NOTIFY; + uses interface MLME_GTS; + + uses interface MLME_ASSOCIATE; + uses interface MLME_DISASSOCIATE; + + uses interface MLME_ORPHAN; + + uses interface MLME_SYNC; + uses interface MLME_SYNC_LOSS; + + uses interface MLME_RESET; + + uses interface MLME_SCAN; + + uses interface MCPS_DATA; + +} +implementation { + + + uint8_t beacon_present=0; + uint8_t on_sync=0; + uint8_t gts_allocated=0; + + uint8_t gts_superframe_count=0; + + PANDescriptor pan_des; + + uint32_t my_short_address=0x00000000; + uint32_t my_pan_id=0x00000001; + + + + event void Boot.booted() { + + printfUART_init(); + + if (TYPE_DEVICE == COORDINATOR) + { + //assign the short address of the device + my_short_address = 0x0000; + call Timer0.startOneShot(5000); + } + else + { + call Timer0.startOneShot(8000); + } + + } + + + + event void Timer0.fired() { + + uint8_t v_temp[2]; + + + + if (TYPE_DEVICE == COORDINATOR) + { + + //set the MAC short address variable + v_temp[0] = (uint8_t)(my_short_address >> 8); + v_temp[1] = (uint8_t)(my_short_address ); + + call MLME_SET.request(MACSHORTADDRESS,v_temp); + + //set the MAC PANID variable + v_temp[0] = (uint8_t)(MAC_PANID >> 8); + v_temp[1] = (uint8_t)(MAC_PANID ); + + call MLME_SET.request(MACPANID,v_temp); + + //start sending beacons + call MLME_START.request(MAC_PANID, LOGICAL_CHANNEL, BEACON_ORDER, SUPERFRAME_ORDER,1,0,0,0,0); + + //call Timer_Send.startPeriodic(3000); + } + else + { + my_short_address = TOS_NODE_ID; + v_temp[0] = (uint8_t)(my_short_address >> 8); + v_temp[1] = (uint8_t)(my_short_address ); + + call MLME_SET.request(MACSHORTADDRESS,v_temp); + + //call Leds.greenOn(); + gts_superframe_count=0; + + + printfUART("GTS req: %i\n", TYPE_DEVICE); + + + //allocate a transmission GTS - enables a GTS time slot allocation for the device transmission to the PAN Coordinator + call MLME_GTS.request(set_gts_characteristics(1, GTS_TX_ONLY,1),0x00); + + //allocate a transmission GTS - enables a GTS time slot allocation for the PAN coordinator transmission to the device + //call MLME_GTS.request(set_gts_characteristics(1, GTS_RX_ONLY,1),0x00); + + + //enable the transmission of the device to the PAN coordinator in the allocated transmit GTS + call Timer_Send.startPeriodic(1000); + + } + + } + +event void Timer_Send.fired() { + + + uint32_t SrcAddr[2]; + uint32_t DstAddr[2]; + uint8_t msdu_payload[4]; + + if (TYPE_DEVICE == COORDINATOR) + { + SrcAddr[0]=0x00000000; + SrcAddr[1]=TOS_NODE_ID; + + DstAddr[0]=0x00000000; + DstAddr[1]=0x00000002; + + call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SrcAddr, SHORT_ADDRESS, MAC_PANID, DstAddr, 4, msdu_payload,1,set_txoptions(1,1,0,0)); + } + else + { + call Leds.led1Toggle(); + + + SrcAddr[0]=0x00000000; + SrcAddr[1]=TOS_NODE_ID; + + DstAddr[0]=0x00000000; + DstAddr[1]=0x00000000; + + call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SrcAddr, SHORT_ADDRESS, MAC_PANID, DstAddr, 4, msdu_payload,1,set_txoptions(1,1,0,0)); + } + +} + + +/*****************************************************************************************************/ +/**************************************MLME-SCAN*******************************************************/ +/*****************************************************************************************************/ +event error_t MLME_SCAN.confirm(uint8_t status,uint8_t ScanType, uint32_t UnscannedChannels, uint8_t ResultListSize, uint8_t EnergyDetectList[], SCAN_PANDescriptor PANDescriptorList[]) +{ + + return SUCCESS; +} + +/*****************************************************************************************************/ +/**************************************MLME-ORPHAN****************************************************/ +/*****************************************************************************************************/ +event error_t MLME_ORPHAN.indication(uint32_t OrphanAddress[1], uint8_t SecurityUse, uint8_t ACLEntry) +{ + + return SUCCESS; +} +/*****************************************************************************************************/ +/**************************************MLME-RESET*****************************************************/ +/*****************************************************************************************************/ +event error_t MLME_RESET.confirm(uint8_t status) +{ + + + + return SUCCESS; +} +/*****************************************************************************************************/ +/**************************************MLME-SYNC-LOSS*************************************************/ +/*****************************************************************************************************/ +event error_t MLME_SYNC_LOSS.indication(uint8_t LossReason) +{ + + return SUCCESS; +} + +/*****************************************************************************************************/ +/**************************************MLME-GTS*******************************************************/ +/*****************************************************************************************************/ + +event error_t MLME_GTS.confirm(uint8_t GTSCharacteristics, uint8_t status) +{ + switch(status) + { + case MAC_SUCCESS: gts_allocated=1; + call Leds.led1Toggle(); + break; + + case MAC_DENIED: gts_allocated=0; + break; + + case MAC_NO_SHORT_ADDRESS: gts_allocated=0; + break; + + case MAC_CHANNEL_ACCESS_FAILURE: gts_allocated=0; + break; + + case MAC_NO_ACK: gts_allocated=0;break; + + case MAC_NO_DATA: gts_allocated=0;break; + + + default: break; + + } + + return SUCCESS; +} + +event error_t MLME_GTS.indication(uint16_t DevAddress, uint8_t GTSCharacteristics, bool SecurityUse, uint8_t ACLEntry) +{ + return SUCCESS; +} + /*****************************************************************************************************/ +/**************************************MLME-BEACON NOTIFY*********************************************/ +/*****************************************************************************************************/ + +event error_t MLME_BEACON_NOTIFY.indication(uint8_t BSN,PANDescriptor pan_descriptor, uint8_t PenAddrSpec, uint8_t AddrList, uint8_t sduLength, uint8_t sdu[]) +{ + gts_superframe_count++; + if (gts_superframe_count==30) + { + //call Leds.greenOff(); + call MLME_GTS.request(set_gts_characteristics(1, GTS_TX_ONLY,0),0x00); + } + return SUCCESS; +} +/*****************************************************************************************************/ +/**************************************MLME-START*****************************************************/ +/*****************************************************************************************************/ + event error_t MLME_START.confirm(uint8_t status) + { + + + return SUCCESS; + } + /*****************************************************************************************************/ +/********************** MLME-SET ******************************************/ +/*****************************************************************************************************/ + + event error_t MLME_SET.confirm(uint8_t status,uint8_t PIBAttribute) + { + + + return SUCCESS; + } + /*****************************************************************************************************/ +/************************* MLME-GET ******************************************/ +/*****************************************************************************************************/ + event error_t MLME_GET.confirm(uint8_t status,uint8_t PIBAttribute, uint8_t PIBAttributeValue[]) + { + + + return SUCCESS; + } + + + /*****************************************************************************************************/ +/**************************************MLME-ASSOCIATE*************************************************/ +/*****************************************************************************************************/ +event error_t MLME_ASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t CapabilityInformation, bool SecurityUse, uint8_t ACLEntry) +{ + + return SUCCESS; +} + +event error_t MLME_ASSOCIATE.confirm(uint16_t AssocShortAddress, uint8_t status) +{ + + return SUCCESS; +} + /*****************************************************************************************************/ +/**************************************MLME-DISASSOCIATE**********************************************/ +/*****************************************************************************************************/ +event error_t MLME_DISASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t DisassociateReason, bool SecurityUse, uint8_t ACLEntry) +{ + return SUCCESS; +} + +event error_t MLME_DISASSOCIATE.confirm(uint8_t status) +{ + return SUCCESS; +} + /*****************************************************************************************************/ +/*****************************************************************************************************/ +/**************** MCPS EVENTS *************************************/ +/*****************************************************************************************************/ +/*****************************************************************************************************/ + + +/*****************************************************************************************************/ +/********************* MCPS-DATA ***************************************/ +/*****************************************************************************************************/ +event error_t MCPS_DATA.confirm(uint8_t msduHandle, uint8_t status) +{ + +return SUCCESS; +} +event error_t MCPS_DATA.indication(uint16_t SrcAddrMode, uint16_t SrcPANId, uint32_t SrcAddr[2], uint16_t DstAddrMode, uint16_t DestPANId, uint32_t DstAddr[2], uint16_t msduLength,uint8_t msdu[100],uint16_t mpduLinkQuality, uint16_t SecurityUse, uint16_t ACLEntry) +{ + + +return SUCCESS; +} + + +} + diff --git a/tos/lib/net/zigbee/apps/GTSManagementExample/Makefile b/tos/lib/net/zigbee/apps/GTSManagementExample/Makefile index 13e57082..9eab3ac6 100644 --- a/tos/lib/net/zigbee/apps/GTSManagementExample/Makefile +++ b/tos/lib/net/zigbee/apps/GTSManagementExample/Makefile @@ -1,4 +1,4 @@ -COMPONENT=GTSManagementExample +COMPONENT=GTSManagementExampleC PFLAGS += -I$(TOSROOT)/tos/lib/net/zigbee/ieee802154/includes \ -I$(TOSROOT)/tos/lib/net/zigbee/ieee802154/mac \ diff --git a/tos/lib/net/zigbee/apps/SimpleRoutingExample/Makefile b/tos/lib/net/zigbee/apps/SimpleRoutingExample/Makefile index 4c3b2fcf..f44b8b3c 100644 --- a/tos/lib/net/zigbee/apps/SimpleRoutingExample/Makefile +++ b/tos/lib/net/zigbee/apps/SimpleRoutingExample/Makefile @@ -1,4 +1,4 @@ -COMPONENT=SimpleRoutingExample +COMPONENT=SimpleRoutingExampleC PFLAGS += -I$(TOSROOT)/tos/lib/net/zigbee/ieee802154/includes \ -I$(TOSROOT)/tos/lib/net/zigbee/ieee802154/mac \ diff --git a/tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExample.nc b/tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExample.nc deleted file mode 100644 index 115572bf..00000000 --- a/tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExample.nc +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise - * @author Andre Cunha - */ -#include - -#include "simpleroutingexample.h" -#include "phy_const.h" -#include "phy_enumerations.h" -#include "mac_const.h" -#include "mac_enumerations.h" -#include "mac_func.h" - - configuration SimpleRoutingExample { -} - -implementation -{ - components MainC; - components LedsC; - components SimpleRoutingExampleM; - - SimpleRoutingExampleM.Boot -> MainC; - - components Mac; - - SimpleRoutingExampleM.Leds -> LedsC; - - components new TimerMilliC() as Timer0; - SimpleRoutingExampleM.Timer0 -> Timer0; - - components new TimerMilliC() as Timer_Send; - SimpleRoutingExampleM.Timer_Send ->Timer_Send; - - - //MAC interfaces - - SimpleRoutingExampleM.MLME_START -> Mac.MLME_START; - - SimpleRoutingExampleM.MLME_GET ->Mac.MLME_GET; - SimpleRoutingExampleM.MLME_SET ->Mac.MLME_SET; - - SimpleRoutingExampleM.MLME_BEACON_NOTIFY ->Mac.MLME_BEACON_NOTIFY; - SimpleRoutingExampleM.MLME_GTS -> Mac.MLME_GTS; - - SimpleRoutingExampleM.MLME_ASSOCIATE->Mac.MLME_ASSOCIATE; - SimpleRoutingExampleM.MLME_DISASSOCIATE->Mac.MLME_DISASSOCIATE; - - SimpleRoutingExampleM.MLME_ORPHAN->Mac.MLME_ORPHAN; - SimpleRoutingExampleM.MLME_SYNC->Mac.MLME_SYNC; - SimpleRoutingExampleM.MLME_SYNC_LOSS->Mac.MLME_SYNC_LOSS; - SimpleRoutingExampleM.MLME_RESET->Mac.MLME_RESET; - - SimpleRoutingExampleM.MLME_SCAN->Mac.MLME_SCAN; - - - SimpleRoutingExampleM.MCPS_DATA->Mac.MCPS_DATA; - - -} - diff --git a/tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExampleC.nc b/tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExampleC.nc new file mode 100644 index 00000000..f43915c0 --- /dev/null +++ b/tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExampleC.nc @@ -0,0 +1,61 @@ +/** + * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise + * @author Andre Cunha + */ +#include + +#include "simpleroutingexample.h" +#include "phy_const.h" +#include "phy_enumerations.h" +#include "mac_const.h" +#include "mac_enumerations.h" +#include "mac_func.h" + + configuration SimpleRoutingExampleC { +} + +implementation +{ + components MainC; + components LedsC; + components SimpleRoutingExampleP; + + SimpleRoutingExampleP.Boot -> MainC; + + components MacC; + + SimpleRoutingExampleP.Leds -> LedsC; + + components new TimerMilliC() as Timer0; + SimpleRoutingExampleP.Timer0 -> Timer0; + + components new TimerMilliC() as Timer_Send; + SimpleRoutingExampleP.Timer_Send ->Timer_Send; + + + //MAC interfaces + + SimpleRoutingExampleP.MLME_START -> MacC.MLME_START; + + SimpleRoutingExampleP.MLME_GET ->MacC.MLME_GET; + SimpleRoutingExampleP.MLME_SET ->MacC.MLME_SET; + + SimpleRoutingExampleP.MLME_BEACON_NOTIFY ->MacC.MLME_BEACON_NOTIFY; + SimpleRoutingExampleP.MLME_GTS -> MacC.MLME_GTS; + + SimpleRoutingExampleP.MLME_ASSOCIATE->MacC.MLME_ASSOCIATE; + SimpleRoutingExampleP.MLME_DISASSOCIATE->MacC.MLME_DISASSOCIATE; + + SimpleRoutingExampleP.MLME_ORPHAN->MacC.MLME_ORPHAN; + SimpleRoutingExampleP.MLME_SYNC->MacC.MLME_SYNC; + SimpleRoutingExampleP.MLME_SYNC_LOSS->MacC.MLME_SYNC_LOSS; + SimpleRoutingExampleP.MLME_RESET->MacC.MLME_RESET; + + SimpleRoutingExampleP.MLME_SCAN->MacC.MLME_SCAN; + + + SimpleRoutingExampleP.MCPS_DATA->MacC.MCPS_DATA; + + +} + diff --git a/tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExampleM.nc b/tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExampleM.nc deleted file mode 100644 index 8f25b938..00000000 --- a/tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExampleM.nc +++ /dev/null @@ -1,308 +0,0 @@ -/* - * - * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise - * @author Andre Cunha - * - */ - -#include -#include "printfUART.h" - -module SimpleRoutingExampleM { - - uses interface Boot; - uses interface Leds; - - uses interface Timer as Timer0; - - uses interface Timer as Timer_Send; - //MAC interfaces - - uses interface MLME_START; - - uses interface MLME_GET; - uses interface MLME_SET; - - uses interface MLME_BEACON_NOTIFY; - uses interface MLME_GTS; - - uses interface MLME_ASSOCIATE; - uses interface MLME_DISASSOCIATE; - - uses interface MLME_ORPHAN; - - uses interface MLME_SYNC; - uses interface MLME_SYNC_LOSS; - - uses interface MLME_RESET; - - uses interface MLME_SCAN; - - uses interface MCPS_DATA; - -} -implementation { - - PANDescriptor pan_des; - - uint32_t my_short_address=0x00000000; - - uint32_t DestinationMote[2]; - uint32_t SourceMoteAddr[2]; - - //number of routed packet (coordinator) - uint8_t routed_packets = 0x00; - - - event void Boot.booted() { - - printfUART_init(); - - printfUART("i_am_pan: %i\n", TYPE_DEVICE); - - DestinationMote[0]=0x00000000; - DestinationMote[1]=0x00000002; - - if (TYPE_DEVICE == COORDINATOR) - { - my_short_address = 0x0000; - call Timer0.startOneShot(4000); - } - else - { - call Timer0.startOneShot(4000); - } - - } - - - event void Timer0.fired() { - - uint8_t v_temp[2]; - - - if (TYPE_DEVICE == END_DEVICE) - { - - my_short_address = TOS_NODE_ID; - - //set the MAC short address variable - v_temp[0] = (uint8_t)(my_short_address >> 8); - v_temp[1] = (uint8_t)(my_short_address ); - - call MLME_SET.request(MACSHORTADDRESS,v_temp); - - //set the MAC PANID variable - v_temp[0] = (uint8_t)(MAC_PANID >> 8); - v_temp[1] = (uint8_t)(MAC_PANID ); - - call MLME_SET.request(MACPANID,v_temp); - - call Timer_Send.startPeriodic(3000); - - } - else - { - //set the MAC short address variable - v_temp[0] = (uint8_t)(my_short_address >> 8); - v_temp[1] = (uint8_t)(my_short_address ); - - call MLME_SET.request(MACSHORTADDRESS,v_temp); - - //set the MAC PANID variable - v_temp[0] = (uint8_t)(MAC_PANID >> 8); - v_temp[1] = (uint8_t)(MAC_PANID ); - - call MLME_SET.request(MACPANID,v_temp); - - //start sending beacons - call MLME_START.request(MAC_PANID, LOGICAL_CHANNEL, BEACON_ORDER, SUPERFRAME_ORDER,1,0,0,0,0); - - //call Timer_send.start(TIMER_REPEAT,8000); - } - - } - -event void Timer_Send.fired() { - - - uint8_t msdu_payload[4]; - - DestinationMote[0]=0x00000000; - DestinationMote[1]=0x00000000; - - //NKL destination address, coordinator will route packet to this address - msdu_payload[0] = 0x00; - msdu_payload[1] = 0x03; - - SourceMoteAddr[0]=0x00000000; - SourceMoteAddr[1]=TOS_NODE_ID; - - if (TOS_NODE_ID == 0x02) - { - call Leds.led2Toggle(); //set_txoptions(ack, gts, indirect_transmission, security) - call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SourceMoteAddr, SHORT_ADDRESS, MAC_PANID, DestinationMote, 2, msdu_payload,1,set_txoptions(1,0,0,0)); - } - - - } - -/*****************************************************************************************************/ -/**************************************MLME-SCAN*******************************************************/ -/*****************************************************************************************************/ -event error_t MLME_SCAN.confirm(uint8_t status,uint8_t ScanType, uint32_t UnscannedChannels, uint8_t ResultListSize, uint8_t EnergyDetectList[], SCAN_PANDescriptor PANDescriptorList[]) -{ - - return SUCCESS; -} - -/*****************************************************************************************************/ -/**************************************MLME-ORPHAN****************************************************/ -/*****************************************************************************************************/ -event error_t MLME_ORPHAN.indication(uint32_t OrphanAddress[1], uint8_t SecurityUse, uint8_t ACLEntry) -{ - - return SUCCESS; -} -/*****************************************************************************************************/ -/**************************************MLME-RESET*****************************************************/ -/*****************************************************************************************************/ -event error_t MLME_RESET.confirm(uint8_t status) -{ - - - - return SUCCESS; -} -/*****************************************************************************************************/ -/**************************************MLME-SYNC-LOSS*************************************************/ -/*****************************************************************************************************/ -event error_t MLME_SYNC_LOSS.indication(uint8_t LossReason) -{ - - return SUCCESS; -} - -/*****************************************************************************************************/ -/**************************************MLME-GTS*******************************************************/ -/*****************************************************************************************************/ -event error_t MLME_GTS.confirm(uint8_t GTSCharacteristics, uint8_t status) -{ - - return SUCCESS; -} - -event error_t MLME_GTS.indication(uint16_t DevAddress, uint8_t GTSCharacteristics, bool SecurityUse, uint8_t ACLEntry) -{ - return SUCCESS; -} -/*****************************************************************************************************/ -/**************************************MLME-BEACON NOTIFY*********************************************/ -/*****************************************************************************************************/ -event error_t MLME_BEACON_NOTIFY.indication(uint8_t BSN,PANDescriptor pan_descriptor, uint8_t PenAddrSpec, uint8_t AddrList, uint8_t sduLength, uint8_t sdu[]) -{ - - return SUCCESS; -} -/*****************************************************************************************************/ -/**************************************MLME-START*****************************************************/ -/*****************************************************************************************************/ -event error_t MLME_START.confirm(uint8_t status) -{ - - -return SUCCESS; -} - /*****************************************************************************************************/ -/********************** MLME-SET ******************************************/ -/*****************************************************************************************************/ - -event error_t MLME_SET.confirm(uint8_t status,uint8_t PIBAttribute) -{ - - -return SUCCESS; -} -/*****************************************************************************************************/ -/************************* MLME-GET ******************************************/ -/*****************************************************************************************************/ -event error_t MLME_GET.confirm(uint8_t status,uint8_t PIBAttribute, uint8_t PIBAttributeValue[]) -{ - - -return SUCCESS; -} - - -/*****************************************************************************************************/ -/**************************************MLME-ASSOCIATE*************************************************/ -/*****************************************************************************************************/ -event error_t MLME_ASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t CapabilityInformation, bool SecurityUse, uint8_t ACLEntry) -{ - - return SUCCESS; -} - -event error_t MLME_ASSOCIATE.confirm(uint16_t AssocShortAddress, uint8_t status) -{ - - return SUCCESS; -} - /*****************************************************************************************************/ -/**************************************MLME-DISASSOCIATE**********************************************/ -/*****************************************************************************************************/ -event error_t MLME_DISASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t DisassociateReason, bool SecurityUse, uint8_t ACLEntry) -{ - return SUCCESS; -} - -event error_t MLME_DISASSOCIATE.confirm(uint8_t status) -{ - return SUCCESS; -} - /*****************************************************************************************************/ -/*****************************************************************************************************/ -/**************** MCPS EVENTS *************************************/ -/*****************************************************************************************************/ -/*****************************************************************************************************/ - - -/*****************************************************************************************************/ -/********************* MCPS-DATA ***************************************/ -/*****************************************************************************************************/ -event error_t MCPS_DATA.confirm(uint8_t msduHandle, uint8_t status) -{ - -return SUCCESS; -} -event error_t MCPS_DATA.indication(uint16_t SrcAddrMode, uint16_t SrcPANId, uint32_t SrcAddr[2], uint16_t DstAddrMode, uint16_t DestPANId, uint32_t DstAddr[2], uint16_t msduLength,uint8_t msdu[100],uint16_t mpduLinkQuality, uint16_t SecurityUse, uint16_t ACLEntry) -{ - -//routing procedure, the short address of the destination device is the first 2 bytes of the data payload - if (TYPE_DEVICE == COORDINATOR) - { - - //route to the desired address - DestinationMote[0]=0x00000000; - DestinationMote[1]=(uint32_t) msdu[1]; - - routed_packets++; - msdu[0] = routed_packets; - //set_txoptions(ack, gts, indirect_transmission, security) - call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SrcAddr, SHORT_ADDRESS, MAC_PANID, DestinationMote, 1, msdu,1,set_txoptions(1,0,0,0)); - } - else - { - - call Leds.led1Toggle(); - - } - - - -return SUCCESS; -} - - -} - diff --git a/tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExampleP.nc b/tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExampleP.nc new file mode 100644 index 00000000..33149070 --- /dev/null +++ b/tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExampleP.nc @@ -0,0 +1,308 @@ +/* + * + * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise + * @author Andre Cunha + * + */ + +#include +#include "printfUART.h" + +module SimpleRoutingExampleP { + + uses interface Boot; + uses interface Leds; + + uses interface Timer as Timer0; + + uses interface Timer as Timer_Send; + //MAC interfaces + + uses interface MLME_START; + + uses interface MLME_GET; + uses interface MLME_SET; + + uses interface MLME_BEACON_NOTIFY; + uses interface MLME_GTS; + + uses interface MLME_ASSOCIATE; + uses interface MLME_DISASSOCIATE; + + uses interface MLME_ORPHAN; + + uses interface MLME_SYNC; + uses interface MLME_SYNC_LOSS; + + uses interface MLME_RESET; + + uses interface MLME_SCAN; + + uses interface MCPS_DATA; + +} +implementation { + + PANDescriptor pan_des; + + uint32_t my_short_address=0x00000000; + + uint32_t DestinationMote[2]; + uint32_t SourceMoteAddr[2]; + + //number of routed packet (coordinator) + uint8_t routed_packets = 0x00; + + + event void Boot.booted() { + + printfUART_init(); + + printfUART("i_am_pan: %i\n", TYPE_DEVICE); + + DestinationMote[0]=0x00000000; + DestinationMote[1]=0x00000002; + + if (TYPE_DEVICE == COORDINATOR) + { + my_short_address = 0x0000; + call Timer0.startOneShot(4000); + } + else + { + call Timer0.startOneShot(4000); + } + + } + + + event void Timer0.fired() { + + uint8_t v_temp[2]; + + + if (TYPE_DEVICE == END_DEVICE) + { + + my_short_address = TOS_NODE_ID; + + //set the MAC short address variable + v_temp[0] = (uint8_t)(my_short_address >> 8); + v_temp[1] = (uint8_t)(my_short_address ); + + call MLME_SET.request(MACSHORTADDRESS,v_temp); + + //set the MAC PANID variable + v_temp[0] = (uint8_t)(MAC_PANID >> 8); + v_temp[1] = (uint8_t)(MAC_PANID ); + + call MLME_SET.request(MACPANID,v_temp); + + call Timer_Send.startPeriodic(3000); + + } + else + { + //set the MAC short address variable + v_temp[0] = (uint8_t)(my_short_address >> 8); + v_temp[1] = (uint8_t)(my_short_address ); + + call MLME_SET.request(MACSHORTADDRESS,v_temp); + + //set the MAC PANID variable + v_temp[0] = (uint8_t)(MAC_PANID >> 8); + v_temp[1] = (uint8_t)(MAC_PANID ); + + call MLME_SET.request(MACPANID,v_temp); + + //start sending beacons + call MLME_START.request(MAC_PANID, LOGICAL_CHANNEL, BEACON_ORDER, SUPERFRAME_ORDER,1,0,0,0,0); + + //call Timer_send.start(TIMER_REPEAT,8000); + } + + } + +event void Timer_Send.fired() { + + + uint8_t msdu_payload[4]; + + DestinationMote[0]=0x00000000; + DestinationMote[1]=0x00000000; + + //NKL destination address, coordinator will route packet to this address + msdu_payload[0] = 0x00; + msdu_payload[1] = 0x03; + + SourceMoteAddr[0]=0x00000000; + SourceMoteAddr[1]=TOS_NODE_ID; + + if (TOS_NODE_ID == 0x02) + { + call Leds.led2Toggle(); //set_txoptions(ack, gts, indirect_transmission, security) + call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SourceMoteAddr, SHORT_ADDRESS, MAC_PANID, DestinationMote, 2, msdu_payload,1,set_txoptions(1,0,0,0)); + } + + + } + +/*****************************************************************************************************/ +/**************************************MLME-SCAN*******************************************************/ +/*****************************************************************************************************/ +event error_t MLME_SCAN.confirm(uint8_t status,uint8_t ScanType, uint32_t UnscannedChannels, uint8_t ResultListSize, uint8_t EnergyDetectList[], SCAN_PANDescriptor PANDescriptorList[]) +{ + + return SUCCESS; +} + +/*****************************************************************************************************/ +/**************************************MLME-ORPHAN****************************************************/ +/*****************************************************************************************************/ +event error_t MLME_ORPHAN.indication(uint32_t OrphanAddress[1], uint8_t SecurityUse, uint8_t ACLEntry) +{ + + return SUCCESS; +} +/*****************************************************************************************************/ +/**************************************MLME-RESET*****************************************************/ +/*****************************************************************************************************/ +event error_t MLME_RESET.confirm(uint8_t status) +{ + + + + return SUCCESS; +} +/*****************************************************************************************************/ +/**************************************MLME-SYNC-LOSS*************************************************/ +/*****************************************************************************************************/ +event error_t MLME_SYNC_LOSS.indication(uint8_t LossReason) +{ + + return SUCCESS; +} + +/*****************************************************************************************************/ +/**************************************MLME-GTS*******************************************************/ +/*****************************************************************************************************/ +event error_t MLME_GTS.confirm(uint8_t GTSCharacteristics, uint8_t status) +{ + + return SUCCESS; +} + +event error_t MLME_GTS.indication(uint16_t DevAddress, uint8_t GTSCharacteristics, bool SecurityUse, uint8_t ACLEntry) +{ + return SUCCESS; +} +/*****************************************************************************************************/ +/**************************************MLME-BEACON NOTIFY*********************************************/ +/*****************************************************************************************************/ +event error_t MLME_BEACON_NOTIFY.indication(uint8_t BSN,PANDescriptor pan_descriptor, uint8_t PenAddrSpec, uint8_t AddrList, uint8_t sduLength, uint8_t sdu[]) +{ + + return SUCCESS; +} +/*****************************************************************************************************/ +/**************************************MLME-START*****************************************************/ +/*****************************************************************************************************/ +event error_t MLME_START.confirm(uint8_t status) +{ + + +return SUCCESS; +} + /*****************************************************************************************************/ +/********************** MLME-SET ******************************************/ +/*****************************************************************************************************/ + +event error_t MLME_SET.confirm(uint8_t status,uint8_t PIBAttribute) +{ + + +return SUCCESS; +} +/*****************************************************************************************************/ +/************************* MLME-GET ******************************************/ +/*****************************************************************************************************/ +event error_t MLME_GET.confirm(uint8_t status,uint8_t PIBAttribute, uint8_t PIBAttributeValue[]) +{ + + +return SUCCESS; +} + + +/*****************************************************************************************************/ +/**************************************MLME-ASSOCIATE*************************************************/ +/*****************************************************************************************************/ +event error_t MLME_ASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t CapabilityInformation, bool SecurityUse, uint8_t ACLEntry) +{ + + return SUCCESS; +} + +event error_t MLME_ASSOCIATE.confirm(uint16_t AssocShortAddress, uint8_t status) +{ + + return SUCCESS; +} + /*****************************************************************************************************/ +/**************************************MLME-DISASSOCIATE**********************************************/ +/*****************************************************************************************************/ +event error_t MLME_DISASSOCIATE.indication(uint32_t DeviceAddress[], uint8_t DisassociateReason, bool SecurityUse, uint8_t ACLEntry) +{ + return SUCCESS; +} + +event error_t MLME_DISASSOCIATE.confirm(uint8_t status) +{ + return SUCCESS; +} + /*****************************************************************************************************/ +/*****************************************************************************************************/ +/**************** MCPS EVENTS *************************************/ +/*****************************************************************************************************/ +/*****************************************************************************************************/ + + +/*****************************************************************************************************/ +/********************* MCPS-DATA ***************************************/ +/*****************************************************************************************************/ +event error_t MCPS_DATA.confirm(uint8_t msduHandle, uint8_t status) +{ + +return SUCCESS; +} +event error_t MCPS_DATA.indication(uint16_t SrcAddrMode, uint16_t SrcPANId, uint32_t SrcAddr[2], uint16_t DstAddrMode, uint16_t DestPANId, uint32_t DstAddr[2], uint16_t msduLength,uint8_t msdu[100],uint16_t mpduLinkQuality, uint16_t SecurityUse, uint16_t ACLEntry) +{ + +//routing procedure, the short address of the destination device is the first 2 bytes of the data payload + if (TYPE_DEVICE == COORDINATOR) + { + + //route to the desired address + DestinationMote[0]=0x00000000; + DestinationMote[1]=(uint32_t) msdu[1]; + + routed_packets++; + msdu[0] = routed_packets; + //set_txoptions(ack, gts, indirect_transmission, security) + call MCPS_DATA.request(SHORT_ADDRESS, MAC_PANID, SrcAddr, SHORT_ADDRESS, MAC_PANID, DestinationMote, 1, msdu,1,set_txoptions(1,0,0,0)); + } + else + { + + call Leds.led1Toggle(); + + } + + + +return SUCCESS; +} + + +} + diff --git a/tos/lib/net/zigbee/apps/Test_APL/Test_APLC.nc b/tos/lib/net/zigbee/apps/Test_APL/Test_APLC.nc index cf230138..efd41b86 100644 --- a/tos/lib/net/zigbee/apps/Test_APL/Test_APLC.nc +++ b/tos/lib/net/zigbee/apps/Test_APL/Test_APLC.nc @@ -1,6 +1,7 @@ /* * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise * @author Andre Cunha + * @author Ricardo Severino * */ #include diff --git a/tos/lib/net/zigbee/apps/Test_APL/Test_APLP.nc b/tos/lib/net/zigbee/apps/Test_APL/Test_APLP.nc index 801f7a35..2755af5a 100644 --- a/tos/lib/net/zigbee/apps/Test_APL/Test_APLP.nc +++ b/tos/lib/net/zigbee/apps/Test_APL/Test_APLP.nc @@ -3,6 +3,7 @@ /* * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise * @author Andre Cunha + * @author Ricardo Severino * */ #include