Skip to main content
added 919 characters in body
Source Link
Biffen
  • 6.4k
  • 6
  • 32
  • 38

I have an Arduino Yun where I host a webpage. Now I want to display the wifi signal quality on that page. I managed to dig in the system and I am able to pop up this JSON-like-array array

{
  "conncount": 5,
  "leases": {
    
  },
  "wan": {
    "proto": "dhcp",
    "ipaddr": "192.168.0.13",
    "link": "/cgi-bin/luci/;stok=235c7aba0f5cbf5cf752ad119ece74e6/admin/network/network/lan",
    "netmask": "255.255.255.0",
    "gwaddr": "192.168.0.1",
    "expires": -1,
    "uptime": 4407,
    "ifname": "wlan0",
    "dns": [
      "192.168.0.1"
    ]
  },
  "membuffers": 15708,
  "connmax": 16384,
  "memfree": 1576,
  "uptime": 4481,
  "wifinets": [
    {
      "device": "radio0",
      "networks": [
        {
          "ifname": "wlan0",
          "encryption": "WPA2 PSK (CCMP)",
          "bssid": "04:A1:51:D3:BC:E8",
          "mode": "Client",
          "quality": 70,
          "noise": -95,
          "ssid": "Skynet-ITA",
          "link": "/cgi-bin/luci/;stok=235c7aba0f5cbf5cf752ad119ece74e6/admin/network/wireless/radio0.network1",
          "assoclist": {
            "04:A1:51:D3:BC:E8": {
              "rx_short_gi": true,
              "noise": -95,
              "rx_mcs": 7,
              "tx_40mhz": true,
              "rx_40mhz": true,
              "tx_rate": 135000,
              "tx_packets": 14825,
              "tx_short_gi": true,
              "rx_packets": 101935,
              "tx_mcs": 6,
              "inactive": 360,
              "rx_rate": 150000,
              "signal": -61
            }
          },
          "txpoweroff": 0,
          "bitrate": 135,
          "txpower": 16,
          "name": "Client \u0022Skynet-ITA\u0022",
          "channel": 6,
          "country": "NL",
          "signal": -61,
          "up": true,
          "frequency": "2.437"
        }
      ],
      "name": "Generic 802.11bgn Wireless Controller (radio0)",
      "up": true
    }
  ],
  "memtotal": 61116,
  "localtime": "Wed Feb  3 12:09:13 2016",
  "memcached": 17596,
  "loadavg": [
    0.04052734375,
    0.125,
    0.20263671875 
 ] ]
}

I have an Arduino Yun where I host a webpage. Now I want to display the wifi signal quality on that page. I managed to dig in the system and I am able to pop up this JSON-like-array

{ "conncount": 5, "leases": {  }, "wan": { "proto": "dhcp", "ipaddr": "192.168.0.13", "link": "/cgi-bin/luci/;stok=235c7aba0f5cbf5cf752ad119ece74e6/admin/network/network/lan", "netmask": "255.255.255.0", "gwaddr": "192.168.0.1", "expires": -1, "uptime": 4407, "ifname": "wlan0", "dns": [ "192.168.0.1" ] }, "membuffers": 15708, "connmax": 16384, "memfree": 1576, "uptime": 4481, "wifinets": [ { "device": "radio0", "networks": [ { "ifname": "wlan0", "encryption": "WPA2 PSK (CCMP)", "bssid": "04:A1:51:D3:BC:E8", "mode": "Client", "quality": 70, "noise": -95, "ssid": "Skynet-ITA", "link": "/cgi-bin/luci/;stok=235c7aba0f5cbf5cf752ad119ece74e6/admin/network/wireless/radio0.network1", "assoclist": { "04:A1:51:D3:BC:E8": { "rx_short_gi": true, "noise": -95, "rx_mcs": 7, "tx_40mhz": true, "rx_40mhz": true, "tx_rate": 135000, "tx_packets": 14825, "tx_short_gi": true, "rx_packets": 101935, "tx_mcs": 6, "inactive": 360, "rx_rate": 150000, "signal": -61 } }, "txpoweroff": 0, "bitrate": 135, "txpower": 16, "name": "Client \u0022Skynet-ITA\u0022", "channel": 6, "country": "NL", "signal": -61, "up": true, "frequency": "2.437" } ], "name": "Generic 802.11bgn Wireless Controller (radio0)", "up": true } ], "memtotal": 61116, "localtime": "Wed Feb  3 12:09:13 2016", "memcached": 17596, "loadavg": [ 0.04052734375, 0.125, 0.20263671875 ] }

I have an Arduino Yun where I host a webpage. Now I want to display the wifi signal quality on that page. I managed to dig in the system and I am able to pop up this JSON-like array

{
  "conncount": 5,
  "leases": {
    
  },
  "wan": {
    "proto": "dhcp",
    "ipaddr": "192.168.0.13",
    "link": "/cgi-bin/luci/;stok=235c7aba0f5cbf5cf752ad119ece74e6/admin/network/network/lan",
    "netmask": "255.255.255.0",
    "gwaddr": "192.168.0.1",
    "expires": -1,
    "uptime": 4407,
    "ifname": "wlan0",
    "dns": [
      "192.168.0.1"
    ]
  },
  "membuffers": 15708,
  "connmax": 16384,
  "memfree": 1576,
  "uptime": 4481,
  "wifinets": [
    {
      "device": "radio0",
      "networks": [
        {
          "ifname": "wlan0",
          "encryption": "WPA2 PSK (CCMP)",
          "bssid": "04:A1:51:D3:BC:E8",
          "mode": "Client",
          "quality": 70,
          "noise": -95,
          "ssid": "Skynet-ITA",
          "link": "/cgi-bin/luci/;stok=235c7aba0f5cbf5cf752ad119ece74e6/admin/network/wireless/radio0.network1",
          "assoclist": {
            "04:A1:51:D3:BC:E8": {
              "rx_short_gi": true,
              "noise": -95,
              "rx_mcs": 7,
              "tx_40mhz": true,
              "rx_40mhz": true,
              "tx_rate": 135000,
              "tx_packets": 14825,
              "tx_short_gi": true,
              "rx_packets": 101935,
              "tx_mcs": 6,
              "inactive": 360,
              "rx_rate": 150000,
              "signal": -61
            }
          },
          "txpoweroff": 0,
          "bitrate": 135,
          "txpower": 16,
          "name": "Client \u0022Skynet-ITA\u0022",
          "channel": 6,
          "country": "NL",
          "signal": -61,
          "up": true,
          "frequency": "2.437"
        }
      ],
      "name": "Generic 802.11bgn Wireless Controller (radio0)",
      "up": true
    }
  ],
  "memtotal": 61116,
  "localtime": "Wed Feb  3 12:09:13 2016",
  "memcached": 17596,
  "loadavg": [
    0.04052734375,
    0.125,
    0.20263671875 
  ]
}
Source Link
Arjan_IO
  • 175
  • 1
  • 11

Complex JSON-array

I have an Arduino Yun where I host a webpage. Now I want to display the wifi signal quality on that page. I managed to dig in the system and I am able to pop up this JSON-like-array

{ "conncount": 5, "leases": {  }, "wan": { "proto": "dhcp", "ipaddr": "192.168.0.13", "link": "/cgi-bin/luci/;stok=235c7aba0f5cbf5cf752ad119ece74e6/admin/network/network/lan", "netmask": "255.255.255.0", "gwaddr": "192.168.0.1", "expires": -1, "uptime": 4407, "ifname": "wlan0", "dns": [ "192.168.0.1" ] }, "membuffers": 15708, "connmax": 16384, "memfree": 1576, "uptime": 4481, "wifinets": [ { "device": "radio0", "networks": [ { "ifname": "wlan0", "encryption": "WPA2 PSK (CCMP)", "bssid": "04:A1:51:D3:BC:E8", "mode": "Client", "quality": 70, "noise": -95, "ssid": "Skynet-ITA", "link": "/cgi-bin/luci/;stok=235c7aba0f5cbf5cf752ad119ece74e6/admin/network/wireless/radio0.network1", "assoclist": { "04:A1:51:D3:BC:E8": { "rx_short_gi": true, "noise": -95, "rx_mcs": 7, "tx_40mhz": true, "rx_40mhz": true, "tx_rate": 135000, "tx_packets": 14825, "tx_short_gi": true, "rx_packets": 101935, "tx_mcs": 6, "inactive": 360, "rx_rate": 150000, "signal": -61 } }, "txpoweroff": 0, "bitrate": 135, "txpower": 16, "name": "Client \u0022Skynet-ITA\u0022", "channel": 6, "country": "NL", "signal": -61, "up": true, "frequency": "2.437" } ], "name": "Generic 802.11bgn Wireless Controller (radio0)", "up": true } ], "memtotal": 61116, "localtime": "Wed Feb  3 12:09:13 2016", "memcached": 17596, "loadavg": [ 0.04052734375, 0.125, 0.20263671875 ] }

Unfortunately, this is the way it comes and I can't change it nor do I know how it is produced.

Is there a way to extract the bit that says "Quality": 70?

I tried it with the following code but no luck (it came back as undefined). I used data[3] as it looks like multiple arrays and Quality is in the 4th one.

var q;

$(document).ready(function() {
var refresh = setInterval(getData, 5000);
});

function getData() {
$.ajax({
        type: "POST",
        url: "/cgi-bin/luci/;stok=6ea83154346f9c42e99ac14ae8856b2b?status=1&_=0.16447926725451678",
        dataType: "JSON",
        cahce: "false",
        success: function(data){
        q  = data[3].quality;
}
});
}