1.Overview
Third-party program plug-in to provide Bluetooth lock door service, users in accordance with the requirements of ginseng, to achieve Bluetooth unlockThe third party small program plug-in provides a custom password function, and users can pass parameters according to the requirements to achieve Bluetooth add, modify and delete the password.
2.Parameter Description
Small program developers call plug-in for Bluetooth lock door, use the method see the program official API
widget Guide
QR KeyMini Programapp-id:wxbe18a842c8d14445
3.Parameter Description
Required parameters |
Explanation |
accountSid |
The Account SID for the Lock Cabinet Developer Account |
token |
The Auth Token for the Lock Cabinet Developer Account |
mobile |
Mobile |
communityNo |
QR Master community |
cardNo |
Please refer to Generate cards |
areaCode |
Mobile phone area code |
4.Sample
4.1 Add plug-ins in the background of small program management
Small program developers can find the required plug-ins based on the AppID and request to use them in ‘Small Program Management Back-Settings-Third-Party Service-Plug-in Management’.
After the plug-in developer passes within 24 hours, the small program developer can use the plug-in within the small program
4.2 To use a plug-in in a small program code that must declare the plug-in you need in app.json's plugins, please refer to the following code:
<!--app.json-->
{
"plugins": {
"yaoshibang": {
"version": "1.0.4",
"provider": "wxbe18a842c8d14445"
}
}
}
4.3 Use the plug-in in the wxml file on the target page, or customize the component style (so you don't have to copy the code in wxss)
<!--index.wxml-->
<button bindtap="openapi" class="yaoshibang">调用api</button>
<!--index.wxss-->
.yaoshibang{
width:80%;
border-radius: 15rpx;
margin-top: 100rpx;
background-color: #1B82D2;
color:#fff;
font-size: 40rpx;
height: 100rpx;
line-height: 100rpx;
}
4.4 In the js of the target page, the plug-in can be obtained using the plug-in interface, the full call api example is as follows:
<!--index.js-->
<!--Add the first of the js file of the called component-->
let yaoshibang = requirePlugin("yaoshibang");
<!--Add this segment to the onShow function of the js file of the called component to turn off The Code for Bluetooth-->
wx.closeBLEConnection({
deviceId: [],
complete(res) {
wx.closeBluetoothAdapter({
success(res) {
console.log('Disconnect Bluetooth');
}
});
}
});
<!--The following paragraph can be placed in any of the custom function bodies (in this case, the openapi function) to call the api-->
openapi: function(){
let apiParam = {
"accountSid": '98651082ab89c3f1b50f35caf794179f',
"token": 'd7ca4ca93c1e809b96ce30acf0a9a9',
"mobile": '10000000000',
"communityNo": '1316879946',
"cardNo": 'd4JYo5DmvRYApL2l',
"areaCode": '86'
}
let url = 'plugin://yaoshibang/yaoshibang?accountSid=' + apiParam.accountSid + '&token=' + apiParam.token + '&mobile=' + apiParam.mobile + '&communityNo=' + apiParam.communityNo + '&cardNo=' + apiParam.cardNo + '&areaCode=' + apiParam.areaCode;
yaoshibang.getFlag(apiParam).then(res => {
<!--If the info returnvalue is 1, page jump-->
<!--info is 1, the door is unlocked-->
if (res.info === 1) {
wx.navigateTo({
url: url
})
}
<!--If the return value of info is 0, the json data results are displayed, the following res and err junctions are the result of processing, the user can take the next step after obtaining, such as pop-up window display to the user (not demonstrated here)-->
<!--info is 0, the cabinet is unlocked-->
if (res.info === 0) {
let result = yaoshibang.getResult(apiParam);
result.then(res => {
console.log(res)
}).catch(err => {
console.log(err)
})
} else {
<!--info is not 0 or -1, return supramail information directly -->
console.log(res)
}
})
}
BLEPasswordOperation interface
yaoshibang.passwordAdd: (prams:PasswordAddParmas)=>Promise<PasswordAddResult> throw PassworldOperationError
PasswordAddParmas
Parameter Name | Type | example | Explanation |
---|
version | string | 1.0.00 | api version |
accountSid | string | 5621e3c3618de890e48375801ca77e18 | Unique identification of developer account |
communityNo | string | 1316880684 | Community No. |
buildNo | string | 001 | Building No. |
floorNo | string | 000 | Floor No. |
roomNo | string | 410 | Room No. |
cipher | string | 123456 | Password |
startTime | string | 202412261200 | Start Time |
endTime | string | 202412271200 | End Time |
token | string | 8732e7bed17b3c0c097bc8af5677df | token |
holder | string | 车轱辘 | Holder |
callback | (p:ProcessCallback)=>void | | Operation progress callback |
ProcessCallback
Parameter Name | Type | example | Explanation |
---|
status | number | 0 | Current operating state |
msg | string | Send data | Short description |
status | msg |
---|
1 | Request QR Master |
10 | Subcontracting data |
20 | Turn on Bluetooth adapter |
30 | Search Bluetooth devices |
40 | Connecting lock |
50 | ObtainBLE service |
60 | Get the Bluetooth service feature value |
70 | Writes data to the lock |
80 | Obtain operation result data |
90 | Synchronize data to QR Master |
PasswordAddResult
Parameter Name | Type | example | Explanation |
---|
cipher | string | 123456 | AddPassword |
power | number | 99 | Electricity 1~100 |
PassworldOperationError
code | message | error | Description |
---|
0 | string | any | Unknown error,message is a short description, error is the original error object |
100 | string | any | Unique to ios users, the user has turned off the wechat Bluetooth permission, and needs to manually go to the system Settings to turn on the wechat Bluetooth permission |
101 | string | any | The user has disabled the Bluetooth permission in the host applet without authorization |
102 | string | any | The Bluetooth of the mobile phone system is disabled |
103 | | | Bluetooth search target lock timed out |
104 | | | Failed to obtain the searched Bluetooth device Procedure |
105 | | | Connection lock failure |
106 | | | Failed to obtain the eigenvalue Procedure |
107 | | | Failed to write data to the lock |
108 | | | Failed to subscribe to the feature value |
109 | | {result:"aabbccdd"} | Lock body returns unknown data, please contact the supplier |
110 | | {code:Number} 声 ringPrompt错误表 | Lock body return error |
111 | string | any | Network request error, please check your network |
112 | any | string | object | The background service of the QR Master is incorrect |
403 | | { status: Number, info:String } | Back office service error |
113 | | any | The password operation succeeded, but failed to synchronize the QR Master. You need to perform the password operation again; otherwise, the service will be abnormal |
完整示example
const yaoshibang = requirePlugin("yaoshibang");
async function passwordAdd() {
try {
wx.showLoading();
const result = await yaoshibang.passwordAdd({
version: "1.0.00",
accountSid: "5621e3c3618de890e48375801ca77e18",
communityNo: "1316880684",
buildNo: "001",
floorNo: "000",
roomNo: "410",
cipher: "123456",
startTime: "202412261200",
endTime: "202412271200",
token: "8732e7bed17b3c0c097bc8af5677df",
holder: "车轱辘",
callback: ({ status, msg }) => {
console.log("进度", status, msg);
wx.showLoading({
title: status + ":" + msg,
});
},
});
console.log("Operation succeeded", result);
console.log("Electricity", result.power);
} catch (error) {
if (error instanceof yaoshibang.PassworldOperationError) {
console.error(error.code, error.message, error.error);
} else {
console.error(error);
}
console.log("Operation failed");
} finally {
wx.hideLoading();
}
}
function passwordAdd(){
wx.showLoading();
yaoshibang.passwordAdd({
version: "1.0.00",
accountSid: "5621e3c3618de890e48375801ca77e18",
communityNo: "1316880684",
buildNo: "001",
floorNo: "000",
roomNo: "410",
cipher: "123456",
startTime: "202412261200",
endTime: "202412271200",
token: "8732e7bed17b3c0c097bc8af5677df",
holder: "车轱辘",
callback: ({ status, msg }) => {
console.log("进度", status, msg);
wx.showLoading({
title: status + ":" + msg,
});
},
})
.then((result) => {
console.log("Operation succeeded", result);
console.log("Electricity", result.power);
wx.hideLoading();
})
.catch((error) => {
if (error instanceof yaoshibang.PassworldOperationError) {
console.error(error.code, error.message, error.error);
} else {
console.error(error);
}
console.log("Operation failed");
wx.hideLoading();
});
},
passwordAdd();
yaoshibang.passwordDel: (prams:PasswordDelParmas)=>Promise<PasswordDelResult> throw PassworldOperationError
PasswordDelParmas
Parameter Name | Type | example | Explanation |
---|
version | string | 1.0.00 | api version |
accountSid | string | 5621e3c3618de880e48375801ca77e18 | Unique identification of developer account |
communityNo | string | 1316880684 | Community No. |
buildNo | string | 001 | Building No. |
floorNo | string | 000 | Floor No. |
roomNo | string | 410 | Room No. |
cipher | string | 123456 | Password |
token | string | 8732e7bed17b3c1c097bc8af5677df | token |
callback | (p:ProcessCallback)=>void | | Operation progress callback |
PasswordDelResult
Parameter Name | Type | example | Explanation |
---|
cipher | string | 123456 | Deleted password |
mac | string | 1234567A1234 | MAC address |
power | number | 99 | Electricity 1~100 |
yaoshibang.passwordsDel: (prams:PasswordDelParmas)=>Promise<PasswordDelResult> throw PassworldOperationError
PasswordsDelParmas
Parameter Name | Type | example | Explanation |
---|
version | string | 1.0.00 | api version |
accountSid | string | 5621e3c3618de880e48375801ca77e18 | Unique identification of developer account |
communityNo | string | 1316880684 | Community No. |
buildNo | string | 001 | Building No. |
floorNo | string | 000 | Floor No. |
roomNo | string | 410 | Room No. |
ciphers | array | ['123456', '234567'] | Password (up to 10 deleted) |
token | string | 8732e7bed17b3c1c097bc8af5677df | token |
callback | (p:ProcessCallback)=>void | | Operation progress callback |
PasswordsDelResult
Parameter Name | Type | example | Explanation |
---|
cipher | array | ['123456','234567'] | Deleted password |
mac | string | 1234567A1234 | MAC address |
power | number | 99 | Electricity 1~100 |
yaoshibang.passwordChange: (prams:PasswordChangeParmas)=>Promise<PasswordChangeResult> throw PassworldOperationError
PasswordChangeParmas
Parameter Name | Type | example | Explanation |
---|
version | string | 1.0.00 | api version |
accountSid | string | 5621e3c3618de880e48375801ca77e18 | Unique identification of developer account |
communityNo | string | 1316880684 | Community No. |
buildNo | string | 001 | Building No. |
floorNo | string | 000 | Floor No. |
roomNo | string | 410 | Room No. |
oldCipher | string | 123456 | Old password |
newCipher | string | 123456 | New password |
startTime | string | 202412261200 | Start Time |
endTime | string | 202412271200 | End Time |
token | string | 8732e7bed17b3c0c097bc8af5677df | token |
holder | string | 车轱辘 | Holder |
callback | (p:ProcessCallback)=>void | | Operation progress callback |
PasswordChangeResult
Parameter Name | Type | example | Explanation |
---|
newCipher | string | 123456 | 新Password |
oldCipher | string | 123456 | 旧Password |
power | number | 99 | Electricity 1~100 |
声 ringPrompt错误表
code | Prompt | 原因,解译 |
---|
1 | Operation succeeded,启动 | LockOperation succeeded,Encrypt、Card Issuer启动, ring声 |
2 | Clearing CardSucceeded | Clear授权信息Succeeded,Recover出厂 |
3 | 密钥不对 | 用户Password错误none效 |
4 | Card type不Normal | Card type出错,or通讯出错,key错误 |
5 | 没StayClients | 五声代表此Room没有客personStay,Checkout Cardnone效 |
6 | Room No.不对 | 房卡Room No.and锁Room No.不同。换Roomor者重新Setting锁 |
7 | Time不对(BLE会Prompt) | 房卡TimeExpireor者Lock记忆时钟不对,重新Obtain cardsor重新setting锁Time |
8 | Batch no.不对(Guest Card) | 该卡被Report the loss,重新generate该Batch no.卡(Guest Card) |
9 | Clearing Cardnone效 | none扭key动作 |
10 | Authorization Card授权码none效 | Lock授权前要拧机械key |
11 | Building Card号none效 | SettingHotel,Building Card不Yes该HotelBuilding Card |
12 | Floor Card号none效 | Setting房号,Floor Card不Yes该FloorFloor Card,重新Setting本Floor楼房号 |
13 | Roomlock the door from the inside | 表示Lock已lock the door from the inside不能打开 |
14 | 电池Electricity低 | 电池Electricity低(锁重启刷房卡也会报 14 声) |
15 | Hotel标示不对 | 刷Authorization Cardor重新发卡不Yes本HotelReception电脑发出来卡片,要inReception电脑上重新发卡 |
16 | 日记collectFailed | 用 IC 卡collect日记时,collect出错锁上报出声音 |
17 | Reading failed | Card IssuerRead出错时发出 ring声 |
18 | 有效Frequencynone效(BLE会Prompt) | Guest Card有效UnlockFrequency用完 |
20 | 品牌号不对 | 非本系统卡 |
21 | Room被封闭中止 | Guest Card、Building、Floor被中止,RoomLock被中止none法Unlock,再刷一下则RecoverNormal |
30 | Agency号不对 | 非本系统卡 |