# wx-bluetooth **Repository Path**: lyflyy/wx-bluetooth ## Basic Information - **Project Name**: wx-bluetooth - **Description**: 使用wx-bluetooth打印图片遇到了问题 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2019-09-20 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 热敏打印机 项目: 1. 可以打印的出来中文与图片的项目[WX-BLUETOOTH],项目本身是有问题的,特征值的选取方式不符合咱们的打印机 1. write、notify、indicate、read同时为true 2. 修改了index.js 的第170行与【getBLEDeviceCharacteristics】方法 3. 原项目地址[wx-bluetooth: 微信 小程序 蓝牙 打印 小票 二维码](https://gitee.com/copperpeas/wx-bluetooth) 4. 参考文章[微信小程序蓝牙打印二维码 - cfujiC的博客 - CSDN博客](https://blog.csdn.net/cfujiC/article/details/86013122)、[热敏打印机编程 ESC/POS指令 - 简书](https://www.jianshu.com/p/dd6ca0054298)、[Android 蓝牙连接 ESC/POS 热敏打印机打印(ESC/POS指令篇) - 简书](https://www.jianshu.com/p/c0b6d1a4823b) 2. 该项目问题 1. 中文打印ok,图片打印,直接使用该项目在其他打印机成功打印的图片依旧是乱码 2. 按照他的逻辑[热敏打印机编程 ESC/POS指令 - 简书](https://www.jianshu.com/p/dd6ca0054298) 前端架构设计图 3. 还有一个人的逻辑 前端架构设计图 现在的代码 前端架构设计图 打印结果 前端架构设计图 文章有提示,宽高配置不对会出现乱码 宽度计算 ``` const x = 160/8 const y = 160 // 补足16位 strX = x.toString(2) if(strX.length < 16){ let temp = 16 - strX.length for (var i = temp - 1; i >= 0; i--) { strX = '0' + strX } } //高八位 hStr = strX.substr(0, 8) console.log('xh-', parseInt(hStr, 2)) //低八位 lStr = strX.substr(8) console.log('xl-', parseInt(lStr, 2)) // 补足16位 strY = y.toString(2) if(strY.length < 16){ let temp = 16 - strY.length for (var i = temp - 1; i >= 0; i--) { strY = '0' + strY } } //高八位 hStr = strY.substr(0, 8) console.log('yh-', parseInt(hStr, 2)) //低八位 lStr = strY.substr(8) console.log('yl-', parseInt(lStr, 2)) ```