簡體   English   中英

如何使用 Wireshark(反向工程藍牙設備)在 Web 藍牙中調用 writeValue

[英]How to call writeValue in Web Bluetooth with Wireshark (Reverse engineer bluetooth device)

我正在嘗試對藍牙設備進行逆向工程,以便我可以創建自己的可以與之通信的應用程序。

我已經設法從我的 Android 手機獲取藍牙日志,並且還能夠通過 web 連接到藍牙設備。

不幸的是,每當我嘗試向特征寫入值時,都會出現錯誤: bluetooth.html:1 Uncaught (in promise) DOMException: GATT operation failed for unknown reason.

在 Wireshark 中,我在寫請求中找到的值為: 0120030000000000

我如何在 Javascript 中發送這個? 我嘗試了以下方法,所有這些都不起作用:

characteristic.writeValue(0x0120030000000000)
characteristic.writeValue(new Uint16Array([0x0120030000000000]));
characteristic.writeValue(new Uint8Array([0x0120030000000000]));
characteristic.writeValue(new Uint16Array([0x0120030000000000]));
characteristic.writeValue(new TextEncoder("utf-16").encode(0x0120030000000000));

我知道原始值為 0120030000000000,如何通過 ArrayBuffer 發送它?

假設 Wireshark 已將數據編碼為十六進制,那么您應該像這樣創建一個Uint8Array

new Uint8Array([0x01, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00])

如果方便在程序中將此數據表示為字符串,那么您可以編寫一個 function 通過一次解析兩個字符的字符串來構建Uint8Array

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM