WEBSERVER
Embedded WebServer refers to the web server that is built into the AVIOR.
It allows you to verify the operating status, control onboard resources and make settings.
Embedded WebServer allows presentation of predefined or custom content through a browser.
WebServer starts when the SDcard is installed and a directory httpdocs
is detected.
Maximum number of connected clients and bandwidth are limited.
Do not expect performances similar to a mainframe!
Every device connected to an IP network must have a unique IP address.
This address is used to reference the specific unit.
Avior can connect to an existing WiFi network, but it can also set up a network of its own:
Station (STA) Mode
SSID address and password has been provided by user and Avior connects to an existing WiFi network.
The IP address is automatically assigned on DHCP-enabled networks.
Soft Access Point (AP) Mode
If an SSID is not defined, Avior creates its own WiFi network and acts as hotspot (like a WiFi router):
you can connect to AVIOR from any device having Wi-Fi capabilities without the need to connect to your router.
Avior does not have interface to a wired network.
The IP address is 192.168.1.1
To access the unit:
- Run the web browser.
- Enter the device IP address as the URL
index.html
page will be accessed and displayed.
This is the only page available until the user enters the device password to LOGIN.
Password is user configurable and is the same used to acces the device from local com port and remote control.
An automatic logout occurs ater 60 minutes of inactivity.
After 30 consecutive attempts with wrong password the access from any bearer is blocked and an OTP password is generated at any further login.
You must ask for the password to factory by sending the code returned by Avior.
WEB CONTENT
- httpdocs
is the root directory from which files are served by the webserver - index.html
is the default page served when a GET request is received at device address
S: ' SDcard ' │ └─ httpdocs ' root directory - webpages stored here ' │ ├── lib ' resources available before login ' │ ├── css // stylesheets │ ├── js // scripts │ └── webfonts // fonts and icons
AJAX
HTML pages use JavaScript and cascading style sheets to provide dynamic content.
Implementing AJAX technologies is possible to update part of a web page, without reloading the whole page.
Avior returns data encoded ISO-8859-1, thus it's important to preset the charset of all AJAX requests. Put the following code before to start any request.
$.ajaxSetup ({ 'beforeSend' : function(xhr) { xhr.overrideMimeType('text/html; charset=iso-8859-1'); } });
You can handle AJAX requests with a standard XMLHttpRequest or via JQuery.
To retrieve information from Avior you need to initiate a GET request.
Here below a simplified example to GET the log from the device.
Native JavaScript XMLHttpRequest
var xhr = new XMLHttpRequest(); xhr.open('GET', '/readlog'); // method & enpoint xhr.onload = function() { // handle xhr.status // process xhr.responseText } xhr.send();
JQuery
$.ajax({ type: "GET", url: "/readlog", // endpoint timeout: 2000, success: function(data) { // called when successful // process received data }, error: function(data, status) { // called when there is an error // handle error } });
To send commands to Avior you need to initiate a POST request.
Here below a simplified example to POST command to device.
Native JavaScript XMLHttpRequest
xhr = new XMLHttpRequest(); xhr.open('POST', '/cmd'); // method & enpoint xhr.onload = function() { // handle xhr.status // process xhr.responseText }; xhr.send('AT');
JQuery
$.ajax({ type: "POST", url: "/cmd", // endpoint data: "AT", timeout: 2000, success: function(data) { // called when successful // process received data }, error: function(data, status) { // called when there is an error // handle error } });Complete reference available here:
ENDPOINTS
WebServer provides specific endpoints to GET and POST data.Access to endpoints is granted after successfully login.
/cmd
POST command
Send command to device.
$.ajax({ url: '/cmd', // endpoint type: 'POST', // method timeout: 4000, data: command, // command to be sent success: function(data, status) { //called when successful }, error: function(request, status, message) { //called when there is an error } });
The data returned on successful request is the response to the command, the same returned when the command is sent through the console.
Some commands are not allowed from this endpoint.
/readuser
GET users list
Returns the list of all users stored within the unit.
$.ajax({ url: '/readuser', type: 'GET', timeout: 4000, success: function(data, status) { //called when successful }, error: function(request, status, message) { //called when there is an error } });
The data returned on successful request is the unordered list of all users stored into the device memory.
/readlog
GET log file
Returns the list of operations stored within the device log file.
$.ajax({ url: '/readlog', type: 'GET', timeout: 4000, success: function(data, status) { //called when successful }, error: function(request, status, message) { //called when there is an error } });
The data returned on successful request is the log stored into the device memory.
/readmap
GET device map
Returns configuration and status of each device resource stored into the map file.
$.ajax({ url: '/readmap', type: 'GET', timeout: 4000, success: function(data, status) { //called when successful }, error: function(request, status, message) { //called when there is an error } });
The data returned on successful request is complete device map represented as TAG VALUE
.
/readrule
POST rule list
Returns complete or partial rule list. POST the interval in the range 1…500
$.ajax({ url: '/readrule', type: 'POST', timeout: 4000, data: interval, success: function(data, status) { //called when successful }, error: function(request, status, message) { //called when there is an error } });
The data returned is the list of rules stored into the unit within the specified interval.
/list
GET file list
Returns a list of all files stored within the unit.
$.ajax({ url: '/list', type: 'GET', timeout: 4000, success: function(data, status) { //called when successful }, error: function(request, status, message) { //called when there is an error } });
The data returned on successfully request is a list of path and filename .
/read
GET file
Retrieves a file from the device specifying the full path.
$.ajax({ url: '/read/' + filename, type: 'GET', timeout: 4000, success: function(data, status) { //called when successful }, error: function(request, status, message) { //called when there is an error } });
The data returned on successfully request is the content of the file.
/upload
POST file
Store a file into the device filesystem specifying the full path.
$.ajax({ url: '/upload/' + filename, type: 'POST', data: file, // file content to be stored timeout: 4000, success: function(data, status) { //called when successful }, error: function(request, status, message) { //called when there is an error } });
There is no data in return, the operation is successfully completed when file has been stored.
/audio
POST audio file
Store an audio file into the device disk P.
$.ajax({ url: '/upload/' + size + '/' filename, type: 'POST', data: file, // audio file content to be stored timeout: 4000, success: function(data, status) { //called when successful }, error: function(request, status, message) { //called when there is an error } });
There is no data in return, the operation is successfully completed when file has been stored.
/delete
GET delete file
Delete a file within the device filesystem specifying the full path.
$.ajax({ url: '/delete/' + filename, type: 'GET', timeout: 4000, success: function(data, status) { //called when successful }, error: function(request, status, message) { //called when there is an error } });
There is no data in return, the operation is successfully completed when file has been deleted.
INFO
Additional information and literature available here: