/ Build Apps

Port Legacy C App

This topic describes how to get a POSIX/Linux legacy app written in C running on a Legato device and using Legato APIs to access services like SMS, SIM, voice calling, and data connections.

Note

The examples in this topic use the command-line tools. You will need to have your shell configured correctly, either by installing your dev environment with Leaf (the environment will already be configured) or running bin/legs in the directory where your framework is installed.

$ path/to/LegatoFramework/bin/legs

The examples also use a Sierra Wireless WP85xx target. If your using a different target, substitute your target name wherever you see WP85.

The examples use IP address 192.168.2.2. Change it if your target IP uses a different address.

Cross-Build

The most basic way to get your legacy app running on a Legato target device is to recompile it using the provided cross-build tool chain and copy it onto the device using a tool like scp.

8. Create a extern:requires: section for the le_info interface in the .adef file:

extern:

{

requires:

{

le_info = $LEGATO_ROOT/interfaces/modemServices/le_info.api

}

}

9. Specify which instance of the le_info service your app should use by creating a binding in the .adef file:

bindings:

{

\*.le_info -> modemService.le_info

}

Note

Actually, there's only one instance of le_info today, but if there were multiple, this would specify which one to use; and even when there's only one instance, we create a binding anyway to explicitly grant access permission so access is never unknowingly granted.

9. Re-generate your app or system bundle, install it, and run it on target:

Sandboxing Your App

To tell the Supervisor to run your app inside a sandbox, remove the following line from your app's .adef file:

sandboxed: false

Or, you can change false to true:

sandboxed: true

Then re-bundle your app using mkapp.

The most commonly-used system libraries, such as libc and libpthread, will be visible inside your app's sandbox by default, but you may now find that your app won't run because some other files are missing from its sandbox.