- added values in celsius degree and in km/h in pws2mqtt
- debug of hooks -added webserver.php
This commit is contained in:
18
moha.php
18
moha.php
@ -1,21 +1,19 @@
|
||||
<?php
|
||||
$title = "moha";
|
||||
$testMode = true;
|
||||
|
||||
$webServerIsActive = true;
|
||||
|
||||
cli_set_process_title($title);
|
||||
file_put_contents("/proc/".getmypid()."/comm",$title);
|
||||
declare(ticks = 1);
|
||||
|
||||
$testMode = true;
|
||||
$webServerIsActive = true;
|
||||
|
||||
require "constants.php";
|
||||
|
||||
declare(ticks = 1);
|
||||
|
||||
$listProperties = array("powerSource" => "batterie");
|
||||
$listPropertiesKeys = array("property");
|
||||
|
||||
//global variables
|
||||
$logLevel = INFO | NOTICE | WARNING | ERROR | ALERT; //ALL;
|
||||
$logLevel = ALL; // INFO | NOTICE | WARNING | ERROR | ALERT; //ALL;
|
||||
$notificationLevel = ALERT | ERROR;
|
||||
$topics = array(); // list of topics
|
||||
$mids = array(); // list of message IDs
|
||||
@ -61,7 +59,7 @@ function notify($message)
|
||||
function logger($level, $log, $notif = true)
|
||||
{
|
||||
global $logFh, $logLevel, $notificationLevel, $logLevels;
|
||||
$logString = date("c") . ' ' . $logLevels[$level] . " : $log";
|
||||
$logString = date("c") . ' ' . $logLevels[$level] . " " . __FILE__ . ":" . __LINE__ . " : " . $log;
|
||||
if ($level & $logLevel)
|
||||
{
|
||||
fwrite($logFh, $logString . EOL);
|
||||
@ -112,7 +110,7 @@ function listHooks($dir, &$hookList)
|
||||
|
||||
function endMoha()
|
||||
{
|
||||
global $devices, $topics, $nSubscribed ,$client, $logFh, $connected;
|
||||
global $testMode, $devices, $topics, $nSubscribed ,$client, $logFh, $connected;
|
||||
$x = 0;
|
||||
storeDB($devices, "/usr/share/moha/moha.db");
|
||||
if($testMode) file_put_contents("moha.devices", print_r($devices, true));
|
||||
@ -149,6 +147,7 @@ require $configDir . "/properties2log.php";
|
||||
require "mqtt_functions.php";
|
||||
require "events.php";
|
||||
require "db_functions.php";
|
||||
require "webserver.php";
|
||||
|
||||
//logger(DEBUG, _('assigning variable $client to mosquitto class "client"'), false);
|
||||
//$client = new Mosquitto\Client();
|
||||
@ -263,6 +262,7 @@ while (true)
|
||||
logger(DEBUG,_("All hooks initialized"));
|
||||
}
|
||||
checkEvents();
|
||||
askWebServer($read);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user