Locking SmartCradle APIs

EMDK For Android 9.1

Overview

EMDK for Android 7.4 (and later) contains interfaces for controlling the EC30 Locking SmartCradle (model CRD-EC30-10SLC1-01), a 10-slot cradle used for securing, charging and individually dispensing Zebra EC30 ultra-compact enterprise companion devices. Interfaces provide programmatic, one-way communication from apps on EC30 devices to the SmartCradle for activating the cradle functions listed below.

Supported Cradle Functions

  • Unlock a device from its individual charging slot
  • Illuminate a slot's LED to shine solid or to "blink"
  • Set LED color to red, green or blue
  • Set a Timeout (in sec.) for expiration of an Action (i.e. Unlock)

Notes

  • Device slots lock automatically when a device is inserted
  • Communications are one-way; from device to cradle only
  • Apps operate with or without a user kiosk
  • APIs NOT supported on ShareCradles (see below)

Requirements

Use of SmartCradle intent APIs requires experience with Java, with Android app development and with usage of Android intents. A supported cradle also is required.

Supported Cradle(s):

  • EC30 10-slot Locking SmartCradle (model CRD-EC30-10SLC1-01)

Cradles NOT Supported:

  • EC30 2-slot Charge ShareCradle (model CRD-EC30-2SCHG1-01)
  • EC30 10-slot Charge ShareCradle (model CRD-EC30-10SC1-01)

Also See


SmartCradle Intent Action

The API currently implements a single intent with individual cradle Actions executed as intent extras. Supported Actions are listed below.

Cradle Intent

com.symbol.cradle.api.ACTION_DO

Cradle Actions

Actions are implemented as intent extras. See sample code for syntax.

Unlock Cradle Slot

Extra: "UNLOCK"
Type: Bundle
Parameters: LED, Timeout

  • "LED": Boolean
    • "true": Unlock cradle slot and light its LED solid green
    • "false": Unlock cradle lighting LED (default)
  • "TIMEOUT": Integer
    • Range: 5–20 (seconds)
    • Step value: 1
    • Default: 0

Blink (flash) LED

Extra: "BLINK"
Type: Bundle
Parameters: Color, Solid, Timeout

  • "COLOR": Integer
    • 0 -Off (default)
    • 1 - Green
    • 16 - Red
    • 17 - Blue
  • "SOLID": Boolean
    • "true": Solid LED
    • "false": Blink LED (default)
  • "TIMEOUT": Integer
    • Range: 0–120 (seconds)
    • Step value: 1
    • Default: 0

Note: The cradle LED blink rate is NOT programmable.

Return Values

Callback

Extra: "CALLBACK_RESPONSE"
Type: Pending intent
Function: Indicates status of "UNLOCK" and "BLINK" intents (NOT of the client ability to execute)
Result codes and messages:

  • "RESULT_CODE"
    • "SUCCESS"
    • "FAILURE"
  • "RESULT_MESSAGE"
    • "INVALID_PARAMETERS"
    • "DEVICE_NOT_READY"
    • "GENERAL_FAILURE"
    • "SENDING_COMMAND_FAILED"
    • "DEVICE_BUSY"

Sample Code

Unlock Cradle:

private void CradleUnlock() {
        Intent intent = new Intent();
        intent.setAction("com.symbol.cradle.api.ACTION_DO");
        Bundle unlockBundle = new Bundle();
        unlockBundle.putInt("TIMEOUT", 5);
        unlockBundle.putBoolean("LED", false);
        intent.putExtra("UNLOCK", unlockBundle);
        Intent responseIntent = new Intent(getApplicationContext(), MyBroadcastReceiver.class);
        responseIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        responseIntent.putExtra("COMMAND", "CRADLE_UNLOCK");
        PendingIntent piResponse = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, responseIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        intent.putExtra("CALLBACK_RESPONSE", piResponse);
        sendBroadcast(intent);
    }

Unlock Cradle with LED:

private void CradleUnlockWithLED() {
    Intent intent = new Intent();
    intent.setAction("com.symbol.cradle.api.ACTION_DO");
    Bundle unlockBundle = new Bundle();
    unlockBundle.putInt("TIMEOUT", 5);
    unlockBundle.putBoolean("LED", true);
    intent.putExtra("UNLOCK", unlockBundle);
    Intent responseIntent = new Intent(getApplicationContext(),  MyBroadcastReceiver.class);
    responseIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
    responseIntent.putExtra("COMMAND", "CRADLE_UNLOCK_WITH_LED");
    PendingIntent piResponse = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, responseIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    intent.putExtra("CALLBACK_RESPONSE", piResponse);
    sendBroadcast(intent);
}

Blink Cradle LED:

private void CradleLEDBlink() {
    Intent intent = new Intent();
    intent.setAction("com.symbol.cradle.api.ACTION_DO");
    Bundle blinkBundle = new Bundle();
    blinkBundle.putInt("TIMEOUT", 5);
    blinkBundle.putInt("COLOR", color); //1-Green,16-Red,17-Blue
    blinkBundle.putBoolean("SOLID", isSolid); // true OR false
    intent.putExtra("BLINK", blinkBundle);
    Intent responseIntent = new Intent(getApplicationContext(), MyBroadcastReceiver.class);
    responseIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
    responseIntent.putExtra("COMMAND", "CRADLE_BLINK_LED");
    PendingIntent piResponse = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, responseIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    intent.putExtra("CALLBACK_RESPONSE", piResponse);
    sendBroadcast(intent);
}

Broadcast Receiver:

/*The broadcast receiver below receives the responseIntent defined in the above functions. Once any of the above API calls have been processed, register this broadcast receiver by adding the code below in the <application> section of the manifest:

        <receiver
        android:name=".MainActivity$MyBroadcastReceiver">
        </receiver>
*/

public static class MyBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String status = "";
        String command = intent.getStringExtra("COMMAND");
        String resultCode = intent.getStringExtra("RESULT_CODE");
        String resultMessage = intent.getStringExtra("RESULT_MESSAGE");
        if (command != null) {
            status += "\n* " + command;
        }
        if (resultCode != null) {
            status += "\n* ResultCode= " + resultCode;
        }
        if (resultMessage != null) {
            status += "\n* Message= " + resultMessage + " \n";
        }
        Log.d(MyBroadcastReceiver.class.getSimpleName(), status);
    }
}

Also See