/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ "./src/css/lib.css"
/*!*************************!*\
  !*** ./src/css/lib.css ***!
  \*************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
// extracted by mini-css-extract-plugin


/***/ },

/***/ "./src/blocks/block.js"
/*!*****************************!*\
  !*** ./src/blocks/block.js ***!
  \*****************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   bemfa_MQTT_sub_topic_rev_msg: () => (/* binding */ bemfa_MQTT_sub_topic_rev_msg),
/* harmony export */   bemfa_Mqtt_Connect_stat: () => (/* binding */ bemfa_Mqtt_Connect_stat),
/* harmony export */   bemfa_Pub_Topic_payload: () => (/* binding */ bemfa_Pub_Topic_payload),
/* harmony export */   bemfa_Sub_Topic: () => (/* binding */ bemfa_Sub_Topic),
/* harmony export */   bemfa_mqtt_help: () => (/* binding */ bemfa_mqtt_help),
/* harmony export */   bemfa_ota_config_help: () => (/* binding */ bemfa_ota_config_help),
/* harmony export */   bemfa_tcp_Pub_Topic_payload: () => (/* binding */ bemfa_tcp_Pub_Topic_payload),
/* harmony export */   bemfa_tcp_Sub_Topic: () => (/* binding */ bemfa_tcp_Sub_Topic),
/* harmony export */   bemfa_tcp_help: () => (/* binding */ bemfa_tcp_help),
/* harmony export */   bemfa_tcp_sub_topic_rev_msg: () => (/* binding */ bemfa_tcp_sub_topic_rev_msg),
/* harmony export */   bemfa_wechat01: () => (/* binding */ bemfa_wechat01),
/* harmony export */   bemfa_wechat02: () => (/* binding */ bemfa_wechat02),
/* harmony export */   bemfa_wechat03: () => (/* binding */ bemfa_wechat03),
/* harmony export */   bemfa_wechat04: () => (/* binding */ bemfa_wechat04),
/* harmony export */   bemfa_wechat_config_airkiss: () => (/* binding */ bemfa_wechat_config_airkiss),
/* harmony export */   bemfa_wechat_config_airkiss_applus: () => (/* binding */ bemfa_wechat_config_airkiss_applus),
/* harmony export */   bemfa_wechat_config_ap: () => (/* binding */ bemfa_wechat_config_ap),
/* harmony export */   bemfa_wechat_config_applus: () => (/* binding */ bemfa_wechat_config_applus),
/* harmony export */   bemfa_wechat_config_ble: () => (/* binding */ bemfa_wechat_config_ble),
/* harmony export */   bemfa_wechat_config_bleplus: () => (/* binding */ bemfa_wechat_config_bleplus),
/* harmony export */   bemfa_wechat_config_help: () => (/* binding */ bemfa_wechat_config_help),
/* harmony export */   bemfa_wechat_esp32cam_config_help: () => (/* binding */ bemfa_wechat_esp32cam_config_help),
/* harmony export */   bemfa_wechat_help: () => (/* binding */ bemfa_wechat_help),
/* harmony export */   bemfa_wechat_reBegin: () => (/* binding */ bemfa_wechat_reBegin),
/* harmony export */   init_Bemfa_ESP_cam: () => (/* binding */ init_Bemfa_ESP_cam),
/* harmony export */   init_Bemfa_Mqtt: () => (/* binding */ init_Bemfa_Mqtt),
/* harmony export */   init_Bemfa_TCP: () => (/* binding */ init_Bemfa_TCP),
/* harmony export */   init_bemfa_ota_updata: () => (/* binding */ init_bemfa_ota_updata)
/* harmony export */ });
/* harmony import */ var blockly_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! blockly/core */ "blockly/core");
/* harmony import */ var blockly_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(blockly_core__WEBPACK_IMPORTED_MODULE_0__);


const DeviceType = [
    [blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_device_name1, "002"],
    [blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_device_name2, "001"],
    [blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_device_name3, "003"],
    [blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_device_name4, "004"],
    [blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_device_name5, "005"],
    [blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_device_name7, "006"],
    [blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_device_name8, "009"],
    [blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_device_name10, "010"],
    [blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_device_name11, "011"],
    [blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_device_name12, "012"],
    [blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_device_name13, "013"],
    [blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_device_name6, "pic"]
];

const DeviceProto = [["tcp", "3"], ["mqtt", "1"]];

//设置服务器地址与端口号
const init_Bemfa_TCP = {
    init: function () {
        this.setColour(133);
        this.appendDummyInput("")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_Server_Config);
        this.appendValueInput("tcp_Server")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_SERVER_ADDR);
        this.appendValueInput("tcp_port")
            .setCheck(Number)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_SERVER_PORT);
        this.appendValueInput("tcp_client_id")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_Server_uid);//开启模块右侧可连接
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip("");
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

const bemfa_tcp_sub_topic_rev_msg = {
    init: function () {
        this.appendDummyInput()
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_Sub_Topic_Center);
        this.appendStatementInput('DO')
            .setCheck(null);
        this.appendDummyInput()
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_msg_Rev);
        this.appendStatementInput("bemfa_function_tcp_rev_msg")
            .setCheck(null);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(133);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_sub_tip);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

//订阅主题
const bemfa_tcp_Sub_Topic = {
    init: function () {
        this.setColour(133);
        this.appendValueInput("tcp_sub_Topic")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_Sub_Topic);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.MQTT_TEST_TOOLTIP);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

//发布消息
const bemfa_tcp_Pub_Topic_payload = {
    init: function () {
        this.setColour(133);
        this.appendDummyInput("")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_Pub_Msg)
        this.appendValueInput("pub_Topic")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_Topic);
        this.appendValueInput("payload")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_Msg_Payload);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.MQTT_TEST_TOOLTIP);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

//使用帮助
const bemfa_tcp_help = {
    init: function () {
        this.setColour(60);
        this.appendValueInput("tcp_help")
            .setCheck(null)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_help);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.MQTT_TEST_TOOLTIP);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

//设置服务器地址与端口号
const init_Bemfa_Mqtt = {
    init: function () {
        this.setColour(195);
        this.appendDummyInput("")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_Server_Config);
        this.appendValueInput("Server")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_SERVER_ADDR);
        this.appendValueInput("port")
            .setCheck(Number)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_SERVER_PORT);
        this.appendValueInput("client_id")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_clientID);//开启模块右侧可连接
        this.appendValueInput("username")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)  //开启模块右侧可连接
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_UserName);
        this.appendValueInput("password")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)//开启模块右侧可连接
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_User_Passwd);

        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip("");
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

const bemfa_MQTT_sub_topic_rev_msg = {
    init: function () {
        this.appendDummyInput()
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_Sub_Topic_Center);
        this.appendStatementInput('DO')
            .setCheck(null);
        this.appendDummyInput()
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_msg_Rev);
        this.appendStatementInput("function")
            .setCheck(null);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(195);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_sub_tip);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);

    }
};

//订阅主题
const bemfa_Sub_Topic = {
    init: function () {
        this.setColour(195);
        this.appendValueInput("sub_Topic")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_Sub_Topic);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.MQTT_TEST_TOOLTIP);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

//连接状态
const bemfa_Mqtt_Connect_stat = {
    init: function () {
        this.setColour(195);
        this.appendDummyInput("")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_Server_Connect)
        //this.setPreviousStatement(true, null);
        //this.setNextStatement(true, null);
        this.setOutput(true, Boolean);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.MQTT_TEST_TOOLTIP);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

//发布消息
const bemfa_Pub_Topic_payload = {
    init: function () {
        this.setColour(195);
        this.appendDummyInput("")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_Pub_Msg)
        this.appendValueInput("pub_Topic")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_Topic);
        this.appendValueInput("payload")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_Msg_Payload);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.MQTT_TEST_TOOLTIP);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

//使用帮助
const bemfa_mqtt_help = {
    init: function () {
        this.setColour(60);
        this.appendValueInput("mqtt_help")
            .setCheck(null)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_help);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.MQTT_TEST_TOOLTIP);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

const bemfa_wechat01 = {
    init: function () {
        this.appendDummyInput()
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_sendmsg_type1);
        this.appendValueInput("buid")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_Server_uid);
        this.appendValueInput("devicename")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_device_name);
        this.appendValueInput("devicemsg")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_msg);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(15);
        this.setTooltip("");
        this.setHelpUrl("");
    }
};

const bemfa_wechat02 = {
    init: function () {
        this.appendDummyInput()
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_sendmsg_type2);

        this.appendValueInput("buid")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_Server_uid);
        this.appendValueInput("devicename")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_device_name);
        this.appendValueInput("devicemsg")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_msg);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(15);
        this.setTooltip("");
        this.setHelpUrl("");
    }
};

const bemfa_wechat03 = {
    init: function () {
        this.appendDummyInput()
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_commsg_text);

        this.appendValueInput("buid")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_Server_uid);
        this.appendValueInput("devicemsg")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_msg);

        this.appendValueInput("devicetime")
            .setCheck(Boolean)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_show_time);


        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(15);
        this.setTooltip("");
        this.setHelpUrl("");
    }
};


const bemfa_wechat04 = {
    init: function () {
        this.appendDummyInput()
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_commsg_card);

        this.appendValueInput("buid")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_Server_uid);
        this.appendValueInput("msgtitle")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_msg_title);
        this.appendValueInput("devicemsg")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_msg);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(15);
        this.setTooltip("");
        this.setHelpUrl("");
    }
};

//使用帮助
const bemfa_wechat_help = {
    init: function () {
        this.setColour(60);
        this.appendValueInput("wechat_help")
            .setCheck(null)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_help);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.MQTT_TEST_TOOLTIP);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

const bemfa_wechat_config_airkiss = {
    init: function () {
        this.setColour(300);
        this.appendDummyInput("")
            .appendField(new blockly_core__WEBPACK_IMPORTED_MODULE_0__.FieldImage(__webpack_require__(/*! ../media/wechat/airkiss.jpg */ "./src/media/wechat/airkiss.jpg"), 70, 70))
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_airkiss);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip();
        this.setHelpUrl();
    }
};

const bemfa_wechat_config_airkiss_applus = {
    init: function () {
        this.setColour(300);
        this.appendDummyInput("")
            .appendField(new blockly_core__WEBPACK_IMPORTED_MODULE_0__.FieldImage(__webpack_require__(/*! ../media/wechat/airkiss.jpg */ "./src/media/wechat/airkiss.jpg"), 70, 70))
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_airkiss_plus);
        this.appendDummyInput("deviceType")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_topic_Type)
            .appendField(new blockly_core__WEBPACK_IMPORTED_MODULE_0__.FieldDropdown(DeviceType), "deviceType");
        this.appendDummyInput("deviceProto")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_topic_proto)
            .appendField(new blockly_core__WEBPACK_IMPORTED_MODULE_0__.FieldDropdown(DeviceProto), "deviceProto");
        this.appendValueInput("bemfa_wechat_airkiss_get_uid")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_uid);
        this.appendValueInput("bemfa_wechat_airkiss_get_topic")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_topic);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip();
        this.setHelpUrl();
    }
};

const bemfa_wechat_config_ap = {
    init: function () {
        this.setColour(300);
        this.appendDummyInput("")
            .appendField(new blockly_core__WEBPACK_IMPORTED_MODULE_0__.FieldImage(__webpack_require__(/*! ../media/wechat/ap.png */ "./src/media/wechat/ap.png"), 70, 70))
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_ap);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip();
        this.setHelpUrl();
    }
};

const bemfa_wechat_config_applus = {
    init: function () {
        this.setColour(300);
        this.appendDummyInput("")
            .appendField(new blockly_core__WEBPACK_IMPORTED_MODULE_0__.FieldImage(__webpack_require__(/*! ../media/wechat/ap.png */ "./src/media/wechat/ap.png"), 70, 70))
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_applus);
        this.appendDummyInput("deviceType")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_topic_Type)
            .appendField(new blockly_core__WEBPACK_IMPORTED_MODULE_0__.FieldDropdown(DeviceType), "deviceType");
        this.appendDummyInput("deviceProto")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_topic_proto)
            .appendField(new blockly_core__WEBPACK_IMPORTED_MODULE_0__.FieldDropdown(DeviceProto), "deviceProto");
        this.appendValueInput("bemfa_wechat_ap_get_uid")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_uid);
        this.appendValueInput("bemfa_wechat_ap_get_topic")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_topic);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip();
        this.setHelpUrl();
    }
};

//恢复出厂
const bemfa_wechat_config_ble = {
    init: function () {
        this.setColour(300);
        this.appendDummyInput("")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_ble);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip();
        this.setHelpUrl();
    }
};

const bemfa_wechat_config_bleplus = {
    init: function () {
        this.setColour(300);
        this.appendDummyInput("")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_bleplus);
        this.appendDummyInput("deviceType")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_topic_Type)
            .appendField(new blockly_core__WEBPACK_IMPORTED_MODULE_0__.FieldDropdown(DeviceType), "deviceType");
        this.appendDummyInput("deviceProto")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_topic_proto)
            .appendField(new blockly_core__WEBPACK_IMPORTED_MODULE_0__.FieldDropdown(DeviceProto), "deviceProto");
        this.appendValueInput("bemfa_wechat_ble_get_uid")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_uid);
        this.appendValueInput("bemfa_wechat_ble_get_topic")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_cre_config_topic);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip();
        this.setHelpUrl();
    }
};

const bemfa_wechat_reBegin = {
    init: function () {
        this.appendDummyInput()
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_wechat_del_config);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(300);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.MQTT_TEST_TOOLTIP);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

//使用帮助
const bemfa_wechat_config_help = {
    init: function () {
        this.setColour(60);
        this.appendValueInput("bemfa_wechat_config_help")
            .setCheck(null)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_help);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.MQTT_TEST_TOOLTIP);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

//设置服务器地址与端口号
const init_Bemfa_ESP_cam = {
    init: function () {
        this.setColour(345);
        this.appendDummyInput("")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Push_Cam_Esp32cam_pic);
        this.appendValueInput("esp32cam_client_id")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_Server_uid);//开启模块右侧可连接
        this.appendValueInput("esp32cam_topic_id")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_picture_Topic);//开启模块右侧可连接
        this.appendValueInput("esp32cam_falsh_led")
            .setCheck(Boolean)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_picture_FlashLED);
        this.appendValueInput("bemfa_push_cam_wechat_msg")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Push_Cam_Wechat_Msg);//开启模块右侧可连接
        this.appendValueInput("bemfa_push_cam_wechat_cam_msg")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Push_Cam_Wechat_Msg_Cam);//开启模块右侧可连接
        this.appendValueInput("bemfa_push_cam_wechat_cam_path")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Push_Cam_User_Path);//开启模块右侧可连接
        this.appendDummyInput()
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Push_Cam_Esp32cam_pic_ok);
        this.appendStatementInput("bemfa_function_pic_rev")
            .setCheck(null);
        this.setInputsInline(false);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip("");
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

//使用帮助
const bemfa_wechat_esp32cam_config_help = {
    init: function () {
        this.setColour(60);
        this.appendValueInput("bemfa_wechat_esp32cam_config_help")
            .setCheck(null)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_help);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.MQTT_TEST_TOOLTIP);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

// OTA 升级
const init_bemfa_ota_updata = {
    init: function () {
        this.setColour(345);
        this.appendDummyInput("")
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_OTA_update);
        this.appendValueInput("init_bemfa_ota_updata_url")
            .setCheck(String)
            .setAlign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.ALIGN_RIGHT)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_OTA_update_Url);
        this.setInputsInline(false);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip("");
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};

//使用帮助
const bemfa_ota_config_help = {
    init: function () {
        this.setColour(60);
        this.appendValueInput("bemfa_ota_config_help")
            .setCheck(null)
            .appendField(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_tcp_help);
        this.setTooltip(blockly_core__WEBPACK_IMPORTED_MODULE_0__.MQTT_TEST_TOOLTIP);
        this.setHelpUrl(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Msg.Bemfa_Mixly_MQTT_helpurl);
    }
};


/***/ },

/***/ "./src/generators/generator.js"
/*!*************************************!*\
  !*** ./src/generators/generator.js ***!
  \*************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   bemfa_MQTT_sub_topic_rev_msg: () => (/* binding */ bemfa_MQTT_sub_topic_rev_msg),
/* harmony export */   bemfa_Mqtt_Connect_stat: () => (/* binding */ bemfa_Mqtt_Connect_stat),
/* harmony export */   bemfa_Pub_Topic_payload: () => (/* binding */ bemfa_Pub_Topic_payload),
/* harmony export */   bemfa_Sub_Topic: () => (/* binding */ bemfa_Sub_Topic),
/* harmony export */   bemfa_mqtt_help: () => (/* binding */ bemfa_mqtt_help),
/* harmony export */   bemfa_ota_config_help: () => (/* binding */ bemfa_ota_config_help),
/* harmony export */   bemfa_tcp_Pub_Topic_payload: () => (/* binding */ bemfa_tcp_Pub_Topic_payload),
/* harmony export */   bemfa_tcp_Sub_Topic: () => (/* binding */ bemfa_tcp_Sub_Topic),
/* harmony export */   bemfa_tcp_help: () => (/* binding */ bemfa_tcp_help),
/* harmony export */   bemfa_tcp_sub_topic_rev_msg: () => (/* binding */ bemfa_tcp_sub_topic_rev_msg),
/* harmony export */   bemfa_wechat01: () => (/* binding */ bemfa_wechat01),
/* harmony export */   bemfa_wechat02: () => (/* binding */ bemfa_wechat02),
/* harmony export */   bemfa_wechat03: () => (/* binding */ bemfa_wechat03),
/* harmony export */   bemfa_wechat04: () => (/* binding */ bemfa_wechat04),
/* harmony export */   bemfa_wechat_config_airkiss: () => (/* binding */ bemfa_wechat_config_airkiss),
/* harmony export */   bemfa_wechat_config_airkiss_applus: () => (/* binding */ bemfa_wechat_config_airkiss_applus),
/* harmony export */   bemfa_wechat_config_ap: () => (/* binding */ bemfa_wechat_config_ap),
/* harmony export */   bemfa_wechat_config_applus: () => (/* binding */ bemfa_wechat_config_applus),
/* harmony export */   bemfa_wechat_config_ble: () => (/* binding */ bemfa_wechat_config_ble),
/* harmony export */   bemfa_wechat_config_bleplus: () => (/* binding */ bemfa_wechat_config_bleplus),
/* harmony export */   bemfa_wechat_config_help: () => (/* binding */ bemfa_wechat_config_help),
/* harmony export */   bemfa_wechat_esp32cam_config_help: () => (/* binding */ bemfa_wechat_esp32cam_config_help),
/* harmony export */   bemfa_wechat_help: () => (/* binding */ bemfa_wechat_help),
/* harmony export */   bemfa_wechat_reBegin: () => (/* binding */ bemfa_wechat_reBegin),
/* harmony export */   init_Bemfa_ESP_cam: () => (/* binding */ init_Bemfa_ESP_cam),
/* harmony export */   init_Bemfa_Mqtt: () => (/* binding */ init_Bemfa_Mqtt),
/* harmony export */   init_Bemfa_TCP: () => (/* binding */ init_Bemfa_TCP),
/* harmony export */   init_bemfa_ota_updata: () => (/* binding */ init_bemfa_ota_updata)
/* harmony export */ });
/* harmony import */ var mustache__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! mustache */ "./node_modules/mustache/mustache.mjs");
/* harmony import */ var mixly__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! mixly */ "mixly");
/* harmony import */ var mixly__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(mixly__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _templates_func_init_bemfa_tcp_c__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../templates/func-init-bemfa-tcp.c */ "./src/templates/func-init-bemfa-tcp.c");
/* harmony import */ var _templates_func_sub_topic_center_c__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../templates/func-sub-topic-center.c */ "./src/templates/func-sub-topic-center.c");
/* harmony import */ var _templates_func_do_tcp_client_tick_c__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../templates/func-do-tcp-client-tick.c */ "./src/templates/func-do-tcp-client-tick.c");
/* harmony import */ var _templates_func_publish_msg_c__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../templates/func-publish-msg.c */ "./src/templates/func-publish-msg.c");
/* harmony import */ var _templates_func_reconnect_c__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../templates/func-reconnect.c */ "./src/templates/func-reconnect.c");
/* harmony import */ var _templates_func_sub_mqtt_topic_center_c__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../templates/func-sub-mqtt-topic-center.c */ "./src/templates/func-sub-mqtt-topic-center.c");
/* harmony import */ var _templates_func_callback_c__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../templates/func-callback.c */ "./src/templates/func-callback.c");
/* harmony import */ var _templates_block_code_bemfa_wechat01_c__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../templates/block-code-bemfa-wechat01.c */ "./src/templates/block-code-bemfa-wechat01.c");
/* harmony import */ var _templates_block_code_bemfa_wechat02_c__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../templates/block-code-bemfa-wechat02.c */ "./src/templates/block-code-bemfa-wechat02.c");
/* harmony import */ var _templates_block_code_bemfa_wechat03_c__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../templates/block-code-bemfa-wechat03.c */ "./src/templates/block-code-bemfa-wechat03.c");
/* harmony import */ var _templates_block_code_bemfa_wechat04_c__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../templates/block-code-bemfa-wechat04.c */ "./src/templates/block-code-bemfa-wechat04.c");
/* harmony import */ var _templates_func_wechat_config_airkiss_c__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../templates/func-wechat-config-airkiss.c */ "./src/templates/func-wechat-config-airkiss.c");
/* harmony import */ var _templates_func_wechat_config_airkiss_header_c__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../templates/func-wechat-config-airkiss-header.c */ "./src/templates/func-wechat-config-airkiss-header.c");
/* harmony import */ var _templates_func_wechat_config_airkiss_applus_c__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../templates/func-wechat-config-airkiss-applus.c */ "./src/templates/func-wechat-config-airkiss-applus.c");
/* harmony import */ var _templates_func_wechat_config_airkiss_applus_header_c__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../templates/func-wechat-config-airkiss-applus-header.c */ "./src/templates/func-wechat-config-airkiss-applus-header.c");
/* harmony import */ var _templates_func_wechat_config_ap_c__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../templates/func-wechat-config-ap.c */ "./src/templates/func-wechat-config-ap.c");
/* harmony import */ var _templates_block_setup_wechat_config_ap_c__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../templates/block-setup-wechat-config-ap.c */ "./src/templates/block-setup-wechat-config-ap.c");
/* harmony import */ var _templates_func_wechat_config_ap_header_c__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../templates/func-wechat-config-ap-header.c */ "./src/templates/func-wechat-config-ap-header.c");
/* harmony import */ var _templates_func_wechat_config_applus_c__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../templates/func-wechat-config-applus.c */ "./src/templates/func-wechat-config-applus.c");
/* harmony import */ var _templates_block_setup_wechat_config_applus_c__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../templates/block-setup-wechat-config-applus.c */ "./src/templates/block-setup-wechat-config-applus.c");
/* harmony import */ var _templates_func_wechat_config_ble_c__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../templates/func-wechat-config-ble.c */ "./src/templates/func-wechat-config-ble.c");
/* harmony import */ var _templates_func_wechat_config_ble_header_c__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../templates/func-wechat-config-ble-header.c */ "./src/templates/func-wechat-config-ble-header.c");
/* harmony import */ var _templates_block_setup_wechat_config_ble_c__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../templates/block-setup-wechat-config-ble.c */ "./src/templates/block-setup-wechat-config-ble.c");
/* harmony import */ var _templates_func_esp32_cam_c__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../templates/func-esp32-cam.c */ "./src/templates/func-esp32-cam.c");
/* harmony import */ var _templates_block_setup_esp32_cam_c__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../templates/block-setup-esp32-cam.c */ "./src/templates/block-setup-esp32-cam.c");
/* harmony import */ var _templates_func_esp32_cam_header_c__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../templates/func-esp32-cam-header.c */ "./src/templates/func-esp32-cam-header.c");
/* harmony import */ var _templates_func_init_bemfa_ota_update_c__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ../templates/func-init-bemfa-ota-update.c */ "./src/templates/func-init-bemfa-ota-update.c");
/* harmony import */ var _templates_block_code_init_bemfa_ota_update_c__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ../templates/block-code-init-bemfa-ota-update.c */ "./src/templates/block-code-init-bemfa-ota-update.c");



const isESP8266Platform = function () {
    return mixly__WEBPACK_IMPORTED_MODULE_1__.JSFuncs.getPlatform() == 'Arduino ESP8266';
};

const getDeviceTypeName = function (deviceType) {
    if (deviceType == "001") {
        return "插座";
    } else if (deviceType == "002") {
        return "灯";
    } else if (deviceType == "003") {
        return "风扇";
    } else if (deviceType == "004") {
        return "传感器";
    } else if (deviceType == "005") {
        return "空调";
    } else if (deviceType == "006") {
        return "开关";
    } else if (deviceType == "009") {
        return "窗帘";
    } else if (deviceType == "010") {
        return "温控器";
    } else if (deviceType == "011") {
        return "热水器";
    } else if (deviceType == "012") {
        return "电视";
    } else if (deviceType == "013") {
        return "空气净化器";
    } else if (deviceType == "pic") {
        return "图片";
    }
    return "";
};

const normalizeDeviceProto = function (deviceType, deviceProto) {
    if (deviceType == "pic") {
        return 4;
    }
    return deviceProto;
};

const getProtoVersionName = function (deviceProto) {
    if (String(deviceProto) == "3") {
        return "3.1";
    } else if (String(deviceProto) == "4") {
        return "4.0";
    }
    return "1.1";
};

const getOutputVariableName = function (block, inputName) {
    var targetBlock = block.getInputTargetBlock(inputName);
    if (!targetBlock || targetBlock.type != 'variables_get') {
        return "";
    }
    var variableField = targetBlock.getField('VAR');
    if (!variableField) {
        return "";
    }
    var variableName = String(variableField.getText()).trim();
    if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(variableName)) {
        return variableName;
    }
    return "";
};

const declareBleOutputVariable = function (generator, variableName, options = {}) {
    if (!variableName) {
        return;
    }
    if (options.skipDefaultUID && variableName == 'UID') {
        return;
    }
    generator.definitions_['var_declare_bemfa_ble_output_' + variableName] = 'String ' + variableName + ' = "";';
};




const init_Bemfa_TCP = function (_, generator) {
    var tcp_SERVER = generator.valueToCode(this, 'tcp_Server', generator.ORDER_ATOMIC);
    var tcp_PORT = generator.valueToCode(this, 'tcp_port', generator.ORDER_ATOMIC);
    var tcp_ClientId = generator.valueToCode(this, 'tcp_client_id', generator.ORDER_ATOMIC);
    generator.definitions_['function_startTCPClient'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_func_init_bemfa_tcp_c__WEBPACK_IMPORTED_MODULE_2__, {
        server: tcp_SERVER,
        port: tcp_PORT,
        clientId: tcp_ClientId
    });
    return "doWiFiTick();\n";
}

;


const bemfa_tcp_sub_topic_rev_msg = function (_, generator) {
    var branch = generator.statementToCode(this, 'DO');
    branch = branch.replace(/(^\s*)|(\s*$)/g, "");
    branch = branch.replace(/\n/g, '\n  ');
    var funcBranch = generator.statementToCode(this, 'bemfa_function_tcp_rev_msg');
    funcBranch = funcBranch.replace(/(^\s*)|(\s*$)/g, "");
    funcBranch = funcBranch.replace(/\n/g, '\n  ');
    generator.definitions_['function_subTopicCenter'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_func_sub_topic_center_c__WEBPACK_IMPORTED_MODULE_3__, { branch });
    generator.definitions_['function_doTCPClientTick'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_func_do_tcp_client_tick_c__WEBPACK_IMPORTED_MODULE_4__, { funcBranch });
    return "doTCPClientTick();\nsubTopicCenter();\n";
}

// 订阅主题
const bemfa_tcp_Sub_Topic = function (_, generator) {
    var sub_topic = generator.valueToCode(this, 'tcp_sub_Topic', generator.ORDER_ATOMIC);
    var sub_code = 'subTopic(' + sub_topic + ');\n';
    return sub_code;
}

;

// 发布消息
const bemfa_tcp_Pub_Topic_payload = function (_, generator) {
    var pub_topic = generator.valueToCode(this, 'pub_Topic', generator.ORDER_ATOMIC);
    var msg = generator.valueToCode(this, 'payload', generator.ORDER_ATOMIC);
    generator.definitions_['jnclude_tcp_ESP8266WiFi_var_declare_publishMsg'] = _templates_func_publish_msg_c__WEBPACK_IMPORTED_MODULE_5__;
    var pub_code = 'publishMsg(' + pub_topic + ', ' + msg + ');\n';
    return pub_code;
}

// 使用帮助
const bemfa_tcp_help = function (_, generator) {
    generator.setups_['bemfa_setup_tcp_help'] = 'Serial.println("help url: https://cloud.bemfa.com/docs/src/app/mixly.html");';
    return "";
}

;

const init_Bemfa_Mqtt = function (_, generator) {
    var SERVER = generator.valueToCode(this, 'Server', generator.ORDER_ATOMIC);
    var PORT = generator.valueToCode(this, 'port', generator.ORDER_ATOMIC);
    generator.definitions_['include_PubSubClient'] = '#include <PubSubClient.h>';
    var ClientId = generator.valueToCode(this, 'client_id', generator.ORDER_ATOMIC);
    var UserName = generator.valueToCode(this, 'username', generator.ORDER_ATOMIC);
    var PassWord = generator.valueToCode(this, 'password', generator.ORDER_ATOMIC);
    generator.definitions_['var_reConnect'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_func_reconnect_c__WEBPACK_IMPORTED_MODULE_6__, {
        clientId: ClientId,
        userName: UserName,
        password: PassWord
    });
    generator.setups_['setup_initMqtt'] = 'client.setServer(' + SERVER + ', ' + PORT + ');';
    return "reConnect();\nclient.loop();";
}

// 订阅主题
const bemfa_Sub_Topic = function (_, generator) {
    var sub_topic = generator.valueToCode(this, 'sub_Topic', generator.ORDER_ATOMIC);
    var sub_code = 'Serial.print("sub topic:");\nSerial.println(String(' + sub_topic + '));\nclient.subscribe(String(' + sub_topic + ').c_str());\ndelay(15);\n';
    return sub_code;
}

;


const bemfa_MQTT_sub_topic_rev_msg = function (_, generator) {
    generator.setups_['wsetup_initClient'] = 'client.setCallback(callback);';
    var branch = generator.statementToCode(this, 'DO', generator.ORDER_ATOMIC);
    branch = branch.replace(/(^\s*)|(\s*$)/g, "");
    branch = branch.replace(/\n/g, '\n  ');
    generator.definitions_['function_subMqttTopicCenter'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_func_sub_mqtt_topic_center_c__WEBPACK_IMPORTED_MODULE_7__, { branch });
    branch = generator.statementToCode(this, 'function', generator.ORDER_ATOMIC);
    branch = branch.replace(/(^\s*)|(\s*$)/g, "");
    generator.definitions_['function_callback'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_func_callback_c__WEBPACK_IMPORTED_MODULE_8__, { branch });
    return "subMqttTopicCenter();\n";
}

const bemfa_Mqtt_Connect_stat = function (_, generator) {
    var code = 'client.connected()';
    return [code, generator.ORDER_ATOMIC];
}

// 发布消息
const bemfa_Pub_Topic_payload = function (_, generator) {
    var pub_topic = generator.valueToCode(this, 'pub_Topic', generator.ORDER_ATOMIC);
    if (pub_topic.indexOf("\"") < 0) {
        pub_topic = pub_topic + ".c_str()";
    }
    var msg = generator.valueToCode(this, 'payload', generator.ORDER_ATOMIC);
    var pub_code = 'client.publish( String(' + pub_topic + ').c_str(), String(' + msg + ').c_str());\nSerial.println("A message has been published");\n';
    return pub_code;
}

// 使用帮助
const bemfa_mqtt_help = function (_, generator) {
    generator.setups_['bemfa_setup_mqtt_help'] = 'Serial.println("help url: https://cloud.bemfa.com/docs/src/app/mixly.html");';
    return "";
}

;

/***************/
const bemfa_wechat01 = function (_, generator) {
    if (isESP8266Platform()) {
        generator.definitions_['include_ESP8266WiFi'] = '#include <ESP8266WiFi.h>';
        generator.definitions_['include_ESP8266HTTPClient'] = '#include <ESP8266HTTPClient.h>';
    } else {
        generator.definitions_['include_WiFi'] = '#include <WiFi.h>';
        generator.definitions_['include_HTTPClient'] = '#include <HTTPClient.h>';
    }
    generator.definitions_['var_declare_client_bemfa_wechat'] = 'WiFiClient client_bemfa_wechat;';
    generator.definitions_['var_declare_http_bemfa_wechat'] = 'HTTPClient http_bemfa_wechat;';
    generator.definitions_['var_declare_httpCode'] = 'int httpCode = 0;';
    //var value_buid = this.getFieldValue('buid');
    //var value_buid2 = this.getFieldValue('buid');
    var value_buid = generator.valueToCode(this, 'buid', generator.ORDER_ATOMIC);
    var value_devicename = generator.valueToCode(this, 'devicename', generator.ORDER_ATOMIC);
    var value_devicemsg = generator.valueToCode(this, 'devicemsg', generator.ORDER_ATOMIC);
    if (value_buid.substring(0, 1) == "\"") {
        value_buid = value_buid.replace(/^"|"$/g, '')
    } else {
        value_buid = "\"+" + value_buid + "+\"";
    }
    value_buid = value_buid.trim();
    if (value_devicename.substring(0, 1) == "\"") {
        value_devicename = value_devicename.replace(/^"|"$/g, '')
    } else {
        value_devicename = "\"+" + value_devicename + "+\"";
    }
    value_devicename = value_devicename.trim();

    if (value_devicemsg.substring(0, 1) == "\"") {
        value_devicemsg = value_devicemsg.replace(/^"|"$/g, '')
    } else {
        value_devicemsg = "\"+" + value_devicemsg + "+\"";
    }
    value_devicemsg = value_devicemsg.trim();
    if (value_devicemsg == "") {
        value_devicemsg = "空";
    }
    if (value_devicename == "") {
        value_devicename = "空";
    }
    // TODO: Assemble JavaScript into code variable.
    var code = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_block_code_bemfa_wechat01_c__WEBPACK_IMPORTED_MODULE_9__, {
        uid: value_buid,
        name: value_devicename,
        msg: value_devicemsg
    });
    return code;
}

;

const bemfa_wechat02 = function (_, generator) {
    if (isESP8266Platform()) {
        generator.definitions_['include_ESP8266WiFi'] = '#include <ESP8266WiFi.h>';
        generator.definitions_['include_ESP8266HTTPClient'] = '#include <ESP8266HTTPClient.h>';
    } else {
        generator.definitions_['include_WiFi'] = '#include <WiFi.h>';
        generator.definitions_['include_HTTPClient'] = '#include <HTTPClient.h>';
    }
    generator.definitions_['var_declare_client_bemfa_wechat'] = 'WiFiClient client_bemfa_wechat;';
    generator.definitions_['var_declare_http_bemfa_wechat'] = 'HTTPClient http_bemfa_wechat;';
    generator.definitions_['var_declare_httpCode'] = 'int httpCode = 0;';
    var value_buid = generator.valueToCode(this, 'buid', generator.ORDER_ATOMIC);
    var value_devicename = generator.valueToCode(this, 'devicename', generator.ORDER_ATOMIC);
    var value_devicemsg = generator.valueToCode(this, 'devicemsg', generator.ORDER_ATOMIC);
    if (value_buid.substring(0, 1) == "\"") {
        value_buid = value_buid.replace(/^"|"$/g, '')
    } else {
        value_buid = "\"+" + value_buid + "+\"";
    }
    value_buid = value_buid.trim();

    if (value_devicename.substring(0, 1) == "\"") {
        value_devicename = value_devicename.replace(/^"|"$/g, '')
    } else {
        value_devicename = "\"+" + value_devicename + "+\"";
    }
    value_devicename = value_devicename.trim();

    if (value_devicemsg.substring(0, 1) == "\"") {
        value_devicemsg = value_devicemsg.replace(/^"|"$/g, '')
    } else {
        value_devicemsg = "\"+" + value_devicemsg + "+\"";
    }
    value_devicemsg = value_devicemsg.trim();

    if (value_devicemsg == "") {
        value_devicemsg = "空";
    }
    if (value_devicename == "") {
        value_devicename = "空";
    }
    // TODO: Assemble JavaScript into code variable.
    var code = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_block_code_bemfa_wechat02_c__WEBPACK_IMPORTED_MODULE_10__, {
        uid: value_buid,
        name: value_devicename,
        msg: value_devicemsg
    });
    return code;
}

;

const bemfa_wechat03 = function (_, generator) {
    if (isESP8266Platform()) {
        generator.definitions_['include_ESP8266WiFi'] = '#include <ESP8266WiFi.h>';
        generator.definitions_['include_ESP8266HTTPClient'] = '#include <ESP8266HTTPClient.h>';
    } else {
        generator.definitions_['include_WiFi'] = '#include <WiFi.h>';
        generator.definitions_['include_HTTPClient'] = '#include <HTTPClient.h>';
    }
    generator.definitions_['var_declare_client_bemfa_wechat'] = 'WiFiClient client_bemfa_wechat;';
    generator.definitions_['var_declare_http_bemfa_wechat'] = 'HTTPClient http_bemfa_wechat;';
    var value_buid = generator.valueToCode(this, 'buid', generator.ORDER_ATOMIC);
    var value_devicetime = generator.valueToCode(this, 'devicetime', generator.ORDER_ATOMIC);
    var value_devicemsg = generator.valueToCode(this, 'devicemsg', generator.ORDER_ATOMIC);
    var value_deviceFlag = value_devicetime == "false" ? 0 : 1;

    if (value_buid.substring(0, 1) == "\"") {
        value_buid = value_buid.replace(/^"|"$/g, '')
    } else {
        value_buid = "\"+" + value_buid + "+\"";
    }
    value_buid = value_buid.trim();

    if (value_devicemsg.substring(0, 1) == "\"") {
        value_devicemsg = value_devicemsg.replace(/^"|"$/g, '')
    } else {
        value_devicemsg = "\"+" + value_devicemsg + "+\"";
    }
    value_devicemsg = value_devicemsg.trim();

    if (value_devicemsg == "") {
        value_devicemsg = "空";
    }
    // TODO: Assemble JavaScript into code variable.
    var code = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_block_code_bemfa_wechat03_c__WEBPACK_IMPORTED_MODULE_11__, {
        uid: value_buid,
        msg: value_devicemsg,
        time: value_deviceFlag
    });
    return code;
}

;

const bemfa_wechat04 = function (_, generator) {
    if (isESP8266Platform()) {
        generator.definitions_['include_ESP8266WiFi'] = '#include <ESP8266WiFi.h>';
        generator.definitions_['include_ESP8266HTTPClient'] = '#include <ESP8266HTTPClient.h>';
    } else {
        generator.definitions_['include_WiFi'] = '#include <WiFi.h>';
        generator.definitions_['include_HTTPClient'] = '#include <HTTPClient.h>';
    }
    generator.definitions_['var_declare_client_bemfa_wechat'] = 'WiFiClient client_bemfa_wechat;';
    generator.definitions_['var_declare_http_bemfa_wechat'] = 'HTTPClient http_bemfa_wechat;';
    generator.definitions_['var_declare_httpCode'] = 'int httpCode = 0;';
    var value_buid = generator.valueToCode(this, 'buid', generator.ORDER_ATOMIC);
    var value_msgtitle = generator.valueToCode(this, 'msgtitle', generator.ORDER_ATOMIC);
    var value_devicemsg = generator.valueToCode(this, 'devicemsg', generator.ORDER_ATOMIC);
    if (value_buid.substring(0, 1) == "\"") {
        value_buid = value_buid.replace(/^"|"$/g, '')
    } else {
        value_buid = "\"+" + value_buid + "+\"";
    }
    value_buid = value_buid.trim();

    if (value_msgtitle.substring(0, 1) == "\"") {
        value_msgtitle = value_msgtitle.replace(/^"|"$/g, '')
    } else {
        value_msgtitle = "\"+" + value_msgtitle + "+\"";
    }
    value_msgtitle = value_msgtitle.trim();

    if (value_devicemsg.substring(0, 1) == "\"") {
        value_devicemsg = value_devicemsg.replace(/^"|"$/g, '')
    } else {
        value_devicemsg = "\"+" + value_devicemsg + "+\"";
    }
    value_devicemsg = value_devicemsg.trim();

    if (value_devicemsg == "") {
        value_devicemsg = "空";
    }
    if (value_msgtitle == "") {
        value_msgtitle = "空";
    }
    // TODO: Assemble JavaScript into code variable.
    var code = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_block_code_bemfa_wechat04_c__WEBPACK_IMPORTED_MODULE_12__, {
        uid: value_buid,
        title: value_msgtitle,
        msg: value_devicemsg
    });
    return code;
}

// 使用帮助
const bemfa_wechat_help = function (_, generator) {
    generator.setups_['bemfa_setup_wechat_help'] = 'Serial.println("help url: https://cloud.bemfa.com/docs/src/app/mixly.html");';
    return "";
}

;


// airkiss
const bemfa_wechat_config_airkiss = function (_, generator) {
    generator.definitions_['include_wechat_config_airkiss_headers'] = _templates_func_wechat_config_airkiss_header_c__WEBPACK_IMPORTED_MODULE_14__;
    generator.definitions_['var_declare_bemfa_wechat_config_airkiss'] = _templates_func_wechat_config_airkiss_c__WEBPACK_IMPORTED_MODULE_13__;
    generator.setups_['bemfa_setup_wechat_wifi_config'] = 'loadConfig();\n'
        + '  waitKey();\n'
        + '  initWiFi();\n';
    return "";
}

;


//airkiss
const bemfa_wechat_config_airkiss_applus = function (_, generator) {
    var deviceProto = this.getFieldValue('deviceProto');
    var deviceType = this.getFieldValue('deviceType');
    // var deviceTypeName = '';
    // if (deviceType == "001") {
    //     deviceTypeName = "插座";
    // } else if (deviceType == "002") {
    //     deviceTypeName = "灯";
    // } else if (deviceType == "003") {
    //     deviceTypeName = "风扇";
    // } else if (deviceType == "004") {
    //     deviceTypeName = "传感器";
    // } else if (deviceType == "005") {
    //     deviceTypeName = "空调";
    // } else if (deviceType == "pic") {
    //     deviceProto = 5;
    //     deviceTypeName = "图片";
    // }
    // if (deviceType == 5) {
    //     deviceTypeName = "图片";
    // }
    // var apuid = generator.valueToCode(this, 'bemfa_wechat_ap_get_uid', generator.ORDER_ATOMIC);
    // var aptopic = generator.valueToCode(this, 'bemfa_wechat_ap_get_topic', generator.ORDER_ATOMIC);
    generator.definitions_['include_wechat_config_airkiss_applus_headers'] = _templates_func_wechat_config_airkiss_applus_header_c__WEBPACK_IMPORTED_MODULE_16__;
    generator.definitions_['include_declare_bemfa_wechat_config_airkiss_plus'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_func_wechat_config_airkiss_applus_c__WEBPACK_IMPORTED_MODULE_15__, {
        deviceType,
        version: deviceProto
    });
    generator.setups_['setup_wechat_wifi_airkiss_config_plus'] = 'String topic = WiFi.macAddress().substring(8);//取mac地址做主题用\n'
        + '  topic.replace(":", "");//去掉:号\n'
        + '  loadConfig();//加载存储的数据\n'
        + '  waitKey();//检查是否需要airkiss配网\n'
        + '  initWiFi();//初始化wifi信息，并连接路由器网络\n'
        + '  getUid(topic);//获取密钥\n';
    return "";
}

;



