微信小程序发送蓝牙指令


writeBLECharacteristicValue(deviceId, serviceId, characteristicId, action) {
				let _that = this;
				// 向蓝牙设备发送一个0x00的16进制数据
				//let buffer = (1)
				//dataView.setUint8(0, Math.random() * 255 | 0)
				var hex = action //AA55080855AA
				var typedArray = new Uint8Array(hex.match(/[\da-f]{2}/gi).map(function(h) {
					return parseInt(h, 16)
				}))
				var buffer1 = typedArray.buffer
				console.log("发送内容:", buffer1)
				wx.writeBLECharacteristicValue({
					deviceId: deviceId,
					serviceId: serviceId,
					characteristicId: characteristicId,
					value: buffer1,
					success: function(resr) {
						console.log("发送成功")
					},
					fail: function(res2) {
						console.log("发送失败:", res2)
					}
				})
			},

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM