NimmstaDevice
An instance of a NimmstaDevice is used to communicate with one HS 50.
To get an instance of NIMMSTADevice, you need to iterate through all connected devices on the NIMMSTAManager
.
Properties
The following properties can be read and set to change the behavior of the scanner.
- Get/Set preferredTriggerMode = Disabled, Button, Touch, ButtonAndTouch, Motion, MotionAndButton, MotionAndTouch, MotionAndButtonAndTouch, DefaultEnabled
- Get/Set preferredAimMode = Default, PickingMode, RepeatedAiming, PickingModeRepeatedAiming, ContinuousScanning, PickingModeContinuousScanning, RepeatedAimingContinuousScanning, PickingModeRepeatedAimingContinuousScanning
- Get/Set reconnectTimeout = 1800 (Timeout in seconds; 30 minutes is default)
- Get/Set barcodeRules
- Get/Set prefersReconnect = true, false
- Get/Set prefersShutdownOnCharge = true, false
- Get/Set decoderBoardSettings
- Get isCharging = true, false
- Get isSearchingToReconnect = true, false
- Get wasReconnected = true, false
- Get batteryLevel = 0 - 100
Example
Actions
To communicate with the corresponding HS 50 you can call several functions, each executing a specific action on the HS 50.
The following actions are currently supported:
Get Device Info
To get information about the given NimmstaDevice, you can call getDeviceInfo on the NimmstaDevice. To access the data of the response, you need to wait for the Task to be completed and access the information in the following way:
device.getDeviceInfo().onSuccess { response ->
// Current battery status in percent
val battery = response.battery
// Current version of the hardware of the connected HS 50
val hardwareVersion = response.hardwareVersion
// Current version of the firmware of the connected HS 50
val firmwareVersion = response.firmwareVersion
// Current version of the ble firmware of the connected HS 50
val bleFirmwareVersion = response.bleFirmwareVersion
// Current version of the ble script of the connected HS 50
val bleScriptVersion = response.bleScriptVersion
// Current version of the bootloader of the connected HS 50
val bootloaderVersion = response.bootloaderVersion
// Current version of the imager of the connected HS 50
val imagerFirmwareVersion = response.imagerFirmwareVersion
}.onError { error ->
Log.e(TAG, "Error getting device info", error)
}
device.getDeviceInfo().onSuccess((response) -> {
// Current battery status in percent
int battery = response.getBattery();
// Current version of the hardware of the connected HS 50
String hardwareVersion = response.getHardwareVersion();
// Current version of the firmware of the connected HS 50
String firmwareVersion = response.getFirmwareVersion();
// Current version of the ble firmware of the connected HS 50
String bleFirmwareVersion = response.getBleFirmwareVersion();
// Current version of the ble script of the connected HS 50
String bleScriptVersion = response.getBleScriptVersion();
// Current version of the bootloader of the connected HS 50
String bootloaderVersion = response.getBootloaderVersion();
// Current version of the imager of the connected HS 50
String imagerFirmwareVersion = response.getImagerFirmwareVersion();
return null;
}).onError((error) -> {
Log.e(TAG, "Error getting device info", error);
return null;
});
Is Device Connected
To check whether the HS 50 that corresponds to this NimmstaDevice is connected to the phone, you can call isConnected() on the NimmstaDevice.
Disconnect
Disconnect from the device.
Stop Reconnecting
Stops a device from reconnecting.
Set Layout
To change the contents of the HS 50 screen, you can call setLayout with an instance of NimmstaLayout. For this action, the response does not contain any data. There are currently multiple predefined layouts that can be used with this function. Check out the Layout Documentation.
To change the layout you need to do the following:
To create your own predefined layout see Predefined Layouts.
Set Layout For
Same as Set Layout, but with a time in ms how long the layout should be shown on the scanner.
Set XML Layout
To change the contents of the HS 50 screen, you can call setXMLLayout with your own custom XML that represents a layout the HS 50 can understand. To learn more about XML layouts head over to Layout Basics of the NIMMSTA Android Core.
val xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<NimmstaLayout name=\"empty\">" +
" <device width=\"1.54\" height=\"1.54\" pxx=\"200\" pxy=\"200\">" +
" <screen default=\"true\" name=\"default\">" +
" <staticElements>" +
" <cell x=\"10\" y=\"10\" name=\"text1\">Text1</cell>" +
" <cell x=\"10\" y=\"50\" name=\"text2\">Text2</cell>" +
" </staticElements>" +
" </screen>" +
" </device>" +
"</NimmstaLayout>"
device.setLayout(xml).onSuccess {
Log.d(TAG, "XML layout successfully set")
}.onError { error ->
Log.e(TAG, "Error setting XML layout", error)
}
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<NimmstaLayout name=\"empty\">" +
" <device width=\"1.54\" height=\"1.54\" pxx=\"200\" pxy=\"200\">" +
" <screen default=\"true\" name=\"default\">" +
" <staticElements>" +
" <cell x=\"10\" y=\"10\" name=\"text1\">Text1</cell>" +
" <cell x=\"10\" y=\"50\" name=\"text2\">Text2</cell>" +
" </staticElements>" +
" </screen>" +
" </device>" +
"</NimmstaLayout>";
device.setLayout(xml).onSuccess((task) -> {
Log.d(TAG, "XML layout successfully set");
return task;
}).onError((error) -> {
Log.e(TAG, "Error setting XML layout", error);
return null;
});
Set XML Layout For
Same as Set XML Layout, but with a time in ms how long the layout should be shown for.
val xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<NimmstaLayout name=\"empty\">" +
" <device width=\"1.54\" height=\"1.54\" pxx=\"200\" pxy=\"200\">" +
" <screen default=\"true\" name=\"default\">" +
" <staticElements>" +
" <cell x=\"10\" y=\"10\" name=\"text1\">Text1</cell>" +
" <cell x=\"10\" y=\"50\" name=\"text2\">Text2</cell>" +
" </staticElements>" +
" </screen>" +
" </device>" +
"</NimmstaLayout>"
device.setLayoutFor(xml, 5000).onSuccess {
Log.d(TAG, "XML layout with timeout successfully set")
}.onError { error ->
Log.e(TAG, "Error setting XML layout with timeout", error)
}
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<NimmstaLayout name=\"empty\">" +
" <device width=\"1.54\" height=\"1.54\" pxx=\"200\" pxy=\"200\">" +
" <screen default=\"true\" name=\"default\">" +
" <staticElements>" +
" <cell x=\"10\" y=\"10\" name=\"text1\">Text1</cell>" +
" <cell x=\"10\" y=\"50\" name=\"text2\">Text2</cell>" +
" </staticElements>" +
" </screen>" +
" </device>" +
"</NimmstaLayout>";
device.setLayoutFor(xml, 5000).onSuccess((task) -> {
Log.d(TAG, "XML layout with timeout successfully set");
return task;
}).onError((error) -> {
Log.e(TAG, "Error setting XML layout with timeout", error);
return null;
});
Update Layout
To update an already displayed Layout without sending the whole layout again, you can call updateLayout. Update layout requires an object with key value pairs. The key should be the same as the name of the element you want to update and the value represents the new value that should be displayed. To update a layout the following code is needed:
Map<String, String> params = new HashMap<>();
params.put("text1", "New Text 1");
params.put("text2", "New Text 2");
device.updateLayout(params).onSuccess((task) -> {
Log.d(TAG, "Layout successfully updated");
return task;
}).onError((error) -> {
Log.e(TAG, "Error updating layout", error);
return null;
});
Set LED Color
To set the color of the HS 50 LED, you can call setLEDColor with values for red, green and blue between 0 and 255, where 0 is no brightness at all and 255 represents the full brightness for the given color. The following code changes the LED color:
Set LED Color Hex
To set the color of the HS 50 LED with a hex string that represents the desired color, you can call setLEDColorHex with values like "#FF00FF" or "FF00FF". The following code changes the LED color:
Trigger Beeper Burst
A beeper burst is a succession of beeps of the HS 50 with a given pattern, which is repeated for a given amount of times or indefinitely. If you want to cancel an indefinitely long beeper burst, you need to send a short beep with only one repeat.
val repeat = 5 // How often to trigger the beeper. 0 means indefinitely. Must be greater or equal to 0 and smaller or equal to 255
val duration = 500 // Duration how long one cycle takes in milliseconds. Must be greater or equal to 10 and smaller or equal to 4095
val pulseDuration = 250 // How long the beeper is on within one cycle in milliseconds. Must be greater or equal to 10 and smaller or equal to 4095
val intensity = 100 // How loud the beeper is (0-100).
device.triggerBeeperBurst(repeat, duration, pulseDuration, intensity).onSuccess {
Log.d(TAG, "Successfully triggered beeper burst")
}.onError { error ->
Log.e(TAG, "Error triggering beeper burst", error)
}
int repeat = 5; // How often to trigger the beeper. 0 means indefinitely. Must be greater or equal to 0 and smaller or equal to 255
int duration = 500; // Duration how long one cycle takes in milliseconds. Must be greater or equal to 10 and smaller or equal to 4095
int pulseDuration = 250; // How long the beeper is on within one cycle in milliseconds. Must be greater or equal to 10 and smaller or equal to 4095
int intensity = 100; // How loud the beeper is (0-100).
device.triggerBeeperBurst(repeat, duration, pulseDuration, intensity).onSuccess((task) -> {
Log.d(TAG, "Successfully triggered beeper burst");
return task;
}).onError((error) -> {
Log.e(TAG, "Error triggering beeper burst", error);
return null;
});
Trigger LED Burst
A LED burst is a succession of flashes of the LED with a given pattern and color, which is repeated for a given amount of times or indefinitely.
val red = 255
val green = 0
val blue = 255
val repeat = 3 // Amount of repeats, 0 means indefinitely. Must be greater or equal to 0 and smaller or equal to 255
val duration = 500 // Duration how long one cycle takes in milliseconds. Must be greater or equal to 10 and smaller or equal to 4095
val pulseDuration = 250 // How long the LED is on within one cycle in milliseconds. Must be greater or equal to 10 and smaller or equal to 4095
device.triggerLEDBurst(repeat, duration, pulseDuration, red, green, blue).onSuccess {
Log.d(TAG, "Led burst successfully triggered")
}.onError { error ->
Log.e(TAG, "Error triggering LED Burst", error)
}
int red = 255;
int green = 0;
int blue = 255;
int repeat = 3; // Amount of repeats, 0 means indefinitely. Must be greater or equal to 0 and smaller or equal to 255
int duration = 500; // Duration how long one cycle takes in milliseconds. Must be greater or equal to 10 and smaller or equal to 4095
int pulseDuration = 250; // How long the LED is on within one cycle in milliseconds. Must be greater or equal to 10 and smaller or equal to 4095
device.triggerLEDBurst(repeat, duration, pulseDuration, red, green, blue).onSuccess((task) -> {
Log.d(TAG, "Led burst successfully triggered");
return task;
}).onError((error) -> {
Log.e(TAG, "Error triggering LED Burst", error);
return null;
});
Trigger SOS
An SOS signal is a red LED with 4x vibration and 4x beeping. To trigger a SOS signal you can use the following code:
Trigger Vibrator Burst
A vibrator burst is a succession of vibrations of the HS 50 with a given pattern, which is repeated for a given amount of times or indefinitely. If you want to cancel an indefinitely long vibrator burst, you need to send a short vibration with only one repeat.
val repeat = 5 // How often to trigger the vibrator. 0 means indefinitely. Must be greater or equal to 0 and smaller or equal to 255
val duration = 500 // Duration how long one cycle takes in milliseconds. Must be greater or equal to 10 and smaller or equal to 4095
val pulseDuration = 250 // How long the vibrator is on within one cycle in milliseconds. Must be greater or equal to 10 and smaller or equal to 4095
val intensity = 100 // How strong the vibration is (0-100).
device.triggerVibratorBurst(repeat, duration, pulseDuration, intensity).onSuccess {
Log.d(TAG, "Successfully triggered vibrator burst")
}.onError { error ->
Log.e(TAG, "Error triggering vibrator burst", error)
}
int repeat = 5; // How often to trigger the vibrator. 0 means indefinitely. Must be greater or equal to 0 and smaller or equal to 255
int duration = 500; // Duration how long one cycle takes in milliseconds. Must be greater or equal to 10 and smaller or equal to 4095
int pulseDuration = 250; // How long the vibrator is on within one cycle in milliseconds. Must be greater or equal to 10 and smaller or equal to 4095
int intensity = 100; // How strong the vibration is (0-100).
device.triggerVibratorBurst(repeat, duration, pulseDuration, intensity).onSuccess((task) -> {
Log.d(TAG, "Successfully triggered vibrator burst");
return task;
}).onError((error) -> {
Log.e(TAG, "Error triggering vibrator burst", error);
return null;
});
Trigger Imager
You can trigger the imager (the part of the scanner that takes pictures and recognizes codes) to scan without pressing the trigger button or the display The duration is passed as a number in milliseconds
Events
To handle device events you need to implement the NIMMSTADeviceEventHandler interface
Connect Event
Connect events occur when a new HS 50 is connected to the device.
Disconnect Event
Disconnect events occur when a HS 50 gets disconnected for whatever reason. The returned event contains the reason of the disconnect.
Scan Event
Scan events happen when a user scans a barcode with the HS 50. The event contains the scanned barcode string after rules are applied, if there are any. To subscribe to a scan event the following code is used:
Touch Event
Touch events occur if a user touches the display of the HS 50. The event contains the x and the y coordinate of the touch location. This event is not affected by the setting of the trigger mode of the android app.
Button Event
Button events occur if a user touches a button on the display of the HS 50. The event contains the title of the button.
Trigger Event
A Trigger Event is fired if the trigger is pressed on the device. The trigger is the button which is usually used to trigger a scan.
Double Trigger Event
A Double Trigger Event is fired if the trigger is pressed twice on the device in quick succession. The trigger is the button which is usually used to trigger a scan.
Note
Before receiving a Double Trigger Event, you will always receive a Trigger Event.
Triple Trigger Event
A Triple Trigger Event is fired if the trigger is pressed three times on the device in quick succession. The trigger is the button which is usually used to trigger a scan.
Note
Before receiving a Triple Trigger Event, you will always receive first a Trigger Event and then a Double Trigger Event.
Start Charging Event
A Start Charging Event is fired if the device is placed on the charging pad and starts charging.
Stop Charging Event
A Stop Charging Event is fired if the device is removed from the charging pad and stops charging.
Battery Level Changed Event
Battery Level Changed events occur if the percentage of the battery of the HS 50 changed.
Software Update Progress Event
Software Update Progress events occur when a SoftwareUpdate is sent to the device and progress was made.