├── pages
├── index
│ ├── index.json
│ ├── index.wxss
│ ├── index.wxml
│ └── index.js
└── bluetooth
│ ├── bluetooth.json
│ ├── bluetooth.wxss
│ ├── bluetooth.wxml
│ └── bluetooth.js
├── images
├── exam.png
├── home.png
├── mine.png
├── tool.png
├── examselected.png
├── homeselected.png
├── mineselected.png
└── toolselected.png
├── app.wxss
├── README.md
├── app.json
└── app.js
/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/bluetooth/bluetooth.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/bluetooth/bluetooth.wxss:
--------------------------------------------------------------------------------
1 | /* pages/tool/tool.wxss */
--------------------------------------------------------------------------------
/images/exam.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xwm111/wechatminiprogramforbluetooth/HEAD/images/exam.png
--------------------------------------------------------------------------------
/images/home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xwm111/wechatminiprogramforbluetooth/HEAD/images/home.png
--------------------------------------------------------------------------------
/images/mine.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xwm111/wechatminiprogramforbluetooth/HEAD/images/mine.png
--------------------------------------------------------------------------------
/images/tool.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xwm111/wechatminiprogramforbluetooth/HEAD/images/tool.png
--------------------------------------------------------------------------------
/images/examselected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xwm111/wechatminiprogramforbluetooth/HEAD/images/examselected.png
--------------------------------------------------------------------------------
/images/homeselected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xwm111/wechatminiprogramforbluetooth/HEAD/images/homeselected.png
--------------------------------------------------------------------------------
/images/mineselected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xwm111/wechatminiprogramforbluetooth/HEAD/images/mineselected.png
--------------------------------------------------------------------------------
/images/toolselected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xwm111/wechatminiprogramforbluetooth/HEAD/images/toolselected.png
--------------------------------------------------------------------------------
/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .container {
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | justify-content: space-between;
8 | padding: 200rpx 0;
9 | box-sizing: border-box;
10 | }
11 |
12 |
13 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | a demo for how to use bluetooth to connect to BLE 4.0 device.
2 | you can use it to communicate with BLE device
3 |
4 | 一个微信小程序,能够搜索并连接蓝牙4.0设备,还能够和蓝牙设备进行数据交互
5 |
6 |
7 | please modify the serviceId and characteristicId to match your bluetooth device
8 |
9 | 请将index.js文件中的 serviceId和characteristicId 修改成和你蓝牙设备相匹配
10 |
11 | 2017-04-13
12 | 增加通用模块,发现设备之后能够搜索设备的serviceId和搜索在该serviceId下的characteristicId(serviceId目前使用的是第一个,如有需要使用其他的请自行修改)
13 |
14 |
15 | 目前请用安卓手机调试,IOS的接口貌似有些不一样,下个版本改进
16 |
17 |
18 |
19 | Q群:54073007
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages":[
3 | "pages/index/index",
4 | "pages/bluetooth/bluetooth"
5 | ],
6 | "window":{
7 | "backgroundTextStyle":"light",
8 | "navigationBarBackgroundColor": "#fff",
9 | "navigationBarTitleText": "蓝牙小程序调试工具",
10 | "navigationBarTextStyle":"black"
11 | },
12 | "tabBar": {
13 |
14 | "borderStyle": "white",
15 |
16 | "list": [{
17 | "pagePath": "pages/index/index",
18 | "iconPath": "images/home.png",
19 | "selectedIconPath": "images/homeselected.png",
20 | "text": "简单"
21 | }, {
22 | "pagePath": "pages/bluetooth/bluetooth",
23 | "iconPath": "images/exam.png",
24 | "selectedIconPath": "images/examselected.png",
25 | "text": "通用"
26 | }]
27 | },
28 | "debug":true
29 | }
30 |
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 | //调用API从本地缓存中获取数据
5 | var logs = wx.getStorageSync('logs') || []
6 | logs.unshift(Date.now())
7 | wx.setStorageSync('logs', logs)
8 | },
9 | getUserInfo:function(cb){
10 | var that = this
11 | if(this.globalData.userInfo){
12 | typeof cb == "function" && cb(this.globalData.userInfo)
13 | }else{
14 | //调用登录接口
15 | wx.login({
16 | success: function () {
17 | wx.getUserInfo({
18 | success: function (res) {
19 | that.globalData.userInfo = res.userInfo
20 | typeof cb == "function" && cb(that.globalData.userInfo)
21 | }
22 | })
23 | }
24 | })
25 | }
26 | },
27 | globalData:{
28 | userInfo:null
29 | }
30 | })
--------------------------------------------------------------------------------
/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | view {
2 | display: inline-block;
3 | }
4 |
5 | .container {
6 | padding: 0;
7 | margin: 0;
8 | align-items: flex-start;
9 | }
10 |
11 | .section {
12 | display: inline-block;
13 | width: 100%;
14 | position: relative;
15 | }
16 |
17 | .content {
18 | margin: auto;
19 | padding: auto;
20 | position: absolute;
21 | top: 5px;
22 | left: 10px;
23 | }
24 |
25 | .switch {
26 | position: relative;
27 | float: right;
28 | right: 0px;
29 | }
30 |
31 | button {
32 | background: red\;
33 | }
34 |
35 | .list-item {
36 | margin-top: 20rpx;
37 | margin-bottom: 20rpx;
38 | display: flex;
39 | flex-direction: column;
40 | box-sizing: border-box;
41 | border: 1px dashed #000;
42 | }
43 |
44 | .list-item text {
45 | margin-top: 10rpx;
46 | }
47 |
48 |
49 | .list-item button {
50 | margin-right: 10rpx;
51 | }
52 |
53 | .deviceconnected{
54 | background-color:sandybrown
55 | }
56 |
57 | .recieve{
58 |
59 | width: 100%
60 | }
61 |
62 | .recieve textarea{
63 | border: 1px dashed;
64 | width: 100%
65 | }
66 |
67 | input{
68 | display: block;
69 | border: 1px dashed;
70 | width: 200px;
71 | }
72 |
73 |
--------------------------------------------------------------------------------
/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 蓝牙初始化:
7 | {{isbluetoothready?"ok":"尚未初始化"}}
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | 设备名称:{{item.name}}
20 | 设备ID:{{item.deviceId}}
21 |
22 |
23 |
24 |
25 |
26 |
27 | 数据接收
28 |
29 |
30 |
31 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/pages/bluetooth/bluetooth.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 功能启用
6 |
7 |
8 | {{errmsg}}
9 | {{actioninfo}}
10 | {{searchingstatus}}
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | 设备名称:{{item.name}}
22 | 设备ID:{{item.deviceId}}
23 | 连接状态:{{connected?"已连接":"未连接"}}
24 |
25 | 接收到消息
26 |
27 |
28 |
29 |
30 |
31 | 发送消息
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | serviceId(uuid):{{item.uuid}}
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/pages/index/index.js:
--------------------------------------------------------------------------------
1 | var app = getApp()
2 | var temp = []
3 | var serviceId = "0000ffe0-0000-1000-8000-00805f9b34fb"
4 | var characteristicId = "0000ffe1-0000-1000-8000-00805f9b34fb"
5 | Page({
6 | data: {
7 | isbluetoothready: false,
8 | defaultSize: 'default',
9 | primarySize: 'default',
10 | warnSize: 'default',
11 | disabled: false,
12 | plain: false,
13 | loading: false,
14 | searchingstatus: false,
15 | receivedata: '',
16 | onreceiving: false
17 | },
18 | onLoad: function () {
19 | // var str = "A13";
20 | // // var code = str.charCodeAt();
21 | // console.log(str.length)
22 | // console.log(str.charAt(0))
23 | // wx.showToast({
24 | // title: '连接成功',
25 | // icon: 'success',
26 | // duration: 2000
27 | // })
28 | // let buffer = new ArrayBuffer(16)
29 | // let dataView = new DataView(buffer)
30 | // dataView.setUint8(1, 6)
31 | //console.log(dataView.getUint8(1))
32 | },
33 | switchBlueTooth: function () {
34 | var that = this
35 |
36 | that.setData({
37 | isbluetoothready: !that.data.isbluetoothready,
38 | })
39 |
40 | if (that.data.isbluetoothready) {
41 | wx.openBluetoothAdapter({
42 | success: function (res) {
43 | console.log("初始化蓝牙适配器成功")
44 | wx.onBluetoothAdapterStateChange(function (res) {
45 | console.log("蓝牙适配器状态变化", res)
46 | that.setData({
47 | isbluetoothready: res.available,
48 | searchingstatus: res.discovering
49 | })
50 | })
51 | wx.onBluetoothDeviceFound(function (devices) {
52 | console.log(devices)
53 | temp.push(devices)
54 | that.setData({
55 | devices: temp
56 | })
57 | console.log('发现新蓝牙设备')
58 | console.log('设备id' + devices.deviceId)
59 | console.log('设备name' + devices.name)
60 | })
61 | wx.onBLECharacteristicValueChange(function (characteristic) {
62 | console.log('characteristic value comed:')
63 | let buffer = characteristic.value
64 | let dataView = new DataView(buffer)
65 | console.log("接收字节长度:" + dataView.byteLength)
66 | var str = ""
67 | for (var i = 0; i < dataView.byteLength; i++) {
68 | str += String.fromCharCode(dataView.getUint8(i))
69 | }
70 | str=getNowFormatDate()+"收到数据:"+str;
71 | that.setData({
72 | receivedata: that.data.receivedata + "\n" + str,
73 | onreceiving: true
74 | })
75 | })
76 | },
77 | fail: function (res) {
78 | console.log("初始化蓝牙适配器失败")
79 | wx.showModal({
80 | title: '提示',
81 | content: '请检查手机蓝牙是否打开',
82 | success: function (res) {
83 | that.setData({
84 | isbluetoothready: false,
85 | searchingstatus: false
86 | })
87 | }
88 | })
89 | }
90 | })
91 | } else {
92 | temp = []
93 | //先关闭设备连接
94 | wx.closeBLEConnection({
95 | deviceId: that.data.connectedDeviceId,
96 | complete: function (res) {
97 | console.log(res)
98 | that.setData({
99 | deviceconnected: false,
100 | connectedDeviceId: ""
101 | })
102 | }
103 | })
104 | wx.closeBluetoothAdapter({
105 | success: function (res) {
106 | console.log(res)
107 | that.setData({
108 | isbluetoothready: false,
109 | deviceconnected: false,
110 | devices: [],
111 | searchingstatus: false,
112 | receivedata: ''
113 | })
114 | },
115 | fail: function (res) {
116 | wx.showModal({
117 | title: '提示',
118 | content: '请检查手机蓝牙是否打开',
119 | success: function (res) {
120 | that.setData({
121 | isbluetoothready: false
122 | })
123 | }
124 | })
125 | }
126 | })
127 | }
128 | },
129 | searchbluetooth: function () {
130 | temp = []
131 | var that = this
132 | if (!that.data.searchingstatus) {
133 | var that = this
134 | wx.startBluetoothDevicesDiscovery({
135 | success: function (res) {
136 | console.log("开始搜索附近蓝牙设备")
137 | console.log(res)
138 | that.setData({
139 | searchingstatus: !that.data.searchingstatus
140 | })
141 | }
142 | })
143 | } else {
144 | wx.stopBluetoothDevicesDiscovery({
145 | success: function (res) {
146 | console.log("停止蓝牙搜索")
147 | console.log(res)
148 | }
149 | })
150 | }
151 | },
152 | connectTO: function (e) {
153 | var that = this
154 |
155 | if (that.data.deviceconnected) {
156 | wx.notifyBLECharacteristicValueChanged({
157 | state: false, // 停用notify 功能
158 | deviceId: that.data.connectedDeviceId,
159 | serviceId: serviceId,
160 | characteristicId: characteristicId,
161 | success: function (res) {
162 | console.log("停用notify 功能")
163 | }
164 | })
165 | wx.closeBLEConnection({
166 | deviceId: e.currentTarget.id,
167 | complete: function (res) {
168 | console.log("断开设备")
169 | console.log(res)
170 | that.setData({
171 | deviceconnected: false,
172 | connectedDeviceId: "",
173 | receivedata: ""
174 | })
175 | }
176 | })
177 | } else {
178 | wx.showLoading({
179 | title: '连接蓝牙设备中...',
180 | })
181 | wx.createBLEConnection({
182 | deviceId: e.currentTarget.id,
183 | success: function (res) {
184 | wx.hideLoading()
185 | wx.showToast({
186 | title: '连接成功',
187 | icon: 'success',
188 | duration: 1000
189 | })
190 | console.log("连接设备成功")
191 | console.log(res)
192 | that.setData({
193 | deviceconnected: true,
194 | connectedDeviceId: e.currentTarget.id
195 | })
196 |
197 | wx.notifyBLECharacteristicValueChanged({
198 | state: true, // 启用 notify 功能
199 | deviceId: that.data.connectedDeviceId,
200 | serviceId: serviceId,
201 | characteristicId: characteristicId,
202 | success: function (res) {
203 | console.log("启用notify")
204 | }
205 | })
206 | },
207 | fail: function (res) {
208 | wx.hideLoading()
209 | wx.showToast({
210 | title: '连接设备失败',
211 | icon: 'success',
212 | duration: 1000
213 | })
214 | console.log("连接设备失败")
215 | console.log(res)
216 | that.setData({
217 | connected: false
218 | })
219 | }
220 | })
221 | wx.stopBluetoothDevicesDiscovery({
222 | success: function (res) {
223 | console.log("停止蓝牙搜索")
224 | console.log(res)
225 | }
226 | })
227 | }
228 | },
229 | formSubmit: function (e) {
230 | console.log('form发生了submit事件,携带数据为:', e.detail.value.senddata)
231 | var senddata = e.detail.value.senddata;
232 | var that = this
233 | let buffer = new ArrayBuffer(senddata.length)
234 | let dataView = new DataView(buffer)
235 | for (var i = 0; i < senddata.length; i++) {
236 | dataView.setUint8(i, senddata.charAt(i).charCodeAt())
237 | }
238 | wx.writeBLECharacteristicValue({
239 | deviceId: that.data.connectedDeviceId,
240 | serviceId: serviceId,
241 | characteristicId: characteristicId,
242 | value: buffer,
243 | success: function (res) {
244 | console.log(res)
245 | console.log('writeBLECharacteristicValue success', res.errMsg)
246 | }
247 | })
248 | },
249 | formReset: function () {
250 | console.log('form发生了reset事件')
251 | }
252 | })
253 |
254 |
255 |
256 | function getNowFormatDate() {
257 | var date = new Date();
258 | var seperator1 = "-";
259 | var seperator2 = ":";
260 | var month = date.getMonth() + 1;
261 | var strDate = date.getDate();
262 | if (month >= 1 && month <= 9) {
263 | month = "0" + month;
264 | }
265 | if (strDate >= 0 && strDate <= 9) {
266 | strDate = "0" + strDate;
267 | }
268 | var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
269 | + " " + date.getHours() + seperator2 + date.getMinutes()
270 | + seperator2 + date.getSeconds();
271 | return currentdate;
272 | }
--------------------------------------------------------------------------------
/pages/bluetooth/bluetooth.js:
--------------------------------------------------------------------------------
1 | var app = getApp()
2 | var temp = []
3 | Page({
4 | data: {
5 | motto: 'Hello World',
6 | userInfo: {},
7 | isopen: false,
8 | disabled: false,
9 | connected: false
10 | },
11 | switchChange: function () {
12 | var that = this
13 | that.setData({
14 | isopen: !that.data.isopen,
15 | errmsg: ""
16 | })
17 | if (that.data.isopen) {
18 | wx.openBluetoothAdapter({
19 | success: function (res) {
20 | console.log(res)
21 | that.setData({
22 | errmsg: "功能已启用"
23 | })
24 | wx.onBluetoothAdapterStateChange(function (res) {
25 | console.log("蓝牙适配器状态变化", res)
26 | that.setData({
27 | actioninfo: res.available ? "蓝牙适配器可用" : "蓝牙适配器不可用",
28 | searchingstatus: res.discovering ? "正在搜索" : "搜索可用"
29 | })
30 | })
31 | wx.onBluetoothDeviceFound(function (devices) {
32 | console.log(devices)
33 | temp.push(devices)
34 | that.setData({
35 | devices: temp
36 | })
37 | console.log('new device list has founded')
38 | console.log('设备id' + devices.deviceId)
39 | console.log('设备name' + devices.name)
40 | })
41 | },
42 | fail: function (res) {
43 | console.log(res)
44 | that.setData({
45 | errmsg: "请检查手机蓝牙是否打开"
46 | })
47 | }
48 | })
49 | } else {
50 | wx.closeBluetoothAdapter({
51 | success: function (res) {
52 | console.log(res)
53 | that.setData({
54 | errmsg: "功能已关闭"
55 | })
56 | },
57 | fail: function (res) {
58 | console.log(res)
59 | that.setData({
60 | errmsg: "请检查手机蓝牙是否打开"
61 | })
62 | }
63 | })
64 | }
65 | console.log('bluetooth is open :' + that.data.isopen)
66 | },
67 | searchbluetooth: function () {
68 | var that = this
69 | wx.startBluetoothDevicesDiscovery({
70 | success: function (res) {
71 | console.log("开始搜索附近蓝牙设备")
72 | console.log(res)
73 | }
74 | })
75 | },
76 | connectTO: function (e) {
77 | var that = this
78 | console.log(e)
79 | wx.createBLEConnection({
80 | deviceId: e.currentTarget.id,
81 | //deviceId: "98:D3:32:30:B0:4E",
82 | success: function (res) {
83 | console.log("连接设备成功")
84 | console.log(res)
85 | that.setData({
86 | connected: true,
87 | connectedDeviceId: e.currentTarget.id
88 | })
89 | },
90 | fail: function (res) {
91 | console.log("连接设备失败")
92 | console.log(res)
93 | that.setData({
94 | connected: false
95 | })
96 | }
97 | })
98 | wx.stopBluetoothDevicesDiscovery(function () {
99 |
100 | })
101 | },
102 | showbluetooth: function () {
103 | wx.getBluetoothDevices({
104 | success: function (res) {
105 | console.log("显示所有蓝牙设备")
106 | console.log(res)
107 | }
108 | })
109 | },
110 | checkbluetooth: function () {
111 | var that = this
112 | wx.getBluetoothAdapterState({
113 | success: function (res) {
114 | console.log(res)
115 | that.setData({
116 | actioninfo: res.available ? "蓝牙适配器可用" : "蓝牙适配器不可用",
117 | searchingstatus: res.discovering ? "正在搜索" : "搜索可用"
118 | })
119 | },
120 | fail: function (res) {
121 | console.log(res)
122 | that.setData({
123 | errmsg: "获取蓝牙适配器信息失败"
124 | })
125 | }
126 | })
127 | },
128 | stopsearch: function () {
129 | wx.stopBluetoothDevicesDiscovery({
130 | success: function (res) {
131 | console.log("停止蓝牙搜索")
132 | console.log(res)
133 | }
134 | })
135 | },
136 | sendtoequ: function (e) {
137 | var that = this
138 | console.log(this.data.services)
139 | console.log("发送消息到:deviceId" + that.data.connectedDeviceId);
140 | console.log("serviceId:" + that.data.services[0].uuid);
141 | console.log("characteristicId:" + that.data.characteristicId);
142 |
143 | let buffer = new ArrayBuffer(1)
144 | let dataView = new DataView(buffer)
145 | dataView.setUint8(0, 6)
146 |
147 | wx.writeBLECharacteristicValue({
148 | // 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
149 | deviceId: that.data.connectedDeviceId,
150 | // 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
151 | serviceId: that.data.services[0].uuid,
152 | // 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取
153 | characteristicId: that.data.characteristicId,
154 | // 这里的value是ArrayBuffer类型
155 | value: buffer,
156 | success: function (res) {
157 | console.log(res)
158 | console.log('writeBLECharacteristicValue success', res.errMsg)
159 | }
160 | })
161 | },
162 | inputTextchange: function (e) {
163 | console.log("数据变化")
164 | console.log(e)
165 | this.setData({
166 | inputValue: e.detail.value
167 | })
168 | },
169 | getAllservice: function (e) {
170 | var that = this
171 | wx.getBLEDeviceServices({
172 | // 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
173 | deviceId: this.data.connectedDeviceId,
174 | success: function (res) {
175 | console.log('device services:', res.services)
176 | that.setData({
177 | services: res.services
178 | })
179 | }
180 | })
181 | },
182 | linkto: function (e) {
183 | var that = this
184 | wx.getBLEDeviceCharacteristics({
185 | // 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
186 | deviceId: that.data.connectedDeviceId,
187 | // 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
188 | serviceId: e.currentTarget.id,
189 | success: function (res) {
190 | console.log('device getBLEDeviceCharacteristics:', res.characteristics)
191 | console.log(res)
192 | that.setData({
193 | characteristicId: res.characteristics[0].uuid,
194 | serviceId: e.currentTarget.id
195 | })
196 | wx.notifyBLECharacteristicValueChanged({
197 | state: true, // 启用 notify 功能
198 | // 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
199 | deviceId: that.data.connectedDeviceId,
200 | // 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
201 | serviceId: that.data.serviceId,
202 | // 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取
203 | characteristicId: that.data.characteristicId,
204 | success: function (res) {
205 | console.log('notifyBLECharacteristicValueChanged success', res.errMsg)
206 | }
207 | })
208 | }
209 | })
210 | },
211 | recieveequ: function (e) {
212 | var that = this
213 | wx.onBLECharacteristicValueChange(function (characteristic) {
214 | console.log('characteristic value comed:')
215 | let buffer = characteristic.value
216 | let dataView = new DataView(buffer)
217 | console.log("接收字节长度:"+dataView.byteLength)
218 | console.log(dataView.getUint8(0))
219 | })
220 | wx.readBLECharacteristicValue({
221 | // 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
222 | deviceId: that.data.connectedDeviceId,
223 | // 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
224 | serviceId: that.data.serviceId,
225 | characteristicId: that.data.characteristicId,
226 | success: function (res) {
227 | console.log('readBLECharacteristicValue:')
228 | console.log(res)
229 | }
230 | })
231 | }
232 | })
233 |
--------------------------------------------------------------------------------