|
1 | 1 | # Endpoint
|
| 2 | + |
2 | 3 | The endpoint is one of the components provided by Tangle-accelerator, running on a resource-constrained network connectivity module. The embedded devices can send messages to blockchain network (Tangle) with a connectivity module loaded endpoint. The message would be transmitted to connectivity module through UART. Message would be encrypted and send to tangle.
|
3 | 4 |
|
4 | 5 | # Streaming Message Channel Implementation
|
| 6 | + |
5 | 7 | The encrypted message would be sent to Tangle with a streaming message channel API. The streaming message channel API would ensure the order of messages in the channel. The user who wants to fetch/send message to Tangle needs to provide `data_id`, `key` and `protocol` to identify a specific message.
|
6 | 8 | A message sent by endpoint needs to be encrypted locally, which avoids message being peeked and modified.
|
7 | 9 |
|
8 |
| -# How to use |
| 10 | +# How to build endpoint |
| 11 | + |
| 12 | +## Setup Legato application framework development environment |
| 13 | + |
| 14 | +The endpoint uses the Legato application framework as based runtime system. Developers need to set up the Sierra development environment to build endpoint as specific target. |
| 15 | + |
| 16 | +### How to build endpoint application for wp77xx |
| 17 | + |
| 18 | +[Leaf](https://docs.legato.io/latest/toolsLeaf.html) is a workspace manager that will download, install and configure the required software packages for a Legato development environment. |
| 19 | + |
| 20 | +#### prerequisite packages required by leaf |
| 21 | + |
| 22 | +```shell |
| 23 | +$ sudo apt install \ |
| 24 | + python3-argcomplete \ |
| 25 | + python3-colorama \ |
| 26 | + python3-gnupg \ |
| 27 | + python3-jsonschema \ |
| 28 | + python3-requests \ |
| 29 | + gnupg \ |
| 30 | + bash-completion \ |
| 31 | + xz-utils |
9 | 32 | ```
|
10 |
| -$ bazel build //endpoint:wp7702 |
11 |
| -$ bazel build //endpoint:sim |
| 33 | + |
| 34 | +Install leaf |
| 35 | + |
| 36 | +```shell |
| 37 | +$ curl -sLO https://downloads.sierrawireless.com/tools/leaf/leaf_latest.deb && sudo dpkg -i leaf_latest.deb |
12 | 38 | ```
|
13 | 39 |
|
14 |
| -## HTTPS Connection Support |
15 |
| -The endpoint uses http connection as default. The message which sent to tangle-accelerator has been encrypted. So the HTTP connection would not be unsafe. To build with https connection support, add `--define https=enable` option. |
| 40 | +Create a workspace |
| 41 | + |
| 42 | +```shell |
| 43 | +$ mkdir -p workspace |
| 44 | +$ cd workspace |
| 45 | +``` |
| 46 | + |
| 47 | +Setup the wp77xx target profile |
| 48 | + |
| 49 | +```shell |
| 50 | +$ leaf setup legato-stable -p swi-wp77_3.0.0 |
| 51 | +``` |
| 52 | + |
| 53 | +Finally, make the wp77xx endpoint target. Be careful with the directory of tangle-accelerator. It should be located within the workspace directory. |
| 54 | + |
| 55 | +```shell |
| 56 | +$ git clone https://github.com/DLTcollab/tangle-accelerator.git |
| 57 | +$ cd tangle-accelerator |
| 58 | +$ make TARGET=wp77xx legato # build endpoint as wp77xx target |
| 59 | +$ make TESTS=true TARGET=wp77xx legato # build endpoint as wp77xx target in test mode |
| 60 | +``` |
| 61 | + |
| 62 | +### How to build endpoint application for native target |
| 63 | + |
| 64 | +Install required packages: |
| 65 | + |
| 66 | +```shell |
| 67 | +$ sudo apt-get install -y \ |
| 68 | + autoconf \ |
| 69 | + automake \ |
| 70 | + bash \ |
| 71 | + bc \ |
| 72 | + bison \ |
| 73 | + bsdiff \ |
| 74 | + build-essential \ |
| 75 | + chrpath \ |
| 76 | + cmake \ |
| 77 | + cpio \ |
| 78 | + diffstat \ |
| 79 | + flex \ |
| 80 | + gawk \ |
| 81 | + gcovr \ |
| 82 | + git \ |
| 83 | + gperf \ |
| 84 | + iputils-ping \ |
| 85 | + libbz2-dev \ |
| 86 | + libcurl4-gnutls-dev \ |
| 87 | + libncurses5-dev \ |
| 88 | + libncursesw5-dev \ |
| 89 | + libsdl-dev \ |
| 90 | + libssl-dev \ |
| 91 | + libtool \ |
| 92 | + libxml2-utils \ |
| 93 | + ninja-build \ |
| 94 | + python \ |
| 95 | + python-git \ |
| 96 | + python-jinja2 \ |
| 97 | + python-pkg-resources \ |
| 98 | + python3 \ |
| 99 | + texinfo \ |
| 100 | + unzip \ |
| 101 | + wget \ |
| 102 | + zlib1g-dev |
16 | 103 | ```
|
17 |
| -$ bazel build --define https=enable //endpoint:wp7702 |
| 104 | + |
| 105 | +Create a workspace |
| 106 | + |
| 107 | +```shell |
| 108 | +$ mkdir -p workspace |
| 109 | +$ cd workspace |
| 110 | +``` |
| 111 | + |
| 112 | +Clone a specific version of `legato`. The `19.07.0` is the preferred stable version. |
| 113 | + |
| 114 | +```shell |
| 115 | +$ repo init -u git://github.com/legatoproject/manifest -m legato/releases/19.07.0.xml # specific legato 19.07.0 version |
| 116 | +$ repo sync |
| 117 | +``` |
| 118 | + |
| 119 | +Build legato as native target |
| 120 | + |
| 121 | +```shell |
| 122 | +$ cd legato |
| 123 | +$ make localhost |
| 124 | +``` |
| 125 | + |
| 126 | +Checkout the shell to legato shell |
| 127 | + |
| 128 | +```shell |
| 129 | +$ source framework/tools/scripts/configlegatoenv |
| 130 | +``` |
| 131 | + |
| 132 | +Finally, use GNU Make to build endpoint application at the root directory of tangle-accelerator. |
| 133 | + |
| 134 | +```shell |
| 135 | +$ cd tangle-accelerator |
| 136 | +$ make legato # build endpoint as native target |
| 137 | +``` |
| 138 | + |
| 139 | +The endpoint will be built at `endpoint/_build_endpoint/localhost/app/endpoint/staging/read-only/bin/endpoint` |
| 140 | + |
| 141 | +## HTTPS Connection Support |
| 142 | + |
| 143 | +The endpoint uses HTTP connection as default. The message sent to tangle-accelerator has been encrypted, so the HTTP connection would not be unsafe. To build with HTTPS connection support, add `ENFORCE_EP_HTTPS=true` option. |
| 144 | + |
| 145 | +For HTTPS connection support, the PEM file should also be set. The default pem file is located at `pem/cert.pem`. If the `PEM` is not set, the build system will use the default pem. The endpoint will verify the connection server with the trusted certificate from the pem file. The default pem is only for the build system. The user should provide the certificate from the server you want to connect. See pem/README.md for more information. |
| 146 | + |
| 147 | +```shell |
| 148 | +$ make ENFORCE_EP_HTTPS=true PEM=/path/to/pem legato |
18 | 149 | ```
|
0 commit comments