Posts

Showing posts with the label bluetooth

How to solve Pybluez OSerror

How to solve Pybluez OSerror I would like to connect a Lego Mindstorms NXT using pybleuz to my labtop. But when I search for the Mindstorms I get the following error: import bluetooth print("performing inquiry...") nearby_devices = bluetooth.discover_devices( duration=8, lookup_names=True, flush_cache=True, lookup_class=False) print("found %d devices" % len(nearby_devices)) for addr, name in nearby_devices: try: print(" %s - %s" % (addr, name)) except UnicodeEncodeError: print(" %s - %s" % (addr, name.encode('utf-8', 'replace'))) I get the error: OSError Traceback (most recent call last) <ipython-input-8-bcb3970d611c> in <module>() 4 5 nearby_devices = bluetooth.discover_devices( ----> 6 duration=8, lookup_names=True, flush_cache=True, lookup_class=False) 7 8 print("found %d devices" % len(nearby_devices)) /...

How to print the text right aligned in a Bluetooth POS Printer?

How to print the text right aligned in a Bluetooth POS Printer? I have been trying to do a POS app in android where I am printing the receipt on a Bluetooth printer connected to the app. I am able to print 'large', 'small' and QR code with the HOINSDK provided with the device and also I am able to align then 'left' and 'centre' but unable to align it to the 'right'. Any help is appreciated. Below are the codes for respective things: //For Large Text cmd[0] = 27; cmd[1] = 97; cmd[2] &= 0xEF; mService.write(cmd); mService.sendMessage("" + large_txt.getText().toString(), "GBK"); //For Small Text cmd[0] = 0x1b; cmd[1] = 0x21; cmd[2] &= 0xEF; mService.write(cmd); mService.sendMessage("" + small_txt.getText().toString(), "GBK"); //For Cent...