| 1 |
// License: BSD/LGPL |
| 2 |
// Copyright (C) 2011-2018 Thomas d'Otreppe |
| 3 |
// |
| 4 |
using System.Threading; |
| 5 |
using WirelessPanda.Readers; |
| 6 |
using WirelessPanda; |
| 7 |
using System.Collections; |
| 8 |
using System.Collections.Generic; |
| 9 |
using System; |
| 10 |
|
| 11 |
namespace NewStationNotify |
| 12 |
{ |
| 13 |
class MainClass |
| 14 |
{ |
| 15 |
public static void Main (string[] args) |
| 16 |
{ |
| 17 |
Console.WriteLine(DateTime.Now + " - Program started"); |
| 18 |
Reader r = new UniversalReader("/home/user/dump-01.csv"); |
| 19 |
|
| 20 |
List<Station> stationList = new List<Station>(); |
| 21 |
|
| 22 |
// Read the file |
| 23 |
r.Read(); |
| 24 |
|
| 25 |
// Add existing stations to the list |
| 26 |
stationList.AddRange(r.Stations); |
| 27 |
|
| 28 |
while (true) { |
| 29 |
// Sleep 5 seconds |
| 30 |
Thread.Sleep(5000); |
| 31 |
|
| 32 |
Console.WriteLine(DateTime.Now + " - Checking for updates"); |
| 33 |
|
| 34 |
// Update file |
| 35 |
r.Read(); |
| 36 |
|
| 37 |
// Get station list |
| 38 |
foreach(Station sta in r.Stations) { |
| 39 |
|
| 40 |
// If new station, update us |
| 41 |
if (!stationList.Contains(sta)) { |
| 42 |
stationList.Add(sta); |
| 43 |
|
| 44 |
// Display it on the command line |
| 45 |
Console.WriteLine(DateTime.Now + " - New station: " + sta.StationMAC); |
| 46 |
|
| 47 |
// Display it as a notification |
| 48 |
Notification.Notify(sta.BSSID, sta.StationMAC); |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
} |
| 54 |
} |
| 55 |
} |