uu
This commit is contained in:
parent
bc6d96fd0f
commit
d1098f2659
@ -24,24 +24,31 @@
|
|||||||
|
|
||||||
export function sendDataToDevice(options) {
|
export function sendDataToDevice(options) {
|
||||||
let byteLength = options.value.byteLength;
|
let byteLength = options.value.byteLength;
|
||||||
//这里默认一次20个字发送
|
// 这里默认一次20个字发送
|
||||||
const speed = options.onceByleLength || 20;
|
const speed = options.onceByleLength || 20;
|
||||||
|
console.log('byteLength====', byteLength)
|
||||||
if (byteLength > 0) {
|
if (byteLength > 0) {
|
||||||
|
console.log('speed====', speed)
|
||||||
|
console.log('value====', options.value)
|
||||||
uni.writeBLECharacteristicValue({
|
uni.writeBLECharacteristicValue({
|
||||||
...options,
|
...options,
|
||||||
// writeType:"writeNoResponse",
|
// writeType:"writeNoResponse",
|
||||||
value: options.value.slice(0, byteLength > speed ? speed : byteLength),
|
value: options.value.slice(0, byteLength > speed ? speed : byteLength),
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
if (byteLength > speed) {
|
// 【writeBLECharacteristicValue】安卓存在频繁调用失败的情况,下次调用前必须加上延迟
|
||||||
sendDataToDevice({
|
setTimeout(()=> {
|
||||||
...options,
|
if (byteLength > speed) {
|
||||||
value: options.value.slice(speed, byteLength),
|
sendDataToDevice({
|
||||||
});
|
...options,
|
||||||
} else {
|
value: options.value.slice(speed, byteLength),
|
||||||
options.lasterSuccess && options.lasterSuccess();
|
});
|
||||||
}
|
} else {
|
||||||
|
options.lasterSuccess && options.lasterSuccess();
|
||||||
|
}
|
||||||
|
},10)
|
||||||
},
|
},
|
||||||
fail: function (res) {
|
fail: function (res) {
|
||||||
|
console.log('writeBLECharacteristicValue:fail====', res)
|
||||||
options.onError && options.onError(res);
|
options.onError && options.onError(res);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -116,7 +123,6 @@ function grayPixle(pix) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
export function overwriteImageData(data) {
|
export function overwriteImageData(data) {
|
||||||
console.log("overwriteImageData data====", data)
|
|
||||||
let sendWidth = data.width,
|
let sendWidth = data.width,
|
||||||
sendHeight = data.height;
|
sendHeight = data.height;
|
||||||
const threshold = data.threshold || 180;
|
const threshold = data.threshold || 180;
|
||||||
@ -174,13 +180,16 @@ export function overwriteImageData(data) {
|
|||||||
*/
|
*/
|
||||||
export function sendDataToPrint(options, allUint8Array) {
|
export function sendDataToPrint(options, allUint8Array) {
|
||||||
const allLenth = allUint8Array.length;
|
const allLenth = allUint8Array.length;
|
||||||
console.log("====allLenth===", allLenth)
|
console.log("sendDataToPrint:allLenth=======", allLenth)
|
||||||
|
console.log("sendDataToPrint:allUint8Array-len=======", allUint8Array.length)
|
||||||
const writeArrayCopyer = allUint8Array.slice(0);
|
const writeArrayCopyer = allUint8Array.slice(0);
|
||||||
const print = (options, writeArray) => {
|
const print = (options, writeArray) => {
|
||||||
|
console.log("===writeArray.length===", writeArray.length)
|
||||||
if (writeArray.length) {
|
if (writeArray.length) {
|
||||||
|
let curBuffer = writeArray.shift().buffer
|
||||||
sendDataToDevice({
|
sendDataToDevice({
|
||||||
...options,
|
...options,
|
||||||
value: writeArray.shift().buffer,
|
value: curBuffer,
|
||||||
lasterSuccess: () => {
|
lasterSuccess: () => {
|
||||||
options.onProgress &&
|
options.onProgress &&
|
||||||
options.onProgress(Math.floor(((allLenth - writeArray.length) / allLenth) * 100));
|
options.onProgress(Math.floor(((allLenth - writeArray.length) / allLenth) * 100));
|
||||||
@ -246,8 +255,6 @@ export function getImageCommandArray(opt = {}, imageInfo = {}) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
export function getPrintImageWriteArray(opt = {}, imageInfo = {}) {
|
export function getPrintImageWriteArray(opt = {}, imageInfo = {}) {
|
||||||
console.log('getPrintImageWriteArray:opt======', opt)
|
|
||||||
console.log('getPrintImageWriteArray:imageInfo=====', imageInfo)
|
|
||||||
const lineByLine = typeof opt.lineByLine !== 'boolean' ? true : opt.lineByLine;
|
const lineByLine = typeof opt.lineByLine !== 'boolean' ? true : opt.lineByLine;
|
||||||
const width = imageInfo.width;
|
const width = imageInfo.width;
|
||||||
let arr = imageInfo.array;
|
let arr = imageInfo.array;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user