#! /usr/bin/perl #Name: IOT-Status.pl version 0.2 #Source & info: www.HomoFaciens.de #http://www.HomoFaciens.de/technics-computer-internet-of-things_en_navion.htm use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $passwd = ""; my $status_only = ""; my $led_red = ""; my $led_green = ""; my $led_yellow = ""; my $led_white = ""; my $servo_1 = ""; my $servo_2 = ""; my $switch_1 = ""; my $switch_2 = ""; my $motor_direction = ""; my $motor_pwm = ""; my $do_reboot = ""; my $make_snapshot = ""; $passwd = param("passwd"); $status_only = param("statusONLY"); $led_red = param("LED_RED"); $led_green = param("LED_GREEN"); $led_yellow = param("LED_YELLOW"); $led_white = param("LED_WHITE"); $servo_1 = param("SERVO_1"); $servo_2 = param("SERVO_2"); $switch_1 = param("SWITCH_1"); $switch_2 = param("SWITCH_2"); $motor_direction = param("MOTOR_DIRECTION"); $motor_pwm = param("MOTOR_PWM"); $do_reboot = param("DOREBOOT"); $make_snapshot = param("MAKE_SNAPSHOT"); my $status_led_green = 0; my $status_led_red = 0; my $status_led_yellow = 0; my $status_led_white = 0; my $status_servo_1 = 0; my $status_servo_2 = 0; my $status_switch_1 = -1; my $status_switch_2 = -1; my $status_motor_direction = 0; my $status_motor_pwm = 0; my $status_make_snapshot = 0; my $status_received = ""; my $file_name = ""; my $system_command = ""; my $allowed_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-"; my $no_matching_password = 1; my $online_status = 0; my $last_status_time = 0; my $last_status_received = ""; my $i = 0; print "Content-type: text/html\n\n"; print '' . "\n"; print "
'; print 'SWITCH 1'; print ' | '; if($status_switch_1 == 512){ print ''; print "CLOSED"; } else{ print ' | '; print "OPEN"; } print ' | '; } if($status_switch_2 > -1){ print ''; print 'SWITCH 2'; print ' | '; if($status_switch_2 == 512){ print ''; print "CLOSED"; } else{ print ' | '; print "OPEN"; } print ' | '; } if($online_status == 1){ print ''; print 'ONLINE'; } else{ print ' | '; print 'OFFLINE'; } print ' | '; print '
'; print 'Status received:'; print ' | '; if($status_led_red eq $led_red && $status_led_green eq $led_green && $status_led_yellow eq $led_yellow && $status_led_white eq $led_white && $status_servo_1 eq $servo_1 && $status_servo_2 eq $servo_2 && $status_motor_direction eq $motor_direction && $status_motor_pwm eq $motor_pwm){ print ''; } else{ print ' | '; } print $last_status_received; print ' | '; print ''; print 'Date / time: '; print ' | '; print ''; print "" . localtime($last_status_time); print ' | '; print ''; print '