JsBridge 开灯关灯

开灯

function su_kaideng(name, cmds) {
    JsBridge.require("SerialPort").open({
            name: "Com1", //看具体设备
            stop_bits: 1,
            baud_rate: 9600,
            data_bits: 8,
            parity: "none", //odd even
        },
        function (ret) {
            JsBridge.require("SerialPort").write({
                id: ret.id,
                data: '55 00 05 01 01 FF FF 6D A9 AA',
                data_type: "hex",
            });
        }
    );
};

  

  关灯

function su_guandeng(name, cmds) {
  JsBridge.require("SerialPort").open({
          name: "Com1",
          stop_bits: 1,
          baud_rate: 9600,
          data_bits: 8,
          parity: "none", //odd even
      },
      function (ret) {
          JsBridge.require("SerialPort").write({
              id: ret.id,
              data: '55 00 05 01 01 00 00 6D A9 AA',
              data_type: "hex",
          });
      }
  );
};

  

原文地址:https://www.cnblogs.com/xiaoyaolang/p/13784210.html