Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3132c50
#6 Add websocket support for events with other devices
SrMouraSilva Feb 17, 2018
5e3d0b3
#6 Make TCP connection async
SrMouraSilva Feb 17, 2018
04b209d
FIX #10 - License Apache
SrMouraSilva Feb 17, 2018
262a06c
#13 Try reconnect wme conectiom is closed
SrMouraSilva Feb 17, 2018
c2a5114
#17 Keyboard support. Protocol improvement: Int Identifier
SrMouraSilva Feb 21, 2018
804c0af
#13 Try reconnect when the stream closes when are sending data. #17 …
SrMouraSilva Feb 22, 2018
87ec1e6
Fix bugs request protocol -> webservice request
SrMouraSilva Feb 24, 2018
7e7878d
Fix request bugs
SrMouraSilva Feb 24, 2018
678a8d0
#19 Initial tests with USB detection (#20) and android usb acessory
SrMouraSilva Mar 6, 2018
f9f7e07
#21 Initial changes
SrMouraSilva Mar 7, 2018
dd0c106
#21 Improve Readme
SrMouraSilva Mar 7, 2018
c450b00
#21 Improve Readme
SrMouraSilva Mar 7, 2018
6c6c3e6
#16 Initial build script
SrMouraSilva Mar 8, 2018
49f4107
#16 Add very simple coverage support
SrMouraSilva Mar 8, 2018
46fb861
#16 Fix travis script
SrMouraSilva Mar 8, 2018
51d6ed2
#16 Fix test to ws v0.3.0t
SrMouraSilva Mar 8, 2018
fc47176
#16 Try fix install requirements. Add Readme badges
SrMouraSilva Mar 8, 2018
0d8a8d5
#16 Try fix bugs
SrMouraSilva Mar 8, 2018
a06fe17
#22 Auto dettect if adb has installed
SrMouraSilva Mar 9, 2018
78c551e
Issue #22 Remove old imports and doc
SrMouraSilva Mar 9, 2018
a2229d2
Merge pull request #8 from PedalPi/issue-1-new-protocol
SrMouraSilva Mar 9, 2018
b18e3e8
Merge pull request #12 from PedalPi/issue-6-websocket-support
SrMouraSilva Mar 9, 2018
cd94b01
Merge pull request #14 from PedalPi/issue-10-apache-license
SrMouraSilva Mar 9, 2018
39027ba
Merge pull request #15 from PedalPi/issue-13-try-reconnect
SrMouraSilva Mar 9, 2018
e5aa91d
Merge pull request #27 from PedalPi/issue-17-key
SrMouraSilva Mar 9, 2018
444630a
Merge pull request #28 from PedalPi/issue-19-android-usb-accessory
SrMouraSilva Mar 9, 2018
718c0ea
Revert "Issue 19 android usb accessory"
SrMouraSilva Mar 9, 2018
b756975
Merge pull request #29 from PedalPi/revert-28-issue-19-android-usb-ac…
SrMouraSilva Mar 9, 2018
e54fa31
Merge pull request #23 from PedalPi/issue-21-readme
SrMouraSilva Mar 9, 2018
bbedc1d
Merge pull request #24 from PedalPi/issue-16-build
SrMouraSilva Mar 9, 2018
9909c0d
Merge pull request #25 from PedalPi/issue-22-detect-adb
SrMouraSilva Mar 9, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
**.pyc
__pycache__/
**.egg-info/

data/
.coverage
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
language: python

python:
- "3.4"
- "3.5"
- "3.6"
- "3.7-dev"
- "nightly"

sudo: required

install:
- make install-develop-requirements
- make install-tests-requirements
- make install-docs-requirements
- python setup.py develop

script:
- lv2ls
- make test

