BlueFletch / motorola-datawedge-cordova-plugin

This is a Cordova/Phonegap plugin to interact with Motorola ruggedized Android devices' Barcode Scanners and Magnetic Stripe Readers (eg, ET1, TC55, MC40). The plugin works by interacting with the "DataWedge" application configured to output scan and magstripe read events.
35 stars 38 forks source link

onReceive isn't triggert #3

Closed schnti closed 10 years ago

schnti commented 10 years ago

I receive no response intent from the datawedge scanner. The Scanner is starting, scanning, stopping and logging the result and the sending of the broadcast to my defined "de.schnti.todo.SCAN" action. I defined this URL here:

datawedge.start("de.schnti.todo.SCAN");

here

<intent-filter>
     <action android:name="de.schnti.todo.SCAN"/>
    <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

and in the DataWedge App.

However, I get no result. The

    private BroadcastReceiver dataReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
             Log.i(TAG, "Data receiver trigged");

issn`t triggert

blakebyrnes commented 10 years ago

If you're using this outside of a Cordova app, you'll need to make sure you're setting a scan callback (setScanCallback) or a magstripe reader (setMagstripeReadCallback). In the DataWedge app, you'll need to make sure that you are associating with your app unless you change the default profile (https://launchpad.motorolasolutions.com/documents/dw_user_guide.html#_applications)

schnti commented 10 years ago

Hei, I using it inside the cordova app...

<script>
    document.addEventListener("deviceready", function() {

        if (window.datawedge) {

            // datawedge.start();
            // datawedge.switchProfile("ACTION");   
            // datawedge.start("com.bluefletch.motorola.datawedge.ACTION");
            datawedge.start("de.schnti.todo.SCAN");
            console.error("START");
            // console.error("datawedge.start");

            datawedge.registerForBarcode(function(data) {
                console.error("CALLBACK");
                // var labelType = data.type, barcode = data.barcode;

                alert("CALLBACK");

                console.error("Barcode scanned.  Label type is: " + labelType + ", " + barcode);
                $("#output").html("Barcode scanned.  Label type is: " + labelType + ", " + barcode);

            });
        }

    });

    $(document).ready(function() {

        $("#startScanner").click(function() {
            datawedge.startScanner();
            console.error("startScanner");
        });

        $("#stopScanner").click(function() {
            datawedge.stopScanner();
            console.error("stopScanner");
        });
    });

</script>
blakebyrnes commented 10 years ago

Oh, ok. Your javascript looks correct. Were you able to update the DataWedge profile to point at your app? Are you also setting the intent to broadcast?

schnti commented 10 years ago

This is the logcat output

D/IntentPlugin(  934): Received scan data Bundle[{com.motorolasolutions.emdk.datawedge.label_type=LABEL-TYPE-EAN13, com.motorolasolutions.emdk.datawedge.data_string=4002343001009, com.motorolasolutions.emdk.datawedge.decode_data=[[B@426ac3c0], com.motorolasolutions.emdk.datawedge.source=scanner}] de.schnti.todo.SCAN Cat: android.intent.category.DEFAULT 2
D/IntentPlugin(  934): broadcasting intent Intent { act=de.schnti.todo.SCAN cat=[android.intent.category.DEFAULT] (has extras) }
D/ALSADevice(  173): setHardwareParams: buffer_size 16384, period_size 2048, period_

complete log....

I/MotorolaDatawedgePlugin( 1764): Action: scanner.softScanOn
D/ScanningService(  934): Intent received Intent { act=com.motorolasolutions.emdk.datawedge.api.ACTION_SOFTSCANTRIGGER flg=0x10 (has extras) }
D/ScanningService(  934): Param received START_SCANNING
D/ScanningService(  934): Soft trigger - start scanning
D/ScannerPlugin(  934): Soft triggering - calling startScanner
W/PluginManager( 1764): THREAD WARNING: exec() call to MotorolaDataWedge.scanner.softScanOn blocked the main thread for 17ms. Plugin should use CordovaInterface.getThreadPool().
D/CordovaLog( 1764): file:///android_asset/www/index.html: Line 46 : startScanner
E/Web Console( 1764): startScanner at file:///android_asset/www/index.html:46
I/SSIProtocol(  934): Sending Wakeup
D/ScannerPlugin(  934): Scan status changed from SCAN_STATUS_ENABLED to SCAN_STATUS_SCANNING
E/NotificationService(  637): Ignoring notification with icon==0: Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x1 kind=[null])
D/BatteryService(  637): Before: mAcOnline=false, mUsbOnline=true
D/BatteryService(  637): ac=0, usb=1
D/BatteryService(  637): After: mAcOnline=false, mUsbOnline=true
D/MediaPlayer(  934): start() mUri is system/media/audio/notifications/decode-short.wav
E/NotificationService(  637): Ignoring notification with icon==0: Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x1 kind=[null])
V/AudioHardwareALSA(  173): AudioHardwareALSA::getParameters() A2dpSuspended=
V/AudioPolicyManagerALSA(  173): startOutput() output 2, stream 3, session 4
D/MediaPlayer(  934): seekTo() mUri is system/media/audio/notifications/decode-short.wav
D/ScannerPlugin(  934): Scan status changed from SCAN_STATUS_SCANNING to SCAN_STATUS_ENABLED
D/ScannerPlugin(  934): Decode time 1403062443571ms. Data: [4002343001009]
V/AudioStreamOutALSA(  173): mDevices =0x2
D/ALSADevice(  173): route: devices 0x2 in mode 0
D/ALSADevice(  173): No valid input device: 0
D/alsa_ucm(  173): snd_use_case_set(): uc_mgr 0x4106c2d8 identifier _enadev value Speaker
D/ALSADevice(  173): switchDevice: mCurTxUCMDevivce None mCurRxDevDevice Speaker
D/alsa_ucm(  173): snd_use_case_set(): uc_mgr 0x4106c2d8 identifier _verb value HiFi
D/alsa_ucm(  173): Set mixer controls for Speaker enable 1
D/alsa_ucm(  173): acdb_id 15 cap 1 enable 1
D/ACDB-LOADER(  173): ACDB -> send_audio_cal, acdb_id = 15, path =  0
D/ACDB-LOADER(  173): ACDB -> send_adm_topology
D/ACDB-LOADER(  173): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
D/ACDB-LOADER(  173): ACDB -> send_audtable
D/ACDB-LOADER(  173): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TABLE
D/ACDB-LOADER(  173): ACDB -> AUDIO_SET_AUDPROC_CAL
D/ACDB-LOADER(  173): ACDB -> send_audvoltable
D/ACDB-LOADER(  173): ACDB -> ACDB_CMD_GET_AUDPROC_GAIN_DEP_VOLTBL_STEP_COPP
D/ACDB-LOADER(  173): ACDB -> AUDIO_SET_AUDPROC_VOL_CAL
D/ACDB-LOADER(  173): ACDB -> send_afe_cal
D/ACDB-LOADER(  173): ACDB -> ACDB_CMD_GET_AFE_COMMON_TABLE
D/ACDB-LOADER(  173): ACDB -> AUDIO_SET_AFE_CAL
D/alsa_ucm(  173): Setting mixer control: SLIM_0_RX Channels, value: Two
D/alsa_ucm(  173): Setting mixer control: RX3 MIX1 INP1, value: RX1
D/ScannerPlugin(  934): String added to bundle: 4002343001009
D/alsa_ucm(  173): Setting mixer control: RX5 MIX1 INP1, value: RX2
D/alsa_ucm(  173): Setting mixer control: RX4 DSM MUX, value: DSM_INV
D/alsa_ucm(  173): Setting mixer control: RX6 DSM MUX, value: DSM_INV
D/alsa_ucm(  173): Setting mixer control: LINEOUT1 Volume, value: 50
D/alsa_ucm(  173): Setting mixer control: LINEOUT2 Volume, value: 50
D/alsa_ucm(  173): Setting mixer control: LINEOUT3 Volume, value: 50
D/alsa_ucm(  173): Setting mixer control: LINEOUT4 Volume, value: 50
D/alsa_ucm(  173): Setting mixer control: RX3 Digital Volume, value: 68
D/alsa_ucm(  173): Setting mixer control: RX4 Digital Volume, value: 68
D/alsa_ucm(  173): Setting mixer control: RX5 Digital Volume, value: 68
D/alsa_ucm(  173): Setting mixer control: RX6 Digital Volume, value: 68
D/alsa_ucm(  173): Set mixer controls for HiFi enable 1
D/alsa_ucm(  173): Setting mixer control: SLIMBUS_0_RX Audio Mixer MultiMedia1, value: 1
D/ALSADevice(  173): close: handle 0x416b18a8 h 0x0
D/ALSADevice(  173): open: handle 0x416b18a8
D/ALSADevice(  173): Device value returned is hw:0,0
D/KeystrokePlugin(  934): scanner data received: Bundle[{com.motorolasolutions.emdk.datawedge.label_type=LABEL-TYPE-EAN13, com.motorolasolutions.emdk.datawedge.data_string=4002343001009, com.motorolasolutions.emdk.datawedge.decode_data=[[B@426ac3c0], com.motorolasolutions.emdk.datawedge.source=scanner}]
D/ALSADevice(  173): setHardwareParams: reqBuffSize 2048 channels 2 sampleRate 48000
D/IntentPlugin(  934): Received scan data Bundle[{com.motorolasolutions.emdk.datawedge.label_type=LABEL-TYPE-EAN13, com.motorolasolutions.emdk.datawedge.data_string=4002343001009, com.motorolasolutions.emdk.datawedge.decode_data=[[B@426ac3c0], com.motorolasolutions.emdk.datawedge.source=scanner}] de.schnti.todo.SCAN Cat: android.intent.category.DEFAULT 2
D/IntentPlugin(  934): broadcasting intent Intent { act=de.schnti.todo.SCAN cat=[android.intent.category.DEFAULT] (has extras) }
D/ALSADevice(  173): setHardwareParams: buffer_size 16384, period_size 2048, period_
cnt 8
D/BatteryService(  637): Before: mAcOnline=false, mUsbOnline=true
D/BatteryService(  637): ac=0, usb=1
D/BatteryService(  637): After: mAcOnline=false, mUsbOnline=true
I/CNE_DEBUG(  637): CNE received action: android.intent.action.BATTERY_CHANGED
I/CNE_DEBUG(  637): UpdateBatteryStatus status=5 pluginType=2 level=100
D/StatusBar.BatteryController(  781): Ethanhsu : stat_sys_battery_1_5x =2130837600
D/StatusBar.BatteryController(  781): Ethanhsu : stat_sys_battery =2130837594
D/StatusBar.BatteryController(  781): Ethanhsu : current icon =2130837600

and this are the DataWedge Settings screenshot_2014-06-18-03-23-46 screenshot_2014-06-18-03-23-57 screenshot_2014-06-18-03-36-21 screenshot_2014-06-18-03-24-14 screenshot_2014-06-18-03-24-23

blakebyrnes commented 10 years ago

On the second screen, have you chosen your app from the Associated Apps sub-menu?

schnti commented 10 years ago

YES

*
de.schnti.todo
blakebyrnes commented 10 years ago

Ok. Are you manually putting the intent receiver into your android manifest? Have you tried taking that out? The plugin should register for everything on it's own. As another test, are you able to receive the intent if you use the default setting (com.bluefletch.motorola.datawedge.ACTION)? Perhaps there's a bug in using the custom value somewhere that I missed.

schnti commented 10 years ago

It testet it with the com.bluefletch.motorola.datawedge.ACTION default settings, same result....

Did this error something to do with it

E/NotificationService(  637): Ignoring notification with icon==0: Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x1 kind=[null])
D/AudioStreamOutALSA(  173): standby
D/ALSADevice(  173): standby: handle 0x416b18a8 h 0x0
E/ALSADevice(  173): standby handle h 0x4023b538
D/alsa_ucm(  173): snd_use_case_set(): uc_mgr 0x4106c2d8 identifier _verb value Inactive
D/alsa_ucm(  173): Set mixer controls for HiFi enable 0
D/alsa_ucm(  173): Setting mixer control: SLIMBUS_0_RX Audio Mixer MultiMedia1, value: 0
E/ALSADevice(  173): Number of modifiers 0
E/ALSADevice(  173): usecase_type is 0
blakebyrnes commented 10 years ago

That all looks normal to me. Are you able to share any of your code?

blakebyrnes commented 10 years ago

Or, can you just show me where you've included:

<intent-filter>
     <action android:name="de.schnti.todo.SCAN"/>
    <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>```
