       network.read(rxheader,&payload,sizeof(payload));
       init_transmit=false;
       init_loop_counter=0;
-      txheader.type=rxheader.type;
-      switch (rxheader.type) {
-        case 111: {
-        // Init des Sleeptimers
-          sleeptime=payload.value;
-          break; }
-        case 112: {
-          // radio on (=1) or off (=0) when sleep
-          if (payload.value > 0.5) radiomode = radio_listen; else radiomode=radio_sleep;
-          break; }
-        case 118: {
-          init_finished=true;
-          break; }
-        default: {
-            // nothing right now
-          } 
-      }
-      //returns every message
-      network.write(txheader,&payload,sizeof(payload));
+      action_loop();
     }
     sleep4ms(30);
     init_loop_counter--;
     //just in case of initialisation is interrupted
     if (init_loop_counter < -1000) init_transmit=true;
   }
-  digitalWrite(STATUSLED,STATUSLED_OFF); 
+  digitalWrite(STATUSLED,STATUSLED_OFF);
   network_busy=true;
 }
 

// This node: Use octal numbers starting with "0": "041" is child 4 of node 1
#define NODE 015
// The CE Pin of the Radio module
#define RADIO_CE_PIN 10 
// The CS Pin of the Radio module
#define RADIO_CSN_PIN 9
// The pin of the statusled

// Network uses that radio
RF24Network network(radio);

void action_loop(void) {
    switch (rxheader.type) {
      case 1:
        txheader.type=1;
        //****
        // insert here: payload.value=[result from sensor]
        network.write(txheader,&payload,sizeof(payload));
       break;
      case 2:
        txheader.type=2;
        //****
        // insert here: payload.value=[result from sensor]
        network.write(txheader,&payload,sizeof(payload));
       break;
      case 3:
        txheader.type=3;
        //****
        // insert here: payload.value=[result from sensor]
        network.write(txheader,&payload,sizeof(payload));
       break;
      case 4:
        txheader.type=4;
        //****
        // insert here: payload.value=[result from sensor]
        network.write(txheader,&payload,sizeof(payload));
       break;
      case 5:
        txheader.type=5;
        //****
        // insert here: payload.value=[result from sensor]
        network.write(txheader,&payload,sizeof(payload));
       break;
      case 6:
        txheader.type=6;
        //****
        // insert here: payload.value=[result from sensor]
        network.write(txheader,&payload,sizeof(payload));
       break;
      case 7:
        txheader.type=7;
        //****
        // insert here: payload.value=[result from sensor]
        network.write(txheader,&payload,sizeof(payload));
       break;
      case 8:
        txheader.type=8;
        //****
        // insert here: payload.value=[result from sensor]
        network.write(txheader,&payload,sizeof(payload));
       break;
      case 9:
        txheader.type=9;
        //****
        // insert here: payload.value=[result from sensor]
        network.write(txheader,&payload,sizeof(payload));
       break;
      case 21:
        txheader.type=21;
        //****
        // insert here: action = payload.value
        if ( payload.value > 0.5 ) {
          digitalWrite(7,HIGH);
        } else {
          digitalWrite(7,LOW);
        }
        network.write(txheader,&payload,sizeof(payload));
       break;
      case 101:
      // battery voltage
        payload.value=read_battery_voltage();
        txheader.type=101;
        network.write(txheader,&payload,sizeof(payload));
        break;
      case 111:
      // sleeptimer
        if (payload.value > 0) sleeptime=payload.value;
        radiomode=radio_sleep;
        txheader.type=111;
        network.write(txheader,&payload,sizeof(payload));
        break;
      case 112:
      // radio on (=1) or off (=0) when sleep
        txheader.type=112;
        if ( payload.value > 0.5) radiomode=radio_listen; else radiomode=radio_sleep;
        network.write(txheader,&payload,sizeof(payload));
        break;
      case 118:
      // just in case that there are still some messages inside the network ...
        init_finished=true;
        txheader.type=118;
        network.write(txheader,&payload,sizeof(payload));
        break;
      default:
      // Default: just send the paket back  
        txheader=rxheader;
        network.write(txheader,&payload,sizeof(payload));
    }
}

void setup(void) {
  pinMode(STATUSLED, OUTPUT);
  pinMode(VMESS_OUT, OUTPUT);
  pinMode(VMESS_IN, INPUT);
  analogReference(INTERNAL);
  SPI.begin();
