At first you need to authenticate with your Google account.
Fig. 2: Settings screen.
When you log in for the first time, you need to enter the values "Workspace folder", "Remote control ID", "Data update in seconds", "Max operations on Drive" (maximum number of files read simultaneously from Google Drive), "Max simultaneous commands" (maximum number of commands sent simultaneously to Google Drive) and press "Set Values." You can set the language to English or Italian. Clicking "Log out" will disconnect your Google account, while clicking "Close application" will exit the application without logging out.
Fig. 3: "On - Off" screen.
In this screen there are buttons to send commands to the devices.
Fig. 4: "Dashboard" screen.
Device information is displayed here.
THE MAIN ALGORITHM OF THE APPLICATION
Going into more detail, once you log in (fig. 1) and enter the required information in the settings screen (fig. 2), the application cyclically runs the following algorithm:
Fig. 5: algorithm executed repeatedly by the application.
In the figs. 2, 3 and 4 the numbers to the right of the writing "STATUS ALGORITHM OF REMOTE CONTROL" are worth:
1 during reading files on Google Drive;
2 during the updating of the "On-Off" and "Dashboard" screens;
3 during pause.
Commands are sent when the numbers considered above are 2 or 3. The pause depends on the "Data update in seconds" value. The final cycle can be interrupted by pressing the "Log out" or "Close application" button. An example of a workspace folder at the end of the third step of the algorithm is shown in fig. 6,
Fig. 6: example of workspace completed the third point of the application algorithm.
where you can see the files:
"File of Remote control 1" created by the software;
of the devices to be controlled.
The next sections explain how these are used in the communication between remote control and devices.
FILE OF REMOTE CONTROL
It has the name "File of Remote control " + ID of the remote control; it is generated when the application starts if it is not present in the workspace folder. The ID must be a unique alphanumeric string. The content can be edited freely.
DEVICE FILES
It must be named "File of device " + ID of the device and generated in the workspace folder by the respective device. The ID must be a unique alphanumeric string. Within it, it is possible to define the buttons and values to be displayed in the "On - Off" and "Dashboard" screens, respecting the following three rules.
A) For buttons, in a single line write "buttons: " + first button name + ", " + second button name + ", " + ... + ", " + last button name ";". The names cannot include the symbols ":", ";", "," and must be unique. You can define a particular button for sending custom strings (will be seen later) by inserting the "customizable value" element.
B) For values, in a single line write "values: " + name first value + " is " + first value + ", " + name second value + " is " + second value + ", " + ... + ", " + name last value + " is " + last value + ";". Value names cannot include the string " is " and must be unique. The symbols ":", ";" and "," may only be used to separate the various elements in the row.
C) The lines of the previous points A and B are optional; if present, they must be placed first. The other rows are modifiable as desired.
Device files can be created, edited and deleted even when the remote control is running; an example is shown in fig. 7.
Fig. 7: example of device file.
SENDING COMMANDS USING THE ON - OFF SCREEN BUTTONS
The buttons of the "On - Off" screen (fig. 3) are used to send commands to the devices. Now it is explained what happens when pressing one of them (except those for sending custom strings):
1) the key is disabled;
2) the application generates a file in the workspace folder with name "To dev. " + device ID + " command " + button name, addressed to the device with the same ID.
At this point, the associated device must read the file, perform the action for which it has been programmed and, at the end, respond with a confirmation ACK by generating a file called "From dev. " + device ID + " ACK " + button name. When the software notices the ACK:
3) delete the command and ACK files;
4) reactivate the button.
Clicking, instead, on a custom string submit button (the ones with the string "Send value" in the middle), the application generates a file in the workspace folder called "To dev. " + device ID + " command Cus. value " + custom value (the custom value is the string in the text box above the button). The related device, once it detects the command, must execute the corresponding action and, at the end, delete the file (even those with identical name, if any) without responding with an ACK.
An example of a workspace folder containing commands and acks is shown in Fig. 8.
Fig. 8: Example of a workspace folder with commands and ack.
WHAT HAPPENS IF MULTIPLE DEVICES HAVE THE SAME ID
If there are multiple "Files of device" with the same ID in a workspace folder, the application will block as in fig. 9 until the problem is solved.
Fig. 9: screen from the application in the presence of identical "Device file".
AND FINALLY
The values displayed in the "Dashboard" screen (fig. 4) are those defined in the "values: " rows of the device files (fig. 7).
In the settings screen it is best to avoid entering too large values for "Max operations on Drive" and "Max simultaneous commands."
Multiple remote controls are allowed in a workspace but only one can operate at a time.
The "Reset workspace" button in the settings screen (fig. 2) is used to delete all command and ack files in the workspace.
In the freely editable parts of the filenames of devices, remote controls, commands and ack you must not enter the strings:
"File of device ";
"File of Remote control ";
"To dev. " together with " command ";
"To dev. " together with " command Cus. value ";
"From dev. " together with " ACK ".
Otherwise the application may malfunction.
For security reasons, the application can only interact with files it has created on Google Drive or those generated by the controlled devices.
Before authenticating with your Google account, you need to enable the Google API and generate authorization credentials by following the guidedevelopers.google.com/i...ls/oauth2.
For this project I helped myself with the official Google Android examples and those contained in Android Studio. Therefore I thank the respective authors.
Notes:
1) the software does not implement all modern security systems for data protection, so it is better to avoid including sensitive data in the information exchanged between the devices and the Internet;
2) the software is provided "as is", without any kind of warranty; I don't assume any responsibility for the consequences deriving from the use of the information contained in this page.