Mobile SDK
Android
Device Management
16 min
listing available miura devices bluetooth val devices = toro bluetoothmiuradeviceslist\<bluetoothdevice> devices = toro getbluetoothmiuradevices(); this will return a list of bluetoothdevice instances, excluding the selectedbluetoothdevice miura devices which have not been paired in the android bluetooth settings will not be returned usb val devices = toro usbmiuradeviceslist\<usbdevice> usbdevices = toro getusbmiuradevices(); this will return a list of usbdevice instances that are currently attached to the system, excluding the selectedusbdevice selecting a device bluetooth to select the device you want to use, set the selectedbluetoothdevice property on the toroclient instance toro selectedbluetoothdevice = device // device is a bluetoothdevice instancetoro setselectedbluetoothdevice(device); to unset the selected device, set the selectedbluetoothdevice property to null toro selectedbluetoothdevice = nulltoro setselectedbluetoothdevice(null); this will only work if the miura device has already been paired with the android device a securityexception is thrown if the app does not have the required permissions the selectedbluetoothdevice is persisted across app restarts, so there is no need to handle this in your application usb to select the device you want to use, set the selectedusbdevice property on the toroclient instance toro selectedusbdevice = device // device is a usbdevice instancetoro setselectedusbdevice(device); to unset the selected device, set the selectedusbdevice property to null toro selectedusbdevice = nulltoro setselectedusbdevice(null); this will only work if the miura device is already attached to the android device when the device is detached, the selectedusbdevice will be automatically set to null permission will need to have been granted by the user before the device can be selected the miura device will need to be in "usb serial mode" to be detected getting device information you can get information about the selected device using the getdeviceinfo method on the toroclient instance toro getdeviceinfo()toro getdeviceinfo(new torocallback\<miuradeviceinfo>() { @override public void onsuccess(@nullable miuradeviceinfo result) { } @override public void onerror(@nonnull toroexception error) { } }); this will return a miuradeviceinfo object containing information about the selected device, such as its serial number, system time, battery status, etc device state updates device session state you can check if the device is currently in use by the toro sdk using the issessionopen property on the toroclient instance toro issessionopenboolean issessionopen = toro issessionopen(); this will return true if the device is currently in use, and false otherwise this is applicable for both bluetooth and usb connections, as there is only one selected device per connection mode, and the sdk cannot be used to connect to multiple devices at once usb device listener you can also register a usbdevicelistener to receive usbdeviceevent updates if you are using connectionmode usb val listener = usbdevicelistener { event > when (event) { is usbdeviceevent deviceattached > todo() is usbdeviceevent devicedetached > todo() is usbdeviceevent permissiondenied > todo() is usbdeviceevent permissiongranted > todo() is usbdeviceevent permissionpending > todo() } } // register the listener with the toroclient instance toro setusbdevicelistener(listener)usbdevicelistener listener = new usbdevicelistener() { @override public void onusbdeviceevent(@nonnull usbdeviceevent event) { if (event instanceof usbdeviceevent deviceattached) { // handle device attached } else if (event instanceof usbdeviceevent devicedetached) { // handle device detached } else if (event instanceof usbdeviceevent permissiondenied) { // handle permission denied } else if (event instanceof usbdeviceevent permissiongranted) { // handle permission granted } else if (event instanceof usbdeviceevent permissionpending) { // handle permission pending } } }; // register the listener with the toroclient instance toro setusbdevicelistener(listener); software reset as the toro sdk has been built to support mpi v1 68, and os v9 7, software updates are not supported over the air at present it may well be the case that the sdk works with newer (or older) versions of the mpi and os, but this is not guaranteed if you want or need to reset the miura device to toro sdk compatible os and mpi, you can use the below functions toro resetdeviceos() // os 9 7 toro resetdevicempi() // mpi v1 68// reset os to 9 7 toro resetdeviceos(new torocallback\<unit>() { @override public void onsuccess(@nullable unit unit) { } @override public void onerror(@nonnull toroexception e) { } }); // reset mpi to v1 68 toro resetdevicempi(new torocallback\<unit>() { @override public void onsuccess(@nullable unit unit) { } @override public void onerror(@nonnull toroexception e) { } }); the configuration files can also be reset to defaults like so toro resetdeviceconfig() // may not be the latest version of the config filestoro resetdeviceconfig(new torocallback\<unit>() { @override public void onsuccess(@nullable unit unit) { } @override public void onerror(@nonnull toroexception e) { } }); read docid 1wybdibflc4cpiumn7xqr for information on how to get up to date configuration files resetdeviceconfig will use defaults the sdk ships with, rather than contacting the terminal management system (tms) to get the latest configuration files security and configuration updates your application should make periodic contact with the terminal management system (tms) to get the latest configuration files and security parameters the sdk does not do this automatically, to avoid performing updates at inappropriate times to check if there are any updates available, you can use the checkfordeviceupdates method on the toroclient instance toro checkfordeviceupdates( onupdatesavailable = { updates > log d(tag, "onupdatesavailable $updates") }, onerror = { error > log e(tag, "checkforupdates error", error) } ) when an update becomes available, you can execute it using the executedeviceupdate method when you are ready toro executedeviceupdate( update = update, onsuccess = { log d(tag, "onupdatecomplete $update") }, onerror = { error > log e(tag, "onupdateerror $update", error) } ) we recommend setting up a recurring job to check for updates, as well as on every app launch or when a device is selected
