Plugin to Plugin

Your ATAK plugin can send and receive data over Somewear via the Somewear ATAK Plugin.

Messages

Outbound

A third party plugin can send a workspace message through the Somewear plugin by broadcasting an intent.

Intent intent = new Intent("com.somewearlabs.tak.message.SEND");
intent.putExtra("content", "Test outbound message");
intent.putExtra("parcelId", 123);

AtakBroadcast.getInstance().sendBroadcast(intent);

Outbound Status

Outbound data and message payloads transmissions will be retried until success or a timeout occurs. You can observe terminal status changes with intents.

HelloDropdownReceiver
public static final String SOMEWEAR_MESSAGE_OUTBOUND = "com.somewearlabs.tak.message.OUTBOUND";

override fun onReceive(context: Context, intent: Intent) {
    switch (action) {
        case HelloWorldDropDownReceiver.SOMEWEAR_MESSAGE_OUTBOUND: {
            String status = intent.getStringExtra("status");
            int parcelId = intent.getIntExtra("parcelId", 0);
            
            if (status.equals("Delivered")) {
                Log.d(TAG, "onReceive: did send Somewear message; parcelId=" + parcelId);
            } else if (status.equals("Error") {
        	Log.d(TAG, "onReceive: Somewear message did timeout; parcelId=" + parcelId);
            }
            
            break;
        }
    }
}

Inbound

A third party plugin can listen for inbound workspace messages as well.

During development, this must first be enabled in the Somewear plugin debug menu. To show the debug menu go to Settings > Long press on Send Logs. Then toggle Broadcast inbound messages.

Once the debug option is enabled, you can listen for inbound messages by registering a BroadcastReceiver. Your plugin’s DropDownReceiver implements BroadcastReceiver already. Here’s a modified version of the helloworld sample:

HelloWorldMapComponent
public static final String SOMEWEAR_MESSAGE_INBOUND = "com.somewearlabs.tak.message.INBOUND";

override fun onCreate(pluginContext: Context, intent: Intent, mapView: MapView) {
    DocumentedIntentFilter ddFilter = new DocumentedIntentFilter();
    ddFilter.addAction(HelloWorldDropDownReceiver.SHOW_HELLO_WORLD, "Show the Hello World drop-down");
    ddFilter.addAction(HelloWorldDropDownReceiver.SOMEWEAR_MESSAGE_INBOUND, "Observe inbound Somewear payloads");
    this.registerDropDownReceiver(this.dropDown, ddFilter);
}
HelloWorldDropdownReceiver
override fun onReceive(context: Context, intent: Intent) {
    switch (action) {
        case HelloWorldDropDownReceiver.SOMEWEAR_MESSAGE_INBOUND: {
            String content = intent.getStringExtra("content");
            long timestampMillis = intent.getLongExtra("timestamp", 0L);
            Date timestamp = new Date(timestampMillis);
    				String status = intent.getStringExtra("status");
    				int parcelId = intent.getIntExtra("parcelId", 0);
            Log.d(TAG, "onReceive: did receive Somewear message; content=" + content + "; timestamp=" + timestamp + "; status=" + status);
            break;
        }
        
        case SHOW_HELLO_WORLD:
            if (!isClosed()) {

Data

You can send/receive generic data payloads as well.

Outbound

byte[] data = "Just some bytes".getBytes(StandardCharsets.UTF_8);

Intent intent = new Intent("com.somewearlabs.tak.data.SEND");
intent.putExtra("data", data);

AtakBroadcast.getInstance().sendBroadcast(intent);

Inbound

Unlike inbound message payloads, you don’t have to change any settings in the Somewear plugin to listen for data payloads.

HelloWorldMapComponent
public static final String SOMEWEAR_DATA_INBOUND = "com.somewearlabs.tak.data.INBOUND";

override fun onCreate(pluginContext: Context, intent: Intent, mapView: MapView) {
    DocumentedIntentFilter ddFilter = new DocumentedIntentFilter();
    ddFilter.addAction(HelloWorldDropDownReceiver.SHOW_HELLO_WORLD, "Show the Hello World drop-down");
    // Observe inbound message payloads
    ddFilter.addAction(HelloWorldDropDownReceiver.SOMEWEAR_MESSAGE_INBOUND, "Observe inbound Somewear payloads");
    // Observe inbound data payloads
    ddFilter.addAction(HelloWorldDropDownReceiver.SOMEWEAR_DATA_INBOUND, "Observe inbound Somewear data payloads");
    this.registerDropDownReceiver(this.dropDown, ddFilter);
}

Last updated