{"id":4709,"date":"2021-09-03T11:38:40","date_gmt":"2021-09-03T03:38:40","guid":{"rendered":"http:\/\/122.152.205.50\/wordpress\/?p=4709"},"modified":"2025-08-14T17:57:44","modified_gmt":"2025-08-14T09:57:44","slug":"ble%e5%ae%a2%e6%88%b7%e7%ab%af%e8%93%9d%e7%89%99%e5%bc%80%e5%8f%91%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709","title":{"rendered":"BLE\u5ba2\u6237\u7aef\u84dd\u7259\u5f00\u53d1\u8be6\u89e3"},"content":{"rendered":"<p>\u5173\u4e8e\u84dd\u7259\u7684\u5404\u79cd\u6982\u5ff5\uff0c\u4e0d\u592a\u719f\u6089\u7684\uff0c\u53ef\u4ee5\u770b\u6211\u768451CTO\u7684\u535a\u5ba2<a href=\"https:\/\/blog.51cto.com\/4259297\/1959736\">https:\/\/blog.51cto.com\/4259297\/1959736<\/a>\uff0c\u4e0a\u9762\u7684\u6587\u7ae0\u7eaf\u7cb9\u662f\u505a\u7b14\u8bb0\u7528\uff0c\u6709\u70b9\u6742\u4e71\uff0c\u8fd9\u91cc\u4f5c\u4e00\u4e0b\u7cfb\u7edf\u7684\u68b3\u7406\u3002<\/p>\n<p>\u7f51\u4e0a\u627e\u7684\u4e00\u4e9b\u6bd4\u8f83\u597d\u7684\u535a\u5ba2\uff1a<br \/>\n<a href=\"https:\/\/www.jianshu.com\/p\/f20327b40268\">https:\/\/www.jianshu.com\/p\/f20327b40268<\/a><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_16 counter-hierarchy counter-decimal ez-toc-grey\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/a><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-1\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%AE%9E%E7%8E%B0\" title=\"\u5ba2\u6237\u7aef\u5b9e\u73b0\">\u5ba2\u6237\u7aef\u5b9e\u73b0<\/a><ul class=\"ez-toc-list-level-2\"><li class=\"ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#%E7%AC%AC1%E6%AD%A5%EF%BC%9A%E8%93%9D%E7%89%99%E5%88%9D%E5%A7%8B%E5%8C%96%E7%8E%AF%E5%A2%83%E5%88%A4%E6%96%AD\" title=\"\u7b2c1\u6b65\uff1a\u84dd\u7259\u521d\u59cb\u5316\u73af\u5883\u5224\u65ad\">\u7b2c1\u6b65\uff1a\u84dd\u7259\u521d\u59cb\u5316\u73af\u5883\u5224\u65ad<\/a><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#1%E5%88%A4%E6%96%ADandroid%E7%B3%BB%E7%BB%9F%E6%98%AF%E5%90%A6%E6%94%AF%E6%8C%81%E8%93%9D%E7%89%99\" title=\"1.\u5224\u65adandroid\u7cfb\u7edf\u662f\u5426\u652f\u6301\u84dd\u7259\">1.\u5224\u65adandroid\u7cfb\u7edf\u662f\u5426\u652f\u6301\u84dd\u7259<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#2%E6%89%93%E5%BC%80%E7%B3%BB%E7%BB%9F%E7%9A%84%E8%93%9D%E7%89%99%E5%BC%80%E5%85%B3\" title=\"2.\u6253\u5f00\u7cfb\u7edf\u7684\u84dd\u7259\u5f00\u5173\">2.\u6253\u5f00\u7cfb\u7edf\u7684\u84dd\u7259\u5f00\u5173<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#%E7%AC%AC2%E6%AD%A5%EF%BC%9A%E6%89%AB%E6%8F%8F%E8%BF%9E%E6%8E%A5%E8%93%9D%E7%89%99\" title=\"\u7b2c2\u6b65\uff1a\u626b\u63cf\u8fde\u63a5\u84dd\u7259\">\u7b2c2\u6b65\uff1a\u626b\u63cf\u8fde\u63a5\u84dd\u7259<\/a><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#1%E6%89%AB%E6%8F%8F%E5%A4%96%E5%9B%B4%E8%93%9D%E7%89%99%E8%AE%BE%E5%A4%87\" title=\"1.\u626b\u63cf\u5916\u56f4\u84dd\u7259\u8bbe\u5907\">1.\u626b\u63cf\u5916\u56f4\u84dd\u7259\u8bbe\u5907<\/a><ul class=\"ez-toc-list-level-6\"><li class=\"ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-7\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#1%E5%AE%9A%E4%BD%8D%E6%9D%83%E9%99%90%E7%94%B3%E8%AF%B7\" title=\"1)\u5b9a\u4f4d\u6743\u9650\u7533\u8bf7\">1)\u5b9a\u4f4d\u6743\u9650\u7533\u8bf7<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-8\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#2%E6%89%93%E5%BC%80%E5%AE%9A%E4%BD%8D%E5%BC%80%E5%85%B3\" title=\"2)\u6253\u5f00\u5b9a\u4f4d\u5f00\u5173\">2)\u6253\u5f00\u5b9a\u4f4d\u5f00\u5173<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-9\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#3%E5%BC%80%E5%A7%8B%E6%89%AB%E6%8F%8F%E8%93%9D%E7%89%99\" title=\"3)\u5f00\u59cb\u626b\u63cf\u84dd\u7259\">3)\u5f00\u59cb\u626b\u63cf\u84dd\u7259<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-10\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#%E5%BC%80%E5%A7%8B%E6%89%AB%E6%8F%8F\" title=\"\u5f00\u59cb\u626b\u63cf\">\u5f00\u59cb\u626b\u63cf<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-11\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#%E5%81%9C%E6%AD%A2%E6%89%AB%E6%8F%8F\" title=\"\u505c\u6b62\u626b\u63cf\">\u505c\u6b62\u626b\u63cf<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-12\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#%E6%89%AB%E6%8F%8F%E5%9B%9E%E8%B0%83\" title=\"\u626b\u63cf\u56de\u8c03\">\u626b\u63cf\u56de\u8c03<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-13\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#2%E8%BF%9E%E6%8E%A5%E8%93%9D%E7%89%99\" title=\"2.\u8fde\u63a5\u84dd\u7259\">2.\u8fde\u63a5\u84dd\u7259<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-14\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#%E7%AC%AC3%E6%AD%A5%EF%BC%9ABLE%E6%A0%B8%E5%BF%83%E6%93%8D%E4%BD%9C\" title=\"\u7b2c3\u6b65\uff1aBLE\u6838\u5fc3\u64cd\u4f5c\">\u7b2c3\u6b65\uff1aBLE\u6838\u5fc3\u64cd\u4f5c<\/a><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-15\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#1%E5%8F%91%E7%8E%B0%E6%9C%8D%E5%8A%A1\" title=\"1.\u53d1\u73b0\u670d\u52a1\">1.\u53d1\u73b0\u670d\u52a1<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-16\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#2%E9%81%8D%E5%8E%86%E6%9C%8D%E5%8A%A1%E7%89%B9%E5%BE%81%E5%80%BC\" title=\"2.\u904d\u5386\u670d\u52a1\u7279\u5f81\u503c\">2.\u904d\u5386\u670d\u52a1\u7279\u5f81\u503c<\/a><ul class=\"ez-toc-list-level-6\"><li class=\"ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-17\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#1%E8%8E%B7%E5%8F%96%E6%9C%8D%E5%8A%A1\" title=\"1)\u83b7\u53d6\u670d\u52a1\">1)\u83b7\u53d6\u670d\u52a1<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-18\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#2%E9%81%8D%E5%8E%86%E6%9C%8D%E5%8A%A1%E7%9A%84%E7%89%B9%E5%BE%81%E5%80%BC\" title=\"2)\u904d\u5386\u670d\u52a1\u7684\u7279\u5f81\u503c\">2)\u904d\u5386\u670d\u52a1\u7684\u7279\u5f81\u503c<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-19\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#3%E5%88%A4%E6%96%AD%E7%89%B9%E5%BE%81%E5%80%BC%E7%9A%84%E5%B1%9E%E6%80%A7\" title=\"3)\u5224\u65ad\u7279\u5f81\u503c\u7684\u5c5e\u6027\">3)\u5224\u65ad\u7279\u5f81\u503c\u7684\u5c5e\u6027<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-20\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#3%E7%89%B9%E5%BE%81%E5%80%BC%E6%93%8D%E4%BD%9C\" title=\"3.\u7279\u5f81\u503c\u64cd\u4f5c\">3.\u7279\u5f81\u503c\u64cd\u4f5c<\/a><ul class=\"ez-toc-list-level-6\"><li class=\"ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-21\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#1%E8%AF%BB%E5%8F%96%E7%89%B9%E5%BE%81%E5%80%BC\" title=\"1)\u8bfb\u53d6\u7279\u5f81\u503c\">1)\u8bfb\u53d6\u7279\u5f81\u503c<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-22\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#2%E5%86%99%E7%89%B9%E5%BE%81%E5%80%BC\" title=\"2)\u5199\u7279\u5f81\u503c\">2)\u5199\u7279\u5f81\u503c<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-23\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#3%E6%89%93%E5%BC%80%E6%88%96%E8%80%85%E5%85%B3%E9%97%ADnotifyindicate%E5%BC%80%E5%85%B3\" title=\"3)\u6253\u5f00\u6216\u8005\u5173\u95ednotify\/indicate\u5f00\u5173\">3)\u6253\u5f00\u6216\u8005\u5173\u95ednotify\/indicate\u5f00\u5173<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-6\"><a class=\"ez-toc-link ez-toc-heading-24\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#4%E7%9B%91%E5%90%AC%E7%89%B9%E5%BE%81%E5%80%BC%E5%8F%98%E5%8C%96\" title=\"4)\u76d1\u542c\u7279\u5f81\u503c\u53d8\u5316\">4)\u76d1\u542c\u7279\u5f81\u503c\u53d8\u5316<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-25\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#%E7%AC%AC4%E6%AD%A5%EF%BC%9A%E5%A4%9A%E4%B8%AA%E5%A4%96%E5%9B%B4%E8%AE%BE%E5%A4%87%E7%9A%84%E5%B0%81%E8%A3%85\" title=\"\u7b2c4\u6b65\uff1a\u591a\u4e2a\u5916\u56f4\u8bbe\u5907\u7684\u5c01\u88c5\">\u7b2c4\u6b65\uff1a\u591a\u4e2a\u5916\u56f4\u8bbe\u5907\u7684\u5c01\u88c5<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-26\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#%E8%AE%BE%E5%A4%87%E5%B0%81%E8%A3%85%E7%B1%BB\" title=\"\u8bbe\u5907\u5c01\u88c5\u7c7b\">\u8bbe\u5907\u5c01\u88c5\u7c7b<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-27\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#%E8%AE%BE%E5%A4%87%E5%B0%81%E8%A3%85%E7%B1%BB%E7%9A%84%E7%AE%A1%E7%90%86%E7%B1%BB\" title=\"\u8bbe\u5907\u5c01\u88c5\u7c7b\u7684\u7ba1\u7406\u7c7b\">\u8bbe\u5907\u5c01\u88c5\u7c7b\u7684\u7ba1\u7406\u7c7b<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-28\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=4709\/#%E6%9C%8D%E5%8A%A1%E7%AB%AF%E7%9A%84%E5%AE%9E%E7%8E%B0%EF%BC%8C%E4%BC%9A%E5%9C%A8%E5%90%8E%E7%BB%AD%E5%8D%9A%E5%AE%A2%E4%B8%AD%E6%8C%81%E7%BB%AD%E6%9B%B4%E6%96%B0%EF%BC%8C%E6%95%AC%E8%AF%B7%E5%85%B3%E6%B3%A8%E3%80%82\" title=\"\u670d\u52a1\u7aef\u7684\u5b9e\u73b0\uff0c\u4f1a\u5728\u540e\u7eed\u535a\u5ba2\u4e2d\u6301\u7eed\u66f4\u65b0\uff0c\u656c\u8bf7\u5173\u6ce8\u3002\">\u670d\u52a1\u7aef\u7684\u5b9e\u73b0\uff0c\u4f1a\u5728\u540e\u7eed\u535a\u5ba2\u4e2d\u6301\u7eed\u66f4\u65b0\uff0c\u656c\u8bf7\u5173\u6ce8\u3002<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%AE%9E%E7%8E%B0\"><\/span>\u5ba2\u6237\u7aef\u5b9e\u73b0<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u5ba2\u6237\u7aef\u84dd\u7259\u8981\u5b9e\u73b0\u7684\u529f\u80fd\u5c31\u662f\u626b\u63cf\u5916\u56f4\u8bbe\u5907\u84dd\u7259\uff0c\u8fde\u63a5\u540e\u5b9e\u73b0\u901a\u8baf\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E7%AC%AC1%E6%AD%A5%EF%BC%9A%E8%93%9D%E7%89%99%E5%88%9D%E5%A7%8B%E5%8C%96%E7%8E%AF%E5%A2%83%E5%88%A4%E6%96%AD\"><\/span>\u7b2c1\u6b65\uff1a\u84dd\u7259\u521d\u59cb\u5316\u73af\u5883\u5224\u65ad<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h5><span class=\"ez-toc-section\" id=\"1%E5%88%A4%E6%96%ADandroid%E7%B3%BB%E7%BB%9F%E6%98%AF%E5%90%A6%E6%94%AF%E6%8C%81%E8%93%9D%E7%89%99\"><\/span>1.\u5224\u65adandroid\u7cfb\u7edf\u662f\u5426\u652f\u6301\u84dd\u7259<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u6211\u8fd9\u91cc\u8bf4\u7684\u662fandroid\u7cfb\u7edf\uff0c\u5305\u62ec\u4e86\u624b\u673a\uff0c\u624b\u673a\u4e00\u822c\u90fd\u6709\u84dd\u7259\u6a21\u5757\u3002\u4f46\u662f\u6709\u4e9b\u642d\u8f7dandroid\u7cfb\u7edf\u7684\u786c\u4ef6\u8bbe\u5907\uff0c\u4e0d\u9700\u8981\u4f7f\u7528\u84dd\u7259\uff0c\u4e3a\u4e86\u8282\u7ea6\u6210\u529f\uff0c\u780d\u6389\u4e86\u84dd\u7259\u6a21\u5757\u3002<\/p>\n<pre><code class=\"language-java\"> BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();\n        if (mBluetoothAdapter == null) {\n            \/\/ Device does not support Bluetooth\n            responseFailure(pluginCallback,ErrorPool.BluetoothError.CODE_10009);\n            return;\n        }<\/code><\/pre>\n<p>mBluetoothAdapter  == null\u5c31\u8868\u793a\u7cfb\u7edf\u4e0d\u652f\u6301\u84dd\u7259\u3002<\/p>\n<h5><span class=\"ez-toc-section\" id=\"2%E6%89%93%E5%BC%80%E7%B3%BB%E7%BB%9F%E7%9A%84%E8%93%9D%E7%89%99%E5%BC%80%E5%85%B3\"><\/span>2.\u6253\u5f00\u7cfb\u7edf\u7684\u84dd\u7259\u5f00\u5173<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u5224\u65ad\u84dd\u7259\u5f00\u5173\u662f\u5426\u6253\u5f00<\/p>\n<pre><code class=\"language-java\">mBluetoothAdapter.isEnabled()<\/code><\/pre>\n<p>\u5f00\u542f\u84dd\u7259\uff0c\u6ce8\u610f\u52a0\u4e0a\u6743\u9650:<\/p>\n<pre><code class=\"language-java\">mBluetoothAdapter.enable()<\/code><\/pre>\n<pre><code class=\"language-xml\"> &lt;uses-permission android:name=&quot;android.permission.BLUETOOTH&quot;&gt;&lt;\/uses-permission&gt;\n    &lt;uses-permission android:name=&quot;android.permission.BLUETOOTH_ADMIN&quot;&gt;&lt;\/uses-permission&gt;<\/code><\/pre>\n<p>\u5173\u95ed\u84dd\u7259<\/p>\n<pre><code class=\"language-java\">mBluetoothAdapter.disable()<\/code><\/pre>\n<p>\u76d1\u542c\u84dd\u7259\u662f\u5426\u6253\u5f00\uff0c\u901a\u8fc7\u76d1\u542c<code>BluetoothAdapter.ACTION_STATE_CHANGED<\/code>\u8fd9\u4e2a\u5e7f\u64ad\u3002<br \/>\n\u9700\u8981\u8bf4\u660e\u7684\u662f<code>BluetoothAdapter.STATE_ON\u548cBluetoothAdapter.STATE_OFF<\/code>\u8fd9\u4e24\u4e2a\u5e7f\u64ad\u6709\u65f6\u5019\u4e0d\u4f1a\u56de\u8c03\uff089.0 vivo iqoo\u624b\u673a\uff09\uff0c\u6240\u4ee5\u9700\u8981\u76d1\u542c\u53e6\u5916\u7684\u4e24\u4e2a\u72b6\u6001\u4f1a\u6bd4\u8f83\u51c6\u786e\u3002<\/p>\n<pre><code class=\"language-java\"> @Override\n        public void onReceive(Context context, Intent intent) {\n            String action = intent.getAction();\n            int btState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1);\n            Logger.d(TAG, &quot;[XXunBtReceiver] &gt;&gt; action: &quot; + action);\n            if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {\n                switch (btState) {\n                    case BluetoothAdapter.STATE_TURNING_ON:\n                        Logger.d(TAG, &quot;[XXunBtReceiver] &gt;&gt; bt state turning on. &quot;);\n                        if(onBlueToothCallBack != null){\n                            onBlueToothCallBack.onBlueToothOpen();\n                        }\n\n                        break;\n\n                    case BluetoothAdapter.STATE_ON:\n                        Logger.d(TAG, &quot;[XXunBtReceiver] &gt;&gt; bt state is on.&quot;);\n\n                        break;\n\n                    case BluetoothAdapter.STATE_TURNING_OFF:\n                        Logger.d(TAG, &quot;[XXunBtReceiver] &gt;&gt; bt state is turning off. &quot;);\n                        if(onBlueToothCallBack != null){\n                            onBlueToothCallBack.onBlueToothClosed();\n                        }\n\n                        break;\n\n                    case BluetoothAdapter.STATE_OFF:        \/\/\u6709\u7684\u65f6\u5019\u4e0d\u4f1a\u56de\u8c03\n                        Logger.d(TAG, &quot;[XXunBtReceiver] &gt;&gt; bt state is off. &quot;);\n                        break;\n\n                }\n            }\n        }<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%E7%AC%AC2%E6%AD%A5%EF%BC%9A%E6%89%AB%E6%8F%8F%E8%BF%9E%E6%8E%A5%E8%93%9D%E7%89%99\"><\/span>\u7b2c2\u6b65\uff1a\u626b\u63cf\u8fde\u63a5\u84dd\u7259<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h5><span class=\"ez-toc-section\" id=\"1%E6%89%AB%E6%8F%8F%E5%A4%96%E5%9B%B4%E8%93%9D%E7%89%99%E8%AE%BE%E5%A4%87\"><\/span>1.\u626b\u63cf\u5916\u56f4\u84dd\u7259\u8bbe\u5907<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<h6><span class=\"ez-toc-section\" id=\"1%E5%AE%9A%E4%BD%8D%E6%9D%83%E9%99%90%E7%94%B3%E8%AF%B7\"><\/span>1)\u5b9a\u4f4d\u6743\u9650\u7533\u8bf7<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<p>\u6ce8\u610f\uff0cBLE(\u84dd\u72594.0)\u626b\u63cf\u5bf9\u4e8e6.0\u4ee5\u4e0a\u624b\u673a\u5148\u8981\u52a8\u6001\u7533\u8bf7Manifest.permission.ACCESS_FINE_LOCATION\u8fd9\u4e2a\u6743\u9650\uff08\u5bf9\u4e8e9.0\u624b\u673a\uff0c\u5373\u4f7f\u662f\u52a8\u6001\u6743\u9650\u4e5f\u8981\u5728XML\u91cc\u58f0\u660e\uff0c\u5426\u5219\u7533\u8bf7\u7684\u65f6\u5019\u4e0d\u4f1a\u6709\u63d0\u793a\u7684UI\u3002\uff09<\/p>\n<h6><span class=\"ez-toc-section\" id=\"2%E6%89%93%E5%BC%80%E5%AE%9A%E4%BD%8D%E5%BC%80%E5%85%B3\"><\/span>2)\u6253\u5f00\u5b9a\u4f4d\u5f00\u5173<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<p>\u5224\u65adGPS\u662f\u5426\u6253\u5f00\u7684\u65b9\u6cd5<\/p>\n<pre><code class=\"language-java\">public static boolean isOPen(Context context) {\n        int locationMode = 0;\n        String locationProviders;\n        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT) {\n            try {\n                locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);\n            } catch (Settings.SettingNotFoundException e) {\n                e.printStackTrace();\n                return false;\n            }\n            return locationMode != Settings.Secure.LOCATION_MODE_OFF;\n        } else {\n            locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);\n            return !TextUtils.isEmpty(locationProviders);\n        }\n    }<\/code><\/pre>\n<p>\u5982\u679cGPS\u5f00\u5173\u6ca1\u6709\u6253\u5f00\uff0c\u5f15\u5bfc\u7528\u6237\u6253\u5f00\u5b9a\u4f4d\u5f00\u5173\uff0c\u6ce8\u610f\u6709\u7684\u624b\u673a\u5373\u4f7f\u7528\u6237\u6253\u5f00\u4e86GPS\u5f00\u5173\uff0c\u518d\u8fd4\u56de\u5230\u754c\u9762onActivityResult\u65b9\u6cd5\u7684resultCode\u5e76\u4e0d\u662fActivity.RESULT_OK\uff0c\u6240\u4ee5\u9700\u8981\u5728onActivityResult\u65b9\u6cd5\u91cc\u518d\u4e00\u6b21\u8c03\u7528\u5224\u65adGPS\u662f\u5426\u6253\u5f00\u7684\u65b9\u6cd5\u3002<\/p>\n<pre><code class=\"language-java\"> new AlertDialog.Builder(webViewFragment.getActivity())\n                        .setTitle(&quot;\u63d0\u793a&quot;)\n                        .setMessage(&quot;\u5f53\u524d\u624b\u673a\u626b\u63cf\u84dd\u7259\u9700\u8981\u6253\u5f00\u5b9a\u4f4d\u529f\u80fd&quot;)\n                        .setNegativeButton(&quot;\u53d6\u6d88&quot;,\n                                new DialogInterface.OnClickListener() {\n                                    @Override\n                                    public void onClick(DialogInterface dialog, int which) {\n                                        dialog.dismiss();\n                                        Logger.e(TAG, &quot;\u7528\u6237\u62d2\u7edd\u4e86\u6253\u5f00\u4f4d\u7f6e\u6743\u9650&quot;);\n                                        responseFailure(pluginCallback, ErrorPool.BluetoothError.CODE_10001);\n                                    }\n                                })\n                        .setPositiveButton(&quot;\u524d\u5f80\u8bbe\u7f6e&quot;,\n                                new DialogInterface.OnClickListener() {\n                                    @Override\n                                    public void onClick(DialogInterface dialog, int which) {\n                                        webViewFragment.addResultListsners(new ActivityResultListener() {\n                                            @Override\n                                            public boolean onSdkActivityResult(int requestCode, int resultCode, Intent intent) {\n\/\/                                                if (resultCode == Activity.RESULT_OK &amp;&amp; requestCode == REQUEST_CODE_OPEN_GPS) {\n\/\/                                                    startDiscovery(webViewFragment, paramsBean, pluginCallback, mBluetoothAdapter, leScanCallback);\n\/\/                                                    return false;\n\/\/                                                }\n\n                                                \/\/\u4e0a\u9762\u7684\u5224\u65ad\u65b9\u6cd5\u6709BUG\uff0c\u5728YuLong\u624b\u673a\u4e0a\uff0c\u5373\u4f7f\u7528\u6237\u6253\u5f00\u4e86\u5b9a\u4f4d\u670d\u52a1\uff0cresultCode\u8fd4\u56de\u7684\u5e76\u4e0d\u662f Activity.RESULT_OK\n                                                \/\/\u90a3\u5c31\u518d\u5224\u65ad\u4e00\u6b21\u5450\uff0c\u673a\u667a\u5982\u6211\uff01\n                                                if(requestCode == REQUEST_CODE_OPEN_GPS){\n                                                    boolean gpsIsOpen = GpsUtil.isOPen(WebApplication.getInstance().getApplication());\n                                                    if(gpsIsOpen){\n                                                        startDiscovery(webViewFragment, paramsBean, pluginCallback, mBluetoothAdapter, leScanCallback);\n                                                        return false;\n                                                    }\n\n                                                    Logger.e(TAG, &quot;\u7528\u6237\u62d2\u7edd\u4e86\u6253\u5f00\u4f4d\u7f6e\u6743\u9650&quot;);\n                                                    responseFailure(pluginCallback, ErrorPool.BluetoothError.CODE_10001);\n                                                }\n                                                return false;\n                                            }\n                                        });\n                                        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);\n                                        webViewFragment.startActivityForResult(intent, REQUEST_CODE_OPEN_GPS);\n                                    }\n                                })\n\n                        .setCancelable(false)\n                        .show();<\/code><\/pre>\n<h6><span class=\"ez-toc-section\" id=\"3%E5%BC%80%E5%A7%8B%E6%89%AB%E6%8F%8F%E8%93%9D%E7%89%99\"><\/span>3)\u5f00\u59cb\u626b\u63cf\u84dd\u7259<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<h6><span class=\"ez-toc-section\" id=\"%E5%BC%80%E5%A7%8B%E6%89%AB%E6%8F%8F\"><\/span>\u5f00\u59cb\u626b\u63cf<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<p>\u8c03\u7528mBluetoothAdapter.startLeScan()\u65b9\u6cd5\uff0c\u70b9\u8fdb\u65b9\u6cd5\u7684\u6ce8\u91ca\uff0c\u5b98\u65b9\u8bf4\u660e\u4e86\u8fd9\u4e2a\u65b9\u6cd5\u662f\u4e13\u95e8\u7528\u6765\u626b\u63cfBLE\u8bbe\u5907\u7684\u65b9\u6cd5\u3002<br \/>\n\u6ce8\u610fmBluetoothAdapter.startDiscovery()\u65b9\u6cd5\u662f\u7528\u6765\u626b\u63cf\u7ecf\u5178\u84dd\u7259\u8bbe\u5907\u7684\uff0c\u4e0d\u662f\u7528\u6765\u4e13\u95e8\u626bBLE\u7684\u3002<\/p>\n<h6><span class=\"ez-toc-section\" id=\"%E5%81%9C%E6%AD%A2%E6%89%AB%E6%8F%8F\"><\/span>\u505c\u6b62\u626b\u63cf<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<p>\u6ce8\u610f\u505c\u6b62\u626b\u63cf\u65b9\u6cd5\u4f20\u5165\u7684callback\u5fc5\u987b\u548c\u5f00\u59cb\u626b\u63cf\u521b\u5efa\u7684callback\u662f\u540c\u4e00\u4e2a\u5bf9\u8c61\uff0c\u800c\u4e14\uff0c\u505c\u6b62\u626b\u63cf\u65b9\u6cd5\u8c03\u7528\u4e4b\u540e\uff0ccallback\u4e0d\u4f1a\u7acb\u9a6c\u56de\u8c03\uff0c\u6240\u4ee5\u5982\u679c\u5728\u56de\u8c03\u91cc\u6709\u7cbe\u5fae\u7684\u5904\u7406\u8981\u6ce8\u610f\u8fd9\u4e2a\u5730\u65b9\u3002<\/p>\n<pre><code class=\"language-java\">        mBluetoothAdapter.stopLeScan(leScanCallback);<\/code><\/pre>\n<h6><span class=\"ez-toc-section\" id=\"%E6%89%AB%E6%8F%8F%E5%9B%9E%E8%B0%83\"><\/span>\u626b\u63cf\u56de\u8c03<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<pre><code class=\"language-java\">leScanCallback = new BluetoothAdapter.LeScanCallback() {\n                @Override\n                public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {\n\n                }\n            };<\/code><\/pre>\n<p>onLeScan\u65b9\u6cd5\u56de\u8c03\u7684\u4e09\u4e2a\u53c2\u6570<br \/>\ndevice\uff1a\u626b\u63cf\u5230\u7684\u8bbe\u5907<br \/>\nrssi:\u84dd\u7259\u4fe1\u53f7\u5f3a\u5ea6<br \/>\nscanRecord:\u626b\u63cf\u5230\u7684\u8bbe\u5907\u5e7f\u64ad\u7684\u6570\u636e\uff08\u5e7f\u64ad\u6570\u636e\u89e3\u6790\uff0c\u8bf7\u53c2\u7167\uff1a<a href=\"https:\/\/blog.csdn.net\/zzx2436125\/article\/details\/79698017\">https:\/\/blog.csdn.net\/zzx2436125\/article\/details\/79698017<\/a><br \/>\n\uff0c\u6ce8\u610f\u535a\u5ba2\u91cc\u6ca1\u6709\u7c7b\uff0c\u53ef\u4ee5\u53bb\u6e90\u7801\u91cc\u627e\u7136\u540e\u590d\u5236\u4e00\u4efd\u5c31\u884c\uff09<br \/>\n\u6ce8\u610fcallback\uff0c\u540c\u4e00\u4e2a\u8bbe\u5907\uff0c\u5982\u679crssi\u6570\u503c\u6709\u53d8\u5316\uff0c\u4e5f\u4f1a\u56de\u8c03\uff0c\u9700\u8981\u6839\u636e\u9700\u6c42\u8fdb\u884c\u8fc7\u6ee4\u3002<br \/>\n\u626b\u63cf\u5230\u6307\u5b9a\u8bbe\u5907\u4e4b\u540e\uff0c\u6ce8\u610f\u4e00\u5b9a\u8981\u505c\u6b62\u626b\u63cf\uff01<\/p>\n<h5><span class=\"ez-toc-section\" id=\"2%E8%BF%9E%E6%8E%A5%E8%93%9D%E7%89%99\"><\/span>2.\u8fde\u63a5\u84dd\u7259<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u8c03\u7528\u4e0a\u9762\u7684callback\u8fd4\u56de\u7684device\u7684connectGatt\u65b9\u6cd5\u5373\u53ef\u8fde\u63a5\u84dd\u7259\uff0c\u84dd\u7259\u7684\u6838\u5fc3\u5c31\u662f\u8fd9\u4e2a\u65b9\u6cd5\u7684\u56de\u8c03\uff0c\u4e0b\u9762\u6211\u622a\u53d6\u6211\u7684\u4e3b\u8981\u4ee3\u7801\u5982\u4e0b\uff08\u76f4\u63a5\u7c98\u8d34\u80af\u5b9a\u6709\u95ee\u9898\uff09\uff1a<\/p>\n<pre><code class=\"language-java\">BluetoothGattCallback bluetoothGattCallback = new BluetoothGattCallback() {\n        public void onConnectionStateChange(BluetoothGatt gatt, int status,\n                                            int newState) {\n            if (status != BluetoothGatt.GATT_SUCCESS) {\n                Logger.e(TAG, &quot;\u7cfb\u7edf\u5f02\u5e38\u56de\u8c03onConnectionStateChange&quot;);\n                return;\n            }\n\n            if (newState == BluetoothGatt.STATE_CONNECTED) {\n                if (BleDeviceContext.this.isDeviceConnected) {\n                    Logger.e(TAG, &quot;\u84dd\u7259\u5df2\u7ecf\u5904\u4e8e\u8fde\u63a5\u72b6\u6001,\u5ffd\u7565\u7cfb\u7edf\u7684\u91cd\u590d\u56de\u8c03\u3002&quot;);\n                    return;\n                }\n\n                Logger.e(TAG, &quot;\u84dd\u7259\u8fde\u63a5\u6210\u529f&quot;);\n\n                \/\/\u8bf7\u6c42\u53d1\u73b0\u670d\u52a1\uff0c\u5426\u5219onServicesDiscovered\u4e0d\u4f1a\u56de\u8c03\u3002\n                gatt.discoverServices();\n\n            } else if (newState == BluetoothGatt.STATE_DISCONNECTED) {\n                if (BleDeviceContext.this.isDeviceConnected == false) {\n                    Logger.e(TAG, &quot;\u84dd\u7259\u5df2\u7ecf\u5904\u4e8e\u65ad\u5f00\u8fde\u63a5\u72b6\u6001\uff08\u6709\u53ef\u80fd\u662f\u901a\u8fc7wx.closeConnection\u65b9\u6cd5\u6765\u65ad\u5f00\u7684\uff09,\u5ffd\u7565\u7cfb\u7edf\u7684\u91cd\u590d\u56de\u8c03\u3002&quot;);\n                    return;\n                }\n\n                Logger.e(TAG, &quot;\u84dd\u7259\u771f\u6b63\u5730\u65ad\u5f00\u8fde\u63a5&quot;);\n\n                BleDeviceContext.this.isDeviceConnected = false;\n                BleDeviceContext.this.curConnectedGatt = null;\n\n            } else if (newState == BluetoothGatt.STATE_CONNECTING) {\n                Logger.e(TAG, &quot;onConnectionStateChange: \u6b63\u5728\u8fde\u63a5\u4e2d...&quot;);\n            }\n        }\n\n        public void onServicesDiscovered(BluetoothGatt gatt, int status) {\n            if (status != BluetoothGatt.GATT_SUCCESS) {\n                Logger.e(TAG, &quot;\u7cfb\u7edf\u5f02\u5e38\u56de\u8c03onServicesDiscovered&quot;);\n                return;\n            }\n            Logger.e(TAG, &quot;onServicesDiscovered: &quot;);\n            BleDeviceContext.this.bluetoothGattServiceList.addAll(gatt.getServices());\n        }\n\n        public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic\n                characteristic,\n                                         int status) {\n            if (status != BluetoothGatt.GATT_SUCCESS) {\n                Logger.e(TAG, &quot;\u7cfb\u7edf\u5f02\u5e38\u56de\u8c03onCharacteristicRead&quot;);\n                return;\n            }\n\n            Logger.e(TAG, &quot;onCharacteristicRead: &quot;);\n            byte[] value = characteristic.getValue();\n\n        }\n\n        public void onCharacteristicWrite(BluetoothGatt gatt,\n                                          BluetoothGattCharacteristic characteristic, int status) {\n            if (status != BluetoothGatt.GATT_SUCCESS) {\n                Logger.e(TAG, &quot;\u7cfb\u7edf\u5f02\u5e38\u56de\u8c03onCharacteristicWrite&quot;);\n                if (onCharacteristicWriteResultListener != null) {\n                    onCharacteristicWriteResultListener.onWriteFailure();\n                }\n                return;\n            }\n            Logger.e(TAG, &quot;onCharacteristicWrite: &quot;);\n            if (onCharacteristicWriteResultListener != null) {\n                onCharacteristicWriteResultListener.onWriteSuccess();\n            }\n        }\n\n        public void onCharacteristicChanged(BluetoothGatt gatt,\n                                            BluetoothGattCharacteristic characteristic) {\n            Logger.e(TAG, &quot;onCharacteristicChanged: &quot;);\n            byte[] value = characteristic.getValue();\n\n            if (value != null) {\n                Logger.e(TAG, &quot;onCharacteristicChanged result: &quot; + TransferUtil.bytes2HexString(value) + &quot;\\n&quot; + &quot;byte[] = &quot; + value);\n            }\n\n        }\n\n    };<\/code><\/pre>\n<p>\u5173\u4e8e\u4e0a\u9762\u7684\u56de\u8c03\uff0c\u6211\u7279\u5730\u5728\u6b64\u5f3a\u8c03\u4e00\u4e0b\u5b83\u7684\u5751\uff1a<br \/>\n\u4e0a\u9762\u7684\u56de\u8c03\u65b9\u6cd5\u9700\u8981\u8fc7\u6ee4status != BluetoothGatt.GATT_SUCCESS\u7684\u5f02\u5e38\u56de\u8c03\uff0c\u4e5f\u8981\u8fc7\u6ee4\u6210\u529f\u56de\u8c03\u7684\u91cd\u590d\u56de\u8c03\u8fc7\u6ee4\uff08\u901a\u8fc7\u4e00\u4e9bboolean\u503c\u63a7\u5236\uff0c\u4e00\u5b9a\u8981\u51c6\u786e\u3002\uff09\u3002<\/p>\n<p>\u8fde\u63a5\u6210\u529f\u4e4b\u540e\uff0c\u8bb0\u5f97\u4fdd\u5b58\u4e00\u4e0bBluetoothGatt\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u540e\u9762\u4f1a\u7528\u5230\u8fd9\u4e2a\u5bf9\u8c61\u6839\u636eUUID\u83b7\u53d6\u670d\u52a1\u6216\u8005\u4e0e\u8bbe\u5907\u65ad\u5f00\u8fde\u63a5\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E7%AC%AC3%E6%AD%A5%EF%BC%9ABLE%E6%A0%B8%E5%BF%83%E6%93%8D%E4%BD%9C\"><\/span>\u7b2c3\u6b65\uff1aBLE\u6838\u5fc3\u64cd\u4f5c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u4e5f\u5c31\u662f\u5bf9\u670d\u52a1\u3001\u7279\u5f81\u503c\uff08\u76f8\u5f53\u4e8e\u670d\u52a1\u7aef\u66b4\u9732\u7ed9\u5ba2\u6237\u7aef\u7684\u63a5\u53e3\uff09\u7684\u5404\u79cd\u64cd\u4f5c\uff0c\u5b9e\u73b0\u4e0e\u670d\u52a1\u7aef\u8bbe\u5907\u7684\u901a\u8baf\u3002\u5173\u4e8e\u8fd9\u4e9b\u6982\u5ff5\u4e0d\u592a\u6e05\u695a\u7684\uff0c\u53ef\u4ee5\u53c2\u8003\u6211\u6587\u7ae0\u5f00\u5934\u7684\u535a\u5ba2\u94fe\u63a5\u548c<a href=\"https:\/\/blog.csdn.net\/MakeWorks\/article\/details\/69487344\">https:\/\/blog.csdn.net\/MakeWorks\/article\/details\/69487344<\/a>\uff0c\u8bbe\u5907\u3001\u670d\u52a1\u3001\u7279\u5f81\uff08\u503c\u3001\u63cf\u8ff0\u7b26\uff09\u662f\u4f9d\u6b21\u5305\u6db5\u7684\u5173\u7cfb\u3002<\/p>\n<h5><span class=\"ez-toc-section\" id=\"1%E5%8F%91%E7%8E%B0%E6%9C%8D%E5%8A%A1\"><\/span>1.\u53d1\u73b0\u670d\u52a1<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u84dd\u7259\u8fde\u63a5\u6210\u529f\u4e4b\u540e\u7684\u56de\u8c03\u91cc\u8c03\u7528<\/p>\n<pre><code class=\"language-java\"> gatt.discoverServices();<\/code><\/pre>\n<p>\u4f1a\u89e6\u53d1BluetoothGattCallback\u7684onServicesDiscovered\u65b9\u6cd5\u88ab\u56de\u8c03\uff0c\u5728\u8fd9\u91cc\u628a\u670d\u52a1\uff08BluetoothGattService\uff09\u5217\u8868\u7f13\u5b58\u8d77\u6765\u3002\u6ce8\u610f\u8fd9\u4e2a\u8fc7\u7a0b\u9700\u8981\u4e00\u5b9a\u7684\u65f6\u95f4\u3002<\/p>\n<h5><span class=\"ez-toc-section\" id=\"2%E9%81%8D%E5%8E%86%E6%9C%8D%E5%8A%A1%E7%89%B9%E5%BE%81%E5%80%BC\"><\/span>2.\u904d\u5386\u670d\u52a1\u7279\u5f81\u503c<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u904d\u5386\u670d\u52a1\u662f\u83b7\u53d6\u7279\u5f81\u503c\uff0c\u7279\u5f81\u503c\u6709\u4e00\u4e9b\u5c5e\u6027\uff1a\u53ef\u8bfb\u3001\u53ef\u5199\u3001\u53efnotify\u3001\u53efindicate\u3002<\/p>\n<h6><span class=\"ez-toc-section\" id=\"1%E8%8E%B7%E5%8F%96%E6%9C%8D%E5%8A%A1\"><\/span>1)\u83b7\u53d6\u670d\u52a1<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<p>\u53ef\u4ee5\u4ece\u524d\u9762\u7f13\u5b58\u7684\u670d\u52a1\u5217\u8868\u91cc\u83b7\u53d6\uff0c\u4e5f\u53ef\u7528\u8fde\u63a5\u6210\u529f\u8fd4\u56de\u7684BluetoothGatt\u5bf9\u8c61\u901a\u8fc7UUID\u6765\u83b7\u53d6\u670d\u52a1\u3002<\/p>\n<h6><span class=\"ez-toc-section\" id=\"2%E9%81%8D%E5%8E%86%E6%9C%8D%E5%8A%A1%E7%9A%84%E7%89%B9%E5%BE%81%E5%80%BC\"><\/span>2)\u904d\u5386\u670d\u52a1\u7684\u7279\u5f81\u503c<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<pre><code class=\"language-java\">List&lt;BluetoothGattCharacteristic&gt; characteristics = supportedGattService.getCharacteristics();<\/code><\/pre>\n<h6><span class=\"ez-toc-section\" id=\"3%E5%88%A4%E6%96%AD%E7%89%B9%E5%BE%81%E5%80%BC%E7%9A%84%E5%B1%9E%E6%80%A7\"><\/span>3)\u5224\u65ad\u7279\u5f81\u503c\u7684\u5c5e\u6027<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<pre><code class=\"language-java\"> \/**\n     * \u5224\u65ad\u7279\u5f81\u503c\u662f\u5426\u53ef\u901a\u77e5 - notify\u7684\u65b9\u5f0f\n     * @param bluetoothGattCharacteristic\n     * @return\n     *\/\n    public static  boolean isNotifable(BluetoothGattCharacteristic bluetoothGattCharacteristic) {\n        int charaProp = bluetoothGattCharacteristic.getProperties();\n        if ((charaProp &amp; BluetoothGattCharacteristic.PROPERTY_NOTIFY) &gt; 0\n               \/* || (charaProp &amp; BluetoothGattCharacteristic.PROPERTY_INDICATE) &gt; 0*\/) {\n            return true;\n        }\n        return false;\n    }\n\n    \/**\n     * \u5224\u65ad\u7279\u5f81\u503c\u662f\u5426\u53efindicate\n     * @param bluetoothGattCharacteristic\n     * @return\n     *\/\n    public  static boolean isIndicatable(BluetoothGattCharacteristic bluetoothGattCharacteristic) {\n        int charaProp = bluetoothGattCharacteristic.getProperties();\n        if (\/*(charaProp &amp; BluetoothGattCharacteristic.PROPERTY_NOTIFY) &gt; 0\n                || *\/(charaProp &amp; BluetoothGattCharacteristic.PROPERTY_INDICATE) &gt; 0) {\n            return true;\n        }\n        return false;\n    }\n\n    public  static boolean isReadable(BluetoothGattCharacteristic bluetoothGattCharacteristic) {\n        int charaProp = bluetoothGattCharacteristic.getProperties();\n        \/\/ \u53ef\u8bfb\n        if ((charaProp &amp; BluetoothGattCharacteristic.PROPERTY_READ) &gt; 0) {\n            return true;\n        }\n        return false;\n    }\n\n    public  static boolean isWritable(BluetoothGattCharacteristic bluetoothGattCharacteristic) {\n        int charaProp = bluetoothGattCharacteristic.getProperties();\n        if ((charaProp &amp; BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) &gt; 0\n                || (charaProp &amp; BluetoothGattCharacteristic.PROPERTY_WRITE) &gt; 0) {\n            return true;\n        }\n        return false;\n    }<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"3%E7%89%B9%E5%BE%81%E5%80%BC%E6%93%8D%E4%BD%9C\"><\/span>3.\u7279\u5f81\u503c\u64cd\u4f5c<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>\u5047\u5982\uff0c\u53d6\u5230\u8fde\u63a5\u6210\u529f\u4fdd\u5b58\u7684BluetoothGatt\u5bf9\u8c61gatt\uff0c\u8981\u64cd\u4f5c\u7684\u7279\u5f81\u503cBluetoothGattCharacteristic\u5bf9\u8c61\u4e3acharacteristicObj.<\/p>\n<p><strong>\u7279\u522b\u6ce8\u610f\uff1a<\/strong>\u5bf9\u4e8e\u540c\u4e00\u4e2a\u8fde\u63a5\uff0c\u5173\u4e8e\u7279\u5f81\u503c\u64cd\u4f5c\u7684API \u4e00\u5b9a\u8981\u7b49\u8fd9\u4e2aAPI\u7684\u56de\u8c03\u6210\u529f\u4e4b\u540e\u65b9\u53ef\u7ee7\u7eed\u64cd\u4f5c\uff0c\u7edd\u5bf9\u4e0d\u80fd\u540c\u65f6\u64cd\u4f5c\u67d0\u4e2a\u7279\u5f81\u503c\uff0c\u8fd9\u4e2a\u662f\u5e94\u7528\u5c42\u8c03\u7528\u7279\u522b\u8981\u6ce8\u610f\u7684\u95ee\u9898\u3002<\/p>\n<h6><span class=\"ez-toc-section\" id=\"1%E8%AF%BB%E5%8F%96%E7%89%B9%E5%BE%81%E5%80%BC\"><\/span>1)\u8bfb\u53d6\u7279\u5f81\u503c<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<p>\u5148\u5229\u7528\u524d\u9762\u7ed9\u7684\u65b9\u6cd5\u5224\u65ad\u7279\u5f81\u503c\u662f\u5426\u53ef\u8bfb\uff0c\u53ea\u6709\u53ef\u8bfb\u624d\u80fd\u8bfb\u53d6\u7279\u5f81\u503c\u3002<\/p>\n<pre><code class=\"language-java\">boolean readOk = gatt.readCharacteristic(characteristicObj)      \/\/\u4f20\u5165\u5230\u8bfb\u53d6\u7684\u7279\u5f81\u503cBluetoothGattCharacteristic<\/code><\/pre>\n<p>\u6ce8\u610f\u8bfb\u53d6\u7684\u7ed3\u679c\u5728readOk\u4e3atrue\u7684\u57fa\u7840\u4e0a\uff0c\u662f\u5728\u8fde\u63a5\u7684\u56de\u8c03BluetoothGattCallback\u7684onCharacteristicRead()\u65b9\u6cd5\u5f02\u6b65\u8fd4\u56de\u7684\u3002<\/p>\n<pre><code class=\"language-java\"> public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic\n                characteristic,\n                                         int status) {\n            if (status != BluetoothGatt.GATT_SUCCESS) {\n                Logger.e(TAG, &quot;\u7cfb\u7edf\u5f02\u5e38\u56de\u8c03onCharacteristicRead&quot;);\n                return;\n            }\n\n            Logger.e(TAG, &quot;onCharacteristicRead: &quot;);\n            byte[] value = characteristic.getValue();\n\n        }<\/code><\/pre>\n<h6><span class=\"ez-toc-section\" id=\"2%E5%86%99%E7%89%B9%E5%BE%81%E5%80%BC\"><\/span>2)\u5199\u7279\u5f81\u503c<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<p>\u5199\u7279\u5f81\u503c\u5176\u5b9e\u5c31\u662f\u5f80\u670d\u52a1\u7aef\u53d1\u9001\u6570\u636e<br \/>\n\u5148\u5229\u7528\u524d\u9762\u7ed9\u7684\u65b9\u6cd5\u5224\u65ad\u7279\u5f81\u503c\u662f\u5426\u53ef\u5199\uff0c\u53ea\u6709\u53ef\u5199\u624d\u80fd\u7ed9\u7279\u5f81\u503c\u5199\u503c\u3002<\/p>\n<pre><code class=\"language-java\">characteristicObj.setValue(byte[])                   \/\/\u5c06\u8981\u5199\u7684\u6570\u636e\u8d4b\u503c\u7ed9\u7279\u5f81\u503c\u5bf9\u8c61\nboolean writeOk = gatt.writeCharacteristic(characteristicObj)      \/\/\u5199\u7279\u5f81\u503c\u5bf9\u8c61<\/code><\/pre>\n<p><strong>\u7279\u522b\u6ce8\u610f\uff1a<\/strong>\u7531\u4e8e\u4f4e\u5c42\u84dd\u7259\u534f\u8bae\u6808\u7684\u9650\u5b9a\uff0c\u4e00\u6b21\u6027\u5199\u5165\u7684\u5b57\u8282\u6570\u4e0d\u53ef\u8d85\u8fc7<strong>20\u5b57\u8282<\/strong>\uff0c\u5426\u5219\u4f1a\u5199\u4e0d\u6210\u529f\u3002<\/p>\n<p>\u6ce8\u610f\u5199\u5165\u7684\u7ed3\u679c\u662f\u5728writeOk \u4e3atrue\u7684\u57fa\u7840\uff0c\u5728\u8fde\u63a5\u7684\u56de\u8c03BluetoothGattCallback\u7684onCharacteristicWrite()\u65b9\u6cd5\u5f02\u6b65\u8fd4\u56de\u7684\u3002<\/p>\n<pre><code class=\"language-java\">  public void onCharacteristicWrite(BluetoothGatt gatt,\n                                          BluetoothGattCharacteristic characteristic, int status) {\n            if (status != BluetoothGatt.GATT_SUCCESS) {\n                Logger.e(TAG, &quot;\u7cfb\u7edf\u5f02\u5e38\u56de\u8c03onCharacteristicWrite&quot;);\n                if (onCharacteristicWriteResultListener != null) {\n                    onCharacteristicWriteResultListener.onWriteFailure();\n                }\n                return;\n            }\n            Logger.e(TAG, &quot;onCharacteristicWrite: &quot;);\n            if (onCharacteristicWriteResultListener != null) {\n                onCharacteristicWriteResultListener.onWriteSuccess();\n            }\n        }<\/code><\/pre>\n<h6><span class=\"ez-toc-section\" id=\"3%E6%89%93%E5%BC%80%E6%88%96%E8%80%85%E5%85%B3%E9%97%ADnotifyindicate%E5%BC%80%E5%85%B3\"><\/span>3)\u6253\u5f00\u6216\u8005\u5173\u95ednotify\/indicate\u5f00\u5173<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<p>\u8fd9\u4e2a\u64cd\u4f5c\u5c31\u662f\u63a7\u5236\u53efnotify\u6216\u8005indicate\u7684\u7279\u5f81\u503c\u662f\u5426\u53ef\u4ee5\u63a5\u6536\u670d\u52a1\u7aef\u7684\u6570\u636e\uff0c\u6253\u5f00\u4e4b\u540eBluetoothGattCallback\u7684onCharacteristicChanged\u65b9\u6cd5\u624d\u80fd\u56de\u8c03\uff0c\u4e5f\u5c31\u662f\u63a5\u6536\u670d\u52a1\u7aef\u5199\u5165\u7684\u6570\u636e\u7684\u5730\u65b9\u3002<\/p>\n<p>\u540c\u7406\uff0c\u5f97\u5224\u65ad\u4e00\u4e0b\u7279\u5f81\u503c\u7684\u5c5e\u6027\u662fnotify\u8fd8\u662findicate\u3002<\/p>\n<p>\u4e0b\u9762\u8fd9\u4e2aUUID\u662f\u4e0b\u9762\u5f00\u542f\u3001\u5173\u95ednotify\/indicate\u9700\u8981\u7528\u5230\u7684\u63cf\u8ff0\u7b26\u7684UUID\uff0c\u662f\u56fa\u5b9a\u4e0d\u53d8\u7684\u3002<\/p>\n<pre><code class=\"language-java\">private static final String UUID_CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR = &quot;00002902-0000-1000-8000-00805f9b34fb&quot;;<\/code><\/pre>\n<ul>\n<li>\n<p>indicate\u7684\u5904\u7406\uff1a<\/p>\n<pre><code class=\"language-java\">\/**\n * \u5f00\u5173indicate\n * @param gatt\n * @param characteristic\n * @param enable\n * @return\n *\/\npublic static boolean setCharacteristicIndicate(BluetoothGatt gatt,\n                                               BluetoothGattCharacteristic characteristic,\n                                              boolean enable){\n    Logger.e(TAG, &quot;setCharacteristicIndicate: &quot; + characteristic.getUuid().toString() + &quot;,enable = &quot; + enable);\n\/\/\u7b2c1\u6b65\uff1a\u6539\u53d8\u7279\u5f81\u503c\u672c\u8eab\n    boolean success = gatt.setCharacteristicNotification(characteristic, enable);\n    if(success == false) {\n        Logger.e(TAG, &quot;setCharacteristicNotification failure&quot;);\n        return false;\n    }\n\n\/\/\u7b2c2\u6b65\uff1a\u6539\u53d8\u7279\u5f81\u503c\u63cf\u8ff0\u7b26\n    BluetoothGattDescriptor descriptor = characteristic.getDescriptor(formUUID(UUID_CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR));\n    if (descriptor != null) {\n        if ((characteristic.getProperties() &amp; BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0) {\n            descriptor.setValue(enable ? BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE :\n                    BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);\n        } else if ((characteristic.getProperties() &amp; BluetoothGattCharacteristic.PROPERTY_INDICATE) != 0) {\n            descriptor.setValue(enable ? BluetoothGattDescriptor.ENABLE_INDICATION_VALUE :\n                    BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);\n\n        }\n        return gatt.writeDescriptor(descriptor);\n    }\n    return false;\n}<\/code><\/pre>\n<\/li>\n<li>\n<p>notify\u7684\u5904\u7406\uff1a<\/p>\n<pre><code class=\"language-java\">\/**\n * \u5f00\u5173notify\n * @param gatt\n * @param characteristic\n * @param enable\n * @return\n *\/\npublic static  boolean setCharacteristicNotification(BluetoothGatt gatt,\n                                              BluetoothGattCharacteristic characteristic,\n                                              boolean enable){\n    Logger.e(TAG, &quot;setCharacteristicNotification: &quot; + characteristic.getUuid().toString() + &quot;,enable = &quot; + enable);\n\/\/\u7b2c1\u6b65\uff1a\u6539\u53d8\u7279\u5f81\u503c\u672c\u8eab\n    boolean success = gatt.setCharacteristicNotification(characteristic, enable);\n    if(success == false) {\n        Logger.e(TAG, &quot;setCharacteristicNotification failure&quot;);\n        return false;\n    }\n\/\/\u7b2c2\u6b65\uff1a\u6539\u53d8\u7279\u5f81\u503c\u63cf\u8ff0\u7b26\n    BluetoothGattDescriptor descriptor = characteristic.getDescriptor(formUUID(UUID_CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR));\n    if (descriptor != null) {\n        descriptor.setValue(enable ? BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE :\n                BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);\n        return gatt.writeDescriptor(descriptor);\n    }\n    return false;\n}<\/code><\/pre>\n<h6><span class=\"ez-toc-section\" id=\"4%E7%9B%91%E5%90%AC%E7%89%B9%E5%BE%81%E5%80%BC%E5%8F%98%E5%8C%96\"><\/span>4)\u76d1\u542c\u7279\u5f81\u503c\u53d8\u5316<span class=\"ez-toc-section-end\"><\/span><\/h6>\n<p>\u76d1\u542c\u7279\u5f81\u503c\u53d8\u5316\uff0c\u4e5f\u5c31\u662f\u76d1\u542c\u670d\u52a1\u7aef\u53d1\u6765\u7684\u6570\u636e\u3002<br \/>\n\u6ce8\u610f\u8fd9\u4e2a\u662f\u5728\u4e0a\u9762notify\u3001indicate\u6253\u5f00\u7684\u60c5\u51b5\u4e0b\u624d\u4f1a\u56de\u8c03<\/p>\n<pre><code class=\"language-java\">public void onCharacteristicChanged(BluetoothGatt gatt,\n                                        BluetoothGattCharacteristic characteristic) {\n        Logger.e(TAG, &quot;onCharacteristicChanged: &quot;);\n        byte[] value = characteristic.getValue();\n\n        if (value != null) {\n            Logger.e(TAG, &quot;onCharacteristicChanged result: &quot; + TransferUtil.bytes2HexString(value) + &quot;\\n&quot; + &quot;byte[] = &quot; + value);\n        }\n}<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"%E7%AC%AC4%E6%AD%A5%EF%BC%9A%E5%A4%9A%E4%B8%AA%E5%A4%96%E5%9B%B4%E8%AE%BE%E5%A4%87%E7%9A%84%E5%B0%81%E8%A3%85\"><\/span>\u7b2c4\u6b65\uff1a\u591a\u4e2a\u5916\u56f4\u8bbe\u5907\u7684\u5c01\u88c5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u8bbe\u5907\u7684\u533a\u5206\u662f\u5728\u8fde\u63a5\u5904\u5f00\u59cb\u7684\uff0c\u6240\u4ee5\u5c06\u8fde\u63a5\u3001\u65ad\u5f00\u8fde\u63a5\u53ca\u5176Callback\u5355\u72ec\u5c01\u88c5\u5230\u4e00\u4e2a\u7c7b\u91cc\uff0cCallback\u8fd4\u56de\u7684\u91cd\u8981\u53c2\u6570\u4e5f\u7f13\u5b58\u5728\u8fd9\u4e2a\u7c7b\u91cc\u3002\u7136\u540e\u521b\u5efa\u4e00\u4e2aManager\u7c7b\u6765\u7ba1\u7406\u7ef4\u62a4\u5c01\u88c5\u7684\u7c7b\u3002<br \/>\n\u4e0b\u9762\u662f\u6211\u7684\u4ee3\u7801\uff0c\u6ca1\u6cd5\u76f4\u63a5\u7c98\u8d34\u4f7f\u7528\uff0c\u4ec5\u4f9b\u53c2\u8003\uff1a<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E8%AE%BE%E5%A4%87%E5%B0%81%E8%A3%85%E7%B1%BB\"><\/span>\u8bbe\u5907\u5c01\u88c5\u7c7b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-java\">\/**\n * \u4e00\u53f0\u8bbe\u5907\u5bf9\u5e94\u7684\u4e0a\u4e0b\u6587\n * \u5305\u62ec\u521b\u5efa\u8fde\u63a5\u65f6\u6240\u6709\u5173\u8054\u7684\u53d8\u91cf\n *\n * \u6ce8\u610f\uff1a\n * 1\uff09\u5bf9\u4e8e\u8fde\u63a5\u4f20\u7ed9\u6211\u7684\u8d85\u65f6\uff0c\u6211\u4f1a\u505a\u626b\u63cf\u548c\u8fde\u63a5\u4e24\u4e2a\u8d85\u65f6\u5904\u7406\u3002\n *    \u626b\u63cf\u4e2d\u5982\u679c\u8d85\u65f6\uff0c\u6211\u4f1a\u505c\u6b62\u626b\u63cf\uff0c\u5047\u5982\u56de\u8c03\u4ecd\u7136\u627e\u5230\u4e86\u8bbe\u5907\uff0c\u8d85\u65f6\u4e86\u8bdd\uff0c\u6211\u4f1a\u4e0d\u8fdb\u884c\u540e\u9762\u7684\u8fde\u63a5\u7b49\u64cd\u4f5c\u3002\n *\/\npublic class BleDeviceContext {\n    private static final String TAG = &quot;BleDeviceContext&quot;;\n    private WebViewFragment webViewFragment;\n    private Plugin.PluginCallback connectionImplPluginCallback;\n    private BLEConnectionImpl bleConnectionImpl;\n    private BluetoothGatt curConnectedGatt;\n    private boolean isDeviceConnected = false;                                                    \/**\u5f53\u524d\u662f\u5426\u6709\u8bbe\u5907\u5728\u8fde\u63a5\u7740\n     \u7279\u522b\u8981\u6ce8\u610f\uff0c\u90e8\u5206android\u624b\u673a\u84dd\u7259\u65ad\u5f00\u56de\u8c03\u4f1a\u6709\u5f88\u5927\u5ef6\u8fdf\u3002\/\/TODO \u8fd9\u4e2a\u662f\u5728\u771f\u6b63\u65ad\u5f00\u7684\u56de\u8c03\u91cc\u8d4b\u503c\u7684\u5417\uff1f\n     *\/\n    private CZWrapperBluetoothDevice czWrapperBluetoothDevice;                                    \/\/\u5f53\u524d\u8fde\u63a5\u7684\u8bbe\u5907\u4fe1\u606f\u5b58\u50a8\n    private boolean isOnServicesDiscoveredCalledBack = false;                                     \/\/\u8fde\u63a5\u8bbe\u5907\u65f6\uff0c\u9632\u6b62onServicesDiscovered\u65b9\u6cd5\u91cd\u590d\u56de\u8c03\u3002\n    private CZBluetoothGattServiceList bluetoothGattServiceList;                                  \/\/\u8bb0\u5f55\u8fde\u63a5\u7684\u8bbe\u5907\u53d1\u73b0\u7684\u670d\u52a1\n    private BLEConnectionParamsBean bleConnectionParamsBean;\n    private OnCharacteristicWriteResultListener onCharacteristicWriteResultListener;\n    private final TimeCounter timeCounter;\n    private boolean isTimeOut = false;            \/\/\u5224\u65ad\u662f\u5426\u662f\u8d85\u65f6\uff0c\u5982\u679c\u8d85\u65f6\uff0c\u5373\u4f7f\u84dd\u7259\u8fde\u63a5\u4e0a\u4e86\u4e5f\u4f1a\u81ea\u52a8\u65ad\u5f00\u3002\n\n    public BleDeviceContext() {\n        this.bluetoothGattServiceList = new CZBluetoothGattServiceList();\n        timeCounter = new TimeCounter();  \/\/\u626b\u63cf\u3001\u8fde\u63a5\u8d85\u65f6\u5224\u65ad\u3002\n        isDeviceConnected = false;\n    }\n\n    BluetoothGattCallback bluetoothGattCallback = new BluetoothGattCallback() {\n        public void onConnectionStateChange(BluetoothGatt gatt, int status,\n                                            int newState) {\n            if (status != BluetoothGatt.GATT_SUCCESS) {\n                Logger.e(TAG, &quot;\u7cfb\u7edf\u5f02\u5e38\u56de\u8c03onConnectionStateChange&quot;);\n\/\/                bleConnectionImpl.responseFailure(connectionImplPluginCallback,ErrorPool.BluetoothError.CODE_10008);\n                return;\n            }\n\n            BleDeviceContext.this.curConnectedGatt = gatt;              \/\/\u8bb0\u5f55\u8d77\u6765\uff0c\u7528\u4e8e\u65ad\u5f00\u8fde\u63a5\u3002\n\n            \/\/\u5173\u95ed\u8fde\u63a5\u8d85\u65f6\u8ba1\u65f6\u5668\n            timeCounter.stop();\n\n            if (newState == BluetoothGatt.STATE_CONNECTED) {\n                if (BleDeviceContext.this.isDeviceConnected) {\n                    Logger.e(TAG, &quot;\u84dd\u7259\u5df2\u7ecf\u5904\u4e8e\u8fde\u63a5\u72b6\u6001,\u5ffd\u7565\u7cfb\u7edf\u7684\u91cd\u590d\u56de\u8c03\u3002&quot;);\n                    return;\n                }\n\n                if(isTimeOut) {\n                   Logger.e(TAG, &quot;\u8fde\u63a5\u8d85\u65f6\uff0c\u5373\u4f7f\u5df2\u7ecf\u8fde\u63a5\u4e86\uff0c\u6211\u4e5f\u4e0d\u5904\u7406,\u4f60\u8fde\u63a5\u665a\u4e86\u3002&quot;);\n                   force_disconnect();\n                   return;\n                }\n\n                Logger.e(TAG, &quot;\u84dd\u7259\u8fde\u63a5\u6210\u529f&quot;);\n                WxBluetoothGlobalPropertyHolder.alreadyConnectedOnceDevices.add(czWrapperBluetoothDevice);\n                BleDeviceContext.this.isDeviceConnected = true;\n\n                bleConnectionImpl.responseSuccess(connectionImplPluginCallback);\n\n                BleJsCallbackHelper.getInstance().callbackConnectionStateChange(webViewFragment, czWrapperBluetoothDevice, true);\n                \/\/\u8bf7\u6c42\u53d1\u73b0\u670d\u52a1\uff0c\u5426\u5219onServicesDiscovered\u4e0d\u4f1a\u56de\u8c03\u3002\n                gatt.discoverServices();\n\n            } else if (newState == BluetoothGatt.STATE_DISCONNECTED) {\n                if (BleDeviceContext.this.isDeviceConnected == false) {\n                    Logger.e(TAG, &quot;\u84dd\u7259\u5df2\u7ecf\u5904\u4e8e\u65ad\u5f00\u8fde\u63a5\u72b6\u6001\uff08\u6709\u53ef\u80fd\u662f\u901a\u8fc7wx.closeConnection\u65b9\u6cd5\u6765\u65ad\u5f00\u7684\uff09,\u5ffd\u7565\u7cfb\u7edf\u7684\u91cd\u590d\u56de\u8c03\u3002&quot;);\n                    return;\n                }\n\n                Logger.e(TAG, &quot;\u84dd\u7259\u771f\u6b63\u5730\u65ad\u5f00\u8fde\u63a5&quot;);\n                bleConnectionImpl.responseSuccess(connectionImplPluginCallback);                            \/\/\u5bf9\u4e8ecloseBleConnect\u662f\u6210\u529f\u56de\u8c03\n\n                BleDeviceContext.this.isDeviceConnected = false;\n                BleDeviceContext.this.curConnectedGatt = null;\n\n                BleJsCallbackHelper.getInstance().callbackConnectionStateChange(webViewFragment, czWrapperBluetoothDevice, false);\n            } else if (newState == BluetoothGatt.STATE_CONNECTING) {\n                Logger.e(TAG, &quot;onConnectionStateChange: \u6b63\u5728\u8fde\u63a5\u4e2d...&quot;);\n            }\n        }\n\n        public void onServicesDiscovered(BluetoothGatt gatt, int status) {\n            if (status != BluetoothGatt.GATT_SUCCESS) {\n                Logger.e(TAG, &quot;\u7cfb\u7edf\u5f02\u5e38\u56de\u8c03onServicesDiscovered&quot;);\n                return;\n            }\n            Logger.e(TAG, &quot;onServicesDiscovered: &quot;);\n            BleDeviceContext.this.bluetoothGattServiceList.addAll(gatt.getServices());\n        }\n\n        public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic\n                characteristic,\n                                         int status) {\n            if (status != BluetoothGatt.GATT_SUCCESS) {\n                Logger.e(TAG, &quot;\u7cfb\u7edf\u5f02\u5e38\u56de\u8c03onCharacteristicRead&quot;);\n                return;\n            }\n\n            Logger.e(TAG, &quot;onCharacteristicRead: &quot;);\n            byte[] value = characteristic.getValue();\n            BleJsCallbackHelper.getInstance().callbackBleCharacteristicValue(webViewFragment,\n                    czWrapperBluetoothDevice.getRealBluetoothDevice().getAddress(),\n                    characteristic.getService().getUuid().toString(),\n                    characteristic.getUuid().toString(),\n                    TransferUtil.bytes2HexString(value));\n            if (value != null) {\n                Logger.e(TAG, &quot;onCharacteristicRead result: &quot; + TransferUtil.bytes2HexString(value) + &quot;\\n&quot; + &quot;byte[] = &quot; + value);\n            }\n        }\n\n        public void onCharacteristicWrite(BluetoothGatt gatt,\n                                          BluetoothGattCharacteristic characteristic, int status) {\n            if (status != BluetoothGatt.GATT_SUCCESS) {\n                Logger.e(TAG, &quot;\u7cfb\u7edf\u5f02\u5e38\u56de\u8c03onCharacteristicWrite&quot;);\n                if (onCharacteristicWriteResultListener != null) {\n                    onCharacteristicWriteResultListener.onWriteFailure();\n                }\n                return;\n            }\n            Logger.e(TAG, &quot;onCharacteristicWrite: &quot;);\n            if (onCharacteristicWriteResultListener != null) {\n                onCharacteristicWriteResultListener.onWriteSuccess();\n            }\n        }\n\n        public void onCharacteristicChanged(BluetoothGatt gatt,\n                                            BluetoothGattCharacteristic characteristic) {\n            Logger.e(TAG, &quot;onCharacteristicChanged: &quot;);\n            byte[] value = characteristic.getValue();\n            BleJsCallbackHelper.getInstance().callbackBleCharacteristicValue(webViewFragment,\n                    czWrapperBluetoothDevice.getRealBluetoothDevice().getAddress(),\n                    characteristic.getService().getUuid().toString(),\n                    characteristic.getUuid().toString(),\n                    TransferUtil.bytes2HexString(value));\n            if (value != null) {\n                Logger.e(TAG, &quot;onCharacteristicChanged result: &quot; + TransferUtil.bytes2HexString(value) + &quot;\\n&quot; + &quot;byte[] = &quot; + value);\n            }\n\n        }\n\n    };\n\n    public void connect(final BluetoothAdapter mBluetoothAdapter, WebViewFragment webViewFragment, final Plugin.PluginCallback connectionImplPluginCallback,\n                        final BLEConnectionImpl bleConnectionImpl, final BLEConnectionParamsBean bleConnectionParamsBean) {\n        if (isDeviceConnected) {\n            bleConnectionImpl.responseFailure(connectionImplPluginCallback, ErrorPool.BluetoothError.createOtherTypeError(&quot;device already connected&quot;));\n            return;\n        }\n        this.webViewFragment = webViewFragment;\n        this.connectionImplPluginCallback = connectionImplPluginCallback;\n        this.bleConnectionImpl = bleConnectionImpl;\n        this.bleConnectionParamsBean = bleConnectionParamsBean;\n\n        this.isOnServicesDiscoveredCalledBack = false;\n        BleDeviceContext.this.bluetoothGattServiceList.clear();\n\n        final boolean[] isScanStopped = {false}; \/**\u6709\u65f6\u5019\uff0c\u5373\u4f7fmBluetoothAdapter.stopLeScan()\u5df2\u7ecf\u8c03\u7528\u8fc7\u4e86\uff0cCallback\u8fd8\u662f\u4f1a\u6709\u56de\u8c03\uff0c\u9700\u8981\u8fc7\u6ee4\u8fd9\u79cd\u9519\u8bef\u7684\u56de\u8c03\u3002*\/\n\n        CZWrapperBluetoothDevice connectedDevice = WxBluetoothGlobalPropertyHolder.getInstance().findConnectedDevice(bleConnectionParamsBean.getDeviceId());\n        if(connectedDevice != null){\n            \/\/\u5df2\u7ecf\u8fde\u63a5\u8fc7\u4e00\u6b21\uff0c\u76f4\u63a5\u8fde\u63a5\u3002\n            Logger.e(TAG, &quot;\u5df2\u7ecf\u8fde\u63a5\u8fc7\u4e00\u6b21\uff0c\u76f4\u63a5\u8fde\u63a5 &quot; + connectedDevice.toString() );\n            BleDeviceContext.this.czWrapperBluetoothDevice = connectedDevice;\n\n            connectedDevice.getRealBluetoothDevice().connectGatt(WebApplication.getInstance().getApplication(), false, bluetoothGattCallback);\n        }else{\n            \/\/\u6ca1\u6709\u8fde\u63a5\uff0c\u626b\u63cf\u540e\u518d\u8fde\u63a5\u3002\n            final BluetoothAdapter.LeScanCallback leScanCallback = new BluetoothAdapter.LeScanCallback() {\n                @Override\n                public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {\n                    CZWrapperBluetoothDevice czWrapperBluetoothDevice = new CZWrapperBluetoothDevice(device, rssi,scanRecord);\n                    if(bleConnectionParamsBean.getDeviceId().equals(czWrapperBluetoothDevice.getRealBluetoothDevice().getAddress())){\n                        if(isScanStopped[0]){\n                            Logger.e(TAG, &quot;\u626b\u63cf\u5df2\u7ecf\u505c\u6b62\u4e86\uff0c\u4f46\u662f\u7cfb\u7edf\u8fd8\u662f\u5728\u56de\u8c03\uff0c\u62d2\u7edd\u8fd9\u79cd\u56de\u8c03\uff0c\u5426\u5219\u4f1a\u5bfc\u81f4\u8fde\u63a5\u4e0d\u6210\u529f\u3002&quot;);\n                            return;\n                        }\n                        \/\/\u5173\u95ed\u626b\u63cf\u8d85\u65f6\u8ba1\u65f6\u5668\n                        timeCounter.stop();\n                        if(isTimeOut) {\n                            Logger.e(TAG, &quot;\u626b\u63cf\u5df2\u7ecf\u8d85\u65f6\u4e86\uff0c\u5373\u4f7f\u8bbe\u5907\u627e\u5230\u4e86\uff0c\u6211\u4e5f\u4e0d\u505a\u5904\u7406\u3002&quot;);\n                            return;\n                        }\n\n                        Logger.e(TAG, &quot;\u626b\u63cf\uff0c\u627e\u5230\u6307\u5b9a\u7684\u8fde\u63a5\u8bbe\u5907&quot; + WxBluetoothDeviceInfo.parse(czWrapperBluetoothDevice));\n                        Logger.e(TAG,&quot;\u505c\u6b62\u626b\u63cf,\u4e00\u5b9a\u8981\u8bb0\u7740\uff0c\u5426\u5219\u8fde\u63a5\u53ef\u80fd\u4f1a\u6709\u95ee\u9898\u3002&quot;);\n                        mBluetoothAdapter.stopLeScan(this);\n                        isScanStopped[0] = true;\n                        Logger.e(TAG,&quot;\u626b\u63cf\u540e\uff0c\u5f00\u59cb\u8fde\u63a5\u8bbe\u5907&quot;);\n                        BleDeviceContext.this.czWrapperBluetoothDevice = czWrapperBluetoothDevice;\n\n                        device.connectGatt(WebApplication.getInstance().getApplication(), false, bluetoothGattCallback);\n                        isTimeOut = false;\n                        \/\/\u5f00\u542f\u8fde\u63a5\u8d85\u65f6\u8ba1\u65f6\u5668\n                        if(bleConnectionParamsBean.getTimeout() &gt; 0) {\n                            timeCounter.setDelayTime(bleConnectionParamsBean.getTimeout());\n                            timeCounter.setTimeCallBack(new TimeCounter.TimeCallBack() {\n                                @Override\n                                public void onTime(int passedCount, long delayMilliSeconds) {\n                                    Logger.e(TAG, &quot;\u8fde\u63a5\u8d85\u65f6\u4e86&quot;);\n                                    timeCounter.stop();\n                                    isTimeOut = true;\n                                    force_disconnect();\n                                    bleConnectionImpl.responseFailure(connectionImplPluginCallback, ErrorPool.BluetoothError.CODE_10012);\n                                }\n                            });\n                            timeCounter.startCount();\n                        }\n                    }\n                }\n            };\n            mBluetoothAdapter.startLeScan(leScanCallback);\n            isScanStopped[0] = false;\n            \/**TODO bleConnectionParamsBean\u91cc\u4f1a\u6709\u4e00\u4e2a\u8d85\u65f6\u65f6\u95f4\uff0c\u4e0d\u6e05\u695a\u5230\u5e95\u662f\u626b\u63cf\u8d85\u65f6\u8fd8\u662f\u8fde\u63a5\u8d85\u65f6\u3002\n             * \u76ee\u524d\u5904\u7406\u529e\u6cd5\u662f\uff1a\u626b\u63cf\u65f6\u7528\u8fd9\u4e2a\u8d85\u65f6\uff0c\u8fde\u63a5\u4e5f\u7528\u8fd9\u4e2a\u8d85\u65f6\u3002\n             * *\/\n            isTimeOut = false;\n            if(bleConnectionParamsBean.getTimeout() &gt; 0){\n                timeCounter.setDelayTime(bleConnectionParamsBean.getTimeout());\n                timeCounter.setTimeCallBack(new TimeCounter.TimeCallBack() {\n                    @Override\n                    public void onTime(int passedCount, long delayMilliSeconds) {\n                        Logger.e(TAG, &quot;\u626b\u63cf\u8d85\u65f6\u4e86&quot;);\n                        isTimeOut = true;\n                        timeCounter.stop();\n                        bleConnectionImpl.responseFailure(connectionImplPluginCallback,ErrorPool.BluetoothError.CODE_10012);\n                        mBluetoothAdapter.stopLeScan(leScanCallback);\n                    }\n                });\n                timeCounter.startCount();\n            }\n        }\n    }\n\n    public void disconnect(){\n        Logger.e(TAG, &quot;disconnect: &quot; );\n        \/\/\u6e05\u9664\u4e4b\u524d\u7684\u8fde\u63a5\uff0c\u9632\u6b62\u7528\u6237\u8fde\u7eed\u8c03\u7528\u4e86create2\u6b21\uff0c\u5bfc\u81f4\u8fde\u63a5\u6ca1\u6709\u91ca\u653e\u3002\n        if(this.curConnectedGatt != null &amp;&amp; isDeviceConnected){\n            this.curConnectedGatt.disconnect();\n            this.curConnectedGatt = null;\n            Logger.e(TAG, &quot;disconnect:1111 &quot; );\n        }else{\n            Logger.e(TAG, &quot;disconnect:2222 &quot; );\n            bleConnectionImpl.responseFailure(connectionImplPluginCallback,ErrorPool.BluetoothError.createOtherTypeError(&quot;device already disconnected&quot;));\n        }\n    }\n\n    \/**\n     * \u7528\u4e8e\u8d85\u65f6\u5173\u95ed\uff0c\u4e0d\u7ed9JS\u56de\u8c03\u3002\n     *\/\n    private void force_disconnect(){\n        Logger.e(TAG, &quot;disconnect: &quot; );\n        \/\/\u6e05\u9664\u4e4b\u524d\u7684\u8fde\u63a5\uff0c\u9632\u6b62\u7528\u6237\u8fde\u7eed\u8c03\u7528\u4e86create2\u6b21\uff0c\u5bfc\u81f4\u8fde\u63a5\u6ca1\u6709\u91ca\u653e\u3002\n        if(this.curConnectedGatt != null &amp;&amp; isDeviceConnected){\n            this.curConnectedGatt.disconnect();\n            this.curConnectedGatt = null;\n            Logger.e(TAG, &quot;disconnect:1111 &quot; );\n        }else{\n            Logger.e(TAG, &quot;disconnect:3333 &quot; );\n        }\n    }\n\n    \/**\n     * \u662f\u5426\u6709\u670d\u52a1\n     * @return\n     *\/\n    public  boolean isThereAnySerivce(){\n        if(bluetoothGattServiceList == null || bluetoothGattServiceList.size() == 0) return false;\n        return true;\n    }\n\n    \/**\n     * \u67e5\u627e\u6307\u5b9a\u7684\u670d\u52a1\n     * @param serviceId\n     * @return\n     *\/\n    public BluetoothGattService findService(String serviceId){\n        if(bluetoothGattServiceList == null || bluetoothGattServiceList.size() == 0) return null;\n        for (BluetoothGattService item : bluetoothGattServiceList){\n            if(serviceId.equals(item.getUuid().toString())){\n                return item;\n            }\n        }\n        return null;\n    }\n\n    \/\/\u5199\u7279\u5f81\u503c\u76d1\u542c\n    public void registOnCharacteristicWriteResultListener(OnCharacteristicWriteResultListener onCharacteristicWriteResultListener){\n        this.onCharacteristicWriteResultListener = onCharacteristicWriteResultListener;\n    }\n\n    public interface OnCharacteristicWriteResultListener{\n        void onWriteSuccess();\n        void onWriteFailure();\n    }\n\n    \/\/java bean\n    public BluetoothGatt getCurConnectedGatt() {\n        return curConnectedGatt;\n    }\n\n    public void setCurConnectedGatt(BluetoothGatt curConnectedGatt) {\n        this.curConnectedGatt = curConnectedGatt;\n    }\n\n    public boolean isDeviceConnected() {\n        return isDeviceConnected;\n    }\n\n    public void setDeviceConnected(boolean deviceConnected) {\n        isDeviceConnected = deviceConnected;\n    }\n\n    public CZWrapperBluetoothDevice getCzWrapperBluetoothDevice() {\n        return czWrapperBluetoothDevice;\n    }\n\n    public void setCzWrapperBluetoothDevice(CZWrapperBluetoothDevice czWrapperBluetoothDevice) {\n        this.czWrapperBluetoothDevice = czWrapperBluetoothDevice;\n    }\n\n    public List&lt;BluetoothGattService&gt; getBluetoothGattServiceList() {\n        return bluetoothGattServiceList;\n    }\n}<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E8%AE%BE%E5%A4%87%E5%B0%81%E8%A3%85%E7%B1%BB%E7%9A%84%E7%AE%A1%E7%90%86%E7%B1%BB\"><\/span>\u8bbe\u5907\u5c01\u88c5\u7c7b\u7684\u7ba1\u7406\u7c7b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-java\">\/**\n * \u7ba1\u7406\u8bbe\u5907\u4e0a\u4e0b\u6587\n *\/\npublic class BleDeviceContextManager {\n    private static final String TAG = &quot;BleDeviceContextManager&quot;;\n    private static final BleDeviceContextManager ourInstance = new BleDeviceContextManager();\n    private Map&lt;String,BleDeviceContext&gt; bleDeviceContextMap;\n    public static BleDeviceContextManager getInstance() {\n        return ourInstance;\n    }\n\n    private BleDeviceContextManager() {\n        bleDeviceContextMap =new HashMap&lt;&gt;();\n    }\n\n    public void release(){\n        \/\/\u65ad\u5f00\u8fde\u63a5\uff0c\u91ca\u653e\u8d44\u6e90\u3002\n        List&lt;BleDeviceContext&gt; connectedBleDeviceContextList = findConnectedBleDeviceContextList();\n        for (BleDeviceContext item : connectedBleDeviceContextList){\n            item.disconnect();\n        }\n        this.bleDeviceContextMap.clear();\n    }\n\n    \/**\n     * \u6839\u636emac\u5730\u5740\u83b7\u53d6\u8bbe\u5907\u4e0a\u4e0b\u6587\n     * @param deviceId\n     * @return\n     *\/\n    public BleDeviceContext findBleDeviceContext(String deviceId){\n        Logger.e(TAG, &quot;findBleDeviceContext: &quot; + deviceId );\n        return bleDeviceContextMap.get(deviceId);\n    }\n\n    \/**\n     * \u83b7\u53d6\u5df2\u7ecf\u8fde\u63a5\u7684\u8bbe\u5907\n     * @return\n     *\/\n    public List&lt;BleDeviceContext&gt; findConnectedBleDeviceContextList(){\n        List&lt;BleDeviceContext&gt; result = new ArrayList&lt;&gt;();\n        for (Iterator&lt;Map.Entry&lt;String, BleDeviceContext&gt;&gt; it = bleDeviceContextMap.entrySet().iterator(); it.hasNext();){\n            Map.Entry&lt;String, BleDeviceContext&gt; item = it.next();\n            if(item.getValue().isDeviceConnected()){\n                result.add(item.getValue());\n            }\n        }\n        return result;\n    }\n\n    \/**\n     * \u6839\u636emac\u5730\u5740\u521b\u5efa\u8bbe\u5907\u4e0a\u4e0b\u6587\n     * @param deviceId\n     * @return\n     *\/\n    public BleDeviceContext createBleDeviceContext(String deviceId){\n        BleDeviceContext bleDeviceContext = findBleDeviceContext(deviceId);\n        if(bleDeviceContext != null){\n            Logger.e(TAG, &quot;deviceId = &quot; + deviceId + &quot;,\u5df2\u7ecf\u521b\u5efa\u4e0a\u4e0b\u6587\u5bf9\u8c61,\u8bf7\u52ff\u91cd\u590d\u521b\u5efa\u3002&quot; );\n            return null;\n        }\n        BleDeviceContext result = new BleDeviceContext();\n        bleDeviceContextMap.put(deviceId,result);\n        return result;\n    }\n\n    \/**\n     * \u6839\u636emac\u5730\u5740\u79fb\u9664\u8bbe\u5907\u4e0a\u4e0b\u6587\n     * @param deviceId\n     * @return\n     *\/\n    public void removeBleDeviceContext(String deviceId){\n        BleDeviceContext bleDeviceContext = findBleDeviceContext(deviceId);\n        if(bleDeviceContext == null){\n            Logger.e(TAG, &quot;deviceId = &quot; + deviceId + &quot;,\u4e0a\u4e0b\u6587\u5bf9\u8c61\u4e0d\u5b58\u5728\uff0c\u5c31\u522b\u79fb\u9664\u4e86\u3002&quot; );\n            return ;\n        }\n        bleDeviceContextMap.remove(deviceId);\n    }\n}<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%E6%9C%8D%E5%8A%A1%E7%AB%AF%E7%9A%84%E5%AE%9E%E7%8E%B0%EF%BC%8C%E4%BC%9A%E5%9C%A8%E5%90%8E%E7%BB%AD%E5%8D%9A%E5%AE%A2%E4%B8%AD%E6%8C%81%E7%BB%AD%E6%9B%B4%E6%96%B0%EF%BC%8C%E6%95%AC%E8%AF%B7%E5%85%B3%E6%B3%A8%E3%80%82\"><\/span>\u670d\u52a1\u7aef\u7684\u5b9e\u73b0\uff0c\u4f1a\u5728\u540e\u7eed\u535a\u5ba2\u4e2d\u6301\u7eed\u66f4\u65b0\uff0c\u656c\u8bf7\u5173\u6ce8\u3002<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u5982\u6709\u7591\u60d1\u6216\u8005\u597d\u7684\u5efa\u8bae\uff0c\u6216\u8005\u60f3\u7ea0\u6b63\u4f5c\u8005\u7684\u535a\u6587\uff0c\u8bf7\u8054\u7cfb\u5982\u4e0b<br \/>\n\u516c\u4f17\u53f7\uff1a\u5fae\u4fe1\u516c\u4f17\u53f7\u641c\u7d22\u201c\u4fee\u7b26\u9053\u4eba\u201d\u6216\u8005\u626b\u63cf\u4e0b\u65b9\u4e8c\u7ef4\u7801<br \/>\n<img src=\"https:\/\/upload-images.jianshu.io\/upload_images\/18328858-59371629ef391585.jpg?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"qrcode_for_gh_97ef1213cc5b_258.jpg\" \/><\/p>\n<p>\u5fae\u4fe1\u53f7\uff1aXinYi1349308479<br \/>\nQQ\u90ae\u7bb1\uff1a1349308479@qq.com<\/p>\n<button class=\"simplefavorite-button\" data-postid=\"4709\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8e\u84dd\u7259\u7684\u5404\u79cd\u6982\u5ff5\uff0c\u4e0d\u592a\u719f\u6089\u7684\uff0c\u53ef\u4ee5\u770b\u6211\u768451CTO\u7684\u535a\u5ba2https:\/\/blog.51cto.co [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[228],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/4709"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4709"}],"version-history":[{"count":2,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/4709\/revisions"}],"predecessor-version":[{"id":15893,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/4709\/revisions\/15893"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4709"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}