Difference between revisions of "WPA FREE 0.5.1 Instalation"
(38 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
= Janus Server= | = Janus Server= | ||
== Update == | == Update == | ||
− | If the | + | If the Janus server is already running with the FREE 0.3.0 version it is only necessary to guarantee that the admin secret is defined. |
Edit the '''janus.plugin.streaming.jcfg ''' file in the '''/var/snap/janus-gateway/common/etc ''' directory and guarantee that the '''admin_key ''' is defined: | Edit the '''janus.plugin.streaming.jcfg ''' file in the '''/var/snap/janus-gateway/common/etc ''' directory and guarantee that the '''admin_key ''' is defined: | ||
Line 26: | Line 26: | ||
===Configuration=== | ===Configuration=== | ||
− | The configuration of | + | The configuration of Janus is done editing a file in the '''/var/snap/janus-gateway/common/etc''' directory |
Edit the '''janus.plugin.streaming.jcfg''' file | Edit the '''janus.plugin.streaming.jcfg''' file | ||
Line 40: | Line 40: | ||
sudo snap restart janus-gateway | sudo snap restart janus-gateway | ||
− | === Example of | + | === Example of Janus Configuration === |
After the configuration of a newly installed Janus Server the '''janus.plugin.streaming.jcfg''' should only containg the following` | After the configuration of a newly installed Janus Server the '''janus.plugin.streaming.jcfg''' should only containg the following` | ||
general : | general : | ||
{ | { | ||
− | admin_key = " | + | admin_key = "super_pass"; |
rtp_port_range = "6000-7000"; | rtp_port_range = "6000-7000"; | ||
}; | }; | ||
Line 54: | Line 54: | ||
− | == Installation of | + | == Installation of Source Code == |
Create a new folder for the new version of FREE. | Create a new folder for the new version of FREE. | ||
− | * For example '''mkdir | + | * For example '''mkdir wpa_free_051 ''' |
Download the Zip file containing the code | Download the Zip file containing the code | ||
− | wget https://github.com/e-lab-FREE/FREE_Web/releases/latest/download/ | + | wget https://github.com/e-lab-FREE/FREE_Web/releases/latest/download/FREE_Web_0_5_1.zip |
Unzip the downloaded file into the new directory. | Unzip the downloaded file into the new directory. | ||
− | * For example '''unzip | + | * For example '''unzip FREE_Web_0_5_1.zip -d wpa_free_051/ ''' |
− | Enter the directory | + | Enter the directory containing the code. |
− | * For example '''cd | + | * For example '''cd wpa_free_051/ ''' |
Create a new python virtual environment, it should be called '''free-env''': | Create a new python virtual environment, it should be called '''free-env''': | ||
Line 79: | Line 79: | ||
pip install -r REQUIREMENTS.txt | pip install -r REQUIREMENTS.txt | ||
− | == Installation of | + | == Installation of New Database == |
Since the data model was change it is necessary to download and install a new empty database. | Since the data model was change it is necessary to download and install a new empty database. | ||
Line 87: | Line 87: | ||
− | wget https://github.com/e-lab-FREE/FREE_Web/releases/latest/download/ | + | wget https://github.com/e-lab-FREE/FREE_Web/releases/latest/download/db_template_0_5_1.sqlite3 -O db.sqlite3 |
This database contains a Pendulum experiment, as well as two example user accounts. | This database contains a Pendulum experiment, as well as two example user accounts. | ||
Line 105: | Line 105: | ||
mv freeweb/.env-template freeweb/.env | mv freeweb/.env-template freeweb/.env | ||
− | It is necessary to define correct values for the following variables. Some of these | + | It is necessary to define correct values for the following variables. Some of these values can be copied form the previous version .env file. |
* PROJECT_NAME, PROJECT_ACRONYMUM, SITE_NAME - Texts that will appear in the page header | * PROJECT_NAME, PROJECT_ACRONYMUM, SITE_NAME - Texts that will appear in the page header | ||
− | * TIME_ZONE - Time zone setting for | + | * TIME_ZONE - Time zone setting for that app in '''TZ database name''' from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List. |
* FREE_PRODUCTION - set to '''on ''' to enable production mode (disables sensitive error messages etc.) | * FREE_PRODUCTION - set to '''on ''' to enable production mode (disables sensitive error messages etc.) | ||
* FREE_REVERSE_PROXY - set to '''on ''' to be able to run the FREE behind a reverse proxy | * FREE_REVERSE_PROXY - set to '''on ''' to be able to run the FREE behind a reverse proxy | ||
Line 119: | Line 119: | ||
By default, the webserver will be available at port 8000. To change the port, pass -p <portnumber> parameter to the daphne command. | By default, the webserver will be available at port 8000. To change the port, pass -p <portnumber> parameter to the daphne command. | ||
− | You can also force binding to specific | + | You can also force binding to specific address by -b <address>. |
+ | |||
+ | |||
+ | == Copy of Pendulum Information == | ||
+ | Since a new database is now being used, it is necessary to copy the various apparatus into the new database. | ||
+ | |||
+ | If running both version at the same time, one of them, should be executed on a different port | ||
+ | |||
+ | On the administration page of the you should copy some of the information from the old database to the new. | ||
+ | |||
+ | here is the list and description of the various fields: | ||
+ | * Apparatus Type : Pendulum | ||
+ | * Location - description of the physical place of the pendulum | ||
+ | * Description - specific characteristics of the pendulum | ||
+ | * Secret - a random string specific to each pendulum | ||
+ | * Owner - Name of the person responsible for the operation and maintenance of the pendulum | ||
+ | * Timeout - leave 60 | ||
+ | * Configuration - copy the following json and modify accordingly the '''id ''' and '''ports_restrict ''' to suitable values: | ||
+ | { | ||
+ | "id": "WP_LIS_IST", | ||
+ | "serial_port": { | ||
+ | "ports_restrict": ["/dev/ttyS0"], | ||
+ | "baud": "115200", "numbits": "8", "stopbits": "1", "partitybits": "0", | ||
+ | "listening_timeout": "100000", "death_timeout": "10000000" | ||
+ | } | ||
+ | } | ||
+ | * video configuration - either copy the value from the old database or leave empty | ||
+ | |||
+ | == Configuration of Video == | ||
+ | In order to have video stream from the Raspberry Pi to the server and then to the browser it is necessary to verify the following data on the '''.env ''' file: | ||
+ | * JANUS_SERVER_ADDRESS, JANUS_STREAM_KEY - Configuration of Janus video streaming server. | ||
+ | |||
+ | After this configuration is correct it is necessary to assign each pendulum one video stream so that video can go from the pendulum to the server and to the browser. | ||
+ | Open the '''Video Config ''' menu: | ||
− | + | [[File:Video-config-menu.png]] | |
+ | |||
+ | On the new page, a table will contain all the configured pendulums and the associated video configuration: | ||
+ | |||
+ | [[File:Video_Config_table.png]] | ||
+ | |||
+ | In the previous example the first apparatus was automatically configure from the previous identifier copied from the old database. | ||
+ | |||
+ | The second apparatus does not have the video stream configure. To create a video stream and update the database click '''Configure Video ''' | ||
+ | |||
+ | |||
+ | [[File:Video Config assign stream.png]] | ||
+ | |||
+ | On the new page it is necessary to click on the '''Assign Stream ''' button. | ||
+ | |||
+ | If the Janus server is well configure the new page will show the Video Stream Configuration and the data to be copied to the Raspberry Pi: | ||
+ | |||
+ | [[File:Video Config RP data.png]] | ||
= Raspberry Pi Proxy = | = Raspberry Pi Proxy = | ||
Line 128: | Line 178: | ||
Due to changes on the API and the database you will need to make a upgrade to this version of the Proxy. | Due to changes on the API and the database you will need to make a upgrade to this version of the Proxy. | ||
− | == Installation of | + | == Installation of Source Code == |
− | Create a new folder for the new version of Proxy ( | + | Create a new folder for the new version of Proxy (compatible to the Version of the FREE server). |
− | * For example '''mkdir | + | * For example '''mkdir Proxy_051 ''' |
Download the Zip file containing the code | Download the Zip file containing the code | ||
− | wget https://github.com/e-lab-FREE/RPi_Proxy/releases/latest/download/ | + | wget https://github.com/e-lab-FREE/RPi_Proxy/releases/latest/download/RPi_Proxy_0_5_1.zip |
Unzip the downloaded file into the new directory. | Unzip the downloaded file into the new directory. | ||
− | * For example '''unzip | + | * For example '''unzip RPi_Proxy_0_5_1.zip -d Proxy_051/ ''' |
− | Enter the directory | + | Enter the directory containing the code. |
− | * For example '''cd | + | * For example '''cd Proxy_051/ ''' |
After that, install the dependent package: | After that, install the dependent package: | ||
Line 151: | Line 201: | ||
pip3 install pyserial | pip3 install pyserial | ||
+ | |||
+ | And for streaming the video (for '''gstreamer '''): | ||
+ | |||
+ | sudo apt-get install gstreamer1.0-tools | ||
+ | |||
+ | sudo apt-get install gstreamer1.0-plugins-good | ||
+ | |||
+ | sudo apt-get install gstreamer1.0-plugins-bad | ||
+ | |||
+ | sudo apt-get install gstreamer1.0-plugins-ugly | ||
+ | |||
+ | sudo apt-get install gstreamer1.0-plugins-base | ||
+ | |||
+ | |||
+ | For '''ffmpeg ''': | ||
+ | sudo apt-get install ffmpeg | ||
== Configuration == | == Configuration == | ||
+ | |||
+ | === Video Streaming Configuration === | ||
+ | |||
+ | In order to configure the video streaming process on the Raspberry pi edit the '''video-stream.ini ''' file. | ||
+ | |||
+ | The following values should be correctly set: | ||
+ | * video_server video_port apparatus_location apparatus_name apparatus_id | ||
+ | ** copy this information from the Video Conf administration page on the FREE server | ||
+ | |||
+ | * usb_camera video_width video_height video_frame | ||
+ | ** find the suitable values depending on the network resources and the information provided by the following commands: | ||
+ | v4l2-ctl --list-devices | ||
+ | v4l2-ctl -d /dev/videoXXXXX --list-formats-ext | ||
+ | |||
+ | In order to debug and verify the video configuration it is possible to execute the '''video-stream.sh ''' command. | ||
+ | |||
+ | |||
+ | === Proxy Configuration === | ||
+ | |||
+ | |||
+ | In order to configure the Proxy on Raspberry pi edit the '''server_info.ini ''' file. | ||
+ | |||
+ | The following values should be correctly set: | ||
+ | |||
+ | *SERVER : The IP address or domain of your FREE_Web server; | ||
+ | *PORT : The port of the server by default is the 8000; | ||
+ | *DEBUG: This can be change to off, after this installation is correctly done; | ||
+ | *APPARATUS_ID, SECRET: This parameters can be seen on the admin of the FREE_Web server; | ||
+ | On the apparatus configure page, you will be able to see the APPARATUS_ID on the URL of the page (indicated with the arrow) and the SECRET on the page it self: | ||
+ | |||
+ | [[File:Info for Proxy.png|1220px]] | ||
== Proxy execution == | == Proxy execution == | ||
+ | In order to debug the various video and apparatus control configuration, the two scripts (video-stream.sh and main.py) can be executed independently on the command line. | ||
+ | |||
+ | After all the parameters are correct, both programs can be executed simultaneously using the following command: | ||
+ | |||
+ | nohup sh start-wp.sh > /dev/null 2>&1 & | ||
+ | |||
+ | This command runs until the raspberry pi is rebooted. | ||
+ | |||
+ | To make the Proxy run when the Raspberry pi reboots it is necessary to edit the '''/etc/rc.local ''' and add the following lines before the '''exit 0 ''': | ||
+ | sleep 60 | ||
+ | cd /INSTALLATION_FOLDER/PATH | ||
+ | su USER -c "sh start-wp.sh &" | ||
+ | |||
+ | |||
+ | Replace /INSTALLATION_FOLDER/PATH with the output of the following command: | ||
+ | readlink -f Proxy_051/ | ||
− | + | Replace USER the the actual user owner of the proxy. |
Latest revision as of 20:25, 21 May 2022
Janus Server
Update
If the Janus server is already running with the FREE 0.3.0 version it is only necessary to guarantee that the admin secret is defined.
Edit the janus.plugin.streaming.jcfg file in the /var/snap/janus-gateway/common/etc directory and guarantee that the admin_key is defined:
general : { admin_key = "elab1"; rtp_port_range = "6000-7000"; };
Installation
To install the Janus stream server you will need to run the following commands on your Debian 11 machine:
sudo apt install snap
sudo apt install snapd
sudo snap install janus-gateway
Configuration
The configuration of Janus is done editing a file in the /var/snap/janus-gateway/common/etc directory
Edit the janus.plugin.streaming.jcfg file
Define an administration secret by uncommenting the line 104) or the one that contains the admin_key string= and changing the string to a suitable value.
Define the possible ports that Janus will use to receive the video stream from the pendulum by uncomment line 106) or the one containing the string rtp_port_range= and define the available ports (for example to 6000-7000).
Delete the sample pre-configure endpoints by deleting all lines from line 124.
Restart Janus by running the command:
sudo snap restart janus-gateway
Example of Janus Configuration
After the configuration of a newly installed Janus Server the janus.plugin.streaming.jcfg should only containg the following`
general : { admin_key = "super_pass"; rtp_port_range = "6000-7000"; };
FREE Server
Due to changes on the database it is ot possible to reuse the FREE 0.3.50 database, as such it is necessary to install this new version on a new directory and after installation copy the pendulums information from one version to the other
Installation of Source Code
Create a new folder for the new version of FREE.
- For example mkdir wpa_free_051
Download the Zip file containing the code
wget https://github.com/e-lab-FREE/FREE_Web/releases/latest/download/FREE_Web_0_5_1.zip
Unzip the downloaded file into the new directory.
- For example unzip FREE_Web_0_5_1.zip -d wpa_free_051/
Enter the directory containing the code.
- For example cd wpa_free_051/
Create a new python virtual environment, it should be called free-env:
virtualenv -p python3 free-env
Activate the virtual environment:
source free-env/bin/activate
You should now see a prefix of (free-env) in your command line.
After that, install the dependent packages:
pip install -r REQUIREMENTS.txt
Installation of New Database
Since the data model was change it is necessary to download and install a new empty database.
This database is configured with two users and the WPA pendulum apparatus types and protocols.
Download the database and put it into the project root:
wget https://github.com/e-lab-FREE/FREE_Web/releases/latest/download/db_template_0_5_1.sqlite3 -O db.sqlite3
This database contains a Pendulum experiment, as well as two example user accounts.
- wp-admin - superuser account with access to admin interface
- wp-guest - guest account
Both users have a temporary123 password.
This password should be changed through admin interface.
Configuration
The application is configured using environment variables.
You can set them using the /freeweb/.env file.
There is a .env-template file in the ~freeweb folder, that can be renamed to .env :
mv freeweb/.env-template freeweb/.env
It is necessary to define correct values for the following variables. Some of these values can be copied form the previous version .env file.
- PROJECT_NAME, PROJECT_ACRONYMUM, SITE_NAME - Texts that will appear in the page header
- TIME_ZONE - Time zone setting for that app in TZ database name from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List.
- FREE_PRODUCTION - set to on to enable production mode (disables sensitive error messages etc.)
- FREE_REVERSE_PROXY - set to on to be able to run the FREE behind a reverse proxy
- FREE_SECRET - String used in hashing function. Set either to a random string of your choice, or generate one here: https://djecrety.ir
- FREE_ALLOWED_HOSTS - comma separated list of domain names/addresses; only requests to these hosts will be processed by the application. This is necessary to prevent HTTP Host header attacks.
- JANUS_SERVER_ADDRESS, JANUS_STREAM_KEY - Configuration of Janus video streaming server.
FREE server execution
to start the FREE server run the following command:
daphne freeweb.asgi:application
By default, the webserver will be available at port 8000. To change the port, pass -p <portnumber> parameter to the daphne command. You can also force binding to specific address by -b <address>.
Copy of Pendulum Information
Since a new database is now being used, it is necessary to copy the various apparatus into the new database.
If running both version at the same time, one of them, should be executed on a different port
On the administration page of the you should copy some of the information from the old database to the new.
here is the list and description of the various fields:
- Apparatus Type : Pendulum
- Location - description of the physical place of the pendulum
- Description - specific characteristics of the pendulum
- Secret - a random string specific to each pendulum
- Owner - Name of the person responsible for the operation and maintenance of the pendulum
- Timeout - leave 60
- Configuration - copy the following json and modify accordingly the id and ports_restrict to suitable values:
{ "id": "WP_LIS_IST", "serial_port": { "ports_restrict": ["/dev/ttyS0"], "baud": "115200", "numbits": "8", "stopbits": "1", "partitybits": "0", "listening_timeout": "100000", "death_timeout": "10000000" } }
- video configuration - either copy the value from the old database or leave empty
Configuration of Video
In order to have video stream from the Raspberry Pi to the server and then to the browser it is necessary to verify the following data on the .env file:
- JANUS_SERVER_ADDRESS, JANUS_STREAM_KEY - Configuration of Janus video streaming server.
After this configuration is correct it is necessary to assign each pendulum one video stream so that video can go from the pendulum to the server and to the browser.
Open the Video Config menu:
On the new page, a table will contain all the configured pendulums and the associated video configuration:
In the previous example the first apparatus was automatically configure from the previous identifier copied from the old database.
The second apparatus does not have the video stream configure. To create a video stream and update the database click Configure Video
On the new page it is necessary to click on the Assign Stream button.
If the Janus server is well configure the new page will show the Video Stream Configuration and the data to be copied to the Raspberry Pi:
Raspberry Pi Proxy
Due to changes on the API and the database you will need to make a upgrade to this version of the Proxy.
Installation of Source Code
Create a new folder for the new version of Proxy (compatible to the Version of the FREE server).
- For example mkdir Proxy_051
Download the Zip file containing the code
wget https://github.com/e-lab-FREE/RPi_Proxy/releases/latest/download/RPi_Proxy_0_5_1.zip
Unzip the downloaded file into the new directory.
- For example unzip RPi_Proxy_0_5_1.zip -d Proxy_051/
Enter the directory containing the code.
- For example cd Proxy_051/
After that, install the dependent package:
For the Proxy:
sudo apt install python3
sudo apt install python3-pip
pip3 install pyserial
And for streaming the video (for gstreamer ):
sudo apt-get install gstreamer1.0-tools
sudo apt-get install gstreamer1.0-plugins-good
sudo apt-get install gstreamer1.0-plugins-bad
sudo apt-get install gstreamer1.0-plugins-ugly
sudo apt-get install gstreamer1.0-plugins-base
For ffmpeg :
sudo apt-get install ffmpeg
Configuration
Video Streaming Configuration
In order to configure the video streaming process on the Raspberry pi edit the video-stream.ini file.
The following values should be correctly set:
- video_server video_port apparatus_location apparatus_name apparatus_id
- copy this information from the Video Conf administration page on the FREE server
- usb_camera video_width video_height video_frame
- find the suitable values depending on the network resources and the information provided by the following commands:
v4l2-ctl --list-devices v4l2-ctl -d /dev/videoXXXXX --list-formats-ext
In order to debug and verify the video configuration it is possible to execute the video-stream.sh command.
Proxy Configuration
In order to configure the Proxy on Raspberry pi edit the server_info.ini file.
The following values should be correctly set:
- SERVER : The IP address or domain of your FREE_Web server;
- PORT : The port of the server by default is the 8000;
- DEBUG: This can be change to off, after this installation is correctly done;
- APPARATUS_ID, SECRET: This parameters can be seen on the admin of the FREE_Web server;
On the apparatus configure page, you will be able to see the APPARATUS_ID on the URL of the page (indicated with the arrow) and the SECRET on the page it self:
Proxy execution
In order to debug the various video and apparatus control configuration, the two scripts (video-stream.sh and main.py) can be executed independently on the command line.
After all the parameters are correct, both programs can be executed simultaneously using the following command:
nohup sh start-wp.sh > /dev/null 2>&1 &
This command runs until the raspberry pi is rebooted.
To make the Proxy run when the Raspberry pi reboots it is necessary to edit the /etc/rc.local and add the following lines before the exit 0 :
sleep 60 cd /INSTALLATION_FOLDER/PATH su USER -c "sh start-wp.sh &"
Replace /INSTALLATION_FOLDER/PATH with the output of the following command:
readlink -f Proxy_051/
Replace USER the the actual user owner of the proxy.