Esempio n. 1
0
<?php

/*
*Project: eYSIP_2015_IoT-Connected-valves-for-irrigation-of-greenhouse
*Team members: Jayant Solanki, Kevin D'Souza
*File name: tasks.php
*Author: Jayant Solanki
*Runs continously in cli mode , executing the scheduled tasks based upon start and stop time
*
*/
include 'iotdb.php';
require __DIR__ . '/spMQTT.class.php';
date_default_timezone_set('Asia/Kolkata');
//setting IST
spMQTTDebug::Enable();
mysql_select_db($dbname) or die(mysql_error());
$query = "SELECT * FROM tasks";
//echo $query;
$results = mysql_query($query);
if (mysql_num_rows($results) > 0) {
    echo "</br>Executing tasks</br>";
    while ($row = mysql_fetch_assoc($results)) {
        $id = $row['id'];
        $start = $row['start'];
        $stop = $row['stop'];
        $action = $row['action'];
        $currenttime = date('Hi');
        //echo $currenttime;
        if ($start != NULL) {
            if ($currenttime >= $start and $currenttime < $stop and $action == 1) {
                $task = "SELECT * FROM devices";