The second part of this week’s 2-Bullet Tuesday! See the first part here.
You can subscribe to the newsletter on the 2-Bullet Tuesday page!

Omega Command of the Week: 

This week we’ll cover how to use your Omega to scan the surrounding area and report on the available WiFi networks. The command we will run is: ubus call onion wifi-scan ‘{“device”:”ra0″}’

Before we dive into the available WiFi networks, let’s take a minute to talk about JSON – JavaScript Object Notation. Both the input given to the command, {“device”:”ra0″} and the output are expressed in JSON.

As you’ll see, JSON is a great data exchange format since it is flexible and very easy to read and write. A JSON object is a collection of key-value pairs; where the key is a unique identifier for the data and the value can be a:

  • String
  • Number – both integer and decimal
  • Boolean value – true or false
  • An array
  • Even another object!

For example:

{
	"string": "this is a string",
	"number": 2,
	"boolean": true,
	"array": [
		"element0",
		"element1",
		"element2"
	],
	"object" : {
		"nested": true
	}
}

What’s really handy is that arrays and objects can hold any data-type, including other arrays and objects, allowing you to store a whole bunch of information in a single JSON object. This is one of many reasons why JSON is one of the most commonly used data exchange formats these days!

Ok, now back to our command! The input we give to the ubus command is {“device”:”ra0″}, which tells the program to use ra0 as the device with which to perform the scan. The output will be in the following form:

{
	"results": [
		{
			"channel": "8",
			"ssid": "Onion HQ",
			"bssid": "40:a3:6b:c0:29:70",
			"authentication": "AES",
			"encryption": "WPA2PSK",
			"signalStrength": "100",
			"wirelessMode": "11b/g/n",
			"ext-ch": "NONE"
		},
		{
			"channel": "6",
			"ssid": "flattop",
			"bssid": "40:a3:6b:c0:29:c2",
			"authentication": "TKIPAES",
			"encryption": "WPA1PSKWPA2PSK",
			"signalStrength": "47",
			"wirelessMode": "11b/g/n",
			"ext-ch": "NONE"
		}
	]
}

The JSON object holds an array with the key results. The array is an array of objects, with each object holding data for a single network found in the scan. Here’s what each of the key-value pairs mean:

  • ssid – The name of the network
  • wirelessMode – The WiFi protocol version being used by the network. The Omega supports b/g/n networks.
  • encryption – The type of encryption used by the network, can be:
    • WPA2PSK – WPA2 Mode (recommended)
    • WPA1PSKWPA2PSK – WPA2/WPA1 Mixed Mode
    • WPAPSK – WPA Mode
    • WEP – WEP Mode (older and not recommended)
    • NONE – An open network (definitely not recommended for transmitting any sensitive data)
  • authentication – The encryption protocol used by the network, can be:
    • TKIP – Older and less secure authentication protocol
    • AES – Most secure
    • TKIPAES – Mixed mode for maximum compatibility
  • channel – The radio frequency channel on which the network is operating
  • signalStrength – The strength of the wireless signal from 0 to 100
  • bssid – The MAC address of the network’s access point, useful for identifying the network even if the SSID changes

For more on JSON, see the official JSON standard site and stay tuned for more info on the ubus command!

 

Let us know what kind of stuff you would like to see featured on 2-Bullet Tuesday! Send a tweet to @OnionIoT with your suggestions!

Thanks for reading! Have a great week!

Team Onion