PrinterDiscovery
The Brady SDK PrinterDiscovery object allows the user to start discovery, stop discovery, and get information about discovered printers.
startBlePrinterDiscovery()
startBlePrinterDiscovery starts discovering nearby printers through Bluetooth Low Energy.
startWifiPrinterDiscovery()
startWifiPrinterDiscovery starts discovering nearby printers on the same internet connection as your device.
stopBlePrinterDiscovery()
stopPrinterDiscovery stops any discovery scan that is currently running.
connectToDiscoveredPrinter(printerSelected: DiscoveredPrinterInformation, listeners: Array[PrinterUpdateListener]) async throws -> PrinterDetails?
connectToDiscoveredPrinter returns a PrinterDetails object holding all information about the connected printer and it's connection status.
- printerSelected: The DiscoveredPrinterInformation object that we are trying to connect to.
- listeners: A list of PrinterUpdateListener objects that will be notified if a change is made to a connected printer.
getLastConnectedPrinterName() -> String?
getLastConnectedPrinterName returns a nullable String that represents the name of the most recent printer that was successfully connected to.
forgetLastConnectedPrinter()
forgetLastConnectedPrinter clears the internally stored printer. This printer will always be the one that was successfully connected to last. Calling this method will always result in getLastConnectedPrinter() returning null.
getHaveOwnership()
getHaveOwnership returns a boolean representing the ownership the device has to the Bluetooth Low Energy printer. Ownership is a concept on the M211 and M511 only. Depending on the result that is returned, you might want to display messages to the user in the form of a Toast or Snackbar.
IF TRUE: Your device has claimed ownership of the printer. This means no other mobile device can connect to the printer. The blue Bluetooth light on the printer goes solid when somebody has ownership. You may hold the power button for 5 seconds to release ownership. However, just because the blue light is solid DOES NOT mean you are currently connected. These are two completely separate things. The only way they relate is that you must attempt to connect at least once to claim ownership. Even if this connection fails, you might still gain ownership successfully.
IF FALSE: You attempted to claim ownership at one point and were rejected because somebody else already as ownership. This doesn't necessarily have to be another device. With the same phone, if you connect to an M211 in the Brady Express Labels app, close the app to disconnect, open your app using the SDK, and attempt to connect, you will be rejected ownership.
IF NIL: The ownership of the desired printer is unknown because your device has not successfully "made contact" with the printer yet. This might be due to a ConnectionTimeout error or some other unrelated error that cause the connection to exit early.