[Window with BLE]Data receive
0、準備
bleakライブラリ[python]
https://bleak.readthedocs.io/en/latest/index.html
1.開始
コンピュータのBluetoothバージョンを確認
デバイスマネージャ->Bluetooth->コンピュータBluetoothデバイス->右クリックプロパティ->拡張->ファームウェアバージョン
デバイスマネージャ->Bluetooth->コンピュータBluetoothデバイス
ペアリングの装備まで出てきたようです.
確認lmp
バージョン:4.0以降
https://support.microsoft.com/ko-kr/windows/%EB%82%B4-pc-bluetooth-%EB%B2%84%EC%A0%84%EC%9D%80-%EB%AC%B4%EC%97%87%EC%9D%B8%EA%B0%80%EC%9A%94-f5d4cff7-c00d-337b-a642-d2d23b082793
2. scann
スキャン確認
https://bleak.readthedocs.io/en/latest/scanning.html
scannの例import asyncio
from bleak import BleakScanner
async def main():
devices = await BleakScanner.discover()
for d in devices:
print(d)
asyncio.run(main())
3. ble connect
paring
コンピュータのBluetoothバージョンを確認
デバイスマネージャ->Bluetooth->コンピュータBluetoothデバイス->右クリックプロパティ->拡張->ファームウェアバージョン
デバイスマネージャ->Bluetooth->コンピュータBluetoothデバイス
ペアリングの装備まで出てきたようです.


確認lmp
バージョン:4.0以降

https://support.microsoft.com/ko-kr/windows/%EB%82%B4-pc-bluetooth-%EB%B2%84%EC%A0%84%EC%9D%80-%EB%AC%B4%EC%97%87%EC%9D%B8%EA%B0%80%EC%9A%94-f5d4cff7-c00d-337b-a642-d2d23b082793
2. scann
スキャン確認
https://bleak.readthedocs.io/en/latest/scanning.html
scannの例import asyncio
from bleak import BleakScanner
async def main():
devices = await BleakScanner.discover()
for d in devices:
print(d)
asyncio.run(main())
3. ble connect
paring
import asyncio
from bleak import BleakScanner
async def main():
devices = await BleakScanner.discover()
for d in devices:
print(d)
asyncio.run(main())
paring
ペアデバイスによる
ペアリング後に下部にデバイスを表示


connect
https://bleak.readthedocs.io/en/latest/usage.html
接続例
import asyncio
from bleak import BleakClient
# 장비 address 작성
address = "--:--:--:--:--:--"
async def main(address):
client = BleakClient(address)
try:
await client.connect()
print("connect to " + client.address)
except Exception as e:
print(e)
finally:
await client.disconnect()
asyncio.run(main(address))
error:接続に失敗したエラー

解決策:Bluetoothホールの使用
ノートパソコン/コンピュータの基本的な内蔵Bluetoothチップのハングアップ現象
->ブルートゥース洞窟を利用してみましょう.いいですね.
4.受信データ
転送データを常に受信するにはnotify enableを設定する必要があります
notify and read
import asyncio
from bleak import BleakClient
address = "--:--:--:--:--:--"
#charateristic uuid
C_uuid = "00001524-1212-efde-1523-785feabcd123"
def callback(sender:int , data:bytearray):
pass
async def main(address):
client = BleakClient(address)
try:
#connect
await client.connect()
print("connect to " + client.address)
#notify
await client.start_notify(C_uuid,callback)
#read
while(True):
data = await client.read_gatt_char(C_uuid)
print(bytes(data))
except Exception as e:
print(e)
pass
finally:
await client.disconnect()
asyncio.run(main(address))
Reference
この問題について([Window with BLE]Data receive), 我々は、より多くの情報をここで見つけました
https://velog.io/@ksbpgsue21/BLE-개발일지-Window
テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol
import asyncio
from bleak import BleakClient
address = "--:--:--:--:--:--"
#charateristic uuid
C_uuid = "00001524-1212-efde-1523-785feabcd123"
def callback(sender:int , data:bytearray):
pass
async def main(address):
client = BleakClient(address)
try:
#connect
await client.connect()
print("connect to " + client.address)
#notify
await client.start_notify(C_uuid,callback)
#read
while(True):
data = await client.read_gatt_char(C_uuid)
print(bytes(data))
except Exception as e:
print(e)
pass
finally:
await client.disconnect()
asyncio.run(main(address))
Reference
この問題について([Window with BLE]Data receive), 我々は、より多くの情報をここで見つけました https://velog.io/@ksbpgsue21/BLE-개발일지-Windowテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol