Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
huaweiWatchClient
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Sky
huaweiWatchClient
Commits
714ce1b9
Commit
714ce1b9
authored
Sep 07, 2020
by
Sky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除js sdk
parent
f619149f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
271 deletions
+8
-271
index.js
entry/src/main/js/default/pages/index/index.js
+8
-40
wearengine.js
entry/src/main/js/default/pages/wearengine.js
+0
-231
No files found.
entry/src/main/js/default/pages/index/index.js
View file @
714ce1b9
import
sensor
from
'@system.sensor'
;
//传感器
import
vibrator
from
'@system.vibrator'
;
//震动
import
brightness
from
'@system.brightness'
//保持屏幕常亮
import
{
P2pClient
,
Message
,
Builder
}
from
'../wearengine'
export
default
{
data
:
{
...
...
@@ -37,10 +36,12 @@ export default {
let
_this
=
this
;
//数据重置
_this
.
restore
();
//ping手机端状态
_this
.
ping
();
//获取客户端信息
_this
.
getMsg
();
//发送个启动事件
_this
.
sendMsg
({
"eventFlg"
:
"6"
,
});
//关闭启动页
setTimeout
(
function
()
{
if
(
!
_this
.
isReceiveStartMessage
)
{
...
...
@@ -131,8 +132,10 @@ export default {
_this
.
acName
=
model
.
acName
;
_this
.
countdownT
=
model
.
countdownT
==
"-1"
?
"0"
:
model
.
countdownT
;
_this
.
acType
=
model
.
acType
;
_this
.
acCnt
=
model
.
acCnt
;
_this
.
acTotalCnt
=
model
.
acTotalCnt
;
if
(
model
.
acType
==
"0"
)
{
_this
.
acCnt
=
model
.
acCnt
;
_this
.
acTotalCnt
=
model
.
acTotalCnt
;
}
break
;
case
"6"
:
//休息中
_this
.
page
=
"6"
;
...
...
@@ -205,41 +208,6 @@ export default {
}
},
/**
*手表端ping手机端
*/
ping
()
{
let
_this
=
this
;
// 步骤1:创建点对点通信对象
var
p2pClient
=
new
P2pClient
();
// 步骤2:设置需要通信的手机侧对应的三方应用包名
p2pClient
.
setPeerPkgName
(
"com.sportq.fit"
);
// 步骤3:设置手机侧应用指纹信息(该接口暂时不可用,本版本需要使用步骤5中在config.json文件中设置指纹方式)
p2pClient
.
setPeerFingerPrint
(
"B1B788A1BBD5F459BC641DA8CE690EA065C96957F58E883764982B5C46E53E06"
);
// 步骤3:检测手机侧对应的第三方应用是否在线
p2pClient
.
ping
({
onSuccess
:
function
()
{
console
.
log
(
'ping方法执行 success.'
);
},
onFailure
:
function
()
{
console
.
log
(
'ping方法执行 failed'
);
},
onPingResult
:
function
(
resultCode
)
{
//205:手机端应用已安装 204:手机端应用未安装
if
(
resultCode
.
code
==
205
)
{
_this
.
sendMsg
({
"eventFlg"
:
"6"
,
});
}
console
.
log
(
'ping 结果:'
+
resultCode
.
data
+
resultCode
.
code
);
},
})
;
}
,
/**
发送短消息给客户端
*/
...
...
entry/src/main/js/default/pages/wearengine.js
deleted
100644 → 0
View file @
f619149f
/*
* Copyright (c) 2020 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Version: 5.0.0.300
* Description: wearEngine SDK
*/
var
P2pClient
=
(
function
()
{
var
peerPkgName
;
var
peerFingerPrint
;
function
P2pClient
(
context
)
{}
/**
* 设置手机应用的packageName
* peerPkgName: string
*/
P2pClient
.
prototype
.
setPeerPkgName
=
function
(
peerPkgName
)
{
if
(
!
peerPkgName
)
{
return
;
}
this
.
peerPkgName
=
peerPkgName
;
};
/**
* 设置手机侧指纹信息
* fingerPrint: string
*/
P2pClient
.
prototype
.
setPeerFingerPrint
=
function
(
fingerPrint
)
{
if
(
!
fingerPrint
)
{
return
;
}
this
.
peerFingerPrint
=
fingerPrint
;
};
/**
* 检测对端设备侧是否已经安装指定应用
* pingCallback: object:onSuccess(),onFailure(),onPingResult(resultCode)
*/
P2pClient
.
prototype
.
ping
=
function
(
pingCallback
)
{
var
successCode
=
{
data
:
"ERROR_CODE_P2P_PHONE_APP_EXIT"
,
code
:
205
}
var
successCallBack
=
function
()
{
pingCallback
.
onSuccess
();
pingCallback
.
onPingResult
(
successCode
);
};
var
notInstallCode
=
{
data
:
"ERROR_CODE_P2P_PHONE_APP_NOT_EXIT"
,
code
:
204
}
var
failCode
=
{
data
:
"ERROR_CODE_P2P_OTHER_ERROR"
,
code
:
203
}
var
failCallBack
=
function
(
data
,
code
)
{
if
(
!
data
&&
!
code
)
{
pingCallback
.
onFailure
();
pingCallback
.
onPingResult
(
notInstallCode
);
}
else
{
pingCallback
.
onFailure
();
pingCallback
.
onPingResult
(
failCode
);
}
};
console
.
log
(
this
.
peerPkgName
);
FeatureAbility
.
detect
({
bundleName
:
this
.
peerPkgName
,
success
:
successCallBack
,
fail
:
failCallBack
,
});
};
/**
* 注册消息监听接口
* receiver:object:onSuccess(),onFailure(),onReceiveMessage(message)
*/
P2pClient
.
prototype
.
registerReceiver
=
function
(
receiver
)
{
if
(
!
receiver
)
{
return
;
}
var
successCallBack
=
function
(
data
)
{
receiver
.
onSuccess
();
receiver
.
onReceiveMessage
(
data
.
message
);
};
FeatureAbility
.
subscribeMsg
({
success
:
successCallBack
,
fail
:
receiver
.
onFailure
});
};
/**
* 发送消息接口
* message: Message
* sendCallback: object:onSuccess(),onFailure(),onSendResult(resultCode),onSendProgress(count)
* resultCode: SUCCESS 207, FAILURE 206
*/
P2pClient
.
prototype
.
send
=
function
(
message
,
sendCallback
)
{
if
(
!
message
||
!
sendCallback
)
{
return
;
}
var
successCallBack
=
function
()
{
var
successCode
=
{
data
:
"ERROR_CODE_COMM_SUCCESS"
,
code
:
207
}
sendCallback
.
onSuccess
();
sendCallback
.
onSendResult
(
successCode
);
sendCallback
.
onSendProgress
(
100
)
};
var
failCallBack
=
function
(
errorMessage
,
code
)
{
var
failCode
=
{
data
:
errorMessage
,
code
:
206
}
sendCallback
.
onFailure
();
sendCallback
.
onSendResult
(
failCode
);
sendCallback
.
onSendProgress
(
0
)
};
FeatureAbility
.
sendMsg
({
deviceId
:
"remote"
,
bundleName
:
this
.
peerPkgName
,
abilityName
:
""
,
message
:
message
.
getData
(),
success
:
successCallBack
,
fail
:
failCallBack
,
});
};
/**
* 注销监听接口
* receiver: onSuccess()
*/
P2pClient
.
prototype
.
unregisterReceiver
=
function
(
receiver
)
{
FeatureAbility
.
unsubscribeMsg
();
receiver
.
onSuccess
();
};
return
P2pClient
;
}());
/**
* 文件格式
* name: file name with path
* mode: 'text' or 'binary'
* mode2: 'R', 'W', 'RW'
*/
var
File
=
(
function
()
{
var
name
;
var
mode
;
var
mode2
;
function
File
()
{}
}());
var
Builder
=
(
function
()
{
var
messageInfo
;
function
Builder
(
context
)
{}
Builder
.
prototype
.
setDescription
=
function
(
description
)
{
this
.
messageInfo
=
description
;
this
.
messageType
=
0
;
};
/**
* 设置messge信息(两种格式任选其一)
* data: ArrayBuffer
* data: File(暂时不支持)
*/
Builder
.
prototype
.
setPayload
=
function
(
data
)
{
if
(
!
data
)
{
return
;
}
if
(
data
instanceof
ArrayBuffer
)
{
this
.
messageType
=
0
;
return
this
.
setBufferPlayload
(
data
);
}
else
if
(
data
instanceof
File
)
{
this
.
messageType
=
1
;
return
this
.
setFilePlayload
(
data
);
}
};
Builder
.
prototype
.
setBufferPlayload
=
function
(
data
)
{
this
.
messageInfo
=
String
.
fromCharCode
.
apply
(
null
,
new
Uint16Array
(
data
));
};
Builder
.
prototype
.
setFilePlayload
=
function
(
data
)
{
this
.
messageInfo
=
JSON
.
stringify
(
data
);
};
return
Builder
;
}());
var
Message
=
(
function
()
{
var
builder
=
new
Builder
();
function
Message
(
context
)
{}
Message
.
prototype
.
describeContents
=
function
()
{
return
this
.
builder
.
messageInfo
;
};
/**
* 获取传送时的信息
*/
Message
.
prototype
.
getData
=
function
()
{
return
this
.
builder
.
messageInfo
;
};
Message
.
prototype
.
getDescription
=
function
()
{
return
this
.
builder
.
messageInfo
;
};
/**
* 获取文件信息
*/
Message
.
prototype
.
getFile
=
function
()
{
if
(
this
.
builder
.
messageType
==
1
)
{
return
JSON
.
parse
(
this
.
builder
.
messageInfo
);
}
return
null
;
};
/**
* 获取传输数据类型
* 0 string
* 1 File
*/
Message
.
prototype
.
getType
=
function
()
{
return
this
.
builder
.
messageType
;
};
return
Message
;
}());
export
{
P2pClient
,
Message
,
Builder
};
\ No newline at end of file
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