当前位置: 首页 > news >正文

全国最大的外发加工网seo搜索引擎优化名词解释

全国最大的外发加工网,seo搜索引擎优化名词解释,网站后台登陆密码忘记,黄埔网站开发公司模拟的是蓝牙设备签到/签出&#xff1a; 获取指定蓝牙设备蓝牙初始搜索次数限制&#xff0c;超过限制就停止搜索蓝牙连接失败次数限制&#xff0c;超过限制标识蓝牙连接失败&#xff08;离开蓝牙范围或其他原因&#xff09;自动重连指定蓝牙 const device ref<any>(nu…

模拟的是蓝牙设备签到/签出:

  1. 获取指定蓝牙设备
  2. 蓝牙初始搜索次数限制,超过限制就停止搜索
  3. 蓝牙连接失败次数限制,超过限制标识蓝牙连接失败(离开蓝牙范围或其他原因)
  4. 自动重连指定蓝牙
const device = ref<any>(null); // 设备信息
const crpBlueList = ref<any[]>([]); // 扫描到的蓝牙信息列表
const linkStatus = ref(false); // 连接状态
const searchTimes = ref(0); // 搜索次数
const searchLimit = 5; // 搜索次数限制
const linkTimes = ref(0); // 扫描次数
const failTimes = ref(0); // 失败次数
const failLimit = 5; // 失败次数限制
const blueName = 'zo-crp'; // 指定蓝牙设备的名称前缀
let isSignIn = false; // 是否签到
// 签到
const signIn = () => {searchTimes.value = 0;uni.showLoading({title: '蓝牙搜索中...',mask: true});openBluetoothAdapter(() => {startBluetoothDeviceDiscovery();});
};
// 签出
const logout = () => {closeBlueTooth(device.value, () => {isSignIn = false;device.value = null;linkStatus.value = false;searchTimes.value = 0;linkTimes.value = 0;failTimes.value = 0;crpBlueList.value = [];uni.showToast({title: '已签出'});});
};
// 初始化蓝牙
const openBluetoothAdapter = (callback: Function) => {uni.openBluetoothAdapter({//打开蓝牙适配器接口success: (res) => {//已打开callback();},fail: (err) => {uni.hideLoading();uni.showModal({title: '',content: '该操作需要蓝牙支持!请打开蓝牙',showCancel: false,success: (res) => {if (res.confirm) {// #ifdef APPlet main = plus.android.runtimeMainActivity();let Intent = plus.android.importClass('android.content.Intent');let mIntent = new Intent('android.settings.BLUETOOTH_SETTINGS');main.startActivity(mIntent);// #endif} else {navigateBack();}},complete: () => {}});}});
};
// 搜索蓝牙
const startBluetoothDeviceDiscovery = () => {if (searchTimes.value > searchLimit - 1) {uni.showModal({content:'没有找到指定的蓝牙设备,请确认所在位置周边有指定蓝牙设备,且手机已开启位置信息并授权',confirmText: '重试',success: (res) => {if (res.confirm) {signIn();} else {stopBluetoothDevicesDiscovery(() => {uni.closeBluetoothAdapter({complete: () => {navigateBack();}});});}}});return;}searchTimes.value += 1;uni.startBluetoothDevicesDiscovery({success: (res) => {// 发现外围设备onBluetoothDeviceFound();},fail: (err) => {console.log(err, '开始搜索蓝牙设备备错误信息');}});
};
// 发现设备
const onBluetoothDeviceFound = () => {let t: any = setTimeout(() => {clearTimeout(t);t = null;stopBluetoothDevicesDiscovery(() => {// 停止搜索蓝牙uni.getBluetoothDevices({success: (res) => {const blueList = res.devices.filter((item: any) => item.name.toLowerCase().startsWith(blueName)).sort((a: any, b: any) => b.RSSI - a.RSSI);crpBlueList.value = blueList;if (!blueList.length) {startBluetoothDeviceDiscovery();return;}const Device: any = blueList[0];isSignIn = true;// 获取电量const serviceData = Array.prototype.map.call(new Uint8Array(Device.serviceData[Object.keys(Device.serviceData)[0]]), (bit) =>bit.toString(16)).join('');const Electric = parseInt(serviceData.slice(-2), 16);// 获取uuidconst UUID = Array.prototype.map.call(new Uint8Array(Device.advertisData), (bit) => ('00' + bit.toString(16)).slice(-2)).join('').substring(8, 40).toUpperCase();device.value = {name: Device.name,deviceId: Device.deviceId,electric: Electric,RSSI: Device.RSSI,UUID: UUID};linkStatus.value = true;createBLEConnection(Device);}});});}, 2000);
};
// 连接设备
const createBLEConnection = (item: any) => {uni.showLoading({title: '连接中,请稍等',mask: true});linkTimes.value += 1;uni.createBLEConnection({deviceId: item.deviceId,success(res) {linkStatus.value = true;failTimes.value = 0;uni.showToast({title: '蓝牙已连接',mask: true});onBLEConnectionStateChange(item);},fail(res) {linkStatus.value = false;plus.device.vibrate(500);if (failTimes.value < failLimit) {failTimes.value += 1;uni.showToast({title: item.name + '蓝牙连接失败',icon: 'none'});reLink(item);} else {closeBlueTooth(item, () => {uni.showToast({title: item.name + '蓝牙连接失败,取消连接',icon: 'none'});});}}});
};
// 监听蓝牙状态
const onBLEConnectionStateChange = (item: any) => {uni.onBLEConnectionStateChange((res) => {m_Debounce(() => {if (!res.connected && isSignIn) {reLink(item);}}, 500);});
};
// 蓝牙重连
const reLink = (item: any) => {closeBlueTooth(item, () => {let t: any = setTimeout(() => {clearTimeout(t);t = null;openBluetoothAdapter(() => {createBLEConnection(item);});}, 1000);});
};// 关闭连接+关闭蓝牙模块
const closeBlueTooth = (item: any, callback: Function) => {// 关闭连接uni.closeBLEConnection({deviceId: item.deviceId,complete: () => {// 关闭蓝牙模块uni.closeBluetoothAdapter({complete: () => {callback();}});}});
};// 停止搜索
const stopBluetoothDevicesDiscovery = (callback: Function) => {uni.stopBluetoothDevicesDiscovery({complete: (e) => {callback();},fail: (e) => {console.log('停止搜索蓝牙设备失败,错误码:' + e.errCode);}});
};
// 后退
const navigateBack = () => {uni.navigateBack({delta: 1,fail: () => {uni.reLaunch({url: '/pages/home/home'});}});
};
http://www.tj-hxxt.cn/news/50709.html

相关文章:

  • 在线做爰a视频网站黑科技引流工具
  • 做印量调查的网站外贸公司如何做推广
  • 山东网站备案注销建站服务
  • 政府英文网站建设seo 工具推荐
  • 网页设计规划书3000字合肥网站优化seo
  • 免费页面网站制作西安新站网站推广优化
  • 用模板怎么做网站惠城网站设计
  • 网站资讯如何做搭建网站基本步骤
  • 做一个营销网站农技推广
  • 网站建设套模板网站app开发公司
  • 深圳建立网站营销营销技巧有哪些
  • 做网站的公司如何运营今日国内新闻头条大事
  • 模板网站建设公司seo推广
  • 展示型外贸网站建设搜索引擎优化结果
  • 一级域名网站目前最靠谱的推广平台
  • wordpress防采集插件连云港网站seo
  • wordpress 改变url群排名优化软件
  • 网站小视频怎么做网站建网站建设网站
  • 郑州的电子商城网站建设长沙网站优化推广
  • 常用的建站工具有哪些拉新app推广平台
  • 做的比较好的b2b网站网站发帖推广平台
  • 做影视网站需要的软件推广的渠道和方法有哪些
  • 网页加速器怎么开seo外链技巧
  • 网站程序调试模式怎么做市场营销是做什么的
  • 九九建站-网站建设 网站推广 seo优化 seo培训抖音seo优化系统招商
  • 电子商务网站建设及推广方案论文备案查询
  • 网站建设用户调查济南seo优化
  • 西安网站建设最新案例个人域名注册流程
  • 哪个网站做清洁的活多引擎搜索优化
  • 建站63年来第一次闭站?北京站辟谣企业建站流程