<commit_before>#PyAirview

[![License](https://pypip.in/license/pyairview/badge.svg)](https://pypi.python.org/pypi/pyairview/)
[![Supported Python versions](https://pypip.in/py_versions/pyairview/badge.svg)](https://pypi.python.org/pypi/pyairview/)
[![Development Status](https://pypip.in/status/pyairview/badge.svg)](https://pypi.python.org/pypi/pyairview/)

PyAirview is a very simple Python library for the Ubiquiti Airview2 2.4GHz
spectrum analyzer, which has an undocumented device API.

PyAirview allows the Airview device to be used by 3rd party applications.

The library works pretty well for the intended purpose :)

Once I have the basics written and documented I may port it to C for use in other
languages and so that there is a common low level library available, but it's 
simple enough that even a high level port to Ruby or C# would probably take no 
more than a day. 

##Airview2 hardware

The Airview2 devices were very cheap ($29-39) and originally came with a Java 
app for visualizing usage of that frequency band, for Wi-Fi network planning, 
discovering rogue hotspots, diagnosing Bluetooth issues, etc.

Inside, the device is basically just a simple microcontroller (A [CC2011](http://www.ti.com/product/cc2511)) 
with an integrated 2.4GHz radio and a USB interface. It uses the standard USB 
CDC-ACM serial interface to connect to a PC.

The firmware running on the device is likely custom built by Ubiquiti Networks,
I don't possess a copy of it outside my own Airview2 device, even in dumped binary 
form, so I don't know much about it but it seems to be a simple command/response
loop coupled with a function to use the native RSSI power level scanning provided
by the chip.<commit_msg>Include usage info in readme<commit_after>#PyAirview

[![License](https://pypip.in/license/pyairview/badge.svg)](https://pypi.python.org/pypi/pyairview/)
[![Supported Python versions](https://pypip.in/py_versions/pyairview/badge.svg)](https://pypi.python.org/pypi/pyairview/)
[![Development Status](https://pypip.in/status/pyairview/badge.svg)](https://pypi.python.org/pypi/pyairview/)

PyAirview is a very simple Python library for the Ubiquiti Airview2 2.4GHz
spectrum analyzer, which has an undocumented device API.

PyAirview allows the Airview device to be used by 3rd party applications.

The library works pretty well for the intended purpose :)

Once I have the basics written and documented I may port it to C for use in other
languages and so that there is a common low level library available, but it's 
simple enough that even a high level port to Ruby or C# would probably take no 
more than a day.


##Device API documentation

See the DEVICE_API.md file included in this repository

##Usage

    from __future__ import print_function

    import libairview

    # open the proper serial port
    libairview.connect(port="/dev/ttyACM0")

    # initialize the device
    libairview.initialize()

    # retrieve device-specific information like RF frequency range and channel size
    device_info = libairview.get_device_info()

    """
        start RSSI scanning in a background thread. callback should take a parameter
        named 'rssi_list', which will be a list of rssi values. Use information
        obtained in device_info to interpret the RSSI values and pair them with
        exact frequencies.

    """
    def scan_callback(rssi_list=None):
        print('RSSI levels received: %s', rssi_list)

    libairview.start_background_scan(callback=scan_callback)

##Airview2 hardware

The Airview2 devices were very cheap ($29-39) and originally came with a Java 
app for visualizing usage of that frequency band, for Wi-Fi network planning, 
discovering rogue hotspots, diagnosing Bluetooth issues, etc.

Inside, the device is basically just a simple microcontroller (A [CC2011](http://www.ti.com/product/cc2511)) 
with an integrated 2.4GHz radio and a USB interface. It uses the standard USB 
CDC-ACM serial interface to connect to a PC.

The firmware running on the device is likely custom built by Ubiquiti Networks,
I don't possess a copy of it outside my own Airview2 device, even in dumped binary 
form, so I don't know much about it but it seems to be a simple command/response
loop coupled with a function to use the native RSSI power level scanning provided
by the chip.
{'fraction_non_alphanumeric': 0.07020389249304912, 'fraction_numerical': 0.009962928637627433, 'mean_word_length': 4.2582216808769795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 12, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6729803', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1189, 'n_words': 547}