Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
harmandeveloperprogram committed Feb 5, 2016
1 parent 196975a commit 00e8d7b
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 96 deletions.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/iOS/hkwhub-spec.doctree
Binary file not shown.
50 changes: 24 additions & 26 deletions docs/_build/html/_sources/iOS/hkwhub-spec.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ With **password** grant mode, you can get an access token and a refresh token as

.. code::

curl -H "Authorization: Basic bjdIaGlUbktZakpkNHptTTpBTlJmQjl6OTR4dGN4RkdYcmQ1WEhYRWlLZzQzVVk=" -d "grant_type=password&username=yyy&password=xxx" http://hkiotcloud.herokuapp.com/oauth/token
curl -X POST -H "Authorization: Basic bjdIaGlUbktZakpkNHptTTpBTlJmQjl6OTR4dGN4RkdYcmQ1WEhYRWlLZzQzVVk=" -d "grant_type=password&username=yyy&password=xxx" http://hkiotcloud.herokuapp.com/oauth/token

Result:

Expand All @@ -357,13 +357,13 @@ Result:
"refresh_token":"1b470edc539681803de95c919bc3779acdf34e01"}


When you call the HKIoTCloud API calls, you should pass the value of the access token into the request header. Specifically, create an ``Authorization`` header and give it the ``value Bearer <access token>``.
When you call the HKIoTCloud API calls, you should pass the value of the access token into the request header. Specifically, create an ``Authorization`` header and give it the value ``Bearer <access token>``.

a. Init session
^^^^^^^^^^^^^^^
``curl -X POST -d "username=seonman&password=xxx" http://hkiotcloud.herokuapp.com/api/v1/init_session``
``curl -X POST -H "Authorization: Bearer 15c0507f3a550d7a31f7af5dc45e4dd9fd9f4bc8" http://hkiotcloud.herokuapp.com/api/v1/init_session``

This returns the SessionToken. The returned SessionToken is used by all subsequent REST API commands.
This returns the SessionToken. The returned SessionToken is used by all subsequent REST API request in the body.

.. code:: json

Expand All @@ -375,7 +375,7 @@ b. Add alls speaker to session

After HKWHub app is launched, none of speakers is selected for playback. You need to add one or more speakers to play audio. To add all speakers to playback session, use ``set_party_mode``. **Party Mode** is the mode where all speakers are playing the same audio together with synchronization. So, by ``set_party_mode``, you can select all speakers to play.

``curl "http://hkiotcloud.herokuapp.com/api/v1/set_party_mode?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh"``
``curl -H "Authorization: Bearer 15c0507f3a550d7a31f7af5dc45e4dd9fd9f4bc8" "http://hkiotcloud.herokuapp.com/api/v1/set_party_mode?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh"``

.. code:: json

Expand All @@ -385,7 +385,7 @@ c. Get the list of speakers available
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To control speakers individually, you can get the list of speakers available by using **device_list** command.

``curl "http://hkiotcloud.herokuapp.com/api/v1/device_list?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh"``
``curl -H "Authorization: Bearer 15c0507f3a550d7a31f7af5dc45e4dd9fd9f4bc8" "http://hkiotcloud.herokuapp.com/api/v1/device_list?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh"``

.. code:: json

Expand Down Expand Up @@ -432,15 +432,15 @@ d. Add a speaker to session

If you want to add a speaker to session, use ``add_device_to_session`. It requires ``DeviceID`` parameter to identify a speaker to add. This command does not impact other speakers regardless of their status.

``curl "http://hkiotcloud.herokuapp.com/api/v1/add_device_to_session?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh&DeviceID=4625984469168"``
``curl -H "Authorization: Bearer 15c0507f3a550d7a31f7af5dc45e4dd9fd9f4bc8" "http://hkiotcloud.herokuapp.com/api/v1/add_device_to_session?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh&DeviceID=4625984469168"``

.. code:: json

{"Result":"true","ResponseOf":"add_device_to_session"}

e. Get the media list
^^^^^^^^^^^^^^^^^^^^^^^
``curl "http://hkiotcloud.herokuapp.com/api/v1/media_list?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh"``
``curl -H "Authorization: Bearer 15c0507f3a550d7a31f7af5dc45e4dd9fd9f4bc8" "http://hkiotcloud.herokuapp.com/api/v1/media_list?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh"``

Here, SessionToken should be the session token you got from ``init_session``. You will get a list of media in JSON like below

Expand Down Expand Up @@ -468,7 +468,7 @@ If you want to play a media item listed in the HKWHub app, use ``play_hub_media`

Note that, before calling ``play_hub_media``, at least one or more speakers must be selected (added to session) in advance. If not, then the playback will fail.

