- 【物流助手】服务商如何接入“即时配送”?
参考下公告: https://developers.weixin.qq.com/community/minihome/doc/000c8aa962c0c0f24ceb574d55d801
2021-12-30 - 蓝牙 数据写入 简单易懂版(适合没写过蓝牙的看)
//字符串转arrbuffer function string2buffer(str) { // 首先将字符串转为16进制 let val = "" for (let i = 0; i < str.length; i++) { if (val === '') { val = str.charCodeAt(i).toString(16) } else { val += ',' + str.charCodeAt(i).toString(16) } } // 将16进制转化为ArrayBuffer return new Uint8Array(val.match(/[\da-f]{2}/gi).map(function (h) { return parseInt(h, 16) })).buffer } writeBLECharacteristicValue() { let obj = { "stime": 1582201466 }; let newbuffer = string2buffer( JSON.stringify(obj)) wx.writeBLECharacteristicValue({ deviceId: this._deviceId, serviceId: this._serviceId, characteristicId: this._characteristicId, value: newbuffer , success(res) { console.info('成功') console.log('writeBLECharacteristicValue success', res.errMsg) }, fail(res) { console.info('失败') console.log('writeBLECharacteristicValue fail', res.errMsg) }, complete(res) { console.info('完成') console.log('writeBLECharacteristicValue complete', res.errMsg) } }) }, 如果数据量在20-30字节之间可直接发送 如果数据量过大 需要进行分包处理 分包发送数据期间要加上时间间隔 不然某些机型可能会传输失败
2020-02-25