after_success:
- bash <(curl -s https://codecov.io/bash)
7 changes: 6 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Version 0.2.0 - released mm/dd/18
Version 0.2.0 - released 03/dd/18
=================================

- Initial release

- Change Android Controller -> WebServiceSerial: Now use WebService to reuse WebService methods
- Defined Target: Initial target is Android, but is possible implements other targets for communication with other devices, as Arduino via USB Serial communication
- Try reconnect when connection is closed
- Check if is ADB has installed
- Try download the ADB if isn't installed
210 changes: 117 additions & 93 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
WebService Serial
=================

.. image:: https://travis-ci.org/PedalPi/WebServiceSerial.svg?branch=master
:target: https://travis-ci.org/PedalPi/WebServiceSerial
:alt: Build Status

.. image:: https://codecov.io/gh/PedalPi/WebServiceSerial/branch/master/graph/badge.svg
:target: https://codecov.io/gh/PedalPi/WebServiceSerial
:alt: Code coverage


WebService Serial disposes the `WebService`_ communication via TCP
Serial communication.

With it, is possible:

- Use `DisplayView`_, an Android application that provides pedalboard
data for live presentations. Your focus is a speed management in live
performances.

- Use `DisplayView`_, an Android application for manages quickly the
current pedalboard. Ideal for adjusting live performances and band
rehearsal.

**Documentation:**
https://github.com/PedalPi/WebServiceSerial
Expand All @@ -25,149 +33,165 @@ With it, is possible:

.. _Apache License 2.0: https://github.com/PedalPi/WebServiceSerial/blob/master/LICENSE

~How to use~ FIXME
------------------
Installation
------------

Like described in `Application documentation`_, create a ``start.py``
and register AndroidController component.
Install with pip:

.. code:: python
.. code-block:: bash

import sys
import tornado
pip install PedalPi-PluginsManager

# DEPRECATED
sys.path.append('application')
sys.path.append('android_controller')
Also is necessary install the `Android Debug Bridge (adb)`_
for communication between the Pedal Pi and a Android device. In a Linux like, execute

from application.Application import Application
from android_controller.android_controller import AndroidController
.. code-block:: bash

address = 'localhost'
port = 3000
sudo apt-get install android-tools-adb

application = Application(path_data="data/", address=address, test=True)
application.register(AndroidController(application, "adb"))
.. _Android Debug Bridge (adb): https://developer.android.com/studio/command-line/adb.html

application.start()
In embedded systems, the WebService Serial will try to download an adb pre-build
if the adb is not installed on the device.

tornado.ioloop.IOLoop.current().start()
Also, is possible compile the adb. See https://github.com/PedalPi/adb-arm

Dependencies
~~~~~~~~~~~~
How to use
----------

**WebService Serial** requires ``Tornado >= 4.2`` for TCP connection.
Like described in `Application documentation`_, create a ``start.py``
and register WebService Serial component. Is necessary that **WebService Serial**
be registered after the **WebService** (WebService is dependency of WebService Serial
and it will be installed when WebService Serial is installed).

For communication with Android (over USB), also needs ``adb``.
.. code:: python

If you uses in a ARM architecture, maybe will be necessary compile
**adb**. In these cases, the project https://github.com/PedalPi/adb-arm
can help you. **adb-arm** PedalPi *fork* already contains some binaries
for RaspberryPi.
# Imports application
from application.application import Application

Protocol
--------
address = 'localhost'
application = Application(path_data="data/", address=address)

The communication are described here. For the possible command lists,
see the `WebService documentation`_.
# Register WebService before WebServiceSerial
from webservice.webservice import WebService
application.register(WebService(application))

Request
~~~~~~~
# Register WebServiceSerial after WebService
from webservice_serial.webservice_serial import WebServiceSerial
from webservice_serial.target.android.android_display_view import AndroidDisplayView

::
target = AndroidDisplayView()
application.register(WebServiceSerial(application, target))

<METHOD> <URL>\n
<DATA>\n
EOF\n
# Start Application
application.start()

- ``<METHOD>``: ``GET``, ``POST``, ``PUT``, ``DELETE``, ``SYSTEM``
- ``<DATA>``: Json data. If none, send ``'{}'``
- ``<URL>``: http://pedalpi.github.io/WebService/
- ``EOF``: The string “EOF”.
import tornado
try:
tornado.ioloop.IOLoop.current().start()
except KeyboardInterrupt:
application.stop()

Example:

::
WebService Serial now has been configured to connect with a Android device that are
installed a app compatible with it. If haven't installed a app in your device, is recommended
the `Pedal Pi - Display View`_. With Display View, is possible manages the current pedalboard
quickly by a Android device connected with Pedal Pi by the USB. Read your recommendations for
details how to configure the device to enable the communication between the devices
over USB.

PUT /current/bank/1/pedalboard/3
{}
EOF
.. _Pedal Pi - Display View: https://play.google.com/store/apps/details?id=io.github.com.pedalpi.displayview

Response
~~~~~~~~
Protocol
--------

::
`WebService Serial` provides a way to communicate with ``WebService`` through a serial connection.

RESPONSE <DATA>
`WebService Serial` provides a TCP client. For communication with a device, is necessary that
the device implements a socket TCP server listening the port ``8888``.

- ``RESPONSE``: String ``RESPONSES``;
- ``<DATA>``: Json data. If none, send ``'{}'``
The communication are based in messages from device to the Pedal Pi (``Request`` messages)
and messages from Pedal Pi to the device (``Response`` and ``Event`` messages)

Notification
~~~~~~~~~~~~
``Request`` Message
~~~~~~~~~~~~~~~~~~~

This corresponds the websocket data notifications
With ``Request`` Message, a device can request data. The message format has the following format::

::
<IDENTIFIER> <METHOD> <URL>\n<DATA>\nEOF\n

EVENT <DATA>
::

- ``EVENT``: String ``EVENT``
- ``<DATA>``: Json data. If none, send ``'{}'``
<IDENTIFIER> <METHOD> <URL>
<DATA>
EOF
[empty line here]

Initialization
~~~~~~~~~~~~~~
The communication are described here. For the possible command lists,
see the `WebService documentation`_.

After the connection has been realized,
- ``<IDENTIFIER>``: ``int`` Unique id that defines the request. This value will be used in a response message, identifying the original request message;
- ``<METHOD>``: ``string`` Possible values are:

1. Application send
+ ``GET``, ``POST``, ``PUT``, ``DELETE`` Based in the `WebService documentation`_;
+ ``SYSTEM`` Informs custom system messages. Actually this isn't used;

::
- ``<DATA>``: Json data. If none, send an empty string;
- ``<URL>``: Resource identifier. Is necessary to informs the API version too (``/v1/<resouce>``). For the full list of resource, see http://pedalpi.github.io/WebService/
- ``EOF``: The string “EOF”.

SYSTEM /
{"message": "connected"}
EOF
Example `Set the current pedalboard`_: ::

After initialization
~~~~~~~~~~~~~~~~~~~~
1 PUT /v1/current/bank/1/pedalboard/3

The connected device can be request thinks, like:
EOF

- The current pedalboard number
.. _Set the current pedalboard: http://pedalpi.github.io/WebService/#current-management-manages-the-current-pedalboard-put

::
``Response`` Message
~~~~~~~~~~~~~~~~~~~~

GET /v1/current
{}
EOF
``Response`` messages contains a response of a request. For identify the
respective request, see the identifier. The message format has the following format::

- Response
<IDENTIFIER> RESPONSE <DATA>\n

::
- ``<IDENTIFIER>``: ``int`` A response returns the same Unique id that the respective request informs;
- ``RESPONSE``: ``string`` The string “RESPONSE”;
- ``<DATA>``: ``string`` Json encoded data. If none, it will be an empty string;

RESPONSE { "bank": 1, "pedalboard": 0 }
``Event`` Message
~~~~~~~~~~~~~~~~~

- The pedalboard data
Changes that modify the Pedal Pi event can be applied by others Components. An example is
`Raspberry P0`_, that contains two buttons that when pressed changes the current pedalboard.
To maintain the application integrity, WebService Serial will send ``Event`` messages informing
the changes.

::
This corresponds the WebService `websocket data notifications`_.

GET /v1/bank/1/pedalboard/0
{}
EOF
.. _Raspberry P0: https://github.com/PedalPi/Raspberry-P0
.. _websocket data notifications: http://pedalpi.github.io/WebService/#websocket

- Response
A ``Event`` message format is::

::
<IDENTIFIER> EVENT <DATA>\n

RESPONSE { "name": "My pedalboard", "effects": [], "connections": [], "data": {} }
- ``EVENT``: ``string`` The string “EVENT”;
- ``<DATA>``: ``string`` Json encoded data. If none, it will be an empty string;

.. _WebService: https://github.com/PedalPi/WebService
.. _DisplayView: https://github.com/PedalPi/DisplayView
.. _Application documentation: http://pedalpi-application.readthedocs.io/en/latest/
.. _WebService documentation: http://pedalpi.github.io/WebService/

Scripts
=======
Development
===========

Install locally to develop::

python setup.py develop

See makefile options::

Install locally to develop
python setup.py develop
make help
Loading