1
0
moha/utils.php

48 lines
729 B
PHP
Raw Normal View History

2021-12-30 16:18:32 +01:00
<?php
2022-01-17 00:18:50 +01:00
logger(DEBUG,"Including utils.php");
2021-12-30 16:18:32 +01:00
2022-01-19 00:22:34 +01:00
function bool2string($var)
{
if ($var === false)
{
return "false";
}elseif($var === true)
{
return "true";
}else
{
return $var;
}
}
2021-12-30 16:18:32 +01:00
function now()
{
2022-01-19 00:22:34 +01:00
return date("c");
2021-12-30 16:18:32 +01:00
}
2022-01-17 00:18:50 +01:00
function farenheit2celsius($value)
{
2022-01-17 00:18:50 +01:00
return ($value - 32 / 1.8);
}
function millibars($value)
{
return ($value * 0.029530);
}
function mktopic($device)
{
return $device->topic . "/" . $device->friendlyName;
}
2021-12-30 16:18:32 +01:00
logger(DEBUG, _("signal handling"), false);
//signal handling
function signalHandler($signal)
{
endMoha();
}
pcntl_signal(SIGTERM, 'signalHandler');// Termination ('kill' was called)
pcntl_signal(SIGHUP, 'signalHandler'); // Terminal log-out
pcntl_signal(SIGINT, 'signalHandler');
2021-12-30 16:18:32 +01:00
?>