schnti commented 10 years ago
platforms/android/AndroidManifest.xml

I'm working on a test example for you.

schnti commented 10 years ago

DropboxLink [REMOVED]

blakebyrnes commented 10 years ago

Ok, I'm narrowing this down. I'm getting this to work if I use the default profile and specify your broadcast intent. Your sample was missing a few things (cordova.js, setting action, etc). I believe you're right that something with that notification is killing things. I'll keep troubleshooting:

E/NotificationService(  637): Ignoring notification with icon==0: Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x1 kind=[null])
schnti commented 10 years ago

Default profile with de.schnti.todo.SCAN does also not work. The cordova.js is needed for Cordova/PhoneGap (will be a 404 during development). What du you mean width setting action, etc? Are you successful with troubleshooting.

blakebyrnes commented 10 years ago

Well, to test that your app isn't receiving scans, it has to be run on the device... Maybe I'm not following your comment on the cordova.js file. The I am seeing the following:

RE: setting action, I meant your example is using: datawedge.start("com.example.hello.SCAN"); I just updated to match the original example. I guess it doesn't really matter, but just to be consistent.

blakebyrnes commented 10 years ago

I pushed a new version that accepts a startActivity option for a custom profile. It appears that the broadcast option is not working outside of the Default Profile in the current version of the DataWedge. Let me know if this helps you at all. If you're still having issues on your device, have you verified that the DWDemo app is working?

blakebyrnes commented 10 years ago

Ok, last update. This issue seems to manifest when you specify a category in the DataWedge. If you take that out, it is working fine.

schnti commented 10 years ago

Thank you for your help!