日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux 检测蓝牙 rssi,树莓派开发笔记(十一):蓝牙的使用,BlueZ协议(双树莓探测rssi并通过蓝牙互传获取的rssi信号强度)...

發(fā)布時間:2023/12/20 linux 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux 检测蓝牙 rssi,树莓派开发笔记(十一):蓝牙的使用,BlueZ协议(双树莓探测rssi并通过蓝牙互传获取的rssi信号强度)... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

若該文為原創(chuàng)文章,轉(zhuǎn)載請注明原文出處

長期持續(xù)帶來更多項目與技術(shù)分享,咨詢請加QQ:21497936、微信:yangsir198808

下一篇:敬請期待…

接下來介紹樹莓派藍牙模塊的開發(fā),使用的協(xié)議為bluez。

客戶端bob,服務(wù)器alice,探測兩方的rssi,并傳送給服務(wù)器alice

BlueZ是官方Linux Bluetooth棧,由主機控制接口(Host Control Interface,HCI)層、Bluetooth協(xié)議核心、邏輯鏈路控制和適配協(xié)議(Logical Link Control and Adaptation Protocol,L2CAP)、SCO 音頻層、其他 Bluetooth 服務(wù)、用戶空間后臺進程以及配置工具組成。

BlueZ由許多單獨的模塊組成:

藍牙內(nèi)核子系統(tǒng)核心

L2CAP和SCO音頻內(nèi)核層

RFCOMM,BNEP,CMTP和HIDP內(nèi)核實現(xiàn)

HCI UART,USB,PCMCIA和虛擬設(shè)備驅(qū)動程序

通用藍牙和SDP庫和守護程序

配置和測試實用程序

協(xié)議解碼和分析工具

sudo apt-get install bluez

hciconfig

sudo hciconfig hci0 up

sudo hciconfig iscan

(注意:不好用,顯示的都是mac地址,而且中文亂碼,周圍藍牙多,根本分不清楚)

bluetoothctl

power on/off

電腦上的藍牙,先打開:

sudo python3 -m pip install pybluez

# -*-coding: utf-8 -*-

from bluetooth import *

import sys

import time

import os

import struct

import bluetooth._bluetooth as bluez

import bluetooth

global hostRssi

os.system("bluetoothctl power on")

# 獲取服務(wù),通過uuid查找目標服務(wù)

#uuid = "63078d70-feb9-lle7-9812-dca90488bd22"

#os.system("bluetoothctl discoverable on")

dstuuid? = "11111111-1111-1111-1111-111111111111"

localuuid = "22222222-2222-2222-2222-222222222222"

print("本地服務(wù)器,搜索客戶端藍牙rssi")

...

data = client.recv(1024)

print (data)

client.close()

bluetooth_sock.close()

from bluetooth import *

import sys

import time

import os

import struct

import bluetooth._bluetooth as bluez

import bluetooth

global hostRssi

#開啟藍牙可見

os.system("bluetoothctl power on")

os.system("bluetoothctl discoverable on")

dstuuid? = "22222222-2222-2222-2222-222222222222"

localuuid = "11111111-1111-1111-1111-111111111111"

bluetooth_sock=BluetoothSocket(RFCOMM)

bluetooth_sock.bind(("",PORT_ANY))

bluetooth_sock.listen(1)

...

data = "server:" + str(hostRssi) + ", client:" + str(clientRssi)

...

sudo vim /lib/systemd/system/bluetooth.service

修改文件內(nèi)容

#ExecStart=/usr/lib/bluez5/bluetooth/bluetoothd

ExecStart=/usr/lib/bluez5/bluetooth/bluetoothd -E -C

&emso;&emso;然后重啟服務(wù)

sudo sdptool add SP

sudo systemctl daemon-reload

sudo systemctl restart bluetooth

sudo sdptool browse local

原因:由于藍牙不可見導(dǎo)致

下一篇:敬請期待…

若該文為原創(chuàng)文章,轉(zhuǎn)載請注明原文出處

總結(jié)

以上是生活随笔為你收集整理的linux 检测蓝牙 rssi,树莓派开发笔记(十一):蓝牙的使用,BlueZ协议(双树莓探测rssi并通过蓝牙互传获取的rssi信号强度)...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。