安卓不能连接蓝牙小票打印机,苹果能发送数据但不能打印
[代码]sendtoequ: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码] [代码][代码]console.log([代码][代码]"发送消息到:deviceId"[代码] [代码]+ that.data.connectedDeviceId);[代码][代码] [代码][代码]console.log([代码][代码]"serviceId:"[代码] [代码]+ that.data.serviceId);[代码][代码] [代码][代码]console.log([代码][代码]"characteristicId:"[代码] [代码]+that.data.characteristicId)[代码]; let _value = str2ab(that.data.inputValue);//输入的数据 [代码] [代码][代码]wx.writeBLECharacteristicValue({[代码][代码] [代码][代码]// 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取[代码][代码] [代码][代码]deviceId: that.data.connectedDeviceId,[代码][代码] [代码][代码]// 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取[代码][代码] [代码][代码]serviceId: that.data.serviceId,[代码][代码] [代码][代码]// 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取[代码][代码] [代码][代码]characteristicId: that.data.characteristicId,[代码][代码] [代码][代码]// 这里的value是ArrayBuffer类型[代码][代码] [代码][代码]value: _value,[代码][代码] [代码][代码]// value: buffer,[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]console.log([代码][代码]'writeBLECharacteristicValue success'[代码][代码], ab2str(_value))[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码], [代码][代码] function ab2str(buf) { return String.fromCharCode.apply(null, new Uint16Array(buf)); } [代码]function[代码] [代码]str2ab(str) {[代码][代码] [代码][代码]var[代码] [代码]buf = [代码][代码]new[代码] [代码]ArrayBuffer(str.length*4); [代码][代码]// 4 bytes for each char[代码][代码] [代码][代码]var[代码] [代码]bufView = [代码][代码]new[代码] [代码]Uint16Array(buf);[代码][代码] [代码][代码]for[代码] [代码]([代码][代码]var[代码] [代码]i=0, strLen=str.length; i<strlen; i++)="" {<="" code="">[代码][代码][代码][代码] [代码][代码]bufView[i] = str.charCodeAt(i);[代码][代码][代码][代码][代码][代码] [代码][代码]}[代码][代码][代码][代码][代码][代码] [代码][代码]return[代码] [代码]buf;[代码][代码][代码][代码][代码][代码]}[代码][代码][代码] [代码][代码][代码] [代码][代码][代码] [代码][代码][代码] [代码][代码][代码] [代码][代码][代码] [代码][代码][代码] 安卓不能连接蓝牙小票打印机,苹果能发送数据,但不能打印 下图成功发送1到打印机,但是,打印机没反应 [图片]