From 58daab21cd043e1dc37024a7f99b396788372918 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 9 Mar 2024 14:19:48 +0100 Subject: Merging upstream version 1.44.3. Signed-off-by: Daniel Baumann --- .../test-tools/IoT-APP-Store-Demo/README.md | 50 ++ .../IoT-APP-Store-Demo/docker-compose.yml | 22 + .../IoT-APP-Store-Demo/wasm_django/Dockerfile | 9 + .../IoT-APP-Store-Demo/wasm_django/db.sqlite3 | Bin 0 -> 45056 bytes .../wasm_django/devices/__init__.py | 0 .../wasm_django/devices/admin.py | 3 + .../IoT-APP-Store-Demo/wasm_django/devices/apps.py | 5 + .../wasm_django/devices/migrations/__init__.py | 0 .../wasm_django/devices/models.py | 3 + .../wasm_django/devices/templates/application.html | 141 +++++ .../wasm_django/devices/templates/appstore.html | 98 ++++ .../wasm_django/devices/templates/empty.html | 125 +++++ .../wasm_django/devices/templates/help.html | 102 ++++ .../wasm_django/devices/templates/mysite.html | 91 +++ .../wasm_django/devices/tests.py | 3 + .../wasm_django/devices/views.py | 273 +++++++++ .../IoT-APP-Store-Demo/wasm_django/manage.py | 21 + .../wasm_django/mysite/__init__.py | 0 .../wasm_django/mysite/settings.py | 136 +++++ .../IoT-APP-Store-Demo/wasm_django/mysite/urls.py | 41 ++ .../IoT-APP-Store-Demo/wasm_django/mysite/wsgi.py | 16 + .../wasm_django/server/Dockerfile | 6 + .../wasm_django/server/wasm_server.py | 621 +++++++++++++++++++++ .../wasm_django/static/css/application.css | 400 +++++++++++++ .../wasm_django/static/css/appstore.css | 216 +++++++ .../wasm_django/static/css/index.css | 197 +++++++ .../wasm_django/static/js/application.js | 217 +++++++ .../wasm_django/static/js/appstore.js | 125 +++++ .../wasm_django/static/js/index.js | 51 ++ .../wasm_django/static/photo/app(1).png | Bin 0 -> 5421 bytes .../wasm_django/static/photo/application.png | Bin 0 -> 7875 bytes .../wasm_django/static/photo/delete.png | Bin 0 -> 4107 bytes .../wasm_django/static/photo/download(1).png | Bin 0 -> 1502 bytes .../wasm_django/static/photo/menu.png | Bin 0 -> 1839 bytes .../static/photo/milky-way-2695569_1280.jpg | Bin 0 -> 535384 bytes .../wasm_django/static/photo/net_device.png | Bin 0 -> 6867 bytes .../static/photo/software-icon-32081.png | Bin 0 -> 39956 bytes .../wasm_django/static/photo/totalblack.png | Bin 0 -> 2301 bytes .../wasm_django/static/upload/connection.wasm | Bin 0 -> 6280 bytes .../wasm_django/static/upload/event_publisher.wasm | Bin 0 -> 4958 bytes .../static/upload/event_subscriber.wasm | Bin 0 -> 4015 bytes .../wasm_django/static/upload/request_handler.wasm | Bin 0 -> 6776 bytes .../wasm_django/static/upload/request_sender.wasm | Bin 0 -> 5311 bytes .../wasm_django/static/upload/sensor.wasm | Bin 0 -> 4455 bytes .../wasm_django/static/upload/simple | Bin 0 -> 387456 bytes .../wasm_django/static/upload/sys/connection.wasm | Bin 0 -> 6280 bytes .../static/upload/sys/event_publisher.wasm | Bin 0 -> 4958 bytes .../static/upload/sys/event_subscriber.wasm | Bin 0 -> 4015 bytes .../static/upload/sys/request_handler.wasm | Bin 0 -> 6776 bytes .../static/upload/sys/request_sender.wasm | Bin 0 -> 5311 bytes .../wasm_django/static/upload/sys/timer.wasm | Bin 0 -> 2388 bytes .../wasm_django/static/upload/timer.wasm | Bin 0 -> 2388 bytes .../wasm_django/static/upload/ui_app.wasm | Bin 0 -> 1912 bytes .../wasm_django/static/upload/wasm_runtime_wgl | Bin 0 -> 615016 bytes 54 files changed, 2972 insertions(+) create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/README.md create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/docker-compose.yml create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/Dockerfile create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/db.sqlite3 create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/__init__.py create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/admin.py create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/apps.py create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/migrations/__init__.py create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/models.py create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/application.html create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/appstore.html create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/empty.html create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/help.html create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/mysite.html create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/tests.py create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/views.py create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/manage.py create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/__init__.py create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/settings.py create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/urls.py create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/wsgi.py create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/server/Dockerfile create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/server/wasm_server.py create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/application.css create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/appstore.css create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/index.css create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/application.js create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/appstore.js create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/index.js create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/app(1).png create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/application.png create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/delete.png create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/download(1).png create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/menu.png create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/milky-way-2695569_1280.jpg create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/net_device.png create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/software-icon-32081.png create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/totalblack.png create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/connection.wasm create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_publisher.wasm create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_subscriber.wasm create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_handler.wasm create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_sender.wasm create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sensor.wasm create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/simple create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/connection.wasm create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_publisher.wasm create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_subscriber.wasm create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_handler.wasm create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_sender.wasm create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/timer.wasm create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/timer.wasm create mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/ui_app.wasm create mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/wasm_runtime_wgl (limited to 'fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo') diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/README.md b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/README.md new file mode 100644 index 00000000..266255c0 --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/README.md @@ -0,0 +1,50 @@ +# IoT Application Store +Wasm application management portal for WAMR + +## Start the server + +### Using docker +1. install docker and docker-compose + ``` bash + sudo apt install docker.io docker-compose + ``` + +2. start + ``` bash + docker-compose up + ``` +### Using commands +> Note: must use python3.5. If you don't have python3.5 on your machine, had better using docker +1. install the required package + ``` bash + pip3 install django + ``` + +2. Start device server + ``` bash + cd wasm_django/server + python3 wasm_server.py + ``` + +3. Start IoT application management web portal + ``` bash + cd wasm_django + python3 manage.py runserver 0.0.0.0:80 + ``` + +## Start the runtime +1. Download WAMR runtime from [help](http://localhost/help/) page + > NOTE: You need to start the server before accessing this link! + +2. Start a WAMR runtime from localhost + ``` bash + chmod +x simple + ./simple + ``` + or from other computers + ``` bash + ./simple -a [your.server.ip.address] + ``` + +## Online demo + http://82.156.57.236/ diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/docker-compose.yml b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/docker-compose.yml new file mode 100644 index 00000000..331d064c --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/docker-compose.yml @@ -0,0 +1,22 @@ +version: '2.0' + +services: + web_portal: + build: ./wasm_django + network_mode: "host" + depends_on: + - 'device_server' + restart: always + volumes: + - store:/app/static/upload/ + device_server: + build: + context: ./wasm_django + dockerfile: ./server/Dockerfile + network_mode: "host" + restart: always + volumes: + - store:/app/static/upload/ + +volumes: + store: \ No newline at end of file diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/Dockerfile b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/Dockerfile new file mode 100644 index 00000000..a796725f --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.5 + +WORKDIR /app +COPY . /app + +# hadolint ignore=DL3013 +RUN pip install django --no-cache-dir + +ENTRYPOINT ["python", "manage.py", "runserver", "0.0.0.0:80"] diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/db.sqlite3 b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/db.sqlite3 new file mode 100755 index 00000000..211576ca Binary files /dev/null and b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/db.sqlite3 differ diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/__init__.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/__init__.py new file mode 100755 index 00000000..e69de29b diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/admin.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/admin.py new file mode 100755 index 00000000..8c38f3f3 --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/apps.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/apps.py new file mode 100755 index 00000000..d43cc4b6 --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class DevicesConfig(AppConfig): + name = 'devices' diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/migrations/__init__.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/migrations/__init__.py new file mode 100755 index 00000000..e69de29b diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/models.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/models.py new file mode 100755 index 00000000..71a83623 --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/application.html b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/application.html new file mode 100644 index 00000000..0b2ea7fa --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/application.html @@ -0,0 +1,141 @@ + + +{% load static %} + + + + + + + Wasm-Micro-Runtime + + + + + + + + + + +
+
+ +
+
+

WebAssembly Micro Runtime - APP Store Demo

+
+
+ + + +
+
+
+
+

+ +

+
+
IP :
+
Port :
+
Installed apps :
+
+
+
+ + + + + +
+

app is downloading now

+
+
+
+
+ + +
+
+
×
+
HOT Applications
+ +
+
+ +

Product Name:

+

Current Version:

+ +
+
+
+
+ + +
+

List of Installed Apps:

+ +
+ + +
+
+ +
Product Name:
+
Staus:
+
Current Version:
+
+
+
+ +
Copyright© intel.com
+ + + + + + + + + + + diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/appstore.html b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/appstore.html new file mode 100644 index 00000000..46ecedf1 --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/appstore.html @@ -0,0 +1,98 @@ + + +{% load static %} + + + + + + + + Wasm-Micro-Runtime + + + + + + + + + + +
+
+ +
+
+

WebAssembly Micro Runtime - APP Store Demo

+
+
+ + + + + +
+
+
+
The products
+
Application List
+
+
+ {%csrf_token%} +
+ + Choose File +
+
+ +
+
+
+
+
+
+
+

Product Name:

+

Product Version:

+

Preloaded Apps

+ +
+
+
+
+
+ + +
+ Copyright© intel.com +
+ + + + + + + + + diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/empty.html b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/empty.html new file mode 100644 index 00000000..5610a2d8 --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/empty.html @@ -0,0 +1,125 @@ + + + + + +wasm-micro-runtime + + + + + + + + + + +
+

404

+

Server Not Found

+

Github

+
+ + + + + + + + + + diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/help.html b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/help.html new file mode 100755 index 00000000..4ad7427b --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/help.html @@ -0,0 +1,102 @@ + + +{% load static %} + + + + + + + Wasm-Micro-Runtime + + + + + + + + + + + + +
+
+
+
+

+ How to use? +

+

+ 1. Download a simple runtime (build for ubuntu 20.04 64 bits, other platforms please build + from the source code) +

+

+ 2. In the terminal: cd ~/Download && ./simple -a 82.156.57.236 +

+
+
+ +
+ Notes: +
We also have a UI-enabled runtime, please download here and enjoy. It may require + a few more setups. +

Before running the UI-enabled runtime, please install some required softwares:

+

sudo apt-get install libsdl2-2.0-0:i386

+

For more details please refer to this guide +

+

cd ~/Download && ./wasm_runtime_wgl -a 82.156.57.236

+
+
+

+ 3. Return to device page, find your device according to the IP address and click it, you + will enter application installation page +

+

+ 4. In the application installation page, click the Install Application button, and chose an + app to install. (The "ui_app" is only for UI_enabled_runtimes, simple runtime can't install + this app) +

+

+ 5. If you want to upload a new application, go to App Store page, choose a file and click + upload +

+

+ Go Back + Download + simple_runtime + Download + UI_enabled_runtime +

+
+
+
+
+

Like this project?

+

Join us and build a powerful and interesting world for embedded + devices!

+ + +

+ View + on GitHub +

+
+
+
+
+
+
+ + + diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/mysite.html b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/mysite.html new file mode 100644 index 00000000..3832791d --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/mysite.html @@ -0,0 +1,91 @@ + + +{% load static %} + + + + + + + Wasm-Micro-Runtime + + + + + + + + + + +
+
+ +
+
+

WebAssembly Micro Runtime - APP Store Demo

+
+
+ +
+
+
+
+

+ +

+
+

The devices

+
+
+ +
+ + +
+
+
+
+

+ +

+
+
IP :
+
Port :
+
Installed apps :
+
+
+

+ +

+
+
+
+ + + + +
+ Copyright© intel.com +
+ + + + + + + + diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/tests.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/tests.py new file mode 100755 index 00000000..7ce503c2 --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/views.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/views.py new file mode 100755 index 00000000..1afa1f95 --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/devices/views.py @@ -0,0 +1,273 @@ +''' + /* Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ +''' + +# _*_ +from django.shortcuts import render, render_to_response +from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound +import json +import socket +import os + +# Create your views here. + + +avaliable_list = [ + {'ID': 'timer', 'Version': '1.0'}, + {'ID': 'connection', 'Version': '1.0'}, + {'ID': 'event_publisher', 'Version': '3.0'}, + {'ID': 'event_subscriber', 'Version': '1.0'}, + {'ID': 'request_handler', 'Version': '1.0'}, + {'ID': 'sensor', 'Version': '1.0'}, + {'ID': 'ui_app', 'Version': '1.0'} +] + +# Help +def help(req): +# return "Help" page + return render(req, "help.html") + +# View +def index(req): + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + host = '127.0.0.1' + port = 8889 + msg = "" + err = "" + + try: + s.connect((host, port)) + s.send(bytes("query:all", encoding='utf8')) + s.settimeout(10) + msg = s.recv(1024) + except socket.timeout as e: + err = "empty" + print("no client connected") + except socket.error as e: + err = "refused" + print("server not started") + + s.close() + + device_list = [] + if msg != "": + devices = msg.decode('utf-8').split("*") + for dev in devices: + dev_info = eval(dev) + addr = dev_info['addr'] + port = dev_info['port'] + apps = dev_info['num'] + device_list.append({'IP': addr, 'Port': port, 'apps': apps}) + else: + if err == "refused": + return render(req, "empty.html") + + dlist = device_list + + return render(req, 'mysite.html', {'dlist': json.dumps(dlist)}) + + +def apps(req): + open_status = '' + search_node = [] + if req.method == "POST": + dev_search = req.POST['mykey'] + dev_addr = req.POST['voip'] + dev_port = req.POST['voport'] + open_status = 'open' + for i in avaliable_list: + if i['ID'] == dev_search: + search_node = [{'ID':dev_search, 'Version': '1.0'}] + print("search_node:",search_node) + break + else: + search_node = ["Nothing find"] + print( "final:",search_node) + else: + dev_addr = req.GET['ip'] + dev_port = req.GET['port'] + open_status = 'close' + + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + host = '127.0.0.1' + port = 8889 + msg = "" + err = "" + + try: + s.connect((host, port)) + s.send(bytes("query:"+dev_addr+":"+str(dev_port), encoding='utf8')) + msg = s.recv(1024) + except socket.error as e: + print("unable to connect to server") + msg = b"fail" + s.close() + + app_list = [] + + if msg != "": + if msg.decode() == "fail": + return render(req, "empty.html") + else: + dic = eval(msg.decode(encoding='utf8')) + app_num = dic["num"] + for i in range(app_num): + app_list.append( + {'pname': dic["applet"+str(i+1)], 'status': 'Installed', 'current_version': '1.0'}) + + alist = app_list + device_info = [] + device_info.append( + {'IP': dev_addr, 'Port': str(dev_port), 'apps': app_num}) + + print(device_info) + return render(req, 'application.html', {'alist': json.dumps(alist), 'dlist': json.dumps(device_info), 'llist': json.dumps(avaliable_list), + "open_status":json.dumps(open_status),"search_node": json.dumps(search_node),}) + + +def appDownload(req): + dev_addr = req.GET['ip'] + dev_port = req.GET['port'] + app_name = req.GET['name'] + + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + host = '127.0.0.1' + port = 8889 + msg = "" + + app_path = os.path.abspath(os.path.join(os.getcwd(), "static", "upload")) + if app_path[-1] != '/': + app_path += '/' + + try: + s.connect((host, port)) + s.send(bytes("install:"+dev_addr+":"+str(dev_port)+":"+app_name + + ":"+app_path + app_name + ".wasm", encoding='utf8')) + msg = s.recv(1024) + except socket.error as e: + print("unable to connect to server") + s.close() + + success = "ok" + fail = "Fail!" + status = [success, fail] + print(msg) + if msg == b"fail": + return HttpResponse(json.dumps({ + "status": fail + })) + elif msg == b"success": + return HttpResponse(json.dumps({ + "status": success + })) + else: + return HttpResponse(json.dumps({ + "status": eval(msg.decode())["error message"].split(':')[1] + })) + + +def appDelete(req): + dev_addr = req.GET['ip'] + dev_port = req.GET['port'] + app_name = req.GET['name'] + + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + host = '127.0.0.1' + port = 8889 + s.connect((host, port)) + s.send(bytes("uninstall:"+dev_addr+":" + + str(dev_port)+":"+app_name, encoding='utf8')) + msg = s.recv(1024) + s.close() + r = HttpResponse("ok") + return r + +static_list = [{'ID': 'timer', 'Version': '1.0'}, {'ID': 'connection', 'Version': '1.0'}, {'ID': 'event_publisher', 'Version': '3.0'}, { + 'ID': 'event_subscriber', 'Version': '1.0'}, {'ID': 'reuqest_handler', 'Version': '1.0'}, {'ID': 'sensor', 'Version': '1.0'}, {'ID': 'ui_app', 'Version': '1.0'}] + +def store(req): + + store_path = os.path.join('static', 'upload') + status = [] + + print(user_file_list) + return render(req, 'appstore.html', {'staticlist': json.dumps(static_list), 'flist': json.dumps(user_file_list),'ulist':json.dumps(status)}) + +user_file_list = [] +files_list = [] +def uploadapps(req): + status = [] + local_list = ['timer','connection','event_publisher','event_subscriber','reuqest_handler','sensor'] + req.encoding = 'utf-8' + if req.method == 'POST': + myfile = req.FILES.get("myfile", None) + obj = req.FILES.get('myfile') + store_path = os.path.join('static', 'upload') + file_path = os.path.join('static', 'upload', obj.name) + + if not os.path.exists(store_path): + os.makedirs(store_path) + + file_name = obj.name.split(".")[0] + file_prefix = obj.name.split(".")[-1] + + + if file_prefix != "wasm": + status = ["Not a wasm file"] + elif file_name in local_list: + status = ["This App is preloaded"] + elif file_name in files_list: + status = ["This App is already uploaded"] + else: + status = [] + avaliable_list.append({'ID': file_name, 'Version': '1.0'}) + user_file_list.append({'ID': file_name, 'Version': '1.0'}) + files_list.append(file_name) + + print(user_file_list) + f = open(file_path, 'wb') + for chunk in obj.chunks(): + f.write(chunk) + f.close() + return render(req, 'appstore.html', {'staticlist': json.dumps(static_list), 'flist': json.dumps(user_file_list),'ulist':json.dumps(status)}) + +appname_list = [] + +def addapps(request): + types = '' + print("enter addapps") + request.encoding = 'utf-8' + app_dic = {'ID': '', 'Version': ''} + + # if request.method == 'get': + if "NAME" in request.GET: + a_name = request.GET['NAME'] + if a_name != "" and a_name not in appname_list: + appname_list.append(a_name) + message = request.GET['NAME'] + request.GET['Version'] + app_dic['ID'] = request.GET['NAME'] + app_dic['Version'] = request.GET['Version'] + avaliable_list.append(app_dic) + else: + types = "Exist" + print(avaliable_list) + return render(request, 'appstore.html', {'alist': json.dumps(avaliable_list)}) + +def removeapps(req): + app_name = req.GET['name'] + app_version = req.GET['version'] + remove_app = {'ID': app_name, 'Version': app_version} + avaliable_list.remove(remove_app) + user_file_list.remove(remove_app) + files_list.remove(app_name) + return render(req, 'appstore.html', {'alist': json.dumps(avaliable_list),'flist': json.dumps(user_file_list)}) + +# Test +# if __name__ == "__main__": +# print(device_list[0]['IP']) +# print(device['IP']) diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/manage.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/manage.py new file mode 100755 index 00000000..341863cf --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/manage.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/__init__.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/__init__.py new file mode 100755 index 00000000..e69de29b diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/settings.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/settings.py new file mode 100755 index 00000000..7eb3685c --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/settings.py @@ -0,0 +1,136 @@ +""" +Django settings for mysite project. + +Generated by 'django-admin startproject' using Django 2.2.2. + +For more information on this file, see +https://docs.djangoproject.com/en/2.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.2/ref/settings/ +""" + +import os +from django.conf.global_settings import STATIC_ROOT + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '8m05#6yx5wcygj*a+v6+=-y(#o+(z58-3!epq$u@5)64!mmu8q' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['*'] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + + 'devices', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'mysite.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'mysite.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.2/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + +APPEND_SLASH = False + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.2/howto/static-files/ + +STATIC_URL = '/static/' +HERE = os.path.dirname(os.path.abspath(__file__)) +HERE = os.path.join(HERE,'../') +STATICFILES_DIRS = (os.path.join(HERE,'static/'),) +#STATICFILES_DIRS = (os.path.join(BASE_DIR,'static'),) +#STATIC_ROOT = (os.path.join(os.path.dirname(_file_),'static') +#templates +TEMPLATE_DIRS=[ + '/home/xujun/mysite/templates', +] + diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/urls.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/urls.py new file mode 100755 index 00000000..8a74b550 --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/urls.py @@ -0,0 +1,41 @@ +#config:utf-8 + +"""mysite URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +#from django.conf.urls import include,url +from django.urls import path,include +from devices import views as devices_views +#from login import views as login_views + + +urlpatterns = [ + + path('admin/', admin.site.urls), + path('',devices_views.index), + path('apps/',devices_views.apps), + path('appDownload/', devices_views.appDownload), + path('appDelete/', devices_views.appDelete), + path('appstore/',devices_views.store), +## path('apps/appstore/',devices_views.storeofdevic), +## path('search/',devices_views.search), + path('upload',devices_views.uploadapps), + path('removeapps/',devices_views.removeapps), + path('help/',devices_views.help), + +] + + diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/wsgi.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/wsgi.py new file mode 100755 index 00000000..45e28c9a --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for mysite project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') + +application = get_wsgi_application() diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/server/Dockerfile b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/server/Dockerfile new file mode 100644 index 00000000..371fa45b --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/server/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.5 + +WORKDIR /app +COPY server/wasm_server.py /app/server/ + +ENTRYPOINT ["python", "server/wasm_server.py"] diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/server/wasm_server.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/server/wasm_server.py new file mode 100755 index 00000000..970ec6f6 --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/server/wasm_server.py @@ -0,0 +1,621 @@ +''' + /* Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ +''' +import select +import socket +import queue +from time import sleep +import struct +import threading +import time +from ctypes import * +import json +import logging +import os + +attr_type_list = [ + "ATTR_TYPE_BYTE", # = ATTR_TYPE_INT8 + "ATTR_TYPE_SHORT",# = ATTR_TYPE_INT16 + "ATTR_TYPE_INT", # = ATTR_TYPE_INT32 + "ATTR_TYPE_INT64", + "ATTR_TYPE_UINT8", + "ATTR_TYPE_UINT16", + "ATTR_TYPE_UINT32", + "ATTR_TYPE_UINT64", + "ATTR_TYPE_FLOAT", + "ATTR_TYPE_DOUBLE", + "ATTR_NONE", + "ATTR_NONE", + "ATTR_TYPE_BOOLEAN", + "ATTR_TYPE_STRING", + "ATTR_TYPE_BYTEARRAY" +] + + +Phase_Non_Start = 0 +Phase_Leading = 1 +Phase_Type = 2 +Phase_Size = 3 +Phase_Payload = 4 + + + +class imrt_link_message(object): + def __init__(self): + self.leading = bytes([0x12, 0x34]) + self.phase = Phase_Non_Start + self.size_in_phase = 0 + self.message_type = bytes() + self.message_size = bytes() + self.payload = bytes() + self.msg = bytes() + + def set_recv_phase(self, phase): + self.phase = phase + + def on_imrt_link_byte_arrive(self, ch): + self.msg += ch + if self.phase == Phase_Non_Start: + if ch == b'\x12': + self.set_recv_phase(Phase_Leading) + else: + return -1 + elif self.phase == Phase_Leading: + if ch == b'\x34': + self.set_recv_phase(Phase_Type) + else: + self.set_recv_phase(Phase_Non_Start) + return -1 + elif self.phase == Phase_Type: + self.message_type += ch + self.size_in_phase += 1 + + if self.size_in_phase == 2: + (self.message_type, ) = struct.unpack('!H', self.message_type) + self.size_in_phase = 0 + self.set_recv_phase(Phase_Size) + elif self.phase == Phase_Size: + self.message_size += ch + self.size_in_phase += 1 + + if self.size_in_phase == 4: + (self.message_size, ) = struct.unpack('!I', self.message_size) + self.size_in_phase = 0 + self.set_recv_phase(Phase_Payload) + + if self.message_size == b'\x00': + self.set_recv_phase(Phase_Non_Start) + return 0 + + self.set_recv_phase(Phase_Payload) + + elif self.phase == Phase_Payload: + self.payload += ch + self.size_in_phase += 1 + + if self.size_in_phase == self.message_size: + self.set_recv_phase(Phase_Non_Start) + return 0 + + return 2 + + return 1 + + + +def read_file_to_buffer(file_name): + file_object = open(file_name, 'rb') + buffer = None + + if not os.path.exists(file_name): + logging.error("file {} not found.".format(file_name)) + return "file not found" + + try: + buffer = file_object.read() + finally: + file_object.close() + + return buffer + +def decode_attr_container(msg): + + attr_dict = {} + + buf = msg[26 : ] + (total_len, tag_len) = struct.unpack('@IH', buf[0 : 6]) + tag_name = buf[6 : 6 + tag_len].decode() + buf = buf[6 + tag_len : ] + (attr_num, ) = struct.unpack('@H', buf[0 : 2]) + buf = buf[2 : ] + + logging.info("parsed attr:") + logging.info("total_len:{}, tag_len:{}, tag_name:{}, attr_num:{}" + .format(str(total_len), str(tag_len), str(tag_name), str(attr_num))) + + for i in range(attr_num): + (key_len, ) = struct.unpack('@H', buf[0 : 2]) + key_name = buf[2 : 2 + key_len - 1].decode() + buf = buf[2 + key_len : ] + (type_index, ) = struct.unpack('@c', buf[0 : 1]) + + attr_type = attr_type_list[int(type_index[0])] + buf = buf[1 : ] + + if attr_type == "ATTR_TYPE_BYTE": # = ATTR_TYPE_INT8 + (attr_value, ) = struct.unpack('@c', buf[0 : 1]) + buf = buf[1 : ] + # continue + elif attr_type == "ATTR_TYPE_SHORT": # = ATTR_TYPE_INT16 + (attr_value, ) = struct.unpack('@h', buf[0 : 2]) + buf = buf[2 : ] + # continue + elif attr_type == "ATTR_TYPE_INT": # = ATTR_TYPE_INT32 + (attr_value, ) = struct.unpack('@i', buf[0 : 4]) + buf = buf[4 : ] + # continue + elif attr_type == "ATTR_TYPE_INT64": + (attr_value, ) = struct.unpack('@q', buf[0 : 8]) + buf = buf[8 : ] + # continue + elif attr_type == "ATTR_TYPE_UINT8": + (attr_value, ) = struct.unpack('@B', buf[0 : 1]) + buf = buf[1 : ] + # continue + elif attr_type == "ATTR_TYPE_UINT16": + (attr_value, ) = struct.unpack('@H', buf[0 : 2]) + buf = buf[2 : ] + # continue + elif attr_type == "ATTR_TYPE_UINT32": + (attr_value, ) = struct.unpack('@I', buf[0 : 4]) + buf = buf[4 : ] + # continue + elif attr_type == "ATTR_TYPE_UINT64": + (attr_value, ) = struct.unpack('@Q', buf[0 : 8]) + buf = buf[8 : ] + # continue + elif attr_type == "ATTR_TYPE_FLOAT": + (attr_value, ) = struct.unpack('@f', buf[0 : 4]) + buf = buf[4 : ] + # continue + elif attr_type == "ATTR_TYPE_DOUBLE": + (attr_value, ) = struct.unpack('@d', buf[0 : 8]) + buf = buf[8 : ] + # continue + elif attr_type == "ATTR_TYPE_BOOLEAN": + (attr_value, ) = struct.unpack('@?', buf[0 : 1]) + buf = buf[1 : ] + # continue + elif attr_type == "ATTR_TYPE_STRING": + (str_len, ) = struct.unpack('@H', buf[0 : 2]) + attr_value = buf[2 : 2 + str_len - 1].decode() + buf = buf[2 + str_len : ] + # continue + elif attr_type == "ATTR_TYPE_BYTEARRAY": + (byte_len, ) = struct.unpack('@I', buf[0 : 4]) + attr_value = buf[4 : 4 + byte_len] + buf = buf[4 + byte_len : ] + # continue + + attr_dict[key_name] = attr_value + + logging.info(str(attr_dict)) + return attr_dict + +class Request(): + mid = 0 + url = "" + action = 0 + fmt = 0 + payload = "" + payload_len = 0 + sender = 0 + + def __init__(self, url, action, fmt, payload, payload_len): + self.url = url + self.action = action + self.fmt = fmt + # if type(payload) == bytes: + # self.payload = bytes(payload, encoding = "utf8") + # else: + self.payload_len = payload_len + if self.payload_len > 0: + self.payload = payload + + + def pack_request(self): + url_len = len(self.url) + 1 + buffer_len = url_len + self.payload_len + + req_buffer = struct.pack('!2BH2IHI',1, self.action, self.fmt, self.mid, self.sender, url_len, self.payload_len) + for i in range(url_len - 1): + req_buffer += struct.pack('!c', bytes(self.url[i], encoding = "utf8")) + req_buffer += bytes([0]) + for i in range(self.payload_len): + req_buffer += struct.pack('!B', self.payload[i]) + + return req_buffer, len(req_buffer) + + + def send(self, conn, is_install): + leading = struct.pack('!2B', 0x12, 0x34) + + if not is_install: + msg_type = struct.pack('!H', 0x0002) + else: + msg_type = struct.pack('!H', 0x0004) + buff, buff_len = self.pack_request() + lenth = struct.pack('!I', buff_len) + + try: + conn.send(leading) + conn.send(msg_type) + conn.send(lenth) + conn.send(buff) + except socket.error as e: + logging.error("device closed") + for dev in tcpserver.devices: + if dev.conn == conn: + tcpserver.devices.remove(dev) + return -1 + + +def query(conn): + req = Request("/applet", 1, 0, "", 0) + if req.send(conn, False) == -1: + return "fail" + time.sleep(0.05) + try: + receive_context = imrt_link_message() + start = time.time() + while True: + if receive_context.on_imrt_link_byte_arrive(conn.recv(1)) == 0: + break + elif time.time() - start >= 5.0: + return "fail" + query_resp = receive_context.msg + print(query_resp) + except OSError as e: + logging.error("OSError exception occur") + return "fail" + + res = decode_attr_container(query_resp) + + logging.info('Query device infomation success') + return res + +def install(conn, app_name, wasm_file): + wasm = read_file_to_buffer(wasm_file) + if wasm == "file not found": + return "failed to install: file not found" + + print("wasm file len:") + print(len(wasm)) + req = Request("/applet?name=" + app_name, 3, 98, wasm, len(wasm)) + if req.send(conn, True) == -1: + return "fail" + time.sleep(0.05) + try: + receive_context = imrt_link_message() + start = time.time() + while True: + if receive_context.on_imrt_link_byte_arrive(conn.recv(1)) == 0: + break + elif time.time() - start >= 5.0: + return "fail" + msg = receive_context.msg + except OSError as e: + logging.error("OSError exception occur") + # TODO: check return message + + if len(msg) == 24 and msg[8 + 1] == 65: + logging.info('Install application success') + return "success" + else: + res = decode_attr_container(msg) + logging.warning('Install application failed: %s' % (str(res))) + print(str(res)) + + return str(res) + + +def uninstall(conn, app_name): + req = Request("/applet?name=" + app_name, 4, 99, "", 0) + if req.send(conn, False) == -1: + return "fail" + time.sleep(0.05) + try: + receive_context = imrt_link_message() + start = time.time() + while True: + if receive_context.on_imrt_link_byte_arrive(conn.recv(1)) == 0: + break + elif time.time() - start >= 5.0: + return "fail" + msg = receive_context.msg + except OSError as e: + logging.error("OSError exception occur") + # TODO: check return message + + if len(msg) == 24 and msg[8 + 1] == 66: + logging.info('Uninstall application success') + return "success" + else: + res = decode_attr_container(msg) + logging.warning('Uninstall application failed: %s' % (str(res))) + print(str(res)) + + return str(res) + +class Device: + def __init__(self, conn, addr, port): + self.conn = conn + self.addr = addr + self.port = port + self.app_num = 0 + self.apps = [] + +cmd = [] + +class TCPServer: + def __init__(self, server, server_address, inputs, outputs, message_queues): + # Create a TCP/IP + self.server = server + self.server.setblocking(False) + + # Bind the socket to the port + self.server_address = server_address + print('starting up on %s port %s' % self.server_address) + self.server.bind(self.server_address) + + # Listen for incoming connections + self.server.listen(10) + + self.cmd_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.cmd_sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) + + self.cmd_sock.bind(('127.0.0.1', 8889)) + self.cmd_sock.listen(5) + + + # Sockets from which we expect to read + self.inputs = inputs + self.inputs.append(self.cmd_sock) + + # Sockets to which we expect to write + # 处理要发送的消息 + self.outputs = outputs + # Outgoing message queues (socket: Queue) + self.message_queues = message_queues + + self.devices = [] + self.conn_dict = {} + + def handler_recever(self, readable): + # Handle inputs + for s in readable: + if s is self.server: + # A "readable" socket is ready to accept a connection + connection, client_address = s.accept() + self.client_address = client_address + print('connection from', client_address) + # this is connection not server + # connection.setblocking(0) + self.inputs.append(connection) + + # Give the connection a queue for data we want to send + # self.message_queues[connection] = queue.Queue() + + res = query(connection) + + if res != "fail": + dev = Device(connection, client_address[0], client_address[1]) + self.devices.append(dev) + self.conn_dict[client_address] = connection + + dev_info = {} + dev_info['addr'] = dev.addr + dev_info['port'] = dev.port + dev_info['apps'] = 0 + + logging.info('A new client connected from ("%s":"%s")' % (dev.conn, dev.port)) + + elif s is self.cmd_sock: + connection, client_address = s.accept() + print("web server socket connected") + logging.info("Django server connected") + self.inputs.append(connection) + self.message_queues[connection] = queue.Queue() + + else: + data = s.recv(1024) + if data != b'': + # A readable client socket has data + logging.info('received "%s" from %s' % (data, s.getpeername())) + + # self.message_queues[s].put(data) + # # Add output channel for response + + # if s not in self.outputs: + # self.outputs.append(s) + + if(data.decode().split(':')[0] == "query"): + if data.decode().split(':')[1] == "all": + resp = [] + print('start query all devices') + for dev in self.devices: + dev_info = query(dev.conn) + if dev_info == "fail": + continue + dev_info["addr"] = dev.addr + dev_info["port"] = dev.port + resp.append(str(dev_info)) + + print(resp) + + if self.message_queues[s] is not None: + # '*' is used in web server to sperate the string + self.message_queues[s].put(bytes("*".join(resp), encoding = 'utf8')) + if s not in self.outputs: + self.outputs.append(s) + else: + client_addr = (data.decode().split(':')[1],int(data.decode().split(':')[2])) + + if client_addr in self.conn_dict.keys(): + print('start query device from (%s:%s)' % (client_addr[0], client_addr[1])) + resp = query(self.conn_dict[client_addr]) + print(resp) + + if self.message_queues[s] is not None: + self.message_queues[s].put(bytes(str(resp), encoding = 'utf8')) + if s not in self.outputs: + self.outputs.append(s) + else: # no connection + if self.message_queues[s] is not None: + self.message_queues[s].put(bytes(str("fail"), encoding = 'utf8')) + if s not in self.outputs: + self.outputs.append(s) + elif(data.decode().split(':')[0] == "install"): + client_addr = (data.decode().split(':')[1],int(data.decode().split(':')[2])) + app_name = data.decode().split(':')[3] + app_file = data.decode().split(':')[4] + + if client_addr in self.conn_dict.keys(): + print('start install application %s to ("%s":"%s")' % (app_name, client_addr[0], client_addr[1])) + res = install(self.conn_dict[client_addr], app_name, app_file) + if self.message_queues[s] is not None: + logging.info("response {} to cmd server".format(res)) + self.message_queues[s].put(bytes(res, encoding = 'utf8')) + if s not in self.outputs: + self.outputs.append(s) + elif(data.decode().split(':')[0] == "uninstall"): + client_addr = (data.decode().split(':')[1],int(data.decode().split(':')[2])) + app_name = data.decode().split(':')[3] + + if client_addr in self.conn_dict.keys(): + print("start uninstall") + res = uninstall(self.conn_dict[client_addr], app_name) + if self.message_queues[s] is not None: + logging.info("response {} to cmd server".format(res)) + self.message_queues[s].put(bytes(res, encoding = 'utf8')) + if s not in self.outputs: + self.outputs.append(s) + + + # if self.message_queues[s] is not None: + # self.message_queues[s].put(data) + # if s not in self.outputs: + # self.outputs.append(s) + else: + logging.warning(data) + + # Interpret empty result as closed connection + try: + for dev in self.devices: + if s == dev.conn: + self.devices.remove(dev) + # Stop listening for input on the connection + if s in self.outputs: + self.outputs.remove(s) + self.inputs.remove(s) + + # Remove message queue + if s in self.message_queues.keys(): + del self.message_queues[s] + s.close() + except OSError as e: + logging.error("OSError raised, unknown connection") + return "got it" + + def handler_send(self, writable): + # Handle outputs + for s in writable: + try: + message_queue = self.message_queues.get(s) + send_data = '' + if message_queue is not None: + send_data = message_queue.get_nowait() + except queue.Empty: + self.outputs.remove(s) + else: + # print "sending %s to %s " % (send_data, s.getpeername) + # print "send something" + if message_queue is not None: + s.send(send_data) + else: + print("client has closed") + # del message_queues[s] + # writable.remove(s) + # print "Client %s disconnected" % (client_address) + return "got it" + + def handler_exception(self, exceptional): + # # Handle "exceptional conditions" + for s in exceptional: + print('exception condition on', s.getpeername()) + # Stop listening for input on the connection + self.inputs.remove(s) + if s in self.outputs: + self.outputs.remove(s) + s.close() + + # Remove message queue + del self.message_queues[s] + return "got it" + + +def event_loop(tcpserver, inputs, outputs): + while inputs: + # Wait for at least one of the sockets to be ready for processing + print('waiting for the next event') + readable, writable, exceptional = select.select(inputs, outputs, inputs) + if readable is not None: + tcp_recever = tcpserver.handler_recever(readable) + if tcp_recever == 'got it': + print("server have received") + if writable is not None: + tcp_send = tcpserver.handler_send(writable) + if tcp_send == 'got it': + print("server have send") + if exceptional is not None: + tcp_exception = tcpserver.handler_exception(exceptional) + if tcp_exception == 'got it': + print("server have exception") + + + sleep(0.1) + +def run_wasm_server(): + server_address = ('localhost', 8888) + server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) + inputs = [server] + outputs = [] + message_queues = {} + tcpserver = TCPServer(server, server_address, inputs, outputs, message_queues) + + task = threading.Thread(target=event_loop,args=(tcpserver,inputs,outputs)) + task.start() + +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG, + filename='wasm_server.log', + filemode='a', + format= + '%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s' + ) + server_address = ('0.0.0.0', 8888) + server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) + inputs = [server] + outputs = [] + message_queues = {} + tcpserver = TCPServer(server, server_address, inputs, outputs, message_queues) + logging.info("TCP Server start at {}:{}".format(server_address[0], "8888")) + + task = threading.Thread(target=event_loop,args=(tcpserver,inputs,outputs)) + task.start() + + # event_loop(tcpserver, inputs, outputs) \ No newline at end of file diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/application.css b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/application.css new file mode 100644 index 00000000..220d4b61 --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/application.css @@ -0,0 +1,400 @@ +/* Copyright (C) 2019 Intel Corporation. All rights reserved. +* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +*/ + +{% load static %} + diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/application.js b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/application.js new file mode 100644 index 00000000..0510fb90 --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/application.js @@ -0,0 +1,217 @@ +/* Copyright (C) 2019 Intel Corporation. All rights reserved. +* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +*/ + +/* + * Dom Location + * + */ + + function setDivCenter(divname) +// make qn element center aligned + { + var Top =($(window).height()-$(divname).height())/2; + var Left = ($(window).width()-$(divname).width())/2; + var scrollTop = $(document).scrollTop(); + var scrollLeft = $(document).scrollLeft(); + $(divname).css({posisiton:'absolute','top':Top+scrollTop,'left':Left+scrollLeft}); + +}; + +setDivCenter(".middlebox"); +setDivCenter(".deletebox"); + +function setmain(divname){ +// Set the pop-up window of apps for download at the right place + var x = $('#btn').offset().top; + var Top = x + $('#btn').height()+15; + var y = $('#btn').offset().left; + var Left = y + ($('#btn').width()/2)-($(divname).width()/2); + console.log(Top,Left) + $(divname).css({'top':Top,'left':Left}); +} +setmain(".main") + +/* + * download apps + * + */ + +function getthis(val) +//Telling background which app to be loaded from appstore_list and to be installed in the current device. +{ + + /* Get the ip adress and the port of a device, as well as the application ID to be downloaded on this device*/ + var ip,port,name,version; + var ipArr=$("#IPs").text().split(":"); + ip=ipArr[1]; + var portArr=$("#ports").text().split(":"); + port=portArr[1]; + name = $(val).parent().find("#appsinfo1").text().split(":")[1]; + version = $(val).parent().find("#appsinfo2").text().split(":")[1]; + $(".main").fadeOut(); + + for (num in alist){ + if (alist[num]['pname'].trim() == name.trim()) + {alert("This app has been downloaded."); + return;}}; + $("#loading").fadeIn(); + var sNode = document.getElementById("APPS"); + var tempNode= sNode.cloneNode(true); + sNode.parentNode.appendChild(tempNode); + $("#appinfo1").html("Product Name : "+ name); + $("#appinfo2").html("Status : "+"Installing"); + $("#appinfo3").html("Current_Version : "+ version); + + $.get("/appDownload/",{'ip':ip.trim(),'port':port.trim(),'name':name.trim(),},function (ret) { + var status = $.trim(ret.split(":")[1].split("}")[0]); + $(".loadapp").html(name+" is downloading now"); + var msg = JSON.parse(status) + console.log(msg) + if (JSON.parse(status)=="ok"){ + $(".middlebox").fadeIn(); + $(".sourceapp").fadeOut(); + $("#loading").fadeOut(); + $(".findapp").html("Download "+name +" successfully"); + $(".surebtn").click(function (){ + $(".middlebox").fadeOut(); + window.location.reload(); + })} + else if (JSON.parse(status)=="Fail!"){ + alert("Download failed!"); + $("#loading").fadeOut(); + sNode.remove(); + } + else { + alert("Install app failed:" + msg) + $("#loading").fadeOut(); + sNode.remove(); + } + }) +}; + +window.onload = function clone() +//Add & Delete apps to the device. +{ + /*Install Apps*/ + var sourceNode = document.getElementById("APPS"); + if (alist.length != 0) + { + $("#appinfo1").html("Product Name : "+ alist[0]['pname']); + $("#appinfo2").html("Status : "+ alist[0]['status']); + $("#appinfo3").html("Current_Version : "+ alist[0]['current_version']); + $("#delete").attr('class','delet0'); + $("#APPS").attr('class','app0'); + + for (var i=1; i=3){ + alert("Install app failed: exceed max app installations.") + } + $(".main").fadeOut(); + getthis(".mybtn2"); + var newurl = "?"+"ip="+ip+"&port="+port; + window.location.href= newurl; + }); + + } +} +givevalue(); + +function popbox(){ +/*Open and close the "install apps" window*/ + $(".btn").click(function(){ + $(".main").fadeIn(); + }); + $(".close").click(function(){ + $(".main").fadeOut(); + }); +}; +popbox(); diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/appstore.js b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/appstore.js new file mode 100644 index 00000000..71d029ef --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/appstore.js @@ -0,0 +1,125 @@ +/* Copyright (C) 2019 Intel Corporation. All rights reserved. +* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +*/ + +function setDivCenter(divname) +//Center a dom +{ + var Top =($(window).height()-$(divname).height())/2; + var Left = ($(window).width()-$(divname).width())/2; + var scrollTop = $(document).scrollTop(); + var scrollLeft = $(document).scrollLeft(); + $(divname).css({posisiton:'absolute','top':Top+scrollTop,'left':Left+scrollLeft}); + +}; +setDivCenter(".deletebox"); + +function setDivheight(divname) +//set the height of "appbook" to contain all its child elements. +{ + var leng = elist.length + flist.length; + var heig = 51 * leng; + $(divname).css({height:'heig'}); +}; +setDivheight(".appbook"); + +function setfooterposition(divname) +//Locate footer on the right place +{ + var Top = flist.length* $("#devices").height()+300; + var scrollTop = $(document).scrollTop(); + if (flist.length >=4){ + $(divname).css({posisiton:'absolute','top':Top+scrollTop}); + } +} +setfooterposition(".footer"); + +function deleteClick (obj) +//Remove an app from apppstore if clicks the "OK" button +{ + var indexapp = $(obj).attr('class').match(/\d+\b/); + var removeitem = $(".applic"+indexapp); + var name=removeitem.find('#appinfo1').text().split(":")[1].trim(); + var version=removeitem.find('#appinfo2').text().split(":")[1].trim(); + + if (flist.length >= 1){ + $(".deletebox").fadeIn(); + $(".findapp").html("Are you sure to delete "+name); + $(".suresbtn").click(function (){ + removeitem.remove(); + $.get("/removeapps/",{'name':name,'version':version},function (ret) { + console.log(ret);}); + $(".deletebox").fadeOut(); + window.location.href="/appstore/"; + }) + $(".delsbtn").click(function (){ + $(".deletebox").fadeOut(); })} +}; + +function upload_file() +//Make sure the uploading file is eligible +{ + var type = ulist[0]; + console.log(type); + if (type == "Not a wasm file"){ + alert(type); + window.location.href="/appstore/"; + } + if (type == "This App is preloaded"){ + alert(type); + window.location.href="/appstore/"; + } + if (type == "This App is already uploaded"){ + alert(type); + window.location.href="/appstore/"; + } +}; +upload_file(); + + +function clone() +//Render a interface that shows all the apps for installing in appstore, +//including preloaded ones and locally uploaded ones. +{ + + var sourceNode = document.getElementById("applications"); + $("#appinfo1").html("product name : "+ elist[0]['ID']); + $("#appinfo2").html("product Version : "+ elist[0]['Version']); + $("#delbutton").attr('class','del0'); + $("#applications").attr('class','applic0'); + + + for (var i=1; i=4){ + $(divname).css({posisiton:'absolute','top':Top+scrollTop}); + } +} +setfooterposition(".footer"); + +window.onload = function clone() +//Show the list of connected devices +{ + var sourceNode = document.getElementById("devices"); + $("#IPs").html("IP : "+ dlist[0]['IP']); + $("#ports").html("Port : "+ dlist[0]['Port']); + $("#installs").html("Installed Apps : "+ dlist[0]['apps']); + $("#devices").attr('class','devic0'); + $("#dbutton").attr('class','bt0'); + $("#choose").attr('class','chos0'); + + for (var i=1; i