Closed OLLYDOTDEV closed 4 years ago
with the #22 hid scripts made and located in HID Folder. they now needed to be executed when
this was done withsystem("my_bash_script.sh");
<--- some hid script
but an issue is that the way that ROMS
is setup is that it will transmit everyone that when it polls the sensor and they are triggered that will transmit "alert" but does not way when setup to say there it is no longer trigger. there for ROMS
sends a lot of Active
packets and since the HID runs everyone a Active
packet is received in depending on the hid script that is currently enabled the second activation does the inverse for the First. So if the The First One hides everything by minimising all windows, the second the HID
script activates it might do the inverse and maximiser windows... and repeat
there are two ways to fix this
every time that active
alert packet is received to start a countdown timer and while that count down is active don't let the HID script reactivate.
add a sending function to the ROMS
code that also says then the sensors are no longer trigger and then not allow the HID script to retrigger until it received that it is no longer triggered.
i will be going with number 2 as the data status verification method as it would be more reliable due to the fact that it is using software flags to confirm whether the situation is active or not rathener rather than just taking a guess after X amount of time.
with reliability in mind as with the Functionality, in short of error unacceptable, It must work flawlessly therefor I have two systems in placed to stop a double activation of the HID script
The first one takes place on ROMS
and what it does is restricted the transmissions to only when there is a change in the state. EG ACTIVE -> OFF vice versa. this us using the JustTransmitted
Boolean variable as a software flag for whether there has been a Transmission. https://github.com/OLLYDOTDEV/Project-Birdseye-DTX-2020/commit/d8302ae81ce4393c5c6dca7c2b27b443e9e8a8de this also happen to speed up the overall total loop processing time which is a plus which allows more operations per second
and the second one is that takes place on RPI
this worked my added if()
statements to the AlertStatus
function.
the first one checks if HID_Active
is true and if so prevents the HID script from being run again.
the next if statement resets the HID_Active
bool value to false when once a Alert
packet with the data of OFF
has been Received
then the last if statement only runs if HID_Active
is set to false and data of ACTIVE
has been Received
To improve the user user experience we can see that for the HID portion of this system is lacking when it comes to Usability Heuristics as for now there is no way of seeing what HID script is active due to a lack of visibility of system status. there is also a issue of User control and freedom as if the end user wants to chance what HID script will be active then it needs to recompile the RPI.cpp
and that takes time, there Projectbirdeye is out of the box working solution.
To fix the lack of visibility for the system status the active hid script will be displayed on the web interface in addion the web interface will be able to control what HID script will be actived as well as the addion of new scripts
So the start with the fix for RPI.cpp
was to set it to execute from a constant file called Selected.sh
and now to control the contents of Selected.sh
this is where the changes to the web interface come in.
the first change is to do with the dynamic layout
Here every HID script is read from the folder and then the name displayed. (in progress is the adding of the contents to the Selected.sh
) this layout will add a new row once there is a total of 4 columns worth of cells.
each of these cells will get given a href (hyperlink) to hid.php
but to be able to work out what link was clicked each link will have a hyperlink with a parameter of the name of the HID script to set at active. to get the parameters from the hyperlink with $_GET
and just as expected changing my URL to hid.php?active=ChromeNewTab.sh
when combined with
<html>
<body>
<?php
// https://www.w3schools.com/php/php_superglobals_get.asp
echo "INFO: " . $_GET['active'];
?>
</body>
</html>
we get the expected output of
with this site is used to
.sh
into selected.sh
<-- this is that the RPI
binary executesselected.txt
to have the path of the active directory the first error that was encountered was that the input PHP commandCOPY()
was failing to do task 1
you as a alternative are used the native Linux cp
in conJunction with php's ability to execute commands to run
echo shell_exec("sudo cp ../HID/".$file." ../HID/Selected.sh");
(hid.php)
as for number 2
$myfile = fopen("../HID/Selected.txt", "w") or die("Unable to open file!");
fwrite($myfile, $file);
fclose($myfile);
(Control.php)
the allow the software to set permanent storage to be read later (by the control panel)
chmod 747 *
in the one HID
directory persistent value as otherwise it cant be written too.
the last key piece to add to the control panel is feedback to show what HID script is selected. this will a matter of reading from my persistent file that contains the filename of the Selected file.
todo this
$txtfile = fopen("../HID/Selected.txt", "r") or die("Unable to open file!");
echo "Selected: ";
echo fread($txtfile,filesize("../HID/Selected.txt"));
fclose($txtfile);
this reads the name of the scripts that will be executed when an ALERT it sent out.
as a final part of the functionality, uses can add custion HID Scripts via the web interface. Todo this some old code that i have used in other older project will be reused from Abideyouth
while i could just add a file upload form. because HTML form has no validation / sanitation they cant be trusted, infact if the information comes from the use it is best practice to always sanitise it and verify that it meets the expected requirements.
things that will be verified are the files
while a html forms do provide these information they do nothing with the data and it can also be faked to the method of cross compearing check the information that the form gives to the data we can extract from the file. https://github.com/OLLYDOTDEV/Project-Birdseye-DTX-2020/blob/68bcfd0d9fa4246f5fd13cd707b0082ebd91ba05/CODE/Release/WebServer/upload.php is there this process takes place.
As a programmer I will be using p4wnp1 aloa on s PI Zero to custom HID scrips to control the PC with web config thus allowing the computer to be controlled by the PI zero.