# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import time import meccano # Connect to the server # For connection you must provide the mac-address of your network adapter, # The server and port where the meccano gateway is running if not meccano.setup("66:66:66:66:66:66", "meccano.server.iot.", 80): print "Could not connect to Meccano Network" exit() # Sending a test fact fact = meccano.fact_create("teste_yun", 1, 10) meccano.fact_send(fact, meccano.MODE_PERSISTENT) # Receiving and processing messages from gateway while (True): custom_messages = meccano.messages_process(30000) if len(custom_messages) > 0: if "MY_COMMAND" in custom_messages: print "Execute my command!" print "Custom commands received: " print custom_messages time.sleep(10)
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import time import meccano # Connect to the server # For connection you must provide the mac-address of your network adapter, # The server and port where the meccano gateway is running if not meccano.setup("66:66:66:66:66:66", "meccano.server.iot.", 80): print "Could not connect to Meccano Network" exit() # Sending a test fact fact = meccano.fact_create("teste_yun", 1, 10) meccano.fact_send(fact, meccano.MODE_PERSISTENT) # Receiving and processing messages from gateway while(True): custom_messages = meccano.messages_process(30000) if len(custom_messages) > 0: if "MY_COMMAND" in custom_messages: print "Execute my command!" print "Custom commands received: " print custom_messages time.sleep(10)
) # Draw a rectangle around the faces for (x, y, w, h) in faces: cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2) # Show the image in the viewport cv2.imshow("preview", frame) # Check for new faces each 10 seconds... if meccano.elapsed(3, 10000): number_of_faces = len(faces) if number_of_faces > 0: print "Found {0} faces!".format(number_of_faces) # Sending a test fact fact = meccano.fact_create("presence", 1, number_of_faces) meccano.fact_send(fact, meccano.MODE_PERSISTENT) # Check messages from gateway custom_messages = meccano.messages_process(30000) if len(custom_messages) > 0: if "SCREENSHOT" in custom_messages: # Here you may send the screenshot to the user (e. g. upload to S3) print "Taking screenshot!" print "Custom commands received: " print custom_messages # Recreate the checkpoint 3 meccano.checkpoint(3) # Exit on ESC key = cv2.waitKey(20) if key == 27: