]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
*** empty log message ***
authorrarseverino <rarseverino>
Fri, 18 Sep 2009 16:55:49 +0000 (16:55 +0000)
committerrarseverino <rarseverino>
Fri, 18 Sep 2009 16:55:49 +0000 (16:55 +0000)
22 files changed:
tos/lib/net/zigbee/apps/AssociationExample/AssociationExample.nc [deleted file]
tos/lib/net/zigbee/apps/AssociationExample/AssociationExampleC.nc [new file with mode: 0644]
tos/lib/net/zigbee/apps/AssociationExample/AssociationExampleM.nc [deleted file]
tos/lib/net/zigbee/apps/AssociationExample/AssociationExampleP.nc [new file with mode: 0644]
tos/lib/net/zigbee/apps/AssociationExample/Makefile
tos/lib/net/zigbee/apps/DataSendExample/DataSendExample.nc [deleted file]
tos/lib/net/zigbee/apps/DataSendExample/DataSendExampleC.nc [new file with mode: 0644]
tos/lib/net/zigbee/apps/DataSendExample/DataSendExampleM.nc [deleted file]
tos/lib/net/zigbee/apps/DataSendExample/DataSendExampleP.nc [new file with mode: 0644]
tos/lib/net/zigbee/apps/DataSendExample/Makefile
tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExample.nc [deleted file]
tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExampleC.nc [new file with mode: 0644]
tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExampleM.nc [deleted file]
tos/lib/net/zigbee/apps/GTSManagementExample/GTSManagementExampleP.nc [new file with mode: 0644]
tos/lib/net/zigbee/apps/GTSManagementExample/Makefile
tos/lib/net/zigbee/apps/SimpleRoutingExample/Makefile
tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExample.nc [deleted file]
tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExampleC.nc [new file with mode: 0644]
tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExampleM.nc [deleted file]
tos/lib/net/zigbee/apps/SimpleRoutingExample/SimpleRoutingExampleP.nc [new file with mode: 0644]
tos/lib/net/zigbee/apps/Test_APL/Test_APLC.nc
tos/lib/net/zigbee/apps/Test_APL/Test_APLP.nc

