AOS Device SDK
Loading...
Searching...
No Matches
AOS Device App SDK Sample Application

Quick Start Guide

1. Install the SDK.

Download the SDK installer and run it. It will prompt you for an install location.

aos SDK installer version v7.1.2
==========================================
Enter target directory for SDK (default: /opt/tools/aos-sdk-7.1.2):

Here's a complete example of installing the SDK under /opt/tools:

$ ./aos-sdk-toolchain-v7.1.2.sh
AOS SDK installer version v7.1.2
=====================================
Enter target directory for SDK (default: /opt/tools/aos-sdk-7.1.2): <Enter>
You are about to install the SDK to "/opt/tools/aos-sdk-7.1.2". Proceed [Y/n]? <Enter>
Extracting SDK..........................................................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
$ . /opt/tools/aos-sdk-7.1.2/environment-setup-aarch64-oe-linux

2. Clone the sample app from github.

git clone https://github.com/aetheros/aos-metering-app.git
cd aos-metering-app

3. Build the sample app using the SDK toolchain.

SDK versions 6.9.2 and above provide a aossdkshell script which will create a development shell, in which the shell environment is set up for using the SDK toolchain. It will change the shell prompt to make it clear to the user that the SDK environment is sourced, meaning it is configured for cross compilation, and SDK tools are in the default PATH. You can exit out of the development shell with the exit command.

$ /opt/tools/aos-sdk-7.1.2/aossdkshell
{aossdk} $

Alternatively, source the environment file as indicated at SDK installation. It will set the environment in the current shell for using the SDK tools and cross compilation.

. /opt/tools/aos-sdk-7.1.2/environment-setup-aarch64-oe-linux

Run make to build the app.

Once the app is built, several SDK tools can be used for app testing and packaging:

  • aosapp - Install, Uninstall, Activate, and Deactivate the app on a connected development device.
  • aospkg - Create an unsigned AOS package.
  • aoscsr - Perform a Certificate Signing Request to create a key/certificate pair for code signing.
  • aossignpkg - Create a signed AOS package using the certificate/key pair generated by aoscsr.

4. Install the app on a device and activate it.

Connect a device to your host via USB or Wi-Fi. Make sure you have the adb command installed. On Ubuntu, it is in the android-tools-adb package.

Refer to ADB over Wi-Fi if connecting to the device over Wi-Fi.

Confirm you can open an ADB shell on the device.

Use the aosapp command to install and activate the app. Run aosapp install to install the app on the connected device. Use the -s <serialno> option if there are multiple devices connected. If the application installs successfully, it can then be activated with aosapp activate.

Run aosapp -h to see the list of options.

Common commands

Starting and stopping the app

Use aosapp to control whether the app is activated on the device, meaning it will run automatically.

  • aosapp activate - Enable the app so it is always running.
  • aosapp deactivate - Disable the app so it does not run.

To simply stop, start, or restart an app, use prctl from a device shell.

  • prctl stop <appname> - Stop the app
  • prctl start <appname> - Start the app
  • prctl restart <appname> - Restart the app
  • prctl status <appname> - Check the status of the app
/ $ prctl stop aos_metering_app
aos_metering_app stopping [ok]
/ $
/ $ prctl start aos_metering_app
aos_metering_app running [ok] (last killed by signal: 9)
/ $
/ $ prctl restart aos_metering_app
aos_metering_app want-running [ok] (last killed by signal: 9)
/ $
/ $ prctl status aos_metering_app
aos_metering_app running [ok] (last killed by signal: 9)

When stopping the app, if it does not exit in response to a SIGTERM sent by the supervisor process, it will be terminated after a few seconds with SIGKILL (9). prctl reports this fact in the status as "(last killed by signal: 9)".

Updating the app

Until further notice, the app can only be updated by first uninstalling it, and then installing the new version.

aosapp uninstall
aosapp install
aosapp activate

Accessing a device shell wth ADB

Use the adb command to access a device, either over USB or Wi-Fi. Running adb shell will drop you into a shell as the apps user. Common linux commands can be run from this shell.

If multiple devices are attached, use the -s option to select a device by its serial number. adb devices will list all the connected devices.

If you specify a command and arguments after adb shell, adb will run that command in a shell.

Example:

$ adb shell cat /etc/issue
aos esr3-kv2 7.2.0 7.2.0-R-20250603:213704-g658fff9
$

ADB over Wi-Fi

When USB is not available and the development host is connected to a device's Wi-Fi AP, a connection must first be made between the host's adb service the the device's adb service.

Create a connection to the device's adb service:

adb connect 192.168.225.1:5555

If successful, the adb devices command will show the attached device:

$ adb devices
...
192.168.225.1:5555 device

When finished using adb over wifi, break the connection between host and device:

adb disconnect 192.168.225.1:5555

Reading the log

From a device shell, use the logread or journalctl command to read the system log. Use grep for filtering.

Example:

$ adb shell logread |grep aos_metering |tail -n 10
May 13 19:56:31 aos daemon.notice aos_metering_app-sv: containerizing /data/polnet/apps/aos_metering_app/aos_metering_app
May 13 19:56:31 aos daemon.notice aos_metering_app-sv: chdir("/home/apps")
May 13 19:56:31 aos daemon.notice aos_metering_app-sv: forking /data/polnet/apps/aos_metering_app/aos_metering_app
May 14 02:56:32 aos user.warn aos_metering_ap: [1] m2m.AppEntity.Impl_.initialize (163) - app_config.json does not exist
May 14 02:56:32 aos user.info aos_metering_ap: [1] main (83) - activating
May 14 02:56:32 aos user.info aos_metering_ap: [1] m2m.AppEntity.Impl_.startRegistration (369) - AE registration request
May 14 02:56:32 aos user.info aos_metering_ap: [3] m2m.AppEntity.Impl_.handleRegisterAEResponse (451) - AE Registration complete. AE-ID = Cmetersvc-smpl
May 14 02:56:32 aos user.info aos_metering_ap: [1] main (98) - activated
May 14 02:56:32 aos user.info aos_metering_ap: [1] create_subscription (149) - subscription: CREATED
May 14 02:56:32 aos user.info aos_metering_ap: [1] create_meter_read_policy (184) - policy creation: CREATED
$

Accessing the application environment.

Running aosapp shell will open a shell in an environment identically to the one the application runs in.

Example:

aosapp -s 87e76c0 shell
/home/apps # ls -l
ls -l
-rwxr-xr-x 1 aos root 193456 May 14 03:15 aos_metering_app
-rw-r----- 1 root root 165 May 14 03:16 app_config.json
-rw-r--r-- 1 aos root 146 May 14 03:15 env
-rw-r--r-- 1 aos root 291 May 14 03:15 manifest.json
-rw-r----- 1 root root 343 May 14 03:24 meter_data.txt
-rw-r--r-- 1 aos root 138 May 14 03:15 service.conf
/home/apps #