Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mackermedia/13a71062dc687634b897 to your computer and use it in GitHub Desktop.
Save mackermedia/13a71062dc687634b897 to your computer and use it in GitHub Desktop.

Pubnub Signalling

Chui uses Pubnub for event Signaling, Listen on a channel that equals your device serial The event message includes a key and name (if identified) If the name is unavailable (ie person unknown), no name attribute will be in the dictionary

Use the following publish and subscribe keys: publish_key='pub-c-e7c43b97-8af8-4a3f-b9d4-fe5710f17e20' subscribe_key=’sub-c-b09806ee-e056-11e3-8f83-02ee2ddab7fe’


User Keys Please wait until an account is assigned to your team. More accounts can be created if needed.

We have provided three accounts for the hackathon, the following are user keys that will be used by some of the endpoints described below:

[email protected]: aglzfjIxNHRlY2hyEQsSBFVzZXIYgICAgMbw6gkM Serial:A513-1111-2227 [email protected]: aglzfjIxNHRlY2hyDAsSBFVzZXIYqroEDA Serial:A513-2222-4448 [email protected]: aglzfjIxNHRlY2hyEQsSBFVzZXIYgICAgIf1-wsM Serial:A513-1111-2222 Serial:A513-1111-4447 (D)

Password for all accounts is 112233


Getting Event Photo

Make a get request to the following endpoint passing the key received in the pubnub message: http://10.214tech.appspot.com/api/1/snapshot-photo/{key}

The endpoint will respond with image data and a "Content-Type" = "image/jpeg" header.


Getting List of Snapshots

Make a GET request to the following endpoint:

url = "http://10.214tech.appspot.com/api/1/mvisits"

passing the user key as a param. ex:

payload = {
	'key':’aglzfjIxNHRlY2hyEQsSBFVzZXIYgICAgIf1-wsM’,
}

The response includes a list of dictionaries for 20 visits:

{u'persons': u'Nezare Chafni', u'key': u'aglzfjIxNHRlY2hyFQsSCFNuYXBzaG90GICAgMDawv0JDA', u'created': u'2014-09-13 17:03:02.767780'

The persons attribute represents the names of the people in the photo, no more than one name will be returned in a dictionary. When the individual triggering the system is unknown the “person” attribute will be an empty string.

The response also includes a cursor object for getting more visitor snapshots: {u'cursor': u'E-ABAOsB8gEHY3JlYXRlZPoBCQiM7-Kq4tzAAuwBggIiaglzfjIxNHRlY2hyFQsSCFNuYXBzaG90GICAgMDtmvQKDIgCARQ='}


Getting List of Enrolled People

Make a get request the following endpoint passing the user key as a request param: "http://10.214tech.appspot.com/api/1/mpeople"

The return comprises a list of dictionaries, each dictionary includes the name of the person, his key in the database, and the paths to the photos used to enroll him.

{u'photos': [u'/frgallery/aglzfjIxNHRlY2hyEQsSBFVzZXIYgICAgIf1-wsM_aglzfjIxNHRlY2hyEwsSBlBlcnNvbhiAgIDAmdHlCAw_0.jpg', u'/frgallery/aglzfjIxNHRlY2hyEQsSBFVzZXIYgICAgIf1-wsM_aglzfjIxNHRlY2hyEwsSBlBlcnNvbhiAgIDAmdHlCAw_1.jpg', u'/frgallery/aglzfjIxNHRlY2hyEQsSBFVzZXIYgICAgIf1-wsM_aglzfjIxNHRlY2hyEwsSBlBlcnNvbhiAgIDAmdHlCAw_2.jpg', u'/frgallery/aglzfjIxNHRlY2hyEQsSBFVzZXIYgICAgIf1-wsM_aglzfjIxNHRlY2hyEwsSBlBlcnNvbhiAgIDAmdHlCAw_3.jpg', u'/frgallery/aglzfjIxNHRlY2hyEQsSBFVzZXIYgICAgIf1-wsM_aglzfjIxNHRlY2hyEwsSBlBlcnNvbhiAgIDAmdHlCAw_4.jpg', u'/frgallery/aglzfjIxNHRlY2hyEQsSBFVzZXIYgICAgIf1-wsM_aglzfjIxNHRlY2hyEwsSBlBlcnNvbhiAgIDAmdHlCAw_5.jpg', u'/frgallery/aglzfjIxNHRlY2hyEQsSBFVzZXIYgICAgIf1-wsM_aglzfjIxNHRlY2hyEwsSBlBlcnNvbhiAgIDAmdHlCAw_6.jpg', u'/frgallery/aglzfjIxNHRlY2hyEQsSBFVzZXIYgICAgIf1-wsM_aglzfjIxNHRlY2hyEwsSBlBlcnNvbhiAgIDAmdHlCAw_7.jpg'], u'name': u'Nezare Chafni', u'key': u'aglzfjIxNHRlY2hyEwsSBlBlcnNvbhiAgIDAmdHlCAw', u'created': u'2014-09-11 15:17:57.233480'}

Getting person photo

Make a request to the following endpoint:

http://10.214tech.appspot.com/api/1/mobilephotorf

passing the path of photo you’d like to get as parameter ‘p’

The endpoint will respond to with image data and a "Content-Type" = "image/jpeg" header.


Simulator

We have put together a simulator to trigger identify events for people already enrolled in the account. The simulator will select among 10 enrolled people to use in triggering the event. You can use the simulator by calling it in the terminal and passing your serial as a positional argument:

Nezares-MacBook-Pro:apitest nchafni$ python simulator.py identify A513-1111-2227

Examples

  • Python Voice Alerts
  • Javascript Picture Display
  • Python HTTP examples for each endpoint

You can download the files from this url: https://www.dropbox.com/s/i92yzht51xlhqr0/chuiHackathon.zip?dl=0

Dependencies: Python Requests Pyttsx Can be installed with: sudo pip install requests sudo pip install pyttsx


Video & Audio

Chui uses Tokbox to power WebRTC audio and video calling. Triggering a chui video session can be done via Pubnub signalling. Publish a Pubnub message on a channel equalling your device serial number with an action attribute = start_video -> {“action”:”start_video”}

Utilizing the Tokbox sdk, you can then initiate a video session using the following Tokbox Session IDs:

TokBoxApiKey = "44850642";

TokBoxSessionId for serial A513-1111-4447= "1_MX40NDg1MDY0Mn5-VHVlIFNlcCAyMyAxMDozOTo0OSBQRFQgMjAxNH4wLjM4NzcwMjE3fn4";

Session ID for A513-7887-0913: 1_MX40NDg1MDY0Mn5-MTQxMTUzMTU4MjIyNH5sMGtxRTVYQWRPZkVhYzcybDllMVBxRnF-fg

Tokens (will be issued at the Hackathon, please see the Chui team if you want to work on a video related idea)


Lockitron

Lockitron can be triggered through Chui with Pubnub signalling. Publish a Pubnub message on a channel equalling your device serial number with the following attributes:

Lock the Lockitron: {"type":"lockitron", "lock": "lock"}

Unlock the Lockitron: {"type":"lockitron", "lock": "unlock"}

Toggle the Lockitron: {"type":"lockitron", "lock": "toggle"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment