We can control everything with this project, but I took LED as an example.
DemoWorking FlowA pattern string is hard-coded in server side code.
When PHPoC receives the input pattern string from user, It will compare the input pattern with hard-coded pattern. If they are the same, PHPoC sends the ACCEPTED code to client (Web browser) and sets the authenticated variable to true . Otherwise, PHPoC sends the DENIED code to client and set the authenticated variable to false.
When PHPoC receives a control command from user, it will check the value of the authenticated variable first. If the value is true, It performs the task corresponding with command. If the value is false, It sends the DENIED code to client.
Pattern MappingPattern will be mapped to a string. For example, in above image, pattern string is "1,4,8,6,3".
Source CodeSource code includes two files:
- index.php: This file is client side code. When receiving HTTP request from web browser, PHPoC interprets PHP script in this file, and then send the interpreted file to web browser. The interpreted file (contains HTML, CSS and JavaScript code) provides UI (User Interface), handling touch/click event from User and send data back to PHPoC via websocket.
- task0.php: This file is server side code. It is run in infinite loop to receive and handle data from web browser, control devices.
Comments
Please log in or sign up to comment.