Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcf194de

Browse files
committed
add bluetooth scanner tutorial
1 parent676c674 commitcf194de

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
5555
-[How to Crack the Affine Cipher in Python](https://thepythoncode.com/article/how-to-crack-the-affine-cipher-in-python). ([code](ethical-hacking/crack-affine-cipher))
5656
-[How to Implement the Vigenère Cipher in Python](https://thepythoncode.com/article/implementing-the-vigenere-cipher-in-python). ([code](ethical-hacking/implement-vigenere-cipher))
5757
-[How to Generate Fake User Data in Python](https://thepythoncode.com/article/generate-fake-user-data-in-python). ([code](ethical-hacking/fake-user-data-generator))
58+
-[Bluetooth Device Scanning in Python](https://thepythoncode.com/article/build-a-bluetooth-scanner-in-python). ([code](ethical-hacking/bluetooth-scanner))
5859

5960
-###[Machine Learning](https://www.thepythoncode.com/topic/machine-learning)
6061
-###[Natural Language Processing](https://www.thepythoncode.com/topic/nlp)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#[Bluetooth Device Scanning in Python](https://thepythoncode.com/article/build-a-bluetooth-scanner-in-python)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Import bluetooth from the PyBluez module.
2+
importbluetooth
3+
4+
defscan_bluetooth_devices():
5+
try:
6+
# Discover Bluetooth devices with names and classes.
7+
discovered_devices=bluetooth.discover_devices(lookup_names=True,lookup_class=True)
8+
9+
# Display information about the scanning process.
10+
print('[!] Scanning for active devices...')
11+
print(f"[!] Found{len(discovered_devices)} Devices\n")
12+
13+
# Iterate through discovered devices and print their details.
14+
foraddr,name,device_classindiscovered_devices:
15+
print(f'[+] Name:{name}')
16+
print(f'[+] Address:{addr}')
17+
print(f'[+] Device Class:{device_class}\n')
18+
19+
exceptExceptionase:
20+
# Handle and display any exceptions that occur during device discovery.
21+
print(f"[ERROR] An error occurred:{e}")
22+
23+
24+
# Call the Bluetooth device scanning function when the script is run
25+
scan_bluetooth_devices()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pybluez2

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp