       
       if (atoi(p.id) == atoi(deviceId) && p.type[0] == 'i') {
         // all sorts of instructions
+        char cmd[4+1];
+        string_copy(cmd, p.data, 0, 3);
+        cmd[4] = '\0';
         DEBUG_PRINTLN("[CONNECTED] command issued");
-        if (strcmp(p.data, "0001") == 0) {
+        if (strcmp(cmd, "0001") == 0) {
           digitalToggle(controlledPin);
           Serial.print("p");
         }

#include <IRremote.h>
#include <string.h>

// #define DEBUG
#include "utils.h"

// Trying to elucidate the way communication works first

          digitalWrite(controlledPin, LOW);
          Serial.print("p");
        }
        else if (strcmp(cmd, "v_up") == 0) {
          // digitalWrite(controlledPin, LOW);
          Serial.print("u");
        }
        else if (strcmp(cmd, "v_dn") == 0) {
          // digitalWrite(controlledPin, LOW);
          Serial.print("d");
        }
