ansibleSensor.php
885 Bytes
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
$ini = "";
$arduino_simple = "[Arduino_init]\r\n";
$arduino_spi = "[Arduino_spi_init]\r\n";
$nucleo = "[Nucleo_init]\r\n";
foreach($_POST['sensor'] as $sensor => $value)
{
$version = -1;
$val = explode(":", $value);
if(count($types)<>0 && !in_array($val[2], $types)) {$err = true;}
else {$types[] = $val[2];}
$version = getSensorVersion($val[0], $val[1]);
if($version == 0)
{
$a_simple = true;
$arduino_simple = $arduino_simple.$val[0]." capteur=".$val[1]."\n";
}
elseif($version == 1)
{
$a_spi = true;
$arduino_spi = $arduino_spi.$val[0]." capteur=".$val[1]."\n";
}
elseif($version == 2)
{
$n = true;
$nucleo = $nucleo.$val[0]." capteur=".$val[1]."\n";
}
}
if($a_simple) {$ini = $ini.$arduino_simple."\n";}
if($a_spi) {$ini = $ini.$arduino_spi."\n";}
if($n) {$ini = $ini.$nucleo."\n";}
if(!$err)
{
file_put_contents('upload/inventaire.ini', $ini);
}