WPA FREE 0.5.1 Instalation

From wwwelab
Jump to navigation Jump to search

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 = "elab1";
  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_050

Download the Zip file containing the code

wget https://github.com/e-lab-FREE/FREE_Web/releases/latest/download/FREE_Web_0_5_0.zip

Unzip the downloaded file into the new directory.

  • For example unzip FREE_Web_0_5_0.zip -d wpa_free_050/

Enter the directory conantaining the code.

  • For example cd wpa_free_050/

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_0.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 vaues can be copied frm 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 tha 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 addres by -b <address>.


Copy of pendulum infomation

Since a new database is now being used, it is necessary to copy the various apparatus into the new database.

On the administration page of the you should copy some of the infomation from the old database to the new.

here is the list and description of the various fields:

  • Apparatus Type : Pendulum
  • Localizaçâo / Location `description of the physical place of the pendulum
  • Descrição / Description - specific characteristics of the pendulum
  • Secret - a random string specific to each pendulum
  • Owner ~responible - Name of the person responsible for the operation and maintenace of the pendulum
  • Timout - leave 60
  • Configuration - copy the following json and modify acordingly the id and ports_restrict to suitable values:
{
   "id": "WP_LIS_IST", 
   "serial_port": {
      "ports_restrict": ["/dev/ttyAMA0"], 
      "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 brosers 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 thta video can go from the pendulum to the server and to the browser.

Open the Video Config menu:

Video-config-menu.png

On the new page, a table will contain all the configured pendulums and the associated video configuration:

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


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:

Video Config RP data.png

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 (compateble to the Version of the FREE server).

  • For example mkdir Proxy_050

Download the Zip file containing the code

wget https://github.com/e-lab-FREE/RPi_Proxy/releases/latest/download/RPi_Proxy_0_5_0.zip 

Unzip the downloaded file into the new directory.

  • For example unzip RPi_Proxy_0_5_0.zip -d Proxy_050/

Enter the directory conantaining the code.

  • For example cd Proxy_050/

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:

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

Configuration

Video Streaming Configuration

In order to configure the video streaming process on the Raspberry pi edit the video-stream.ini file.

The following valiues 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 valiues should be correctly set:

  • SERVER : The IP address or doman 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 parameteres can be seen on the admin of the FREE_Web server:

Info for Proxy.png

Proxy execution

To run the code you can use the following cmd:

nohup sh start-wp.sh > /dev/null 2>&1 &

And to make the Proxy run when the Raspberry pi reboot you will need to edit the rc.local, doing nano /etc/rc.local and add the following lines before the exit 0 :

sleep 60
cd $full_path_to_folder$
su $user$ -c "sh start-wp.sh &"


To see the full path to the folder of the proxy you can you the following cmd:

readlink -f Proxy_050/