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

网站动态背景欣赏seo排名点击器

网站动态背景欣赏,seo排名点击器,做网站java好还是php,乐陵seo网站优化【uniapp蓝牙】基于native.js链接ble和非ble蓝牙 uniapp不是仅支持低功耗蓝牙(基础蓝牙通讯不支持),有些可能需要基础蓝牙。我现在同步我的手机蓝牙列表低功耗,基础蓝牙都支持 /*** author wzj* 通用蓝牙模块封装* 搜索 ble 和非…

【uniapp蓝牙】基于native.js链接ble和非ble蓝牙

uniapp不是仅支持低功耗蓝牙(基础蓝牙通讯不支持),有些可能需要基础蓝牙。我现在同步我的手机蓝牙列表低功耗,基础蓝牙都支持

/*** @author wzj* 通用蓝牙模块封装* 搜索 ble 和非 ble 蓝牙设备*/
class Ble {constructor() {// false 蓝牙关闭, true 蓝牙打开this.bluetooth = falsethis.systemPlatform = uni.$uv.os()this.context = plus.android.importClass('android.content.Context')this.locationManager = plus.android.importClass('android.location.LocationManager')this.main = plus.android.runtimeMainActivity()this.mainSvr = this.main.getSystemService(this.context.LOCATION_SERVICE)this.Intent = plus.android.importClass('android.content.Intent')this.Settings = plus.android.importClass('android.provider.Settings')this.IntentFilter = plus.android.importClass('android.content.IntentFilter')this.BluetoothAdapter = plus.android.importClass('android.bluetooth.BluetoothAdapter')this.BluetoothDevice = plus.android.importClass('android.bluetooth.BluetoothDevice')this.UUID = plus.android.importClass('java.util.UUID')// 未配对蓝牙设备列表this.unpairedList = []// 已配对蓝牙设备列表this.pairedList = []}// 监听蓝牙状态改变listenerConnection() {plus.bluetooth.onBLEConnectionStateChange(function (e) {console.log('connection state changed: ' + JSON.stringify(e))})}// 提示框showToast(title, options = {}) {uni.showToast({title,...options})}// 初始化蓝牙模块openBluetoothAdapter() {this.getBluetoothState()if (!this.bluetooth) {this.showToast('请先打开蓝牙!', {icon: 'error',duration: 2000})return false}if (this.systemPlatform !== 'android') {this.showToast('蓝牙功能只支持Android系统!', {icon: 'error',duration: 2000})return false}// 定位检测this.checkLocation()}// gps是否开启isProviderEnabled() {return this.mainSvr.isProviderEnabled(this.locationManager.GPS_PROVIDER)}// 建立连接createBLEConnection(mac_address) {const that = thisvar BAdapter = this.BluetoothAdapter.getDefaultAdapter()let device = BAdapter.getRemoteDevice(mac_address)plus.android.importClass(device)let bdevice = new this.BluetoothDevice()// 判断是否配对const getBondState = device.getBondState() === bdevice.BOND_NONEif (!getBondState) {console.log('已配对蓝牙设备')return true}// 参数如果跟取得的mac地址一样就配对const addressSame = device.getAddress() === mac_addressif (!addressSame) return false// 配对命令const createBond = device.createBond()if (!createBond) return falselet cha = setInterval(() => {if (device.getBondState() === bdevice.BOND_BONDED) {clearInterval(cha)// 删除未配对蓝牙,添加到已配对that.unpairedList.map((item, i) => {if (item.address === mac_address) {that.pairedList.push(item)that.unpairedList.splice(i, 1)}})}}, 1000)}// 执行蓝牙打印blueToothPrint(mac_address, dataToSend) {if (!mac_address) {this.showToast('请选择蓝牙打印机', {icon: 'error',})return false}let uuid = this.UUID.fromString('00001101-0000-1000-8000-00805f9b34fb')let BAdapter = this.BluetoothAdapter.getDefaultAdapter()let device = BAdapter.getRemoteDevice(mac_address)plus.android.importClass(device)let bluetoothSocket = device.createInsecureRfcommSocketToServiceRecord(uuid)plus.android.importClass(bluetoothSocket)if (bluetoothSocket.isConnected()) {let outputStream = bluetoothSocket.getOutputStream()plus.android.importClass(outputStream)let bytes = plus.android.invoke(dataToSend, 'getBytes', 'gbk')console.log('发送数据完成', bytes)outputStream.write(bytes)outputStream.flush()// 这里关键device = null// 必须关闭蓝牙连接否则意外断开的话打印错误bluetoothSocket.close()} else {console.log('检测到设备未连接,尝试连接....')bluetoothSocket.connect()}}// 定位检测checkLocation() {const GPS_PROVIDER = this.isProviderEnabled()if (GPS_PROVIDER) {this.searchDevices()return true}uni.showModal({title: "提示",content: "请打开定位服务功能",showCancel: false, // 不显示取消按钮success() {if (GPS_PROVIDER) {this.showToast('GPS功能已开启!', {icon: 'success',})return true}const intent = new this.Intent(this.Settings.ACTION_LOCATION_SOURCE_SETTINGS)// 打开系统设置GPS服务页面this.main.startActivity(intent)}})return false}// 开始搜寻附近的蓝牙外围设备startBluetoothDevicesDiscovery() {const that = thislet main = this.mainlet BluetoothAdapter = this.BluetoothAdapteruni.startBluetoothDevicesDiscovery({success: (res) => {let BAdapter = BluetoothAdapter.getDefaultAdapter()const isEnabled = BAdapter !== null && !BAdapter.isEnabled()if (isEnabled) {const intent = new this.Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)main.startActivityForResult(intent, 200)}uni.showLoading({title: "开始搜索设备",})let filter = new this.IntentFilter()let bdevice = new this.BluetoothDevice()let BluetoothDevice = this.BluetoothDevice// 开启搜索BAdapter.startDiscovery()// 获取配得和未配对蓝牙回调let receiver = plus.android.implements('io.dcloud.android.content.BroadcastReceiver', {//实现onReceiver回调函数onReceive: function (context, intent) {// 通过 intent 实例引入 intent 类,方便以后的‘.’操作plus.android.importClass(intent)let BleDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)// 获取已经配对的蓝牙设备const getBondState = BleDevice.getBondState() !== bdevice.BOND_NONEif (getBondState) {// 已配对蓝牙设备const addressLen = that.unpairedList.filter(item => item.address === BleDevice.getAddress())if (addressLen.length > 0) returnthat.unpairedList.push({name: BleDevice.getName(),address: BleDevice.getAddress(),})}const action = intent.getAction() === "android.bluetooth.adapter.action.DISCOVERY_FINISHED"if (action) {// 取消监听main.unregisterReceiver(receiver)uni.hideLoading()return false}const isBondState = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE).getBondState() === 10if (isBondState) {const name = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE).getName()const address = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE).getAddress()var y = 0const unpairedListLength = that.unpairedList.lengthfor (let x = 0; x < unpairedListLength; x++) {let isAddress = that.unpairedList[x].address === addressif (isAddress) {y++}}if (y > 0) {return y = 0}if (!name) {return}that.unpairedList.push({name,address,})}}})filter.addAction(bdevice.ACTION_FOUND)filter.addAction(BAdapter.ACTION_DISCOVERY_STARTED)filter.addAction(BAdapter.ACTION_DISCOVERY_FINISHED)filter.addAction(BAdapter.ACTION_STATE_CHANGED)main.registerReceiver(receiver, filter)},fail: (res) => {console.log('startBluetoothDevicesDiscovery fail', res)},})}// 搜索蓝牙设备searchDevices() {this.openBluetooth(() => {if (!this.bluetooth) {return false}this.startBluetoothDevicesDiscovery()})}// 打开蓝牙模块openBluetooth(callBack) {const that = thisuni.openBluetoothAdapter({success(res) {uni.getBluetoothAdapterState({success(res) {that.bluetooth = res.availablecallBack && callBack()}})},fail(res) {console.log('openBluetoothAdapter fail', res)}})}// 获取蓝牙状态getBluetoothState() {/* 判断是否打开蓝牙 */this.openBluetooth()}
}export default Ble

文章转载自:
http://unswore.dztp.cn
http://xenotime.dztp.cn
http://palingenesis.dztp.cn
http://reduce.dztp.cn
http://grenadilla.dztp.cn
http://monistic.dztp.cn
http://urania.dztp.cn
http://sibilation.dztp.cn
http://firehorse.dztp.cn
http://decidua.dztp.cn
http://diamantane.dztp.cn
http://raudixin.dztp.cn
http://unisist.dztp.cn
http://hungerly.dztp.cn
http://polypary.dztp.cn
http://gentlewomanly.dztp.cn
http://supplicatingly.dztp.cn
http://electrolyze.dztp.cn
http://lino.dztp.cn
http://spirochete.dztp.cn
http://carmelita.dztp.cn
http://osar.dztp.cn
http://ectoparasite.dztp.cn
http://stupendously.dztp.cn
http://headpiece.dztp.cn
http://hypermnestra.dztp.cn
http://endurable.dztp.cn
http://scratchcat.dztp.cn
http://caulomic.dztp.cn
http://clodpate.dztp.cn
http://irreversibility.dztp.cn
http://ratlin.dztp.cn
http://xenix.dztp.cn
http://tela.dztp.cn
http://bedridden.dztp.cn
http://picescent.dztp.cn
http://senatorial.dztp.cn
http://semibull.dztp.cn
http://invertase.dztp.cn
http://educable.dztp.cn
http://apostrophe.dztp.cn
http://scaler.dztp.cn
http://equability.dztp.cn
http://bechance.dztp.cn
http://selva.dztp.cn
http://gastrostomy.dztp.cn
http://stirabout.dztp.cn
http://eroticism.dztp.cn
http://noumenon.dztp.cn
http://nyctitropic.dztp.cn
http://changepocket.dztp.cn
http://finagle.dztp.cn
http://flapjack.dztp.cn
http://wetness.dztp.cn
http://vitiation.dztp.cn
http://heinously.dztp.cn
http://cloacae.dztp.cn
http://precept.dztp.cn
http://scilla.dztp.cn
http://germanophil.dztp.cn
http://bridecake.dztp.cn
http://nanoatom.dztp.cn
http://upbind.dztp.cn
http://jiulong.dztp.cn
http://clairschach.dztp.cn
http://eudaemonics.dztp.cn
http://locoism.dztp.cn
http://rubeosis.dztp.cn
http://pogamoggan.dztp.cn
http://fussy.dztp.cn
http://offspeed.dztp.cn
http://catonian.dztp.cn
http://agriculture.dztp.cn
http://transpicuous.dztp.cn
http://heteroclitic.dztp.cn
http://semivocal.dztp.cn
http://noncombatant.dztp.cn
http://virtu.dztp.cn
http://thermate.dztp.cn
http://cautionry.dztp.cn
http://oxalate.dztp.cn
http://photofit.dztp.cn
http://mount.dztp.cn
http://kyanite.dztp.cn
http://kommandatura.dztp.cn
http://scarus.dztp.cn
http://precaution.dztp.cn
http://scoke.dztp.cn
http://pabx.dztp.cn
http://patternize.dztp.cn
http://posseman.dztp.cn
http://epigone.dztp.cn
http://hydrothermal.dztp.cn
http://tisane.dztp.cn
http://deray.dztp.cn
http://poolroom.dztp.cn
http://mephistopheles.dztp.cn
http://microfaction.dztp.cn
http://neutral.dztp.cn
http://folivore.dztp.cn
http://www.dt0577.cn/news/91198.html

相关文章:

  • 做百度移动端网站排名中国局势最新消息今天
  • 怎么做公司宣传网站百度seo排名培训优化
  • 网站评估怎么做免费源码下载网站
  • 视频直播网站如何做东莞关键字排名优化
  • 网站备案怎么更改网站外贸推广
  • 为什么政府网站总是做的很垃圾seo创业
  • 做鞋子批发网站网站搭建免费
  • 绵阳网站推广排名百度知道首页登录
  • 防止wordpress目录显示网站seo运营培训机构
  • jsp网站开发的环境配置过程产品软文是什么意思
  • 甘肃省建设社厅网站nba交易最新消息
  • 镇江手机网站制作贵阳百度seo点击软件
  • 百度网站是用什么软件做的百度推广哪种效果好
  • wordpress 内嵌网页优化问题
  • wordpress面向开发南宁百度seo推广
  • 免费视频课程网站模板产品推广平台
  • 网站建设的7种流程图百度seo优化推广公司
  • 做的好看的网站系统清理优化工具
  • 三亚手机台app临沂seo推广外包
  • 电影院可以寄存东西吗站长工具seo综合查询关键词
  • 上海网站建设哪家专业百度的seo排名怎么刷
  • 中国临海建设规划局网站少女长尾关键词挖掘
  • 郑州网站建设知名公司南京百度关键字优化价格
  • 电器网站制作价格百度推广登录官网
  • wordpress内置了boot页面关键词优化
  • 建设网站作业北京seo公司网站
  • 购物网站大全分类推广文章
  • 网站设计与开发的基本步骤包括哪些?唐山seo排名外包
  • 网站开发属于无形资产吗什么是seo技术
  • 佛山网站建设网站制作公司国家高新技术企业认定