Skip to content

Commit

Permalink
Update README instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
pataxis committed Aug 5, 2022
1 parent af8728b commit cc822ee
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 91 deletions.
26 changes: 18 additions & 8 deletions axevent/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
*Copyright (C) 2020, Axis Communications AB, Lund, Sweden. All Rights Reserved.*
*Copyright (C) 2022, Axis Communications AB, Lund, Sweden. All Rights Reserved.*

# ACAP applications interacting with event system on an edge device

# ACAP3 applications interacting with event system on an edge device
This README file explains how to use the axevent library, which provides an interface to the event system found in Axis device.

The purpose is to provide applications a mechanism to send and receive events.

* **Producer** - Application sends events.
* **Consumer** - Application subscribe events.

Expand All @@ -13,9 +15,10 @@ The first example will create an application that subscribes to events, which ar
The second example will create an application that declares and sends an ONVIF event that the application in the third example is subscribed to.

A wrapper "get_eventlist.py" is also available for testing the applications. The wrapper supports different ONVIF APIs.
APIs specification is available on https://www.onvif.org/specs/core/ONVIF-Core-Specification.pdf
APIs specification is available on <https://www.onvif.org/specs/core/ONVIF-Core-Specification.pdf>

## Getting started

Below is the structure and scripts of the files and folders on the top level:

```bash
Expand All @@ -29,11 +32,12 @@ axevent

* **get_eventlist.py** - Wrapper to find declared and sent events, using ONVIF APIs.
* **README.md** - Step by step instructions on how to use the examples.
* **send_event** - Folder containing files for building ACAP3 application "send_event".
* **subscribe_to_event** - Folder containing files for building ACAP3 application "subscribe_to_event".
* **subscribe_to_events** - Folder containing files for building ACAP3 application "subscribe_to_events".
* **send_event** - Folder containing files for building ACAP application "send_event".
* **subscribe_to_event** - Folder containing files for building ACAP application "subscribe_to_event".
* **subscribe_to_events** - Folder containing files for building ACAP application "subscribe_to_events".

### Example applications

Each example has as a README file in its directory which shows overview, example directory structure and step-by-step instructions on how to run applications on the device.
Below is the list of examples available in the repository.

Expand All @@ -45,32 +49,37 @@ Below is the list of examples available in the repository.
* The example code is written in C which subscribes to different predefined events.

### Find events using wrapper

> [!IMPORTANT]
> *The wrapper needs an ONVIF user with password in case wrapper is being used. Browse to the following page (replace <axis_device_ip> with the IP number of your Axis video device)*
>
> ```bash
> http://<axis_device_ip>/#settings/system/security/onvif
> ```
> *Goto your device web page above > Click on Add **(+)** sign below the **ONVIF users** in the device GUI > Add >**Username**, **New password** and **Repeat password** > Click **Save** button*
*Goto your device web page above > Click on Add **(+)** sign below the **ONVIF users** in the device GUI > Add >**Username**, **New password** and **Repeat password** > Click **Save** button*
#### Find declared events using wrapper
The wrapper "get_eventlist.py" helps you save the declared eventlist to an XML-file called "onviflist.xml.new".
```bash
./get_eventlist.py getlist -h
```
#### Find sent events using wrapper

The wrapper also helps you save the sent eventlist to an XML-file called "sentonviflist.xml.new".

```bash
./get_eventlist.py getsent -h
```

### Find events using GStreamer

> [!IMPORTANT]
> *Install GStreamer on your machine by following the instructions here:
https://gstreamer.freedesktop.org/documentation/installing/on-linux.html?gi-language=c*
<https://gstreamer.freedesktop.org/documentation/installing/on-linux.html?gi-language=c>*
It is also possible to use GStreamer tools for monitoring events, as a complement to the wrapper
(replace <user>, <password> and <axis_device_ip> with the username, password and IP number of your Axis video device).
Expand All @@ -80,4 +89,5 @@ gst-launch-1.0 rtspsrc location="rtsp://<user>:<password>@<axis_device_ip>/axis-
```

## License

**[Apache License 2.0](../LICENSE)**
45 changes: 29 additions & 16 deletions axevent/send_event/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
*Copyright (C) 2020, Axis Communications AB, Lund, Sweden. All Rights Reserved.*

# ACAP3 application sending an ONVIF event on an edge device
This README file explains how to build an ACAP3 application that uses axevent library for sending a stateful ONVIF event.
# ACAP application sending an ONVIF event on an edge device

This README file explains how to build an ACAP application that uses axevent library for sending a stateful ONVIF event.

An ONVIF event is using the namespace "tns1" as the namespace.
Different namespaces is used for a custom defined stateful event. Axis is using namespace "tnsaxis" for Axis defined events.

This example shows an ProcessorUsage ONVIF event with topic namespace "tns1:Monitoring/ProcessorUsage",
according to chapter "8.8.1 Processor Usage" in
https://www.onvif.org/specs/core/ONVIF-Core-Specification.pdf
<https://www.onvif.org/specs/core/ONVIF-Core-Specification.pdf>

