iRoar Application

An Add-On is a software application running on iRoar. The scripting language for iRoar applications is simple and typeless, with syntax similar to the "C" programming language. In addition, you can include an optional graphical user interface for the application by creating one or more HTML pages. These HTML pages can contain usage instructions, or javascript widgets to control the application remotely from the mobile device.

When deploying your Add-On, the application, HTML pages and resources will be packaged within a single iRoar application package (IPK). The iRoar Dashboard mobile application enables you to install the Add-On on the iRoar. During installation, the IPK will be transferred to the microSD card inserted into the iRoar device, while the HTML pages will be installed on the user's mobile device.

Application Lifecycle

The lifecycle of an iRoar application is managed by the system. Once the iRoar device is powered on, the iRoar applications will start execution in the background. Some APIs are ignored if the application is not in focus, or when the system is in low power mode. The applications continue to execute until the iRoar device is powered down, with the exception of the alarm APIs. When the application is uninstalled, it will no longer run on the iRoar device.

An iRoar application is event driven with these three main events:

1. app_start

When an iRoar application starts execution, the entry function @app_start will be called. Initialization required to run the application should be done here. When the @app_start function exits, the application will continue to run, and waits for trigger events such as a button tap.

The following code sample prints "Hello World",

@app_start(app_id)
{
printf(“Hello World”);
}

2. event_observer

After exiting from the @app_start function, the @event_observer function will be called whenever a trigger event occurs. In this function, you can handle desired events and implement your application's functionality.

The following code sample prints the button ID when button state changes,

@event_observer(event_id, param1, param2)
{
if(event_id == EVENT_BUTTON){
printf(“Button event %d on button id %d”, param1, param2);
}
}

3. app_exit

Before the application exits, the @app_exit function will be called. The application exits when the user powers down the iRoar, ejects the applications microSD card, uninstalls the application, or when the app_quit() function is called. You should release almost all resources that aren't needed by the user in this function.

The following code sample terminates the application when user taps on the increase volume button and prints "Bye" on exit,

@event_observer(event_id, param1, param2)
{
if((event_id == EVENT_BUTTON) && (param1 == EVENT_BUTTON_TAP) &&
(param2 == BUTTON_VOLUP)){
}
}
{
printf("Bye");
}