這篇文章將為大家詳細講解有關python中如何獲取藍牙設備類型,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
Python主要應用于:1、Web開發;2、數據科學研究;3、網絡爬蟲;4、嵌入式應用開發;5、游戲開發;6、桌面應用開發。
python 獲取藍牙設備類型
掃描藍牙設備獲取到的信息中,無法判斷掃描到的藍牙設備屬于什么類型的設備。
掃描藍牙信息使用的是python 里面的bluetooth模塊。
首先掃描出來的是這樣的信息
('74:60:FA:FD:FC:49','HUAWEI P30',5898764)
可根據5898764來判斷是什么藍牙設備。
收集了一些設備,可以成功的轉化為設備類型
def bt_device_type(device_type): if device_type == 5898764 or device_type == 'Android': return 'Android' if device_type == 7078144 or device_type == 'computer_ubuntu14': return 'computer_ubuntu14' if device_type == 786700 or device_type == 'computer_ubuntu16': return 'computer_ubuntu16' if device_type == 655620 or device_type == 'computer_windows': return 'computer_windows' if device_type == 2360324 or device_type == 'headset': return 'headset' #耳機 if device_type == 2360328 or device_type =='speaker': return 'speaker' # 擴音器 if device_type == 263208 or device_type == 'SV': return 'SV' #藍牙音響 if device_type == 7995916 or device_type == 'phone': return 'phone' #蘋果設備 if device_type == 3670284 or device_type == 'MACBook': return 'MACBook' if device_type == 7936 or device_type == 2752780 or device_type == 'PC': return 'PC' if device_type == 6947088 or device_type == 'iPad': return 'iPad' return 'unknown'
關于“python中如何獲取藍牙設備類型”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。