//ap
const bemfa_wechat_config_ap = function (_, generator) {
    generator.definitions_['include_wechat_config_ap_headers'] = _templates_func_wechat_config_ap_header_c__WEBPACK_IMPORTED_MODULE_19__;
    generator.definitions_['var_bemfa_wechat_config_airkiss'] = _templates_func_wechat_config_ap_c__WEBPACK_IMPORTED_MODULE_17__;
    generator.setups_['bemfa_setup_wechat_wifi_apconfig'] = _templates_block_setup_wechat_config_ap_c__WEBPACK_IMPORTED_MODULE_18__.replace(/\n/g, '\n  ');
    return "";
}

;





//ap plus
const bemfa_wechat_config_applus = function (_, generator) {
    var deviceProto = this.getFieldValue('deviceProto');
    var deviceType = this.getFieldValue('deviceType');
    var deviceTypeName = '';
    if (deviceType == "001") {
        deviceTypeName = "插座";
    } else if (deviceType == "002") {
        deviceTypeName = "灯";
    } else if (deviceType == "003") {
        deviceTypeName = "风扇";
    } else if (deviceType == "004") {
        deviceTypeName = "传感器";
    } else if (deviceType == "005") {
        deviceTypeName = "空调";
    } else if (deviceType == "006") {
        deviceTypeName = "开关";
    } else if (deviceType == "009") {
        deviceTypeName = "窗帘";
    } else if (deviceType == "010") {
        deviceTypeName = "温控器";
    } else if (deviceType == "011") {
        deviceTypeName = "热水器";
    } else if (deviceType == "012") {
        deviceTypeName = "电视";
    } else if (deviceType == "013") {
        deviceTypeName = "空气净化器";
    } else if (deviceType == "pic") {
        deviceProto = 4;
        deviceTypeName = "图片";
    }
    // var apuid = generator.valueToCode(this, 'bemfa_wechat_ap_get_uid', generator.ORDER_ATOMIC);
    // var aptopic = generator.valueToCode(this, 'bemfa_wechat_ap_get_topic', generator.ORDER_ATOMIC);
    deviceTypeName = getDeviceTypeName(deviceType);
    deviceProto = normalizeDeviceProto(deviceType, deviceProto);
    generator.definitions_['include_wechat_config_ap_headers'] = _templates_func_wechat_config_ap_header_c__WEBPACK_IMPORTED_MODULE_19__;
    generator.definitions_['var_declare_bemfa_wechat_config_airkiss'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_func_wechat_config_applus_c__WEBPACK_IMPORTED_MODULE_20__, {
        deviceType,
        deviceName: deviceTypeName,
        protoVersion: deviceProto
    });
    generator.setups_['include_setup_wechat_wifi_apconfig'] = _templates_block_setup_wechat_config_applus_c__WEBPACK_IMPORTED_MODULE_21__.replace(/\n/g, '\n  ');
    return "";
}

// 恢复出厂
const bemfa_wechat_config_ble = function (_, generator) {
    if (isESP8266Platform()) {
        generator.definitions_['include_wechat_config_ble_unsupported'] = '#error "Bemfa BLE provisioning only supports ESP32."';
        return "";
    }
    generator.definitions_['include_wechat_config_ble_headers'] = _templates_func_wechat_config_ble_header_c__WEBPACK_IMPORTED_MODULE_23__;
    generator.definitions_['var_declare_bemfa_wechat_config_ble'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_func_wechat_config_ble_c__WEBPACK_IMPORTED_MODULE_22__, {
        createTopic: "false",
        unCreate: 1,
        deviceType: "999",
        deviceName: "",
        protoVersion: 3,
        protoVersionName: "3.1"
    });
    generator.setups_['setup_wechat_wifi_bleconfig'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_block_setup_wechat_config_ble_c__WEBPACK_IMPORTED_MODULE_24__, {
        assignOutput: ""
    }).replace(/\n/g, '\n  ');
    return "";
}

const bemfa_wechat_config_bleplus = function (_, generator) {
    if (isESP8266Platform()) {
        generator.definitions_['include_wechat_config_ble_unsupported'] = '#error "Bemfa BLE provisioning only supports ESP32."';
        return "";
    }
    var deviceProto = this.getFieldValue('deviceProto');
    var deviceType = this.getFieldValue('deviceType');
    var deviceTypeName = getDeviceTypeName(deviceType);
    deviceProto = normalizeDeviceProto(deviceType, deviceProto);
    generator.definitions_['include_wechat_config_ble_headers'] = _templates_func_wechat_config_ble_header_c__WEBPACK_IMPORTED_MODULE_23__;
    generator.definitions_['var_declare_bemfa_wechat_config_ble'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_func_wechat_config_ble_c__WEBPACK_IMPORTED_MODULE_22__, {
        createTopic: "true",
        unCreate: 0,
        deviceType,
        deviceName: deviceTypeName,
        protoVersion: deviceProto,
        protoVersionName: getProtoVersionName(deviceProto)
    });
    generator.valueToCode(this, 'bemfa_wechat_ble_get_uid', generator.ORDER_ATOMIC);
    generator.valueToCode(this, 'bemfa_wechat_ble_get_topic', generator.ORDER_ATOMIC);
    var bleUidVarName = getOutputVariableName(this, 'bemfa_wechat_ble_get_uid');
    var bleTopicVarName = getOutputVariableName(this, 'bemfa_wechat_ble_get_topic');
    declareBleOutputVariable(generator, bleUidVarName, { skipDefaultUID: true });
    declareBleOutputVariable(generator, bleTopicVarName);
    var assignOutput = "";
    if (bleUidVarName) {
        assignOutput += bleUidVarName + " = bemfaBleUID;\n";
    }
    if (bleTopicVarName) {
        assignOutput += bleTopicVarName + " = bemfaBleTopic;\n";
    }
    generator.setups_['setup_wechat_wifi_bleconfig'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_block_setup_wechat_config_ble_c__WEBPACK_IMPORTED_MODULE_24__, {
        assignOutput
    }).replace(/\n/g, '\n  ');
    return "";
}

const bemfa_wechat_reBegin = function () {
    var code = 'Serial.println(" Restore Factory....... ");\n'
        + 'config.magic = 0x00;\n'
        + 'strcpy(config.stassid, "");\n'
        + 'strcpy(config.stapsw, "");\n'
        + 'strcpy(config.cuid, "");\n'
        + 'strcpy(config.ctopic, "");\n'
        + 'config.magic = 0x00;\n'
        + 'saveConfig();\n'
        + 'delayRestart(1);\n'
    return code;
}

// 使用帮助
const bemfa_wechat_config_help = function (_, generator) {
    generator.setups_['bemfa_setup_wechat_help'] = 'Serial.println("help url: https://cloud.bemfa.com/docs/src/app/mixly.html");';
    return "";
}

;



//esp32 拍照上传
const init_Bemfa_ESP_cam = function (_, generator) {
    var bemfa_uid = generator.valueToCode(this, 'esp32cam_client_id', generator.ORDER_ATOMIC);
    var bemfa_topic_id = generator.valueToCode(this, 'esp32cam_topic_id', generator.ORDER_ATOMIC);
    var bemfa_wechat_msg = generator.valueToCode(this, 'bemfa_push_cam_wechat_msg', generator.ORDER_ATOMIC);
    var bemfa_wechat_msg_cam = generator.valueToCode(this, 'bemfa_push_cam_wechat_cam_msg', generator.ORDER_ATOMIC);
    var bemfa_wechat_cam_path = generator.valueToCode(this, 'bemfa_push_cam_wechat_cam_path', generator.ORDER_ATOMIC);
    var value_esp32cam_falsh_led = generator.valueToCode(this, 'esp32cam_falsh_led', generator.ORDER_ATOMIC);

    if (bemfa_wechat_msg == '"空"') {
        bemfa_wechat_msg = '""';
    }
    if (bemfa_wechat_msg_cam == '"空"') {
        bemfa_wechat_msg_cam = '""';
    }
    if (bemfa_wechat_cam_path == '"空"') {
        bemfa_wechat_cam_path = '""';
    }

    if (bemfa_uid.substring(0, 1) != "\"") {
        bemfa_uid = bemfa_uid + '.c_str()'
    }
    if (bemfa_topic_id.substring(0, 1) != "\"") {
        bemfa_topic_id = bemfa_topic_id + '.c_str()'
    }
    if (bemfa_wechat_msg.substring(0, 1) != "\"") {
        bemfa_wechat_msg = bemfa_wechat_msg + '.c_str()'
    }
    if (bemfa_wechat_msg_cam.substring(0, 1) != "\"") {
        bemfa_wechat_msg_cam = bemfa_wechat_msg_cam + '.c_str()'
    }
    if (bemfa_wechat_cam_path.substring(0, 1) != "\"") {
        bemfa_wechat_cam_path = bemfa_wechat_cam_path + '.c_str()'
    }
    var funcBranch = generator.statementToCode(this, 'bemfa_function_pic_rev');
    funcBranch = funcBranch.replace(/(^\s*)|(\s*$)/g, "");
    generator.definitions_['include_esp32_cam_headers'] = _templates_func_esp32_cam_header_c__WEBPACK_IMPORTED_MODULE_27__;
    generator.definitions_['var_declare_bemfa_cam_pic'] = mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_func_esp32_cam_c__WEBPACK_IMPORTED_MODULE_25__, {
        flashLed: value_esp32cam_falsh_led,
        uid: bemfa_uid,
        topicId: bemfa_topic_id,
        wechatMsg: bemfa_wechat_msg,
        wechatMsgCam: bemfa_wechat_msg_cam,
        wechatCamPath: bemfa_wechat_cam_path,
        funcBranch
    });
    generator.setups_['bemfa_setup_bemfa_cam_pic'] = _templates_block_setup_esp32_cam_c__WEBPACK_IMPORTED_MODULE_26__;
    return "take_send_photo();";
}


//使用帮助
const bemfa_wechat_esp32cam_config_help = function (_, generator) {
    generator.setups_['bemfa_wechat_esp32cam_config_help'] = 'Serial.println("help url: https://cloud.bemfa.com/docs/src/app/mixly.html");';
    return "";
}

;


//使用帮助
const init_bemfa_ota_updata = function (_, generator) {
    // var type = this.getFieldValue('type');
    var otaUrl = generator.valueToCode(this, 'init_bemfa_ota_updata_url', generator.ORDER_ATOMIC);
    generator.definitions_['var_declear_ESP8266WiFiota001'] = _templates_func_init_bemfa_ota_update_c__WEBPACK_IMPORTED_MODULE_28__;
    return mustache__WEBPACK_IMPORTED_MODULE_0__["default"].render(_templates_block_code_init_bemfa_ota_update_c__WEBPACK_IMPORTED_MODULE_29__, { otaUrl });
}

// 使用帮助
const bemfa_ota_config_help = function (_, generator) {
    generator.setups_['bemfa_ota_config_help'] = 'Serial.println("help url: https://cloud.bemfa.com/docs/src/app/mixly.html");';
    return "";
}


/***/ },

/***/ "./src/language/en.js"
/*!****************************!*\
  !*** ./src/language/en.js ***!
  \****************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   EnCatgories: () => (/* binding */ EnCatgories),
/* harmony export */   EnMsg: () => (/* binding */ EnMsg)
/* harmony export */ });
const EnMsg = {};

EnMsg.Bemfa_Mixly_MQTT_helpurl='https://cloud.bemfa.com/docs/';
EnMsg.Bemfa_Mixly_Board_Type='board type';
EnMsg.Bemfa_Mixly_MQTT_Server_Config='mqtt config';
EnMsg.Bemfa_Mixly_MQTT_SERVER_ADDR='server address';
EnMsg.Bemfa_Mixly_MQTT_SERVER_PORT='server port';
EnMsg.Bemfa_Mixly_MQTT_clientID='clientID';
EnMsg.Bemfa_Mixly_MQTT_UserName='username';
EnMsg.Bemfa_Mixly_MQTT_User_Passwd='password';
EnMsg.Bemfa_Mixly_MQTT_Sub_Topic_Center='Subscription Management';
EnMsg.Bemfa_Mixly_MQTT_Sub_Topic='subscribe topic';
EnMsg.Bemfa_Mixly_MQTT_msg_Rev='Message receiving';
EnMsg.Bemfa_Mixly_MQTT_Server_Connect='Is the server connected';
EnMsg.Bemfa_Mixly_MQTT_Pub_Msg='publish msg';
EnMsg.Bemfa_Mixly_MQTT_Topic='topic';
EnMsg.Bemfa_Mixly_MQTT_Msg_Payload='msg';
EnMsg.Bemfa_Mixly_MQTT_sub_tip='Support for subscribing to multiple topics';
EnMsg.Bemfa_Mixly_tcp_Server_Config='tcp service configuration';
EnMsg.Bemfa_Mixly_tcp_Server_uid ='Private key';
EnMsg.Bemfa_Mixly_tcp_help ='Use tutorial';

EnMsg.Bemfa_Mixly_wechat_msg ='Message content';
EnMsg.Bemfa_Mixly_wechat_msg_title ='Message title';
EnMsg.Bemfa_Mixly_wechat_commsg_card ='Corporate Card Message';
EnMsg.Bemfa_Mixly_wechat_commsg_text ='Corporate Text Message';
EnMsg.Bemfa_Mixly_wechat_show_time ='display time';
EnMsg.Bemfa_Mixly_wechat_device_name ='Device name';
EnMsg.Bemfa_Mixly_wechat_sendmsg_type2 ='Send reminder message';
EnMsg.Bemfa_Mixly_wechat_sendmsg_type1 ='Send alert message';

EnMsg.Bemfa_Mixly_wechat_del_config ='Clear distribution network information';
EnMsg.Bemfa_Mixly_wechat_cre_config_topic ='Generate topic';
EnMsg.Bemfa_Mixly_wechat_cre_config_uid ='Generate uid';
EnMsg.Bemfa_Mixly_wechat_cre_config_topic_proto ='Topic agreement';
EnMsg.Bemfa_Mixly_wechat_cre_config_topic_Type ='Topic type';
EnMsg.Bemfa_Mixly_wechat_cre_config_applus ='ap one-key distribution network+';
EnMsg.Bemfa_Mixly_wechat_cre_config_ap ='ap one-key distribution network';
EnMsg.Bemfa_Mixly_wechat_cre_config_airkiss ='One-click distribution network';
EnMsg.Bemfa_Mixly_wechat_cre_config_ble ='Bluetooth provisioning';
EnMsg.Bemfa_Mixly_wechat_cre_config_bleplus ='Bluetooth provisioning+';

EnMsg.Bemfa_Mixly_wechat_cre_config_device_name1 ='light';
EnMsg.Bemfa_Mixly_wechat_cre_config_device_name2 ='outlet';
EnMsg.Bemfa_Mixly_wechat_cre_config_device_name3 ='fan';
EnMsg.Bemfa_Mixly_wechat_cre_config_device_name4 ='sensor';
EnMsg.Bemfa_Mixly_wechat_cre_config_device_name5 ='air conditioner';
EnMsg.Bemfa_Mixly_wechat_cre_config_device_name7 ='switch';
EnMsg.Bemfa_Mixly_wechat_cre_config_device_name8 ='curtain';

EnMsg.Bemfa_Mixly_wechat_cre_config_device_name10 ='thermostat';
EnMsg.Bemfa_Mixly_wechat_cre_config_device_name11 ='water heater';
EnMsg.Bemfa_Mixly_wechat_cre_config_device_name12 ='TV';
EnMsg.Bemfa_Mixly_wechat_cre_config_device_name13 ='air purifier';

EnMsg.Bemfa_Mixly_wechat_cre_config_airkiss_plus ='One-click distribution network+';
EnMsg.Bemfa_Mixly_picture_Topic='Picture topic';
EnMsg.Bemfa_Push_Cam_Wechat_Msg='WeChat message';
EnMsg.Bemfa_Mixly_picture_FlashLED='Flash LED';
EnMsg.Bemfa_Push_Cam_Wechat_Msg_Cam='Enterprise WeChat Message';
EnMsg.Bemfa_Push_Cam_User_Path='Set image link';
EnMsg.Bemfa_Mixly_wechat_cre_config_device_name6 ='picture';
EnMsg.Bemfa_Push_Cam_User_Path_Rev='Generate image link';

EnMsg.Bemfa_Push_Cam_Esp32cam_pic='esp32cam photo upload';
EnMsg.Bemfa_Push_Cam_Esp32cam_pic_ok='Uploaded successfully';

EnMsg.Bemfa_OTA_update='Remote OTA upgrade';
EnMsg.Bemfa_OTA_update_Url='Firmware address';

const EnCatgories = {};


/***/ },

/***/ "./src/language/loader.js"
/*!********************************!*\
  !*** ./src/language/loader.js ***!
  \********************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony import */ var blockly_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! blockly/core */ "blockly/core");
/* harmony import */ var blockly_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(blockly_core__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _zh_hans__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./zh-hans */ "./src/language/zh-hans.js");
/* harmony import */ var _zh_hant__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./zh-hant */ "./src/language/zh-hant.js");
/* harmony import */ var _en__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./en */ "./src/language/en.js");





// 载入语言文件
Object.assign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Lang.ZhHans, _zh_hans__WEBPACK_IMPORTED_MODULE_1__.ZhHansMsg);
Object.assign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Lang.ZhHant, _zh_hant__WEBPACK_IMPORTED_MODULE_2__.ZhHantMsg);
Object.assign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Lang.En, _en__WEBPACK_IMPORTED_MODULE_3__.EnMsg);
Object.assign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Lang.ZhHans.MSG, _zh_hans__WEBPACK_IMPORTED_MODULE_1__.ZhHansCatgories);
Object.assign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Lang.ZhHant.MSG, _zh_hant__WEBPACK_IMPORTED_MODULE_2__.ZhHantCatgories);
Object.assign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Lang.En.MSG, _en__WEBPACK_IMPORTED_MODULE_3__.EnCatgories);

/***/ },

/***/ "./src/language/zh-hans.js"
/*!*********************************!*\
  !*** ./src/language/zh-hans.js ***!
  \*********************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   ZhHansCatgories: () => (/* binding */ ZhHansCatgories),
/* harmony export */   ZhHansMsg: () => (/* binding */ ZhHansMsg)
/* harmony export */ });
const ZhHansMsg = {};

ZhHansMsg.Bemfa_Mixly_Board_Type='开发板类型';
ZhHansMsg.Bemfa_Mixly_MQTT_Server_Config='mqtt服务配置';
ZhHansMsg.Bemfa_Mixly_MQTT_SERVER_ADDR='服务器地址';
ZhHansMsg.Bemfa_Mixly_MQTT_SERVER_PORT='端口号';
ZhHansMsg.Bemfa_Mixly_MQTT_clientID='clientID';
ZhHansMsg.Bemfa_Mixly_MQTT_UserName='用户名';
ZhHansMsg.Bemfa_Mixly_MQTT_User_Passwd='密码';
ZhHansMsg.Bemfa_Mixly_MQTT_Sub_Topic_Center='订阅管理';
ZhHansMsg.Bemfa_Mixly_MQTT_Sub_Topic ='订阅主题';
ZhHansMsg.Bemfa_Mixly_MQTT_msg_Rev='消息接收';
ZhHansMsg.Bemfa_Mixly_MQTT_Server_Connect='服务器是否连接';
ZhHansMsg.Bemfa_Mixly_MQTT_Pub_Msg='发布消息';
ZhHansMsg.Bemfa_Mixly_MQTT_Topic='主题';
ZhHansMsg.Bemfa_Mixly_MQTT_Msg_Payload='消息';

ZhHansMsg.Bemfa_Mixly_MQTT_sub_tip='支持订阅多个主题';
ZhHansMsg.Bemfa_Mixly_MQTT_helpurl='https://cloud.bemfa.com/docs/';

ZhHansMsg.Bemfa_Mixly_tcp_Server_Config='tcp服务配置';

ZhHansMsg.Bemfa_Mixly_tcp_Server_uid ='私钥';
ZhHansMsg.Bemfa_Mixly_tcp_help ='使用教程';

ZhHansMsg.Bemfa_Mixly_wechat_msg ='消息内容';
ZhHansMsg.Bemfa_Mixly_wechat_msg_title ='消息标题';
ZhHansMsg.Bemfa_Mixly_wechat_commsg_card ='企业卡片消息';
ZhHansMsg.Bemfa_Mixly_wechat_commsg_text ='企业文本消息';
ZhHansMsg.Bemfa_Mixly_wechat_show_time ='显示时间';
ZhHansMsg.Bemfa_Mixly_wechat_device_name ='设备名称';

ZhHansMsg.Bemfa_Mixly_wechat_sendmsg_type2 ='发送提醒消息';
ZhHansMsg.Bemfa_Mixly_wechat_sendmsg_type1 ='发送预警消息';


ZhHansMsg.Bemfa_Mixly_wechat_del_config ='清除配网信息';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_topic ='生成主题';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_uid ='生成私钥';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_topic_proto ='主题协议';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_topic_Type ='主题类型';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_applus ='ap一键配网+';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_ap ='ap一键配网';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_airkiss ='一键配网';



ZhHansMsg.Bemfa_Mixly_wechat_cre_config_device_name1 ='灯';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_device_name2 ='插座';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_device_name3 ='风扇';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_device_name4 ='传感器';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_device_name5 ='空调';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_device_name7 ='开关';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_device_name8 ='窗帘';

ZhHansMsg.Bemfa_Mixly_wechat_cre_config_device_name10 ='温控器';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_device_name11 ='热水器';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_device_name12 ='电视';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_device_name13 ='空气净化器';


ZhHansMsg.Bemfa_Mixly_wechat_cre_config_airkiss_plus ='一键配网+';
ZhHansMsg.Bemfa_Mixly_picture_Topic='图片主题';
ZhHansMsg.Bemfa_Push_Cam_Wechat_Msg='微信消息';
ZhHansMsg.Bemfa_Mixly_picture_FlashLED='闪光灯';
ZhHansMsg.Bemfa_Push_Cam_Wechat_Msg_Cam='企业微信消息';
ZhHansMsg.Bemfa_Push_Cam_User_Path='设置图片链接';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_device_name6 ='图片';
ZhHansMsg.Bemfa_Push_Cam_User_Path_Rev='生成图片链接';

ZhHansMsg.Bemfa_Push_Cam_Esp32cam_pic='esp32cam拍照上传';
ZhHansMsg.Bemfa_Push_Cam_Esp32cam_pic_ok='上传成功';

