www/cmd_ispindel.php

Tue, 07 Jan 2020 15:47:00 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 07 Jan 2020 15:47:00 +0100
changeset 587
31caffee8c9c
parent 578
e75ce5bbda73
child 593
e0230bf4ac3f
permissions
-rw-r--r--

Changed several float precision values. Changed some database fields to double. Everything has now the same precision as received values from the iSpindel.

570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 require_once('config.php');
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 #Connect to the database
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 if (! $connect) {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 }
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 mysqli_set_charset($connect, "utf8" );
578
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
10 $sql = "";
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11
578
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
12 if (isset($_POST['beername']) && isset($_POST['beercode']) && isset($_POST['beeruuid'])) {
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
13 $sql = "UPDATE `mon_ispindels` SET ";
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
14 $sql .= "beername='" . mysqli_real_escape_string($connect, $_POST['beername']);
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
15 $sql .= "', beercode='" . mysqli_real_escape_string($connect, $_POST['beercode']);
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
16 $sql .= "', beeruuid='" . mysqli_real_escape_string($connect, $_POST['beeruuid']);
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
17 $sql .= "' WHERE uuid='" . $_POST['uuid'] . "';";
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
18 } else if (isset($_POST['mode'])) {
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
19 $sql = "UPDATE `mon_ispindels` SET mode='" .$_POST['mode'] . "' WHERE uuid='" . $_POST['uuid'] . "';";
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
20 }
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 $result = mysqli_query($connect, $sql);
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 if (! $result) {
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 syslog(LOG_NOTICE, "cmd_ispindel: result: ".mysqli_error($connect));
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 } else {
578
e75ce5bbda73 Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents: 570
diff changeset
26 syslog(LOG_NOTICE, "cmd_ispindel: updated record ".$_POST['uuid']);
570
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 }
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 echo $result;
c8a20234d7e7 Added iSpindel monitor screen design.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 ?>

mercurial