【问题标题】:Gateway check using Javascript使用 Javascript 进行网关检查
【发布时间】:2017-04-04 14:16:59
【问题描述】:

如何在 Tizen 中执行网关检查?或者有什么方法可以使用 Javascript 知道默认路由器的 IP 地址?

【问题讨论】:

  • 您尝试解决问题的方法是什么?请在这里分享。

标签: javascript tizen gateway tizen-native-app


【解决方案1】:

在您的问题中,您要求使用 JavaScript 解决方案。但是您已将此问题标记为针对 Tizen 本机。除非您正在制作一个混合应用程序,要求一个通常意味着排除另一个。如果 JavaScript 是您正在使用的,则答案如下。

听起来您会对 SystemInfoWifiNetwork 感兴趣。它有如下界面。

 interface SystemInfoWifiNetwork : SystemInfoProperty {
    readonly attribute DOMString status;
    readonly attribute DOMString ssid;
    readonly attribute DOMString ipAddress;
    readonly attribute DOMString ipv6Address;
    readonly attribute DOMString macAddress;
    readonly attribute double signalStrength;
    readonly attribute SystemInfoWifiSecurityMode securityMode;
    readonly attribute SystemInfoWifiEncryptionType encryptionType;
    readonly attribute SystemInfoNetworkIpMode ipMode;
    readonly attribute DOMString subnetMask;
    readonly attribute DOMString gateway;
   readonly attribute DOMString dns;
 };

网关保存您要求的信息。不过要考虑的一点是,如果手机在附近,为了节省电量,手表可能会关闭 WiFi。

Tizen 开发者网站上已有用于检索此信息的代码示例。看看https://developer.tizen.org/community/tip-tech/system-information-api-guide

 function onSuccessCallback(wifi) {
      alert("Status: " + wifi.status +  "    SSID: " + wifi.ssid
      + "\nIP Address: " + wifi.ipAddress + "\nIPV6 Address: " + 
      wifi.ipv6Address + "    Signal Strength: " + wifi.signalStrength);
 }

 function onErrorCallback(error) {
      alert("Not supported: " + error.message);
 }
 tizen.systeminfo.getPropertyValue("WIFI_NETWORK", onSuccessCallback, onErrorCallback);

【讨论】:

    猜你喜欢
    • 2019-07-03
    • 2019-01-05
    • 2014-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多