#ifndef WIFISENSORLINUXC_H
#define WIFISENSORLINUXC_H

#ifdef LINUX_DESKTOP

#include <errno.h>
#include <netlink/errno.h>
#include <netlink/netlink.h>
#include <netlink/genl/genl.h>
#include <netlink/genl/ctrl.h>
#include <linux/nl80211.h>
#include <net/if.h>

struct wifiChannels {
	uint32_t* frequencies;	// array of frequencies
	uint32_t numUsed;		// number of array elements
};

struct wifiScanResultEntry {
	char mac[17];
	int rssi;
};

struct wifiScanResult {
	struct wifiScanResultEntry entries[128];
	int numUsed;
};

struct wifiState {
	struct nl_sock* socket;
	int driverID;
	int mcid;
};

/** get the driver used for scanning */
int wifiGetDriver(struct wifiState* state);

/** convert interface name to index number. 0 if interface is not present */
int wifiGetInterfaceIndex(const char* name);

/** trigger a scan on the given channels / the provided interface */
int wifiTriggerScan(struct wifiState* state, int interfaceIndex, struct wifiChannels* channels);

/** blocking get the result of a triggered scan */
int wifiGetScanResult(struct wifiState* state, int interfaceIndex, struct wifiScanResult* res);

#ifdef LINUX_DESKTOP

#endif // WIFISENSORLINUXC_H
