Copy off node 1 to behave node 2

Dependencies:   mbed RF24Network RF24

Revision:
8:5c8bf540ed8e
Parent:
7:1f768ebd2742
Child:
10:a3cd481e7ef3
--- a/main.cpp	Sun May 23 23:41:26 2021 +0000
+++ b/main.cpp	Mon May 24 13:39:15 2021 +0000
@@ -31,7 +31,7 @@
 RF24Network network(radio);
 
 // Address of our node
-const uint16_t this_node = 01;
+const uint16_t this_node = 02;
 
 // Address of the other node
 const uint16_t other_node = 00;
@@ -64,13 +64,16 @@
 
 int main()
 {
+    Init_Spi();
+    Affiche_Display(this_node);
+    
     _node node;
        
     BTN1.mode(PullUp);    // Resist interne Pull up
 //    pc.baud(9600);
     wait_ms(1000);
 
-    pc.printf("mBed RF24Network node : 01\r\n");
+    pc.printf("mBed RF24Network node : %d\r\n",this_node);
     radio.begin();
     network.begin(/*channel*/ 90, /*node address*/ this_node);
     wait_ms(2000);
@@ -119,15 +122,19 @@
             payload_t payload_rx;
             network.read(header_rx,&payload_rx,sizeof(payload_rx));
 
-            pc.printf("Node 01 recu de node %d, data : %d\r\n",payload_rx.src,payload_rx.data);
+            pc.printf("Node %d recu de node %d, data : %d\r\n",this_node,payload_rx.src,payload_rx.data);
             
             node.del = payload_rx.data;
         }
-        if(!BTN1)
+        if(!BTN1 || !BTN2)
         {
+            node.del++;
             payload_t payload_tx;
             payload_tx.src = this_node;
-            payload_tx.dest = 00;
+            if(!BTN1)
+                payload_tx.dest = 00;
+            if(!BTN2)
+                payload_tx.dest = 01;    
             payload_tx.data = node.del%5;
             pc.printf("Envoi...");