Copyright (C) 2024, Axis Communications AB, Lund, Sweden. All Rights Reserved.
This example shows how an ACAP application can call VAPIX APIs, Axis open APIs.
The collection of VAPIX APIs enables a wide selection of functionality to an ACAP application. Some examples:
- Call basic device information API to get a device's serial number and system-on-chip (SoC).
- Call list installed applications API to get installed ACAP applications.
- Retrieve VAPIX credentials through a D-Bus API.
- Use curl to make a HTTP POST request to VAPIX API Basic device
information on dedicated local host IP
127.0.0.12
. - Parse out fields from the answer
- The credentials should be re-fetched each time the ACAP application starts and should only be kept in memory by the ACAP application, not stored in any file.
- See more information of this feature in ACAP documentation.
- The feature to call VAPIX APIs was introduced in AXIS OS 11.6 as Beta.
- The format of the D-Bus API to get VAPIX credentials changed in 11.8.
- The D-Bus API to get VAPIX credentials reached General Availability in 11.9.
- Some VAPIX APIs may work with GET, but it's recommended to use POST for all API calls since it should cover all use cases of GET.
- The response format varies for different VAPIX APIs, but common response formats are JSON, XML and text. See the VAPIX documentation of the specific API for information of format.
These instructions will guide you on how to execute the code. Below is the structure and scripts used in the example:
vapix
├── app
│ ├── vapix_example.c
│ ├── LICENSE
│ ├── Makefile
│ └── manifest.json
├── Dockerfile
└── README.md
- app/vapix_example.c - Application source code in C.
- 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 ACAP application.
- app/manifest.json - Defines the application and its configuration. This includes additional parameters.
- Dockerfile - Docker file with the specified Axis toolchain and API container to build the example specified.
- README.md - Step by step instructions on how to run the example.
Below is the step by step instructions on how to execute the program. So basically starting with the generation of the .eap file to running it on a device.
Standing in your working directory run the following commands:
Note
Depending on the network you are connected to, you may need to add proxy settings.
The file that needs these settings is: ~/.docker/config.json
. For reference please see
https://docs.docker.com/network/proxy and a
script for Axis devices in the ACAP documentation.
docker build --tag <APP_IMAGE> --build-arg ARCH=<ARCH> .
<APP_IMAGE>
is the name to tag the image with, e.g.,vapix_example:1.0
<ARCH>
is the SDK architecture,armv7hf
oraarch64
.
Copy the result from the container image to a local directory build
:
docker cp $(docker create <APP_IMAGE>):/opt/app ./build
The build
directory contains the build artifacts, where the ACAP application
is found with suffix .eap
, depending on which SDK architecture that was
chosen, one of these files should be found:
vapix_example_1_0_0_aarch64.eap
vapix_example_1_0_0_armv7hf.eap
Browse to the application page of the Axis device:
http://<AXIS_DEVICE_IP>/index.html#apps
- Click on the tab
App
in the device GUI - Click
(+)
sign to upload the application file - Browse to the newly built ACAP application, depending on architecture:
vapix_example_1_0_0_aarch64.eap
vapix_example_1_0_0_armv7hf.eap
- Click
Install
- Run the application by enabling the
Start
switch
The application log can be found by either
- Browse to
http://<AXIS_DEVICE_IP>/axis-cgi/admin/systemlog.cgi?appname=vapix_example
. - Browse to the application page and click the
App log
.
The log shows a few parsed values from the VAPIX API response.
----- Contents of SYSTEM_LOG for 'vapix_example' -----
[ INFO ] vapix_example[9731]: Curl version 8.6.0
[ INFO ] vapix_example[9731]: Jansson version 2.14
[ INFO ] vapix_example[9731]: ProdShortName: AXIS Q3536-LVE
[ INFO ] vapix_example[9731]: Soc: Axis Artpec-8
[ INFO ] vapix_example[9731]: SocSerialNumber: ABCD1234-0101ABAB
Note
The curl and Jansson versions mentioned in the example log are only for representation purpose. They may vary according to the library version available and linked from AXIS OS on which the application runs.