-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.php
More file actions
62 lines (50 loc) · 1.43 KB
/
example.php
File metadata and controls
62 lines (50 loc) · 1.43 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
// Root dir of owfs
$owfs_root = '/owfs';
// Example sensor type, here temperature sensors
$owfs_type = 'DS18B20';
?>
<!doctype html>
<html class="no-js" lang="en">
<head>
<style>
pre { border: 1px solid gray; padding: 5px }
</style>
<title>Example page</title>
</head>
<body>
<?php
#ini_set('display_startup_errors', 1);
#ini_set('display_errors', 1);
#error_reporting(-1);
function __autoload($className) {
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
require $fileName;
}
$owfs = new OWFS\OWFS($owfs_root);
echo '<h2>All sensors</h2>';
echo '<pre>$sensors = $owfs->getAll();
print_r($sensors);
', print_r($owfs->getAll(), TRUE), '</pre>';
echo '<h2>All sensors of type "'.$owfs_type.'"</h2>';
echo '<pre>$sensors = $owfs->getByType(\''.$owfs_type.'\');
print_r($sensors);
', print_r($owfs->getByType($owfs_type), TRUE), '</pre>';
echo '<h2>All sensor properties</h2>';
echo '<pre>foreach($owfs->getAll() as $sensor) {
print_r($sensor->getAll());
}
';
foreach($owfs->getAll() as $sensor) print_r($sensor->getAll());
echo '</pre>';
?>
</body>
</html>