Bluetooth Low Energy - Python 3 Projects

Bluetooth Low Energy (BLE) - Using iTag and Tile

BLE is a great way to track tings like keys and pets. Using Python 3, BLE Tags (Use cheap iTags on Ebay) and Expensive Tile(s)) to track my keys and also to track my a puppy.

iTag on Ebay - +- $4-6

Tile at JB Hifi - 4 = $79


iTag work just fine for tracking.

I already have an alarm system setup with email and SMS gateway so just leveraging the numerous Raspberry PI Zero W devices in each room to triangulate the BLE broadcast signal from the iTag and Tile and record the RSSI signal in a file. Then use a JSON REST query to get 5 minutes of history (1 min intervals) returned and displayed in a PHP/Javascript web page.

I did use a number of existing blogs and pieced together to create a working solution

Uses:

http://www.kernel.org/pub/linux/bluetooth/bluez-5.54.tar.xz

The solution provided didn't work for me. The reason is that the make file of the official source distribution is searching in the directory /usr/include,

meanwhile the headers are in /usr/include/bluetooth.

I had to copy all the headers from the bluetooth directory to /usr/include.

##########################################################################################

sudo apt install libbluetooth-dev libglib2.0-dev libdbus-1-dev libudev-dev libical-dev libreadline-dev libffi-dev libssl-dev

compile python3 so it picks up bluetooth.h

sudo cp /usr/include/bluetooth/* /usr/include

##########################################################################################

./configure

make

sudo make install


NOTE 01: I had to wireshark the advertisement packets to see what byte position the data was at for the BLE iTag and Tile tags - They are different! AND.....I dont pretend to know exactly what the bluetooth HCI commands do. I copied this from other posts. But it works reliably.

NOTE 02: I dont pause for my car keys search. I only pause for 60s if i find the iTag / Tile tags on the pet dog. But for the car keys i simply log to a file and keep going. After much testing I prefer this way of BLE scanning as it does not take out my entire WIFI network. The other methods were searching for too long and taking out everything on the 2.4 Ghz spectrum. This does not.

##########################################################################################

BASE Python 3.83 script - check-ble-tag-20200617-1.6.py

##########################################################################################

#!/usr/bin/python

#coding: utf-8

#Version 20200617 1.6

#Check BLE Beacon sudo /usr/bin/btmgmt find | grep E1:B6:27:18:2A:20 (Molly tag)



import sys

import time

import datetime

import os

import binascii

import struct

import codecs

from ctypes import (CDLL, get_errno)

from ctypes.util import find_library

from socket import (

socket,

AF_BLUETOOTH,

SOCK_RAW,

BTPROTO_HCI,

SOL_HCI,

HCI_FILTER,

)

if not os.geteuid() == 0:

sys.exit("script only works as root")


btlib = find_library("bluetooth")

if not btlib:

raise Exception(

"Can't find required bluetooth libraries"

" (need to install bluez)"

)


try:

bluez = CDLL(btlib, use_errno=True)

dev_id = bluez.hci_get_route(None)

sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)

sock.bind((dev_id,))

except:

now = datetime.datetime.now()

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error creating Bluez and Socket")

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error creating Bluez and Socket",file=open(logPath+"ble-tag-"+now.strftime("%Y-%m-%d")+".error.log", "a"))

try:

#hci_lib.h - int hci_le_set_scan_parameters(int dev_id, uint8_t type, uint16_t interval,uint16_t window, uint8_t own_type,uint8_t filter, int to);

#uint8_t type = HCI_COMMAND_PKT; = #define HCI_COMMAND_PKT 0x01

bluez.hci_le_set_scan_parameters(sock.fileno(), 0, 0x10, 0x10, 0, 0, 1000);

except:

now = datetime.datetime.now()

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Set initial scan parameters failed")

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Set initial scan parameters failed",file=open(logPath+"ble-tag-"+now.strftime("%Y-%m-%d")+".error.log", "a"))


# allows LE advertising events

hci_filter = struct.pack(

"<IQH",

0x00000010,

0x4000000000000000,

0

)


try:

sock.setsockopt(SOL_HCI, HCI_FILTER, hci_filter)

#sock.setsockopt(SOL_HCI, HCI_FILTER, PASS_ALL)

except:

now = datetime.datetime.now()

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error HCI access to Socket")

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error HCI access to Socket",file=open(logPath+"ble-tag-"+now.strftime("%Y-%m-%d")+".error.log", "a"))


try:

bluez.hci_le_set_scan_enable(

sock.fileno(),

1, # 1 - turn on; 0 - turn off

0, # 0-filtering disabled, 1-filter out duplicates

1000 # timeout

)

except:

now = datetime.datetime.now()

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error enabling scan")

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error enabling scan",file=open(logPath+"ble-tag-"+now.strftime("%Y-%m-%d")+".error.log", "a"))

counter = 1

counterMax = 300

#Molly's MAC Tile

bleTagMacAddress01 = 'E1:B6:27:18:2A:20'

bleTagMacAddressLog01 = 'E1-B6-27-18-2A-20'

bleTagType01 = 'tile'


#Additional BLE Tag - iTag on Molly

bleTagMacAddress02 = 'FF:FF:B2:00:4A:01'

bleTagMacAddressLog02 = 'FF-FF-B2-00-4A-01'

bleTagType02 = 'itag'


#Fullys Car keys - Tile FEEC - Uses different fields - NB

bleTagMacAddress03 = 'C3:71:27:B2:72:B0'

bleTagMacAddressLog03 = 'C3-71-27-B2-72-B0'

bleTagType03 = 'tile-fullys-keys'


#Itag Tag

#bleTagMacAddress = 'FF:FF:AB:05:22:75'

#bleTagMacAddressLog = 'FF-FF-AB-05-22-75'

#log file paths

logPath = '/home/pi/python-scripts/ble/logs/'


while True:

try:

data = sock.recv(1024)

#MAC is reversed by ::-1 and it starts at 6th place and ens at 11 so index stops at 12-1. Tile name 18:19

macAddress = ':'.join(f'{y:02x}' for y in data[12:6:-1])

print("Counter:",counter," Mac Address: ",macAddress.upper())

#Fullys Tile - car keys - dont pause for 60s just log to a seperate file

if macAddress.upper() == bleTagMacAddress03:

#Get UUID16 of name listed at Bluetooth.com - current tile matches 'feed' = 0xed,0xfe (reversed)

tagNameUuid16 = ''.join(f'{z:02x}' for z in data[20:18:-1])


if macAddress.upper() == bleTagMacAddress03:

#print("Tag Name:",str(tagNameUuid16))

if tagNameUuid16.upper() == 'FEED' or tagNameUuid16.upper() == 'FEEC':

tagName = bleTagType03

#data3 = data[34]

#rssi = ''.join(f'{y:02x}' for y in data[35:36])

#tagName = codecs.decode(tagNameStr,"hex")

rssiRaw = data[21:22]

rssiDecode = ord(rssiRaw)

#print("TYPE RSSI:",type(rssi))

#rssi = data[35:36]

rssi = (rssiDecode)-256

else:

tagName = "NA"

rssi = "NA"

now = datetime.datetime.now()

print(counter," ",now.strftime("%Y-%m-%d %H:%M:%S.%f")," ",macAddress.upper(),"Name: ",tagName,"RSSI: ",rssi," dBm")


if macAddress.upper() == bleTagMacAddress03:

now = datetime.datetime.now()

print(counter," ",now.strftime("%Y-%m-%d %H:%M:%S.%f")," ","Match found for ",bleTagType03,",",bleTagMacAddress03,","," RSSI (dBm):",",",rssi)

print(counter,",",now.strftime("%Y-%m-%d %H:%M:%S"),",","BLE Tag - Match found ",",","True",",",bleTagType03,",",bleTagMacAddress03,","," RSSI (dBm):",",",rssi,file=open(logPath+"ble-tag-"+bleTagType03+"-"+bleTagMacAddressLog03+"-"+now.strftime("%Y-%m-%d")+".log", "a"))

#Check for Tile tag first

if macAddress.upper() == bleTagMacAddress01:

#Get UUID16 of name listed at Bluetooth.com - current tile matches 'feed' = 0xed,0xfe (reversed)

tagNameUuid16 = ''.join(f'{z:02x}' for z in data[34:32:-1])


if macAddress.upper() == bleTagMacAddress01:

#print("Tag Name:",str(tagNameUuid16))

if tagNameUuid16.upper() == 'FEED' or tagNameUuid16.upper() == 'FEEC':

tagName = "tile"

#data3 = data[34]

#rssi = ''.join(f'{y:02x}' for y in data[35:36])

#tagName = codecs.decode(tagNameStr,"hex")

rssiRaw = data[35:36]

rssiDecode = ord(rssiRaw)

#print("TYPE RSSI:",type(rssi))

#rssi = data[35:36]

rssi = (rssiDecode)-256

else:

tagName = "NA"

rssi = "NA"

now = datetime.datetime.now()

print(counter," ",now.strftime("%Y-%m-%d %H:%M:%S.%f")," ",macAddress.upper(),"Name: ",tagName,"RSSI: ",rssi," dBm")


if macAddress.upper() == bleTagMacAddress01:

now = datetime.datetime.now()

print(counter," ",now.strftime("%Y-%m-%d %H:%M:%S.%f")," ","Match found for ",bleTagType01,",",bleTagMacAddress01,","," RSSI (dBm):",",",rssi)

print(counter,",",now.strftime("%Y-%m-%d %H:%M:%S"),",","BLE Tag - Match found ",",","True",",",bleTagType01,",",bleTagMacAddress01,","," RSSI (dBm):",",",rssi,file=open(logPath+"ble-tag-"+bleTagType01+"-"+bleTagMacAddressLog01+"-"+now.strftime("%Y-%m-%d")+".log", "a"))

try:

bluez.hci_le_set_scan_enable(

sock.fileno(),

0, # 1 - turn on; 0 - turn off

0, # 0-filtering disabled, 1-filter out duplicates

1000 # timeout

)

except:

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error disabling scan")

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error disabling scan",file=open(logPath+"ble-tag-"+now.strftime("%Y-%m-%d")+".error.log", "a"))

#counter=1

#sleep for 60s if tag found

time.sleep(60)

#Reset counter

counter=0

try:

bluez.hci_le_set_scan_enable(

sock.fileno(),

1, # 1 - turn on; 0 - turn off

0, # 0-filtering disabled, 1-filter out duplicates

1000 # timeout

)

except:

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error enabling scan")

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error enabling scan",file=open(logPath+"ble-tag-"+now.strftime("%Y-%m-%d")+".error.log", "a"))

#iTag

if macAddress.upper() == bleTagMacAddress02:

#Get UUID16 of name listed at Bluetooth.com - current tile matches 'feed' = 0xed,0xfe (reversed)

tagNameUuid16 = ''.join(f'{z:02x}' for z in data[27:25:-1])


if macAddress.upper() == bleTagMacAddress02:

#print("Tag Name:",str(tagNameUuid16))

if tagNameUuid16.upper() == 'FFE0': #or tagNameUuid16.upper() == 'FEEC':

tagName = "iTag"

#print("DEBUG: Tag Name: ",tagName)

#data3 = data[34]

#rssi = ''.join(f'{y:02x}' for y in data[35:36])

#tagName = codecs.decode(tagNameStr,"hex")

rssiRaw = data[28:29]

#print("RSSI Raw:",rssiRaw)

rssiDecode = ord(rssiRaw)

#print("TYPE RSSI:",type(rssi))

#rssi = data[35:36]

rssi = (rssiDecode-256)

else:

tagName = "NA"

rssi = "NA"

now = datetime.datetime.now()

print(counter," ",now.strftime("%Y-%m-%d %H:%M:%S.%f")," ",macAddress.upper(),"Name: ",tagName,"RSSI: ",rssi," dBm")


if macAddress.upper() == bleTagMacAddress02:

now = datetime.datetime.now()

print(counter," ",now.strftime("%Y-%m-%d %H:%M:%S.%f")," ","Match found for ",bleTagType02,",",bleTagMacAddress02,","," RSSI (dBm):",",",rssi)

print(counter,",",now.strftime("%Y-%m-%d %H:%M:%S"),",","BLE Tag - Match found ",",","True",",",bleTagType02,",",bleTagMacAddress02,","," RSSI (dBm):",",",rssi,file=open(logPath+"ble-tag-"+bleTagType01+"-"+bleTagMacAddressLog01+"-"+now.strftime("%Y-%m-%d")+".log", "a"))

try:

bluez.hci_le_set_scan_enable(

sock.fileno(),

0, # 1 - turn on; 0 - turn off

0, # 0-filtering disabled, 1-filter out duplicates

1000 # timeout

)

except:

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error disabling scan")

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error disabling scan",file=open(logPath+"ble-tag-"+now.strftime("%Y-%m-%d")+".error.log", "a"))

#counter=1

#sleep for 60s if tag found

time.sleep(60)

#Reset counter

counter=0

try:

bluez.hci_le_set_scan_enable(

sock.fileno(),

1, # 1 - turn on; 0 - turn off

0, # 0-filtering disabled, 1-filter out duplicates

1000 # timeout

)

except:

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error enabling scan")

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error enabling scan",file=open(logPath+"ble-tag-"+now.strftime("%Y-%m-%d")+".error.log", "a"))

counter = counter+1


#Try 20 samples before pausing for 60s

if (counter == counterMax):

now = datetime.datetime.now()

print("Match NOT found in the time required for ",bleTagType01,"=",bleTagMacAddress01)

print("Match NOT found in the time required for ",bleTagType02,"=",bleTagMacAddress02)

print("Match NOT found in the time required for ",bleTagType03,"=",bleTagMacAddress03)

print(counter,",",now.strftime("%Y-%m-%d %H:%M:%S"),",","BLE Tag - Match NOT found ",",","False",",",bleTagType01,",",bleTagMacAddress01,",","RSSI",","," ",file=open(logPath+"ble-tag-"+bleTagType01+"-"+bleTagMacAddressLog01+"-"+now.strftime("%Y-%m-%d")+".log", "a"))

print(counter,",",now.strftime("%Y-%m-%d %H:%M:%S"),",","BLE Tag - Match NOT found ",",","False",",",bleTagType02,",",bleTagMacAddress02,",","RSSI",","," ",file=open(logPath+"ble-tag-"+bleTagType01+"-"+bleTagMacAddressLog01+"-"+now.strftime("%Y-%m-%d")+".log", "a"))

print(counter,",",now.strftime("%Y-%m-%d %H:%M:%S"),",","BLE Tag - Match NOT found ",",","False",",",bleTagType03,",",bleTagMacAddress03,",","RSSI",","," ",file=open(logPath+"ble-tag-"+bleTagType03+"-"+bleTagMacAddressLog03+"-"+now.strftime("%Y-%m-%d")+".log", "a"))


try:

bluez.hci_le_set_scan_enable(

sock.fileno(),

0, # 1 - turn on; 0 - turn off

0, # 0-filtering disabled, 1-filter out duplicates

1000 # timeout

)

except:

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error disabling scan")

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error disabling scan",file=open(logPath+"ble-tag-"+now.strftime("%Y-%m-%d")+".error.log", "a"))

counter=1

#sleep for 60s if tag not found in case out of range

time.sleep(60)

try:

bluez.hci_le_set_scan_enable(

sock.fileno(),

1, # 1 - turn on; 0 - turn off

0, # 0-filtering disabled, 1-filter out duplicates

1000 # timeout

)

except:

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error enabling scan")

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error enabling scan",file=open(logPath+"ble-tag-"+now.strftime("%Y-%m-%d")+".error.log", "a"))

#Log to file if found


#asciiData = str(data1,'ascii')

#binascii.unhexlify(_).decode('utf8')

#print(data)

#res = ""

#for b in data:

# res += "%02x" % b

# print(res)

except KeyboardInterrupt:

# here you put any code you want to run before the program

# exits when you press CTRL+C

try:

bluez.hci_le_set_scan_enable(sock.fileno(),0, # 1 - turn on; 0 - turn off

0, # 0-filtering disabled, 1-filter out duplicates

1000 # timeout

)

exit()

except:

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error disabling scan")

print(now.strftime("%Y-%m-%d %H:%M:%S"),",","Error disabling scan",file=open(logPath+"ble-tag-"+now.strftime("%Y-%m-%d")+".error.log", "a"))

except Exception as inst:

print(type(inst)) # the exception instance

print(inst.args) # arguments stored in .args

print(inst) # __str__ allows args to be printed directly,

# but may be overridden in exception subclasses

x, y = inst.args # unpack args

print('x =', x)

print('y =', y)

#####################################################################################################################

Once I have the required data logged then I used a JSON PHP query and then I display the results using html and CSS.


For each RPI Zero W: status-engine-ble.php

#####################################################################################################################

<?php

//Allow other servers to access this info remotely via PHP/JSON/Javascript etc

//version 20200530 1.0

header("Access-Control-Allow-Origin: *");

//header("Content-Type: application/json; charset=UTF-8");

header("Content-Type:application/json");

date_default_timezone_set('Australia/Brisbane');


$logNamePath = '/home/pi/python-scripts/ble/logs/';

$dateTempCheck = date("Y-m-d");

$dateTimeTempCheck = date("Y-m-d-H-i-s");

$bleTagMacAddressLog = 'E1-B6-27-18-2A-20';

$bleTagType = 'tile';#Tag as listed under bluetooth.com FEED or FEEC - UUID16

//log

$tempLogName = $logNamePath."ble-tag-".$bleTagType."-".$bleTagMacAddressLog."-".$dateTempCheck.".log";

#Debug

#print($tempLogName);

//Calculate number of lines in file

$row2=0;


$bleTagDateTimeCheck = "";

$bleTagStatus = "";

$bleTagRssi = "";


$bleTagDateTimeCheckOneMin = "";

$bleTagStatusOneMin = "";

$bleTagRssiOneMin = "";


$bleTagDateTimeCheckTwoMin = "";

$bleTagStatusTwoMin = "";

$bleTagRssiTwoMin = "";


$bleTagDateTimeCheckThreeMin = "";

$bleTagStatusThreeMin = "";

$bleTagRssiThreeMin = "";


$bleTagDateTimeCheckFourMin = "";

$bleTagStatusFourMin = "";

$bleTagRssiFourMin = "";


$bleTagDateTimeCheckFiveMin = "";

$bleTagStatusFiveMin = "";

$bleTagRssiFiveMin = "";


$numLinesTempLog = count(file($tempLogName));


if ((($handle = fopen($tempLogName, "r")) !== FALSE))

{

while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)

{

$row2++;

#get the last 5 minutes of rssi data

#Five minutes before

if ($row2 == ($numLinesTempLog - 5))

{

$bleTagDateTimeCheckFiveMin = trim($data[1]);

$bleTagStatusFiveMin = trim($data[3]);

$bleTagRssiFiveMin = trim($data[7]);

}


#Four minutes before

if ($row2 == ($numLinesTempLog - 4))

{

$bleTagDateTimeCheckFourMin = trim($data[1]);

$bleTagStatusFourMin = trim($data[3]);

$bleTagRssiFourMin = trim($data[7]);

}


#Three minutes before

if ($row2 == ($numLinesTempLog - 3))

{

$bleTagDateTimeCheckThreeMin = trim($data[1]);

$bleTagStatusThreeMin = trim($data[3]);

$bleTagRssiThreeMin = trim($data[7]);

}


#Two minutes before

if ($row2 == ($numLinesTempLog - 2))

{

$bleTagDateTimeCheckTwoMin = trim($data[1]);

$bleTagStatusTwoMin = trim($data[3]);

$bleTagRssiTwoMin = trim($data[7]);

}


#One Minute before

if ($row2 == ($numLinesTempLog - 1))

{

$bleTagDateTimeCheckOneMin = trim($data[1]);

$bleTagStatusOneMin = trim($data[3]);

$bleTagRssiOneMin = trim($data[7]);

}


#Current min

if ($row2 == $numLinesTempLog)

{

$bleTagDateTimeCheck = trim($data[1]);

$bleTagStatus = trim($data[3]);

$bleTagRssi = trim($data[7]);

}

}

}


#Send JSON data

response(200,"10.88.10.17","BLE Scan Room 01",$bleTagDateTimeCheck,$bleTagStatus,$bleTagRssi,$bleTagDateTimeCheckOneMin,$bleTagStatusOneMin,$bleTagRssiOneMin,$bleTagDateTimeCheckTwoMin,$bleTagStatusTwoMin,$bleTagRssiTwoMin,$bleTagDateTimeCheckThreeMin,$bleTagStatusThreeMin,$bleTagRssiThreeMin,$bleTagDateTimeCheckFourMin,$bleTagStatusFourMin,$bleTagRssiFourMin,$bleTagDateTimeCheckFiveMin,$bleTagStatusFiveMin,$bleTagRssiFiveMin);


function response($status,$ipAddress,$locationName,$bleTagDateTimeCheck,$bleTagStatus,$bleTagRssi,$bleTagDateTimeCheckOneMin,$bleTagStatusOneMin,$bleTagRssiOneMin,$bleTagDateTimeCheckTwoMin,$bleTagStatusTwoMin,$bleTagRssiTwoMin,$bleTagDateTimeCheckThreeMin,$bleTagStatusThreeMin,$bleTagRssiThreeMin,$bleTagDateTimeCheckFourMin,$bleTagStatusFourMin,$bleTagRssiFourMin,$bleTagDateTimeCheckFiveMin,$bleTagStatusFiveMin,$bleTagRssiFiveMin)

{

header("HTTP/1.1 ".$status);

$response['status']=$status;

$response['ipAddress']=$ipAddress;

$response['locationName']=$locationName;

$response['bleTagDateTimeCheck']=$bleTagDateTimeCheck;

$response['bleTagStatus']=$bleTagStatus;

$response['bleTagRssi']=$bleTagRssi;

$response['bleTagDateTimeCheckOneMin']=$bleTagDateTimeCheckOneMin;

$response['bleTagStatusOneMin']=$bleTagStatusOneMin;

$response['bleTagRssiOneMin']=$bleTagRssiOneMin;

$response['bleTagDateTimeCheckTwoMin']=$bleTagDateTimeCheckTwoMin;

$response['bleTagStatusTwoMin']=$bleTagStatusTwoMin;

$response['bleTagRssiTwoMin']=$bleTagRssiTwoMin;

$response['bleTagDateTimeCheckThreeMin']=$bleTagDateTimeCheckThreeMin;

$response['bleTagStatusThreeMin']=$bleTagStatusThreeMin;

$response['bleTagRssiThreeMin']=$bleTagRssiThreeMin;

$response['bleTagDateTimeCheckFourMin']=$bleTagDateTimeCheckFourMin;

$response['bleTagStatusFourMin']=$bleTagStatusFourMin;

$response['bleTagRssiFourMin']=$bleTagRssiFourMin;

$response['bleTagDateTimeCheckFiveMin']=$bleTagDateTimeCheckFiveMin;

$response['bleTagStatusFiveMin']=$bleTagStatusFiveMin;

$response['bleTagRssiFiveMin']=$bleTagRssiFiveMin;

#Debug

#print("Five Min:".$bleTagDateTimeCheckFiveMin);

//load json array

$json_response = json_encode($response);

echo $json_response;

}


?>


#########################################################################################################################

Then use a php webpage to interrogate each status-engine-ble.php file and return all results to tabulate the RSSI and a True/False:

status-ble.php

########################################################################################################################

<!--| Designed By: Andrew Fullagar | Edited Last By: Andrew Fullagar | afullagar@gmail.com |-->

<!DOCTYPE html>

<?php

####Debug Start

/**

* Simple function to replicate PHP 5 behaviour

*/


