2 Replies Latest reply on Nov 14, 2018 5:35 AM by Peter Kastner

    MC330M EMDK API calls for LED and vibration

    Peter Kastner

      Hi,

       

      I am currently developing mobile apps for the Zebra MC3300 (P/N 1PMC330M-SN3HA2RW) and wondering how to control the LED and vibrator programmatically from my applicaton. Please point me in the right direction. So far, I've found the API Documentation to be unhelpful.

       

      I was very eager to test the NotificationSample, however I am not interested in sending notifications for LED or vibrator to a remote device via bluetooth. That's not what this is about - I would like to control the Zebra MC3300's built-in LEDs and make the device vibrate programmatically inside my code. Device has been shipped with Android 7.1.2 Nougat (Android API Level 25). I've integrated the Zebra EMDK for Android inside AndroidStudio using the plugin, testet some of the android code samples successfully and would be willing to go the extra mile writing a wrapper class or creating another build version of the app if what I want to do is possible - which I sure hope so.

       

      To put it in a nutshell - how can I control the Zebra MC33's built-in LED (color, on/off time) and vibrator (frequency, time....) from my application code?

       

      Thanks for the help!

       

      Best regards,

       

      Peter

        • Re: MC330M EMDK API calls for LED and vibration
          Brian Moore

          Peter,

           

          The vibration function can be controlled with the Android Vibrator Api: Vibrator  |  Android Developers

          The LED can be controlled with the Android Noticication Api: Notification  |  Android Developers

           

          Thanks,

          Brian Moore

          Software Engineer Kutir Mobility

          Posted on behalf of Zebra Technologies

            • Re: MC330M EMDK API calls for LED and vibration
              Peter Kastner

              Thanks for the reply, Brian, appreciate it.

              The vibration function can be controlled with the Android Vibrator Api: Vibrator  |  Android Developers

              I had already tried using the Android Vibrator class prior to posting on here. However, the device did not vibrate (silent mode was set to OFF).

              Hence I was thinking the Zebra EMDK might provide a solution, as standard Android did not yield the expected result.

               

              Here is the code I was using:

              void vibrate(){

                 // Get instance of Vibrator from current Context
                 Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
                 // vibrate for 500 ms
                 v.vibrate(500); // deprecated on API level >=26, MC33 is on 25
              }

               

              I'm calling this method from a simple MainActivity upon the onClick-Event of a button.

              On a Samsung Galaxy smartphone this is working as expected, the device vibrates upon button click, however the MC33 does not.

               

              Could you please confirm this behaviour?

               

              Now, the android dev reference you linked in your post mentions the method hasVibrator()

              https://developer.android.com/reference/android/os/Vibrator#hasVibrator()

               

              So I went ahead an implemented this in my test application in vibrate():

                   // Output yes if can vibrate, no otherwise
                   if (v.hasVibrator()) {

                     Log.d("Can Vibrate", "YES");
                   } else {

                     Log.e("Can Vibrate", "NO");
                   }

               

              ..and came to find that hasVibrator() returns true for the Samsung galaxy, and false for the MC33, the corresponding logcat output is:

                   2018-11-14 15:04:54.149 877-877/com.siemens.feedbackuser E/Can Vibrate: NO

               

              This leads me to strongly believe that the MC33 does not have a vibration motor at all. So, was I mistaken in believing that the MC33 can vibrate? If so could you please confirm this?

              I'll leave the device serial number etc. here:

              S/NP/NREVMFD
              S181275230211921PMC330M-SN3HA2RW2PAD08MAY18

               

               

               

              The LED can be controlled with the Android Noticication Api: Notification  |  Android Developers

              First of all, I would like to clarify that using notification does not fit my actual use case. Basically, it's not what I would like to do.
              What I would like to achieve is the following (let me describe this with a simple example):
              In my application the user has to scan a matrix code into an edittext field, which I am validating using regex. Now suppose the users has scanned the wrong matrix code I'd like to make the two built-in front LEDs on either side of the MC33 device flash red e.g. three times,

              in order to visually notify the user of this error. As you can see, this is different from sending a notification to the status bar.

               

              As the device itself triggers a green flash of the front LEDs upon successfully decoding a matrix code via DataWedge, I was assuming control of the front LEDs would be possible using the Zebra EMDK.

               

              I just gave the notification class a shot anyways, created a simple method to show a notification and I set the LED color to red.

                  

              void sendNotification() {

                 final Notification.Builder builder =

                      new Notification.Builder(this)

                          .setSmallIcon(android.R.drawable.ic_dialog_info)

                          .setContentTitle("A title")

                          .setContentText("text of example notificaton")

                          .setSound(RingtoneManager.getActualDefaultRingtoneUri(this,RingtoneManager.TYPE_NOTIFICATION))

                          .setLights(Color.RED, 2000, 500);

               

                   final int notificationId = 4711;

                   final NotificationManager notifMngr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

                   final Notification notification = builder.build();

                   notifMngr.notify(notificationId, notification);
              }

              The notification works as expected with regard to being displayed in the status bar, however the MC33's front LEDs do not blink at all.

              Instead of using .setLights(...) I also tried setting the parameters directly after building the notification with .build() :

                   notification.ledARGB = Color.RED; // red color light flash
                   notification.ledOnMS = 2000; // LED is on for 2 second
                   notification.ledOffMS = 500; // LED is off for 0.5 second
                   notification.flags = Notification.FLAG_SHOW_LIGHTS;

              ...but to no avail.


              Is there another way to programmatically control the LED, using the EMDK for example, or is it not possible? As the front LED is showing an orange light when charging the device, green when the battery is fully charged, there must be way, right? If the EMDK does not expose this functionality could you please confirm this as well?

               

              To sum up, two questions basically:

              1. Does my Zebra MC33 support vibration? And if it does not, could you please confirm this, as I would like to inform our management about it with an official response.
              2. Can the LED be controlled using the EMDK or does it not expose this functionality?

               

              Best regards,

               

              Peter

               

                

               

              edit 1: formatting