ZhHansMsg.Bemfa_OTA_update='远程OTA升级';
ZhHansMsg.Bemfa_OTA_update_Url='固件地址';

ZhHansMsg.Bemfa_Mixly_wechat_cre_config_ble ='蓝牙配网';
ZhHansMsg.Bemfa_Mixly_wechat_cre_config_bleplus ='蓝牙配网+';

const ZhHansCatgories = {};


/***/ },

/***/ "./src/language/zh-hant.js"
/*!*********************************!*\
  !*** ./src/language/zh-hant.js ***!
  \*********************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   ZhHantCatgories: () => (/* binding */ ZhHantCatgories),
/* harmony export */   ZhHantMsg: () => (/* binding */ ZhHantMsg)
/* harmony export */ });
/* harmony import */ var _zh_hans__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./zh-hans */ "./src/language/zh-hans.js");


const ZhHantMsg = {};

ZhHantMsg.Bemfa_Mixly_MQTT_helpurl='https://cloud.bemfa.com/docs/';
ZhHantMsg.Bemfa_Mixly_Board_Type='開發板類型';
ZhHantMsg.Bemfa_Mixly_MQTT_Server_Config='mqtt服務配置';
ZhHantMsg.Bemfa_Mixly_MQTT_SERVER_ADDR='服務器地址';
ZhHantMsg.Bemfa_Mixly_MQTT_SERVER_PORT='端口號';
ZhHantMsg.Bemfa_Mixly_MQTT_clientID='clientID';
ZhHantMsg.Bemfa_Mixly_MQTT_UserName='用戶名';
ZhHantMsg.Bemfa_Mixly_MQTT_User_Passwd='密碼';
ZhHantMsg.Bemfa_Mixly_MQTT_Sub_Topic_Center='訂閱管理';
ZhHantMsg.Bemfa_Mixly_MQTT_Sub_Topic='訂閱主題';
ZhHantMsg.Bemfa_Mixly_MQTT_msg_Rev='消息接收';
ZhHantMsg.Bemfa_Mixly_MQTT_Server_Connect='服務器是否連接';
ZhHantMsg.Bemfa_Mixly_MQTT_Pub_Msg='發布消息';
ZhHantMsg.Bemfa_Mixly_MQTT_Topic='主題';
ZhHantMsg.Bemfa_Mixly_MQTT_Msg_Payload='消息';
ZhHantMsg.Bemfa_Mixly_MQTT_sub_tip='支持訂閱多個主題';
ZhHantMsg.Bemfa_Mixly_tcp_Server_Config='tcp服務配置';
ZhHantMsg.Bemfa_Mixly_tcp_Server_uid ='私鑰';
ZhHantMsg.Bemfa_Mixly_tcp_help ='使用教程';

ZhHantMsg.Bemfa_Mixly_wechat_msg ='消息內容';
ZhHantMsg.Bemfa_Mixly_wechat_msg_title ='消息標題';
ZhHantMsg.Bemfa_Mixly_wechat_commsg_card ='企業卡片消息';
ZhHantMsg.Bemfa_Mixly_wechat_commsg_text ='企業文本消息';
ZhHantMsg.Bemfa_Mixly_wechat_show_time ='顯示時間';
ZhHantMsg.Bemfa_Mixly_wechat_device_name ='設備名稱';
ZhHantMsg.Bemfa_Mixly_wechat_sendmsg_type2 ='發送提醒消息';
ZhHantMsg.Bemfa_Mixly_wechat_sendmsg_type1 ='發送預警消息';


ZhHantMsg.Bemfa_Mixly_wechat_del_config ='清除配網信息';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_topic ='生成主題';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_uid ='生成私鑰';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_topic_proto ='主題協議';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_topic_Type ='主題類型';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_applus ='ap一鍵配網+';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_ap ='ap一鍵配網';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_airkiss ='一鍵配網';


ZhHantMsg.Bemfa_Mixly_wechat_cre_config_device_name1 ='燈';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_device_name2 ='插座';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_device_name3 ='風扇';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_device_name4 ='傳感器';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_device_name5 ='空調';

ZhHantMsg.Bemfa_Mixly_wechat_cre_config_device_name7 ='開關';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_device_name8 ='窗簾';

ZhHantMsg.Bemfa_Mixly_wechat_cre_config_device_name10 ='溫控器';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_device_name11 ='熱水器';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_device_name12 ='電視';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_device_name13 ='空氣淨化器';

ZhHantMsg.Bemfa_Mixly_wechat_cre_config_airkiss_plus ='一键配网+';
ZhHantMsg.Bemfa_Mixly_picture_Topic='圖片主題';
ZhHantMsg.Bemfa_Push_Cam_Wechat_Msg='微信消息';
_zh_hans__WEBPACK_IMPORTED_MODULE_0__.ZhHansMsg.Bemfa_Mixly_picture_FlashLED='闪光灯';
ZhHantMsg.Bemfa_Push_Cam_Wechat_Msg_Cam='企業微信消息';
ZhHantMsg.Bemfa_Push_Cam_User_Path='設置圖片鏈接';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_device_name6 ='圖片';
ZhHantMsg.Bemfa_Push_Cam_User_Path_Rev='生生成圖片鏈接';

ZhHantMsg.Bemfa_Push_Cam_Esp32cam_pic='esp32cam拍照上傳';
ZhHantMsg.Bemfa_Push_Cam_Esp32cam_pic_ok='上傳成功';

ZhHantMsg.Bemfa_OTA_update='遠程OTA升級';
ZhHantMsg.Bemfa_OTA_update_Url='固件地址';

ZhHantMsg.Bemfa_Mixly_wechat_cre_config_ble ='藍牙配網';
ZhHantMsg.Bemfa_Mixly_wechat_cre_config_bleplus ='藍牙配網+';

const ZhHantCatgories = {};


/***/ },

/***/ "./src/templates/block-code-bemfa-wechat01.c"
/*!***************************************************!*\
  !*** ./src/templates/block-code-bemfa-wechat01.c ***!
  \***************************************************/
(module) {

module.exports = "http_bemfa_wechat.begin(client_bemfa_wechat,\"http://apis.bemfa.com/vb/wechat/v1/wechatAlert?uid={{&uid}}&device={{&name}}&message={{&msg}}\");\r\nhttpCode = http_bemfa_wechat.GET();\r\nif (httpCode > 0) {\r\n  String payload = http_bemfa_wechat.getString();\r\n  Serial.println(payload);\r\n}\r\nhttp_bemfa_wechat.end();\r\n";

/***/ },

/***/ "./src/templates/block-code-bemfa-wechat02.c"
/*!***************************************************!*\
  !*** ./src/templates/block-code-bemfa-wechat02.c ***!
  \***************************************************/
(module) {

module.exports = "http_bemfa_wechat.begin(client_bemfa_wechat,\"http://apis.bemfa.com/vb/wechat/v1/wechatWarn?uid={{&uid}}&device={{&name}}&message={{&msg}}\");\r\nhttpCode = http_bemfa_wechat.GET();\r\nif (httpCode > 0) {\r\n  String payload = http_bemfa_wechat.getString();\r\n  Serial.println(payload);\r\n}\r\nhttp_bemfa_wechat.end();\r\n";

/***/ },

/***/ "./src/templates/block-code-bemfa-wechat03.c"
/*!***************************************************!*\
  !*** ./src/templates/block-code-bemfa-wechat03.c ***!
  \***************************************************/
(module) {

module.exports = "http_bemfa_wechat.begin(client_bemfa_wechat,\"http://go.bemfa.com/v1/sendwechat?uid={{&uid}}&msg={{&msg}}&time={{&time}}\");\r\nhttpCode = http_bemfa_wechat.GET();\r\nif (httpCode > 0) {\r\n  String payload = http_bemfa_wechat.getString();\r\n  Serial.println(payload);\r\n}\r\nhttp_bemfa_wechat.end();\r\n";

/***/ },

/***/ "./src/templates/block-code-bemfa-wechat04.c"
/*!***************************************************!*\
  !*** ./src/templates/block-code-bemfa-wechat04.c ***!
  \***************************************************/
(module) {

module.exports = "http_bemfa_wechat.begin(client_bemfa_wechat,\"http://go.bemfa.com/v1/sendwechatcard?uid={{&uid}}&title={{&title}}&msg={{&msg}}\");\r\nhttpCode = http_bemfa_wechat.GET();\r\nif (httpCode > 0) {\r\n  String payload = http_bemfa_wechat.getString();\r\n  Serial.println(payload);\r\n}\r\nhttp_bemfa_wechat.end();\r\n";

/***/ },

/***/ "./src/templates/block-code-init-bemfa-ota-update.c"
/*!**********************************************************!*\
  !*** ./src/templates/block-code-init-bemfa-ota-update.c ***!
  \**********************************************************/
(module) {

module.exports = "WiFiClient OTAUpdateClient;\r\nSerial.println(\"start update\");\r\n#ifdef ESP32\r\nhttpUpdate.onStart(update_started);//当升级开始时\r\nhttpUpdate.onEnd(update_finished); //当升级结束时\r\nhttpUpdate.onProgress(update_progress); //当升级中\r\nhttpUpdate.onError(update_error); //当升级失败时\r\nt_httpUpdate_return ret = httpUpdate.update(OTAUpdateClient, {{&otaUrl}});\r\n#else\r\nESPhttpUpdate.onStart(update_started);//当升级开始时\r\nESPhttpUpdate.onEnd(update_finished); //当升级结束时\r\nESPhttpUpdate.onProgress(update_progress); //当升级中\r\nESPhttpUpdate.onError(update_error); //当升级失败时\r\nt_httpUpdate_return ret = ESPhttpUpdate.update(OTAUpdateClient, {{&otaUrl}});\r\n#endif\r\nswitch(ret) {\r\ncase HTTP_UPDATE_FAILED:  // 当升级失败\r\n  Serial.println(\"[update] Update failed.\");\r\n  break;\r\ncase HTTP_UPDATE_NO_UPDATES:  // 当无升级\r\n  Serial.println(\"[update] Update no Update.\");\r\n  break;\r\ncase HTTP_UPDATE_OK:  // 当升级成功\r\n  Serial.println(\"[update] Update ok.\");\r\n  break;\r\n}\r\n";

/***/ },

/***/ "./src/templates/block-setup-esp32-cam.c"
/*!***********************************************!*\
  !*** ./src/templates/block-setup-esp32-cam.c ***!
  \***********************************************/
(module) {

module.exports = "pinMode(brightLED, OUTPUT); // flash LED\r\n\r\ndigitalWrite(brightLED, LOW); // led off = Low\r\n\r\ncamera_config_t esp32cam_config;\r\nesp32cam_config.ledc_channel = LEDC_CHANNEL_0;\r\nesp32cam_config.ledc_timer = LEDC_TIMER_0;\r\nesp32cam_config.pin_d0 = Y2_GPIO_NUM;\r\nesp32cam_config.pin_d1 = Y3_GPIO_NUM;\r\nesp32cam_config.pin_d2 = Y4_GPIO_NUM;\r\nesp32cam_config.pin_d3 = Y5_GPIO_NUM;\r\nesp32cam_config.pin_d4 = Y6_GPIO_NUM;\r\nesp32cam_config.pin_d5 = Y7_GPIO_NUM;\r\nesp32cam_config.pin_d6 = Y8_GPIO_NUM;\r\nesp32cam_config.pin_d7 = Y9_GPIO_NUM;\r\nesp32cam_config.pin_xclk = XCLK_GPIO_NUM;\r\nesp32cam_config.pin_pclk = PCLK_GPIO_NUM;\r\nesp32cam_config.pin_vsync = VSYNC_GPIO_NUM;\r\nesp32cam_config.pin_href = HREF_GPIO_NUM;\r\nesp32cam_config.pin_sscb_sda = SIOD_GPIO_NUM;\r\nesp32cam_config.pin_sscb_scl = SIOC_GPIO_NUM;\r\nesp32cam_config.pin_pwdn = PWDN_GPIO_NUM;\r\nesp32cam_config.pin_reset = RESET_GPIO_NUM;\r\nesp32cam_config.xclk_freq_hz = 20000000;\r\nesp32cam_config.frame_size = FRAMESIZE_UXGA;\r\nesp32cam_config.pixel_format = PIXFORMAT_JPEG; // for streaming\r\nesp32cam_config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;\r\nesp32cam_config.fb_location = CAMERA_FB_IN_PSRAM;\r\nesp32cam_config.jpeg_quality = 10;\r\nesp32cam_config.fb_count = 1;\r\n\r\nif (esp32cam_config.pixel_format == PIXFORMAT_JPEG) {\r\n    if (psramFound()) {\r\n        esp32cam_config.jpeg_quality = 10;\r\n        esp32cam_config.fb_count = 2;\r\n        esp32cam_config.grab_mode = CAMERA_GRAB_LATEST;\r\n    } else {\r\n        esp32cam_config.frame_size = FRAMESIZE_SVGA;\r\n        esp32cam_config.fb_location = CAMERA_FB_IN_DRAM;\r\n    }\r\n} else {\r\n    esp32cam_config.frame_size = FRAMESIZE_240X240;\r\n#if CONFIG_IDF_TARGET_ESP32S3\r\n    esp32cam_config.fb_count = 2;\r\n#endif\r\n}\r\n\r\n#if defined(CAMERA_MODEL_ESP_EYE)\r\npinMode(13, INPUT_PULLUP);\r\npinMode(14, INPUT_PULLUP);\r\n#endif\r\n\r\nesp_err_t err = esp_camera_init(&esp32cam_config);\r\nif (err != ESP_OK) {\r\n    Serial.printf(\"Camera init failed with error 0x%x\", err);\r\n    return;\r\n}\r\n\r\nsensor_t *s = esp_camera_sensor_get();\r\nif (s->id.PID == OV3660_PID) {\r\n    s->set_vflip(s, 1);       // flip it back\r\n    s->set_brightness(s, 1);  // up the brightness just a bit\r\n    s->set_saturation(s, -2); // lower the saturation\r\n}\r\n\r\n#if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)\r\ns->set_vflip(s, 1);\r\ns->set_hmirror(s, 1);\r\n#endif\r\n\r\n#if defined(CAMERA_MODEL_ESP32S3_EYE)\r\ns->set_vflip(s, 1);\r\n#endif\r\nsetupFlashPWM();";

/***/ },

/***/ "./src/templates/block-setup-wechat-config-ap.c"
/*!******************************************************!*\
  !*** ./src/templates/block-setup-wechat-config-ap.c ***!
  \******************************************************/
(module) {

module.exports = "String topic = WiFi.macAddress().substring(8);  // 取mac地址做主题用\r\ntopic.replace(\":\", \"\");  // 去掉:号\r\nloadConfig();  // 加载存储的数据\r\napConfig(topic);  // 加载ap\r\n#ifdef ESP32\r\nWiFi.mode(WIFI_AP_STA);\r\nWiFi.disconnect(true, true);\r\n#else\r\nWiFi.mode(WIFI_STA);\r\nWiFi.disconnect(true);\r\n#endif\r\nWiFi.begin(config.stassid, config.stapsw);  // 连接路由器\r\nint connAttempts = 0;\r\nwhile (WiFi.status() != WL_CONNECTED) {  // 检查是否连接成功\r\n  delay(500);\r\n  Serial.print(\".\");\r\n  connAttempts++;\r\n  if (connAttempts > 100) {\r\n    break;\r\n  }\r\n}\r\nif (connAttempts >= 100) {\r\n  Serial.println(\"wifi connect error\");\r\n} else {\r\n  Serial.println(\"wifi connect ok\");\r\n}\r\ncheckFirstConfig();//保存WIFI配置信息,并创建主题";

/***/ },

/***/ "./src/templates/block-setup-wechat-config-applus.c"
/*!**********************************************************!*\
  !*** ./src/templates/block-setup-wechat-config-applus.c ***!
  \**********************************************************/
(module) {

module.exports = "String topic = WiFi.macAddress().substring(8);  // 取mac地址做主题用\r\ntopic.replace(\":\", \"\");  // 去掉:号\r\nloadConfig();  // 加载存储的数据\r\napConfig(topic);  // 加载ap\r\n#ifdef ESP32\r\nWiFi.mode(WIFI_AP_STA);  // STA模式\r\nWiFi.disconnect(true, true);//断开连接\r\n#else\r\nWiFi.mode(WIFI_STA);  // STA模式\r\nWiFi.disconnect(true);//断开连接\r\n#endif\r\nWiFi.begin(config.stassid, config.stapsw);  // 连接路由器\r\nint connAttempts = 0;\r\nwhile (WiFi.status() != WL_CONNECTED) {  // 检查是否连接成功\r\n  delay(500);\r\n  Serial.print(\".\");\r\n  connAttempts++;if (connAttempts > 100)break;\r\n}\r\nif (connAttempts >= 100) {\r\n  Serial.println(\"wifi connect error\");\r\n} else {\r\n  Serial.println(\"wifi connect ok\");\r\n}\r\ncheckFirstConfig();//保存WIFI配置信息,并创建主题";

/***/ },

/***/ "./src/templates/block-setup-wechat-config-ble.c"
/*!*******************************************************!*\
  !*** ./src/templates/block-setup-wechat-config-ble.c ***!
  \*******************************************************/
(module) {

module.exports = "loadConfig();\nbleConfig();\n{{&assignOutput}}\n";

/***/ },

/***/ "./src/templates/func-callback.c"
/*!***************************************!*\
  !*** ./src/templates/func-callback.c ***!
  \***************************************/
(module) {

module.exports = "void callback(char* rtopic, byte* payload, unsigned int length) {\r\n  String msg = \"\";\r\n  String topic = rtopic;\r\n  for (int i = 0; i < length; i++) {\r\n    msg += (char)payload[i];\r\n  }\r\n  {{&branch}} \r\n  msg = \"\";\r\n  topic = \"\";\r\n}";

/***/ },

/***/ "./src/templates/func-do-tcp-client-tick.c"
/*!*************************************************!*\
  !*** ./src/templates/func-do-tcp-client-tick.c ***!
  \*************************************************/
(module) {

module.exports = "void doTCPClientTick() {\r\n  if(WiFi.status() != WL_CONNECTED) return;\r\n  if (!TCPclient.connected()) {\r\n    #ifdef ESP32\r\n    TCPclient.stop();\r\n    #else\r\n    TCPclient.stopAll();\r\n    #endif\r\n    if (preTCPConnected == true) {\r\n      preTCPConnected = false;\r\n      preTCPStartTick = millis();\r\n      Serial.println();\r\n      Serial.println(\"TCP Client disconnected.\");\r\n    } else if (millis() - preTCPStartTick > 1*1000) {\r\n      startTCPClient();\r\n    }\r\n  } else {\r\n    if (TCPclient.available()) {\r\n      char c =TCPclient.read();\r\n      TcpClient_Buff +=c;\r\n      TcpClient_BuffIndex++;\r\n      TcpClient_preTick = millis();\r\n      if (TcpClient_BuffIndex >= MAX_PACKETSIZE - 1) {\r\n        TcpClient_BuffIndex = MAX_PACKETSIZE-2;\r\n        TcpClient_preTick = TcpClient_preTick - 200;\r\n      }\r\n    }\r\n    if (millis() - preHeartTick >= KEEPALIVEATIME) {\r\n      preHeartTick = millis();\r\n      Serial.println(\"--Keep alive:\");\r\n      sendtoTCPServer(\"ping\\r\\n\");\r\n    }\r\n  }\r\n  if ((TcpClient_Buff.length() >= 1) && (millis() - TcpClient_preTick>=200)) {\r\n    TCPclient.flush();\r\n    TcpClient_Buff.trim();\r\n    String topic = \"\";\r\n    String msg = \"\";\r\n    if (TcpClient_Buff.length() > 15) {\r\n      int topicIndex = TcpClient_Buff.indexOf(\"&topic=\")+7;\r\n      int msgIndex = TcpClient_Buff.indexOf(\"&msg=\");\r\n      topic = TcpClient_Buff.substring(topicIndex,msgIndex);\r\n      msg = TcpClient_Buff.substring(msgIndex+5);\r\n    }\r\n    {{&funcBranch}}\r\n    msg = \"\";\r\n    topic = \"\";\r\n    TcpClient_Buff=\"\";\r\n    TcpClient_BuffIndex = 0;\r\n  }\r\n}";

/***/ },

/***/ "./src/templates/func-esp32-cam-header.c"
/*!***********************************************!*\
  !*** ./src/templates/func-esp32-cam-header.c ***!
  \***********************************************/
(module) {

module.exports = "#include \"esp_camera.h\"\r\n#include \"esp_http_client.h\"\r\n#include <ArduinoJson.h>";

/***/ },

/***/ "./src/templates/func-esp32-cam.c"
/*!****************************************!*\
  !*** ./src/templates/func-esp32-cam.c ***!
  \****************************************/
(module) {

module.exports = "const int brightLED = 4;\r\nstatic String httpResponseString;\r\nconst int ledFreq = 50;       // PWM settings\r\nconst int ledChannel = 15;    // camera uses timer1\r\nconst int ledRresolution = 8; // resolution (8 = from 0 to 255)\r\nbool flashRequired = {{&flashLed}};\r\n\r\nvoid brightLed(byte ledBrightness) {\r\n  ledcWrite(ledChannel, ledBrightness); // change LED brightness (0 - 255)\r\n}\r\n\r\nvoid setupFlashPWM() {\r\n  ledcSetup(ledChannel, ledFreq, ledRresolution);\r\n  ledcAttachPin(brightLED, ledChannel);\r\n  brightLed(0);\r\n}\r\n\r\n#define CAMERA_MODEL_AI_THINKER\r\n#define PWDN_GPIO_NUM 32\r\n#define RESET_GPIO_NUM -1\r\n#define XCLK_GPIO_NUM 0\r\n#define SIOD_GPIO_NUM 26\r\n#define SIOC_GPIO_NUM 27\r\n\r\n#define Y9_GPIO_NUM 35\r\n#define Y8_GPIO_NUM 34\r\n#define Y7_GPIO_NUM 39\r\n#define Y6_GPIO_NUM 36\r\n#define Y5_GPIO_NUM 21\r\n#define Y4_GPIO_NUM 19\r\n#define Y3_GPIO_NUM 18\r\n#define Y2_GPIO_NUM 5\r\n#define VSYNC_GPIO_NUM 25\r\n#define HREF_GPIO_NUM 23\r\n#define PCLK_GPIO_NUM 22\r\n\r\nesp_err_t _http_event_handler(esp_http_client_event_t *evt) {\r\n  if (evt->event_id == HTTP_EVENT_ON_DATA) {\r\n    httpResponseString.concat((char *)evt->data, evt->data_len);\r\n  }\r\n  return ESP_OK;\r\n}\r\n\r\nstatic esp_err_t take_send_photo() {\r\n  if (!WiFi.isConnected()) {\r\n    WiFi.begin();\r\n  }\r\n\r\n  if (flashRequired) {\r\n    brightLed(255);\r\n    delay(300);\r\n  }\r\n\r\n  Serial.println(\"Taking picture...\");\r\n  camera_fb_t *fb = NULL;\r\n  esp_err_t res = ESP_OK;\r\n  fb = esp_camera_fb_get();\r\n  if (flashRequired) {\r\n    brightLed(0);\r\n  }\r\n  if (!fb) {\r\n    Serial.println(\"Camera capture failed\");\r\n    return ESP_FAIL;\r\n  }\r\n  httpResponseString.clear();\r\n  esp_http_client_handle_t http_client;\r\n  esp_http_client_config_t config_client = {0};\r\n  config_client.url = \"http://apis.bemfa.com/vb/api/v1/imagesUploadBin\";\r\n  config_client.event_handler = _http_event_handler;\r\n  config_client.method = HTTP_METHOD_POST;\r\n  http_client = esp_http_client_init(&config_client);\r\n  esp_http_client_set_post_field(http_client, (const char *)fb->buf, fb->len); // 设置http发送的内容和长度\r\n  esp_http_client_set_header(http_client, \"Content-Type\", \"image/jpg\");        // 设置http头部字段\r\n  esp_http_client_set_header(http_client, \"Authorization\", {{&uid}});          // 设置http头部字段\r\n  esp_http_client_set_header(http_client, \"Authtopic\", {{&topicId}});          // 设置http头部字段\r\n  esp_http_client_set_header(http_client, \"wechatmsg\", {{&wechatMsg}});        // 设置http头部字段\r\n  esp_http_client_set_header(http_client, \"wecommsg\", {{&wechatMsgCam}});      // 设置http头部字段\r\n  esp_http_client_set_header(http_client, \"picpath\", {{&wechatCamPath}});      // 设置http头部字段\r\n  esp_err_t err = esp_http_client_perform(http_client);                        // 发送http请求\r\n  if (err == ESP_OK) {\r\n    // json数据解析\r\n    StaticJsonDocument<200> doc;\r\n    DeserializationError error = deserializeJson(doc, httpResponseString);\r\n    if (error) {\r\n      Serial.print(F(\"deserializeJson() failed: \"));\r\n      Serial.println(error.c_str());\r\n    }\r\n    String url = doc[\"url\"]; \r\n    {{&funcBranch}}\r\n  }\r\n  esp_http_client_cleanup(http_client);\r\n  esp_camera_fb_return(fb);\r\n  return res;\r\n}";

/***/ },

/***/ "./src/templates/func-init-bemfa-ota-update.c"
/*!****************************************************!*\
  !*** ./src/templates/func-init-bemfa-ota-update.c ***!
  \****************************************************/
(module) {

module.exports = "#if defined(ESP32)\r\n#include <HTTPUpdate.h>\r\n#elif defined(ESP8266)\r\n#include <ESP8266httpUpdate.h>\r\n#endif\r\n\r\n// 当升级开始时，打印日志\r\nvoid update_started() {\r\n  Serial.println(\"CALLBACK:  HTTP update process started\");\r\n}\r\n\r\n// 当升级结束时，打印日志\r\nvoid update_finished() {\r\n  Serial.println(\"CALLBACK:  HTTP update process finished\");\r\n}\r\n\r\n// 当升级中，打印日志\r\nvoid update_progress(int cur, int total) {\r\n  Serial.printf(\"CALLBACK:  HTTP update process at %d of %d bytes...\\n\", cur, total);\r\n}\r\n\r\n// 当升级失败时，打印日志\r\nvoid update_error(int err) {\r\n  Serial.printf(\"CALLBACK:  HTTP update fatal error code %d\\n\", err);\r\n}";

/***/ },

/***/ "./src/templates/func-init-bemfa-tcp.c"
/*!*********************************************!*\
  !*** ./src/templates/func-init-bemfa-tcp.c ***!
  \*********************************************/
(module) {

module.exports = "#ifdef defined(ESP32)\r\n#include <WiFi.h>\r\n#elif defined(ESP8266)\r\n#include <ESP8266WiFi.h>\r\n#endif\r\n\r\n#define TCP_SERVER_ADDR {{&server}}\r\n#define TCP_SERVER_PORT {{&port}}\r\n#ifndef AP_CONFIG\r\nString UID = {{&clientId}};\r\n#endif\r\n#define MAX_PACKETSIZE 512\r\n#define KEEPALIVEATIME 30*1000\r\nWiFiClient TCPclient;\r\nString TcpClient_Buff = \"\";\r\nunsigned int TcpClient_BuffIndex = 0;\r\nunsigned long TcpClient_preTick = 0;\r\nunsigned long preHeartTick = 0;\r\nunsigned long preTCPStartTick = 0;\r\nbool preTCPConnected = false;\r\nbool subFlag = false;\r\nvoid doWiFiTick();\r\nvoid doTCPClientTick();\r\nvoid sendtoTCPServer(String p);\r\n\r\nvoid subTopic(String topic) {\r\n  String tcpTemp = \"\";\r\n  tcpTemp = \"cmd=1&uid=\"+UID+\"&topic=\"+topic+\"\\r\\n\";\r\n  Serial.println(tcpTemp);\r\n  sendtoTCPServer(tcpTemp);\r\n  tcpTemp=\"\";\r\n  Serial.print(\"sub topic:\");\r\n  Serial.println(topic);\r\n}\r\n\r\nvoid doWiFiTick() {\r\n  static bool taskStarted = false;\r\n  static uint32_t lastWiFiCheckTick = 0;\r\n  if (WiFi.status() != WL_CONNECTED) {\r\n    taskStarted = false;\r\n    if (millis() - lastWiFiCheckTick > 1000) {\r\n      lastWiFiCheckTick = millis();\r\n      #ifdef ESP32\r\n      WiFi.begin();\r\n      #endif\r\n    }\r\n  } else {\r\n    if (taskStarted == false) {\r\n      taskStarted = true;\r\n      Serial.print(\"Get IP Address: \");\r\n      Serial.println(WiFi.localIP());\r\n      startTCPClient();\r\n    }\r\n  }\r\n}\r\n\r\nvoid sendtoTCPServer(String p) {\r\n  if (!TCPclient.connected()) {\r\n    Serial.println(\"Client is not readly\");\r\n    return;\r\n  }\r\n  TCPclient.print(p);\r\n  preHeartTick = millis(); //心跳计时开始，需要每隔60秒发送一次数据\r\n}\r\n\r\nvoid startTCPClient() {\r\n  if (TCPclient.connect(TCP_SERVER_ADDR, TCP_SERVER_PORT)) {\r\n    Serial.print(\"Connected to server:\");\r\n    Serial.println(TCP_SERVER_ADDR);  \r\n    subFlag = true;\r\n    preHeartTick = millis();\r\n    TCPclient.setNoDelay(true);\r\n  } else {\r\n    Serial.print(\"Failed connected to server:\");\r\n    Serial.println(TCP_SERVER_ADDR);\r\n    #ifdef ESP32\r\n    TCPclient.stop();\r\n    #else\r\n    TCPclient.stopAll();\r\n    #endif\r\n    preTCPConnected = false;\r\n  }\r\n  preTCPStartTick = millis();\r\n}";

/***/ },

/***/ "./src/templates/func-publish-msg.c"
/*!******************************************!*\
  !*** ./src/templates/func-publish-msg.c ***!
  \******************************************/
(module) {

module.exports = "void publishMsg(String topic,String msg) {\r\n  String tcpTemp=\"\";\r\n  tcpTemp = \"cmd=2&uid=\" + UID + \"&topic=\" + topic + \"&msg=\" + msg + \"\\r\\n\";\r\n  sendtoTCPServer(tcpTemp);\r\n  tcpTemp=\"\";\r\n  Serial.println(\"A message has been published\");\r\n}";

/***/ },

/***/ "./src/templates/func-reconnect.c"
/*!****************************************!*\
  !*** ./src/templates/func-reconnect.c ***!
  \****************************************/
(module) {

module.exports = "#if defined(ESP32)\r\n#include <WiFi.h>\r\n#elif defined(ESP8266)\r\n#include <ESP8266WiFi.h>\r\n#endif\r\n\r\nWiFiClient espClient;\r\nPubSubClient client(espClient);\r\n#ifndef AP_CONFIG\r\nString UID = {{&clientId}};\r\n#endif\r\nconst char* UserName = {{&userName}};\r\nconst char* PassWord = {{&password}};\r\nbool subTopicCenterFlag = false;\r\nunsigned long bemfa_mqtt_current_millis;\r\nunsigned long bemfa_mqtt_last_re_millis = 0;\r\nvoid reConnect() {\r\n  if (!client.connected()) {\r\n    if (client.connect(UID.c_str(), UserName, PassWord)) {\r\n      Serial.println(\"connected\");\r\n      subTopicCenterFlag = true;\r\n    } else {\r\n      bemfa_mqtt_current_millis = millis();\r\n      if (bemfa_mqtt_current_millis - bemfa_mqtt_last_re_millis > 2000) { \r\n        bemfa_mqtt_last_re_millis = millis();\r\n        Serial.println(\" try again reconnect\");\r\n        #ifdef ESP32\r\n        WiFi.begin();\r\n        #endif\r\n      }\r\n    }\r\n  }\r\n}";

/***/ },

/***/ "./src/templates/func-sub-mqtt-topic-center.c"
/*!****************************************************!*\
  !*** ./src/templates/func-sub-mqtt-topic-center.c ***!
  \****************************************************/
(module) {

module.exports = "void subMqttTopicCenter() {\r\n  if (subTopicCenterFlag == true) {\r\n    subTopicCenterFlag = false;\r\n    {{&branch}}\r\n  }\r\n}";

/***/ },

/***/ "./src/templates/func-sub-topic-center.c"
/*!***********************************************!*\
  !*** ./src/templates/func-sub-topic-center.c ***!
  \***********************************************/
(module) {

module.exports = "void subTopicCenter() {\r\n  if (subFlag == true) {\r\n    subFlag = false;\r\n    {{&branch}}\r\n  }\r\n}";

/***/ },

/***/ "./src/templates/func-wechat-config-airkiss-applus-header.c"
/*!******************************************************************!*\
  !*** ./src/templates/func-wechat-config-airkiss-applus-header.c ***!
  \******************************************************************/
(module) {

module.exports = "#if defined(ESP32)\n#include <WiFi.h>\n#include <HTTPClient.h>\n#elif defined(ESP8266)\n#include <ESP8266WiFi.h>\n#include <ESP8266HTTPClient.h>\n#endif\n#include <EEPROM.h>\n#include <Ticker.h>\n#include <ArduinoJson.h>\n";

/***/ },

/***/ "./src/templates/func-wechat-config-airkiss-applus.c"
/*!***********************************************************!*\
  !*** ./src/templates/func-wechat-config-airkiss-applus.c ***!
  \***********************************************************/
(module) {

module.exports = "WiFiClient client_bemfa_WiFiClient;\r\nHTTPClient http_bemfa_HTTPClient;\r\n#define AP_CONFIG \"ok\"\r\nString UID = \"\";\r\nString wxTopic=\"\";\r\nint httpCode = 0;\r\n#define HOST_NAME  \"bemfa\"\r\nchar config_flag = 0;\r\n#define MAGIC_NUMBER 0xAA\r\nstruct config_type {\r\n  char stassid[32];\r\n  char stapsw[64];\r\n  char cuid[40];\r\n  char ctopic[32];\r\n  uint8_t reboot;\r\n  uint8_t magic;\r\n};\r\nconfig_type config;\r\nvoid doSmartconfig();\r\nvoid saveConfig();\r\nvoid initWiFi();\r\nvoid loadConfig();\r\nvoid restoreFactory();\r\nvoid waitKey();\r\n\r\nvoid doSmartconfig() {\r\n  Serial.print(\" Airkiss begin,Waiting for WeChat Config.....\");\r\n  #ifdef ESP32\r\n  WiFi.mode(WIFI_AP_STA);\r\n  WiFi.disconnect(true, true);\r\n  #else\r\n  WiFi.mode(WIFI_STA);\r\n  WiFi.disconnect(true);\r\n  #endif\r\n  WiFi.beginSmartConfig();\r\n  int cnt = 0;\r\n  while (!WiFi.smartConfigDone()) {\r\n    delay(500);\r\n    cnt++;\r\n    if (cnt >= 600) {\r\n      delayRestart(0);\r\n    }\r\n  }\r\n  if (WiFi.smartConfigDone()) {\r\n    strcpy(config.stassid, WiFi.SSID().c_str());\r\n    strcpy(config.stapsw, WiFi.psk().c_str());\r\n    config.magic = 0xAA;\r\n    saveConfig();\r\n  }\r\n}\r\n\r\nvoid saveConfig(){\r\n  int rand_key;\r\n  uint8_t mac[6];\r\n  WiFi.macAddress(mac);\r\n  config.reboot = 0;\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  uint8_t *p = (uint8_t*)(&config);\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    EEPROM.write(i, *(p + i));\r\n  }\r\n  EEPROM.commit();\r\n}\r\n\r\nTicker delayTimer;\r\n\r\nvoid delayRestart(float t) {\r\n  delayTimer.attach(t, []() {\r\n    ESP.restart();\r\n  });\r\n}\r\n\r\nvoid initWiFi() {\r\n  char temp[32];\r\n  uint8_t mac[6];\r\n  WiFi.macAddress(mac);\r\n  sprintf(temp, \"%s_%02X%02X%02X\", HOST_NAME, mac[3], mac[4], mac[5]);\r\n  WiFi.hostname(temp);\r\n  if (WiFi.status() != WL_CONNECTED) {\r\n    #ifdef ESP32\r\n    WiFi.disconnect(true, true);//断开连接\r\n    #else\r\n    WiFi.disconnect(true);//断开连接\r\n    #endif\r\n    WiFi.mode(WIFI_STA);  // STA模式\r\n    WiFi.begin(config.stassid, config.stapsw);  // 连接路由器\r\n  }\r\n  int connAttempts = 0;\r\n  while (WiFi.status() != WL_CONNECTED) {  // 检查是否连接成功\r\n    delay(500);\r\n    Serial.print(\".\");\r\n    connAttempts++;if (connAttempts > 100)break;\r\n  }\r\n  if (connAttempts >= 100) {\r\n    Serial.println(\"wifi connect error\");\r\n  } else {\r\n    Serial.println(\"wifi connect ok\");\r\n  }\r\n  WiFi.softAP(temp);\r\n}\r\n\r\nuint8_t *p = (uint8_t*)(&config);\r\n\r\nvoid loadConfig() {\r\n  uint8_t mac[6];\r\n  WiFi.macAddress(mac);\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    *(p + i) = EEPROM.read(i);\r\n  }\r\n  config.reboot = config.reboot + 1;\r\n  if(config.reboot>=4){\r\n    restoreFactory();\r\n  }\r\n  if(config.magic != 0xAA){\r\n    config_flag = 1;\r\n  }\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  for (int i = 0; i < sizeof(config); i++){\r\n    EEPROM.write(i, *(p + i));\r\n  }\r\n  EEPROM.commit();\r\n  delay(2000);\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  config.reboot = 0;\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    EEPROM.write(i, *(p + i));\r\n  }\r\n  EEPROM.commit();\r\n  delay(2000);\r\n}\r\n\r\nvoid restoreFactory() {\r\n  Serial.println(\"Restore Factory....... \");\r\n  config.magic = 0x00;\r\n  strcpy(config.stassid, \"\");\r\n  strcpy(config.stapsw, \"\");\r\n  strcpy(config.cuid, \"\");\r\n  strcpy(config.ctopic, \"\");\r\n  config.magic = 0x00;\r\n  saveConfig();\r\n  delayRestart(1);\r\n  while (1) {\r\n    delay(100);\r\n  }\r\n}\r\n\r\nvoid waitKey() {\r\n  if(config_flag == 1){\r\n    doSmartconfig();\r\n  }\r\n}\r\n\r\nvoid getUid(String mac) {\r\n  String topic = mac + \"{{&deviceType}}\";\r\n  if (strcmp(config.cuid, \"\") == 0){\r\n    http_bemfa_HTTPClient.begin(client_bemfa_WiFiClient, \"http://api.bemfa.com/api/device/v1/airkiss/?topic=\" + topic + \"&version={{&version}}\");\r\n    httpCode = http_bemfa_HTTPClient.GET();\r\n    if (httpCode > 0) {\r\n      String payload = http_bemfa_HTTPClient.getString();\r\n      StaticJsonDocument<200> doc;  // json数据解析\r\n      DeserializationError error = deserializeJson(doc, payload);\r\n      if (error) {\r\n        Serial.print(F(\"deserializeJson() failed: \"));\r\n        Serial.println(error.c_str());\r\n      }\r\n      String code = doc[\"code\"];\r\n      if(code == \"5723200\") {\r\n        String docUID = doc[\"uid\"];\r\n        strcpy(config.cuid, docUID.c_str());\r\n        strcpy(config.ctopic, topic.c_str());\r\n        saveConfig();\r\n      } else {\r\n        Serial.println(\" config ERROR.........\");\r\n      }\r\n      http_bemfa_HTTPClient.end();\r\n    }\r\n  }\r\n  if (strcmp(config.ctopic, \"\") == 0) {\r\n    wxTopic = topic;\r\n  } else {\r\n    wxTopic = config.ctopic;\r\n  }\r\n  UID = config.cuid;\r\n}";

/***/ },

/***/ "./src/templates/func-wechat-config-airkiss-header.c"
/*!***********************************************************!*\
  !*** ./src/templates/func-wechat-config-airkiss-header.c ***!
  \***********************************************************/
(module) {

module.exports = "#if defined(ESP32)\n#include <WiFi.h>\n#include <HTTPClient.h>\n#elif  defined(ESP8266)\n#include <ESP8266WiFi.h>\n#include <ESP8266HTTPClient.h>\n#endif\n#include <EEPROM.h>\n#include <Ticker.h>\n";

/***/ },

/***/ "./src/templates/func-wechat-config-airkiss.c"
/*!****************************************************!*\
  !*** ./src/templates/func-wechat-config-airkiss.c ***!
  \****************************************************/
(module) {

module.exports = "#define HOST_NAME  \"bemfa\"\r\nchar config_flag = 0;\r\n#define MAGIC_NUMBER 0xAA\r\nstruct config_type {\r\n  char stassid[32];\r\n  char stapsw[64];\r\n  char cuid[40];\r\n  char ctopic[32];\r\n  uint8_t reboot;\r\n  uint8_t magic;\r\n};\r\nconfig_type config;\r\nvoid doSmartconfig();\r\nvoid saveConfig();\r\nvoid initWiFi();\r\nvoid loadConfig();\r\nvoid restoreFactory();\r\nvoid waitKey();\r\n\r\n/**\r\n* 设置SmartConfig\r\n*/\r\nvoid setConfig() {\r\n  String mac = WiFi.macAddress().substring(8);//取mac地址做主题用\r\n  mac.replace(\":\", \"\");//去掉:号\r\n  WiFiClient client_bemfa_WiFiClientAIR;\r\n  HTTPClient http_bemfa_HTTPClientAIR;\r\n  http_bemfa_HTTPClientAIR.begin(client_bemfa_WiFiClientAIR, \"http://pro.bemfa.com/vv/setSmartConfig?version=1&user=\" + mac);\r\n  int httpCode = http_bemfa_HTTPClientAIR.GET();\r\n  if (httpCode == 200) {\r\n    Serial.println(\"wifi smartconfig ok\");\r\n  }\r\n  http_bemfa_HTTPClientAIR.end();\r\n}\r\n\r\nvoid doSmartconfig() {\r\n  Serial.print(\" Airkiss begin,Waiting for WeChat Config.....\");\r\n  #ifdef ESP32\r\n  WiFi.mode(WIFI_AP_STA);\r\n  WiFi.disconnect(true, true);\r\n  #else\r\n  WiFi.mode(WIFI_STA);\r\n  WiFi.disconnect(true);\r\n  #endif\r\n  WiFi.beginSmartConfig();\r\n  int cnt = 0;\r\n  while (!WiFi.smartConfigDone()) {\r\n    delay(500);\r\n    cnt++;\r\n    if (cnt >= 600) {\r\n      delayRestart(0);\r\n    }\r\n  }\r\n  if (WiFi.smartConfigDone()) {\r\n    strcpy(config.stassid, WiFi.SSID().c_str());\r\n    strcpy(config.stapsw, WiFi.psk().c_str());\r\n    config.magic = 0xAA;\r\n    saveConfig();\r\n  }\r\n}\r\n\r\nvoid saveConfig() {  \r\n  int rand_key;\r\n  uint8_t mac[6];\r\n  WiFi.macAddress(mac);\r\n  config.reboot = 0;\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  uint8_t *p = (uint8_t*)(&config);\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    EEPROM.write(i, *(p + i));\r\n  }\r\n  EEPROM.commit();\r\n}\r\n\r\nTicker delayTimer;\r\nvoid delayRestart(float t) {\r\n  delayTimer.attach(t, []() {\r\n    ESP.restart();\r\n  });\r\n}\r\n\r\nvoid initWiFi() {\r\n  char temp[32];\r\n  uint8_t mac[6];\r\n  WiFi.macAddress(mac);\r\n  sprintf(temp, \"%s_%02X%02X%02X\", HOST_NAME, mac[3], mac[4], mac[5]);\r\n  WiFi.hostname(temp);\r\n  if (WiFi.status() != WL_CONNECTED) {\r\n    #ifdef ESP32\r\n    WiFi.disconnect(true, true);//断开连接\r\n    #else\r\n    WiFi.disconnect(true);//断开连接\r\n    #endif\r\n    WiFi.mode(WIFI_STA);\r\n    WiFi.begin(config.stassid, config.stapsw);//连接路由器\r\n  }\r\n  int connAttempts = 0;\r\n  while (WiFi.status() != WL_CONNECTED) {//检查是否连接成功\r\n    delay(500);\r\n    Serial.print(\".\");\r\n    connAttempts++;if (connAttempts > 100)break;\r\n  }\r\n\r\n  if (config_flag == 1) {\r\n    setConfig();\r\n  }\r\n  if (connAttempts >= 100) {\r\n    Serial.println(\"wifi connect error\");\r\n  } else {\r\n    Serial.println(\"wifi connect ok\");\r\n  }\r\n  WiFi.softAP(temp);\r\n}\r\n\r\nuint8_t *p = (uint8_t*)(&config);\r\nvoid loadConfig() {\r\n  uint8_t mac[6];\r\n  WiFi.macAddress(mac);\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    *(p + i) = EEPROM.read(i);\r\n  }\r\n  config.reboot = config.reboot + 1;\r\n  if (config.reboot >= 4) {\r\n    restoreFactory();\r\n  }\r\n  if (config.magic != 0xAA) {\r\n    config_flag = 1;\r\n  }\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    EEPROM.write(i, *(p + i));\r\n  }\r\n  EEPROM.commit();\r\n  delay(2000);\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  config.reboot = 0;\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    EEPROM.write(i, *(p + i));\r\n  }\r\n  EEPROM.commit();\r\n  delay(2000);\r\n}\r\n\r\nvoid restoreFactory() {\r\n  Serial.println(\"Restore Factory....... \");\r\n  config.magic = 0x00;\r\n  strcpy(config.stassid, \"\");\r\n  strcpy(config.stapsw, \"\");\r\n  strcpy(config.cuid, \"\");\r\n  strcpy(config.ctopic, \"\");\r\n  config.magic = 0x00;\r\n  saveConfig();\r\n  delayRestart(1);\r\n  while (1) {\r\n    delay(100);\r\n  }\r\n}\r\n\r\nvoid waitKey() {  \r\n  if (config_flag == 1) {\r\n    doSmartconfig();\r\n  }\r\n}";

/***/ },

