3 This project provides the binder component of the the microservice architecture
4 of Automotive Grade Linux (AGL).
6 This project is available there https://git.automotivelinux.org/src/app-framework-binder/
8 It can be cloned with **git clone https://git.automotivelinux.org/src/app-framework-binder**.
11 ## License and copying
13 This software is an open source software funded by LinuxFoundation and Renesas.
15 This software is delivered under the terms of the open source license Apache 2.
17 This license is available in the file LICENSE-2.0.txt or on the worl wide web at the
18 location https://opensource.org/licenses/Apache-2.0
25 Building the AGL framework binder has been tested under
26 **Ubuntu**, **Debian** and **Fedora 26** with gcc 6 and 7.
28 It requires the following libraries:
30 * libmagic ("libmagic-dev" under Ubuntu, "file-devel" under Fedora);
31 * libmicrohttpd >= 0.9.55 (fetch and build from "http://ftp.gnu.org/gnu/libmicrohttpd");
32 * json-c ("libjson-c-dev/devel");
33 * uuid ("uuid-dev/libuuid-devel");
34 * openssl ("libssl-dev/openssl-devel");
35 * systemd >= 222 ("libsystemd-dev/systemd-devel");
37 The following library can be used for checking permissions:
39 * cynara (https://github.com/Samsung/cynara)
41 and the following tools:
47 To install all dependencies under Ubuntu (excepting libmicrohttpd), please type:
49 $ apt-get install libmagic-dev libjson-c-dev uuid-dev libsystemd-dev libssl-dev gcc make pkg-config cmake
51 or under Fedora (excepting libmicrohttpd and rtl-sdr):
53 $ dnf install git passwd iproute openssh-server openssh-client
54 $ dnf install file-devel gcc gdb make pkgconfig cmake
55 $ dnf install json-c-devel libuuid-devel systemd-devel openssl-devel
57 ### Simple compilation
59 The following commands will install the binder in your subdirectory
60 **$HOME/local** (instead of **/usr/local** the default when
61 *CMAKE_INSTALL_PREFIX* isn't set).
63 $ git clone https://git.automotivelinux.org/src/app-framework-binder
64 $ cd app-framework-binder
67 $ cmake -DCMAKE_INSTALL_PREFIX=$HOME/local ..
70 ### Advanced compilation
72 You can tune options when calling cmake. Here are the known options with
75 $ git clone https://git.automotivelinux.org/src/app-framework-binder
76 $ cd app-framework-binder
80 -DCMAKE_INSTALL_PREFIX=/usr/local \
82 -DINCLUDE_MONITORING=OFF \
83 -DINCLUDE_SUPERVISOR=OFF \
84 -DINCLUDE_DBUS_TRANSPARENCY=OFF \
85 -DINCLUDE_LEGACY_BINDING_V1=OFF \
86 -DINCLUDE_LEGACY_BINDING_VDYN=OFF \
87 -DAFS_SUPERVISOR_PORT=1619 \
88 -DAFS_SUPERVISOR_TOKEN="HELLO" \
89 -DAFS_SUPERVISION_SOCKET="@urn:AGL:afs:supervision:socket" \
90 -DUNITDIR_SYSTEM=${CMAKE_INSTALL_LIBDIR}/systemd/system \
94 The configuration options are:
96 | Variable | Type | Feature
97 |:----------------------------|:-------:|:------------------------------
98 | AGL_DEVEL | BOOLEAN | Activates development features
99 | INCLUDE_MONITORING | BOOLEAN | Activates installation of monitoring
100 | INCLUDE_SUPERVISOR | BOOLEAN | Activates installation of supervisor
101 | INCLUDE_DBUS_TRANSPARENCY | BOOLEAN | Allows API transparency over DBUS
102 | INCLUDE_LEGACY_BINDING_V1 | BOOLEAN | Includes the legacy Binding API version 1
103 | INCLUDE_LEGACY_BINDING_VDYN | BOOLEAN | Includes the legacy Binding API version dynamic
104 | AFS_SUPERVISOR_PORT | INTEGER | Port of service for the supervisor
105 | AFS_SUPERVISOR_TOKEN | STRING | Secret token for the supervisor
106 | AFS_SUPERVISION_SOCKET | STRING | Internal socket path for supervision (internal if starts with @)
107 | UNITDIR_SYSTEM | STRING | Path to systemd system unit files for installing supervisor
112 ***** TO BE COMPLETED *****
133 $ ${AFB_DAEMON_DIR}/build/src/afb-daemon --help
134 $ ${AFB_DAEMON_DIR}/build/src/afb-daemon --port=1234 --token='' --ldpaths=${AFB_DAEMON_DIR}/build --sessiondir=/tmp --rootdir=${AFB_DAEMON_DIR}/test
141 $ afb-daemon --verbose --port=<port> --token='' --sessiondir=<working directory> --rootdir=<web directory (index.html)>
147 $ afb-daemon --verbose --port=1234 --token='' --sessiondir=/tmp --rootdir=/srv/www/htdocs --alias=icons:/usr/share/icons
150 ### Directories & Paths
152 Default behaviour is to locate ROOTDIR in $HOME/.AFB
156 Developers are intended to provide a structure containing : API name, corresponding methods/callbacks, and optionally a context and a handle.
157 A handle is a void* structure automatically passed to API callbacks.
158 Callbacks also receive HTTP GET data as well as HTTP POST data, in case a POST method was used.
159 Every method should return a JSON object or NULL in case of error.
161 API plugins can be protected from timeout and other errors. By default this behaviour is deactivated, use --apitimeout to activate it.
163 STATIC AFB_restapi myApis[]= {
164 {"ping" , AFB_SESSION_NONE, (AFB_apiCB)ping, "Ping Function"},
165 {"action1" , AFB_SESSION_CHECK, (AFB_apiCB)action1 , "Action-1"},
166 {"action2" , AFB_SESSION_CHECK, (AFB_apiCB)action2 , "Action-2"},
170 PUBLIC AFB_plugin *pluginRegister () {
171 AFB_plugin *plugin = malloc (sizeof (AFB_plugin));
172 plugin->type = AFB_PLUGIN_JSON;
173 plugin->info = "Plugin Sample";
174 plugin->prefix= "myPlugin";
175 plugin->apis = myApis;
179 ### HTML5 and AngularJS Redirects
181 Binder supports HTML5 redirect mode even with an application baseurl.
182 Default value for application base URL is /opa.
183 See Application Framework HTML5 Client template at https://github.com/iotbzh/afb-client-sample
185 If the Binder receives something like _http://myopa/sample_ when sample is not the homepage of the AngularJS OPA,
186 it will redirect to _http://myopa/#!sample_.
187 This redirect will return the _index.html_ OPA file and will notify AngularJS not to display the homepage, but the sample page.
189 Warning: in order for AngularJS applications to be able to work with both BASEURL="/" and BASEURL="/MyApp/", all page references have to be relative.
191 Recommended model is to develop with a BASEURL="/opa" as any application working with a BASEURL will work without, while the opposite is not true.
193 Note: If a resource is not accessible from ROOTDIR then the "--alias" switch should be used, as in: --alias=/icons:/usr/share/icons.
194 Only use alias for external support static files. This should not be used for API and OPA.
199 Javascript plugins. As of today, only C plugins are supported, but JS plugins are on the TODO list.