ubuntu查看蓝牙设备

ubuntu查看蓝牙设备,第1张

1、插入硬件,打开终端,查看是否检测到设备

2、查看是否识别为蓝牙模块

3、查看蓝牙模块的地址;如果不显示蓝牙模块及其地址,则需要通过rfkilllist命令查看hci0是否blocked,使用rfkillunblock0(rfkilllist显示的hci0的序号)即可启用蓝牙模块(hci0)。

4、激活蓝牙模块。

5、此次测试设置蓝牙模块为服务端且不需要配对码。

6、hciconfig和hcitool(BlueZ提供的工具,BlueZ是多数Linux发行版的默认蓝牙协议栈)可以实现搜索、连接等功能,此处主要希望通过编程控制蓝牙模块,故对此暂时不做深究。

//初始化蓝牙

initBlue() {

var that = this;

wxopenBluetoothAdapter({ //调用微信小程序api 打开蓝牙适配器接口

success: function (res) {

consolelog('1初始化蓝牙成功')

},

//监听手机蓝牙的开关

monitorTheBlue:function(){

var that =this;

wxonBluetoothAdapterStateChange(function(res){

})

},

//开始获取附近的蓝牙设备

// 获取到附近的蓝牙数组 通过蓝牙特定的名称获取自己想要连接的蓝牙设备

// 获取附近蓝牙设备的数组

findBlue() {

consolelog(new Date())

var that = this

wxstartBluetoothDevicesDiscovery({

allowDuplicatesKey: false,

interval: 0,

success: function (res) {

consolelog('2正在搜索设备')

if (thatdataisFirestShow) {

wxshowLoading({

title: '正在搜索设备'

})

}

},

//搜索获取附近的所有蓝牙设备 获取附近所有的蓝牙设备的相关信息 获取需要连接蓝牙设备的deviceID

// 通过bluetoothDeviceName 和 localName 来确定制定蓝牙

// 一般根据制定设备的名字去连接 设备的名字 是出产厂家设定

getBlue() {

var that = this

wxgetBluetoothDevices({

success: function (res) {

consolelog('3找到设备列表')

wxhideLoading()

// return false

var index = 10

for (var i = 0; i < resdeviceslength; i++) {

if (resdevices[i]name && resdevices[i]localName) {

var arr = resdevices[i]namesplit("-")

var secArr = resdevices[i]localNamesplit("-")

if (arr[0] == thatdatabluetoothDeviceName || secArr[0] == thatdatabluetoothDeviceName) {

},

//连接蓝牙设备

//通过deviceId 连接蓝牙

/

},

//6 连接上需要的蓝牙设备之后,获取这个蓝牙设备的服务uuid

//获取设备的uuid

getServiceId() {

var that = this

wxgetBLEDeviceServices({

// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接

deviceId: thatdatadeviceId,

success: function (res) {

var model = resservices[1]

thatsetData({

servicesUUID: modeluuid

})

consolelog('7获取设备 uuid 成功')

thatgetCharacteId() //60

}

})

},

//7 如果一个蓝牙设备需要进行数据的写入以及数据传输,就必须具有某些特征值,所以通过上面步骤获取的id可以查看当前蓝牙设备的特征值

//notify write read 当只有 notify为true的时候才能 接收蓝牙设备传来的数据,

//write 为true 才能传入数据

//read 为true 才能读取设备数据

getCharacteId() {

var that = this

wxgetBLEDeviceCharacteristics({

// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接

deviceId: thatdatadeviceId,

// 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取

serviceId: thatdataservicesUUID,

success: function (res) {

for (var i = 0; i < rescharacteristicslength; i++) { //2个值

var model = rescharacteristics[i]

if (modelpropertiesnotify == true) {

thatsetData({

characteristicId: modeluuid //监听的值

})

consolelog('8modelpropertiesnotify == true')

thatstartNotice(modeluuid) //70

}

// if (modelpropertiesread == true) {

// thatreadData(modeluuid)

// }

// if (modelpropertieswrite == true) {

// thatsetData({

// writeId: modeluuid//用来写入的值

// })

// }

}

}

})

},

fordateTime1(){

let now = new Date(),hour = nowgetHours()

consolelog(hour)

let str = ''

if(hour < 7){str = '早餐前'}

else if ((7< hour) && (hour<= 9)){str = '早餐后'}

else if ((9< hour) && (hour<= 11)){str = '午餐前'}

else if ((11< hour) && (hour<= 13)){str = '午餐后'}

else if ((13< hour) && (hour<= 17)){str = '晚餐前'}

else if ((17< hour) && (hour<= 19)){str = '晚餐后'}

else if ((19< hour) && (hour<= 24)){str = '睡觉前'}

return str

},

//8 如果一个蓝牙设备需要进行数据的写入以及数据传输,就必须具有某些特征值,所以通过上面步骤获取的id可以查看当前蓝牙设备的特征值

//开启设备数据监听 监听蓝牙设备返回来的数据

startNotice(uuid) {

var that = this;

wxnotifyBLECharacteristicValueChanged({

state: true, // 启用 notify 功能

deviceId: thatdatadeviceId,

serviceId: thatdataservicesUUID,

characteristicId: uuid, //第一步 开启监听 notityid 第二步发送指令 write

success: function (res) {

// thatcloseConnect(thatdatadeviceId)

// 设备返回的方法

let tip = 0

wxonBLECharacteristicValueChange(res1 => {

},

/

//监听蓝牙设备是否会异常断开

getTheBlueDisConnectWithAccident() {

},

// 断开设备连接

closeConnect: function(v) {

var that = this

if (v) {

wxcloseBLEConnection({

deviceId: v,

success: function(res) {

consolelog("蓝牙断开连接")

thatcloseBluetoothAdapter()

},

fail(res) {

}

})

} else {

thatcloseBluetoothAdapter()

}

},

// 关闭蓝牙模块

closeBluetoothAdapter:function () {

wxcloseBluetoothAdapter({

success: function(res) {

consolelog("关闭蓝牙模块")

},

fail: function(err) {

}

})

},

没有那个设备。根据查询ubuntu相关资料得知,ubuntu获取接口标志时出错是因为没有那个设备。Ubuntu是一个以桌面应用为主的Linux *** 作系统,其名称来自非洲南部祖鲁语或豪萨语的“ubuntu”一词,意思是“人道待人”。

ubuntu2004 安装虚拟,将一个定制化的系统移植到虚拟机

1安装必要的软件包

其它用的一些常用工具,比如ifconfig,如果需要,自行安装。

而且上面的这些包的安装或安装很多依赖包。

2 配置桥接网络

要移植的系统不能以nat方式,要以暴露在局域网,做一个普通的终端节点。

netplan的yaml文件配置示例:

将要桥接的网卡放在bridges里。

将两个虚拟网卡桥接到br0的相关的物理网卡上

3 创建虚拟磁盘

4 通过iso安装系统

需要重时候,重写启动qemu, 去掉-cdrom选项即可

5 启动虚拟机

三块磁盘,两块网卡,8G内存。注意网卡的写法,使用了刚建立的两个桥接网卡设备。

6 编辑qcow2镜像文件

安装工具包

这里如果不知道有哪些分区可以,直接是使用sda,出错信息里会有提示有那几个分区可用。当然guestmount可用只读挂载。

dd的img文件挂载方式:

这里的offset=startsector sectorsize, 通过fdisk获得这些信息

7 至此,能够编辑镜像,就可以定制系统,或者用已定制文件系统挺好已经安装的系统。

这样做的好处是保证grub已经正确安装,不用折腾怎么在空虚拟磁盘安装引导程序了。

替换文件系统两个要点:

a,grub引导现在大都以uuid方式进行,确保元系统的grub部分和相关内核、内核模块不要被删除

b,/etc/fstab文件要使用原理文件系统的,不要替换;或者你用设备节点名替换uuid=“xxx”

以上就是关于ubuntu查看蓝牙设备全部的内容,包括:ubuntu查看蓝牙设备、小程序 蓝牙连接、ubuntu获取接口标志时出错等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/9554071.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-29
下一篇 2023-04-29

发表评论

登录后才能评论

评论列表(0条)

保存