Details and source code on my blog at https://www.linuxpinguin.de/project/wifiscanner/