/***/ "./src/templates/func-wechat-config-ap-header.c"
/*!******************************************************!*\
  !*** ./src/templates/func-wechat-config-ap-header.c ***!
  \******************************************************/
(module) {

module.exports = "#if defined(ESP32)\n#include <WiFi.h>\n#include <HTTPClient.h>\n#elif defined(ESP8266)\n#include <ESP8266WiFi.h>\n#include <ESP8266HTTPClient.h>\n#endif\n#include <WiFiUdp.h>\n#include <ArduinoJson.h>\n#include <EEPROM.h>\n#include <Ticker.h>\n";

/***/ },

/***/ "./src/templates/func-wechat-config-ap.c"
/*!***********************************************!*\
  !*** ./src/templates/func-wechat-config-ap.c ***!
  \***********************************************/
(module) {

module.exports = "char config_flag = 0;     // 判断是否配网\r\n#define MAGIC_NUMBER 0xAA // 判断是否配网\r\nstruct config_type\r\n{\r\n  char stassid[32];\r\n  char stapsw[16];\r\n  char cuid[40];\r\n  char ctopic[32];\r\n  uint8_t reboot;\r\n  uint8_t magic;\r\n};\r\nconfig_type config;\r\nchar packetBuffer[255]; // 发送数据包\r\nWiFiUDP Udp;\r\nWiFiClient client_bemfa_WiFiClient;\r\nHTTPClient http_bemfa_HTTPClient;\r\nString topicAP = \"\";\r\nbool firstWIfiConfig = false;\r\nuint8_t *p = (uint8_t *)(&config);\r\nvoid loadConfig() {\r\n  uint8_t mac[6];\r\n  WiFi.macAddress(mac);\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    *(p + i) = EEPROM.read(i);\r\n  }\r\n  config.reboot = config.reboot + 1;\r\n  if (config.reboot >= 4) {\r\n    restoreFactory();\r\n  }\r\n  if (config.magic != 0xAA) {\r\n    config_flag = 1;\r\n  }\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    EEPROM.write(i, *(p + i));\r\n  }\r\n  EEPROM.commit();\r\n  delay(2000);\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  config.reboot = 0;\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    EEPROM.write(i, *(p + i));\r\n  }\r\n  EEPROM.commit();\r\n}\r\n\r\nvoid restoreFactory() {\r\n  Serial.println(\"Restore Factory....... \");\r\n  config.magic = 0x00;\r\n  strcpy(config.stassid, \"\");\r\n  strcpy(config.stapsw, \"\");\r\n  strcpy(config.cuid, \"\");\r\n  strcpy(config.ctopic, \"\");\r\n  config.magic = 0x00;\r\n  saveConfig();\r\n  delayRestart(1);\r\n  while (1) {\r\n    delay(100);\r\n  }\r\n}\r\n\r\nvoid saveConfig() {\r\n  config.reboot = 0;\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  uint8_t *p = (uint8_t *)(&config);\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    EEPROM.write(i, *(p + i));\r\n  }\r\n  EEPROM.commit();\r\n}\r\n\r\nTicker delayTimer;\r\n\r\nvoid delayRestart(float t) {\r\n  delayTimer.attach(t, []()\r\n                    { ESP.restart(); });\r\n}\r\n\r\nvoid apConfig(String mac) {\r\n  if (config_flag == 1) {\r\n    WiFi.softAP(\"bemfa_\" + mac);\r\n    Udp.begin(8266);\r\n    Serial.println(\"Started Ap Config...\");\r\n  }\r\n  topicAP = mac + \"002\";\r\n  while (config_flag) { // 如果未配网，开启AP配网，并接收配网信息\r\n    int packetSize = Udp.parsePacket();\r\n    if (packetSize) {\r\n      Serial.print(\"Received packet of size \");\r\n      Serial.println(packetSize);\r\n      Serial.print(\"From \");\r\n      IPAddress remoteIp = Udp.remoteIP();\r\n      Serial.print(remoteIp);\r\n      Serial.print(\", port \");\r\n      Serial.println(Udp.remotePort());\r\n\r\n      int len = Udp.read(packetBuffer, 255);\r\n      if (len > 0) {\r\n        packetBuffer[len] = 0;\r\n      }\r\n      Serial.println(\"Contents:\");\r\n      Serial.println(packetBuffer);\r\n      StaticJsonDocument<200> doc;\r\n\r\n      DeserializationError error = deserializeJson(doc, packetBuffer);\r\n      if (error) {\r\n        Serial.print(F(\"deserializeJson() failed: \"));\r\n        Serial.println(error.f_str());\r\n        return;\r\n      }\r\n      int cmdType = doc[\"cmdType\"].as<int>();\r\n\r\n      if (cmdType == 1) {\r\n        const char *ssid = doc[\"ssid\"];\r\n        const char *password = doc[\"password\"];\r\n        const char *token = doc[\"token\"];\r\n        strcpy(config.stassid, ssid);\r\n        strcpy(config.stapsw, password);\r\n        strcpy(config.cuid, token);\r\n        // 收到信息，并回复\r\n        String ReplyBuffer = \"{\\\"cmdType\\\":2,\\\"productId\\\":\\\"\" + topicAP + \"\\\",\\\"deviceName\\\":\\\"\\\",\\\"protoVersion\\\":\\\"3.1\\\"}\";\r\n        Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());\r\n        #ifdef ESP32\r\n        Udp.print(ReplyBuffer.c_str());\r\n        #else\r\n        Udp.write(ReplyBuffer.c_str());\r\n        #endif\r\n        Udp.endPacket();\r\n      } else if (cmdType == 3) {\r\n        config_flag = 0;\r\n        firstWIfiConfig = true;\r\n        WiFi.softAPdisconnect(true);\r\n      }\r\n    }\r\n  }\r\n}\r\n\r\nvoid checkFirstConfig() {\r\n  if (firstWIfiConfig) {\r\n    bool httpRequestOk = false;\r\n    while (httpRequestOk == false) {\r\n      if (WiFi.status() == WL_CONNECTED) {\r\n        // 设置目标 URL\r\n        http_bemfa_HTTPClient.begin(client_bemfa_WiFiClient, \"http://pro.bemfa.com/vs/web/v1/deviceAddTopic\");\r\n\r\n        // 创建 JSON 对象\r\n        StaticJsonDocument<200> jsonDoc;\r\n        jsonDoc[\"uid\"] = config.cuid;\r\n        jsonDoc[\"topic\"] = topicAP;\r\n        jsonDoc[\"type\"] = 3;\r\n        jsonDoc[\"wifiConfig\"] = 1; // 必填字段\r\n        jsonDoc[\"unCreate\"] = 1;   // 是否不创建，1不创建,0创建\r\n        // 将 JSON 对象转换为字符串\r\n        String jsonString;\r\n        serializeJson(jsonDoc, jsonString);\r\n        http_bemfa_HTTPClient.addHeader(\"Content-Type\", \"application/json; charset=UTF-8\");\r\n        // 发送请求\r\n        int httpCode = http_bemfa_HTTPClient.POST(jsonString);\r\n        if (httpCode == 200) {\r\n          httpRequestOk = true;\r\n          Serial.println(\"POST succeeded with code:\");\r\n          Serial.println(httpCode);\r\n          String payload = http_bemfa_HTTPClient.getString();\r\n          Serial.println(payload);\r\n\r\n          // json数据解析\r\n          StaticJsonDocument<200> doc;\r\n          DeserializationError error = deserializeJson(doc, payload);\r\n          if (error) {\r\n            Serial.print(F(\"deserializeJson() failed: \"));\r\n            Serial.println(error.c_str());\r\n          }\r\n\r\n          int code = doc[\"code\"];\r\n          if (code == 0) {\r\n            int resCode = doc[\"data\"][\"code\"];\r\n            if (resCode == 40006 || resCode == 0) {\r\n              String docUID = doc[\"uid\"];\r\n              if (firstWIfiConfig)\r\n              {\r\n                config.reboot = 0;\r\n                config.magic = 0xAA;\r\n                saveConfig();\r\n              }\r\n            } else {\r\n              Serial.println(\" config ERROR.........\");\r\n            }\r\n          } else {\r\n            Serial.println(\" config ERROR.........\");\r\n          }\r\n        } else if (httpCode != 200) {\r\n          Serial.println(\"POST failed with code:\");\r\n          Serial.println(httpCode);\r\n        } else {\r\n          Serial.println(\"Unknown error\");\r\n        }\r\n        http_bemfa_HTTPClient.end();\r\n      }\r\n      delay(1000); // 每秒检查一次\r\n    }\r\n  }\r\n}\r\n";

/***/ },

/***/ "./src/templates/func-wechat-config-applus.c"
/*!***************************************************!*\
  !*** ./src/templates/func-wechat-config-applus.c ***!
  \***************************************************/
(module) {

module.exports = "char config_flag = 0;              // 判断是否配网\r\n#define MAGIC_NUMBER 0xAA          // 判断是否配网\r\nString aptype = \"{{&deviceType}}\"; // 001插座类型，002灯类型，003风扇类型，，004传感器，，005空调\r\nString UID = \"\";\r\n#define AP_CONFIG \"ok\"\r\nString APtopic = \"\";\r\n\r\nstruct config_type {\r\n  char stassid[32];\r\n  char stapsw[16];\r\n  char cuid[40];\r\n  char ctopic[32];\r\n  uint8_t reboot;\r\n  uint8_t magic;\r\n};\r\nconfig_type config;\r\nchar packetBuffer[255]; // 发送数据包\r\nWiFiUDP Udp;\r\nuint8_t *p = (uint8_t *)(&config);\r\nWiFiClient client_bemfa_WiFiClient;\r\nHTTPClient http_bemfa_HTTPClient;\r\n\r\nbool firstWIfiConfig = false;\r\nvoid loadConfig() {\r\n  uint8_t mac[6];\r\n  WiFi.macAddress(mac);\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    *(p + i) = EEPROM.read(i);\r\n  }\r\n  config.reboot = config.reboot + 1;\r\n  if (config.reboot >= 4) {\r\n    restoreFactory();\r\n  }\r\n  if (config.magic != 0xAA) {\r\n    config_flag = 1;\r\n  }\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    EEPROM.write(i, *(p + i));\r\n  }\r\n  EEPROM.commit();\r\n  delay(2000);\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  config.reboot = 0;\r\n  for (int i = 0; i < sizeof(config); i++) {\r\n    EEPROM.write(i, *(p + i));\r\n  }\r\n  EEPROM.commit();\r\n}\r\n\r\nvoid restoreFactory() {\r\n  Serial.println(\"Restore Factory....... \");\r\n  config.magic = 0x00;\r\n  strcpy(config.stassid, \"\");\r\n  strcpy(config.stapsw, \"\");\r\n  strcpy(config.cuid, \"\");\r\n  strcpy(config.ctopic, \"\");\r\n  config.magic = 0x00;\r\n  saveConfig();\r\n  delayRestart(1);\r\n  while (1) {\r\n    delay(100);\r\n  }\r\n}\r\n\r\nvoid saveConfig() {\r\n  config.reboot = 0;\r\n  #ifdef ESP32\r\n  EEPROM.begin(512);\r\n  #else\r\n  EEPROM.begin(256);\r\n  #endif\r\n  uint8_t *p = (uint8_t *)(&config);\r\n  for (int i = 0; i < sizeof(config); i++)\r\n  {\r\n    EEPROM.write(i, *(p + i));\r\n  }\r\n  EEPROM.commit();\r\n}\r\n\r\nTicker delayTimer;\r\n\r\nvoid delayRestart(float t) {\r\n  delayTimer.attach(t, []()\r\n  { ESP.restart(); });\r\n}\r\n\r\nvoid apConfig(String mac) {\r\n  if (config_flag == 1) {\r\n    WiFi.softAP(\"bemfa_\" + mac + aptype);\r\n    Udp.begin(8266);\r\n    Serial.println(\"Started Ap Config...\");\r\n  }\r\n  APtopic = mac + aptype;\r\n  while (config_flag) { // 如果未配网，开启AP配网，并接收配网信息\r\n    int packetSize = Udp.parsePacket();\r\n    if (packetSize) {\r\n      Serial.print(\"Received packet of size \");\r\n      Serial.println(packetSize);\r\n      Serial.print(\"From \");\r\n      IPAddress remoteIp = Udp.remoteIP();\r\n      Serial.print(remoteIp);\r\n      Serial.print(\", port \");\r\n      Serial.println(Udp.remotePort());\r\n\r\n      int len = Udp.read(packetBuffer, 255);\r\n      if (len > 0) {\r\n        packetBuffer[len] = 0;\r\n      }\r\n      Serial.println(\"Contents:\");\r\n      Serial.println(packetBuffer);\r\n      StaticJsonDocument<200> doc;\r\n\r\n      DeserializationError error = deserializeJson(doc, packetBuffer);\r\n      if (error) {\r\n        Serial.print(F(\"deserializeJson() failed: \"));\r\n        Serial.println(error.f_str());\r\n        return;\r\n      }\r\n      int cmdType = doc[\"cmdType\"].as<int>();\r\n\r\n      if (cmdType == 1) {\r\n        const char *ssid = doc[\"ssid\"];\r\n        const char *password = doc[\"password\"];\r\n        const char *token = doc[\"token\"];\r\n        strcpy(config.stassid, ssid);\r\n        strcpy(config.stapsw, password);\r\n        strcpy(config.cuid, token);\r\n        String protoVersion = \"\";\r\n        if (\"{{&protoVersion}}\" == \"3\") {\r\n          protoVersion = \"3.1\";\r\n        } else {\r\n           if(aptype == \"pic\"){\r\n             protoVersion = \"4.0\";\r\n           }else{\r\n             protoVersion = \"1.1\";\r\n           }\r\n        }\r\n        // 收到信息，并回复\r\n        String ReplyBuffer = \"{\\\"cmdType\\\":2,\\\"productId\\\":\\\"\" + APtopic + \"\\\",\\\"deviceName\\\":\\\"{{&deviceName}}\\\",\\\"protoVersion\\\":\\\"\" + protoVersion + \"\\\"}\";\r\n        Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());\r\n        #ifdef ESP32\r\n        Udp.print(ReplyBuffer.c_str());\r\n        #else\r\n        Udp.write(ReplyBuffer.c_str());\r\n        #endif\r\n        Udp.endPacket();\r\n      } else if (cmdType == 3) {\r\n        config_flag = 0;\r\n        firstWIfiConfig = true;\r\n        WiFi.softAPdisconnect(true);\r\n      }\r\n    }\r\n  }\r\n  UID = config.cuid;\r\n}\r\n\r\nvoid checkFirstConfig() {\r\n\r\n  if (firstWIfiConfig) {\r\n    bool httpRequestOk = false;\r\n    while (httpRequestOk == false) {\r\n      if (WiFi.status() == WL_CONNECTED) {\r\n        // 设置目标 URL\r\n        http_bemfa_HTTPClient.begin(client_bemfa_WiFiClient, \"http://pro.bemfa.com/vs/web/v1/deviceAddTopic\");\r\n\r\n        // 创建 JSON 对象\r\n        StaticJsonDocument<200> jsonDoc;\r\n        jsonDoc[\"uid\"] = config.cuid;\r\n        jsonDoc[\"name\"] = \"{{&deviceName}}\";\r\n        jsonDoc[\"topic\"] = APtopic;\r\n        jsonDoc[\"type\"] = {{&protoVersion}};\r\n        // jsonDoc[\"room\"] = room;\r\n        // jsonDoc[\"adminID\"] = adminID;\r\n        jsonDoc[\"wifiConfig\"] = 1; // 必填字段\r\n        // 将 JSON 对象转换为字符串\r\n        String jsonString;\r\n        serializeJson(jsonDoc, jsonString);\r\n        http_bemfa_HTTPClient.addHeader(\"Content-Type\", \"application/json; charset=UTF-8\");\r\n        // 发送请求\r\n        int httpCode = http_bemfa_HTTPClient.POST(jsonString);\r\n        if (httpCode == 200) {\r\n          httpRequestOk = true;\r\n          Serial.println(\"POST succeeded with code:\");\r\n          Serial.println(httpCode);\r\n          String payload = http_bemfa_HTTPClient.getString();\r\n          Serial.println(payload);\r\n\r\n          // json数据解析\r\n          StaticJsonDocument<200> doc;\r\n          DeserializationError error = deserializeJson(doc, payload);\r\n          if (error) {\r\n            Serial.print(F(\"deserializeJson() failed: \"));\r\n            Serial.println(error.c_str());\r\n          }\r\n\r\n          int code = doc[\"code\"];\r\n          if (code == 0) {\r\n            int resCode = doc[\"data\"][\"code\"];\r\n            if (resCode == 40006 || resCode == 0) {\r\n              String docUID = doc[\"uid\"];\r\n              if (firstWIfiConfig) {\r\n                config.reboot = 0;\r\n                config.magic = 0xAA;\r\n                saveConfig();\r\n              }\r\n            } else {\r\n              Serial.println(\" config ERROR.........\");\r\n            }\r\n          } else {\r\n            Serial.println(\" config ERROR.........\");\r\n          }\r\n        } else if (httpCode != 200) {\r\n          Serial.println(\"POST failed with code:\");\r\n          Serial.println(httpCode);\r\n        } else {\r\n          Serial.println(\"Unknown error\");\r\n        }\r\n        http_bemfa_HTTPClient.end();\r\n      }\r\n      delay(1000); // 每秒检查一次\r\n    }\r\n  }\r\n}";

/***/ },

/***/ "./src/templates/func-wechat-config-ble-header.c"
/*!*******************************************************!*\
  !*** ./src/templates/func-wechat-config-ble-header.c ***!
  \*******************************************************/
(module) {

module.exports = "#if !defined(ESP32)\n#error \"Bemfa BLE provisioning only supports ESP32.\"\n#endif\n\n#include <ArduinoJson.h>\n#include <HTTPClient.h>\n#include <NimBLEDevice.h>\n#include <Preferences.h>\n#include <Ticker.h>\n#include <WiFi.h>\n";

/***/ },

/***/ "./src/templates/func-wechat-config-ble.c"
/*!************************************************!*\
  !*** ./src/templates/func-wechat-config-ble.c ***!
  \************************************************/
(module) {

module.exports = "char config_flag = 0;\n#define MAGIC_NUMBER 0xAA\n#define RESET_BUTTON_PIN 0\n#define RESET_HOLD_MS 5000\n\nString aptype = \"{{&deviceType}}\";\nString bemfaBleDeviceName = \"{{&deviceName}}\";\nint bemfaBleProtoType = {{&protoVersion}};\nString bemfaBleProtoVersion = \"{{&protoVersionName}}\";\nbool bemfaBleCreateTopic = {{&createTopic}};\nint bemfaBleUnCreate = {{&unCreate}};\nString bemfaBleUID = \"\";\nString bemfaBleTopic = \"\";\nString topic = \"\";\n\nstruct config_type {\n  char stassid[33];\n  char stapsw[65];\n  char cuid[65];\n  char ctopic[33];\n  uint8_t reboot;\n  uint8_t magic;\n};\n\nconfig_type config;\nPreferences prefs;\nWiFiClient client_bemfa_WiFiClient;\nHTTPClient http_bemfa_HTTPClient;\nTicker delayTimer;\n\nstatic const char *SERVICE_UUID = \"BEFA2000-BE35-4A5A-9C4A-BE0E02000000\";\nstatic const char *RX_UUID = \"BEFA2001-BE35-4A5A-9C4A-BE0E02000000\";\nstatic const char *TX_UUID = \"BEFA2002-BE35-4A5A-9C4A-BE0E02000000\";\n\nstatic const unsigned long BLE_NOTIFY_GAP_MS = 120;\nstatic const unsigned long WIFI_ACK_TO_STATUS_GAP_MS = 250;\nstatic const unsigned long WIFI_CONNECTED_TO_DONE_GAP_MS = 250;\nstatic const unsigned long WIFI_CONNECT_TIMEOUT_MS = 90000;\nstatic const unsigned long WIFI_RETRY_INTERVAL_MS = 5000;\n\nenum ProvisionState {\n  STATE_IDLE,\n  STATE_BLE_CONNECTED,\n  STATE_READY,\n  STATE_WIFI_RECEIVED,\n  STATE_WIFI_CONNECTING,\n  STATE_WIFI_CONNECTED,\n  STATE_DONE,\n  STATE_FAILED\n};\n\nProvisionState provisionState = STATE_IDLE;\nNimBLEServer *bleServer = nullptr;\nNimBLECharacteristic *txCharacteristic = nullptr;\nNimBLECharacteristic *rxCharacteristic = nullptr;\nNimBLEAdvertising *advertising = nullptr;\n\nbool deviceConnected = false;\nbool txSubscribed = false;\nbool firstWIfiConfig = false;\nbool wifiConnectStarted = false;\nunsigned long wifiConnectStartMs = 0;\nunsigned long wifiLastNotifyMs = 0;\nunsigned long wifiLastRetryMs = 0;\nunsigned long resetButtonPressStartMs = 0;\nunsigned long lastBleNotifyMs = 0;\nint pendingHelloSeq = -1;\nint wifiStatusSeq = 0;\nuint16_t shortCode = 0;\n\nvoid delayRestart(float t) {\n  delayTimer.attach(t, []() {\n    ESP.restart();\n  });\n}\n\nvoid safeCopy(char *dest, size_t size, const char *src) {\n  if (size == 0) {\n    return;\n  }\n  if (src == nullptr) {\n    dest[0] = '\\0';\n    return;\n  }\n  strncpy(dest, src, size - 1);\n  dest[size - 1] = '\\0';\n}\n\nString getBaseMacString() {\n  uint64_t chipId = ESP.getEfuseMac();\n  char mac[13];\n  snprintf(\n    mac,\n    sizeof(mac),\n    \"%02X%02X%02X%02X%02X%02X\",\n    (uint8_t)(chipId >> 40),\n    (uint8_t)(chipId >> 32),\n    (uint8_t)(chipId >> 24),\n    (uint8_t)(chipId >> 16),\n    (uint8_t)(chipId >> 8),\n    (uint8_t)chipId\n  );\n  return String(mac);\n}\n\nString makeTopicId() {\n  String mac = getBaseMacString();\n  return mac.substring(6) + aptype;\n}\n\nuint16_t makeShortCode() {\n  String mac = getBaseMacString();\n  long value = strtol(mac.substring(8).c_str(), nullptr, 16);\n  return (uint16_t)(value & 0xFFFF);\n}\n\nint deviceTypeValue() {\n  return aptype.toInt();\n}\n\nvoid saveConfig() {\n  config.magic = MAGIC_NUMBER;\n  config.reboot = 0;\n  prefs.putUChar(\"magic\", config.magic);\n  prefs.putUChar(\"reboot\", 0);\n  prefs.putString(\"ssid\", config.stassid);\n  prefs.putString(\"psw\", config.stapsw);\n  prefs.putString(\"uid\", config.cuid);\n  prefs.putString(\"topic\", config.ctopic);\n}\n\nvoid restoreFactory() {\n  Serial.println(\"Restore Factory.......\");\n  prefs.clear();\n  memset(&config, 0, sizeof(config));\n  delayRestart(1);\n  while (1) {\n    delay(100);\n  }\n}\n\nvoid loadConfig() {\n  memset(&config, 0, sizeof(config));\n  prefs.begin(\"bemfa\", false);\n  config.magic = prefs.getUChar(\"magic\", 0);\n  config.reboot = prefs.getUChar(\"reboot\", 0);\n  config.reboot = config.reboot + 1;\n  prefs.putUChar(\"reboot\", config.reboot);\n  Serial.print(\"Boot count: \");\n  Serial.println(config.reboot);\n\n  if (config.reboot >= 4) {\n    restoreFactory();\n  }\n\n  prefs.getString(\"ssid\", \"\").toCharArray(config.stassid, sizeof(config.stassid));\n  prefs.getString(\"psw\", \"\").toCharArray(config.stapsw, sizeof(config.stapsw));\n  prefs.getString(\"uid\", \"\").toCharArray(config.cuid, sizeof(config.cuid));\n  prefs.getString(\"topic\", \"\").toCharArray(config.ctopic, sizeof(config.ctopic));\n\n  config_flag = config.magic != MAGIC_NUMBER;\n  delay(2000);\n  config.reboot = 0;\n  prefs.putUChar(\"reboot\", 0);\n  Serial.println(\"Boot count reset\");\n}\n\nvoid handleResetButton() {\n  int buttonState = digitalRead(RESET_BUTTON_PIN);\n  if (buttonState == LOW) {\n    if (resetButtonPressStartMs == 0) {\n      resetButtonPressStartMs = millis();\n    }\n    if (millis() - resetButtonPressStartMs >= RESET_HOLD_MS) {\n      Serial.println(\"BOOT button long press detected\");\n      restoreFactory();\n    }\n    return;\n  }\n  resetButtonPressStartMs = 0;\n}\n\nbool notifyJson(const String &payload) {\n  if (!deviceConnected || !txSubscribed || txCharacteristic == nullptr) {\n    Serial.println(\"Device -> App notify skipped: not ready\");\n    return false;\n  }\n  unsigned long now = millis();\n  if (lastBleNotifyMs != 0 && now - lastBleNotifyMs < BLE_NOTIFY_GAP_MS) {\n    delay(BLE_NOTIFY_GAP_MS - (now - lastBleNotifyMs));\n  }\n  bool notifyOk = txCharacteristic->notify((const uint8_t *)payload.c_str(), payload.length());\n  lastBleNotifyMs = millis();\n  Serial.print(\"Device -> App notify=\");\n  Serial.print(notifyOk ? \"ok\" : \"fail\");\n  Serial.print(\", len=\");\n  Serial.print(payload.length());\n  Serial.print(\": \");\n  Serial.println(payload);\n  return notifyOk;\n}\n\nvoid sendResponse(const char *cmd, int seq, int code) {\n  StaticJsonDocument<128> doc;\n  doc[\"cmd\"] = cmd;\n  doc[\"seq\"] = seq;\n  doc[\"code\"] = code;\n  String out;\n  serializeJson(doc, out);\n  notifyJson(out);\n}\n\nvoid sendError(int seq, int code, const char *reason, bool retryable) {\n  StaticJsonDocument<256> doc;\n  doc[\"cmd\"] = \"error\";\n  doc[\"seq\"] = seq;\n  doc[\"code\"] = code;\n  doc[\"reason\"] = reason;\n  doc[\"retryable\"] = retryable;\n  String out;\n  serializeJson(doc, out);\n  notifyJson(out);\n}\n\nvoid sendStatus(int seq, int code, const char *stage, int progress, const char *reason = nullptr, bool retryable = true) {\n  StaticJsonDocument<256> doc;\n  doc[\"cmd\"] = \"status\";\n  doc[\"seq\"] = seq;\n  doc[\"code\"] = code;\n  doc[\"stage\"] = stage;\n  doc[\"progress\"] = progress;\n  if (reason != nullptr) {\n    doc[\"reason\"] = reason;\n    doc[\"retryable\"] = retryable;\n  }\n  if (WiFi.status() == WL_CONNECTED) {\n    doc[\"ip\"] = WiFi.localIP().toString();\n    doc[\"rssi\"] = WiFi.RSSI();\n  }\n  String out;\n  serializeJson(doc, out);\n  notifyJson(out);\n}\n\nvoid sendHello(int seq) {\n  StaticJsonDocument<384> doc;\n  doc[\"cmd\"] = \"hello\";\n  doc[\"seq\"] = seq;\n  doc[\"code\"] = 0;\n  doc[\"ver\"] = 2;\n  doc[\"device_id\"] = topic;\n  doc[\"device_type\"] = deviceTypeValue();\n  doc[\"name\"] = bemfaBleDeviceName;\n  JsonArray cap = doc.createNestedArray(\"cap\");\n  cap.add(\"wifi\");\n  String out;\n  serializeJson(doc, out);\n  notifyJson(out);\n}\n\nvoid sendInfo(int seq) {\n  StaticJsonDocument<384> doc;\n  doc[\"cmd\"] = \"info\";\n  doc[\"seq\"] = seq;\n  doc[\"code\"] = 0;\n  doc[\"device_id\"] = topic;\n  doc[\"product_id\"] = topic;\n  doc[\"fw\"] = bemfaBleProtoVersion;\n  doc[\"hw\"] = \"esp32\";\n  doc[\"mac\"] = getBaseMacString();\n  String out;\n  serializeJson(doc, out);\n  notifyJson(out);\n}\n\nvoid connectWifiAsync() {\n  wifiConnectStarted = true;\n  wifiConnectStartMs = millis();\n  wifiLastNotifyMs = 0;\n  wifiLastRetryMs = millis();\n  provisionState = STATE_WIFI_CONNECTING;\n  WiFi.disconnect(true);\n  delay(100);\n  WiFi.mode(WIFI_STA);\n  WiFi.begin(config.stassid, config.stapsw);\n}\n\nbool addTopicToBemfa() {\n  if (!bemfaBleCreateTopic || WiFi.status() != WL_CONNECTED) {\n    return false;\n  }\n\n  http_bemfa_HTTPClient.begin(client_bemfa_WiFiClient, \"http://pro.bemfa.com/vs/web/v1/deviceAddTopic\");\n  http_bemfa_HTTPClient.addHeader(\"Content-Type\", \"application/json; charset=UTF-8\");\n\n  StaticJsonDocument<256> jsonDoc;\n  jsonDoc[\"uid\"] = config.cuid;\n  jsonDoc[\"name\"] = bemfaBleDeviceName;\n  jsonDoc[\"topic\"] = topic;\n  jsonDoc[\"type\"] = bemfaBleProtoType;\n  jsonDoc[\"wifiConfig\"] = 1;\n  jsonDoc[\"unCreate\"] = bemfaBleUnCreate;\n\n  String jsonString;\n  serializeJson(jsonDoc, jsonString);\n  int httpCode = http_bemfa_HTTPClient.POST(jsonString);\n  String payload = http_bemfa_HTTPClient.getString();\n  http_bemfa_HTTPClient.end();\n  Serial.print(\"deviceAddTopic httpCode: \");\n  Serial.println(httpCode);\n  Serial.println(payload);\n\n  if (httpCode != 200) {\n    return false;\n  }\n\n  StaticJsonDocument<256> doc;\n  DeserializationError error = deserializeJson(doc, payload);\n  if (error) {\n    Serial.print(\"deserializeJson failed: \");\n    Serial.println(error.c_str());\n    return false;\n  }\n\n  int code = doc[\"code\"] | -1;\n  int resCode = doc[\"data\"][\"code\"] | -1;\n  return code == 0 && (resCode == 0 || resCode == 40006);\n}\n\nvoid updateAdvertisementData(uint8_t setupState) {\n  if (advertising == nullptr) {\n    return;\n  }\n\n  String bleName = \"Bemfa_\" + String(shortCode, HEX);\n  NimBLEAdvertisementData advData;\n  NimBLEAdvertisementData scanRespData;\n  advData.setFlags(0x06);\n  scanRespData.setName(bleName.c_str());\n  scanRespData.setCompleteServices(NimBLEUUID(SERVICE_UUID));\n\n  uint8_t manufacturerField[11] = {\n    10,\n    0xFF,\n    0xFA,\n    0xBE,\n    0x02,\n    0x00,\n    (uint8_t)(deviceTypeValue() & 0xFF),\n    setupState,\n    0x01,\n    (uint8_t)(shortCode & 0xFF),\n    (uint8_t)((shortCode >> 8) & 0xFF)\n  };\n\n  advData.addData(manufacturerField, sizeof(manufacturerField));\n  advertising->setAdvertisementData(advData);\n  advertising->setScanResponseData(scanRespData);\n}\n\nvoid startBleProvisioning() {\n  shortCode = makeShortCode();\n  String bleName = \"Bemfa_\" + String(shortCode, HEX);\n  NimBLEDevice::init(bleName.c_str());\n  NimBLEDevice::setMTU(185);\n\n  bleServer = NimBLEDevice::createServer();\n\n  class ServerCallbacks : public NimBLEServerCallbacks {\n    void onConnect(NimBLEServer *server, NimBLEConnInfo &connInfo) override {\n      deviceConnected = true;\n      provisionState = STATE_BLE_CONNECTED;\n      Serial.println(\"BLE connected\");\n    }\n\n    void onDisconnect(NimBLEServer *server, NimBLEConnInfo &connInfo, int reason) override {\n      deviceConnected = false;\n      txSubscribed = false;\n      Serial.println(\"BLE disconnected\");\n      if (provisionState != STATE_DONE) {\n        delay(200);\n        server->getAdvertising()->start();\n      }\n    }\n  };\n  bleServer->setCallbacks(new ServerCallbacks());\n\n  NimBLEService *service = bleServer->createService(SERVICE_UUID);\n  txCharacteristic = service->createCharacteristic(TX_UUID, NIMBLE_PROPERTY::NOTIFY);\n\n  class TxCallbacks : public NimBLECharacteristicCallbacks {\n    void onSubscribe(NimBLECharacteristic *characteristic, NimBLEConnInfo &connInfo, uint16_t subValue) override {\n      txSubscribed = (subValue != 0);\n      Serial.print(\"TX subscribe state: \");\n      Serial.println(subValue);\n    }\n  };\n  txCharacteristic->setCallbacks(new TxCallbacks());\n\n  rxCharacteristic = service->createCharacteristic(RX_UUID, NIMBLE_PROPERTY::WRITE);\n\n  class RxCallbacks : public NimBLECharacteristicCallbacks {\n    void onWrite(NimBLECharacteristic *characteristic, NimBLEConnInfo &connInfo) override {\n      std::string value = characteristic->getValue();\n      if (value.empty()) {\n        return;\n      }\n      Serial.print(\"App -> Device: \");\n      Serial.println(value.c_str());\n\n      StaticJsonDocument<512> doc;\n      DeserializationError error = deserializeJson(doc, value.c_str());\n      int seq = doc[\"seq\"] | 0;\n      if (error) {\n        sendError(seq, 3002, \"invalid_json\", false);\n        return;\n      }\n\n      const char *cmd = doc[\"cmd\"] | \"\";\n      Serial.print(\"BLE cmd: \");\n      Serial.println(cmd);\n      if (strcmp(cmd, \"hello\") == 0) {\n        provisionState = STATE_READY;\n        pendingHelloSeq = seq;\n        if (txSubscribed) {\n          sendHello(seq);\n          pendingHelloSeq = -1;\n        }\n        return;\n      }\n\n      if (strcmp(cmd, \"info\") == 0) {\n        sendInfo(seq);\n        return;\n      }\n\n      if (strcmp(cmd, \"wifi\") == 0) {\n        if (provisionState != STATE_READY && provisionState != STATE_FAILED) {\n          sendError(seq, 3001, \"invalid_state\", true);\n          return;\n        }\n\n        const char *ssid = doc[\"ssid\"] | \"\";\n        const char *password = doc[\"password\"] | \"\";\n        const char *token = doc[\"token\"] | \"\";\n        if (strlen(ssid) == 0 || strlen(token) == 0) {\n          sendError(seq, 3002, \"invalid_json\", false);\n          return;\n        }\n\n        safeCopy(config.stassid, sizeof(config.stassid), ssid);\n        safeCopy(config.stapsw, sizeof(config.stapsw), password);\n        safeCopy(config.cuid, sizeof(config.cuid), token);\n        safeCopy(config.ctopic, sizeof(config.ctopic), topic.c_str());\n        bemfaBleUID = config.cuid;\n        bemfaBleTopic = topic;\n        firstWIfiConfig = true;\n        provisionState = STATE_WIFI_RECEIVED;\n        wifiStatusSeq = seq + 1;\n\n        StaticJsonDocument<128> ack;\n        ack[\"cmd\"] = \"wifi\";\n        ack[\"seq\"] = seq;\n        ack[\"code\"] = 0;\n        ack[\"accepted\"] = true;\n        String out;\n        serializeJson(ack, out);\n        notifyJson(out);\n        delay(WIFI_ACK_TO_STATUS_GAP_MS);\n\n        sendStatus(wifiStatusSeq, 0, \"received\", 20);\n        connectWifiAsync();\n        return;\n      }\n\n      if (strcmp(cmd, \"finish\") == 0) {\n        sendStatus(seq, 0, \"done\", 100);\n        sendResponse(\"finish\", seq, 0);\n        provisionState = STATE_DONE;\n        if (advertising != nullptr) {\n          advertising->stop();\n        }\n        return;\n      }\n\n      sendError(seq, 3003, \"unsupported_cmd\", false);\n    }\n  };\n  rxCharacteristic->setCallbacks(new RxCallbacks());\n\n  service->start();\n  advertising = NimBLEDevice::getAdvertising();\n  advertising->addServiceUUID(SERVICE_UUID);\n  advertising->enableScanResponse(true);\n  updateAdvertisementData(1);\n  advertising->start();\n  Serial.println(\"Started BLE provisioning\");\n}\n\nvoid waitSavedWifiConnect() {\n  bemfaBleUID = config.cuid;\n  bemfaBleTopic = config.ctopic;\n  WiFi.disconnect(true);\n  delay(100);\n  WiFi.mode(WIFI_STA);\n  WiFi.begin(config.stassid, config.stapsw);\n  int connAttempts = 0;\n  while (WiFi.status() != WL_CONNECTED) {\n    delay(500);\n    Serial.print(\".\");\n    connAttempts++;\n    if (connAttempts > 100) {\n      break;\n    }\n  }\n  Serial.println();\n  if (WiFi.status() == WL_CONNECTED) {\n    Serial.print(\"WiFi connected: \");\n    Serial.println(WiFi.localIP());\n  } else {\n    Serial.println(\"wifi connect error\");\n  }\n}\n\nvoid handleBleProvisioning() {\n  if (pendingHelloSeq >= 0 && txSubscribed) {\n    sendHello(pendingHelloSeq);\n    pendingHelloSeq = -1;\n  }\n\n  if (!wifiConnectStarted || provisionState != STATE_WIFI_CONNECTING) {\n    return;\n  }\n\n  unsigned long now = millis();\n  if (now - wifiLastNotifyMs > 3000) {\n    wifiLastNotifyMs = now;\n    sendStatus(wifiStatusSeq, 0, \"wifi_connecting\", 40);\n  }\n\n  if (WiFi.status() == WL_CONNECTED) {\n    wifiConnectStarted = false;\n    provisionState = STATE_WIFI_CONNECTED;\n    Serial.print(\"WiFi connected: \");\n    Serial.println(WiFi.localIP());\n    saveConfig();\n    sendStatus(wifiStatusSeq, 0, \"wifi_connected\", 100);\n    delay(WIFI_CONNECTED_TO_DONE_GAP_MS);\n    sendStatus(wifiStatusSeq, 0, \"done\", 100);\n    provisionState = STATE_DONE;\n    config_flag = 0;\n    if (advertising != nullptr) {\n      advertising->stop();\n    }\n    return;\n  }\n\n  if (now - wifiConnectStartMs > WIFI_CONNECT_TIMEOUT_MS) {\n    provisionState = STATE_FAILED;\n    wifiConnectStarted = false;\n    sendStatus(wifiStatusSeq, 1003, \"wifi_failed\", 100, \"wifi_timeout\", true);\n    return;\n  }\n\n  if (now - wifiLastRetryMs > WIFI_RETRY_INTERVAL_MS) {\n    wifiLastRetryMs = now;\n    Serial.println(\"WiFi retry begin\");\n    WiFi.disconnect();\n    delay(100);\n    WiFi.begin(config.stassid, config.stapsw);\n  }\n}\n\nvoid bleConfig() {\n  pinMode(RESET_BUTTON_PIN, INPUT_PULLUP);\n  topic = makeTopicId();\n  bemfaBleTopic = topic;\n  shortCode = makeShortCode();\n\n  if (strlen(config.ctopic) > 0) {\n    topic = String(config.ctopic);\n    bemfaBleTopic = topic;\n  } else {\n    safeCopy(config.ctopic, sizeof(config.ctopic), topic.c_str());\n  }\n\n  if (config_flag) {\n    startBleProvisioning();\n    while (config_flag) {\n      handleResetButton();\n      handleBleProvisioning();\n      delay(20);\n    }\n    if (bemfaBleCreateTopic && firstWIfiConfig && WiFi.status() == WL_CONNECTED) {\n      addTopicToBemfa();\n    }\n    firstWIfiConfig = false;\n    NimBLEDevice::deinit(true);\n    return;\n  }\n\n  waitSavedWifiConnect();\n  Serial.println(\"Config success\");\n}\n";

/***/ },

/***/ "./src/media/wechat/airkiss.jpg"
/*!**************************************!*\
  !*** ./src/media/wechat/airkiss.jpg ***!
  \**************************************/
(module) {

module.exports = "data:image/jpeg;base64, ";

/***/ },

/***/ "./src/media/wechat/ap.png"
/*!*********************************!*\
  !*** ./src/media/wechat/ap.png ***!
  \*********************************/
(module, __unused_webpack_exports, __webpack_require__) {

module.exports = __webpack_require__.p + "images/ap_c41c1911.png";

/***/ },

/***/ "blockly/core"
/*!**************************!*\
  !*** external "Blockly" ***!
  \**************************/
(module) {

module.exports = Blockly;

/***/ },

/***/ "mixly"
/*!************************!*\
  !*** external "Mixly" ***!
  \************************/
(module) {

module.exports = Mixly;

/***/ },

/***/ "./node_modules/mustache/mustache.mjs"
/*!********************************************!*\
  !*** ./node_modules/mustache/mustache.mjs ***!
  \********************************************/
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/*!
 * mustache.js - Logic-less {{mustache}} templates with JavaScript
 * http://github.com/janl/mustache.js
 */

var objectToString = Object.prototype.toString;
var isArray = Array.isArray || function isArrayPolyfill (object) {
  return objectToString.call(object) === '[object Array]';
};

function isFunction (object) {
  return typeof object === 'function';
}

/**
 * More correct typeof string handling array
 * which normally returns typeof 'object'
 */
function typeStr (obj) {
  return isArray(obj) ? 'array' : typeof obj;
}

function escapeRegExp (string) {
  return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
}

/**
 * Null safe way of checking whether or not an object,
 * including its prototype, has a given property
 */
function hasProperty (obj, propName) {
  return obj != null && typeof obj === 'object' && (propName in obj);
}

/**
 * Safe way of detecting whether or not the given thing is a primitive and
 * whether it has the given property
 */
function primitiveHasOwnProperty (primitive, propName) {
  return (
    primitive != null
    && typeof primitive !== 'object'
    && primitive.hasOwnProperty
    && primitive.hasOwnProperty(propName)
  );
}

// Workaround for https://issues.apache.org/jira/browse/COUCHDB-577
// See https://github.com/janl/mustache.js/issues/189
var regExpTest = RegExp.prototype.test;
function testRegExp (re, string) {
  return regExpTest.call(re, string);
}

var nonSpaceRe = /\S/;
function isWhitespace (string) {
  return !testRegExp(nonSpaceRe, string);
}

var entityMap = {
  '&': '&amp;',
  '<': '&lt;',
  '>': '&gt;',
  '"': '&quot;',
  "'": '&#39;',
  '/': '&#x2F;',
  '`': '&#x60;',
  '=': '&#x3D;'
};

function escapeHtml (string) {
  return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
    return entityMap[s];
  });
}

var whiteRe = /\s*/;
var spaceRe = /\s+/;
var equalsRe = /\s*=/;
var curlyRe = /\s*\}/;
var tagRe = /#|\^|\/|>|\{|&|=|!/;

/**
 * Breaks up the given `template` string into a tree of tokens. If the `tags`
 * argument is given here it must be an array with two string values: the
 * opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
 * course, the default is to use mustaches (i.e. mustache.tags).
 *
 * A token is an array with at least 4 elements. The first element is the
 * mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
 * did not contain a symbol (i.e. {{myValue}}) this element is "name". For
 * all text that appears outside a symbol this element is "text".
 *
 * The second element of a token is its "value". For mustache tags this is
 * whatever else was inside the tag besides the opening symbol. For text tokens
 * this is the text itself.
 *
 * The third and fourth elements of the token are the start and end indices,
 * respectively, of the token in the original template.
 *
 * Tokens that are the root node of a subtree contain two more elements: 1) an
 * array of tokens in the subtree and 2) the index in the original template at
 * which the closing tag for that section begins.
 *
 * Tokens for partials also contain two more elements: 1) a string value of
 * indendation prior to that tag and 2) the index of that tag on that line -
 * eg a value of 2 indicates the partial is the third tag on this line.
 */
function parseTemplate (template, tags) {
  if (!template)
    return [];
  var lineHasNonSpace = false;
  var sections = [];     // Stack to hold section tokens
  var tokens = [];       // Buffer to hold the tokens
  var spaces = [];       // Indices of whitespace tokens on the current line
  var hasTag = false;    // Is there a {{tag}} on the current line?
  var nonSpace = false;  // Is there a non-space char on the current line?
  var indentation = '';  // Tracks indentation for tags that use it
  var tagIndex = 0;      // Stores a count of number of tags encountered on a line

  // Strips all whitespace tokens array for the current line
  // if there was a {{#tag}} on it and otherwise only space.
  function stripSpace () {
    if (hasTag && !nonSpace) {
      while (spaces.length)
        delete tokens[spaces.pop()];
    } else {
      spaces = [];
    }

    hasTag = false;
    nonSpace = false;
  }

  var openingTagRe, closingTagRe, closingCurlyRe;
  function compileTags (tagsToCompile) {
    if (typeof tagsToCompile === 'string')
      tagsToCompile = tagsToCompile.split(spaceRe, 2);

    if (!isArray(tagsToCompile) || tagsToCompile.length !== 2)
      throw new Error('Invalid tags: ' + tagsToCompile);

    openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*');
    closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1]));
    closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1]));
  }

  compileTags(tags || mustache.tags);

  var scanner = new Scanner(template);

  var start, type, value, chr, token, openSection;
  while (!scanner.eos()) {
    start = scanner.pos;

    // Match any text between tags.
    value = scanner.scanUntil(openingTagRe);

    if (value) {
      for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
        chr = value.charAt(i);

        if (isWhitespace(chr)) {
          spaces.push(tokens.length);
          indentation += chr;
        } else {
          nonSpace = true;
          lineHasNonSpace = true;
          indentation += ' ';
        }

        tokens.push([ 'text', chr, start, start + 1 ]);
        start += 1;

        // Check for whitespace on the current line.
        if (chr === '\n') {
          stripSpace();
          indentation = '';
          tagIndex = 0;
          lineHasNonSpace = false;
        }
      }
    }

    // Match the opening tag.
    if (!scanner.scan(openingTagRe))
      break;

    hasTag = true;

    // Get the tag type.
    type = scanner.scan(tagRe) || 'name';
    scanner.scan(whiteRe);

    // Get the tag value.
    if (type === '=') {
      value = scanner.scanUntil(equalsRe);
      scanner.scan(equalsRe);
      scanner.scanUntil(closingTagRe);
    } else if (type === '{') {
      value = scanner.scanUntil(closingCurlyRe);
      scanner.scan(curlyRe);
      scanner.scanUntil(closingTagRe);
      type = '&';
    } else {
      value = scanner.scanUntil(closingTagRe);
    }

    // Match the closing tag.
    if (!scanner.scan(closingTagRe))
      throw new Error('Unclosed tag at ' + scanner.pos);

    if (type == '>') {
      token = [ type, value, start, scanner.pos, indentation, tagIndex, lineHasNonSpace ];
    } else {
      token = [ type, value, start, scanner.pos ];
    }
    tagIndex++;
    tokens.push(token);

    if (type === '#' || type === '^') {
      sections.push(token);
    } else if (type === '/') {
      // Check section nesting.
      openSection = sections.pop();

      if (!openSection)
        throw new Error('Unopened section "' + value + '" at ' + start);

      if (openSection[1] !== value)
        throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
    } else if (type === 'name' || type === '{' || type === '&') {
      nonSpace = true;
    } else if (type === '=') {
      // Set the tags for the next time around.
      compileTags(value);
    }
  }

  stripSpace();

  // Make sure there are no open sections when we're done.
  openSection = sections.pop();

  if (openSection)
    throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);

  return nestTokens(squashTokens(tokens));
}

/**
 * Combines the values of consecutive text tokens in the given `tokens` array
 * to a single token.
 */
function squashTokens (tokens) {
  var squashedTokens = [];

  var token, lastToken;
  for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
    token = tokens[i];

    if (token) {
      if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
        lastToken[1] += token[1];
        lastToken[3] = token[3];
      } else {
        squashedTokens.push(token);
        lastToken = token;
      }
    }
  }

  return squashedTokens;
}

/**
 * Forms the given array of `tokens` into a nested tree structure where
 * tokens that represent a section have two additional items: 1) an array of
 * all tokens that appear in that section and 2) the index in the original
 * template that represents the end of that section.
 */
function nestTokens (tokens) {
  var nestedTokens = [];
  var collector = nestedTokens;
  var sections = [];

  var token, section;
  for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
    token = tokens[i];

    switch (token[0]) {
      case '#':
      case '^':
        collector.push(token);
        sections.push(token);
        collector = token[4] = [];
        break;
      case '/':
        section = sections.pop();
        section[5] = token[2];
        collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
        break;
      default:
        collector.push(token);
    }
  }

  return nestedTokens;
}

/**
 * A simple string scanner that is used by the template parser to find
 * tokens in template strings.
 */
function Scanner (string) {
  this.string = string;
  this.tail = string;
  this.pos = 0;
}

/**
 * Returns `true` if the tail is empty (end of string).
 */
Scanner.prototype.eos = function eos () {
  return this.tail === '';
};

/**
 * Tries to match the given regular expression at the current position.
 * Returns the matched text if it can match, the empty string otherwise.
 */
Scanner.prototype.scan = function scan (re) {
  var match = this.tail.match(re);

  if (!match || match.index !== 0)
    return '';

  var string = match[0];

  this.tail = this.tail.substring(string.length);
  this.pos += string.length;

  return string;
};

/**
 * Skips all text until the given regular expression can be matched. Returns
 * the skipped string, which is the entire tail if no match can be made.
 */
Scanner.prototype.scanUntil = function scanUntil (re) {
  var index = this.tail.search(re), match;

  switch (index) {
    case -1:
      match = this.tail;
      this.tail = '';
      break;
    case 0:
      match = '';
      break;
    default:
      match = this.tail.substring(0, index);
      this.tail = this.tail.substring(index);
  }

  this.pos += match.length;

  return match;
};

/**
 * Represents a rendering context by wrapping a view object and
 * maintaining a reference to the parent context.
 */
function Context (view, parentContext) {
  this.view = view;
  this.cache = { '.': this.view };
  this.parent = parentContext;
}

/**
 * Creates a new context using the given view with this context
 * as the parent.
 */
Context.prototype.push = function push (view) {
  return new Context(view, this);
};

/**
 * Returns the value of the given name in this context, traversing
 * up the context hierarchy if the value is absent in this context's view.
 */
Context.prototype.lookup = function lookup (name) {
  var cache = this.cache;

  var value;
  if (cache.hasOwnProperty(name)) {
    value = cache[name];
  } else {
    var context = this, intermediateValue, names, index, lookupHit = false;

    while (context) {
      if (name.indexOf('.') > 0) {
        intermediateValue = context.view;
        names = name.split('.');
        index = 0;

        /**
         * Using the dot notion path in `name`, we descend through the
         * nested objects.
         *
         * To be certain that the lookup has been successful, we have to
         * check if the last object in the path actually has the property
         * we are looking for. We store the result in `lookupHit`.
         *
         * This is specially necessary for when the value has been set to
         * `undefined` and we want to avoid looking up parent contexts.
         *
         * In the case where dot notation is used, we consider the lookup
         * to be successful even if the last "object" in the path is
         * not actually an object but a primitive (e.g., a string, or an
         * integer), because it is sometimes useful to access a property
         * of an autoboxed primitive, such as the length of a string.
         **/
        while (intermediateValue != null && index < names.length) {
          if (index === names.length - 1)
            lookupHit = (
              hasProperty(intermediateValue, names[index])
              || primitiveHasOwnProperty(intermediateValue, names[index])
            );

          intermediateValue = intermediateValue[names[index++]];
        }
      } else {
        intermediateValue = context.view[name];

        /**
         * Only checking against `hasProperty`, which always returns `false` if
         * `context.view` is not an object. Deliberately omitting the check
         * against `primitiveHasOwnProperty` if dot notation is not used.
         *
         * Consider this example:
         * ```
         * Mustache.render("The length of a football field is {{#length}}{{length}}{{/length}}.", {length: "100 yards"})
         * ```
         *
         * If we were to check also against `primitiveHasOwnProperty`, as we do
         * in the dot notation case, then render call would return:
         *
         * "The length of a football field is 9."
         *
         * rather than the expected:
         *
         * "The length of a football field is 100 yards."
         **/
        lookupHit = hasProperty(context.view, name);
      }

      if (lookupHit) {
        value = intermediateValue;
        break;
      }

      context = context.parent;
    }

    cache[name] = value;
  }

  if (isFunction(value))
    value = value.call(this.view);

  return value;
};

/**
 * A Writer knows how to take a stream of tokens and render them to a
 * string, given a context. It also maintains a cache of templates to
 * avoid the need to parse the same template twice.
 */
function Writer () {
  this.templateCache = {
    _cache: {},
    set: function set (key, value) {
      this._cache[key] = value;
    },
    get: function get (key) {
      return this._cache[key];
    },
    clear: function clear () {
      this._cache = {};
    }
  };
}

/**
 * Clears all cached templates in this writer.
 */
Writer.prototype.clearCache = function clearCache () {
  if (typeof this.templateCache !== 'undefined') {
    this.templateCache.clear();
  }
};

/**
 * Parses and caches the given `template` according to the given `tags` or
 * `mustache.tags` if `tags` is omitted,  and returns the array of tokens
 * that is generated from the parse.
 */
Writer.prototype.parse = function parse (template, tags) {
  var cache = this.templateCache;
  var cacheKey = template + ':' + (tags || mustache.tags).join(':');
  var isCacheEnabled = typeof cache !== 'undefined';
  var tokens = isCacheEnabled ? cache.get(cacheKey) : undefined;

  if (tokens == undefined) {
    tokens = parseTemplate(template, tags);
    isCacheEnabled && cache.set(cacheKey, tokens);
  }
  return tokens;
};

/**
 * High-level method that is used to render the given `template` with
 * the given `view`.
 *
 * The optional `partials` argument may be an object that contains the
 * names and templates of partials that are used in the template. It may
 * also be a function that is used to load partial templates on the fly
 * that takes a single argument: the name of the partial.
 *
 * If the optional `config` argument is given here, then it should be an
 * object with a `tags` attribute or an `escape` attribute or both.
 * If an array is passed, then it will be interpreted the same way as
 * a `tags` attribute on a `config` object.
 *
 * The `tags` attribute of a `config` object must be an array with two
 * string values: the opening and closing tags used in the template (e.g.
 * [ "<%", "%>" ]). The default is to mustache.tags.
 *
 * The `escape` attribute of a `config` object must be a function which
 * accepts a string as input and outputs a safely escaped string.
 * If an `escape` function is not provided, then an HTML-safe string
 * escaping function is used as the default.
 */
Writer.prototype.render = function render (template, view, partials, config) {
  var tags = this.getConfigTags(config);
  var tokens = this.parse(template, tags);
  var context = (view instanceof Context) ? view : new Context(view, undefined);
  return this.renderTokens(tokens, context, partials, template, config);
};

/**
 * Low-level method that renders the given array of `tokens` using
 * the given `context` and `partials`.
 *
 * Note: The `originalTemplate` is only ever used to extract the portion
 * of the original template that was contained in a higher-order section.
 * If the template doesn't use higher-order sections, this argument may
 * be omitted.
 */
Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate, config) {
  var buffer = '';

  var token, symbol, value;
  for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
    value = undefined;
    token = tokens[i];
    symbol = token[0];

    if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate, config);
    else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate, config);
    else if (symbol === '>') value = this.renderPartial(token, context, partials, config);
    else if (symbol === '&') value = this.unescapedValue(token, context);
    else if (symbol === 'name') value = this.escapedValue(token, context, config);
    else if (symbol === 'text') value = this.rawValue(token);

    if (value !== undefined)
      buffer += value;
  }

  return buffer;
};

Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate, config) {
  var self = this;
  var buffer = '';
  var value = context.lookup(token[1]);

  // This function is used to render an arbitrary template
  // in the current context by higher-order sections.
  function subRender (template) {
    return self.render(template, context, partials, config);
  }

  if (!value) return;

  if (isArray(value)) {
    for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
      buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate, config);
    }
  } else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
    buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate, config);
  } else if (isFunction(value)) {
    if (typeof originalTemplate !== 'string')
      throw new Error('Cannot use higher-order sections without the original template');

    // Extract the portion of the original template that the section contains.
    value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);

    if (value != null)
      buffer += value;
  } else {
    buffer += this.renderTokens(token[4], context, partials, originalTemplate, config);
  }
  return buffer;
};

Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate, config) {
  var value = context.lookup(token[1]);

  // Use JavaScript's definition of falsy. Include empty arrays.
  // See https://github.com/janl/mustache.js/issues/186
  if (!value || (isArray(value) && value.length === 0))
    return this.renderTokens(token[4], context, partials, originalTemplate, config);
};

Writer.prototype.indentPartial = function indentPartial (partial, indentation, lineHasNonSpace) {
  var filteredIndentation = indentation.replace(/[^ \t]/g, '');
  var partialByNl = partial.split('\n');
  for (var i = 0; i < partialByNl.length; i++) {
    if (partialByNl[i].length && (i > 0 || !lineHasNonSpace)) {
      partialByNl[i] = filteredIndentation + partialByNl[i];
    }
  }
  return partialByNl.join('\n');
};

Writer.prototype.renderPartial = function renderPartial (token, context, partials, config) {
  if (!partials) return;
  var tags = this.getConfigTags(config);

  var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
  if (value != null) {
    var lineHasNonSpace = token[6];
    var tagIndex = token[5];
    var indentation = token[4];
    var indentedValue = value;
    if (tagIndex == 0 && indentation) {
      indentedValue = this.indentPartial(value, indentation, lineHasNonSpace);
    }
    var tokens = this.parse(indentedValue, tags);
    return this.renderTokens(tokens, context, partials, indentedValue, config);
  }
};

Writer.prototype.unescapedValue = function unescapedValue (token, context) {
  var value = context.lookup(token[1]);
  if (value != null)
    return value;
};

Writer.prototype.escapedValue = function escapedValue (token, context, config) {
  var escape = this.getConfigEscape(config) || mustache.escape;
  var value = context.lookup(token[1]);
  if (value != null)
    return (typeof value === 'number' && escape === mustache.escape) ? String(value) : escape(value);
};

Writer.prototype.rawValue = function rawValue (token) {
  return token[1];
};

Writer.prototype.getConfigTags = function getConfigTags (config) {
  if (isArray(config)) {
    return config;
  }
  else if (config && typeof config === 'object') {
    return config.tags;
  }
  else {
    return undefined;
  }
};

Writer.prototype.getConfigEscape = function getConfigEscape (config) {
  if (config && typeof config === 'object' && !isArray(config)) {
    return config.escape;
  }
  else {
    return undefined;
  }
};

var mustache = {
  name: 'mustache.js',
  version: '4.2.0',
  tags: [ '{{', '}}' ],
  clearCache: undefined,
  escape: undefined,
  parse: undefined,
  render: undefined,
  Scanner: undefined,
  Context: undefined,
  Writer: undefined,
  /**
   * Allows a user to override the default caching strategy, by providing an
   * object with set, get and clear methods. This can also be used to disable
   * the cache by setting it to the literal `undefined`.
   */
  set templateCache (cache) {
    defaultWriter.templateCache = cache;
  },
  /**
   * Gets the default or overridden caching object from the default writer.
   */
  get templateCache () {
    return defaultWriter.templateCache;
  }
};

// All high-level mustache.* functions use this writer.
var defaultWriter = new Writer();

/**
 * Clears all cached templates in the default writer.
 */
mustache.clearCache = function clearCache () {
  return defaultWriter.clearCache();
};

/**
 * Parses and caches the given template in the default writer and returns the
 * array of tokens it contains. Doing this ahead of time avoids the need to
 * parse templates on the fly as they are rendered.
 */
mustache.parse = function parse (template, tags) {
  return defaultWriter.parse(template, tags);
};

/**
 * Renders the `template` with the given `view`, `partials`, and `config`
 * using the default writer.
 */
mustache.render = function render (template, view, partials, config) {
  if (typeof template !== 'string') {
    throw new TypeError('Invalid template! Template should be a "string" ' +
                        'but "' + typeStr(template) + '" was given as the first ' +
                        'argument for mustache#render(template, view, partials)');
  }

  return defaultWriter.render(template, view, partials, config);
};

// Export the escaping function so that the user may override it.
// See https://github.com/janl/mustache.js/issues/244
mustache.escape = escapeHtml;

// Export these mainly for testing, but also for advanced usage.
mustache.Scanner = Scanner;
mustache.Context = Context;
mustache.Writer = Writer;

/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (mustache);


/***/ }

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		if (!(moduleId in __webpack_modules__)) {
/******/ 			delete __webpack_module_cache__[moduleId];
/******/ 			var e = new Error("Cannot find module '" + moduleId + "'");
/******/ 			e.code = 'MODULE_NOT_FOUND';
/******/ 			throw e;
/******/ 		}
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/compat get default export */
/******/ 	(() => {
/******/ 		// getDefaultExport function for compatibility with non-harmony modules
/******/ 		__webpack_require__.n = (module) => {
/******/ 			var getter = module && module.__esModule ?
/******/ 				() => (module['default']) :
/******/ 				() => (module);
/******/ 			__webpack_require__.d(getter, { a: getter });
/******/ 			return getter;
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/define property getters */
/******/ 	(() => {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = (exports, definition) => {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/global */
/******/ 	(() => {
/******/ 		__webpack_require__.g = (function() {
/******/ 			if (typeof globalThis === 'object') return globalThis;
/******/ 			try {
/******/ 				return this || new Function('return this')();
/******/ 			} catch (e) {
/******/ 				if (typeof window === 'object') return window;
/******/ 			}
/******/ 		})();
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	(() => {
/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	(() => {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = (exports) => {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/publicPath */
/******/ 	(() => {
/******/ 		var scriptUrl;
/******/ 		if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
/******/ 		var document = __webpack_require__.g.document;
/******/ 		if (!scriptUrl && document) {
/******/ 			if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
/******/ 				scriptUrl = document.currentScript.src;
/******/ 			if (!scriptUrl) {
/******/ 				var scripts = document.getElementsByTagName("script");
/******/ 				if(scripts.length) {
/******/ 					var i = scripts.length - 1;
/******/ 					while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
/******/ 				}
/******/ 			}
/******/ 		}
/******/ 		// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
/******/ 		// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
/******/ 		if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
/******/ 		scriptUrl = scriptUrl.replace(/^blob:/, "").replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
/******/ 		__webpack_require__.p = scriptUrl;
/******/ 	})();
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
(() => {
/*!**********************!*\
  !*** ./src/index.js ***!
  \**********************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var blockly_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! blockly/core */ "blockly/core");
/* harmony import */ var blockly_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(blockly_core__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _language_loader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./language/loader */ "./src/language/loader.js");
/* harmony import */ var _generators_generator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./generators/generator */ "./src/generators/generator.js");
/* harmony import */ var _blocks_block__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blocks/block */ "./src/blocks/block.js");
/* harmony import */ var _css_lib_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./css/lib.css */ "./src/css/lib.css");






// 载入图形化模块外观定义文件
Object.assign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Blocks, _blocks_block__WEBPACK_IMPORTED_MODULE_3__);

// 载入图形化模块代码生成定义文件
Object.assign(blockly_core__WEBPACK_IMPORTED_MODULE_0__.Arduino.forBlock, _generators_generator__WEBPACK_IMPORTED_MODULE_2__);
})();

/******/ })()
;
//# sourceMappingURL=main.bundle.js.map