Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yanshouyi-Minipro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xinzhedeai
yanshouyi-Minipro
Commits
2acd14a6
Commit
2acd14a6
authored
Jan 04, 2025
by
xinzhedeai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发送蓝牙信息到从设备 公共方法抽取
parent
8d0dd4b2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
27 deletions
+52
-27
mixin.js
common/mixin.js
+3
-1
util.js
common/util.js
+21
-0
blueSearch.vue
pages/home/blueSearch.vue
+1
-1
home.vue
pages/home/home.vue
+27
-25
No files found.
common/mixin.js
View file @
2acd14a6
...
@@ -6,7 +6,8 @@ import {
...
@@ -6,7 +6,8 @@ import {
showCustomToast
,
showCustomToast
,
commonStateCodeDeal
,
commonStateCodeDeal
,
blueToother
,
blueToother
,
storager
storager
,
popuper
}
from
'
./util.js
'
}
from
'
./util.js
'
const
blueToothMixin
=
{
const
blueToothMixin
=
{
...
@@ -264,6 +265,7 @@ const blueToothMixin = {
...
@@ -264,6 +265,7 @@ const blueToothMixin = {
if
(
!
isService
)
{
if
(
!
isService
)
{
this
.
setConnectState
(
false
)
this
.
setConnectState
(
false
)
this
.
setNavBarTitle
(
'
未发现可匹配的验收仪设备服务,请确认连接的设备是否正确~
'
)
this
.
setNavBarTitle
(
'
未发现可匹配的验收仪设备服务,请确认连接的设备是否正确~
'
)
popuper
.
hideLoading
()
}
}
}
else
{
}
else
{
this
.
setConnectState
(
false
)
this
.
setConnectState
(
false
)
...
...
common/util.js
View file @
2acd14a6
...
@@ -342,6 +342,27 @@ var pager = {
...
@@ -342,6 +342,27 @@ var pager = {
var
blueToother
=
{
var
blueToother
=
{
serviceId
:
'
0000FFE0-0000-1000-8000-00805F9B34FB
'
,
characteristicId_WRITE
:
'
0000FFE1-0000-1000-8000-00805F9B34FB
'
,
// 写特征值
characteristicId_NOTIFY
:
'
0000FFE1-0000-1000-8000-00805F9B34FB
'
,
// 通知特征值
writeBLECharacteristicValue
:
function
(
value
){
// value: 'GETDATA'
var
strbuf
=
new
Uint8Array
(
stringToBytes
(
value
));
var
buffer1
=
strbuf
.
buffer
;
uni
.
writeBLECharacteristicValue
({
deviceId
:
storager
.
get
(
'
deviceInfo
'
).
deviceId
,
serviceId
:
this
.
serviceId
,
characteristicId
:
this
.
characteristicId_WRITE
,
value
:
buffer1
,
success
:
(
res
)
=>
{
console
.
log
(
'
writeBLECharacteristicValue-success:res1=>
'
,
res
)
},
fail
:
(
res
)
=>
{
console
.
log
(
'
writeBLECharacteristicValue-fail:res1=>
'
,
res
)
// commonStateCodeDeal(res.errCode || res, 'gosend -> writeBLECharacteristicValue',
// this)
},
});
},
openBluetoothAdapter
:
function
()
{
openBluetoothAdapter
:
function
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
...
...
pages/home/blueSearch.vue
View file @
2acd14a6
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<view
class=
"wrapper"
>
<view
class=
"wrapper"
>
<CustomNavbar
title=
"蓝牙扫描"
@
gobackDeal=
"gobackDeal('blueSearch')"
>
<CustomNavbar
title=
"蓝牙扫描"
@
gobackDeal=
"gobackDeal('blueSearch')"
>
</CustomNavbar>
</CustomNavbar>
<view
class=
""
style=
"text-align: center; color: #
000
; font-size: 32rpx; margin-top:20rpx;"
>
<view
class=
""
style=
"text-align: center; color: #
fff
; font-size: 32rpx; margin-top:20rpx;"
>
{{
pageLoadText
}}
{{
pageLoadText
}}
</view>
</view>
<view
class=
"body-wrapper"
>
<view
class=
"body-wrapper"
>
...
...
pages/home/home.vue
View file @
2acd14a6
...
@@ -90,7 +90,8 @@
...
@@ -90,7 +90,8 @@
commonStateCodeDeal
,
commonStateCodeDeal
,
popup
,
popup
,
storager
,
storager
,
pager
pager
,
blueToother
}
from
"
../../common/util.js
"
}
from
"
../../common/util.js
"
import
*
as
XLSX
from
'
@/common/excel.js
'
import
*
as
XLSX
from
'
@/common/excel.js
'
...
@@ -213,30 +214,31 @@
...
@@ -213,30 +214,31 @@
})
})
}
}
},
},
gosend
()
{
gosend
(
text
)
{
this
.
$store
.
commit
(
'
setMeasureVal
'
,
{
blueToother
.
writeBLECharacteristicValue
(
text
)
actualDepth
:
'
xxx
'
,
// 孔深
// this.$store.commit('setMeasureVal', {
actualWaterLevel
:
'
666
'
// 水深
// actualDepth: 'xxx', // 孔深
})
// actualWaterLevel: '666' // 水深
var
strbuf
=
new
Uint8Array
(
stringToBytes
(
'
GETDATA
'
));
// })
var
buffer1
=
strbuf
.
buffer
;
// var strbuf = new Uint8Array(stringToBytes('GETDATA'));
setTimeout
(()
=>
{
// var buffer1 = strbuf.buffer;
uni
.
writeBLECharacteristicValue
({
// setTimeout(() => {
// deviceId: 'C8:47:80:52:93:A2',
// uni.writeBLECharacteristicValue({
deviceId
:
storager
.
get
(
'
deviceInfo
'
).
deviceId
,
// // deviceId: 'C8:47:80:52:93:A2',
serviceId
:
'
0000FFE0-0000-1000-8000-00805F9B34FB
'
,
// deviceId: storager.get('deviceInfo').deviceId,
characteristicId
:
'
0000FFE1-0000-1000-8000-00805F9B34FB
'
,
// serviceId: '0000FFE0-0000-1000-8000-00805F9B34FB',
value
:
buffer1
,
// characteristicId: '0000FFE1-0000-1000-8000-00805F9B34FB',
success
:
(
res
)
=>
{
// value: buffer1,
console
.
log
(
'
writeBLECharacteristicValue-success:res=>
'
,
res
)
// success: (res) => {
},
// console.log('writeBLECharacteristicValue-success:res=>', res)
fail
:
(
res
)
=>
{
// },
console
.
log
(
'
writeBLECharacteristicValue-fail:res=>
'
,
res
)
// fail: (res) => {
// commonStateCodeDeal(res.errCode || res, 'gosend -> writeBLECharacteristicValue',
// console.log('writeBLECharacteristicValue-fail:res=>', res)
// this)
// // commonStateCodeDeal(res.errCode || res, 'gosend -> writeBLECharacteristicValue',
},
// // this)
});
// },
},
1000
)
// });
// }, 1000)
},
},
navTo
(
flag
)
{
navTo
(
flag
)
{
if
(
flag
===
'
export
'
)
{
if
(
flag
===
'
export
'
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment