(function () {
  window.__wifi_callback__ = [];

  window.__set_wifi_info__ = (wifiInfoStr) => {
    let wifiInfo;
    try {
      const result = JSON.parse(wifiInfoStr);
      if (result.BSSID && result.SSID) {
        wifiInfo = result;
      }
    } catch (err) {

    }

    window.__wifi_callback__.forEach(callback => callback(wifiInfo));
  }

  window.__init_wifi_callback__ = (callback) => {
    window.__wifi_callback__.push(callback);
  }

  window.__remove_wifi_callback__ = (callback) => {
    window.__wifi_callback__ = window.__wifi_callback__.filter(item => item !== callback);
  }

  window.__refresh_wifi_info__ = () => {
    window.__plus_postmsg__("refresh_wifi_info");
  }
})();