``curl "http://hkiotcloud.herokuapp.com/api/v1/play_hub_media?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh&PersistentID=1062764963669236741"``
``curl -H "Authorization: Bearer 15c0507f3a550d7a31f7af5dc45e4dd9fd9f4bc8" "http://hkiotcloud.herokuapp.com/api/v1/play_hub_media?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh&PersistentID=1062764963669236741"``

.. code-block:: json

Expand All @@ -479,7 +479,7 @@ f. Play a media item in the HKWHub by specifying a speaker list to play
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can play a media item in the HKWHub app by specifying the list of speakers.

``curl "http://hkiotcloud.herokuapp.com/api/v1/play_hub_media_selected_speakers?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh&PersistentID=1062764963669236741&DeviceIDList=34317244381360,129321920968880"``
``curl -H "Authorization: Bearer 15c0507f3a550d7a31f7af5dc45e4dd9fd9f4bc8" "http://hkiotcloud.herokuapp.com/api/v1/play_hub_media_selected_speakers?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh&PersistentID=1062764963669236741&DeviceIDList=34317244381360,129321920968880"``

The list of speakers are listed by the parameter ``DeviceIDList`` with delimitor ",".

Expand All @@ -489,23 +489,23 @@ The list of speakers are listed by the parameter ``DeviceIDList`` with delimitor

g. Play a HTTP streaming media as party mode
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``curl "http://hkiotcloud.herokuapp.com/api/v1/play_web_media_party_mode?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh&MediaUrl=http://seonman.github.io/music/hyolyn.mp3"``
``curl -H "Authorization: Bearer 15c0507f3a550d7a31f7af5dc45e4dd9fd9f4bc8" "http://hkiotcloud.herokuapp.com/api/v1/play_web_media_party_mode?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh&MediaUrl=http://seonman.github.io/music/hyolyn.mp3"``

.. code-block:: json

{"Result":"true","ResponseOf":"play_web_media_party_mode"}

h. Stop playing
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``curl "http://hkiotcloud.herokuapp.com/api/v1/stop_play?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh"``
``curl -H "Authorization: Bearer 15c0507f3a550d7a31f7af5dc45e4dd9fd9f4bc8" "http://hkiotcloud.herokuapp.com/api/v1/stop_play?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh"``

.. code-block:: json

{"Result":"true","ResponseOf":"stop_play"}

i. Set Volume
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``curl "http://hkiotcloud.herokuapp.com/api/v1/set_volume?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh&Volume=30"``
``curl -H "Authorization: Bearer 15c0507f3a550d7a31f7af5dc45e4dd9fd9f4bc8" "http://hkiotcloud.herokuapp.com/api/v1/set_volume?SessionToken=r:abciKaTbUgdpQFuvYtgMm0FRh&Volume=30"``

.. code-block:: json

Expand Down Expand Up @@ -554,13 +554,13 @@ Session Timeout
REST API Specification (including PubNub JSON format)
-------------------------------------------------------

This specification describes the REST API for controlling HKWHub app remotely to control HK Omni speakers and stream audio to the speakers.
This specification describes about the REST APIs to control HK Omni speakers and stream audio to the speakers via HKWHub app.

All the APIS are in REST API protocol.

.. Note::

For HKIoTCloud mode, <server_host> should be "hkiotcloud.herokuapp.com".
In this documentation, for HKIoTCloud mode, <server_host> should be "hkiotcloud.herokuapp.com".
For Local server mode, <server_host> should be the URL (IP address and port number) tat HKWHub app is showing.

.. Note::
Expand All @@ -569,23 +569,21 @@ All the APIS are in REST API protocol.

So, we will describe PubNub message specification along with REST API specification here.


.. Note::

All the REST request should contain ``Authorization`` header that contains the access token, as described above.


Session Management
~~~~~~~~~~~~~~~~~~~~

Start Session
^^^^^^^^^^^^^^
This starts a new session. As a response, the client will receive a SessionToken. The SessionToken is required to be sent in any following requests. Note that the REST requests differs depending on the server mode.

- HKIoTCloud mode
- API: **POST** /api/v1/init_session
- Body
- username: the username
- password: the password
- Local Server mode
- API: **GET** /api/v1/init_session
- Body : none
- Note that the message is sent as **GET** mode, instead of **POST**.


- API: GET /api/v1/init_session
- Response
- Returns a unique session token
- The session token will be used for upcoming requests.
Expand All @@ -594,7 +592,7 @@ This starts a new session. As a response, the client will receive a SessionToken

.. code-block:: json

curl -X POST -d "username=seonman&password=xxx" http://<server_host>/api/v1/init_session
curl -X POST -H "Authorization: Bearer 15c0507f3a550d7a31f7af5dc45e4dd9fd9f4bc8" http://<server_host>/api/v1/init_session

- Response:

Expand Down

0 comments on commit 00e8d7b

Please sign in to comment.