#Note: Install gd or graphs wont work - sudo apt-get install php7.0-gd

#Enable debug reporting to browser

echo("<html>");

echo("<head>");

echo('<title>Py Arm IoT - BLE Scan Lounge - Overall status BLE Tag</title>');


#Set Version info for page

$pageVersion = "20200530-1.0";


//Set time zone to avoid daylight savings

date_default_timezone_set('Australia/Brisbane');


if (!empty($_SERVER['HTTPS']))

{

$Prot='https';

}

else

{

$Prot='http';

}


echo("<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $Prot . "://" . $_SERVER['SERVER_NAME'] . "/../css/css-default.css\"></link>");

#echo("<meta http-equiv='refresh' content='1'>"); //Refresh by HTTP META


echo("</head>");


echo("<body>");


echo("<div id=\"bodycenter\">");

echo("<h1>Py Arm IoT Configuration - BLE Scan Lounge - Overall Status BLE Tag</h1>");

#Refresh page every x Seconds

$page = $_SERVER['PHP_SELF'];

$sec = "60";

header("Refresh: $sec; url=$page");

//Get current dat and time

$dateCheck = date("Y-m-d");

$timeCheck = date("H-i-s");

//Placeholder for data from JSON Objects via Javascript

print("<h2>Date: $dateCheck, Time: $timeCheck</h2>");

print("<table>");


print("<tr>");


print("<th>IP Address</th>");

print("<th>Location</th>");


print("<th>BLE Tag Checked</th>");

print("<th>BLE Tag (RSSI)</th>");


print("<th>BLE Tag Checked (1m)</th>");

print("<th>BLE Tag (RSSI) (1m)</th>");


print("<th>BLE Tag Checked (2m)</th>");

print("<th>BLE Tag (RSSI) (2m)</th>");


print("<th>BLE Tag Checked (3m)</th>");

print("<th>BLE Tag (RSSI) (3m)</th>");


print("<th>BLE Tag Checked (4m)</th>");

print("<th>BLE Tag (RSSI) (4m)</th>");


print("<th>BLE Tag Checked (5m)</th>");

print("<th>BLE Tag (RSSI) (5m)</th>");


print("</tr>");


print("<tr>");

print("<td id=\"10-88-10-11-ipAddress\">---</td>");

print("<td id=\"10-88-10-11-locationName\">---</td>");

print("<td id=\"10-88-10-11-bleTagDateTimeCheck\">---</td>");

print("<td id=\"10-88-10-11-bleTagStatus\">---</td>");

print("<td id=\"10-88-10-11-bleTagDateTimeCheckOneMin\">---</td>");

print("<td id=\"10-88-10-11-bleTagStatusOneMin\">---</td>");

print("<td id=\"10-88-10-11-bleTagDateTimeCheckTwoMin\">---</td>");

print("<td id=\"10-88-10-11-bleTagStatusTwoMin\">---</td>");

print("<td id=\"10-88-10-11-bleTagDateTimeCheckThreeMin\">---</td>");

print("<td id=\"10-88-10-11-bleTagStatusThreeMin\">---</td>");

print("<td id=\"10-88-10-11-bleTagDateTimeCheckFourMin\">---</td>");

print("<td id=\"10-88-10-11-bleTagStatusFourMin\">---</td>");

print("<td id=\"10-88-10-11-bleTagDateTimeCheckFiveMin\">---</td>");

print("<td id=\"10-88-10-11-bleTagStatusFiveMin\">---</td>");

print("</tr>");


print("<tr>");

print("<td id=\"10-88-10-12-ipAddress\">---</td>");

print("<td id=\"10-88-10-12-locationName\">---</td>");

print("<td id=\"10-88-10-12-bleTagDateTimeCheck\">---</td>");

print("<td id=\"10-88-10-12-bleTagStatus\">---</td>");

print("<td id=\"10-88-10-12-bleTagDateTimeCheckOneMin\">---</td>");

print("<td id=\"10-88-10-12-bleTagStatusOneMin\">---</td>");

print("<td id=\"10-88-10-12-bleTagDateTimeCheckTwoMin\">---</td>");

print("<td id=\"10-88-10-12-bleTagStatusTwoMin\">---</td>");

print("<td id=\"10-88-10-12-bleTagDateTimeCheckThreeMin\">---</td>");

print("<td id=\"10-88-10-12-bleTagStatusThreeMin\">---</td>");

print("<td id=\"10-88-10-12-bleTagDateTimeCheckFourMin\">---</td>");

print("<td id=\"10-88-10-12-bleTagStatusFourMin\">---</td>");

print("<td id=\"10-88-10-12-bleTagDateTimeCheckFiveMin\">---</td>");

print("<td id=\"10-88-10-12-bleTagStatusFiveMin\">---</td>");

print("</tr>");


print("<tr>");

print("<td id=\"10-88-10-13-ipAddress\">---</td>");

print("<td id=\"10-88-10-13-locationName\">---</td>");

print("<td id=\"10-88-10-13-bleTagDateTimeCheck\">---</td>");

print("<td id=\"10-88-10-13-bleTagStatus\">---</td>");

print("<td id=\"10-88-10-13-bleTagDateTimeCheckOneMin\">---</td>");

print("<td id=\"10-88-10-13-bleTagStatusOneMin\">---</td>");

print("<td id=\"10-88-10-13-bleTagDateTimeCheckTwoMin\">---</td>");

print("<td id=\"10-88-10-13-bleTagStatusTwoMin\">---</td>");

print("<td id=\"10-88-10-13-bleTagDateTimeCheckThreeMin\">---</td>");

print("<td id=\"10-88-10-13-bleTagStatusThreeMin\">---</td>");

print("<td id=\"10-88-10-13-bleTagDateTimeCheckFourMin\">---</td>");

print("<td id=\"10-88-10-13-bleTagStatusFourMin\">---</td>");

print("<td id=\"10-88-10-13-bleTagDateTimeCheckFiveMin\">---</td>");

print("<td id=\"10-88-10-13-bleTagStatusFiveMin\">---</td>");

print("</tr>");


print("<tr>");

print("<td id=\"10-88-10-14-ipAddress\">---</td>");

print("<td id=\"10-88-10-14-locationName\">---</td>");

print("<td id=\"10-88-10-14-bleTagDateTimeCheck\">---</td>");

print("<td id=\"10-88-10-14-bleTagStatus\">---</td>");

print("<td id=\"10-88-10-14-bleTagDateTimeCheckOneMin\">---</td>");

print("<td id=\"10-88-10-14-bleTagStatusOneMin\">---</td>");

print("<td id=\"10-88-10-14-bleTagDateTimeCheckTwoMin\">---</td>");

print("<td id=\"10-88-10-14-bleTagStatusTwoMin\">---</td>");

print("<td id=\"10-88-10-14-bleTagDateTimeCheckThreeMin\">---</td>");

print("<td id=\"10-88-10-14-bleTagStatusThreeMin\">---</td>");

print("<td id=\"10-88-10-14-bleTagDateTimeCheckFourMin\">---</td>");

print("<td id=\"10-88-10-14-bleTagStatusFourMin\">---</td>");

print("<td id=\"10-88-10-14-bleTagDateTimeCheckFiveMin\">---</td>");

print("<td id=\"10-88-10-14-bleTagStatusFiveMin\">---</td>");

print("</tr>");


print("<tr>");

print("<td id=\"10-88-10-15-ipAddress\">---</td>");

print("<td id=\"10-88-10-15-locationName\">---</td>");

print("<td id=\"10-88-10-15-bleTagDateTimeCheck\">---</td>");

print("<td id=\"10-88-10-15-bleTagStatus\">---</td>");

print("<td id=\"10-88-10-15-bleTagDateTimeCheckOneMin\">---</td>");

print("<td id=\"10-88-10-15-bleTagStatusOneMin\">---</td>");

print("<td id=\"10-88-10-15-bleTagDateTimeCheckTwoMin\">---</td>");

print("<td id=\"10-88-10-15-bleTagStatusTwoMin\">---</td>");

print("<td id=\"10-88-10-15-bleTagDateTimeCheckThreeMin\">---</td>");

print("<td id=\"10-88-10-15-bleTagStatusThreeMin\">---</td>");

print("<td id=\"10-88-10-15-bleTagDateTimeCheckFourMin\">---</td>");

print("<td id=\"10-88-10-15-bleTagStatusFourMin\">---</td>");

print("<td id=\"10-88-10-15-bleTagDateTimeCheckFiveMin\">---</td>");

print("<td id=\"10-88-10-15-bleTagStatusFiveMin\">---</td>");

print("</tr>");


print("<tr>");

print("<td id=\"10-88-10-17-ipAddress\">---</td>");

print("<td id=\"10-88-10-17-locationName\">---</td>");

print("<td id=\"10-88-10-17-bleTagDateTimeCheck\">---</td>");

print("<td id=\"10-88-10-17-bleTagStatus\">---</td>");

print("<td id=\"10-88-10-17-bleTagDateTimeCheckOneMin\">---</td>");

print("<td id=\"10-88-10-17-bleTagStatusOneMin\">---</td>");

print("<td id=\"10-88-10-17-bleTagDateTimeCheckTwoMin\">---</td>");

print("<td id=\"10-88-10-17-bleTagStatusTwoMin\">---</td>");

print("<td id=\"10-88-10-17-bleTagDateTimeCheckThreeMin\">---</td>");

print("<td id=\"10-88-10-17-bleTagStatusThreeMin\">---</td>");

print("<td id=\"10-88-10-17-bleTagDateTimeCheckFourMin\">---</td>");

print("<td id=\"10-88-10-17-bleTagStatusFourMin\">---</td>");

print("<td id=\"10-88-10-17-bleTagDateTimeCheckFiveMin\">---</td>");

print("<td id=\"10-88-10-17-bleTagStatusFiveMin\">---</td>");

print("</tr>");


print("<tr>");

print("<td id=\"10-88-10-18-ipAddress\">---</td>");

print("<td id=\"10-88-10-18-locationName\">---</td>");

print("<td id=\"10-88-10-18-bleTagDateTimeCheck\">---</td>");

print("<td id=\"10-88-10-18-bleTagStatus\">---</td>");

print("<td id=\"10-88-10-18-bleTagDateTimeCheckOneMin\">---</td>");

print("<td id=\"10-88-10-18-bleTagStatusOneMin\">---</td>");

print("<td id=\"10-88-10-18-bleTagDateTimeCheckTwoMin\">---</td>");

print("<td id=\"10-88-10-18-bleTagStatusTwoMin\">---</td>");

print("<td id=\"10-88-10-18-bleTagDateTimeCheckThreeMin\">---</td>");

print("<td id=\"10-88-10-18-bleTagStatusThreeMin\">---</td>");

print("<td id=\"10-88-10-18-bleTagDateTimeCheckFourMin\">---</td>");

print("<td id=\"10-88-10-18-bleTagStatusFourMin\">---</td>");

print("<td id=\"10-88-10-18-bleTagDateTimeCheckFiveMin\">---</td>");

print("<td id=\"10-88-10-18-bleTagStatusFiveMin\">---</td>");

print("</tr>");


print("<tr>");

print("<td id=\"10-88-10-19-ipAddress\">---</td>");

print("<td id=\"10-88-10-19-locationName\">---</td>");

print("<td id=\"10-88-10-19-bleTagDateTimeCheck\">---</td>");

print("<td id=\"10-88-10-19-bleTagStatus\">---</td>");

print("<td id=\"10-88-10-19-bleTagDateTimeCheckOneMin\">---</td>");

print("<td id=\"10-88-10-19-bleTagStatusOneMin\">---</td>");

print("<td id=\"10-88-10-19-bleTagDateTimeCheckTwoMin\">---</td>");

print("<td id=\"10-88-10-19-bleTagStatusTwoMin\">---</td>");

print("<td id=\"10-88-10-19-bleTagDateTimeCheckThreeMin\">---</td>");

print("<td id=\"10-88-10-19-bleTagStatusThreeMin\">---</td>");

print("<td id=\"10-88-10-19-bleTagDateTimeCheckFourMin\">---</td>");

print("<td id=\"10-88-10-19-bleTagStatusFourMin\">---</td>");

print("<td id=\"10-88-10-19-bleTagDateTimeCheckFiveMin\">---</td>");

print("<td id=\"10-88-10-19-bleTagStatusFiveMin\">---</td>");

print("</tr>");


print("<tr>");

print("<td id=\"10-88-10-21-ipAddress\">---</td>");

print("<td id=\"10-88-10-21-locationName\">---</td>");

print("<td id=\"10-88-10-21-bleTagDateTimeCheck\">---</td>");

print("<td id=\"10-88-10-21-bleTagStatus\">---</td>");

print("<td id=\"10-88-10-21-bleTagDateTimeCheckOneMin\">---</td>");

print("<td id=\"10-88-10-21-bleTagStatusOneMin\">---</td>");

print("<td id=\"10-88-10-21-bleTagDateTimeCheckTwoMin\">---</td>");

print("<td id=\"10-88-10-21-bleTagStatusTwoMin\">---</td>");

print("<td id=\"10-88-10-21-bleTagDateTimeCheckThreeMin\">---</td>");

print("<td id=\"10-88-10-21-bleTagStatusThreeMin\">---</td>");

print("<td id=\"10-88-10-21-bleTagDateTimeCheckFourMin\">---</td>");

print("<td id=\"10-88-10-21-bleTagStatusFourMin\">---</td>");

print("<td id=\"10-88-10-21-bleTagDateTimeCheckFiveMin\">---</td>");

print("<td id=\"10-88-10-21-bleTagStatusFiveMin\">---</td>");

print("</tr>");



print("</table>");


?>


<script type='text/javascript'>


//set high threshold vars for RPIs - Red

var $bleTagStatusHighRpizerow = -89;

//Set upper and lower for RPIs - OrangeRed

var $bleTagStatusMediumUpperRpizerow = -90;

var $bleTagStatusMediumLowerRpizerow = -95;

//Set upper and lower for RPIs - Light Green

var $bleTagStatusLowUpperRpizerow = -96;

var $bleTagStatusLowLowerRpizerow = -100;

//Blue

var $bleTagStatusLowestRpizerow = -101;


var $bleTagStatusZeroRpizerow = 0;



//10.88.10.11 - Lounge

var jsonHttp11 = new XMLHttpRequest();

var url11 = "http://10.88.10.11/status-engine-ble.php";


jsonHttp11.overrideMimeType("application/json");

jsonHttp11.open('GET', url11, true);

jsonHttp11.send();


jsonHttp11.onreadystatechange = function()

{

if (this.readyState == 4 && this.status == 200)

{

//Returns an object reference for JSON

var jsonResponse11 = JSON.parse(jsonHttp11.responseText);

//var jsonResponse = jsonHttp.responseText;

document.getElementById("10-88-10-11-ipAddress").innerHTML = '<a href="http://'+jsonResponse11.ipAddress+'" target="_blank"> '+jsonResponse11.ipAddress+'</a>';

document.getElementById("10-88-10-11-locationName").innerHTML = jsonResponse11.locationName;

document.getElementById("10-88-10-11-bleTagDateTimeCheck").innerHTML = jsonResponse11.bleTagDateTimeCheck;

document.getElementById("10-88-10-11-bleTagStatus").innerHTML = jsonResponse11.bleTagStatus + " " + jsonResponse11.bleTagRssi;


document.getElementById("10-88-10-11-bleTagDateTimeCheckOneMin").innerHTML = jsonResponse11.bleTagDateTimeCheckOneMin;

document.getElementById("10-88-10-11-bleTagStatusOneMin").innerHTML = jsonResponse11.bleTagStatusOneMin + " " + jsonResponse11.bleTagRssiOneMin;

document.getElementById("10-88-10-11-bleTagDateTimeCheckTwoMin").innerHTML = jsonResponse11.bleTagDateTimeCheckTwoMin;

document.getElementById("10-88-10-11-bleTagStatusTwoMin").innerHTML = jsonResponse11.bleTagStatusTwoMin + " " + jsonResponse11.bleTagRssiTwoMin;

document.getElementById("10-88-10-11-bleTagDateTimeCheckThreeMin").innerHTML = jsonResponse11.bleTagDateTimeCheckThreeMin;

document.getElementById("10-88-10-11-bleTagStatusThreeMin").innerHTML = jsonResponse11.bleTagStatusThreeMin + " " + jsonResponse11.bleTagRssiThreeMin;

document.getElementById("10-88-10-11-bleTagDateTimeCheckFourMin").innerHTML = jsonResponse11.bleTagDateTimeCheckFourMin;

document.getElementById("10-88-10-11-bleTagStatusFourMin").innerHTML = jsonResponse11.bleTagStatusFourMin + " " + jsonResponse11.bleTagRssiFourMin;

document.getElementById("10-88-10-11-bleTagDateTimeCheckFiveMin").innerHTML = jsonResponse11.bleTagDateTimeCheckFiveMin;

document.getElementById("10-88-10-11-bleTagStatusFiveMin").innerHTML = jsonResponse11.bleTagStatusFiveMin + " " + jsonResponse11.bleTagRssiFiveMin;

//Change background color based on value threshold

if (jsonResponse11.bleTagStatus == 'True')

{

//Green


document.getElementById('10-88-10-11-bleTagStatus').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse11.bleTagStatus == 'False')

{

//Red


document.getElementById('10-88-10-11-bleTagStatus').style.background="rgb("+255+","+0+","+0+")";

}

//One Min


if (jsonResponse11.bleTagStatusOneMin == 'True')

{

//Green

document.getElementById('10-88-10-11-bleTagStatusOneMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse11.bleTagStatusOneMin == 'False')

{

//Red

document.getElementById('10-88-10-11-bleTagStatusOneMin').style.background="rgb("+255+","+0+","+0+")";

}


//Two Min

if (jsonResponse11.bleTagStatusTwoMin == 'True')

{

//Green

document.getElementById('10-88-10-11-bleTagStatusTwoMin').style.background="rgb("+57+","+255+","+20+")";


}

else if (jsonResponse11.bleTagStatusTwoMin == 'False')

{

//Red

document.getElementById('10-88-10-11-bleTagStatusTwoMin').style.background="rgb("+255+","+0+","+0+")";


}

//Three Min

if (jsonResponse11.bleTagStatusThreeMin == 'True')

{

//Green


document.getElementById('10-88-10-11-bleTagStatusThreeMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse11.bleTagStatusThreeMin == 'False')

{

//Red


document.getElementById('10-88-10-11-bleTagStatusThreeMin').style.background="rgb("+255+","+0+","+0+")";

}

//Four Min

if (jsonResponse11.bleTagStatusFourMin == 'True')

{

//Green

document.getElementById('10-88-10-11-bleTagStatusFourMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse11.bleTagStatusFourMin == 'False')


{

//Red

document.getElementById('10-88-10-11-bleTagStatusFourMin').style.background="rgb("+255+","+0+","+0+")";

}

//Five Min


if (jsonResponse11.bleTagStatusFiveMin == 'True')

{

//Green

document.getElementById('10-88-10-11-bleTagStatusFiveMin').style.background="rgb("+57+","+255+","+20+")";

}


else if (jsonResponse11.bleTagStatusFiveMin == 'False')

{

//Red

document.getElementById('10-88-10-11-bleTagStatusFiveMin').style.background="rgb("+255+","+0+","+0+")";

}

}

};



//Garage

//10.88.10.12 - Garage

var jsonHttp12 = new XMLHttpRequest();

var url12 = "http://10.88.10.12/status-engine-ble.php";


jsonHttp12.overrideMimeType("application/json");

jsonHttp12.open('GET', url12, true);

jsonHttp12.send();


jsonHttp12.onreadystatechange = function()


{


if (this.readyState == 4 && this.status == 200)


{


//Returns an object reference for JSON


var jsonResponse12 = JSON.parse(jsonHttp12.responseText);


//var jsonResponse = jsonHttp.responseText;


document.getElementById("10-88-10-12-ipAddress").innerHTML = '<a href="http://'+jsonResponse12.ipAddress+'" target="_blank"> '+jsonResponse12.ipAddress+'</a>';


document.getElementById("10-88-10-12-locationName").innerHTML = jsonResponse12.locationName;


document.getElementById("10-88-10-12-bleTagDateTimeCheck").innerHTML = jsonResponse12.bleTagDateTimeCheck;


document.getElementById("10-88-10-12-bleTagStatus").innerHTML = jsonResponse12.bleTagStatus + " " + jsonResponse12.bleTagRssi;



document.getElementById("10-88-10-12-bleTagDateTimeCheckOneMin").innerHTML = jsonResponse12.bleTagDateTimeCheckOneMin;


document.getElementById("10-88-10-12-bleTagStatusOneMin").innerHTML = jsonResponse12.bleTagStatusOneMin + " " + jsonResponse12.bleTagRssiOneMin;


document.getElementById("10-88-10-12-bleTagDateTimeCheckTwoMin").innerHTML = jsonResponse12.bleTagDateTimeCheckTwoMin;


document.getElementById("10-88-10-12-bleTagStatusTwoMin").innerHTML = jsonResponse12.bleTagStatusTwoMin + " " + jsonResponse12.bleTagRssiTwoMin;


document.getElementById("10-88-10-12-bleTagDateTimeCheckThreeMin").innerHTML = jsonResponse12.bleTagDateTimeCheckThreeMin;


document.getElementById("10-88-10-12-bleTagStatusThreeMin").innerHTML = jsonResponse12.bleTagStatusThreeMin + " " + jsonResponse12.bleTagRssiThreeMin;


document.getElementById("10-88-10-12-bleTagDateTimeCheckFourMin").innerHTML = jsonResponse12.bleTagDateTimeCheckFourMin;


document.getElementById("10-88-10-12-bleTagStatusFourMin").innerHTML = jsonResponse12.bleTagStatusFourMin + " " + jsonResponse12.bleTagRssiFourMin;


document.getElementById("10-88-10-12-bleTagDateTimeCheckFiveMin").innerHTML = jsonResponse12.bleTagDateTimeCheckFiveMin;


document.getElementById("10-88-10-12-bleTagStatusFiveMin").innerHTML = jsonResponse12.bleTagStatusFiveMin + " " + jsonResponse12.bleTagRssiFiveMin;


///Change background color based on value threshold

if (jsonResponse12.bleTagStatus == 'True')

{

//Green


document.getElementById('10-88-10-12-bleTagStatus').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse12.bleTagStatus == 'False')

{

//Red


document.getElementById('10-88-10-12-bleTagStatus').style.background="rgb("+255+","+0+","+0+")";

}

//One Min


if (jsonResponse12.bleTagStatusOneMin == 'True')

{

//Green

document.getElementById('10-88-10-12-bleTagStatusOneMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse12.bleTagStatusOneMin == 'False')

{

//Red

document.getElementById('10-88-10-12-bleTagStatusOneMin').style.background="rgb("+255+","+0+","+0+")";

}


//Two Min

if (jsonResponse12.bleTagStatusTwoMin == 'True')

{

//Green

document.getElementById('10-88-10-12-bleTagStatusTwoMin').style.background="rgb("+57+","+255+","+20+")";


}

else if (jsonResponse12.bleTagStatusTwoMin == 'False')

{

//Red

document.getElementById('10-88-10-12-bleTagStatusTwoMin').style.background="rgb("+255+","+0+","+0+")";


}

//Three Min

if (jsonResponse12.bleTagStatusThreeMin == 'True')

{

//Green


document.getElementById('10-88-10-12-bleTagStatusThreeMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse12.bleTagStatusThreeMin == 'False')

{

//Red


document.getElementById('10-88-10-12-bleTagStatusThreeMin').style.background="rgb("+255+","+0+","+0+")";

}

//Four Min

if (jsonResponse12.bleTagStatusFourMin == 'True')

{

//Green

document.getElementById('10-88-10-12-bleTagStatusFourMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse12.bleTagStatusFourMin == 'False')


{

//Red

document.getElementById('10-88-10-12-bleTagStatusFourMin').style.background="rgb("+255+","+0+","+0+")";

}

//Five Min


if (jsonResponse12.bleTagStatusFiveMin == 'True')

{

//Green

document.getElementById('10-88-10-12-bleTagStatusFiveMin').style.background="rgb("+57+","+255+","+20+")";

}


else if (jsonResponse12.bleTagStatusFiveMin == 'False')

{

//Red

document.getElementById('10-88-10-12-bleTagStatusFiveMin').style.background="rgb("+255+","+0+","+0+")";

}

}

};



//Laundry

//10.88.10.13 - Laundry

var jsonHttp13 = new XMLHttpRequest();

var url13 = "http://10.88.10.13/status-engine-ble.php";


jsonHttp13.overrideMimeType("application/json");

jsonHttp13.open('GET', url13, true);

jsonHttp13.send();


jsonHttp13.onreadystatechange = function()


{


if (this.readyState == 4 && this.status == 200)


{


//Returns an object reference for JSON


var jsonResponse13 = JSON.parse(jsonHttp13.responseText);


//var jsonResponse = jsonHttp.responseText;


document.getElementById("10-88-10-13-ipAddress").innerHTML = '<a href="http://'+jsonResponse13.ipAddress+'" target="_blank"> '+jsonResponse13.ipAddress+'</a>';


document.getElementById("10-88-10-13-locationName").innerHTML = jsonResponse13.locationName;


document.getElementById("10-88-10-13-bleTagDateTimeCheck").innerHTML = jsonResponse13.bleTagDateTimeCheck;


document.getElementById("10-88-10-13-bleTagStatus").innerHTML = jsonResponse13.bleTagStatus + " " + jsonResponse13.bleTagRssi;



document.getElementById("10-88-10-13-bleTagDateTimeCheckOneMin").innerHTML = jsonResponse13.bleTagDateTimeCheckOneMin;


document.getElementById("10-88-10-13-bleTagStatusOneMin").innerHTML = jsonResponse13.bleTagStatusOneMin + " " + jsonResponse13.bleTagRssiOneMin;


document.getElementById("10-88-10-13-bleTagDateTimeCheckTwoMin").innerHTML = jsonResponse13.bleTagDateTimeCheckTwoMin;


document.getElementById("10-88-10-13-bleTagStatusTwoMin").innerHTML = jsonResponse13.bleTagStatusTwoMin + " " + jsonResponse13.bleTagRssiTwoMin;


document.getElementById("10-88-10-13-bleTagDateTimeCheckThreeMin").innerHTML = jsonResponse13.bleTagDateTimeCheckThreeMin;


document.getElementById("10-88-10-13-bleTagStatusThreeMin").innerHTML = jsonResponse13.bleTagStatusThreeMin + " " + jsonResponse13.bleTagRssiThreeMin;


document.getElementById("10-88-10-13-bleTagDateTimeCheckFourMin").innerHTML = jsonResponse13.bleTagDateTimeCheckFourMin;


document.getElementById("10-88-10-13-bleTagStatusFourMin").innerHTML = jsonResponse13.bleTagStatusFourMin + " " + jsonResponse13.bleTagRssiFourMin;


document.getElementById("10-88-10-13-bleTagDateTimeCheckFiveMin").innerHTML = jsonResponse13.bleTagDateTimeCheckFiveMin;


document.getElementById("10-88-10-13-bleTagStatusFiveMin").innerHTML = jsonResponse13.bleTagStatusFiveMin + " " + jsonResponse13.bleTagRssiFiveMin;


//Change background color based on value threshold

if (jsonResponse13.bleTagStatus == 'True')

{

//Green


document.getElementById('10-88-10-13-bleTagStatus').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse13.bleTagStatus == 'False')

{

//Red


document.getElementById('10-88-10-13-bleTagStatus').style.background="rgb("+255+","+0+","+0+")";

}

//One Min


if (jsonResponse13.bleTagStatusOneMin == 'True')

{

//Green

document.getElementById('10-88-10-13-bleTagStatusOneMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse13.bleTagStatusOneMin == 'False')

{

//Red

document.getElementById('10-88-10-13-bleTagStatusOneMin').style.background="rgb("+255+","+0+","+0+")";

}


//Two Min

if (jsonResponse13.bleTagStatusTwoMin == 'True')

{

//Green

document.getElementById('10-88-10-13-bleTagStatusTwoMin').style.background="rgb("+57+","+255+","+20+")";


}

else if (jsonResponse13.bleTagStatusTwoMin == 'False')

{

//Red

document.getElementById('10-88-10-13-bleTagStatusTwoMin').style.background="rgb("+255+","+0+","+0+")";


}

//Three Min

if (jsonResponse13.bleTagStatusThreeMin == 'True')

{

//Green


document.getElementById('10-88-10-13-bleTagStatusThreeMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse13.bleTagStatusThreeMin == 'False')

{

//Red


document.getElementById('10-88-10-13-bleTagStatusThreeMin').style.background="rgb("+255+","+0+","+0+")";

}

//Four Min

if (jsonResponse13.bleTagStatusFourMin == 'True')

{

//Green

document.getElementById('10-88-10-13-bleTagStatusFourMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse13.bleTagStatusFourMin == 'False')


{

//Red

document.getElementById('10-88-10-13-bleTagStatusFourMin').style.background="rgb("+255+","+0+","+0+")";

}

//Five Min


if (jsonResponse13.bleTagStatusFiveMin == 'True')

{

//Green

document.getElementById('10-88-10-13-bleTagStatusFiveMin').style.background="rgb("+57+","+255+","+20+")";

}


else if (jsonResponse13.bleTagStatusFiveMin == 'False')

{

//Red

document.getElementById('10-88-10-13-bleTagStatusFiveMin').style.background="rgb("+255+","+0+","+0+")";

}

}

};


//Office

//10.88.10.14 - office

var jsonHttp14 = new XMLHttpRequest();

var url14 = "http://10.88.10.14/status-engine-ble.php";


jsonHttp14.overrideMimeType("application/json");

jsonHttp14.open('GET', url14, true);

jsonHttp14.send();


jsonHttp14.onreadystatechange = function()


{


if (this.readyState == 4 && this.status == 200)


{


//Returns an object reference for JSON


var jsonResponse14 = JSON.parse(jsonHttp14.responseText);


//var jsonResponse = jsonHttp.responseText;


document.getElementById("10-88-10-14-ipAddress").innerHTML = '<a href="http://'+jsonResponse14.ipAddress+'" target="_blank"> '+jsonResponse14.ipAddress+'</a>';


document.getElementById("10-88-10-14-locationName").innerHTML = jsonResponse14.locationName;


document.getElementById("10-88-10-14-bleTagDateTimeCheck").innerHTML = jsonResponse14.bleTagDateTimeCheck;


document.getElementById("10-88-10-14-bleTagStatus").innerHTML = jsonResponse14.bleTagStatus + " " + jsonResponse14.bleTagRssi;



document.getElementById("10-88-10-14-bleTagDateTimeCheckOneMin").innerHTML = jsonResponse14.bleTagDateTimeCheckOneMin;


document.getElementById("10-88-10-14-bleTagStatusOneMin").innerHTML = jsonResponse14.bleTagStatusOneMin + " " + jsonResponse14.bleTagRssiOneMin;


document.getElementById("10-88-10-14-bleTagDateTimeCheckTwoMin").innerHTML = jsonResponse14.bleTagDateTimeCheckTwoMin;


document.getElementById("10-88-10-14-bleTagStatusTwoMin").innerHTML = jsonResponse14.bleTagStatusTwoMin + " " + jsonResponse14.bleTagRssiTwoMin;


document.getElementById("10-88-10-14-bleTagDateTimeCheckThreeMin").innerHTML = jsonResponse14.bleTagDateTimeCheckThreeMin;


document.getElementById("10-88-10-14-bleTagStatusThreeMin").innerHTML = jsonResponse14.bleTagStatusThreeMin + " " + jsonResponse14.bleTagRssiThreeMin;


document.getElementById("10-88-10-14-bleTagDateTimeCheckFourMin").innerHTML = jsonResponse14.bleTagDateTimeCheckFourMin;


document.getElementById("10-88-10-14-bleTagStatusFourMin").innerHTML = jsonResponse14.bleTagStatusFourMin + " " + jsonResponse14.bleTagRssiFourMin;


document.getElementById("10-88-10-14-bleTagDateTimeCheckFiveMin").innerHTML = jsonResponse14.bleTagDateTimeCheckFiveMin;


document.getElementById("10-88-10-14-bleTagStatusFiveMin").innerHTML = jsonResponse14.bleTagStatusFiveMin + " " + jsonResponse14.bleTagRssiFiveMin;


//Change background color based on value threshold

if (jsonResponse14.bleTagStatus == 'True')

{

//Green


document.getElementById('10-88-10-14-bleTagStatus').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse14.bleTagStatus == 'False')

{

//Red


document.getElementById('10-88-10-14-bleTagStatus').style.background="rgb("+255+","+0+","+0+")";

}

//One Min


if (jsonResponse14.bleTagStatusOneMin == 'True')

{

//Green

document.getElementById('10-88-10-14-bleTagStatusOneMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse14.bleTagStatusOneMin == 'False')

{

//Red

document.getElementById('10-88-10-14-bleTagStatusOneMin').style.background="rgb("+255+","+0+","+0+")";

}


//Two Min

if (jsonResponse14.bleTagStatusTwoMin == 'True')

{

//Green

document.getElementById('10-88-10-14-bleTagStatusTwoMin').style.background="rgb("+57+","+255+","+20+")";


}

else if (jsonResponse14.bleTagStatusTwoMin == 'False')

{

//Red

document.getElementById('10-88-10-14-bleTagStatusTwoMin').style.background="rgb("+255+","+0+","+0+")";


}

//Three Min

if (jsonResponse14.bleTagStatusThreeMin == 'True')

{

//Green


document.getElementById('10-88-10-14-bleTagStatusThreeMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse14.bleTagStatusThreeMin == 'False')

{

//Red


document.getElementById('10-88-10-14-bleTagStatusThreeMin').style.background="rgb("+255+","+0+","+0+")";

}

//Four Min

if (jsonResponse14.bleTagStatusFourMin == 'True')

{

//Green

document.getElementById('10-88-10-14-bleTagStatusFourMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse14.bleTagStatusFourMin == 'False')


{

//Red

document.getElementById('10-88-10-14-bleTagStatusFourMin').style.background="rgb("+255+","+0+","+0+")";

}

//Five Min


if (jsonResponse14.bleTagStatusFiveMin == 'True')

{

//Green

document.getElementById('10-88-10-14-bleTagStatusFiveMin').style.background="rgb("+57+","+255+","+20+")";

}


else if (jsonResponse14.bleTagStatusFiveMin == 'False')

{

//Red

document.getElementById('10-88-10-14-bleTagStatusFiveMin').style.background="rgb("+255+","+0+","+0+")";

}

}

};


//media

//10.88.10.15 - media

var jsonHttp15 = new XMLHttpRequest();

var url15 = "http://10.88.10.15/status-engine-ble.php";


jsonHttp15.overrideMimeType("application/json");

jsonHttp15.open('GET', url15, true);

jsonHttp15.send();


jsonHttp15.onreadystatechange = function()

{

if (this.readyState == 4 && this.status == 200)

{

//Returns an object reference for JSON

var jsonResponse15 = JSON.parse(jsonHttp15.responseText);

//var jsonResponse = jsonHttp.responseText;

document.getElementById("10-88-10-15-ipAddress").innerHTML = '<a href="http://'+jsonResponse15.ipAddress+'" target="_blank"> '+jsonResponse15.ipAddress+'</a>';

document.getElementById("10-88-10-15-locationName").innerHTML = jsonResponse15.locationName;

document.getElementById("10-88-10-15-bleTagDateTimeCheck").innerHTML = jsonResponse15.bleTagDateTimeCheck;

document.getElementById("10-88-10-15-bleTagStatus").innerHTML = jsonResponse15.bleTagStatus + " " + jsonResponse15.bleTagRssi;


document.getElementById("10-88-10-15-bleTagDateTimeCheckOneMin").innerHTML = jsonResponse15.bleTagDateTimeCheckOneMin;

document.getElementById("10-88-10-15-bleTagStatusOneMin").innerHTML = jsonResponse15.bleTagStatusOneMin + " " + jsonResponse15.bleTagRssiOneMin;

document.getElementById("10-88-10-15-bleTagDateTimeCheckTwoMin").innerHTML = jsonResponse15.bleTagDateTimeCheckTwoMin;

document.getElementById("10-88-10-15-bleTagStatusTwoMin").innerHTML = jsonResponse15.bleTagStatusTwoMin + " " + jsonResponse15.bleTagRssiTwoMin;

document.getElementById("10-88-10-15-bleTagDateTimeCheckThreeMin").innerHTML = jsonResponse15.bleTagDateTimeCheckThreeMin;

document.getElementById("10-88-10-15-bleTagStatusThreeMin").innerHTML = jsonResponse15.bleTagStatusThreeMin + " " + jsonResponse15.bleTagRssiThreeMin;

document.getElementById("10-88-10-15-bleTagDateTimeCheckFourMin").innerHTML = jsonResponse15.bleTagDateTimeCheckFourMin;

document.getElementById("10-88-10-15-bleTagStatusFourMin").innerHTML = jsonResponse15.bleTagStatusFourMin + " " + jsonResponse15.bleTagRssiFourMin;

document.getElementById("10-88-10-15-bleTagDateTimeCheckFiveMin").innerHTML = jsonResponse15.bleTagDateTimeCheckFiveMin;

document.getElementById("10-88-10-15-bleTagStatusFiveMin").innerHTML = jsonResponse15.bleTagStatusFiveMin + " " + jsonResponse15.bleTagRssiFiveMin;

//Change background color based on value threshold

if (jsonResponse15.bleTagStatus == 'True')

{

//Green


document.getElementById('10-88-10-15-bleTagStatus').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse15.bleTagStatus == 'False')

{

//Red


document.getElementById('10-88-10-15-bleTagStatus').style.background="rgb("+255+","+0+","+0+")";

}

//One Min


if (jsonResponse15.bleTagStatusOneMin == 'True')

{

//Green

document.getElementById('10-88-10-15-bleTagStatusOneMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse15.bleTagStatusOneMin == 'False')

{

//Red

document.getElementById('10-88-10-15-bleTagStatusOneMin').style.background="rgb("+255+","+0+","+0+")";

}


//Two Min

if (jsonResponse15.bleTagStatusTwoMin == 'True')

{

//Green

document.getElementById('10-88-10-15-bleTagStatusTwoMin').style.background="rgb("+57+","+255+","+20+")";


}

else if (jsonResponse15.bleTagStatusTwoMin == 'False')

{

//Red

document.getElementById('10-88-10-15-bleTagStatusTwoMin').style.background="rgb("+255+","+0+","+0+")";


}

//Three Min

if (jsonResponse15.bleTagStatusThreeMin == 'True')

{

//Green


document.getElementById('10-88-10-15-bleTagStatusThreeMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse15.bleTagStatusThreeMin == 'False')

{

//Red


document.getElementById('10-88-10-15-bleTagStatusThreeMin').style.background="rgb("+255+","+0+","+0+")";

}

//Four Min

if (jsonResponse15.bleTagStatusFourMin == 'True')

{

//Green

document.getElementById('10-88-10-15-bleTagStatusFourMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse15.bleTagStatusFourMin == 'False')


{

//Red

document.getElementById('10-88-10-15-bleTagStatusFourMin').style.background="rgb("+255+","+0+","+0+")";

}

//Five Min


if (jsonResponse15.bleTagStatusFiveMin == 'True')

{

//Green

document.getElementById('10-88-10-15-bleTagStatusFiveMin').style.background="rgb("+57+","+255+","+20+")";

}


else if (jsonResponse15.bleTagStatusFiveMin == 'False')

{

//Red

document.getElementById('10-88-10-15-bleTagStatusFiveMin').style.background="rgb("+255+","+0+","+0+")";

}

}

};


//BLE Scan Lounge

//10.88.10.17 - BLE Scan Lounge

var jsonHttp17 = new XMLHttpRequest();

var url17 = "http://10.88.10.17/status-engine-ble.php";


jsonHttp17.overrideMimeType("application/json");

jsonHttp17.open('GET', url17, true);

jsonHttp17.send();


jsonHttp17.onreadystatechange = function()

{

if (this.readyState == 4 && this.status == 200)

{

//Returns an object reference for JSON

var jsonResponse17 = JSON.parse(jsonHttp17.responseText);

//var jsonResponse = jsonHttp.responseText;

document.getElementById("10-88-10-17-ipAddress").innerHTML = '<a href="http://'+jsonResponse17.ipAddress+'" target="_blank"> '+jsonResponse17.ipAddress+'</a>';

document.getElementById("10-88-10-17-locationName").innerHTML = jsonResponse17.locationName;

document.getElementById("10-88-10-17-bleTagDateTimeCheck").innerHTML = jsonResponse17.bleTagDateTimeCheck;

document.getElementById("10-88-10-17-bleTagStatus").innerHTML = jsonResponse17.bleTagStatus + " " + jsonResponse17.bleTagRssi;


document.getElementById("10-88-10-17-bleTagDateTimeCheckOneMin").innerHTML = jsonResponse17.bleTagDateTimeCheckOneMin;

document.getElementById("10-88-10-17-bleTagStatusOneMin").innerHTML = jsonResponse17.bleTagStatusOneMin + " " + jsonResponse17.bleTagRssiOneMin;

document.getElementById("10-88-10-17-bleTagDateTimeCheckTwoMin").innerHTML = jsonResponse17.bleTagDateTimeCheckTwoMin;

document.getElementById("10-88-10-17-bleTagStatusTwoMin").innerHTML = jsonResponse17.bleTagStatusTwoMin + " " + jsonResponse17.bleTagRssiTwoMin;

document.getElementById("10-88-10-17-bleTagDateTimeCheckThreeMin").innerHTML = jsonResponse17.bleTagDateTimeCheckThreeMin;

document.getElementById("10-88-10-17-bleTagStatusThreeMin").innerHTML = jsonResponse17.bleTagStatusThreeMin + " " + jsonResponse17.bleTagRssiThreeMin;

document.getElementById("10-88-10-17-bleTagDateTimeCheckFourMin").innerHTML = jsonResponse17.bleTagDateTimeCheckFourMin;

document.getElementById("10-88-10-17-bleTagStatusFourMin").innerHTML = jsonResponse17.bleTagStatusFourMin + " " + jsonResponse17.bleTagRssiFourMin;

document.getElementById("10-88-10-17-bleTagDateTimeCheckFiveMin").innerHTML = jsonResponse17.bleTagDateTimeCheckFiveMin;

document.getElementById("10-88-10-17-bleTagStatusFiveMin").innerHTML = jsonResponse17.bleTagStatusFiveMin + " " + jsonResponse17.bleTagRssiFiveMin;

//Change background color based on value threshold

if (jsonResponse17.bleTagStatus == 'True')

{

//Green


document.getElementById('10-88-10-17-bleTagStatus').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse17.bleTagStatus == 'False')

{

//Red


document.getElementById('10-88-10-17-bleTagStatus').style.background="rgb("+255+","+0+","+0+")";

}

//One Min


if (jsonResponse17.bleTagStatusOneMin == 'True')

{

//Green

document.getElementById('10-88-10-17-bleTagStatusOneMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse17.bleTagStatusOneMin == 'False')

{

//Red

document.getElementById('10-88-10-17-bleTagStatusOneMin').style.background="rgb("+255+","+0+","+0+")";

}


//Two Min

if (jsonResponse17.bleTagStatusTwoMin == 'True')

{

//Green

document.getElementById('10-88-10-17-bleTagStatusTwoMin').style.background="rgb("+57+","+255+","+20+")";


}

else if (jsonResponse17.bleTagStatusTwoMin == 'False')

{

//Red

document.getElementById('10-88-10-17-bleTagStatusTwoMin').style.background="rgb("+255+","+0+","+0+")";


}

//Three Min

if (jsonResponse17.bleTagStatusThreeMin == 'True')

{

//Green


document.getElementById('10-88-10-17-bleTagStatusThreeMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse17.bleTagStatusThreeMin == 'False')

{

//Red


document.getElementById('10-88-10-17-bleTagStatusThreeMin').style.background="rgb("+255+","+0+","+0+")";

}

//Four Min

if (jsonResponse17.bleTagStatusFourMin == 'True')

{

//Green

document.getElementById('10-88-10-17-bleTagStatusFourMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse17.bleTagStatusFourMin == 'False')


{

//Red

document.getElementById('10-88-10-17-bleTagStatusFourMin').style.background="rgb("+255+","+0+","+0+")";

}

//Five Min


if (jsonResponse17.bleTagStatusFiveMin == 'True')

{

//Green

document.getElementById('10-88-10-17-bleTagStatusFiveMin').style.background="rgb("+57+","+255+","+20+")";

}


else if (jsonResponse17.bleTagStatusFiveMin == 'False')

{

//Red

document.getElementById('10-88-10-17-bleTagStatusFiveMin').style.background="rgb("+255+","+0+","+0+")";

}


}

};


//10.88.10.18 - Onsuite

var jsonHttp18 = new XMLHttpRequest();

var url18 = "http://10.88.10.18/status-engine-ble.php";


jsonHttp18.overrideMimeType("application/json");

jsonHttp18.open('GET', url18, true);

jsonHttp18.send();


jsonHttp18.onreadystatechange = function()


{


if (this.readyState == 4 && this.status == 200)


{


//Returns an object reference for JSON


var jsonResponse18 = JSON.parse(jsonHttp18.responseText);


//var jsonResponse = jsonHttp.responseText;


document.getElementById("10-88-10-18-ipAddress").innerHTML = '<a href="http://'+jsonResponse18.ipAddress+'" target="_blank"> '+jsonResponse18.ipAddress+'</a>';


document.getElementById("10-88-10-18-locationName").innerHTML = jsonResponse18.locationName;


document.getElementById("10-88-10-18-bleTagDateTimeCheck").innerHTML = jsonResponse18.bleTagDateTimeCheck;


document.getElementById("10-88-10-18-bleTagStatus").innerHTML = jsonResponse18.bleTagStatus + " " + jsonResponse18.bleTagRssi;



document.getElementById("10-88-10-18-bleTagDateTimeCheckOneMin").innerHTML = jsonResponse18.bleTagDateTimeCheckOneMin;


document.getElementById("10-88-10-18-bleTagStatusOneMin").innerHTML = jsonResponse18.bleTagStatusOneMin + " " + jsonResponse18.bleTagRssiOneMin;


document.getElementById("10-88-10-18-bleTagDateTimeCheckTwoMin").innerHTML = jsonResponse18.bleTagDateTimeCheckTwoMin;


document.getElementById("10-88-10-18-bleTagStatusTwoMin").innerHTML = jsonResponse18.bleTagStatusTwoMin + " " + jsonResponse18.bleTagRssiTwoMin;


document.getElementById("10-88-10-18-bleTagDateTimeCheckThreeMin").innerHTML = jsonResponse18.bleTagDateTimeCheckThreeMin;


document.getElementById("10-88-10-18-bleTagStatusThreeMin").innerHTML = jsonResponse18.bleTagStatusThreeMin + " " + jsonResponse18.bleTagRssiThreeMin;


document.getElementById("10-88-10-18-bleTagDateTimeCheckFourMin").innerHTML = jsonResponse18.bleTagDateTimeCheckFourMin;


document.getElementById("10-88-10-18-bleTagStatusFourMin").innerHTML = jsonResponse18.bleTagStatusFourMin + " " + jsonResponse18.bleTagRssiFourMin;


document.getElementById("10-88-10-18-bleTagDateTimeCheckFiveMin").innerHTML = jsonResponse18.bleTagDateTimeCheckFiveMin;


document.getElementById("10-88-10-18-bleTagStatusFiveMin").innerHTML = jsonResponse18.bleTagStatusFiveMin + " " + jsonResponse18.bleTagRssiFiveMin;


//Change background color based on value threshold

if (jsonResponse18.bleTagStatus == 'True')

{

//Green


document.getElementById('10-88-10-18-bleTagStatus').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse18.bleTagStatus == 'False')

{

//Red


document.getElementById('10-88-10-18-bleTagStatus').style.background="rgb("+255+","+0+","+0+")";

}

//One Min


if (jsonResponse18.bleTagStatusOneMin == 'True')

{

//Green

document.getElementById('10-88-10-18-bleTagStatusOneMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse18.bleTagStatusOneMin == 'False')

{

//Red

document.getElementById('10-88-10-18-bleTagStatusOneMin').style.background="rgb("+255+","+0+","+0+")";

}


//Two Min

if (jsonResponse18.bleTagStatusTwoMin == 'True')

{

//Green

document.getElementById('10-88-10-18-bleTagStatusTwoMin').style.background="rgb("+57+","+255+","+20+")";


}

else if (jsonResponse18.bleTagStatusTwoMin == 'False')

{

//Red

document.getElementById('10-88-10-18-bleTagStatusTwoMin').style.background="rgb("+255+","+0+","+0+")";


}

//Three Min

if (jsonResponse18.bleTagStatusThreeMin == 'True')

{

//Green


document.getElementById('10-88-10-18-bleTagStatusThreeMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse18.bleTagStatusThreeMin == 'False')

{

//Red


document.getElementById('10-88-10-18-bleTagStatusThreeMin').style.background="rgb("+255+","+0+","+0+")";

}

//Four Min

if (jsonResponse18.bleTagStatusFourMin == 'True')

{

//Green

document.getElementById('10-88-10-18-bleTagStatusFourMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse18.bleTagStatusFourMin == 'False')


{

//Red

document.getElementById('10-88-10-18-bleTagStatusFourMin').style.background="rgb("+255+","+0+","+0+")";

}

//Five Min


if (jsonResponse18.bleTagStatusFiveMin == 'True')

{

//Green

document.getElementById('10-88-10-18-bleTagStatusFiveMin').style.background="rgb("+57+","+255+","+20+")";

}


else if (jsonResponse18.bleTagStatusFiveMin == 'False')

{

//Red

document.getElementById('10-88-10-18-bleTagStatusFiveMin').style.background="rgb("+255+","+0+","+0+")";

}


}

};


//10.88.10.19 - Jacks room

var jsonHttp19 = new XMLHttpRequest();

var url19 = "http://10.88.10.19/status-engine-ble.php";


jsonHttp19.overrideMimeType("application/json");

jsonHttp19.open('GET', url19, true);

jsonHttp19.send();


jsonHttp19.onreadystatechange = function()


{


if (this.readyState == 4 && this.status == 200)


{


//Returns an object reference for JSON


var jsonResponse19 = JSON.parse(jsonHttp19.responseText);


//var jsonResponse = jsonHttp.responseText;


document.getElementById("10-88-10-19-ipAddress").innerHTML = '<a href="http://'+jsonResponse19.ipAddress+'" target="_blank"> '+jsonResponse19.ipAddress+'</a>';


document.getElementById("10-88-10-19-locationName").innerHTML = jsonResponse19.locationName;


document.getElementById("10-88-10-19-bleTagDateTimeCheck").innerHTML = jsonResponse19.bleTagDateTimeCheck;


document.getElementById("10-88-10-19-bleTagStatus").innerHTML = jsonResponse19.bleTagStatus + " " + jsonResponse19.bleTagRssi;



document.getElementById("10-88-10-19-bleTagDateTimeCheckOneMin").innerHTML = jsonResponse19.bleTagDateTimeCheckOneMin;


document.getElementById("10-88-10-19-bleTagStatusOneMin").innerHTML = jsonResponse19.bleTagStatusOneMin + " " + jsonResponse19.bleTagRssiOneMin;


document.getElementById("10-88-10-19-bleTagDateTimeCheckTwoMin").innerHTML = jsonResponse19.bleTagDateTimeCheckTwoMin;


document.getElementById("10-88-10-19-bleTagStatusTwoMin").innerHTML = jsonResponse19.bleTagStatusTwoMin + " " + jsonResponse19.bleTagRssiTwoMin;


document.getElementById("10-88-10-19-bleTagDateTimeCheckThreeMin").innerHTML = jsonResponse19.bleTagDateTimeCheckThreeMin;


document.getElementById("10-88-10-19-bleTagStatusThreeMin").innerHTML = jsonResponse19.bleTagStatusThreeMin + " " + jsonResponse19.bleTagRssiThreeMin;


document.getElementById("10-88-10-19-bleTagDateTimeCheckFourMin").innerHTML = jsonResponse19.bleTagDateTimeCheckFourMin;


document.getElementById("10-88-10-19-bleTagStatusFourMin").innerHTML = jsonResponse19.bleTagStatusFourMin + " " + jsonResponse19.bleTagRssiFourMin;


document.getElementById("10-88-10-19-bleTagDateTimeCheckFiveMin").innerHTML = jsonResponse19.bleTagDateTimeCheckFiveMin;


document.getElementById("10-88-10-19-bleTagStatusFiveMin").innerHTML = jsonResponse19.bleTagStatusFiveMin + " " + jsonResponse19.bleTagRssiFiveMin;


//Change background color based on value threshold

if (jsonResponse19.bleTagStatus == 'True')

{

//Green


document.getElementById('10-88-10-19-bleTagStatus').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse19.bleTagStatus == 'False')

{

//Red


document.getElementById('10-88-10-19-bleTagStatus').style.background="rgb("+255+","+0+","+0+")";

}

//One Min


if (jsonResponse19.bleTagStatusOneMin == 'True')

{

//Green

document.getElementById('10-88-10-19-bleTagStatusOneMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse19.bleTagStatusOneMin == 'False')

{

//Red

document.getElementById('10-88-10-19-bleTagStatusOneMin').style.background="rgb("+255+","+0+","+0+")";

}


//Two Min

if (jsonResponse19.bleTagStatusTwoMin == 'True')

{

//Green

document.getElementById('10-88-10-19-bleTagStatusTwoMin').style.background="rgb("+57+","+255+","+20+")";


}

else if (jsonResponse19.bleTagStatusTwoMin == 'False')

{

//Red

document.getElementById('10-88-10-19-bleTagStatusTwoMin').style.background="rgb("+255+","+0+","+0+")";


}

//Three Min

if (jsonResponse19.bleTagStatusThreeMin == 'True')

{

//Green


document.getElementById('10-88-10-19-bleTagStatusThreeMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse19.bleTagStatusThreeMin == 'False')

{

//Red


document.getElementById('10-88-10-19-bleTagStatusThreeMin').style.background="rgb("+255+","+0+","+0+")";

}

//Four Min

if (jsonResponse19.bleTagStatusFourMin == 'True')

{

//Green

document.getElementById('10-88-10-19-bleTagStatusFourMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse19.bleTagStatusFourMin == 'False')


{

//Red

document.getElementById('10-88-10-19-bleTagStatusFourMin').style.background="rgb("+255+","+0+","+0+")";

}

//Five Min


if (jsonResponse19.bleTagStatusFiveMin == 'True')

{

//Green

document.getElementById('10-88-10-19-bleTagStatusFiveMin').style.background="rgb("+57+","+255+","+20+")";

}


else if (jsonResponse19.bleTagStatusFiveMin == 'False')

{

//Red

document.getElementById('10-88-10-19-bleTagStatusFiveMin').style.background="rgb("+255+","+0+","+0+")";

}


}

};

//Leo Room

//10.88.10.21 - Leo-Room

var jsonHttp21 = new XMLHttpRequest();

var url21 = "http://10.88.10.21/status-engine-ble.php";


jsonHttp21.overrideMimeType("application/json");

jsonHttp21.open('GET', url21, true);

jsonHttp21.send();


jsonHttp21.onreadystatechange = function()

{

if (this.readyState == 4 && this.status == 200)

{

//Returns an object reference for JSON

var jsonResponse21 = JSON.parse(jsonHttp21.responseText);


//var jsonResponse = jsonHttp.responseText;

document.getElementById("10-88-10-21-ipAddress").innerHTML = '<a href="http://'+jsonResponse21.ipAddress+'" target="_blank"> '+jsonResponse21.ipAddress+'</a>';

document.getElementById("10-88-10-21-locationName").innerHTML = jsonResponse21.locationName;

document.getElementById("10-88-10-21-bleTagDateTimeCheck").innerHTML = jsonResponse21.bleTagDateTimeCheck;


document.getElementById("10-88-10-21-bleTagStatus").innerHTML = jsonResponse21.bleTagStatus + " " + jsonResponse21.bleTagRssi;


document.getElementById("10-88-10-21-bleTagDateTimeCheckOneMin").innerHTML = jsonResponse21.bleTagDateTimeCheckOneMin;

document.getElementById("10-88-10-21-bleTagStatusOneMin").innerHTML = jsonResponse21.bleTagStatusOneMin + " " + jsonResponse21.bleTagRssiOneMIn;


document.getElementById("10-88-10-21-bleTagDateTimeCheckTwoMin").innerHTML = jsonResponse21.bleTagDateTimeCheckTwoMin;

document.getElementById("10-88-10-21-bleTagStatusTwoMin").innerHTML = jsonResponse21.bleTagStatusTwoMin + " " + jsonResponse21.bleTagRssiTwoMin;

document.getElementById("10-88-10-21-bleTagDateTimeCheckThreeMin").innerHTML = jsonResponse21.bleTagDateTimeCheckThreeMin;

document.getElementById("10-88-10-21-bleTagStatusThreeMin").innerHTML = jsonResponse21.bleTagStatusThreeMin + " " + jsonResponse21.bleTagRssiThreeMin;

document.getElementById("10-88-10-21-bleTagDateTimeCheckFourMin").innerHTML = jsonResponse21.bleTagDateTimeCheckFourMin;

document.getElementById("10-88-10-21-bleTagStatusFourMin").innerHTML = jsonResponse21.bleTagStatusFourMin + " " + jsonResponse21.bleTagRssiFourMin;

document.getElementById("10-88-10-21-bleTagDateTimeCheckFiveMin").innerHTML = jsonResponse21.bleTagDateTimeCheckFiveMin;

document.getElementById("10-88-10-21-bleTagStatusFiveMin").innerHTML = jsonResponse21.bleTagStatusFiveMin + " " + jsonResponse21.bleTagRssiFiveMin;

//Change background color based on value threshold

if (jsonResponse21.bleTagStatus == 'True')

{

//Green


document.getElementById('10-88-10-21-bleTagStatus').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse21.bleTagStatus == 'False')

{

//Red


document.getElementById('10-88-10-21-bleTagStatus').style.background="rgb("+255+","+0+","+0+")";

}

//One Min


if (jsonResponse21.bleTagStatusOneMin == 'True')

{

//Green

document.getElementById('10-88-10-21-bleTagStatusOneMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse21.bleTagStatusOneMin == 'False')

{

//Red

document.getElementById('10-88-10-21-bleTagStatusOneMin').style.background="rgb("+255+","+0+","+0+")";

}


//Two Min

if (jsonResponse21.bleTagStatusTwoMin == 'True')

{

//Green

document.getElementById('10-88-10-21-bleTagStatusTwoMin').style.background="rgb("+57+","+255+","+20+")";


}

else if (jsonResponse21.bleTagStatusTwoMin == 'False')

{

//Red

document.getElementById('10-88-10-21-bleTagStatusTwoMin').style.background="rgb("+255+","+0+","+0+")";


}

//Three Min

if (jsonResponse21.bleTagStatusThreeMin == 'True')

{

//Green


document.getElementById('10-88-10-21-bleTagStatusThreeMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse21.bleTagStatusThreeMin == 'False')

{

//Red


document.getElementById('10-88-10-21-bleTagStatusThreeMin').style.background="rgb("+255+","+0+","+0+")";

}

//Four Min

if (jsonResponse21.bleTagStatusFourMin == 'True')

{

//Green

document.getElementById('10-88-10-21-bleTagStatusFourMin').style.background="rgb("+57+","+255+","+20+")";

}

else if (jsonResponse21.bleTagStatusFourMin == 'False')


{

//Red

document.getElementById('10-88-10-21-bleTagStatusFourMin').style.background="rgb("+255+","+0+","+0+")";

}

//Five Min


if (jsonResponse21.bleTagStatusFiveMin == 'True')

{

//Green

document.getElementById('10-88-10-21-bleTagStatusFiveMin').style.background="rgb("+57+","+255+","+20+")";

}


else if (jsonResponse21.bleTagStatusFiveMin == 'False')

{

//Red

document.getElementById('10-88-10-21-bleTagStatusFiveMin').style.background="rgb("+255+","+0+","+0+")";

}


}

};


</script>

<?php

echo("<p>Menu:</p>");

echo("<p></p>");

//echo("<p><a href=\"alarm.php\" target=\"_blank\">Alarm - Auto - ARM / DISARM All AREAS</a></p>");


echo("<p></p>");

echo("<p><a href=\"default.php\" target=\"_blank\">Check current day Temp</a></p>");

echo("<p><a href=\"status-ble.php\" target=\"_blank\">Status of BLE Beacon</a></p>");

echo("<p><a href=\"bleTagJSGraph-20200611-1.0.php\" target=\"_blank\">BLE Tag RSSI Graph</a></p>");

echo("<p><a href=\"daytempgraph.php\" target=\"_blank\">Check a days temp graph</a></p>");

echo("<p><a href=\"dayalarmgraph.php\" target=\"_blank\">Check a days alarm trigger graph</a></p>");


print("</body>");

echo("<footer>");

echo("<p>page version : " . $pageVersion . "</p>");

echo("</footer>");

echo("</div>");


?>


</html>

##################################################################################################

Note: associated CSS:

/css/css-default.css

##################################################################################################

/*<!--| Ver 1.7 | Last edited Date 25 Feb 2018 | Designed By: Andrew Fullagar | Edited Last By: Andrew Fullagar | afullagar@gmail.com |-->*/

* {

margin: 0px;

padding: 0px;

}


body {

font-family: verdana,arial,serif;

width: 100%;

display: box;

display: -moz-box;

display: -webkit-box;

box-pack: center;

-moz-box-pack: center;

-webkit-box-pack: center;

}


header, section, aside, nav, article, figure, figcaption, hgroup {

display: block;

}


#bodycenter {

font-family: verdana,arial,serif;

margin-left: 2%;

margin-right:2%;

width: 96%;

border: 1px solid #2352B1;

border-collapse:collapse;

padding:0px;

}



#bodycenter form p {

font-family: verdana,arial,serif;

/*font-size: 16px;*/

font-size: calc(0.8vw + 0.8vh);

display: block-inline;

clear:both;

border-top: 1px solid #2352B1;

border-collapse:collapse;

margin: 2px;

padding: 2px;

}


#bodycenter form p label {

font-family: verdana,arial,serif;

/*font-size: 16px;*/

font-size: calc(0.8vw + 0.8vh);

font-weight: bold;

/*clear:both;*/

float: left;

color: 0000FF;

background: #FFF;

margin: 2px;

padding: 2px;

display: block;

border-collapse:collapse;

}


#bodycenter form p .flyleft {

font-family: verdana,arial,serif;

font-size: 16px;

/*clear:both;*/

float: left;

color: 0000FF;

background: #FFF;

margin: 2px;

padding: 1px;

display: block;

}

#bodycenter form p input,textarea,select,option,legend {

font-family: verdana,arial,serif;

/*font-size: 18px;*/

font-size: calc(0.8vw + 0.8vh);

background-color:#ffffff;

border: 2px solid #2352B1;

border-collapse:collapse;

margin: 2px;

padding: 2px;

color: 0000FF;

/*clear:both;*/

float: right;

}


/*specs for submit button on forms*/

#bodycenter form p .submitbutton {

font-family: bold verdana,arial,serif;

margin: 1pt;

padding: 1pt;

border: 1pt outset #336699;

background-color: #0000ff;

/*font-size: 16px;*/

font-size: calc(0.8vw + 0.8vh);

color: #fff;

float: right;

}

/*specs for submit button on forms*/

#bodycenter form p .submitbuttonimage {

font-family: bold verdana,arial,serif;

margin: 1pt;

padding: 1pt;

border: none;

background-color: #fff;

font-size: 16px;

color: #fff;

float: right;

}

#bodycenter form p .updatebutton {

font-family: bold verdana,arial,serif;

margin: 1pt;

padding: 1pt;

border: 1pt outset #336699;

background-color: #00ff00;

font-size: 16px;

color: #000;

float: right;

}

#bodycenter form p .updatebuttonimage {

font-family: bold verdana,arial,serif;

margin: 1pt;

padding: 1pt;

border: none;

background-color: #fff;

font-size: 16px;

color: #000;

float: right;

}

#bodycenter form p .insertbutton {

font-family: bold verdana,arial,serif;

margin: 1pt;

padding: 1pt;

border: 1px outset #336699;

background-color: yellow;

font-size: 16px;

color: #000;

float: right;

}

#bodycenter form p .mustfillout {

font-family: bold verdana,arial,serif;

/*margin: 1pt;*/

/*padding: 1pt;*/

/*border: 1pt outset #336699;*/

font-weight: bold;

background-color: #0000cd;

font-size: 16px;

color: white;

float: right;

}


#bodycenter form p .resetbutton {

font-family: verdana,bold arial,serif;

margin: 1pt;

padding: 1pt;

border: 1pt outset #336699;

background-color: #ff0000;

font-size: 16px;

color: #fff;

float: left;

}

#bodycenter form p .resetbuttonimage {

font-family: verdana,bold arial,serif;

margin: 1pt;

padding: 1pt;

border: none;

background-color: #fff;

font-size: 16px;

color: #fff;

float: left;

}

#bodycenter form p .emailbutton {

font-family: verdana,bold arial,serif;

margin: 1pt;

padding: 1pt;

border: 1pt outset #336699;

background-color: #F90;

font-size: 16px;

color: #fff;

float: right;

}

#bodycenter form p .emailbuttonimage {

font-family: verdana,bold arial,serif;

margin: 1pt;

padding: 1pt;

border: none;

background-color: #fff;

font-size: 16px;

color: #fff;

float: right;

}

#bodycenter ul li {

font-family: verdana,arial,serif;

font-size: 16px;

list-style: none;

margin: 1px;

padding: 1px;

}


#bodycenter h1 {

font-family: verdana,arial,serif;

margin: 2px;

/*font-size: 28px;*/

font-size: calc(1.1vw + 1.1vh);

color: #5692D0;

text-align: center;

font-weight: bold;

border: 1px solid #A4C0E2;

background-color: #ffffff;

}


#bodycenter h2 {

margin: 2px;

font-family: verdana,arial,serif;

/*font-size: 24px;*/

font-size: calc(0.9vw + 0.9vh);

/*color: #5692D0;*/

color: 000;

text-align: center;

font-weight: bold;

clear:both;

border: 1px solid #A4C0E2;

background-color: #ffffff;

}


#bodycenter h3 {

margin: 2px;

font-family: verdana,arial,serif;

/*font-size: 20px;*/

font-size: calc(0.8vw + 0.8vh);

/*color: #5692D0;*/

color: 000;

text-align: left;

font-weight: bold;

border: 1px solid #A4C0E2;

background-color: #ffffff;

}

#bodycenter table {

font-family: verdana,arial,serif;

font-size: calc(0.8vw + 0.8vh);

/*border: 0.1pt solid black;*/

border-collapse: collapse;

empty-cells: show;

width: 99%;

line-height: calc(1.3vw + 1.3vh);

background-color:#ffffff;

margin: 5px;

padding: 5px;

}


#bodycenter th {

font-family: verdana,arial,serif;

font-size: calc(0.8vw + 0.8vh);

text-align: left;

color: 0000FF;

border-collapse: collapse;

border: 1px solid #2352B1;

background-color:#ffffff;

empty-cells: show;

line-height: calc(0.8vw + 0.8vh);

margin: 2px;

padding: 1px;

}


#bodycenter tr {

font-family: verdana,arial,serif;

font-size: calc(0.8vw + 0.8vh);

border-collapse: collapse;

/*border-top: 0.1pt solid black;*/

empty-cells: show;

line-height: calc(0.8vw + 0.8vh);

background-color:#ffffff;

}


#bodycenter td {

font-family: verdana,arial,serif;

/*font-size: calc(0.8vw + 0.8vh);*/

font-size: calc(0.8vw + 0.8vh);

empty-cells:show;

color: 0000FF;

border-collapse: collapse;

border: 1px solid #2352B1;

/*margin:0pt;

padding:0pt;*/

/*white-space:nowrap;*/

line-height: calc(0.8vw + 0.8vh);

text-align: left;

background-color:#ffffff;

}

#bodycenter a img {border: 0; }


#bodycenter img {

padding: 10;

display: block;

margin: 0 auto;

max-height: 100%;

max-width: 100%;

}

#bodycenter a,href {

font-family: verdana,arial,serif;

font-size: calc(0.8vw + 0.8vh);

text-decoration: none;

font-weight: bold;

/*color: #234A76;*/

/*margin: 1px;

padding: 1px;*/

display: block;

}


#bodycenter a:link {


font-size: calc(0.8vw + 0.8vh);

text-decoration: none;

font-weight: bold;

color: #234A76;

margin:1px;

display: block;

}


#bodycenter a:visited {

font-size: calc(0.8vw + 0.8vh);

text-decoration: none;

font-weight: bold;

color: #234A76;

margin:1px;

display: block;

}


#bodycenter a:hover {

font-family: verdana,arial,serif;

font-size: calc(0.8vw + 0.8vh);

text-decoration: underline;

font-weight: bold;

display: block;

}


#bodycenter a:active {

font-family: verdana,arial,serif;

font-size: calc(0.8vw + 0.8vh);

text-decoration: underline;

font-weight: bold;

display: block;

}

#bodycenter footer {

font-family: verdana,arial,serif;

font-size: calc(0.4vw + 0.4vh);

text-decoration: underline;

font-weight: bold;

display: block;

text-align: right;

}



p {

font-family: verdana,arial,serif;

/*font-size: 16px;*/

font-size: calc(0.8vw + 0.8vh);

}

a {

font-family: verdana,arial,serif;

font-size: calc(0.8vw + 0.8vh);

}


table {

font-family: verdana,arial narrow,serif;

font-size: calc(0.8vw + 0.8vh);

/*border: 0.1pt solid black;*/

border-collapse: collapse;

empty-cells: show;

width: 99%;

line-height: calc(0.8vw + 0.8vh);

}


th {

font-family: verdana,arial narrow,serif;

font-size: calc(0.8vw + 0.8vh);

text-align: left;

border-collapse: collapse;

border-top: 0.1pt solid black;

border-left: 0.1pt solid black;

border-right: 0.1pt solid black;

border-bottom: 0.1pt solid black;

background-color: #ccf;

empty-cells: show;

line-height: calc(0.8vw + 0.8vh);

}

.th-report {

font-family: verdana,arial narrow,serif;

font-size: 16px;

text-align: left;

background-color: #fff;

line-height: 10pt;

}

/*No shade for th*/

.noshade {

font-family: verdana,arial narrow,serif;

font-size: 16px;

text-align: left;

background-color: #fff;

line-height: 10pt;

}


tr {

font-family: verdana,arial narrow,serif;

font-size: calc(0.8vw + 0.8vh);

border-collapse: collapse;

/*border-top: 0.1pt solid black;*/

empty-cells: show;

line-height: calc(0.8vw + 0.8vh);

}


td {

font-family: verdana,arial narrow,serif;

font-size: calc(0.8vw + 0.8vh);

empty-cells:show;

border-collapse: collapse;

border-top: 0.1pt solid black;

border-left: 0.1pt solid black;

border-right: 0.1pt solid black;

border-bottom: 0.1pt solid black;

/*margin:0pt;

padding:0pt;*/

/*white-space:nowrap;*/

line-height: calc(0.8vw + 0.8vh);

}


#####################################################################################################

Graph results for one rpi zero w scan results over time:

NOTE 03: Have not finished updating fields and there are remnants of copied scripts but the graph works.

bleTagJSGraph-20200611-1.0.php

#####################################################################################################


<!--| Ver 1.2 | Date 06 Oct 2019 | Designed By: Andrew Fullagar | Edited Last By: Andrew Fullagar | afullagar@gmail.com |-->

<!DOCTYPE html><?#Note: Install gd or graphs wont work - sudo apt-get install php7.3-gd

################Release Notes###########################################

#20191006 1.2

# - Change to bar graph as it is easier to follow tooltip than a line graph.

#

#

#

# Enable debug reporting to browser ?>

<head>

<title>Py Arm IoT -BLE Graph - Using chartjs.org</title>

<?php

date_default_timezone_set('Australia/Brisbane');

if (!empty($_SERVER['HTTPS']))

{

$Prot='https';

}

else

{

$Prot='http';

}


echo("<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $Prot . "://" . $_SERVER['SERVER_NAME'] . "/css/css-default.css\"></link>");

#echo("<meta http-equiv='refresh' content='1'>"); //Refresh by HTTP META

?>

</head>

</header>

<body>


<?php

#Refresh page every x Seconds

$page = $_SERVER['PHP_SELF'];

$sec = "60";

header("Refresh: $sec; url=$page");

$path = "/home/pi/html-php-scripts/graph-png"; // full server path to the directory where you want the backup files (no trailing slash)


if (is_dir($path) == FALSE)

{

mkdir($path, 0755);

}

#Delete file from filesystem

$outputFilePng = shell_exec("rm -Rf /home/pi/html-php-scripts/graph-png/*.png");

#print("Output png files deleted" . $outputFilePng);



$alarmConfig =0;


$configName = '/home/pi/python-scripts/alarm/config/alarm.conf';

$logPath = '/home/pi/python-scripts/ble/logs/';

$dateTempCheck = date("Y-m-d");

$dateTimeTempCheck = date("Y-m-d-H-i-s");


//log

$bleTagDataLogName = $logPath . "ble-tag-tile-E1-B6-27-18-2A-20-".$dateTempCheck.".log";

#Image Name

$tempPng = "bleTagData-$dateTimeTempCheck.log.png";

//Center Output

echo("<div id=\"bodycenter\">");

?>





<h1>Py Arm IoT Configuration - BLE Tag Track - Graph</h1>


<form enctype="multipart/form-data" action="bleTagJSGraph-20200611-1.0.php" method="post">

<p>...</p>

<?php

print("<p>Choose Year Month Day");

print("<select name=\"Day\">");

print("<option value=\"\">Day</option>");

$x=1;

while ($x <= 31)

{

echo("<option value=\"$x\">$x</option>");

$x++;

}

print("</select>");

print("<select name=\"Month\">");

print("<option value=\"\">Month</option>");

$x=1;

while ($x <= 12)

{

echo("<option value=\"$x\">$x</option>");

$x++;

}

print("</select>");

print("<select name=\"Year\">");

print("<option value=\"\">Year</option>");

$x=2017;

while ($x <= 2020)

{

echo("<option value=\"$x\">$x</option>");

$x++;

}

print("</select>");


print("<p>...</p>");


$outputGpu = shell_exec("tail -n 1 " . $bleTagDataLogName);

print("<p>...</p>");

?>


<p><input type="submit" name="submit" value="submit" /></p>


</form>


<?php


if (isset($_POST['submit']))

{

$tempCheckDay = $_POST['Day'];

$tempCheckDay = sprintf("%02d", $tempCheckDay);

$tempCheckMonth = $_POST['Month'];

$tempCheckMonth = sprintf("%02d", $tempCheckMonth);

#echo $num_padded; // returns 04


$tempCheckYear = $_POST['Year'];

$dateTempCheck = $tempCheckYear . "-" . $tempCheckMonth . "-" . $tempCheckDay;

print("$dateTempCheck");

print("</p>");

//print("Date: $Y-$M-$D $Hrs:$Min:$SeMB");

//log

$bleTagDataLogName = $logPath . "ble-tag-tile-E1-B6-27-18-2A-20-".$dateTempCheck.".log";

#Image Name

$tempPng = "bleTagData-$dateTimeTempCheck.log.png";

}

#phpinfo();

###$numLinesAmbientTempLog = count(file($ambientTempLogName));

$numLinesFileSizeMp4TempLog = count(file($bleTagDataLogName));

$moveGraphLeft = 40;

$moveHeadingLeft = 10;

$yGraphLength = 500;

###$xGraphAmbientIncrement = ($yGraphLength*2)/$numLinesAmbientTempLog;

$xGraphGpuIncrement = ($yGraphLength*2)/$numLinesGpuTempLog;

$yGraphLengthTotalBorder = 610;#Keep it about 200 bigger than $yGraphLength

$yGraphLengthBuffer = 100;

$yGraphBottomScaleOffset = 50;#Move everything down by this amount so there is room at the top


#########################################################################

#######ADJUST these for Y increment and how many increments shown visible

$yGraphScale = 30;

$yIncrementScale = 3; #Default is one multiplier

##########################################################################

$graphFont = 2;

$graphFontHeading = 7;

$xGraphLength = 1440;

#add date to graphFont

$dateTimeLongGraph = date("Y-m-d H:i:s"). substr((string)microtime(), 1, 6);

#For javascript

$j=0;

?>

<!--Define vars -->

<script type="text/javascript">

var j;

var dataCatalog = [];

var dataPoints = [];

</script>

<?php


// Here's a function for drawing a rotated gradient Rectangle (based on a previous note)

$row = 0;

#0-127 - 127=no line opaque 0=line darkest

$crossLineOpacity = 100;

$crossTextOpacity = 50;

$graphLineOpacity = 0;

$moveGraphLeft = 40;

$moveHeadingLeft = 16;

$moveVerticalHeadingLeft = 0;

$moveHeadingUp = -6;#reverse logic from top down


$dataXTempStart = 0;

$dataBarWidth = 5;


#Initialise Vars otherwise they wont work with min/max functions

$tempBleTagRssiMin=100;

###$tempAmbientMin=100;

$tempBleTagRssiMax=-100;

###$tempAmbientMax=-100;


if (($handleFileBleTagData = fopen($bleTagDataLogName, "r")) !== FALSE)

{

while (($dataBleTag = fgetcsv($handleFileBleTagData, 1000, ",")) !== FALSE)

{

$row++;

$dataBleTagTimestamp = strtotime($dataBleTag[1]);

if ($row == 1)

{

###$dataAmbientStart = $dataAmbient[3];

###$dataXAmbientContinue = 0;

#convert from 2s compliment back to positive number for graph - higher is closer (rssi)

$dataBleTagStartTemp = (float)$dataBleTag[7];

$dataBleTagStart = $dataBleTagStartTemp + 256;

$dataXGpuContinue = 0;

#X points

#debug x points on curve

###$hourAmbientTest = date("H", $dataAmbientTimestamp);

$hourGpuTest = date("H", $dataBleTagTimestamp);

###$minuteAmbientTest = date("i", $dataAmbientTimestamp);

$minuteGpuTest = date("i", $dataBleTagTimestamp);

###$hourAmbientTestMinutesConvert = $hourAmbientTest * 60;

$hourGpuTestMinutesConvert = $hourGpuTest * 60;

###$totalAmbientMinutesXScale = $hourAmbientTestMinutesConvert + $minuteAmbientTest;

$totalGpuMinutesXScale = $hourGpuTestMinutesConvert + $minuteGpuTest;

#logging starts at 00:00 so 1440 minutes total

#print("<p>X point should be = " . $totalMinutesXScale . "</p>");

###$dataXAmbientStart = $totalAmbientMinutesXScale;

$dataXGpuStart = $totalGpuMinutesXScale;

#print("DEBUG - 1st packet dataXAmbientStart = $dataXAmbientStart");

}

else

{

#make sure values follow on from each other and join up

###$dataAmbientStart = $dataAmbientContinue;

$dataBleTagStart = (float)$dataBleTagContinue;

#X points

#debug x points on curve

###$hourAmbientTest = date("H", $dataAmbientTimestamp);

$hourGpuTest = date("H", $dataBleTagTimestamp);

###$minuteAmbientTest = date("i", $dataAmbientTimestamp);

$minuteGpuTest = date("i", $dataBleTagTimestamp);

###$hourAmbientTestMinutesConvert = $hourAmbientTest * 60;

$hourGpuTestMinutesConvert = $hourGpuTest * 60;

###$totalAmbientMinutesXScale = $hourAmbientTestMinutesConvert + $minuteAmbientTest;

$totalGpuMinutesXScale = $hourGpuTestMinutesConvert + $minuteGpuTest;

#print($totalGpuMinutesXScale);

#logging starts at 00:00 so 1440 minutes total

#print("X point should be = " . $totalMinutesXScale);

#$dataXAmbientStart = $totalMinutesXScale;

###$dataXAmbientStart = $dataXAmbientContinue;

#print("dataXAmbientStart 2nd part = $dataXAmbientStart");

###$dataXAmbientContinue = $totalAmbientMinutesXScale;

$dataXGpuContinue = $totalGpuMinutesXScale;

#print("<p>X totalMinutesXScale point should be = " . $dataXAmbientContinue . "</p>");

}

#Find MIN and MAX Temp

$tempBleTagRssiMax = max((float)$dataBleTag[7],(float)$dataBleTagStart,(float)$tempBleTagRssiMax);

###$tempAmbientMax = max($dataAmbient[3],$dataAmbientStart,$tempAmbientMax);

$tempBleTagRssiMin = min((float)$tempBleTagRssiMin,(float)$dataBleTag[7],(float)$dataBleTagStart);

###$tempAmbientMin = min($dataAmbient[3],$dataAmbientStart,$tempAmbientMin);

#################Javascript fromphp debug##############################################################

?>

<script type="text/javascript">

var j = <?php echo $j ?>;

var k = <?php echo $totalGpuMinutesXScale ?>;

dataCatalog[j] = k;

<?php

$dataBleTagTemp = (float)$dataBleTag[7];

$dataBleTagConverted = $dataBleTagTemp + 256;

?>

//Make sure zero points are converted to '' RSSI to show properly on graph.

dataPoints[j] = <?php if ($dataBleTagTemp == 0) { echo ($dataBleTagConverted='');} else { echo ($dataBleTagConverted);} ?>;

</script>

<?php

$j=$j+1;

###$dataAmbientContinue = $dataAmbient[3];

$dataBleTagContinueTemp = (float)$dataBleTag[7];

#Negative RSSI + Positive to negate 2s compliment

$dataBleTagContinue = $dataBleTagContinueTemp + 256;

###$dataXAmbientStart = $dataXAmbientContinue;

$dataXGpuStart = $dataXGpuContinue;

}


######fclose($handleAmbient);

fclose($handleFileBleTagData);

}


?>

<!--canvas for chartjs.org -->

<canvas id="myChart"></canvas>

<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>

<script type='text/javascript'>

<!--console.log(dataPoints);-->

var ctx = document.getElementById('myChart').getContext('2d');

var chart = new Chart(ctx, {

// The type of chart we want to create

//type: 'line',bar

type: 'bar',

//type: 'radar',



// The data for our dataset

data: {

labels: dataCatalog,

datasets: [{

label: 'RSSI Track',

//red

borderColor: 'rgb(255, 0, 0)',

borderWidth: 0.5,

hoverBackgroundColor: 'rgb(0, 0, 0)',

hoverBorderColor: 'rgb(0, 0, 0)',

spanGaps: true,

pointRadius:0,

data: dataPoints

}]

},

// Configuration options go here

options: {

scales: {

yAxes: [{

ticks: {

//beginAtZero: false,

// Include a dollar sign in the ticks

callback: function(value, index, values) {

return (value-256)+" dBm";

}

},

scaleLabel: {

display: true,

labelString: "RSSI",

fontColor: "red"

}

}],

xAxes: [{

ticks: {

// Include a dollar sign in the ticks

callback: function(value, index, values) {

var hours = Math.floor(value / 60);

var minutes = (value % 60);

hours = hours < 10 ? '0' + hours : hours;

minutes = minutes < 10 ? '0' + minutes : minutes;

value = hours+":"+minutes;

return value;

}

},

scaleLabel: {

display: true,

labelString: "Time (HH:MM)",

fontColor: "red"

}

}]

},

tooltips: {

enabled: true,

titleFontSize: 12,

titleFontStyle: 'bold',

callbacks: {

label: function(tooltipItem, data) {

var label = data.datasets[tooltipItem.datasetIndex].label || '';

//label = Math.round((tooltipItem.yLabel * 100) / 100;

label = tooltipItem.yLabel.toPrecision(4);

label = "RSSI: "+(label-256)+"dBm";

return label;

},

title: function(tooltipItem, data) {

var title = tooltipItem[0].xLabel;

title = "Time: "+title;

return title;

}

}

}

}

});

</script>



<?php

echo("<p>Menu:</p>");

echo("<p><a href=\"default.php\" target=\"_blank\">Check current day Temp</a></p>");

echo("<p><a href=\"daytempgraph.php\" target=\"_blank\">Check a days temp graph</a></p>");

echo("<p><a href=\"filesizemp4graph.php\" target=\"_blank\">Check a File Size MP4 graph</a></p>");

echo("<p><a href=\"dayalarmgraph.php\" target=\"_blank\">Check a days alarm trigger graph</a></p>");

echo("</div>");


?>