Skip to content

jietang/dbrc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DBRC Spec

I'm showing someone git!

The main concept we're using for DBRC are the idea of remotes and screens. A remote is a device that sets up a broadcast, a screen can subscribe to one or more broadcasts to be controller by the remote. The API is very straightforward.

connection info refers to: {'bssid': <bssid>, 'ssid': <ssid>, 'strength': <signal strength>}

For pairing using remote.py you'll need to create a "~/.dbrc_config" file with the following sections:

[secrets]

APP_KEY="gafchy215r87od1"

APP_SECRET="0bhl35g2fcybyvh"

ACCESS_TOKEN=""

ACCESS_TOKEN_SECRET=""

. /broadcasts/

POST

create a new broadcast channel

data: {'remote_id': remote id, <optional>'connected': connection info}

headers: {'content-type': 'application/json'}

response: broadcast_id

. /broadcasts/<int:broadcast_id>

POST

post something to a broadcast channel. returns list of screen_ids successfully published to (mostly for debug purposes)..

uses a message type. valid types: "pairing", "url"

pairing is for sending app token information to the TV, url is for putting an image url on a screen.

data: json.dumps({"type": "url", "url": some_url})

data: json.dumps({"type": "pairing", "app_key": app_key, "app_secret": app_secret, "access_token": access_token, "access_token_secret": access_token_secret})

headers: `{'content-type': 'application/json'}

response: {'screen_ids': [screen_id1,...]}

. /broadcasts/<int:id>/screens/

GET

get the list of screens subscribed to the broadcast

data: nothing

response: {"<screen_id>": <subscription_timestamp>, "<screen_id>", <subscription_timestamp>, ...}

POST

subscribe a screen to a broadcast

data: {"screen_id": screen_id}

response: <status code>

. /broadcasts/<int:broadcast_id>/screens/<int:screen_id>

DELETE

remove a screen from a broadcast

data: nothing

response: {"broadcast_id": broadcast_id, "screen_id": screen_id}

. /broadcasts/<int:id>/known_screens/

GET

get a list of screens have previously paired with the remote that created this broadcast. known is True/False, depending on whether we have explicitly paired with this device in the past.

data: nothing

response: [{"screen_id": screen_id, "device_name": device_name, "known": True/False}, ...]

POST

subscribe a screen to a broadcast

data: {"screen_id": screen_id}

response: <status code>

. /screens

POST

create a new screen, and associate it with a unique device_id

data: `{"device_id": device_id, "device_name": device_name,

"pairing_info": {"connected": connection info, "nearby": [... connection info]}}`

headers: {"content-type": "application/json"}

response: {"broadcast_id": broadcast_id}

. /screens/<int:screen_id>

GET

long poll: listen for a message

data: <optional> {"timeout": seconds}

response: a (stringified) JSON ball posted to /broadcasts/<int:id> by a remote. right now, the json dict is guarenteed to have a "method_type" field set to "link" or "action"

. /screens/<int:id>/broadcasts

GET

gets all broadcast streams this screen is subscribed to

data: nothing

response: {"<broadcast_id>": <subscription_timestamp>, "<broadcast_id>", <subscription_timestamp>, ...}

POST

subscribe a screen to a broadcast

data: {"broadcast_id": broadcast_id}

response: (status code)

. /screens/<int:screen_id>/broadcasts/<int:broadcast_id>

DELETE

remove a screen from a broadcast

data: nothing

response: {"broadcast_id": broadcast_id, "screen_id": screen_id}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •