{"id":1519,"date":"2026-01-31T04:27:10","date_gmt":"2026-01-31T04:27:10","guid":{"rendered":"https:\/\/robinluo.top\/?p=1519"},"modified":"2026-01-31T04:33:49","modified_gmt":"2026-01-31T04:33:49","slug":"%e9%a6%99%e6%a9%99%e6%b4%beble%e8%93%9d%e7%89%99-python","status":"publish","type":"post","link":"https:\/\/robinluo.top\/?p=1519","title":{"rendered":"\u9999\u6a59\u6d3eble\u84dd\u7259 python"},"content":{"rendered":"\n<p>\u5b89\u88c5\u4f9d\u8d56\u5305<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get update\r\nsudo apt-get install bluetooth bluez libbluetooth-dev libusb-dev libdbus-1-dev\r\n<\/code><\/pre>\n\n\n\n<p>\u786e\u4fdd\u84dd\u7259\u5f00\u542f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable bluetooth\r\nsudo systemctl start bluetooth\r<\/code><\/pre>\n\n\n\n<p>bluetoothctl \u662f\u4e00\u4e2a\u70b9\u5bf9\u70b9\u84dd\u7259\u63a7\u5236\u5de5\u5177<\/p>\n\n\n\n<p>gatttool \u662f\u4e00\u4e2able\u84dd\u7259\u63a7\u5236\u5de5\u5177<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install bluez-tools\r\ngatttool -b &lt;\u8bbe\u5907\u5730\u5740> --interactive\r<\/code><\/pre>\n\n\n\n<p> python \u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install python3-pip\r\npip3 install bluepy\r<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>from bluepy.btle import Scanner, DefaultDelegate\r\nimport time\r\n\r\nclass ScanDelegate(DefaultDelegate):\r\n    def handleDiscovery(self, dev, isNewDev, isNewData):\r\n        if isNewDev:\r\n            print(\"Discovered device\")\r\n            print(\"  Device %s (%s), RSSI=%d dB\" % (dev.addr, dev.addrType, dev.rssi))\r\n        elif isNewData:\r\n            print(\"  Updated data: %s\" % dev.scanData)\r\n            print(\"  Manufacturer data: %s\" % dev.manufacturerData)        # Optional: manufacturer data if available. 0x0000FFFF is the default for BLE devices. 0xFFFF is the default for Beacons. 0x004C is the default for iBeacons. 0x0215 is the default for AltBeacons. 0x0242 is the default for Estimote beacons. 0x0015 is the default for Eddystone beacons. 0x02AA is the default for Apple beacons. 0x0118 is the default for Samsung beacons. 0x02AA is the default for Apple beacons. 0x0118 is the default for Samsung beacons. 0x02AA is the default for Apple beacons. 0x0118 is the default for Samsung beacons. 0x02AA is the default for Apple beacons. 0x0118 is the default for Samsung beacons. 0x02AA is the default for Apple beacons. 0x0118 is the default for Samsung beacons. 0x02AA is the default for Apple beacons. 0x0118 is the default for Samsung\r\n<\/code><\/pre>\n\n\n\n<p>\u76f8\u5173\u94fe\u63a5<\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/weixin_30598047\/article\/details\/156319564\">https:\/\/blog.csdn.net\/weixin_30598047\/article\/details\/156319564<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5\u4f9d\u8d56\u5305 \u786e\u4fdd\u84dd\u7259\u5f00\u542f bluetoothctl \u662f\u4e00\u4e2a\u70b9\u5bf9\u70b9\u84dd\u7259\u63a7\u5236\u5de5\u5177 gatttool \u662f\u4e00\u4e2able\u84dd\u7259\u63a7\u5236\u5de5\u5177 python \u4ee3\u7801\uff1a \u76f8\u5173\u94fe\u63a5 https:\/\/blog.csdn.net\/weixin_30598047\/article\/details\/156319564<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[127,160],"_links":{"self":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/1519"}],"collection":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1519"}],"version-history":[{"count":2,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/1519\/revisions"}],"predecessor-version":[{"id":1521,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/1519\/revisions\/1521"}],"wp:attachment":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}