The ONVIF event is being sent with an updated processor usage value every 10th second.

Building the application is achieved by using the containerized Axis API and toolchain images.
Building the application is achieved by using the containerized API and toolchain images.

Together with this README file you should be able to find a directory called app.
That directory contains the "send_event" application source code, which can easily
be compiled and run with the help of the tools and step by step below.

## Getting started

These instructions will guide you on how to execute the code. Below is the structure and scripts used in the example:

```bash
Expand All @@ -32,24 +34,27 @@ send_event
```

* **app/LICENSE** - Text file which lists all open source licensed source code distributed with the application.
* **app/Makefile** - Makefile containing the build and link instructions for building the ACAP3 application "send_event".
* **app/Makefile** - Makefile containing the build and link instructions for building the ACAP application "send_event".
* **app/send_event.c** - Application which sends events, written in C.
* **Dockerfile** - Docker file with the specified Axis toolchain and API container to build the example "send_event".
* **README.md** - Step by step instructions on how to run the example.

### Limitations

* The example is done for the armv7hf architecture, but it is possible to update to aarch64 architecture.

### How to run the code

Below is the step by step instructions on how to execute the program. So basically starting with the generation of the .eap files to running it on a device:

#### Build the application

Standing in your working directory run the following commands:

> [!IMPORTANT]
> *Depending on the network you are connected to.
The file that needs those settings is: *~/.docker/config.json.*
For reference please see: https://docs.docker.com/network/proxy/ and a
The file that needs those settings is:* ~/.docker/config.json. *For
reference please see: <https://docs.docker.com/network/proxy/> and a
[script for Axis device here](../FAQs.md#HowcanIset-upnetworkproxysettingsontheAxisdevice?).*

```bash
Expand All @@ -61,6 +66,7 @@ docker build --tag <APP_IMAGE> .
Default architecture is **armv7hf**. To build for **aarch64** it's possible to
update the *ARCH* variable in the Dockerfile or to set it in the docker build
command via build argument:

```bash
docker build --build-arg ARCH=aarch64 --tag <APP_IMAGE> .
```
Expand Down Expand Up @@ -101,6 +107,7 @@ send_event
* **build/send_event_1_0_0_LICENSE.txt** - Copy of LICENSE file.

#### Install your application

Installing your application on an Axis video device is as simple as:

Browse to the following page (replace <axis_device_ip> with the IP number of your Axis video device)
Expand All @@ -115,9 +122,10 @@ the newly built **send_event_1_0_0_armv7hf.eap** > Click **Install** > Run the a
Application is now available as an application on the device and has been started to send events.

#### The expected output

Application log can be found directly at:

```
```sh
http://<axis_device_ip>/axis-cgi/admin/systemlog.cgi?appname=send_event
```

Expand All @@ -127,13 +135,13 @@ in the terminal.
*> Please make sure SSH is enabled on the device to run the
following commands.*

```
```sh
ssh root@<axis_device_ip>
cd /var/log/
head -200 info.log
```

```
```sh
----- Contents of SYSTEM_LOG for 'send_event' -----

16:23:56.628 [ INFO ] send_event[0]: starting send_event
Expand All @@ -146,11 +154,13 @@ head -200 info.log
A stateful event will be sent every 10th second, changing its value.

### Find events using wrapper

See general information about wrapper "get_eventlist.py" in [README](../README.md).

Replace <onvifuser>, <onvifpassword> and <axis_device_ip> with the ONVIF user, ONVIF password and IP number of your Axis video device.

#### Find declared events using wrapper

The wrapper helps you save the declared eventlist to an XML-file.

```bash
Expand All @@ -164,11 +174,11 @@ In this case ONVIF API is used and an ONVIF username and password needs to be ad
```

This output could be compared to the ONVIF event specification chapter "8.8.1 Processor Usage" in
https://www.onvif.org/specs/core/ONVIF-Core-Specification.pdf
<https://www.onvif.org/specs/core/ONVIF-Core-Specification.pdf>

XML file "onviflist.xml.new" contains:

```
```xml
<tns1:Monitoring>
<ProcessorUsage wstop:topic="true">
<tt:MessageDescription IsProperty="true">
Expand All @@ -184,9 +194,10 @@ XML file "onviflist.xml.new" contains:
```

#### Find sent events using wrapper

The wrapper helps you save the sent eventlist to an XML-file.

```bash
```sh
../get_eventlist.py getsent -h
```

Expand All @@ -198,7 +209,7 @@ In this case ONVIF APIs are used, which means that an ONVIF username and passwor

XML file "sentonviflist.xml.new" contains:

```
```xml
<wsnt:NotificationMessage>
<wsnt:Topic Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Simple">tns1:Monitoring/ProcessorUsage</wsnt:Topic>
<wsnt:ProducerReference>
Expand All @@ -219,18 +230,19 @@ XML file "sentonviflist.xml.new" contains:
```

### Find events using GStreamer

See general information about GStreamer tools in [README](../README.md).

If using GStreamer tools for monitoring events
(replace <user>, <password> and <axis_device_ip> with the username, password and IP number of your Axis video device).

```bash
```sh
gst-launch-1.0 rtspsrc location="rtsp://<user>:<password>@<axis_device_ip>/axis-media/media.amp?video=0&audio=0&event=on" ! fdsink
```

Output in XML, which has been formatted manually to show topic "tns1:Monitoring/ProcessorUsage":

```
```xml
<?xml version="1.0" encoding="UTF-8"?>
<tt:MetadataStream xmlns:tt="http://www.onvif.org/ver10/schema">
<tt:Event>
Expand All @@ -256,4 +268,5 @@ Output in XML, which has been formatted manually to show topic "tns1:Monitoring/
```

## License

**[Apache License 2.0](../../LICENSE)**
34 changes: 22 additions & 12 deletions axevent/subscribe_to_event/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
*Copyright (C) 2020, Axis Communications AB, Lund, Sweden. All Rights Reserved.*
*Copyright (C) 2022, Axis Communications AB, Lund, Sweden. All Rights Reserved.*

# ACAP3 application subscribing to an ONVIF event on an edge device
This README file explains how to build an ACAP3 application that uses axevent library for subscribing to an ONVIF event.
# ACAP application subscribing to an ONVIF event on an edge device

It is achieved by using the containerized Axis API and toolchain images.
This README file explains how to build an ACAP application that uses axevent library for subscribing to an ONVIF event.

It is achieved by using the containerized API and toolchain images.

Together with this README file you should be able to find a directory called app.
That directory contains the "subscribe_to_event" application source code, which can easily
be compiled and run with the help of the tools and step by step below.

## Getting started

These instructions will guide you on how to execute the code. Below is the structure and scripts used in the example:

```bash
Expand All @@ -23,24 +25,27 @@ subscribe_to_event
```

* **app/LICENSE** - Text file which lists all open source licensed source code distributed with the application.
* **app/Makefile** - Makefile containing the build and link instructions for building the ACAP3 application "subscribe_to_event".
* **app/Makefile** - Makefile containing the build and link instructions for building the ACAP application "subscribe_to_event".
* **app/subscribe_to_event.c** - Application which subscribes for event, written in C.
* **Dockerfile** - Docker file with the specified Axis toolchain and API container to build the example "subscribe_to_event".
* **README.md** - Step by step instructions on how to run the example.

### Limitations

* The example is done for the armv7hf architecture, but it is possible to update to aarch64 architecture.

### How to run the code

Below is the step by step instructions on how to execute the program. So basically starting with the generation of the .eap files to running it on a device:

#### Build the application

Standing in your working directory run the following commands:

> [!IMPORTANT]
> *Depending on the network you are connected to.
The file that needs those settings is: *~/.docker/config.json.*
For reference please see: https://docs.docker.com/network/proxy/ and a
The file that needs those settings is:* ~/.docker/config.json. *For
reference please see: <https://docs.docker.com/network/proxy/> and a
[script for Axis device here](../FAQs.md#HowcanIset-upnetworkproxysettingsontheAxisdevice?).*

```bash
Expand All @@ -52,6 +57,7 @@ docker build --tag <APP_IMAGE> .
Default architecture is **armv7hf**. To build for **aarch64** it's possible to
update the *ARCH* variable in the Dockerfile or to set it in the docker build
command via build argument:

```bash
docker build --build-arg ARCH=aarch64 --tag <APP_IMAGE> .
```
Expand Down Expand Up @@ -92,11 +98,12 @@ subscribe_to_event
* **build/subscribe_to_event_1_0_0_LICENSE.txt** - Copy of LICENSE file.

#### Install your application

Installing your application on an Axis video device is as simple as:

Browse to the following page (replace <axis_device_ip> with the IP number of your Axis video device)

```bash
```sh
http://<axis_device_ip>/#settings/apps
```

Expand All @@ -114,15 +121,16 @@ the newly built **send_event_1_0_0_armv7hf.eap** > Click **Install** > Run the a
Application is now available as an application on the device and has been started to send events.

#### The expected output

Application logs can be found directly at:

```
```sh
http://<axis_device_ip>/axis-cgi/admin/systemlog.cgi?appname=send_event
```

or

```
```sh
http://<axis_device_ip>/axis-cgi/admin/systemlog.cgi?appname=subscribe_to_event
```

Expand All @@ -132,15 +140,16 @@ in the terminal.
*> Please make sure SSH is enabled on the device to run the
following commands.*

```
```sh
ssh root@<axis_device_ip>

cd /var/log/
head -200 info.log
```

##### Output

```
```sh
16:23:51.242 [ INFO ] subscribe_to_event[0]: starting subscribe_to_event
16:23:51.280 [ INFO ] subscribe_to_event[20408]: Started logging from subscribe event application
16:23:51.281 [ INFO ] subscribe_to_event[20408]: And here's the token: 1234
Expand All @@ -160,4 +169,5 @@ the initial state of the property. This is the reason why there is one log stati
log stating "Send stateful event with value: 0.000000".

## License

**[Apache License 2.0](../../LICENSE)**
Loading

0 comments on commit cc822ee

Please sign in to comment.