-
Notifications
You must be signed in to change notification settings - Fork 113
/
emoncms_wifiscan.php
29 lines (25 loc) · 1.08 KB
/
emoncms_wifiscan.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
define('EMONCMS_EXEC', 1);
chdir("/var/www/emoncms");
require "Lib/EmonLogger.php";
require "process_settings.php";
require "Modules/wifi/wifi.php";
$wifi = new Wifi();
$log = new EmonLogger(__FILE__);
if ($settings['redis']['enabled']) {
$redis = new Redis();
$connected = $redis->connect($settings['redis']['host'], $settings['redis']['port']);
if (!$connected) { echo "Can't connect to redis at ".$settings['redis']['host'].":".$settings['redis']['port']." , it may be that redis-server is not installed or started see readme for redis installation"; die; }
if (!empty($settings['redis']['prefix'])) $redis->setOption(Redis::OPT_PREFIX, $settings['redis']['prefix']);
if (!empty($settings['redis']['auth'])) {
if (!$redis->auth($settings['redis']['auth'])) {
echo "Can't connect to redis at ".$settings['redis']['host'].", autentication failed"; die;
}
}
if (!empty($settings['redis']['dbnum'])) {
$redis->select($settings['redis']['dbnum']);
}
} else {
$redis = false;
}
$redis->set("wifi/scan",json_encode($wifi->scan()));