 
 #define FIRST_PIN_CTRL 3
 #define FIRST_PIN_LED 6
-#define FIRST_PIN_PWM 9
 #define FIRST_PIN_TOUCH A1
 
 /* 检测到 MAX_LOW_CNT 次小于 MAX_LOW_ANNALOG 的电压后, 认为是面板发出了关的信号 */
 #define MAX_LOW_CNT 16
 #define MAX_LOW_ANNALOG 192
 
-#define CHILD_NUM 1
-
-
-class Child;
+#define CHILD_NUM 3
+
+
+class ChildSwitch;
 
 const char *g_devid = "switch_0";
 

  }

  int check_touch() {
    int i = 0;
    i = analogRead(this->pin_touch);
  
    if (i < MAX_LOW_ANNALOG) {
      ++this->low_cnt;
      if (this->low_cnt >= MAX_LOW_CNT) {
        this->low_cnt = 0;

uint16_t g_body_len = 0;
uint16_t g_recv_len = 0;

ChildSwitch *g_child[CHILD_NUM];

char g_need_report = 1;
unsigned long g_check_ms = 0;


class ChildSwitch {
private:
  int pin_ctrl; /* 控制继电器 */
  int pin_led; /* 控制开关的指示LED */
  int pin_touch; /* 接受来自触摸面板的开关信号  */

  int ctrl_value; /* 当前继电器状态 */

  int touch_value; /* 当前触摸面板认为的开关状态 */
  int low_cnt; /* 触摸面板开关信号为低的计数, 当超过 MAX_LOW_CNT, 认为是关信号(因为面板输出不稳定的脉冲) */

public:
  ChildSwitch(int pin_ctrl, int pin_led, int pin_touch) {
    this->pin_ctrl = pin_ctrl;
    this->pin_led = pin_led;
//    this->pin_pwm = pin_pwm;
    this->pin_touch = pin_touch;

    pinMode(this->pin_ctrl, OUTPUT);
