   if (strcmp(root["cmd"], "switch_set") == 0) {
     int j = min(CHILD_NUM, root["status"].size());
     for (int i = 0; i < j; i++) {
-      uint8_t st = root["status"][i];
-      set_status(i, st);
+      uint8_t value = root["status"][i];
+      if (value) {
+        value = 1;
+      }
+      if (value != g_child[i]->GetCtrl()) {
+        g_child[i]->SetCtrl(value);
+        g_need_report = 1;
+      }
     }
   } else if (strcmp(root["cmd"], "switch_get") == 0) {
     g_need_report = 1;
-  }
-}
-
-void set_status(int index, char st) {
-  if (st != 0)
-    st = 1;
-
-  Serial.print("set:");
-  Serial.println(index);
-  Serial.println((int)st);
-
-  if (g_status[index] != st) {
-    g_status[index] = st;
-  }
-   
-  if (st == 0) {
-    digitalWrite(FIRST_PIN + index, LOW);
-  } else {
-    digitalWrite(FIRST_PIN + index, HIGH);
-  }
-  g_need_report = 1;
-}
-
-void get_all_status() {
-  
-}
-
-void check_status() {
-  char st[CHILD_NUM] = {0};
-  int i = 0;
-
-  for (i = 0; i < CHILD_NUM; i++) {
-    st[i] = g_status[i];
-  }
-
-  get_all_status();
-
-  for (i = 0; i < CHILD_NUM; i++) {
-    if (g_status[i] != st[i]) {
-      g_need_report = 1;
-      break;
-    }
   }
 }
 

uint16_t g_body_len = 0;
uint16_t g_recv_len = 0;

char g_status[CHILD_NUM];

char g_need_report = 1;
unsigned long g_check_ms = 0;

void recv_header() {
  while (Serial.available() >= HEADER_LEN) {

  }
}

void init_child() {
  InitTimersSafe();

  for (int i = 0; i < CHILD_NUM; i++) {
    g_child[i] = new Child(FIRST_PIN_CTRL + i, FIRST_PIN_LED + i, FIRST_PIN_PWM + i, FIRST_PIN_TOUCH + i);
  }
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  //Serial.setTimeout(100);
  Serial.println("setup...");

  init_child();
}

void loop() {
  // put your main code here, to run repeatedly:
  handle_input();

  if (g_need_report) {
    report_status();
    g_need_report = 0;
  }

  for (int i = 0; i < CHILD_NUM; i++) {
    g_child[i]->loop();
  }

  delay(1);
}