diff --git a/tos/lib/net/zigbee/apps/AssociationExample/AssociationExample.nc b/tos/lib/net/zigbee/apps/AssociationExample/AssociationExample.nc
deleted file mode 100644 (file)
index 75aa75f..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
- * @author Andre Cunha
- *
- */
-#include <Timer.h>
-
-#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 (file)
index 0000000..bebb506
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
+ * @author Andre Cunha
+ *
+ */
+#include <Timer.h>
+
+#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 (file)
index 99e4c79..0000000
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
- * @author Andre Cunha
- *
- */
-#include <Timer.h>
-#include "printfUART.h"
-
-module AssociationExampleM {
-
-       uses interface Boot;
-       uses interface Leds;
-       
-       uses interface Timer<TMilli> as Timer0;
-       
-       uses interface Timer<TMilli> 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<ResultListSize;i++)
-               {
-                       printfUART("ED SCAN %i %i\n", (0x0A + i),EnergyDetectList[i]);
-               }
-               return SUCCESS;
-       }
-       
-       for (i=0; i<ResultListSize;i++)
-       {               /*
-                       printfUART("cord id %i", PANDescriptorList[i].CoordPANId);
-                       printfUART("CoordAddress %i", PANDescriptorList[i].CoordAddress);
-                       printfUART("LogicalChannel %i", PANDescriptorList[i].LogicalChannel);
-                       printfUART("SuperframeSpec %i", PANDescriptorList[i].SuperframeSpec);
-                       printfUART("lqi %i\n", PANDescriptorList[i].lqi);
-                       */
-               if(max_lqi < PANDescriptorList[i].lqi)
-               {
-                       max_lqi =PANDescriptorList[i].lqi;
-                       best_pan_index = i;
-               }
-       }
-       
-       printfUART("SELECTED cord id %i", PANDescriptorList[best_pan_index].CoordPANId);
-       printfUART("CoordAddress %i", PANDescriptorList[best_pan_index].CoordAddress);
-       printfUART("LogicalChannel %i", PANDescriptorList[best_pan_index].LogicalChannel);
-       printfUART("SuperframeSpec %i", PANDescriptorList[best_pan_index].SuperframeSpec);
-       printfUART("lqi %i\n", PANDescriptorList[best_pan_index].lqi);
-       
-       coordinator_addr[0] = 0x00000001;
-       
-       coordinator_addr[1] = (uint32_t)PANDescriptorList[best_pan_index].CoordAddress;
-       
-       //pan_des = PANDescriptorList[best_pan_index];
-
-       
-       //BUILD the PAN descriptor of the COORDINATOR
-       //assuming that the adress is short
-       pan_des.CoordAddrMode = SHORT_ADDRESS;
-       pan_des.CoordPANId = PANDescriptorList[best_pan_index].CoordAddress;
-       pan_des.CoordAddress0=0x00000000;
-       pan_des.CoordAddress1=0x00000000;
-       pan_des.LogicalChannel=PANDescriptorList[best_pan_index].LogicalChannel;
-       //superframe specification field
-       pan_des.SuperframeSpec = PANDescriptorList[best_pan_index].SuperframeSpec;
-       
-       pan_des.GTSPermit=0x01;
-       pan_des.LinkQuality=0x00;
-       pan_des.TimeStamp=0x000000;
-       pan_des.SecurityUse=0;
-       pan_des.ACLEntry=0x00;
-       pan_des.SecurityFailure=0x00;
-       
-       received_beacon_count=0;
-       go_associate=1;
-       //enables the TimerAsync events, in order to enable the synchronization with the PAN coordinator
-       call MLME_SYNC.request(PANDescriptorList[best_pan_index].LogicalChannel,0);
-       
-       
-       
-       return SUCCESS;
-}
-
-/*****************************************************************************************************/  
-/**************************************MLME-ORPHAN****************************************************/
-/*****************************************************************************************************/ 
-event error_t MLME_ORPHAN.indication(uint32_t OrphanAddress[1], uint8_t SecurityUse, uint8_t ACLEntry)
-{
-
-       uint16_t assigned_address;
-       
-       assigned_address = search_associated_devices(OrphanAddress[0],OrphanAddress[1]);
-       
-       if (assigned_address == 0x0000)
-       {
-               printfUART("not my child\n","");
-       }
-       else
-       {
-               //printfUART("my child\n","");
-               call MLME_ORPHAN.response(OrphanAddress,assigned_address,0x01, 0x00);
-       }
-
-       return SUCCESS;
-}
-
-       uint16_t search_associated_devices(uint32_t ext1, uint32_t ext2)
-       {
-               int i;
-               
-               for(i=0;i<4;i++)
-               {
-                       //printfUART("ad %i %i %i\n",associated_devices[i].extended1,associated_devices[i].extended2,associated_devices[i].assigned_short);
-                       if(associated_devices[i].extended1 == ext1 && associated_devices[i].extended2 == ext2 )
-                       {
-                       
-                               return associated_devices[i].assigned_short;
-                       }
-               
-               }
-               
-               return 0x0000;
-       }
-
-/*****************************************************************************************************/  
-/**************************************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)
-{
-               printfUART("SL\n","");
-               
-               call MLME_SCAN.request(ORPHAN_SCAN,0xFFFFFFFF,7);
-
-
-       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[])
-{
-       
-       if (go_associate==1)
-       {
-               received_beacon_count++;
-               
-               printfUART("bn %i\n", received_beacon_count);
-               
-               if (received_beacon_count==5)
-               {
-                               printfUART("sa \n", "");
-                               go_associate=0;
-                               call MLME_ASSOCIATE.request(pan_des.LogicalChannel,SHORT_ADDRESS,pan_des.CoordPANId,coordinator_addr,0x00,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)
-{
-               //the coordinator device receives the association request and assigns the device with a short address
-               address_poll ++;
-               number_associations++;
-               
-               printfUART("address pool: %i %i\n", address_poll,number_associations);
-               
-               call MLME_ASSOCIATE.response(DeviceAddress,address_poll, CMD_RESP_ASSOCIATION_SUCCESSFUL, 0);
-       return SUCCESS;
-}
-
-event error_t MLME_ASSOCIATE.confirm(uint16_t AssocShortAddress, uint8_t status)
-{
-
-//the end device receives the association confirm and activates the data frame send timer
-       uint8_t v_temp[2];
-       
-       printfUART("MLME_ASSOCIATE.confirm\n", "");
-
-       printfUART("Short: %x\n", AssocShortAddress);
-       printfUART("Status: %i\n", status);
-       
-       if (AssocShortAddress == 0x0000)
-       {
-               //call Timer0.startOneShot(8000);
-       
-       }
-       else
-       {
-               
-               my_short_address = AssocShortAddress;
-                       
-               v_temp[0] = (my_short_address >> 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 (file)
index 0000000..6ba8d55
--- /dev/null
@@ -0,0 +1,489 @@
+/*
+ * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
+ * @author Andre Cunha
+ *
+ */
+#include <Timer.h>
+#include "printfUART.h"
+
+module AssociationExampleP {
+
+       uses interface Boot;
+       uses interface Leds;
+       
+       uses interface Timer<TMilli> as Timer0;
+       
+       uses interface Timer<TMilli> 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<ResultListSize;i++)
+               {
+                       printfUART("ED SCAN %i %i\n", (0x0A + i),EnergyDetectList[i]);
+               }
+               return SUCCESS;
+       }
+       
+       for (i=0; i<ResultListSize;i++)
+       {               /*
+                       printfUART("cord id %i", PANDescriptorList[i].CoordPANId);
+                       printfUART("CoordAddress %i", PANDescriptorList[i].CoordAddress);
+                       printfUART("LogicalChannel %i", PANDescriptorList[i].LogicalChannel);
+                       printfUART("SuperframeSpec %i", PANDescriptorList[i].SuperframeSpec);
+                       printfUART("lqi %i\n", PANDescriptorList[i].lqi);
+                       */
+               if(max_lqi < PANDescriptorList[i].lqi)
+               {
+                       max_lqi =PANDescriptorList[i].lqi;
+                       best_pan_index = i;
+               }
+       }
+       
+       printfUART("SELECTED cord id %i", PANDescriptorList[best_pan_index].CoordPANId);
+       printfUART("CoordAddress %i", PANDescriptorList[best_pan_index].CoordAddress);
+       printfUART("LogicalChannel %i", PANDescriptorList[best_pan_index].LogicalChannel);
+       printfUART("SuperframeSpec %i", PANDescriptorList[best_pan_index].SuperframeSpec);
+       printfUART("lqi %i\n", PANDescriptorList[best_pan_index].lqi);
+       
+       coordinator_addr[0] = 0x00000001;
+       
+       coordinator_addr[1] = (uint32_t)PANDescriptorList[best_pan_index].CoordAddress;
+       
+       //pan_des = PANDescriptorList[best_pan_index];
+
+       
+       //BUILD the PAN descriptor of the COORDINATOR
+       //assuming that the adress is short
+       pan_des.CoordAddrMode = SHORT_ADDRESS;
+       pan_des.CoordPANId = PANDescriptorList[best_pan_index].CoordAddress;
+       pan_des.CoordAddress0=0x00000000;
+       pan_des.CoordAddress1=0x00000000;
+       pan_des.LogicalChannel=PANDescriptorList[best_pan_index].LogicalChannel;
+       //superframe specification field
+       pan_des.SuperframeSpec = PANDescriptorList[best_pan_index].SuperframeSpec;
+       
+       pan_des.GTSPermit=0x01;
+       pan_des.LinkQuality=0x00;
+       pan_des.TimeStamp=0x000000;
+       pan_des.SecurityUse=0;
+       pan_des.ACLEntry=0x00;
+       pan_des.SecurityFailure=0x00;
+       
+       received_beacon_count=0;
+       go_associate=1;
+       //enables the TimerAsync events, in order to enable the synchronization with the PAN coordinator
+       call MLME_SYNC.request(PANDescriptorList[best_pan_index].LogicalChannel,0);
+       
+       
+       
+       return SUCCESS;
+}
+
+/*****************************************************************************************************/  
+/**************************************MLME-ORPHAN****************************************************/
+/*****************************************************************************************************/ 
+event error_t MLME_ORPHAN.indication(uint32_t OrphanAddress[1], uint8_t SecurityUse, uint8_t ACLEntry)
+{
+
+       uint16_t assigned_address;
+       
+       assigned_address = search_associated_devices(OrphanAddress[0],OrphanAddress[1]);
+       
+       if (assigned_address == 0x0000)
+       {
+               printfUART("not my child\n","");
+       }
+       else
+       {
+               //printfUART("my child\n","");
+               call MLME_ORPHAN.response(OrphanAddress,assigned_address,0x01, 0x00);
+       }
+
+       return SUCCESS;
+}
+
+       uint16_t search_associated_devices(uint32_t ext1, uint32_t ext2)
+       {
+               int i;
+               
+               for(i=0;i<4;i++)
+               {
+                       //printfUART("ad %i %i %i\n",associated_devices[i].extended1,associated_devices[i].extended2,associated_devices[i].assigned_short);
+                       if(associated_devices[i].extended1 == ext1 && associated_devices[i].extended2 == ext2 )
+                       {
+                       
+                               return associated_devices[i].assigned_short;
+                       }
+               
+               }
+               
+               return 0x0000;
+       }
+
+/*****************************************************************************************************/  
+/**************************************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)
+{
+               printfUART("SL\n","");
+               
+               call MLME_SCAN.request(ORPHAN_SCAN,0xFFFFFFFF,7);
+
+
+       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[])
+{
+       
+       if (go_associate==1)
+       {
+               received_beacon_count++;
+               
+               printfUART("bn %i\n", received_beacon_count);
+               
+               if (received_beacon_count==5)
+               {
+                               printfUART("sa \n", "");
+                               go_associate=0;
+                               call MLME_ASSOCIATE.request(pan_des.LogicalChannel,SHORT_ADDRESS,pan_des.CoordPANId,coordinator_addr,0x00,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)
+{
+               //the coordinator device receives the association request and assigns the device with a short address
+               address_poll ++;
+               number_associations++;
+               
+               printfUART("address pool: %i %i\n", address_poll,number_associations);
+               
+               call MLME_ASSOCIATE.response(DeviceAddress,address_poll, CMD_RESP_ASSOCIATION_SUCCESSFUL, 0);
+       return SUCCESS;
+}
+
+event error_t MLME_ASSOCIATE.confirm(uint16_t AssocShortAddress, uint8_t status)
+{
+
+//the end device receives the association confirm and activates the data frame send timer
+       uint8_t v_temp[2];
+       
+       printfUART("MLME_ASSOCIATE.confirm\n", "");
+
+       printfUART("Short: %x\n", AssocShortAddress);
+       printfUART("Status: %i\n", status);
+       
+       if (AssocShortAddress == 0x0000)
+       {
+               //call Timer0.startOneShot(8000);
+       
+       }
+       else
+       {
+               
+               my_short_address = AssocShortAddress;
+                       
+               v_temp[0] = (my_short_address >> 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;
+}
+  
+}
+
index 61dcca8f0226bab6dc8a9d9e4795c5f45466ca90..3d1ca3b4cffa0c1dbf710e0579d6418fa2f11331 100644 (file)
@@ -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 (file)
index 1463b31..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
- * @author Andre Cunha
- */
-#include <Timer.h>
-
-#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 (file)
index 0000000..d4ee637
--- /dev/null
@@ -0,0 +1,60 @@
+/**
+ * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
+ * @author Andre Cunha
+ */
+#include <Timer.h>
+
+#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 (file)
index fd8760b..0000000
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- *
- * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
- * @author Andre Cunha
- *
- */
-#include <Timer.h>
-#include "printfUART.h"
-
-module DataSendExampleM {
-
-       uses interface Boot;
-       uses interface Leds;
-       
-       uses interface Timer<TMilli> as Timer0;
-       
-       uses interface Timer<TMilli> 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 (file)
index 0000000..f9c3835
--- /dev/null
@@ -0,0 +1,315 @@
+/*
+ *
+ * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
+ * @author Andre Cunha
+ *
+ */
+#include <Timer.h>
+#include "printfUART.h"
+
+module DataSendExampleP {
+
+       uses interface Boot;
+       uses interface Leds;
+       
+       uses interface Timer<TMilli> as Timer0;
+       
+       uses interface Timer<TMilli> 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;
+}
+
+  
+}
+
index f9e6b4b5a9c1ca1cc9ae3b97ad0be203a8bf7ebc..24d32aba664a274a954035460b1e33c417d48617 100644 (file)
@@ -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 (file)
index fda840e..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
- * @author Andre Cunha
- */
-#include <Timer.h>
-
-#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 (file)
index 0000000..dd5a929
--- /dev/null
@@ -0,0 +1,61 @@
+/**
+ * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
+ * @author Andre Cunha
+ */
+#include <Timer.h>
+
+#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 (file)
index 5ba5556..0000000
+++ /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 <Timer.h>
-#include "printfUART.h"
-
-module GTSManagementExampleM {
-
-       uses interface Boot;
-       uses interface Leds;
-       
-       uses interface Timer<TMilli> as Timer0;
-       
-       uses interface Timer<TMilli> 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 (file)
index 0000000..ff859d0
--- /dev/null
@@ -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 <Timer.h>
+#include "printfUART.h"
+
+module GTSManagementExampleP {
+
+       uses interface Boot;
+       uses interface Leds;
+       
+       uses interface Timer<TMilli> as Timer0;
+       
+       uses interface Timer<TMilli> 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;
+}
+
+  
+}
+
index 13e57082468e1261b5074103601610e5c8851956..9eab3ac622b2de45e559fde811e3b7af95ceca43 100644 (file)
@@ -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 \
index 4c3b2fcf9ee671969db96043033c80b44e7d7644..f44b8b3cbbce15b5bb31e75770911fc590ad0a0f 100644 (file)
@@ -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 (file)
index 115572b..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
- * @author Andre Cunha
- */
-#include <Timer.h>
-
-#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 (file)
index 0000000..f43915c
--- /dev/null
@@ -0,0 +1,61 @@
+/**
+ * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
+ * @author Andre Cunha
+ */
+#include <Timer.h>
+
+#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 (file)
index 8f25b93..0000000
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- *
- * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
- * @author Andre Cunha
- *
- */
-
-#include <Timer.h>
-#include "printfUART.h"
-
-module SimpleRoutingExampleM {
-
-       uses interface Boot;
-       uses interface Leds;
-       
-       uses interface Timer<TMilli> as Timer0;
-       
-       uses interface Timer<TMilli> 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 (file)
index 0000000..3314907
--- /dev/null
@@ -0,0 +1,308 @@
+/*
+ *
+ * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
+ * @author Andre Cunha
+ *
+ */
+
+#include <Timer.h>
+#include "printfUART.h"
+
+module SimpleRoutingExampleP {
+
+       uses interface Boot;
+       uses interface Leds;
+       
+       uses interface Timer<TMilli> as Timer0;
+       
+       uses interface Timer<TMilli> 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;
+}
+
+  
+}
+
index cf230138f99f0e0ed590ebc9b1c7bab9c9e441d7..efd41b8610e90f3f08256b0ba288f178cf2e5ebf 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
  * @author Andre Cunha
+ * @author Ricardo Severino <rars@isep.ipp.pt>
  *
  */
 #include <Timer.h>
index 801f7a3582640d45adce8aa8599d6b865cd09a84..2755af5a33e25b2932fb1b489c7595912a978ef2 100644 (file)
@@ -3,6 +3,7 @@
 /*
  * @author IPP HURRAY http://www.hurray.isep.ipp.pt/art-wise
  * @author Andre Cunha
+ * @author Ricardo Severino <rars@isep.ipp.pt>
  *
  */
 #include <Timer.h>