微信小程序蓝牙使用

// let _ = this;
				// console.log('蓝牙开始查找')
				// wx.openBluetoothAdapter({
				// 	success(res) {
				// 		wx.startBluetoothDevicesDiscovery({
				// 			services: [],
				// 			success: function() {
				// 				console.log('开始搜索蓝牙')
				// 				wx.onBluetoothDeviceFound((result) => {
				// 					// console.log("监听蓝牙新设备: ", result )
				// 					let t = 0;
				// 					let searchDevice = [];
				// 					// TODO 在这可以判断是否已经搜素到,指定蓝牙。如果搜素到,则停止蓝牙搜素
				// 					// console.log("监听寻找新设备的事件 - ", result.devices[0]);
				// 					for (let i = 0; i < result.devices.length; i++) {
				// 						console.log('循环id', result.devices[i])
				// 						// if (!result.devices[i].deviceId || !result.devices[i]
				// 						// 	.name) {
				// 						// 	return
				// 						// }
				// 						searchDevice[t++] = result.devices[i];
				// 						console.log('发现的新设备')
				// 						// console.log('设备id - ' + result.devices[i].deviceId)
				// 						console.log('设备name - ' + result.devices[i].name)

				// 						if (result.devices[i].advertisData) {
				// 							// console.log('IOS - 将UUID转化为设备ID')
				// 							let bf = result.devices[i].advertisData.slice(2,
				// 							8);
				// 							// console.log('IOS - 获取所需数据', bf)
				// 							console.log('IOS - 将UUID转化为设备ID', _.ab2hex(result
				// 								.devices[i].advertisData))

				// 							let mac = Array.prototype.map
				// 								.call(new Uint8Array(bf), (x) => ("00" + x
				// 									.toString(16)).slice(-2))
				// 								.join(":");
				// 							mac = mac.toUpperCase();
				// 							for (let i = 0; i < result.devices.length; i++) {
				// 								result.devices[0].macId = mac
				// 							}
				// 							console.log('IOS - UUID转化的mac地址为', mac)
				// 							console.log(result.devices);
				// 						}
				// 					}
				// 					var device = result.devices[0];
				// 				})

				// 			},
				// 			fail: function(err) {
				// 				console.log('蓝牙开始失败', err);
				// 				wx.stopBluetoothDevicesDiscovery({
				// 					success: function() {}
				// 				})
				// 			}
				// 		})
				// 		let timers = setTimeout(() => {
				// 			wx.stopBluetoothDevicesDiscovery({
				// 				success: function() {}
				// 			})
				// 			uni.hideLoading()
				// 			clearTimeout(timers)
				// 			timers = null;
				// 		}, 10000)
				// 	},
				// 	fail(err) {
				// 		console.log(err);
				// 	}
				// })

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值