123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- const app = getApp();
- import strings from '../../utils/strings.js';
- const {
- BtHelper
- } = require('../../devices/bt_helper');
- const {
- BleUtil
- } = require('../../utils/blue_ble/util');
- Page({
- data: {
- nvabarData: {
- showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
- title: '连接配网', //导航栏 中间的标题
- },
- scopeBluetooth: app.globalData.scopeBluetooth,
- ssid: app.globalData.ssid,
- password: app.globalData.pwdData,
- version: '2.0',
- name: '',
- connectedDeviceId: '',
- connected: true,
- deviceInfo: null,
- isInitOK: false,
- customData: '',
- percent: 0,
- ruterStatus: 0, // 0 连接中 // 1 成功 // 2失败
- imageUrl: "./../../img/g.png",
- },
- onLoad: function (options) {
- var that = this;
- var param = options.param;
- if (!strings.isEmpty(param)) {
- param = JSON.parse(param);
- that.setData({
- imageUrl: param.img,
- });
- }
- // AIrSMArT_861210052356337===D0:31:10:86:AC:9A
- /// 纯蓝牙:MW_BLE CC:90:DD:88:C7:E8
- var name = options.name;
- var deviceId = options.deviceId;
- that.setData({
- name: name,
- connectedDeviceId: deviceId,
- });
- // var device = {
- // "mac": name,
- // "deviceId": deviceId
- // };
- var device = {
- "mac": "MW_BLE",
- "deviceId": "CC:90:DD:88:C7:E8"
- };
- console.log("gadsfasdfadfaf===00==");
- // BtHelper.getInstance().connect(device, function (isConnected, device) {
- // if (isConnected) {
- // }
- // }, true, device);
- BtHelper.getInstance().startScan(device,
- async function (b) {
- console.log("gadsfasdfadfaf===xxx==" + b);
- if (b) {
- setTimeout(function () {
- console.log("gadsfasdfadfaf===yyy==");
- BleUtil.getInstance().startConnect(device, function (changed) {
- if (changed) {
- BleUtil.getInstance().sendData(device, app.globalData.ssid, app.globalData.pwdData);
- }
- });
- }, 10 * 1000);
- }
- },
- async function (res) {
- console.log("gadsfasdfadfaf===yyy==");
- await BtHelper.getInstance().stopSearch();
- BleUtil.getInstance().startConnect(device, function (changed) {
- if (changed) {
- BleUtil.getInstance().sendData(device, app.globalData.ssid, app.globalData.pwdData);
- }
- });
- }
- );
- },
- })
|