def _main(): api = ConnectAPI() devices = api.list_connected_devices().data if len(devices) == 0: raise Exception("No endpints registered. Aborting") # Delete device subscriptions api.delete_device_subscriptions(devices[0].id) # First register to webhook api.update_webhook("https://mbed-iot.herokuapp.com/webhook/") time.sleep(2) api.add_resource_subscription(devices[0].id, BUTTON_RESOURCE)
def _main(): api = ConnectAPI() devices = api.list_connected_devices().data if len(devices) == 0: raise Exception("No endpints registered. Aborting") # Delete device subscriptions api.delete_device_subscriptions(devices[0].id) # First register to webhook api.update_webhook("http://python.requestcatcher.com/") time.sleep(2) api.add_resource_subscription(devices[0].id, BUTTON_RESOURCE) while True: print("Webhook registered. Listening to button updates for 10 seconds...") time.sleep(10) break api.delete_webhook() print("Deregistered and unsubscribed from all resources. Exiting.")
def _main(): api = ConnectAPI() api.start_notifications() devices = api.list_connected_devices().data if not devices: raise Exception("No connected devices registered. Aborting") value = api.get_resource_value(devices[0].id, POPUP_IOT_RESOURCE) queue = api.add_resource_subscription(devices[0].id, POPUP_IOT_RESOURCE) while True: print("Current value: %r" % (value, )) value = queue.get(timeout=30)
def _main(): api = ConnectAPI() api.start_notifications() devices = api.list_connected_devices().data if not devices: raise Exception("No connected devices registered. Aborting") # Synchronously get the initial/current value of the resource value = api.get_resource_value(devices[0].id, BUTTON_RESOURCE) # Register a subscription for new values api.set_resource_value(device_id=devices[0].id, resource_path=WRITEABLE_RESOURCE, resource_value='10') queue = api.add_resource_subscription(devices[0].id, BUTTON_RESOURCE) while True: # Print the current value print("Current value: %r" % (value, )) # Get a new value, using the subscriptions value = queue.get(timeout=30)
def _main(): api = ConnectAPI() api.delete_device_subscriptions(dev) api.update_webhook("https://www.tric.kr/heroku/mbed-iot/webhook/") time.sleep(1) api.add_resource_subscription(dev, POPUP_IOT_RESOURCE)