Index: /firmware/openos/openwsn/02a-MAC/IEEE802154E.c
===================================================================
--- /firmware/openos/openwsn/02a-MAC/IEEE802154E.c	(revision 1159)
+++ /firmware/openos/openwsn/02a-MAC/IEEE802154E.c	(revision 1162)
@@ -11,4 +11,5 @@
 #include "scheduler.h"
 #include "leds.h"
+#include "neighbors.h"
 
 //=========================== variables =======================================
@@ -1354,6 +1355,6 @@
    currentTar           =  TAR;
    currentTaccr0        =  TACCR0;
-   // only resynchronize if I'm not a DAGroot
-   if (idmanager_getIsDAGroot()==FALSE) {
+   // only resynchronize if I'm not a DAGroot and this is my preferred parent
+   if (idmanager_getIsDAGroot()==FALSE && neighbors_isPreferredParent(advFrom)) {
       timeCorrection    =  (int16_t)((int16_t)timeReceived-(int16_t)TsTxOffset);
       newTaccr0         =  TsSlotDuration;
@@ -1381,6 +1382,6 @@
    // record the current states of the TAR and TACCR0 registers
    currentTaccr0        =  TACCR0;
-   // only resynchronize if I'm not a DAGroot
-   if (idmanager_getIsDAGroot()==FALSE) {
+   // only resynchronize if I'm not a DAGroot and this is my preferred parent
+   if (idmanager_getIsDAGroot()==FALSE && neighbors_isPreferredParent(advFrom)) {
       newTaccr0         =  (uint16_t)((int16_t)currentTaccr0-timeCorrection);
       TACCR0            =  newTaccr0;
Index: /firmware/openos/openwsn/02b-RES/neighbors.c
===================================================================
--- /firmware/openos/openwsn/02b-RES/neighbors.c	(revision 1161)
+++ /firmware/openos/openwsn/02b-RES/neighbors.c	(revision 1162)
@@ -177,5 +177,5 @@
 
 bool neighbors_isStableNeighbor(open_addr_t* address) {
-   uint8_t i=0;
+   uint8_t i;
    open_addr_t temp_addr_64b;
    open_addr_t temp_prefix;
@@ -192,4 +192,15 @@
    for (i=0;i<MAXNUMNEIGHBORS;i++) {
       if (isThisRowMatching(&temp_addr_64b,i) && neighbors_vars.neighbors[i].stableNeighbor==TRUE) {
+         return TRUE;
+      }
+   }
+   return FALSE;
+}
+
+__monitor bool neighbors_isPreferredParent(open_addr_t* address) {
+   return TRUE; //poipoipoipoi
+   uint8_t i;
+   for (i=0;i<MAXNUMNEIGHBORS;i++) {
+      if (isThisRowMatching(address,i) && neighbors_vars.neighbors[i].parentPreference==MAXPREFERENCE) {
          return TRUE;
       }
Index: /firmware/openos/openwsn/02b-RES/neighbors.h
===================================================================
--- /firmware/openos/openwsn/02b-RES/neighbors.h	(revision 1154)
+++ /firmware/openos/openwsn/02b-RES/neighbors.h	(revision 1162)
@@ -42,21 +42,22 @@
 //=========================== prototypes ======================================
 
-void          neighbors_init();
-void          neighbors_receiveDIO(OpenQueueEntry_t* msg);
-void          neighbors_updateMyDAGrankAndNeighborPreference();
-void          neighbors_indicateRx(open_addr_t* l2_src,
-                                   int8_t       rssi,
-                                   asn_t        asnTimestamp);
-void          neighbors_indicateTx(open_addr_t* dest,
-                                   uint8_t      numTxAttempts,
-                                   bool         was_finally_acked,
-                                   asn_t        asnTimestamp);
-open_addr_t*  neighbors_KaNeighbor();
-bool          neighbors_isStableNeighbor(open_addr_t* address);
-dagrank_t     neighbors_getMyDAGrank();
-uint8_t       neighbors_getNumNeighbors();
-void          neighbors_getPreferredParent(open_addr_t* addressToWrite,
-                                           uint8_t addr_type);
-bool          debugPrint_neighbors();
+          void          neighbors_init();
+          void          neighbors_receiveDIO(OpenQueueEntry_t* msg);
+          void          neighbors_updateMyDAGrankAndNeighborPreference();
+          void          neighbors_indicateRx(open_addr_t* l2_src,
+                                             int8_t       rssi,
+                                             asn_t        asnTimestamp);
+          void          neighbors_indicateTx(open_addr_t* dest,
+                                             uint8_t      numTxAttempts,
+                                             bool         was_finally_acked,
+                                             asn_t        asnTimestamp);
+          open_addr_t*  neighbors_KaNeighbor();
+          bool          neighbors_isStableNeighbor(open_addr_t* address);
+__monitor bool          neighbors_isPreferredParent(open_addr_t* address);
+          dagrank_t     neighbors_getMyDAGrank();
+          uint8_t       neighbors_getNumNeighbors();
+          void          neighbors_getPreferredParent(open_addr_t* addressToWrite,
+                                                     uint8_t addr_type);
+          bool          debugPrint_neighbors();
 
 /**
