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 APIwidget 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 NameTypeexampleExplanation
versionstring1.0.00api version
accountSidstring5621e3c3618de890e48375801ca77e18Unique identification of developer account
communityNostring1316880684Community No.
buildNostring001Building No.
floorNostring000Floor No.
roomNostring410Room No.
cipherstring123456Password
startTimestring202412261200Start Time
endTimestring202412271200End Time
tokenstring8732e7bed17b3c0c097bc8af5677dftoken
holderstring车轱辘Holder
callback(p:ProcessCallback)=>voidOperation progress callback

ProcessCallback

Parameter NameTypeexampleExplanation
statusnumber0Current operating state
msgstringSend dataShort description
statusmsg
1Request QR Master
10Subcontracting data
20Turn on Bluetooth adapter
30Search Bluetooth devices
40Connecting lock
50ObtainBLE service
60Get the Bluetooth service feature value
70Writes data to the lock
80Obtain operation result data
90Synchronize data to QR Master

PasswordAddResult

Parameter NameTypeexampleExplanation
cipherstring123456AddPassword
powernumber99Electricity 1~100

PassworldOperationError

codemessageerrorDescription
0stringanyUnknown error,message is a short description, error is the original error object
100stringanyUnique 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
101stringanyThe user has disabled the Bluetooth permission in the host applet without authorization
102stringanyThe Bluetooth of the mobile phone system is disabled
103Bluetooth search target lock timed out
104Failed to obtain the searched Bluetooth device Procedure
105Connection lock failure
106Failed to obtain the eigenvalue Procedure
107Failed to write data to the lock
108Failed 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
111stringanyNetwork request error, please check your network
112anystring | objectThe background service of the QR Master is incorrect
403{
   status: Number,
   info:String
}
Back office service error
113anyThe 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();
                    }
                  }
                
                  //Promise风格
                  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 NameTypeexampleExplanation
versionstring1.0.00api version
accountSidstring5621e3c3618de880e48375801ca77e18Unique identification of developer account
communityNostring1316880684Community No.
buildNostring001Building No.
floorNostring000Floor No.
roomNostring410Room No.
cipherstring123456Password
tokenstring8732e7bed17b3c1c097bc8af5677dftoken
callback(p:ProcessCallback)=>voidOperation progress callback

PasswordDelResult

Parameter NameTypeexampleExplanation
cipherstring123456Deleted password
macstring1234567A1234MAC address
powernumber99Electricity 1~100

yaoshibang.passwordsDel: (prams:PasswordDelParmas)=>Promise<PasswordDelResult> throw PassworldOperationError

PasswordsDelParmas

Parameter NameTypeexampleExplanation
versionstring1.0.00api version
accountSidstring5621e3c3618de880e48375801ca77e18Unique identification of developer account
communityNostring1316880684Community No.
buildNostring001Building No.
floorNostring000Floor No.
roomNostring410Room No.
ciphersarray['123456', '234567']Password (up to 10 deleted)
tokenstring8732e7bed17b3c1c097bc8af5677dftoken
callback(p:ProcessCallback)=>voidOperation progress callback

PasswordsDelResult

Parameter NameTypeexampleExplanation
cipherarray['123456','234567']Deleted password
macstring1234567A1234MAC address
powernumber99Electricity 1~100

yaoshibang.passwordChange: (prams:PasswordChangeParmas)=>Promise<PasswordChangeResult> throw PassworldOperationError

PasswordChangeParmas

Parameter NameTypeexampleExplanation
versionstring1.0.00api version
accountSidstring5621e3c3618de880e48375801ca77e18Unique identification of developer account
communityNostring1316880684Community No.
buildNostring001Building No.
floorNostring000Floor No.
roomNostring410Room No.
oldCipherstring123456Old password
newCipherstring123456New password
startTimestring202412261200Start Time
endTimestring202412271200End Time
tokenstring8732e7bed17b3c0c097bc8af5677dftoken
holderstring车轱辘Holder
callback(p:ProcessCallback)=>voidOperation progress callback

PasswordChangeResult

Parameter NameTypeexampleExplanation
newCipherstring123456新Password
oldCipherstring123456旧Password
powernumber99Electricity 1~100

声 ringPrompt错误表

codePrompt原因,解译
1Operation succeeded,启动LockOperation succeeded,Encrypt、Card Issuer启动, ring声
2Clearing CardSucceededClear授权信息Succeeded,Recover出厂
3密钥不对用户Password错误none效
4Card type不NormalCard type出错,or通讯出错,key错误
5没StayClients五声代表此Room没有客personStay,Checkout Cardnone效
6Room No.不对房卡Room No.and锁Room No.不同。换Roomor者重新Setting锁
7Time不对(BLE会Prompt)房卡TimeExpireor者Lock记忆时钟不对,重新Obtain cardsor重新setting锁Time
8Batch no.不对(Guest Card)该卡被Report the loss,重新generate该Batch no.卡(Guest Card)
9Clearing Cardnone效none扭key动作
10Authorization Card授权码none效Lock授权前要拧机械key
11Building Card号none效SettingHotel,Building Card不Yes该HotelBuilding Card
12Floor Card号none效Setting房号,Floor Card不Yes该FloorFloor Card,重新Setting本Floor楼房号
13Roomlock the door from the inside表示Lock已lock the door from the inside不能打开
14电池Electricity低电池Electricity低(锁重启刷房卡也会报 14 声)
15Hotel标示不对刷Authorization Cardor重新发卡不Yes本HotelReception电脑发出来卡片,要inReception电脑上重新发卡
16日记collectFailed用 IC 卡collect日记时,collect出错锁上报出声音
17Reading failedCard IssuerRead出错时发出 ring声
18有效Frequencynone效(BLE会Prompt)Guest Card有效UnlockFrequency用完
20品牌号不对非本系统卡
21Room被封闭中止Guest Card、Building、Floor被中止,RoomLock被中止none法Unlock,再刷一下则RecoverNormal
30Agency号不对非本系统卡