ZQ620 do not bluetooth connection from Chrome (JavaScript)

// Expert user has replied.
M Makoto Uno 2 months 3 weeks ago
45 1 0

I want to connection ZQ620(this is verification machine) and print, use bluetooth from Android Chrome browser JavaScript (pure or jQuery) only.

My sample source.

const DEVICE_UUID = '0000fe79-0000-1000-8000-00805f9b34fb';
const SERVICE_UUID = '38eb4a84-c570-11e3-9507-0002a5d5c51b';
var printer = null;
var printRes = null;
function sendText(s) {
	let encoder = new TextEncoder("utf-8");
	let txt     = encoder.encode(s+ '\u000A\u000D\u000A\u000D\u000A\u000D\u000A\u000D\u000A\u000D');
	return printer.writeValue(txt);
}

function fnc(eve){
	navigator.bluetooth.requestDevice({
		filters: [{
			namePrefix: 'X',
		}],
		optionalServices: [SERVICE_UUID]
	})
	.then(device => {
		console.log('connect device start');
		return device.gatt.connect();
	})
	.then(server => {
		console.log('start primary servicies');
		return server.getPrimaryServices();
	})
	.then(services => {
		console.log(services);
	})/*
	.then(service => {
		console.log('start characteristic');
		return service.getCharacteristic(SERVICE_UUID);
	})
	.then(characteristic => {
		printer = characteristic;
		printRes = sendText($("#_textarea").val());
	})
	*/
	.catch(error => {
		console.err('error occurred', error);
	});
}

But, error occurrd. Throws error is 'NotFoundError: No Services found in device.' from 'return server.getPrimaryServices();'
nRF Connect app said service is exist, but can not access(screeenshot). 

So, how connect and print? This printer not supported?Can I use it on other devices?
I'm sorry if my English is strange.

Please Register or Login to post a reply

1 Replies

S Steven Si

Looks like the UUID for the service is wrong. The service UUID should be "38eb4a80-c570-11e3-9507-0002a5d5c51b", i.e., starting with 38eb4a80, not 38eb4a84.

const SERVICE_UUID = '38eb4a84-c570-11e3-9507-0002a5d5c51b';

See the example project for more info on how to connect to printer's BLE - zebraPrinterBLEDemo and the Link-OS Environment Bluetooth Low Energy AppNote for the currect UUIDs.

 

CONTACT
Can’t find what you’re looking for?