dobots / Dodedodo_Android

Other
1 stars 0 forks source link
legacy

Dodedodo Android

The dodedodo app starts, stops and connects AIM modules.

For users

First create a dodedodo account, then login on this app. You can then use the website to drag and drop modules on your phone and connect them. Each modules is a seperate app you will have to install, the dodedodo app will ask you to do this. The dodedodo app will keep on running in the background, you will see a notification while it is running. If things seem broken, try stopping all modules (also check running services) and then restart the dodedodo app.

For developers

To make your own module, there are several ways to go:

Deployment

A module needs a deployment file that describes the module to dodedodo. This module should be located at "module_dir/aim-core/aim_deployment.json". It should contain the following:

{
    "name":"MyModule",
    "type":"background",
    "version":"1",
    "category":"Image processing",
    "description":"short description",
    "long_description":"longer description goes here",
    "supported_middleware":[ "android" ],
    "supported_devices":[ "android" ],
    "enable":"true",
    "android": {
        "package":"org.dobots.mymodule",
        "url":"https://play.google.com/store/apps/details?id=org.dobots.mymodule"
    },
    "ports": [
        {
            "name":"bmp",
            "dir":"in",
            "type":"intarray",
            "middleware":"default"
        },
        {
            "name":"jpg",
            "dir":"out",
            "type":"string",
            "middleware":"default"
        }
    ]
}
Attribute Description
type Either "background" or "UI". If type is UI, it means the module requires a UI to work.
version A positive integer number, increase it each time you update your module.
supported_middleware Since you're making an android app, only android is supported.
supported_devices Since you're making an android app, only android is supported.
enable Either "true" or "false". If set to true, this module will be added to the dodedodo website.
ports A list of input and output ports of your module.
port name Should be lower case
port dir Either "in" or "out"
port type Can be "string", "int", "intarray", "float" or "floatarray"
port middleware Should be "default"

Here are some examples: PictureSelectModule BmpToJpgModule

Starting

A module will be started by dodedodo by calling an intent with action "ACTION_RUN" in category "CATEGORY_DEFAULT". This means your AndroidManifest.xml should contain:

</intent-filter>
    <action android:name="android.intent.action.RUN" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

in the service or activity that should be started.

When a user clicks on your module in the module list, dodedodo will call an intent with action "ACTION_MAIN" in category "CATEGORY_DEFAULT". This means your AndroidManifest.xml should contain:

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

in the activity of the module.

On create / On StartCommand

A module that's started as activity will get the module id on create, while background module will get it onStartCommand. You can get it by reading intent.getIntExtra("id")

Binding

When the module is started, it should bind to the dodedodo service like so:


Intent intent = new Intent();
intent.setClassName("org.dobots.dodedodo", "org.dobots.dodedodo.MsgService");
bindService(intent, mMsgServiceConnection, Context.BIND_AUTO_CREATE);

where mMsgServiceConnection is an instance of ServiceConnection.

Modules communicate with the dodedodo app via android messengers. Your module should have a messenger to which dodedodo can send commands and a seperate messenger for each input port.

These messengers are registered when connected to dodedodo as done in the function onServiceConnected in AimConnectionHelper.

Stopping

Dodedodo will send a MSG_STOP when the module should stop. On destroy, the module should unregister with a MSG_UNREGISTER and unbind from dodedodo. See function unbindFromMsgService in AimConnectionHelper.

Heartbeat

Each second the module should send a MSG_PONG to dodedodo, to indicate the module is still working. See HeartBeatTimerTask in AimConnectionHelper.

Connecting ports

Dodedodo will send a MSG_SET_MESSENGER to a module when connecting an output port. The message contains a messenger to which the output port can send its messages and the name of the output port. See IncomingMsgHandler in AimConnectionHelper.

Data

Each messenger of an input port has a message handler to read incoming data. A data message should be of type MSG_PORT_DATA and contain a bundle which contains the datatype (DATATYPE_...) and the data. See AimUtils.

Copyrights

The copyrights (2013) belong to:

Analytics