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";
Esempio n. 2
0
 protected function processRead($message)
 {
     # for PINGRESP
     if (!isset($message[$this->read_bytes - 1])) {
         # error
         spMQTTDebug::Log('Message PINGRESP: error on reading');
         return false;
     }
     $packet = unpack('Ccmd/Clength', $message);
     $packet['cmd'] = spMQTTUtil::UnpackCommand($packet['cmd']);
     if ($packet['cmd']['message_type'] != $this->message_type) {
         spMQTTDebug::Log("Message PINGRESP: type mismatch");
         return false;
     } else {
         spMQTTDebug::Log("Message PINGRESP: success");
         return true;
     }
 }