dylan 2 жил өмнө
commit
4558b5d4aa
100 өөрчлөгдсөн 7381 нэмэгдсэн , 0 устгасан
  1. 14 0
      .gitignore
  2. 127 0
      app.js
  3. 75 0
      app.json
  4. 24 0
      app.wxss
  5. BIN
      images/1help.png
  6. BIN
      images/1m-bluetooth.png
  7. BIN
      images/1rtu.png
  8. BIN
      images/1scan.png
  9. BIN
      images/1service.png
  10. BIN
      images/add.png
  11. BIN
      images/background.jpg
  12. BIN
      images/baseInfo-m.png
  13. BIN
      images/baseInfo.png
  14. BIN
      images/blt-link.png
  15. BIN
      images/bluebooth.png
  16. BIN
      images/bluetooth-s.png
  17. BIN
      images/bluetooth.png
  18. BIN
      images/click.png
  19. BIN
      images/find.png
  20. BIN
      images/foucs.png
  21. BIN
      images/help-s.png
  22. BIN
      images/help.png
  23. BIN
      images/icon/arrow-right.png
  24. BIN
      images/icon/none-star.png
  25. BIN
      images/icon/star.png
  26. BIN
      images/icon/xx.png
  27. BIN
      images/launch.png
  28. BIN
      images/location1.png
  29. BIN
      images/login2.jpg
  30. BIN
      images/login_icon.png
  31. BIN
      images/m-bluetooth.png
  32. BIN
      images/marker_blue.png
  33. BIN
      images/marker_red.png
  34. BIN
      images/more.png
  35. BIN
      images/normal.png
  36. BIN
      images/proj-s.png
  37. BIN
      images/proj.png
  38. BIN
      images/project.png
  39. BIN
      images/purse.png
  40. BIN
      images/pw.png
  41. BIN
      images/rec.png
  42. BIN
      images/refresh.png
  43. BIN
      images/report-1.png
  44. BIN
      images/report.png
  45. BIN
      images/rtu-help-listimage.png
  46. BIN
      images/rtu-help.png
  47. BIN
      images/rtu-s.png
  48. BIN
      images/rtu.png
  49. BIN
      images/scan.png
  50. BIN
      images/search-k.png
  51. BIN
      images/search-k1.png
  52. BIN
      images/search.png
  53. BIN
      images/service.png
  54. BIN
      images/setting-1.png
  55. BIN
      images/setting.png
  56. BIN
      images/sign1.png
  57. BIN
      images/user.png
  58. BIN
      images/waiting.png
  59. BIN
      images/warning.png
  60. BIN
      images/xcx.png
  61. BIN
      images/yule.png
  62. 24 0
      pages/baseInfo/baseInfo.js
  63. 3 0
      pages/baseInfo/baseInfo.json
  64. 6 0
      pages/baseInfo/baseInfo.wxml
  65. 20 0
      pages/baseInfo/baseInfo.wxss
  66. 1042 0
      pages/bluetooth/baseSetting/bluetoothBaseSetting.js
  67. 6 0
      pages/bluetooth/baseSetting/bluetoothBaseSetting.json
  68. 171 0
      pages/bluetooth/baseSetting/bluetoothBaseSetting.wxml
  69. 119 0
      pages/bluetooth/baseSetting/bluetoothBaseSetting.wxss
  70. 810 0
      pages/bluetooth/bluetooth.js
  71. 6 0
      pages/bluetooth/bluetooth.json
  72. 95 0
      pages/bluetooth/bluetooth.wxml
  73. 366 0
      pages/bluetooth/bluetooth.wxss
  74. 398 0
      pages/bluetooth/clock/bluetoothClock.js
  75. 6 0
      pages/bluetooth/clock/bluetoothClock.json
  76. 80 0
      pages/bluetooth/clock/bluetoothClock.wxml
  77. 55 0
      pages/bluetooth/clock/bluetoothClock.wxss
  78. 564 0
      pages/bluetooth/home/bluetoothHome.js
  79. 6 0
      pages/bluetooth/home/bluetoothHome.json
  80. 222 0
      pages/bluetooth/home/bluetoothHome.wxml
  81. 406 0
      pages/bluetooth/home/bluetoothHome.wxss
  82. 417 0
      pages/bluetooth/info/bluetoothInfo.js
  83. 6 0
      pages/bluetooth/info/bluetoothInfo.json
  84. 186 0
      pages/bluetooth/info/bluetoothInfo.wxml
  85. 45 0
      pages/bluetooth/info/bluetoothInfo.wxss
  86. 893 0
      pages/bluetooth/runSetting/bluetoothRunSetting.js
  87. 6 0
      pages/bluetooth/runSetting/bluetoothRunSetting.json
  88. 368 0
      pages/bluetooth/runSetting/bluetoothRunSetting.wxml
  89. 83 0
      pages/bluetooth/runSetting/bluetoothRunSetting.wxss
  90. 108 0
      pages/deviceCheck/deviceCheckList.js
  91. 4 0
      pages/deviceCheck/deviceCheckList.json
  92. 36 0
      pages/deviceCheck/deviceCheckList.wxml
  93. 74 0
      pages/deviceCheck/deviceCheckList.wxss
  94. 126 0
      pages/deviceCheck/process/checkProcessInfo.js
  95. 4 0
      pages/deviceCheck/process/checkProcessInfo.json
  96. 46 0
      pages/deviceCheck/process/checkProcessInfo.wxml
  97. 69 0
      pages/deviceCheck/process/checkProcessInfo.wxss
  98. 199 0
      pages/deviceCheck/report/deviceCheckReport.js
  99. 4 0
      pages/deviceCheck/report/deviceCheckReport.json
  100. 62 0
      pages/deviceCheck/report/deviceCheckReport.wxml

+ 14 - 0
.gitignore

@@ -0,0 +1,14 @@
+# Windows
+[Dd]esktop.ini
+Thumbs.db
+$RECYCLE.BIN/
+
+# macOS
+.DS_Store
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+
+# Node.js
+node_modules/

+ 127 - 0
app.js

@@ -0,0 +1,127 @@
+App({
+
+  /**
+   * 当小程序初始化完成时,会触发 onLaunch(全局只触发一次)
+   */
+  onLaunch: function () {
+    // wx.checkSession({
+    //   success: function () {
+    //     console.debug("already login");
+    //     try {
+    //       var userToken = wx.getStorageSync('user_token');
+    //       if (userToken == null || userToken == undefined || userToken == "") {
+    //         wx.removeStorageSync("user_token");
+    //         wx.removeStorageSync("openid");
+    //         that.login();
+    //       }
+    //     } catch (e) {
+    //       console.log(e);
+    //     }
+    //   },
+    //   fail: function () {
+    //     console.log("go login");
+    //     wx.removeStorageSync("user_token");
+    //     wx.removeStorageSync("openid");
+    //     that.login();
+    //   }
+    // })
+    
+  },
+  // login: function () {
+  //   var that = this;
+  //   wx.login({
+  //     success: function (res) {
+  //       console.debug("wx.login" + res);
+  //       if (res.code) {
+  //         //   that.loginToTaishan(res.code);
+  //       } else {
+  //         console.log('登录失败!' + res.errMsg)
+  //       }
+
+  //     },
+  //     fail: function (res) {
+  //       console.log('fail' + res.errMsg)
+  //     }
+  //   })
+  // },
+  /**
+   * 登录泰山系统
+   * @param {*} code 
+   */
+  // loginToTaishan: function (code) {
+  //   wx.request({
+  //     url: this.globalData.cloudBase + "/Wx/Login/code=" + code,
+  //     method: 'GET',
+  //     header: {
+  //       "Content-Type": "json"
+  //     },
+  //     success: function (res) {
+  //       console.debug("login " + res.data);
+  //       if (res.data.code === "0") {
+  //         try {
+  //           wx.setStorageSync('openid', res.data.openid);
+  //           if (res.data.reg === "1") {
+  //             wx.setStorageSync('headIcon', res.data.headIcon);
+  //             wx.setStorageSync('nick', res.data.nick);
+  //             wx.setStorageSync('user_token', res.data.userToken);
+  //           } else {
+  //             console.log("user check  fail ");
+  //           }
+  //         } catch (e) {
+  //           console.log(e);
+  //         }
+  //       } else {
+  //         console.log("login to taishan fail " + res);
+  //       }
+  //     },
+  //     fail: function (res) {
+  //       console.log("fail" + res);
+  //     }
+  //   })
+  // },
+  globalData: {
+    defaultCity: '',
+    defaultCounty: '',
+    weatherData: '',
+    g_isPlayingMusic: false,
+    g_currentMusicPostId: null,
+    //doubanBase: "https://api.douban.com",
+    heWeatherBase: "https://free-api.heweather.com",
+    //juhetoutiaoBase: "https://v.juhe.cn/toutiao/index",
+    cloudBase: "https://wx.dahengsi.com",
+    tencentMapKey: "4HYBZ-EB23D-SLC42-HQ5R3-LP3LQ-OZFU5",
+    heWeatherKey: "4a817b4338e04cc59bdb92da7771411e",
+    //juhetoutiaoKey: "a9f703a0200d68926f707f3f13629078",
+    marketIndex: 0,
+    imageBase: "https://wx.dahengsi.com",
+    bluetoothErrCode: {
+      ok: 0,
+      //已连接
+      alreadyConnect: -1,
+      //未初始化蓝牙适配器
+      notInit: 10000,
+      //当前蓝牙适配器不可用
+      notAvailable: 10001,
+      //没有找到指定设备
+      noDevice: 10002,
+      //连接失败
+      connectionFail: 10003,
+      //没有找到指定服务
+      noService: 10004,
+      //没有找到指定特征
+      noCharacteristic: 10005,
+      //当前连接已断开
+      noConnection: 10006,
+      //当前特征不支持此操作
+      propertyNotSupport: 10007,
+      //其余所有系统上报的异常
+      systemErro: 10008,
+      //Android 系统特有,系统版本低于 4.3 不支持 BLE
+      systemNotSupport: 10009,
+      //连接超时
+      operateTimeOut: 10012,
+      //连接 deviceId 为空或者是格式不正确
+      invalidData: 10013
+    }
+  }
+})

+ 75 - 0
app.json

@@ -0,0 +1,75 @@
+{
+  "pages": [
+    "pages/home/home",
+    "pages/user/user",
+    "pages/index/index",
+    "pages/movies/movies",
+    "pages/switchcity/switchcity",
+    "pages/news/news",
+    "pages/movies/movie-detail/movie-detail",
+    "pages/movies/more-movie/more-movie",
+    "pages/logs/logs",
+    "pages/org/org",
+    "pages/myPage/myPage",
+    "pages/myPage/detail/reportDetail",
+    "pages/project/project",
+    "pages/project/talkToBuyer/talkToBuyer",
+    "pages/msg/submitMsg",
+    "pages/help/help",
+    "pages/index/showBoxDetail/showBoxDetail",
+    "pages/index/publish/publishPhoto",
+    "pages/index/setting/setting",
+    "pages/moreReply/moreReply",
+    "pages/index/datagramDetailView/datagramDetailInfo",
+    "pages/baseInfo/baseInfo",
+    "pages/project/prog-rtu-List/prog-rtu-list",
+    "pages/report/report",
+    "pages/report/rtuConstructionReport/rtuConstructionReport",
+    "pages/help/xcxhelp/xcxhelp",
+    "pages/help/rtuhelp/rtuhelp",
+    "pages/help/rtuhelp/stateset/stateset",
+    "pages/help/rtuhelp/timeReportset/timeReportset",
+    "pages/help/rtuhelp/addReporteset/addReporteset",
+    "pages/help/rtuhelp/reportTypeset/reportTypeset",
+    "pages/help/rtuhelp/dtuset/dtuset",
+    "pages/help/rtuhelp/sensorset/sensorset",
+    "pages/help/rtuhelp/reset/reset",
+    "pages/help/rtuhelp/addset/addset",
+    "pages/help/rtuhelp/rtuTimeset/rtuTimeset",
+    "pages/help/rtuhelp/sendTestreport/sendTestreport",
+    "pages/bluetooth/bluetooth",
+    "pages/bluetooth/home/bluetoothHome",
+    "pages/bluetooth/info/bluetoothInfo",
+    "pages/bluetooth/baseSetting/bluetoothBaseSetting",
+    "pages/bluetooth/clock/bluetoothClock",
+    "pages/bluetooth/runSetting/bluetoothRunSetting",
+    "pages/rtu/projectSelectView",
+    "pages/rtu/rtuList/rtuSelectView",
+    "pages/rtu/rtuNavigate/rtuNavigateListView",
+    "pages/rtu/rtuNavigate/detail/rtuNavigateInfoView",
+    "pages/sign/sign",
+    "pages/deviceCheck/deviceCheckList",
+    "pages/deviceCheck/report/deviceCheckReport",
+    "pages/deviceCheck/process/checkProcessInfo",
+    "pages/deviceCheck/report/edit/checkProcessReportEdit"
+  ],
+  "window": {
+    "backgroundTextStyle": "light",
+    "navigationBarBackgroundColor": "#426666",
+    "navigationBarTitleText": "智能运维",
+    "navigationBarTextStyle": "white"
+  },
+  "sitemapLocation": "sitemap.json",
+  "permission": {
+    "scope.userLocation": {
+      "desc": "您的位置信息将用于小程序中上报工作情况"
+    }
+  },
+  "requiredPrivateInfos": [
+    "getLocation"
+  ],
+  "useExtendedLib": {
+    "kbone": true,
+    "weui": true
+  }
+}

+ 24 - 0
app.wxss

@@ -0,0 +1,24 @@
+  /**app.wxss**/
+  /* @import "pages/weui/style/weui.wxss";  */
+  page {
+    width: 100%;
+    height: 100%;
+    background-color: whitesmoke;
+  }
+
+  .fixedViewBox {
+    position: fixed;
+    width: 100%;
+    height: 100%;
+    overflow: hidden;
+  }
+
+text {
+  font-family: MicroSoft Yahei;
+  font-size: 24rpx;
+  color: #666;
+}
+
+input {
+  font-family: MicroSoft YaHei;
+}

BIN
images/1help.png


BIN
images/1m-bluetooth.png


BIN
images/1rtu.png


BIN
images/1scan.png


BIN
images/1service.png


BIN
images/add.png


BIN
images/background.jpg


BIN
images/baseInfo-m.png


BIN
images/baseInfo.png


BIN
images/blt-link.png


BIN
images/bluebooth.png


BIN
images/bluetooth-s.png


BIN
images/bluetooth.png


BIN
images/click.png


BIN
images/find.png


BIN
images/foucs.png


BIN
images/help-s.png


BIN
images/help.png


BIN
images/icon/arrow-right.png


BIN
images/icon/none-star.png


BIN
images/icon/star.png


BIN
images/icon/xx.png


BIN
images/launch.png


BIN
images/location1.png


BIN
images/login2.jpg


BIN
images/login_icon.png


BIN
images/m-bluetooth.png


BIN
images/marker_blue.png


BIN
images/marker_red.png


BIN
images/more.png


BIN
images/normal.png


BIN
images/proj-s.png


BIN
images/proj.png


BIN
images/project.png


BIN
images/purse.png


BIN
images/pw.png


BIN
images/rec.png


BIN
images/refresh.png


BIN
images/report-1.png


BIN
images/report.png


BIN
images/rtu-help-listimage.png


BIN
images/rtu-help.png


BIN
images/rtu-s.png


BIN
images/rtu.png


BIN
images/scan.png


BIN
images/search-k.png


BIN
images/search-k1.png


BIN
images/search.png


BIN
images/service.png


BIN
images/setting-1.png


BIN
images/setting.png


BIN
images/sign1.png


BIN
images/user.png


BIN
images/waiting.png


BIN
images/warning.png


BIN
images/xcx.png


BIN
images/yule.png


+ 24 - 0
pages/baseInfo/baseInfo.js

@@ -0,0 +1,24 @@
+var app = getApp();
+var util = require('../../utils/util.js');
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    openid: null
+  },
+
+  onLoad: function (options) {
+  
+  },
+  onUnload: function(){
+  
+  },
+  onReady: function () {
+
+  },
+  onShow: function () {
+
+  }
+})

+ 3 - 0
pages/baseInfo/baseInfo.json

@@ -0,0 +1,3 @@
+{
+  "navigationBarTitleText": "基础信息管理"
+}

+ 6 - 0
pages/baseInfo/baseInfo.wxml

@@ -0,0 +1,6 @@
+<!--baseInfo.wxml-->
+<page>
+    <view class="waiting">
+        <image class="waitingImg" src="/images/waiting.png"></image>
+    </view>    
+</page>

+ 20 - 0
pages/baseInfo/baseInfo.wxss

@@ -0,0 +1,20 @@
+/**baseInfo.wxss**/
+
+.waiting{
+  height: 100%;
+  width: 100%;
+  display: flex;
+  position: relative;
+}
+
+.waitingImg{
+  width: 300rpx;
+  height: 300rpx;
+  display: flex;
+  margin-left: auto; 
+  margin-right: auto;
+  margin-top: auto;
+  margin-bottom: auto;
+}
+
+

+ 1042 - 0
pages/bluetooth/baseSetting/bluetoothBaseSetting.js

@@ -0,0 +1,1042 @@
+const util = require("../../../utils/util");
+const datagramHelp = require("../../../utils/datagramHelp")
+
+var app = getApp();
+var task_timer;
+Page({
+  data: {
+    devices: {
+      deviceId: '',
+      serviceId: '',
+      characteristicId: '',
+      connectedBluetoothName: ''
+    },
+    rtuInfo: {
+      rtu_code: '',
+      ip1: '',
+      ip1_port: '',
+      ip2: '',
+      ip2_port: '',
+      ip3: '',
+      ip3_port: '',
+      ip4: '',
+      ip4_port: '',
+      ipV6Checked1: false,
+      ipV6Checked2: false,
+      ipV6Checked3: false,
+      ipV6Checked4: false,
+      rtu_work_model: '',
+      rtu_kind: '',
+      collect_interval: '',
+      water_level_base_point: '',
+      water_level_correct_point: '',
+      datagram_idx: '',
+      collect_time: '',
+      acc_rain: '',
+      fiveMinute_rain: '',
+      hour_rain: '',
+      weater_level: '',
+      power_v: '',
+      rtu_ver: '',
+      rtu_uuid: '',
+      bt_v: '',
+      rtu_rssi: '',
+      rtu_temperature: '',
+      lua_ver: '',
+      netModel: '00',
+    },
+    netModels: [{
+      value: '00',
+      name: 'TCP',
+      checked: true
+    }, {
+      value: '01',
+      name: 'UDP',
+      checked: false
+    }, {
+      value: '02',
+      name: 'TCP-NDNS',
+      checked: false
+    }, {
+      value: '03',
+      name: 'UDP-NDNS',
+      checked: false
+    }, {
+      value: '04',
+      name: 'IPV6',
+      checked: false
+    }, {
+      value: '05',
+      name: 'DAPN',
+      checked: false
+    }],
+    ip1Checkbox: [{
+        value: 'IPV4',
+        name: 'IPV4',
+        checked: true
+      },
+      {
+        value: 'IPV6',
+        name: 'IPV6',
+        checked: false
+      }
+    ],
+    ip2Checkbox: [{
+        value: 'IPV4',
+        name: 'IPV4',
+        checked: true
+      },
+      {
+        value: 'IPV6',
+        name: 'IPV6',
+        checked: false
+      }
+    ],
+    ip3Checkbox: [{
+        value: 'IPV4',
+        name: 'IPV4',
+        checked: true
+      },
+      {
+        value: 'IPV6',
+        name: 'IPV6',
+        checked: false
+      }
+    ],
+    ip4Checkbox: [{
+        value: 'IPV4',
+        name: 'IPV4',
+        checked: true
+      },
+      {
+        value: 'IPV6',
+        name: 'IPV6',
+        checked: false
+      }
+    ],
+    datagramBuff: '',
+    datagramCache: [],
+    trySendCount: 0,
+    datagramIndex: 0,
+    rtu_kind_code: ['P', 'H', 'K', 'Z', 'D', 'T', 'M', 'G', 'Q', 'I', 'O'],
+    rtu_kind_name: ['P(降水)', 'H(河道)', 'K(水库/湖泊)', 'Z(闸坝)', 'D(泵站)', 'T(潮汐)', 'M(墒情)', 'G(地下水)', 'Q(水质)', 'I(取水口)', 'O(排水口)'],
+    rtu_kind_index: 0,
+    rtu_work_model_name: ['低功耗', '永在线'],
+    rtu_work_model_index: 0,
+    suspend: false,
+    showSettingResult: false,
+    settingResultText: '操作已完成!'
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    console.log('bluebooth home page load ', '**********************************************')
+    let deviceId = options.deviceId;
+    let serviceId = options.serviceId;
+    let characteristicId = options.characteristicId;
+    let connectedBluetoothName = options.connectedBluetoothName;
+    console.log('name' + connectedBluetoothName)
+    let devices = {}
+    devices['deviceId'] = deviceId;
+    devices['serviceId'] = serviceId;
+    devices['characteristicId'] = characteristicId;
+    devices['connectedBluetoothName'] = connectedBluetoothName;
+    this.setData({
+      devices: devices,
+      trySendCount: 0,
+      datagramIndex: 0,
+      suspend: false
+    })
+    task_timer = undefined;
+    this.getRtuBaseSetting();
+
+
+    if (this.data.datagramCache.length > 0) {
+      let datagram = this.data.datagramCache[this.data.datagramIndex];
+      this.sendDatagramToRtu(datagram);
+      let index = this.data.datagramIndex + 1;
+      if (this.data.datagramCache.length == index) {
+        index = 0;
+      }
+      let count = this.data.trySendCount + 1;
+      this.setData({
+        datagramIndex: index,
+        trySendCount: count
+      })
+    }
+  },
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+    console.log('bluebooth baseSetting page onHide ', '**********************************************')
+    this.cancelTime();
+  },
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+    console.log('bluebooth baseSetting page onUnload ', '**********************************************')
+    this.cancelTime();
+  },
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    console.log('bluebooth baseSetting page onShow ', '**********************************************')
+    // if (!this.data.suspend) {
+    this.timeCallback();
+    //  }
+  },
+  settingCompletTabEvent(e) {
+    this.setData({
+      showSettingResult: false
+    })
+    const btn = e.detail.index;
+    if (btn == 0) {
+      wx.navigateBack({
+        delta: 2,
+      });
+    }
+  },
+  bindNewRtuCodeInput: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.rtu_code = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  bindIp1Input: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    let oldip = rtuInfo.ip1;
+    let newip = e.detail.value;
+    let ipv6checked = rtuInfo.ipV6Checked1;
+    let maxLen = false;
+    if (ipv6checked) {
+      let ipitems = oldip.split(":");
+      if (newip.length > oldip.length) {
+        if (ipitems.length == 8) {
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 4) {
+            maxLen = true;
+          }
+        }
+        if (maxLen) {
+          newip = oldip;
+        } else {
+          let ipitems = newip.split(":");
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 4) {
+            if (ipitems.length < 8) {
+              newip += ":";
+            }
+          }
+        }
+      }
+    } else {
+      let ipitems = oldip.split(".");
+      if (newip.length > oldip.length) {
+        if (ipitems.length == 4) {
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 3) {
+            maxLen = true;
+          }
+        }
+        if (maxLen) {
+          newip = oldip;
+        } else {
+          let ipitems = newip.split(".");
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 3) {
+            if (ipitems.length < 4) {
+              newip += ".";
+            }
+          }
+        }
+      }
+    }
+    rtuInfo.ip1 = newip;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  bindIp2Input: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    let oldip = rtuInfo.ip2;
+    let newip = e.detail.value;
+    let ipv6checked = rtuInfo.ipV6Checked2;
+    let maxLen = false;
+    if (ipv6checked) {
+      let ipitems = oldip.split(":");
+      if (newip.length > oldip.length) {
+        if (ipitems.length == 8) {
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 4) {
+            maxLen = true;
+          }
+        }
+        if (maxLen) {
+          newip = oldip;
+        } else {
+          let ipitems = newip.split(":");
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 4) {
+            if (ipitems.length < 8) {
+              newip += ":";
+            }
+          }
+        }
+      }
+    } else {
+      let ipitems = oldip.split(".");
+      if (newip.length > oldip.length) {
+        if (ipitems.length == 4) {
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 3) {
+            maxLen = true;
+          }
+        }
+        if (maxLen) {
+          newip = oldip;
+        } else {
+          let ipitems = newip.split(".");
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 3) {
+            if (ipitems.length < 4) {
+              newip += ".";
+            }
+          }
+        }
+      }
+    }
+    rtuInfo.ip2 = newip;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  bindIp3Input: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    let oldip = rtuInfo.ip3;
+    let newip = e.detail.value;
+    let ipv6checked = rtuInfo.ipV6Checked3;
+    let maxLen = false;
+    if (ipv6checked) {
+      let ipitems = oldip.split(":");
+      if (newip.length > oldip.length) {
+        if (ipitems.length == 8) {
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 4) {
+            maxLen = true;
+          }
+        }
+        if (maxLen) {
+          newip = oldip;
+        } else {
+          let ipitems = newip.split(":");
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 4) {
+            if (ipitems.length < 8) {
+              newip += ":";
+            }
+          }
+        }
+      }
+    } else {
+      let ipitems = oldip.split(".");
+      if (newip.length > oldip.length) {
+        if (ipitems.length == 4) {
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 3) {
+            maxLen = true;
+          }
+        }
+        if (maxLen) {
+          newip = oldip;
+        } else {
+          let ipitems = newip.split(".");
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 3) {
+            if (ipitems.length < 4) {
+              newip += ".";
+            }
+          }
+        }
+      }
+    }
+    rtuInfo.ip3 = newip;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  bindIp4Input: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    let oldip = rtuInfo.ip4;
+    let newip = e.detail.value;
+    let ipv6checked = rtuInfo.ipV6Checked4;
+    let maxLen = false;
+    if (ipv6checked) {
+      let ipitems = oldip.split(":");
+      if (newip.length > oldip.length) {
+        if (ipitems.length == 8) {
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 4) {
+            maxLen = true;
+          }
+        }
+        if (maxLen) {
+          newip = oldip;
+        } else {
+          let ipitems = newip.split(":");
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 4) {
+            if (ipitems.length < 8) {
+              newip += ":";
+            }
+          }
+        }
+      }
+    } else {
+      let ipitems = oldip.split(".");
+      if (newip.length > oldip.length) {
+        if (ipitems.length == 4) {
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 3) {
+            maxLen = true;
+          }
+        }
+        if (maxLen) {
+          newip = oldip;
+        } else {
+          let ipitems = newip.split(".");
+          let lastText = ipitems[ipitems.length - 1];
+          if (lastText != null && lastText.length == 3) {
+            if (ipitems.length < 4) {
+              newip += ".";
+            }
+          }
+        }
+      }
+    }
+    rtuInfo.ip4 = newip;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  bindIp1portInput: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.ip1_port = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  bindIp2portInput: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.ip2_port = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  bindIp3portInput: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.ip3_port = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  bindIp4portInput: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.ip4_port = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  bindWorkModelPickerChange: function (e) {
+    console.log('picker发送选择改变,携带值为', e.detail.value)
+    let index = e.detail.value;
+    let rtuInfo = this.data.rtuInfo;
+    if (index == 0) {
+      rtuInfo['rtu_work_model'] = '0';
+    } else {
+      rtuInfo['rtu_work_model'] = '1';
+    }
+    this.setData({
+      rtu_work_model_index: index,
+      rtuInfo: rtuInfo
+    })
+  },
+  bindRtuKindPickerChange: function (e) {
+    console.log('picker发送选择改变,携带值为', e.detail.value)
+    let rtuInfo = this.data.rtuInfo;
+    let index = e.detail.value;
+    let v = "" + this.data.rtu_kind_code[index];
+    rtuInfo['rtu_kind'] = v;
+    this.setData({
+      rtu_kind_index: index,
+      rtuInfo: rtuInfo
+    })
+  },
+  checkIp(ip, port, ipV6Checked) {
+    let formatError = false;
+    if (ip != undefined && ip.length > 0) {
+      if (ipV6Checked) {
+        let ipitems = ip.split(":");
+        if (ipitems.length == 8) {
+          for (let i = 0; i < ipitems.length; i++) {
+            let text = ipitems[i];
+            let len = text.length;
+            if (len == 4) {
+              for (let j = 0; j < 3; j++) {
+                let subText = text.charCodeAt(j);
+                if ((subText >= 48 && subText <= 57) || (subText >= 65 && subText <= 70) || (subText >= 97 && subText <= 102)) {
+                  formatError = false;
+                } else {
+                  formatError = true;
+                  break;
+                }
+              }
+              if (formatError) {
+                break;
+              }
+            } else {
+              formatError = true;
+              break;
+            }
+          }
+        } else {
+          formatError = true;
+        }
+      } else {
+        let ipitems = ip.split(".");
+        if (ipitems.length == 4) {
+          for (let i = 0; i < ipitems.length; i++) {
+            let text = ipitems[i];
+            let len = text.length;
+            if (len > 0) {
+              for (let j = 0; j < len; j++) {
+                let subText = text.charCodeAt(j);
+                if (subText >= 48 && subText <= 57) {
+                  formatError = false;
+                } else {
+                  formatError = true;
+                  break;
+                }
+              }
+              if (formatError) {
+                break;
+              }
+            } else {
+              formatError = true;
+              break;
+            }
+          }
+        } else {
+          formatError = true;
+        }
+      }
+      let len = port.length;
+      if (len > 0) {
+        if (isNaN(Number(port, 10))) {
+          formatError = true;
+        }
+      } else {
+        formatError = true;
+      }
+    }
+    return formatError;
+  },
+  baseSettingBtn: function () {
+    let ip = this.data.rtuInfo['ip1'];
+    let port = this.data.rtuInfo['ip1_port'];
+    let ipV6Checked = this.data.rtuInfo['ipV6Checked1'];
+    let formatError = this.checkIp(ip, port, ipV6Checked);
+    if (formatError) {
+      wx.showToast({
+        title: '第1路IP地址格式错误,请检查!',
+        icon: 'none',
+        duration: 2000
+      })
+      return;
+    }
+    ip = this.data.rtuInfo['ip2'];
+    port = this.data.rtuInfo['ip2_port'];
+    ipV6Checked = this.data.rtuInfo['ipV6Checked2'];
+    formatError = this.checkIp(ip, port, ipV6Checked);
+    if (formatError) {
+      wx.showToast({
+        title: '第2路IP地址格式错误,请检查!',
+        icon: 'none',
+        duration: 2000
+      })
+      return;
+    }
+    ip = this.data.rtuInfo['ip3'];
+    port = this.data.rtuInfo['ip3_port'];
+    ipV6Checked = this.data.rtuInfo['ipV6Checked3'];
+    formatError = this.checkIp(ip, port, ipV6Checked);
+    if (formatError) {
+      wx.showToast({
+        title: '第3路IP地址格式错误,请检查!',
+        icon: 'none',
+        duration: 2000
+      })
+      return;
+    }
+    ip = this.data.rtuInfo['ip4'];
+    port = this.data.rtuInfo['ip4_port'];
+    ipV6Checked = this.data.rtuInfo['ipV6Checked4'];
+    formatError = this.checkIp(ip, port, ipV6Checked);
+    if (formatError) {
+      wx.showToast({
+        title: '第4路IP地址格式错误,请检查!',
+        icon: 'none',
+        duration: 2000
+      })
+      return;
+    }
+    this.cancelTime();
+    this.setRtuBaseSetting(this.data.rtuInfo);
+  },
+  setRtuBaseSetting(rtuInfo) {
+    let datagram = datagramHelp.datagram_40(rtuInfo);
+    this.sendDatagramToRtu(datagram);
+  },
+  /**
+   * 查询测站基础参数信息
+   */
+  getRtuBaseSetting() {
+    let datagram = datagramHelp.datagram_41();
+    let cache = this.data.datagramCache;
+    cache.push(datagram);
+
+
+  },
+  pushDatagramBuff(datagram) {
+    let tmpdatagramBuff = this.data.datagramBuff;
+    if (tmpdatagramBuff.length > 0) {
+      tmpdatagramBuff = tmpdatagramBuff + datagram;
+    } else {
+      tmpdatagramBuff = datagram;
+    }
+    console.log(" datagram buff ==========", tmpdatagramBuff)
+    this.setData({
+      datagramBuff: tmpdatagramBuff
+    })
+    this.processDatagram();
+  },
+  processDatagram() {
+    let datagram = this.data.datagramBuff;
+    if (datagram.length > 0) {
+      for (let i = 0; i < datagram.length; i++) {
+        if (datagram.indexOf("7e7e") == 0) {
+          break;
+        } else {
+          datagram = datagram.substring(i, datagram.length);
+        }
+      }
+      if (null != datagram && datagram.length > 0 && datagram.indexOf("7e7e") >= 0) {
+        if (datagram.length >= 26) {
+          var lenBuff = util.HexStr2Bytes(datagram.substring(22, 22 + 4));
+          var len = util.byteToUint16(lenBuff); // 报文长度(int)
+          var datagramlength = 11 + len + 6;
+          if (datagram.length >= datagramlength * 2) {
+            var onedatagram = datagram.substring(0, datagramlength * 2);
+            if (!datagramHelp.crcCheck(onedatagram)) {
+              wx.showToast({
+                title: '数据CRC校验错误,请重试!',
+                icon: 'none',
+                duration: 2000
+              })
+              this.setData({
+                datagramBuff: ''
+              })
+              return;
+            }
+            var count = 20;
+            var funcode = datagram.substring(count, count + 2);
+            count += 2;
+            if (funcode == "f6") {
+
+            } else if (funcode == "f7") {
+
+            } else if (funcode == '45') {
+
+            } else if (funcode == '47') {
+
+            } else if (funcode == '48') {
+
+            } else if (funcode == '41') {
+              var info = datagramHelp.datagram_41_analyse(onedatagram)
+              console.log(info)
+              let rtuCode = info['rtu_code'];
+              let workModel = info['rtu_work_model'];
+              let rtuInfo = this.data.rtuInfo;
+              rtuInfo['rtu_code'] = rtuCode;
+              rtuInfo['ip1'] = info['ip1'];
+              rtuInfo['ip2'] = info['ip2'];
+              rtuInfo['ip3'] = info['ip3'];
+              rtuInfo['ip4'] = info['ip4'];
+              rtuInfo['ip1_port'] = info['ip1_port'];
+              rtuInfo['ip2_port'] = info['ip2_port'];
+              rtuInfo['ip3_port'] = info['ip3_port'];
+              rtuInfo['ip4_port'] = info['ip4_port'];
+              rtuInfo['rtu_kind'] = info['rtu_kind'];
+              rtuInfo['ipV6Checked1'] = info['ipV6Checked1'];
+              rtuInfo['ipV6Checked2'] = info['ipV6Checked2'];
+              rtuInfo['ipV6Checked3'] = info['ipV6Checked3'];
+              rtuInfo['ipV6Checked4'] = info['ipV6Checked4'];
+              rtuInfo['netModel'] = info['net_model'];
+
+              console.log("netModel" + rtuInfo['netModel']);
+              let netModels = this.data.netModels;
+              for (let i = 0; i < netModels.length; i++) {
+                console.log("netModel " + i + " " + netModels[i].value);
+
+                if (netModels[i].value === rtuInfo['netModel']) {
+                  netModels[i].checked = true;
+                } else {
+                  netModels[i].checked = false;
+                }
+              }
+
+              console.log("ipv61 " + rtuInfo['ipV6Checked1']);
+              console.log("ipv62 " + rtuInfo['ipV6Checked2']);
+              console.log("ipv63 " + rtuInfo['ipV6Checked3']);
+              console.log("ipv64 " + rtuInfo['ipV6Checked4']);
+              let checkbox1 = this.data.ip1Checkbox;
+              let checkbox2 = this.data.ip2Checkbox;
+              let checkbox3 = this.data.ip3Checkbox;
+              let checkbox4 = this.data.ip4Checkbox;
+              if (rtuInfo['ipV6Checked1']) {
+                checkbox1[0].checked = false;
+                checkbox1[1].checked = true;
+              } else {
+                checkbox1[0].checked = true;
+                checkbox1[1].checked = false;
+              }
+              if (rtuInfo['ipV6Checked2']) {
+                checkbox2[0].checked = false;
+                checkbox2[1].checked = true;
+              } else {
+                checkbox2[0].checked = true;
+                checkbox2[1].checked = false;
+              }
+              if (rtuInfo['ipV6Checked3']) {
+                checkbox3[0].checked = false;
+                checkbox3[1].checked = true;
+              } else {
+                checkbox3[0].checked = true;
+                checkbox3[1].checked = false;
+              }
+              if (rtuInfo['ipV6Checked4']) {
+                checkbox4[0].checked = false;
+                checkbox4[1].checked = true;
+              } else {
+                checkbox4[0].checked = true;
+                checkbox4[1].checked = false;
+              }
+              rtuInfo['rtu_work_model'] = workModel;
+              let work_model_index = 0;
+              if (workModel == "0") {
+                work_model_index = 0;
+              } else {
+                work_model_index = 1;
+              }
+              let rtu_kind_index = 0;
+              for (let i = 0; i < this.data.rtu_kind_code.length; i++) {
+                let code = this.data.rtu_kind_code[i];
+                if (code == rtuInfo['rtu_kind']) {
+                  rtu_kind_index = i;
+                  break;
+                }
+              }
+              this.setData({
+                rtuInfo: rtuInfo,
+                netModels: netModels,
+                ip1Checkbox: checkbox1,
+                ip2Checkbox: checkbox2,
+                ip3Checkbox: checkbox3,
+                ip4Checkbox: checkbox4,
+                rtu_work_model_index: work_model_index,
+                rtu_kind_index: rtu_kind_index
+              });
+              let index = this.data.datagramIndex + 1;
+              if (this.data.datagramCache.length == index) {
+                index = 0;
+              }
+              this.setData({
+                datagramIndex: index,
+                trySendCount: 0
+              })
+              this.cancelTime();
+            } else if (funcode == '40') {
+              this.setData({
+                showSettingResult: true,
+                settingResultText: "基本参数配置已完成,请重新连接蓝牙!"
+              })
+              // wx.showToast({
+              //   title: 'RTU基本参数操作已完成!',
+              //   icon: 'ok',
+              //   duration: 2000 //持续的时间
+              // })
+            } else if (funcode == '43') {
+
+            } else if (funcode == '42') {
+
+            } else if (funcode == '4A') {
+
+            } else if (funcode == '51') {
+
+            } else if (funcode == 'f3') {
+
+            }
+            if (datagram.length - datagramlength * 2 > 0) {
+              let tmp = datagram.substring(datagramlength * 2, datagram.length);
+              this.setData({
+                datagramBuff: tmp
+              })
+            } else {
+              this.setData({
+                datagramBuff: ""
+              })
+            }
+          } else {
+            this.setData({
+              datagramBuff: datagram
+            })
+          }
+        } else {
+          this.setData({
+            datagramBuff: datagram
+          })
+        }
+      } else {
+        if (null != datagram && datagram.length > 0) {
+          this.setData({
+            datagramBuff: datagram
+          })
+        } else {
+          this.setData({
+            datagramBuff: ''
+          })
+        }
+      }
+    }
+  },
+  sendDatagramToRtu(datagram) {
+    console.log("will send datagram " + datagram);
+    let buffer = util.HexStr2Bytes(datagram);
+    var that = this;
+    let count = 0;
+    let inView = new DataView(buffer);
+    while (true) {
+      if (buffer.byteLength - count > 20) {
+        let tmpBuff = new ArrayBuffer(20);
+        let outView = new DataView(tmpBuff);
+        for (let i = 0; i < 20; i++) {
+          outView.setUint8(i, inView.getUint8(count + i))
+        }
+        wx.writeBLECharacteristicValue({
+          deviceId: that.data.devices['deviceId'],
+          serviceId: that.data.devices['serviceId'],
+          characteristicId: that.data.devices['characteristicId'],
+          value: tmpBuff,
+          success(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+            wx.onBLECharacteristicValueChange((characteristic) => {
+              console.log("read datagram==============", util.ab2hex(characteristic.value))
+              var datagram = util.ab2hex(characteristic.value);
+              that.pushDatagramBuff(datagram);
+            })
+            wx.readBLECharacteristicValue({
+              deviceId: that.data.devices['deviceId'],
+              serviceId: that.data.devices['serviceId'],
+              characteristicId: that.data.devices['characteristicId'],
+              success: function (res) {
+                console.log('readBLECharacteristicValue')
+              }
+            })
+          },
+          fail(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+          }
+        })
+        count += 20;
+      } else {
+        let len = buffer.byteLength - count;
+        let tmpBuff = new ArrayBuffer(len);
+        let outView = new DataView(tmpBuff);
+        for (let i = 0; i < len; i++) {
+          outView.setUint8(i, inView.getUint8(count + i))
+        }
+        wx.writeBLECharacteristicValue({
+          deviceId: that.data.devices['deviceId'],
+          serviceId: that.data.devices['serviceId'],
+          characteristicId: that.data.devices['characteristicId'],
+          value: tmpBuff,
+          success(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+            wx.onBLECharacteristicValueChange((characteristic) => {
+              console.log("read datagram==============", util.ab2hex(characteristic.value))
+              var datagram = util.ab2hex(characteristic.value);
+              that.pushDatagramBuff(datagram);
+            })
+            wx.readBLECharacteristicValue({
+              deviceId: that.data.devices['deviceId'],
+              serviceId: that.data.devices['serviceId'],
+              characteristicId: that.data.devices['characteristicId'],
+              success: function (res) {
+                console.log('readBLECharacteristicValue')
+              }
+            })
+          },
+          fail(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+          }
+        })
+        count += len;
+      }
+      if (count >= buffer.byteLength) {
+        break;
+      }
+    }
+  },
+  timeCallback() {
+    var that = this;
+    task_timer = setTimeout(function () {
+      console.log("------------------------------------Time CallBack----------------------------");
+      if (that.data.trySendCount == 0) {
+        if (that.data.datagramCache.length > 0) {
+          let datagram = that.data.datagramCache[that.data.datagramIndex];
+          that.sendDatagramToRtu(datagram);
+          let index = that.data.datagramIndex + 1;
+          if (that.data.datagramCache.length == index) {
+            index = 0;
+          }
+          let count = that.data.trySendCount + 1;
+          that.setData({
+            datagramIndex: index,
+            trySendCount: count
+          })
+        }
+      } else {
+        let count = that.data.trySendCount + 1;
+        if (count >= 10) {
+          count = 0;
+        }
+        that.setData({
+          trySendCount: count
+        })
+      }
+      that.timeCallback();
+    }, 3000);
+  },
+  cancelTime() {
+    if (task_timer != undefined) {
+      clearTimeout(task_timer);
+      task_timer = undefined;
+    }
+    this.setData({
+      datagramIndex: 0,
+      trySendCount: 0,
+      suspend: true
+    })
+  },
+  /**
+   * 第一路IPV6勾选项
+   * @param {} e 
+   */
+  netModelsCheckedChange: function (e) {
+    const netModels = this.data.netModels;
+    let netModel = e.detail.value;
+    for (let i = 0, len = netModels.length; i < len; ++i) {
+      netModels[i].checked = netModels[i].value === e.detail.value
+    }
+    const rtuInfo = this.data.rtuInfo;
+    rtuInfo.netModel = netModel;
+    this.setData({
+      netModels,
+      rtuInfo
+    })
+  },
+  /**
+   * 第一路IPV6勾选项
+   * @param {} e 
+   */
+  ip1CheckedChange: function (e) {
+    const ip1Checkbox = this.data.ip1Checkbox;
+    let ipV6Checked1 = false;
+    for (let i = 0, len = ip1Checkbox.length; i < len; ++i) {
+      ip1Checkbox[i].checked = ip1Checkbox[i].value === e.detail.value
+      if (e.detail.value === 'IPV6') {
+        ipV6Checked1 = true;
+      }
+    }
+    const rtuInfo = this.data.rtuInfo;
+    rtuInfo.ipV6Checked1 = ipV6Checked1;
+    this.setData({
+      ip1Checkbox,
+      rtuInfo
+    })
+  },
+  /**
+   * 第二路IP勾选项
+   * @param {} e 
+   */
+  ip2CheckedChange: function (e) {
+    const ip2Checkbox = this.data.ip2Checkbox;
+    let ipV6Checked2 = false;
+    for (let i = 0, len = ip2Checkbox.length; i < len; ++i) {
+      ip2Checkbox[i].checked = ip2Checkbox[i].value === e.detail.value
+      if (e.detail.value === 'IPV6') {
+        ipV6Checked2 = true;
+      }
+    }
+    const rtuInfo = this.data.rtuInfo;
+    rtuInfo.ipV6Checked2 = ipV6Checked2;
+    this.setData({
+      ip2Checkbox,
+      rtuInfo
+    })
+  },
+  /**
+   * 第三路IP勾选项
+   * @param {} e 
+   */
+  ip3CheckedChange: function (e) {
+    const ip3Checkbox = this.data.ip3Checkbox;
+    let ipV6Checked3 = false;
+    for (let i = 0, len = ip3Checkbox.length; i < len; ++i) {
+      ip3Checkbox[i].checked = ip3Checkbox[i].value === e.detail.value
+      if (e.detail.value === 'IPV6') {
+        ipV6Checked3 = true;
+      }
+    }
+    const rtuInfo = this.data.rtuInfo;
+    rtuInfo.ipV6Checked3 = ipV6Checked3;
+    this.setData({
+      ip3Checkbox,
+      rtuInfo
+    })
+  },
+  /**
+   * 第四路IP勾选项
+   * @param {} e 
+   */
+  ip4CheckedChange: function (e) {
+    const ip4Checkbox = this.data.ip4Checkbox;
+    let ipV6Checked4 = false;
+    for (let i = 0, len = ip4Checkbox.length; i < len; ++i) {
+      ip4Checkbox[i].checked = ip4Checkbox[i].value === e.detail.value
+      if (e.detail.value === 'IPV6') {
+        ipV6Checked4 = true;
+      }
+    }
+    const rtuInfo = this.data.rtuInfo;
+    rtuInfo.ipV6Checked4 = ipV6Checked4;
+    this.setData({
+      ip4Checkbox,
+      rtuInfo
+    })
+  }
+})

+ 6 - 0
pages/bluetooth/baseSetting/bluetoothBaseSetting.json

@@ -0,0 +1,6 @@
+{
+  "navigationBarTitleText": "",
+  "usingComponents": {
+    "mp-dialog": "weui-miniprogram/dialog/dialog"
+  }
+}

+ 171 - 0
pages/bluetooth/baseSetting/bluetoothBaseSetting.wxml

@@ -0,0 +1,171 @@
+<page>
+  <view class="body-content">
+    <view class="info_list_box">
+      <scroll-view class="info_list" scroll-y scroll-with-animation>
+        <!-- RTU编码设置 -->
+        <view class="weui-panel weui-panel_access">
+          <view class="weui-panel__hd">RTU编码</view>
+          <view class="weui-panel__bd">
+            <view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+              <view class="myinput ip-group">
+                <input type='text' value='{{rtuInfo.rtu_code}}' bindinput="bindNewRtuCodeInput"></input>
+              </view>
+            </view>
+          </view>
+        </view>
+        <!-- 网络模式 -->
+        <view class="weui-panel weui-panel_access">
+          <view class="weui-panel__hd">网络模式</view>
+          <view class="weui-panel__bd">
+            <view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+              <view>
+                <radio-group bindchange="netModelsCheckedChange">
+                  <label class="check-label-title" wx:for="{{netModels}}" wx:key="value">
+                    <radio value="{{item.value}}" checked="{{item.checked}}" />{{item.name}}
+                  </label>
+                </radio-group>
+              </view>
+            </view>
+          </view>
+        </view>
+        <!-- IP地址设置 -->
+        <view class="weui-panel weui-panel_access">
+          <view class="weui-panel__hd">IP地址</view>
+          <view class="weui-panel__bd">
+            <!-- 第1路IP设置 -->
+            <view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+              <view class="input-title">
+                第1路IP:
+              </view>
+              <view>
+                <radio-group bindchange="ip1CheckedChange">
+                  <label class="check-label-title" wx:for="{{ip1Checkbox}}" wx:key="value">
+                    <radio value="{{item.value}}" checked="{{item.checked}}" />{{item.name}}
+                  </label>
+                </radio-group>
+              </view>
+              <view class="weui-media-box__desc">
+                <view class="myinput ip-group" style="margin-top:10rpx">
+                  <input type='text' bindinput='bindIp1Input' value='{{rtuInfo.ip1}}'></input>
+                </view>
+                <view class="port ip-group" style="margin-top:10rpx">
+                  <input type='text' bindinput='bindIp1portInput' value='{{rtuInfo.ip1_port}}'></input>
+                </view>
+              </view>
+            </view>
+            <!-- 第2路IP设置 -->
+            <view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+              <view class="input-title">
+                第2路IP:
+              </view>
+              <view>
+                <radio-group bindchange="ip2CheckedChange">
+                  <label class="check-label-title" wx:for="{{ip2Checkbox}}" wx:key="value">
+                    <radio value="{{item.value}}" checked="{{item.checked}}" />{{item.name}}
+                  </label>
+                </radio-group>
+              </view>
+              <view class="weui-media-box__desc">
+                <view class="myinput ip-group" style="margin-top:10rpx">
+                  <input type='text' bindinput='bindIp2Input' value='{{rtuInfo.ip2}}'></input>
+                </view>
+                <view class="port ip-group" style="margin-top:10rpx">
+                  <input type='text' bindinput='bindIp2portInput' value='{{rtuInfo.ip2_port}}'></input>
+                </view>
+              </view>
+            </view>
+            <!-- 第3路IP设置 -->
+            <view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+              <view class="input-title">
+                第3路IP:
+              </view>
+              <view>
+                <radio-group bindchange="ip3CheckedChange">
+                  <label class="check-label-title" wx:for="{{ip3Checkbox}}" wx:key="value">
+                    <radio value="{{item.value}}" checked="{{item.checked}}" />{{item.name}}
+                  </label>
+                </radio-group>
+              </view>
+              <view class="weui-media-box__desc">
+                <view class="myinput ip-group" style="margin-top:10rpx">
+                  <input type='text' bindinput='bindIp3Input' value='{{rtuInfo.ip3}}'></input>
+                </view>
+                <view class="port ip-group" style="margin-top:10rpx">
+                  <input type='text' bindinput='bindIp3portInput' value='{{rtuInfo.ip3_port}}'></input>
+                </view>
+              </view>
+            </view>
+            <!-- 第4路IP设置 -->
+            <view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+              <view class="input-title">
+                第4路IP:
+              </view>
+              <view>
+                <radio-group bindchange="ip4CheckedChange">
+                  <label class="check-label-title" wx:for="{{ip4Checkbox}}" wx:key="value">
+                    <radio value="{{item.value}}" checked="{{item.checked}}" />{{item.name}}
+                  </label>
+                </radio-group>
+              </view>
+              <view class="weui-media-box__desc">
+                <view class="myinput ip-group" style="margin-top:10rpx">
+                  <input type='text' bindinput='bindIp4Input' value='{{rtuInfo.ip4}}'></input>
+                </view>
+                <view class="port ip-group" style="margin-top:10rpx">
+                  <input type='text' bindinput='bindIp4portInput' value='{{rtuInfo.ip4_port}}'></input>
+                </view>
+              </view>
+            </view>
+          </view>
+        </view>
+        <!-- 工作模式设置 -->
+        <view class="weui-panel weui-panel_access">
+          <view class="weui-panel__hd">工作模式</view>
+          <view class="weui-panel__bd">
+            <view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+              <view style="margin-left: 20rpx;margin-bottom: 10rpx;">
+                <view class="section">
+                  <picker bindchange="bindWorkModelPickerChange" value="{{rtu_work_model_index}}" range="{{rtu_work_model_name}}">
+                    <view class="picker picker_name">
+                      {{rtu_work_model_name[rtu_work_model_index]}}
+                    </view>
+                  </picker>
+                </view>
+              </view>
+            </view>
+          </view>
+        </view>
+        <!-- 测站分类码设置 -->
+        <view class="weui-panel weui-panel_access">
+          <view class="weui-panel__hd">测站分类码</view>
+          <view class="weui-panel__bd">
+            <view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+              <view style="margin-left: 20rpx;margin-bottom: 10rpx;">
+                <view class="section">
+                  <picker bindchange="bindRtuKindPickerChange" value="{{rtu_kind_index}}" range="{{rtu_kind_name}}">
+                    <view class="picker picker_name">
+                      {{rtu_kind_name[rtu_kind_index]}}
+                    </view>
+                  </picker>
+                </view>
+              </view>
+            </view>
+          </view>
+        </view>
+        <!-- 提交 -->
+        <view class="weui-panel weui-panel_access">
+          <view class="weui-panel__bd">
+            <view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+              <view class="submit-btn">
+                <button type="warn" bindtap="baseSettingBtn">提交</button>
+              </view>
+            </view>
+          </view>
+        </view>
+      </scroll-view>
+    </view>
+  </view>
+  <mp-dialog title="操作提示" show="{{showSettingResult}}" bindbuttontap="settingCompletTabEvent" buttons="{{[ {text: '确定'}]}}">
+    <view>{{settingResultText}}</view>
+  </mp-dialog>
+</page>

+ 119 - 0
pages/bluetooth/baseSetting/bluetoothBaseSetting.wxss

@@ -0,0 +1,119 @@
+/* page {
+  height: 97%;
+} */
+@import "../../weui/style/weui.wxss";
+
+.body-content{
+  width: 100%;
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+}
+
+.info_list_box{
+  width: 100%;
+  height: 100%;
+  position: relative;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+
+.info_list {
+  width: 98%;
+  height: 98%;
+  margin-top: 8px;
+  margin-bottom: 8px;
+}
+
+.info_text_line_inline{
+  width: 100%;
+  display: flex;
+  flex-direction: row;
+  align-items: flex-start;
+  color: black;
+}
+
+.info_text_line_inline_title{
+  width: 50%;
+}
+
+.info_text_line_inline_content{
+  width: 50%;
+  text-align: left;
+  color:#669999;
+  font-size: small;
+}
+
+.info_text_line_center{
+  text-align: center;
+}
+
+.datetime_font{
+  color:#669999;
+}
+
+.myinput{
+  width: 95%;
+  margin-left: 10rpx;
+  margin-top: 10rpx;
+  margin-bottom: 10rpx;
+}
+
+.myinput input {
+  border-style: solid;
+  border-width:thin;
+  border-color: lightgray;
+  padding-top: 10rpx;
+  padding-left: 10rpx;
+  padding-bottom: 10rpx;
+  color:#669999;
+  width: 100%;
+}
+
+.ip-group{
+  display: flex;
+  flex-direction: row;
+}
+
+.ip{
+  width:95%;
+  /* margin-right: 20rpx; */
+}
+
+.input-title{
+  margin-left:20rpx;
+  margin-right: 10rpx;
+  font-size: 14px;
+  color:gray;
+}
+
+.check-label-title{
+  margin-left:20rpx;
+  margin-right: 10rpx;
+  font-size: 14px;
+  color:gray;
+}
+
+
+.picker_name{
+  color:#669999;
+}
+
+.port{
+  width: 95%;
+  margin-left: 10rpx;
+  margin-top: 10rpx;
+  margin-bottom: 10rpx;
+}
+
+.port input {
+  border-style: solid;
+  border-width:thin;
+  border-color: lightgray;
+  padding-top: 10rpx;
+  padding-left: 10rpx;
+  padding-bottom: 10rpx;
+  color:#669999;
+  width: 50%;
+}

+ 810 - 0
pages/bluetooth/bluetooth.js

@@ -0,0 +1,810 @@
+const app = getApp();
+var util = require('../../utils/util');
+var datagramHelp = require('../../utils/datagramHelp');
+var task_timer;
+var scan_timer;
+Page({
+  data: {
+    devices: [],
+    alreadyConnectDevices: [],
+    connected: false,
+    chs: [],
+    isOpenBluetooth: false,
+    bluetoothOpening: false,
+    findBtnDisabled: true,
+    isFinding: false,
+    scanBtn: 'inline',
+    rtu_wakeup: '唤醒中...',
+    btnName: '开始扫描',
+    bluetoothConnectBtn: '连接设备',
+    connectedBluetoothName: '',
+    datagramBuff: '',
+    rtuWakeup: false,
+    read_datagram_bluebooth_css: '',
+    deviceId: '',
+    serviceId: '',
+    characteristicId: '',
+    showBleOpenFailDig: false,
+    showBleOtherErrorDig: false,
+    bleOtherErrorReeponseMsg: '',
+    discoveryStarted: false,
+    loadingHidden: true,
+    wakeupCount: 0,
+    scanDeviceTimeCount: 0,
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    console.log('bluebooth home load ', '**********************************************')
+    this.connectBle();
+    // var devices = [];
+    // var d = {};
+    // d['name'] = "1";
+    // d['localName'] = "1";
+    // d['RSSI'] = "1";
+    // d['deviceId'] = "1";
+    // devices.push(d);
+    // devices.push(d);
+    // devices.push(d);
+    // devices.push(d);
+    // devices.push(d);
+    // devices.push(d);
+
+    // var devices2 = [];
+    // devices2.push(d);
+
+    // this.setData({
+    //   rtuWakeup: false,
+    //   devices: devices,
+    //   alreadyConnectDevices: devices2
+    // })
+    var tmpDevices = wx.getStorageSync('alreadyConnectDevices');
+    if (null != tmpDevices && undefined != tmpDevices) {
+      this.setData({
+        alreadyConnectDevices: tmpDevices
+      })
+    }
+  },
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+    console.log('bluebooth home onHide ', '**********************************************')
+    this.cancelTaskTime();
+    this.cancelScanTime();
+  },
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+    console.log('bluebooth home onUnload ', '**********************************************')
+    this.cancelTaskTime();
+    this.cancelScanTime();
+    this.closeBluetoothAdapter();
+    this.blueboothCloseState();
+  },
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    console.log('bluebooth home onShow ', '**********************************************')
+  },
+  /**
+   * 蓝牙适配器-打开状态
+   */
+  blueboothOpenState() {
+    this.setData({
+      isOpenBluetooth: true,
+    })
+  },
+  /**
+   * 蓝牙适配器-关闭状态
+   */
+  blueboothCloseState() {
+    this.setData({
+      isOpenBluetooth: false,
+    })
+  },
+  /**
+   * 开始连接蓝牙
+   */
+  connectBle() {
+    console.log("connectBle ", "isOpenBluetooth " + this.data.isOpenBluetooth);
+    if (!this.data.isOpenBluetooth) {
+      if (!this.data.bluetoothOpening) {
+        this.setData({
+          bluetoothOpening: true,
+        })
+        this.openBluetoothAdapter();
+      }
+    }
+  },
+  /**
+   * 打开蓝牙适配器
+   */
+  openBluetoothAdapter() {
+    let that = this;
+    console.log("openBluetoothAdapter", "***** open **********")
+    wx.openBluetoothAdapter({
+      success: (res) => {
+        //改变连接状态
+        that.blueboothOpenState();
+        console.log("openBluetoothAdapter", "***** open success " + that.data.isOpenBluetooth);
+        that.setData({
+          bluetoothOpening: false,
+        })
+        //初始化成功,监听
+        that.onBluetoothAdapterStateChange();
+        //消息提示
+        wx.showToast({
+          title: '蓝牙设备打开成功',
+          icon: 'none',
+          duration: 2000,
+        })
+      },
+      fail: (res) => {
+        if (res.errCode != undefined) {
+          let code = res.errCode;
+          // if (code == app.globalData.bluetoothErrCode.alreadyConnect) {
+          //   console.log("openBluetoothAdapter","***** openBluetoothAdapter alreadyConnect **********")
+          //   //已连接,监听
+          //   that.onBluetoothAdapterStateChange();
+          //   //改变连接状态
+          //   that.blueboothOpenState();
+          // } else 
+          if (code == app.globalData.bluetoothErrCode.notAvailable) {
+            console.log("openBluetoothAdapter", "***** openBluetoothAdapter notAvailable **********")
+            //蓝牙未打开,提示用户
+            that.setData({
+              showBleOpenFailDig: true,
+              loadingHidden: true,
+            })
+          } else {
+            //其它错误
+            console.log("openBluetoothAdapter", "***** openBluetoothAdapter error code " + code + " **********")
+            that.setData({
+              bleOtherErrorReeponseMsg: "蓝牙模块系统异常,请重新打开蓝牙助手再试,错误代码: " + code,
+              showBleOtherErrorDig: true,
+              loadingHidden: true,
+            })
+          }
+        } else {
+          //未知错误
+          console.log("openBluetoothAdapter", "***** openBluetoothAdapter error msg  " + res.errMsg + " **********")
+          that.setData({
+            bleOtherErrorReeponseMsg: "蓝牙模块系统异常,请重新打开蓝牙助手再试,错误信息: " + res.errMsg,
+            showBleOtherErrorDig: true,
+            loadingHidden: true,
+          })
+        }
+        that.setData({
+          bluetoothOpening: false,
+        })
+      }
+    })
+  },
+  /**
+   * 关闭蓝牙适配器
+   */
+  closeBluetoothAdapter() {
+    if (this.data.isOpenBluetooth) {
+      wx.closeBluetoothAdapter();
+      this.setData({
+        bluetoothOpening: false
+      })
+    }
+  },
+  /**
+   * 监听蓝牙适配器的变化
+   */
+  onBluetoothAdapterStateChange() {
+    let that = this;
+    wx.onBluetoothAdapterStateChange(function (res) {
+      if (res.available) {
+        console.log("onBluetoothAdapterStateChange", "******* onBluetoothAdapterStateChange  available *********")
+        that.connectBle();
+      } else {
+        console.log("onBluetoothAdapterStateChange", "******* onBluetoothAdapterStateChange  unavailable *********")
+        that.blueboothCloseState();
+        wx.showToast({
+          title: '蓝牙设备断开',
+          icon: 'none',
+          duration: 2000
+        })
+      }
+      if (res.discovering) {
+        console.log("onBluetoothAdapterStateChange", "******* onBluetoothAdapterStateChange discovering *********")
+      } else {
+        console.log("onBluetoothAdapterStateChange", "******* onBluetoothAdapterStateChange stop discovering *********")
+      }
+    })
+  },
+  /**
+   * 打开蓝牙失败确认事件
+   * @param {}} e 
+   */
+  bluetoothOpenEvent(e) {
+    this.setData({
+      showBleOpenFailDig: false
+    })
+    const btn = e.detail.index;
+    if (btn == 0) {
+      this.closeBluetoothAdapter();
+      wx.navigateBack();
+    } else if (btn == 1) {
+      this.connectBle();
+    }
+  },
+  /**
+   * 蓝牙系统错误确认事件
+   * @param {*} e 
+   */
+  bluetoothOtherErrorEvent(e) {
+    this.setData({
+      showBleOtherErrorDig: false
+    })
+    this.closeBluetoothAdapter();
+    wx.navigateBack();
+  },
+  /**
+   * 开始扫描操作事件
+   */
+  scanBluetoothDevicesHandle() {
+    if (this.data.isFinding) {
+      this.stopBluetoothDevicesDiscovery()
+      this.cancelScanTime();
+      console.log('scanBluetoothDevicesHandle', 'stop scan bluebooth devices *****************');
+    } else {
+      this.startBluetoothDevicesDiscovery()
+      console.log('scanBluetoothDevicesHandle', 'start scan bluebooth devices *****************');
+    }
+  },
+  /**
+   * 开始扫描蓝牙设置
+   */
+  startBluetoothDevicesDiscovery() {
+    if (this.data.discoveryStarted) {
+      return
+    }
+    const that = this;
+    let data = [];
+    this.setData({
+      btnName: '停止扫描',
+      isFinding: true,
+      devices: data,
+      rtuWakeu: false,
+      scanDeviceTimeCount: 0
+    })
+    wx.startBluetoothDevicesDiscovery({
+      allowDuplicatesKey: true,
+      success: (res) => {
+        console.log('startBluetoothDevicesDiscovery success', res)
+        that.setData({
+          discoveryStarted: true
+        })
+        that.scanTimeCallback();
+        wx.onBluetoothDeviceFound((res) => {
+          res.devices.forEach(device => {
+            if (device.name != undefined && device.name.length > 0) {
+              //console.log('bluetooth find *************************************', device.name)
+              if (device.name.indexOf('XT-') == 0 || device.name.indexOf('DH') == 0 || device.name.indexOf('dh') == 0) {
+                let foundDevices = that.data.devices
+                let idx = util.inArray(foundDevices, 'deviceId', device.deviceId)
+                if (idx === -1) {
+                  foundDevices[foundDevices.length] = device;
+                  that.setData({
+                    scanDeviceTimeCount: 0
+                  });
+                } else {
+                  foundDevices[idx] = device;
+                }
+                that.setData({
+                  devices: foundDevices
+                });
+              }
+            }
+          })
+        })
+      },
+      fail: (res) => {
+        console.log('startBluetoothDevicesDiscovery fail', res)
+        that.setData({
+          isFinding: false,
+          btnName: '开始扫描',
+          discoveryStarted: false
+        })
+      }
+    })
+  },
+  /**
+   * 停止扫描蓝牙设备
+   */
+  stopBluetoothDevicesDiscovery() {
+    let that = this;
+    wx.stopBluetoothDevicesDiscovery({
+      success(res) {
+        that.cancelScanTime();
+        that.setData({
+          isFinding: false,
+          btnName: '开始扫描',
+          discoveryStarted: false
+        })
+      }
+    });
+  },
+  /**
+   * 连接蓝牙设备
+   * @param {*} e 
+   */
+  onBLEConnectionHandle(e) {
+    var that = this;
+    const ds = e.currentTarget.dataset;
+    const deviceId = ds.deviceId;
+    const name = ds.name;
+    if (this.data.discoveryStarted) {
+      this.stopBluetoothDevicesDiscovery();
+      this.cancelScanTime();
+    }
+    this.setData({
+      connectedBluetoothName: name,
+      deviceId: deviceId,
+      isFinding: false,
+      loadingHidden: false,
+      wakeupCount: 1,
+      rtuWakeup: false
+    })
+    console.log('onBLEConnectionHandle  connect ', name)
+    wx.createBLEConnection({
+      deviceId,
+      timeout: 5000,
+      success: (res) => {
+        console.log('onBLEConnectionHandle  connect success ', name)
+        that.setData({
+          connected: true
+        })
+        // wx.onBLEConnectionStateChange(function (res) {
+        //   // 该方法回调中可以用于处理连接意外断开等异常情况
+        //   console.log(`device ${res.deviceId} state has changed, connected: ${res.connected}`)
+        // })
+        that.getBLEDeviceServices(deviceId);
+      },
+      fail(res) {
+        if (res.errCode != undefined) {
+          if (res.errCode == app.globalData.bluetoothErrCode.alreadyConnect) {
+            that.setData({
+              loadingHidden: true,
+              rtuWakeup: false,
+              wakeupCount: 1
+            })
+            that.datagramReadTask();
+            that.taskTimeCallback();
+          } else {
+            console.log("onBLEConnectionHandle ", "*****  error code  " + res.errCode + " **********")
+            that.setData({
+              bleOtherErrorReeponseMsg: "蓝牙模块系统异常,请重新打开蓝牙助手再试,错误代码: " + res.errCode,
+              showBleOtherErrorDig: true,
+              loadingHidden: true
+            })
+          }
+        } else {
+          console.log("onBLEConnectionHandle ", "*****  error msg  " + res.errMsg + " **********")
+          that.setData({
+            bleOtherErrorReeponseMsg: "蓝牙模块系统异常,请重新打开蓝牙助手再试,错误信息: " + res.errMsg,
+            showBleOtherErrorDig: true,
+            loadingHidden: true
+          })
+        }
+      }
+    })
+  },
+  onBLEConnectionFormQr(device) {
+    var that = this;
+    const deviceId = device.deviceId;
+    const name = device.name;
+    if (this.data.discoveryStarted) {
+      this.stopBluetoothDevicesDiscovery();
+      this.cancelScanTime();
+    }
+    this.setData({
+      connectedBluetoothName: name,
+      deviceId: deviceId,
+      isFinding: false,
+      loadingHidden: false,
+      wakeupCount: 1,
+      rtuWakeup: false
+    })
+    console.log('onBLEConnectionHandle  connect ', name)
+    wx.createBLEConnection({
+      deviceId,
+      timeout: 5000,
+      success: (res) => {
+        console.log('onBLEConnectionHandle  connect success ', name)
+        that.setData({
+          connected: true
+        })
+        that.getBLEDeviceServices(deviceId);
+      },
+      fail(res) {
+        if (res.errCode != undefined) {
+          if (res.errCode == app.globalData.bluetoothErrCode.alreadyConnect) {
+            that.setData({
+              loadingHidden: true,
+              rtuWakeup: false,
+              wakeupCount: 1
+            })
+            that.datagramReadTask();
+            that.taskTimeCallback();
+          } else {
+            console.log("onBLEConnectionHandle ", "*****  error code  " + res.errCode + " **********")
+            that.setData({
+              bleOtherErrorReeponseMsg: "蓝牙模块系统异常,请重新打开蓝牙助手再试,错误代码: " + res.errCode,
+              showBleOtherErrorDig: true,
+              loadingHidden: true
+            })
+          }
+        } else {
+          console.log("onBLEConnectionHandle ", "*****  error msg  " + res.errMsg + " **********")
+          that.setData({
+            bleOtherErrorReeponseMsg: "蓝牙模块系统异常,请重新打开蓝牙助手再试,错误信息: " + res.errMsg,
+            showBleOtherErrorDig: true,
+            loadingHidden: true
+          })
+        }
+      }
+    })
+  },
+  onStartQr: function (e) {
+    var that = this;
+    // 允许从相机和相册扫码
+    wx.scanCode({
+      success: (res) => {
+        var result = res.result;
+        if (result != undefined && result.length > 0) {
+          that.findDeviceByQr(result)
+        }
+      }
+    })
+  },
+  findDeviceByQr(qr) {
+    for (let i = 0; i < this.data.devices.length; i++) {
+      let d = this.data.devices[i];
+      if (d.name == qr) {
+        this.onBLEConnectionFormQr(d);
+        return;
+      }
+    }
+    for (let i = 0; i < this.data.alreadyConnectDevices.length; i++) {
+      let d = this.data.alreadyConnectDevices[i];
+      if (d.name == qr) {
+        this.onBLEConnectionFormQr(d);
+        return;
+      }
+    }
+    wx.showToast({
+      title: '没匹配到设备',
+      icon: 'error',
+      duration: 2000
+    })
+  },
+  /**
+   * 获取蓝牙设备所有服务(service)
+   * @param {*} deviceId 
+   */
+  getBLEDeviceServices(deviceId) {
+    const that = this;
+    console.log('*************************** getBLEDeviceServices  start', deviceId);
+    wx.getBLEDeviceServices({
+      deviceId,
+      success: (res) => {
+        console.log('*************************** getBLEDeviceServices  ', "ok");
+        let toNext = false;
+        for (let i = 0; i < res.services.length; i++) {
+          console.log(' res++++++++++++ ', res.services[i])
+          if (res.services[i].isPrimary) {
+            toNext = true;
+            that.getBLEDeviceCharacteristics(deviceId, res.services[i].uuid);
+            break;
+          }
+        }
+        if (!toNext) {
+          that.setData({
+            loadingHidden: true
+          })
+        }
+      },
+      fail: (res) => {
+        console.log("getBLEDeviceServices ", "*****  error msg  " + res.errMsg + " **********")
+        that.setData({
+          bleOtherErrorReeponseMsg: "蓝牙模块系统异常,请重新打开蓝牙助手再试,错误信息: " + res.errMsg,
+          showBleOtherErrorDig: true,
+          loadingHidden: true
+        })
+      }
+    })
+  },
+  /**
+   * 获取蓝牙设备某个服务中所有特征值(characteristic)
+   * @param {*} deviceId 
+   * @param {*} serviceId 
+   */
+  getBLEDeviceCharacteristics(deviceId, serviceId) {
+    var that = this
+    wx.getBLEDeviceCharacteristics({
+      deviceId,
+      serviceId,
+      success: (res) => {
+        console.log('getBLEDeviceCharacteristics success', res.characteristics)
+        that.setData({
+          canWrite: false
+        })
+        let write_uuid = [];
+        for (let i = 0; i < res.characteristics.length; i++) {
+          let item = res.characteristics[i]
+          if (item.properties.read) {
+            console.log("read uuid", item.uuid)
+            // that.setData({
+            //   deviceId: deviceId,
+            //   serviceId: serviceId,
+            //   characteristicId: item.uuid
+            // })
+            wx.readBLECharacteristicValue({
+              deviceId,
+              serviceId,
+              characteristicId: item.uuid,
+            })
+          }
+          if (item.properties.write) {
+            //使用透传UUID进行读
+            console.log("write uuid", item.uuid)
+            let u = "" + item.uuid;
+            write_uuid.push(u);
+            // if (u.includes("FFE1", 0)) {
+            that.setData({
+              canWrite: true,
+              // deviceId: deviceId,
+              // serviceId: serviceId,
+              // characteristicId: item.uuid
+            })
+            // }
+          }
+          if (item.properties.notify || item.properties.indicate) {
+            console.log("notify uuid", item.uuid)
+            //  console.log('notify success+++++++++++++++++++++++ ')
+            // that.setData({
+            //   deviceId: deviceId,
+            //   serviceId: serviceId,
+            //   characteristicId: item.uuid
+            // })
+            wx.notifyBLECharacteristicValueChange({
+              deviceId,
+              serviceId,
+              characteristicId: item.uuid,
+              state: true,
+            })
+          }
+        }
+        that.setData({
+          loadingHidden: true
+        })
+        if (this.data.canWrite) {
+          if (write_uuid.length == 1) {
+            console.log("get uuid", write_uuid[0])
+            that.setData({
+              deviceId: deviceId,
+              serviceId: serviceId,
+              characteristicId: write_uuid[0]
+            })
+          } else {
+            for (let j = 0; j < write_uuid.length; j++) {
+              let uid = "" + write_uuid[j];
+              if (uid.includes("FFE1", 0)) {
+                console.log("get uuid", uid)
+                that.setData({
+                  // canWrite: true,
+                  deviceId: deviceId,
+                  serviceId: serviceId,
+                  characteristicId: uid
+                })
+                break;
+              }
+            }
+          }
+          that.canWriteBLECharacteristicValue()
+        }
+      },
+      fail(res) {
+        console.log("getBLEDeviceCharacteristics ", "*****  error msg  " + res.errMsg + " **********")
+        that.setData({
+          bleOtherErrorReeponseMsg: "蓝牙模块系统异常,请重新打开蓝牙助手再试,错误信息: " + res.errMsg,
+          showBleOtherErrorDig: true,
+          loadingHidden: true
+        })
+      }
+    })
+  },
+  /**
+   * 发送蓝牙设备唤醒报文
+   */
+  datagramReadTask() {
+    const that = this;
+    this.setData({
+      read_datagram_bluebooth_css: 'shanshuo'
+    })
+    if (!this.data.rtuWakeup) {
+      console.log("------------------------------------f6 datagram----------------------------");
+      this.sendWakeupDatagram();
+    }
+  },
+  processWakeupDatagram() {
+    let datagram = this.data.datagramBuff;
+    if (datagram.length > 0) {
+      if (datagram.indexOf("7e7e") >= 0) {
+        if (datagram.length >= 50) {
+          const funcode = datagram.substring(20, 22);
+          if (funcode == 'f6') {
+            console.log("------------------------------------find  f6 datagram----------------------------");
+            this.setData({
+              read_datagram_bluebooth_css: '',
+              rtuWakeup: true,
+              datagramBuff: ''
+            })
+          } else {
+            this.setData({
+              datagramBuff: ''
+            })
+          }
+        }
+      } else {
+        this.setData({
+          datagramBuff: ''
+        })
+      }
+    }
+    if (this.data.rtuWakeup) {
+      this.cancelTaskTime();
+      this.cancelScanTime();
+      this.setData({
+        loadingHidden: true
+      })
+      var tmpDevices = [];
+      var device = {};
+      device['deviceId'] = this.data.deviceId;
+      device['name'] = this.data.connectedBluetoothName;
+      device['serviceId'] = this.data.serviceId;
+      device['characteristicId'] = this.data.characteristicId;
+      tmpDevices.push(device);
+      var devices = this.data.alreadyConnectDevices;
+      for (var i = 0; i < devices.length; i++) {
+        var d = devices[i];
+        if (device['deviceId'] !== d['deviceId']) {
+          tmpDevices.push(d);
+        }
+        if (tmpDevices.length >= 5) {
+          break;
+        }
+      }
+      try {
+        wx.setStorageSync('alreadyConnectDevices', tmpDevices);
+      } catch (e) {
+        console.log(e);
+      }
+      this.setData({
+        alreadyConnectDevices: tmpDevices
+      })
+      //跳转到蓝牙主页
+      wx.navigateTo({
+        url: '/pages/bluetooth/home/bluetoothHome?connectedBluetoothName=' + this.data.connectedBluetoothName + '&deviceId=' + this.data.deviceId + '&serviceId=' + this.data.serviceId + '&characteristicId=' + this.data.characteristicId,
+      })
+    }
+  },
+  /**
+   * 接收到数据
+   * @param {} datagram 
+   */
+  pushDatagram(datagram) {
+    if (null != datagram && datagram.length > 0) {
+      var tmpdatagramBuff = this.data.datagramBuff;
+      if (tmpdatagramBuff.length > 0) {
+        tmpdatagramBuff = tmpdatagramBuff + datagram;
+      } else {
+        tmpdatagramBuff = datagram;
+      }
+      console.log(" datagram buff ==========", tmpdatagramBuff)
+      this.setData({
+        datagramBuff: tmpdatagramBuff
+      })
+      this.processWakeupDatagram();
+    }
+  },
+  /**
+   * 发送唤醒蓝牙设备操作
+   */
+  sendWakeupDatagram() {
+    let datagram = datagramHelp.datagram_f6();
+    let buffer = util.HexStr2Bytes(datagram);
+    var that = this
+    wx.writeBLECharacteristicValue({
+      deviceId: this.data.deviceId,
+      serviceId: this.data.serviceId,
+      characteristicId: this.data.characteristicId,
+      value: buffer,
+      success(res) {
+        console.log('writeBLECharacteristicValue success', res.errMsg)
+        // 操作之前先监听,保证第一时间获取数据
+        wx.onBLECharacteristicValueChange((characteristic) => {
+          console.log("read datagram==========", util.ab2hex(characteristic.value))
+          let datagram = util.ab2hex(characteristic.value);
+          that.pushDatagram(datagram);
+        })
+        wx.readBLECharacteristicValue({
+          deviceId: that.data.deviceId,
+          serviceId: that.data.serviceId,
+          characteristicId: that.data.characteristicId,
+          success: function (res) {
+            console.log('readBLECharacteristicValue')
+          }
+        })
+      },
+      fail(res) {
+        console.log('writeBLECharacteristicValue success', res.errMsg);
+      }
+    })
+  },
+  taskTimeCallback() {
+    console.log("------------------------------------Task Time CallBack----------------------------");
+    var that = this;
+    if (!this.data.rtuWakeup) {
+      if (this.data.wakeupCount >= 5) {
+        this.setData({
+          loadingHidden: true
+        })
+      } else {
+        task_timer = setTimeout(function () {
+          that.datagramReadTask();
+          that.taskTimeCallback();
+        }, 3000);
+      }
+    }
+  },
+  cancelTaskTime() {
+    if (task_timer != undefined) {
+      clearTimeout(task_timer);
+      task_timer = undefined;
+    }
+  },
+  scanTimeCallback() {
+    console.log("------------------------------------Scan Time CallBack----------------------------");
+    var that = this;
+    if (this.data.scanDeviceTimeCount >= 6) {
+      console.log("Scan Time CallBack stopBluetoothDevicesDiscovery");
+      this.stopBluetoothDevicesDiscovery();
+    } else {
+      let c = this.data.scanDeviceTimeCount + 2;
+      this.setData({
+        scanDeviceTimeCount: c
+      })
+      scan_timer = setTimeout(function () {
+        that.scanTimeCallback();
+      }, 2000);
+    }
+  },
+  cancelScanTime() {
+    if (scan_timer != undefined) {
+      clearTimeout(scan_timer);
+      scan_timer = undefined;
+    }
+  },
+  canWriteBLECharacteristicValue() {
+    if (!this.data.rtuWakeup) {
+      this.setData({
+        isFinding: false,
+        btnName: '开始扫描',
+        rtuWakeup: false
+      })
+      console.log("----------------------------------- 发送第一个包----------------------------");
+      this.datagramReadTask();
+      this.taskTimeCallback();
+    }
+  }
+})

+ 6 - 0
pages/bluetooth/bluetooth.json

@@ -0,0 +1,6 @@
+{
+  "navigationBarTitleText": "",
+  "usingComponents": {
+    "mp-dialog": "weui-miniprogram/dialog/dialog"
+  }
+}

+ 95 - 0
pages/bluetooth/bluetooth.wxml

@@ -0,0 +1,95 @@
+<page>
+  <wxs module="utils">
+    module.exports.max = function (n1, n2) {
+      return Math.max(n1, n2)
+    }
+    module.exports.len = function (arr) {
+      arr = arr || []
+      return arr.length
+    }
+  </wxs>
+
+  <view class="page-bluebooth-list" style="display:{{scanBtn}}">
+    <view class="body-toolBar">
+      <image class="bltImg" src="/images/blt-link.png"></image>
+      <view style="display: flex;flex-direction: row;justify-content: center;"> 
+        <button class="scanBtn" loading="{{isFinding}}" bindtap="scanBluetoothDevicesHandle">{{btnName}}</button>
+        <view bindtap="onStartQr" style="margin-top: 25rpx;margin-left: 40rpx;width:50rpx;height:50rpx;background-color: white;border-radius: 50%;box-shadow:0 0 10rpx 10rpx white;">
+          <image src='/images/scan.png' style="width:50rpx;height:50rpx;" > </image>
+        </view>
+      </view>
+    </view>
+    <view class="body-content">
+      <view class="device-list-box">
+        <scroll-view class="device_list" scroll-y scroll-with-animation>
+          <view class="devices_summary">
+            <text>扫描到的新设备: </text><text style="color:#FD7400;">{{devices.length}}</text>
+          </view>
+          <view class="devicesBox">
+            <view wx:for="{{devices}}" wx:key="index" data-device-id="{{item.deviceId}}" data-name="{{item.name || item.localName}}" class="device_item">
+              <view class="bluetooth-status-box">
+                <view class="bluebooth-status-line">
+                  <view class="bluebooth-status-image-view">
+                    <image id="{{item.icon}}" src='/images/bluebooth.png'></image>
+                  </view>
+                  <view class="bluebooth-status-name-view">
+                    <text>{{item.name}}</text>
+                  </view>
+                </view>
+                <view class="bluebooth-status-info-sub">
+                  <text>信号强度: {{item.RSSI}}dBm ({{utils.max(0, item.RSSI + 100)}}%)</text>
+                </view>
+                <view class="bluebooth-status-info-sub">
+                  <text>UUID: {{item.deviceId}}</text>
+                </view>
+              </view>
+              <view class="bluebooth-process-box">
+                <view class="bluebooth-process-btn">
+                  <button style="margin-right: 10px;" hover-class='blue-icon-button-hover' size="mini" data-device-id="{{item.deviceId}}" data-name="{{item.name || item.localName}}" bindtouchend="onBLEConnectionHandle">连接设备</button>
+                </view>
+              </view>
+            </view>
+          </view>
+          <view class="devices_summary">
+            <text>最近连接的设备: </text>
+          </view>
+          <view class="devicesBox">
+            <view wx:for="{{alreadyConnectDevices}}" wx:key="index" data-device-id="{{item.deviceId}}" data-name="{{item.name || item.localName}}" class="device_item">
+              <view class="bluetooth-status-box">
+                <view class="bluebooth-status-line">
+                  <view class="bluebooth-status-image-view">
+                    <image id="{{item.icon}}" src='/images/bluebooth.png'></image>
+                  </view>
+                  <view class="bluebooth-status-name-view">
+                    <text>{{item.name}}</text>
+                  </view>
+                </view>
+                <!-- <view class="bluebooth-status-info-sub">
+                  <text>信号强度: {{item.RSSI}}dBm ({{utils.max(0, item.RSSI + 100)}}%)</text>
+                </view> -->
+                <view class="bluebooth-status-info-sub">
+                  <text>UUID: {{item.deviceId}}</text>
+                </view>
+              </view>
+              <view class="bluebooth-process-box">
+                <view class="bluebooth-process-btn">
+                  <button style="margin-right: 10px;" hover-class='blue-icon-button-hover' size="mini" data-device-id="{{item.deviceId}}" data-name="{{item.name || item.localName}}" bindtouchend="onBLEConnectionHandle">连接设备</button>
+                </view>
+              </view>
+            </view>
+          </view>
+        </scroll-view>
+      </view>
+    </view>
+  </view>
+  <mp-dialog title="操作提示" show="{{showBleOpenFailDig}}" bindbuttontap="bluetoothOpenEvent" buttons="{{[ {text: '取消'}, {text: '重试'}]}}">
+    <view>当前蓝牙不可用,请检查手机蓝牙是否已打开后再试!</view>
+  </mp-dialog>
+  <mp-dialog title="操作提示" show="{{showBleOtherErrorDig}}" bindbuttontap="bluetoothOtherErrorEvent" buttons="{{[ {text: '确定'}]}}">
+    <view>{{bleOtherErrorReeponseMsg}}</view>
+  </mp-dialog>
+  <!-- <view class="qrbtn">
+    <button type="primary" bindtouchend="onStartQr">扫码连接</button>
+  </view> -->
+  <loading hidden="{{loadingHidden}}"></loading>
+</page>

+ 366 - 0
pages/bluetooth/bluetooth.wxss

@@ -0,0 +1,366 @@
+ page {
+  width: 100%;
+  height: 99%;
+  overflow: hidden;
+} 
+
+.page-bluebooth-list{
+  width: 100%;
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+  justify-content: start;
+  overflow: hidden;
+}
+
+.page-rtu-status-list{
+  width: 100%;
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+}
+
+.body-toolBar{
+  width:100%;
+  height: 35%;
+  background-color: #426666;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+
+.body-content{
+  width: 100%;
+  height: 64%;
+  background-color: white;
+  display: flex;
+  flex-direction: column;
+}
+
+.qrbtn{
+   width: 100%;
+   height: 50px;
+   position: fixed;
+   bottom: 18rpx;
+   align-self: center;
+}
+
+.qrbtn button{
+  width:60%;
+}
+
+/* button{
+  margin-top: 30rpx;
+  margin-bottom: 10rpx;
+  margin-left: 20rpx;
+  margin-right: 20rpx;
+} */
+
+
+.button-sp-area{
+  margin: 0 auto;
+  width: 60%;
+}
+
+.mini-btn{
+  margin-right: 10rpx;
+}
+
+.devices_summary {
+  padding-top: 8px;
+  padding-left: 20rpx;
+  background-color: lightgrey;
+  width: 100%;
+  height:70rpx;
+}
+
+.devices_summary text{
+  font-size: 30rpx;
+  color:  #7b7b7b;
+  margin-left: 5px;
+}
+
+.devicesBox{
+  margin-top: 10rpx;
+  margin-bottom: 10rpx;
+}
+
+.connected_devices_info{
+  /* margin-top: 0px;
+  padding-left: 20rpx; */
+  background-color: #ffffff;
+  width: 90%;
+  height:15%;
+  display: flex;
+  flex-direction: column;
+  /* border-radius: 5px; */
+  position: relative;
+  /* top: -30px; */
+  border-bottom: 1px #dddddd solid;
+
+}
+
+/* .connected_devices_info text{
+  font-size: 26rpx;
+  color:  #444444;
+} */
+.itemBox{
+  width: 100%;
+  height: 90%;
+}
+
+.device_list {
+  width: 100%;
+  height: 99%;
+}
+
+.info_list {
+  /* margin: 50px 5px;
+  border: 1px solid #EEE;
+  border-radius: 5px;
+  width: auto;  */
+  width: 98%;
+  margin-top: 8px;
+  /* height: 90%;
+  background-color: #fff;
+  border-radius: 5px;
+  position: relative;
+  display: flex;
+  flex-direction: column;
+  align-items: center;  */
+}
+
+.device_item {
+  /* border-bottom: 1px gray solid; */
+  margin-left: 10rpx;
+  margin-right: 10rpx;
+  margin-top:10rpx;
+  margin-bottom:10rpx;
+  /* color: #666; */
+}
+.device_item_hover {
+  background-color: rgba(0, 0, 0, .1);
+}
+
+.bluebooth-status-line{
+  height:50rpx;
+  width: 100%;
+  display: flex;
+  flex-direction: row;
+}
+
+.connected-devices-info-name{
+  height:100%;
+  /* padding-left: 10rpx; */
+  width: 90%;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  margin-left: 8px;
+  margin-bottom: 5px;
+  
+}
+
+.connected-devices-info-name text{
+  color: #181818;
+  font-size: 32rpx;
+}
+
+.bluebooth-status-name-view{
+  height:100%;
+  padding-left: 10rpx;
+  width: 90%;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+}
+
+.bluebooth-status-name-view text{
+  color: #181818;
+  font-size: 30rpx;
+}
+
+
+.connected-devices-info-image{
+  height:100%;
+  align-items: center;
+  margin-left: 8px;
+  margin-top: 8px;
+  /* width: 10%; */
+}
+
+/* .connected-devices-info-image image{
+  width: 40rpx;
+  height: 40rpx;
+  margin-left: 10rpx;
+  margin-top:5rpx;
+} */
+
+.bluebooth-status-image-view{
+  height:100%;
+  align-items: center;
+  width: 10%;
+}
+
+.bluebooth-status-image-view image{
+  width: 40rpx;
+  height: 40rpx;
+  margin-left: 10rpx;
+  margin-top:5rpx;
+  /* margin-right: 10rpx;
+  margin-left: 10rpx;
+  margin-top:5rpx; */
+}
+
+.bluebooth-status-info-sub{
+  height:40rpx;
+  align-items: center;
+  padding-left: 10rpx;
+  width: 100%;
+}
+
+.bluebooth-status-info-sub text{
+  font-size: 24rpx;
+  color: #acacac;
+}
+
+.bluebooth-process-box{
+  width: 95%;
+  display: flex;
+  flex-direction: row;
+  justify-content: flex-end;
+}
+
+.bluebooth-process-btn{
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+}
+
+.bluebooth-process-btn button{
+ color:#ffffff;
+ font-size:26rpx;
+ background-color:#669999;
+}
+
+.connected_info {
+  position: fixed;
+  bottom: 0;
+  width: 100%;
+  background-color: #F0F0F0;
+  padding: 10px;
+  padding-bottom: 20px;
+  margin-bottom: env(safe-area-inset-bottom);
+  font-size: 14px;
+  min-height: 100px;
+  box-shadow: 0px 0px 3px 0px;
+}
+.connected_info .operation {
+  position: absolute;
+  display: inline-block;
+  right: 30px;
+}
+
+.rtu_status_line_white{
+  /* background-color: whitesmoke; */
+  height: 60rpx;
+  display: flex;
+  flex-direction: row;
+}
+
+.rtu_status_line_grey{
+  /* background-color: #EEEEEE; */
+  height: 60rpx;
+  display: flex;
+  flex-direction: row;
+}
+
+.rtu_status_info_view_name{
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  height: 100%;
+  width: 40%;
+}
+
+.rtu_status_info_view_value{
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  height: 100%;
+  width: 60%;
+}
+
+.rtu_status_info_view_name text{
+   font-size: 26rpx;
+   color: #333333;
+   margin-left: 10rpx;
+}
+
+.rtu_status_info_view_value text{
+  font-size: 26rpx;
+  color: #FF9933;
+  width: 60%;
+}
+
+.shanshuo{
+  animation: twinkling 1s infinite ease-in-out;
+}
+
+@keyframes twinkling{
+  0% {opacity: 0; }
+  100% {opacity: 1; }
+}
+
+.blue-icon-button-hover {
+  opacity: 0.8;
+  background: #f7f7f7;
+}
+
+.connectBtn{
+  align-items: flex-end;
+}
+
+.bltImg{
+  width: 260rpx;
+  height: 260rpx;
+  margin-bottom: 20px;
+}
+
+.device-list-box{
+  width: 100%;
+  height: 99%;
+  background-color: white;
+  position: relative;
+  display: flex;
+  flex-direction: column;
+}
+
+.scanBtn{
+  background-color: #669999;
+  border-radius: 50rpx;
+  width: 300rpx;
+  margin-bottom: 8px;
+}
+
+.scanBtn-l{
+  background-color: #FD7400;
+  border-radius: 50px;
+  width: 300rpx;
+}
+
+.bluetooth-status-box{
+  margin-bottom: 10rpx;
+}
+
+.info_list_box{
+  width: 95%;
+  height: 95%;
+  background-color: #fff;
+  /* border-radius: 5px; */
+  position: relative;
+  display: flex;
+  flex-direction: column;
+  /* top: -22rpx; */
+}

+ 398 - 0
pages/bluetooth/clock/bluetoothClock.js

@@ -0,0 +1,398 @@
+const util = require("../../../utils/util");
+const datagramHelp = require("../../../utils/datagramHelp")
+var app = getApp();
+var task_timer;
+Page({
+  data: {
+    devices: {
+      deviceId: '',
+      serviceId: '',
+      characteristicId: '',
+      connectedBluetoothName: ''
+    },
+    rtuInfo: {
+      rtu_code: '',
+      ip1: '',
+      ip2: '',
+      ip3: '',
+      ip4: '',
+      rtu_work_model: '',
+      rtu_kind: '',
+      collect_interval: '',
+      water_level_base_point: '',
+      water_level_correct_point: '',
+      datagram_idx: '',
+      collect_time: '',
+      acc_rain: '',
+      fiveMinute_rain: '',
+      hour_rain: '',
+      weater_level: '',
+      power_v: '',
+      rtu_ver: '',
+      rtu_uuid: '',
+      bt_v: '',
+      rtu_rssi: '',
+      rtu_temperature: '',
+      lua_ver: ''
+    },
+    datagramBuff: '',
+    datagramCache: [],
+    trySendCount: 0,
+    datagramIndex: 0,
+    date: '',
+    time: '',
+    showSettingResult: false,
+    settingResultText: '操作已完成!'
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    console.log('bluebooth home page load ', '**********************************************')
+    let deviceId = options.deviceId;
+    let serviceId = options.serviceId;
+    let characteristicId = options.characteristicId;
+    let connectedBluetoothName = options.connectedBluetoothName;
+    console.log('name' + connectedBluetoothName)
+    let devices = {}
+    devices['deviceId'] = deviceId;
+    devices['serviceId'] = serviceId;
+    devices['characteristicId'] = characteristicId;
+    devices['connectedBluetoothName'] = connectedBluetoothName;
+    let time = util.getTime().substring(0, 5) + ":00";
+    let date = util.getDate();
+    this.setData({
+      devices: devices,
+      trySendCount: 0,
+      datagramIndex: 0,
+      time: time,
+      date: date
+    })
+    task_timer = undefined;
+    this.getRtuClock();
+
+    if (this.data.datagramCache.length > 0) {
+      let datagram = this.data.datagramCache[this.data.datagramIndex];
+      this.sendDatagramToRtu(datagram);
+      let index = this.data.datagramIndex + 1;
+      if (this.data.datagramCache.length == index) {
+        index = 0;
+      }
+      let count = this.data.trySendCount + 1;
+      this.setData({
+        datagramIndex: index,
+        trySendCount: count
+      })
+    }
+  },
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+    console.log('bluebooth clock page onHide ', '**********************************************')
+    this.cancelTime();
+  },
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+    console.log('bluebooth  clock onUnload ', '**********************************************')
+    this.cancelTime();
+  },
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    console.log('bluebooth  clock onShow ', '**********************************************')
+    this.timeCallback();
+  },
+  settingCompletTabEvent(e) {
+    this.setData({
+      showSettingResult: false
+    })
+    const btn = e.detail.index;
+    if (btn == 0) {
+      wx.navigateBack();
+    }
+  },
+  bindDateChange: function (e) {
+    console.log('picker发送选择改变,携带值为', e.detail.value)
+    this.setData({
+      date: e.detail.value
+    })
+  },
+  bindTimeChange: function (e) {
+    console.log('picker发送选择改变,携带值为', e.detail.value)
+    this.setData({
+      time: e.detail.value + ":00"
+    })
+  },
+  syncClockBtnTap: function () {
+    this.cancelTime();
+    let tm = util.getTimeStr();
+    console.log(tm)
+    this.setRtuClock(tm);
+  },
+  submitClockBtnTap: function () {
+    this.cancelTime();
+    let tm = this.data.date.substring(0, 4) + this.data.date.substring(5, 7) + this.data.date.substring(8, 10);
+    tm += this.data.time.substring(0, 2) + this.data.time.substring(3, 5) + this.data.time.substring(6, 8);
+    console.log(tm)
+    this.setRtuClock(tm);
+  },
+  getRtuClock() {
+    let datagram = datagramHelp.datagram_51();
+    let cache = this.data.datagramCache;
+    cache.push(datagram);
+
+
+  },
+  /**
+   * 设置时钟
+   * @param {时钟格式 yyyymmddhhmmss} clock 
+   */
+  setRtuClock(clock) {
+    let datagram = datagramHelp.datagram_4A(clock);
+    this.sendDatagramToRtu(datagram);
+  },
+  pushDatagramBuff(datagram) {
+    let tmpdatagramBuff = this.data.datagramBuff;
+    if (tmpdatagramBuff.length > 0) {
+      tmpdatagramBuff = tmpdatagramBuff + datagram;
+    } else {
+      tmpdatagramBuff = datagram;
+    }
+    console.log(" datagram buff ==========", tmpdatagramBuff)
+    this.setData({
+      datagramBuff: tmpdatagramBuff
+    })
+    this.processDatagram();
+  },
+  processDatagram() {
+    let datagram = this.data.datagramBuff;
+    if (datagram.length > 0) {
+      for (let i = 0; i < datagram.length; i++) {
+        if (datagram.indexOf("7e7e") == 0) {
+          break;
+        } else {
+          datagram = datagram.substring(i, datagram.length);
+        }
+      }
+      if (null != datagram && datagram.length > 0 && datagram.indexOf("7e7e") >= 0) {
+        if (datagram.length >= 26) {
+          var lenBuff = util.HexStr2Bytes(datagram.substring(22, 22 + 4));
+          var len = util.byteToUint16(lenBuff); // 报文长度(int)
+          var datagramlength = 11 + len + 6;
+          if (datagram.length >= datagramlength * 2) {
+            var onedatagram = datagram.substring(0, datagramlength * 2);
+            if (!datagramHelp.crcCheck(onedatagram)) {
+              wx.showToast({
+                title: '数据CRC校验错误,请重试!',
+                icon: 'none',
+                duration: 2000
+              })
+              this.setData({
+                datagramBuff: ''
+              })
+              return;
+            }
+            var count = 20;
+            var funcode = datagram.substring(count, count + 2);
+            count += 2;
+            if (funcode == "f6") {
+
+            } else if (funcode == "f7") {
+
+            } else if (funcode == '45') {
+
+            } else if (funcode == '47') {
+
+            } else if (funcode == '48') {
+
+            } else if (funcode == '41') {
+
+            } else if (funcode == '40') {
+
+            } else if (funcode == '43') {
+
+            } else if (funcode == '42') {
+
+            } else if (funcode == '4a') {
+              this.setData({
+                showSettingResult: true,
+                settingResultText: "时钟同步操作已完成!"
+              })
+              // wx.showToast({
+              //   title: '操作已完成!',
+              //   icon: 'ok',
+              //   duration: 2000 //持续的时间
+              // })
+            } else if (funcode == '51') {
+              var info = datagramHelp.datagram_51_analyse(onedatagram)
+              console.log(info)
+              let ct = info['collect_time'];
+              if (ct != undefined && ct.length > 0) {
+                let rtuInfo = this.data.rtuInfo;
+                rtuInfo['collect_time'] = ct;
+                this.setData({
+                  rtuInfo: rtuInfo
+                });
+              }
+              let index = this.data.datagramIndex + 1;
+              if (this.data.datagramCache.length == index) {
+                index = 0;
+              }
+              this.setData({
+                datagramIndex: index,
+                trySendCount: 0
+              })
+              this.cancelTime();
+            } else if (funcode == 'f3') {
+
+            }
+            if (datagram.length - datagramlength * 2 > 0) {
+              let tmp = datagram.substring(datagramlength * 2, datagram.length);
+              this.setData({
+                datagramBuff: tmp
+              })
+            }
+          } else {
+            this.setData({
+              datagramBuff: datagram
+            })
+          }
+        } else {
+          this.setData({
+            datagramBuff: datagram
+          })
+        }
+      } else {
+        if (null != datagram && datagram.length > 0) {
+          this.setData({
+            datagramBuff: datagram
+          })
+        } else {
+          this.setData({
+            datagramBuff: ''
+          })
+        }
+      }
+    }
+  },
+  sendDatagramToRtu(datagram) {
+    console.log("will send datagram " + datagram);
+    let buffer = util.HexStr2Bytes(datagram);
+    var that = this;
+    let count = 0;
+    let inView = new DataView(buffer);
+    while (true) {
+      if (buffer.byteLength - count > 20) {
+        let tmpBuff = new ArrayBuffer(20);
+        let outView = new DataView(tmpBuff);
+        for (let i = 0; i < 20; i++) {
+          outView.setUint8(i, inView.getUint8(count + i))
+        }
+        wx.writeBLECharacteristicValue({
+          deviceId: that.data.devices['deviceId'],
+          serviceId: that.data.devices['serviceId'],
+          characteristicId: that.data.devices['characteristicId'],
+          value: tmpBuff,
+          success(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+            wx.onBLECharacteristicValueChange((characteristic) => {
+              console.log("read datagram==============", util.ab2hex(characteristic.value))
+              var datagram = util.ab2hex(characteristic.value);
+              that.pushDatagramBuff(datagram);
+            })
+            wx.readBLECharacteristicValue({
+              deviceId: that.data.devices['deviceId'],
+              serviceId: that.data.devices['serviceId'],
+              characteristicId: that.data.devices['characteristicId'],
+              success: function (res) {
+                console.log('readBLECharacteristicValue')
+              }
+            })
+          },
+          fail(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+          }
+        })
+        count += 20;
+      } else {
+        let len = buffer.byteLength - count;
+        let tmpBuff = new ArrayBuffer(len);
+        let outView = new DataView(tmpBuff);
+        for (let i = 0; i < len; i++) {
+          outView.setUint8(i, inView.getUint8(count + i))
+        }
+        wx.writeBLECharacteristicValue({
+          deviceId: that.data.devices['deviceId'],
+          serviceId: that.data.devices['serviceId'],
+          characteristicId: that.data.devices['characteristicId'],
+          value: tmpBuff,
+          success(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+            wx.onBLECharacteristicValueChange((characteristic) => {
+              console.log("read datagram==============", util.ab2hex(characteristic.value))
+              var datagram = util.ab2hex(characteristic.value);
+              that.pushDatagramBuff(datagram);
+            })
+            wx.readBLECharacteristicValue({
+              deviceId: that.data.devices['deviceId'],
+              serviceId: that.data.devices['serviceId'],
+              characteristicId: that.data.devices['characteristicId'],
+              success: function (res) {
+                console.log('readBLECharacteristicValue')
+              }
+            })
+          },
+          fail(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+          }
+        })
+        count += len;
+      }
+      if (count >= buffer.byteLength) {
+        break;
+      }
+    }
+  },
+  timeCallback() {
+    var that = this;
+    task_timer = setTimeout(function () {
+      console.log("------------------------------------Time CallBack----------------------------");
+      if (that.data.trySendCount == 0) {
+        let datagram = that.data.datagramCache[that.data.datagramIndex];
+        that.sendDatagramToRtu(datagram);
+        let index = that.data.datagramIndex + 1;
+        if (that.data.datagramCache.length == index) {
+          index = 0;
+        }
+        let count = that.data.trySendCount + 1;
+        that.setData({
+          datagramIndex: index,
+          trySendCount: count
+        })
+      } else {
+        let count = that.data.trySendCount + 1;
+        if (count >= 10) {
+          count = 0;
+        }
+        that.setData({
+          trySendCount: count
+        })
+      }
+      that.timeCallback();
+    }, 3000);
+  },
+  cancelTime() {
+    if (task_timer != undefined) {
+      clearTimeout(task_timer);
+      task_timer = undefined;
+    }
+    this.setData({
+      datagramIndex: 0,
+      trySendCount: 0
+    })
+  }
+})

+ 6 - 0
pages/bluetooth/clock/bluetoothClock.json

@@ -0,0 +1,6 @@
+{
+  "navigationBarTitleText": "",
+  "usingComponents": {
+    "mp-dialog": "weui-miniprogram/dialog/dialog"
+  }
+}

+ 80 - 0
pages/bluetooth/clock/bluetoothClock.wxml

@@ -0,0 +1,80 @@
+<page>
+	<view class="body-content">
+		<view class="info_list_box">
+			<scroll-view class="info_list" scroll-y scroll-with-animation>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">RTU当前时钟</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										时钟:
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.collect_time}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">时钟同步方式一</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__title">
+									<button type="warn" bindtap="syncClockBtnTap">一键同步</button>
+								</view>
+								<view class="weui-media-box__desc info_text_line_center">
+									基于手机时间进行同步操作
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">时钟同步方式二</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="section">
+									<view class="section__title">时间</view>
+									<picker mode="time" value="{{time}}" bindchange="bindTimeChange">
+										<view class="picker datetime_font">
+											{{time}}
+										</view>
+									</picker>
+								</view>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="section">
+									<view class="section__title">日期</view>
+									<picker mode="date" value="{{date}}" bindchange="bindDateChange">
+										<view class="picker datetime_font">
+											{{date}}
+										</view>
+									</picker>
+								</view>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__title">
+									<button type="warn" bindtap="submitClockBtnTap">提交</button>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+			</scroll-view>
+		</view>
+	</view>
+	<mp-dialog title="操作提示" show="{{showSettingResult}}" bindbuttontap="settingCompletTabEvent"
+		buttons="{{[ {text: '确定'}]}}">
+		<view>{{settingResultText}}</view>
+	</mp-dialog>
+</page>

+ 55 - 0
pages/bluetooth/clock/bluetoothClock.wxss

@@ -0,0 +1,55 @@
+/* page {
+  height: 97%;
+} */
+
+
+
+.body-content{
+  width: 100%;
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+}
+
+.info_list_box{
+  width: 100%;
+  height: 100%;
+  position: relative;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+
+.info_list {
+  width: 98%;
+  height: 98%;
+  margin-top: 8px;
+  margin-bottom: 8px;
+}
+
+.info_text_line_inline{
+  width: 100%;
+  display: flex;
+  flex-direction: row;
+  align-items: flex-start;
+  color: black;
+}
+
+.info_text_line_inline_title{
+  width: 50%;
+}
+
+.info_text_line_inline_content{
+  width: 50%;
+  text-align: left;
+  color:#669999;
+  font-size: small;
+}
+
+.info_text_line_center{
+  text-align: center;
+}
+
+.datetime_font{
+  color:#669999;
+}

+ 564 - 0
pages/bluetooth/home/bluetoothHome.js

@@ -0,0 +1,564 @@
+const util = require("../../../utils/util");
+const datagramHelp = require("../../../utils/datagramHelp")
+var app = getApp();
+var task_timer;
+Page({
+  data: {
+    devices: {
+      deviceId: '',
+      serviceId: '',
+      characteristicId: '',
+      connectedBluetoothName: ''
+    },
+    deviceConnected: true,
+    statusInfo: {
+      rtu_code: '',
+      datagram_idx: '',
+      collect_time: '',
+      acc_rain: '',
+      fiveMinute_rain: '',
+      hour_rain: '',
+      weater_level: '',
+      power_v: '',
+      rtu_ver: '',
+      rtu_uuid: '',
+      bt_v: '',
+      rtu_rssi: '',
+      rtu_temperature: '',
+      lua_ver: ''
+    },
+    baseInfo: {
+      rtu_code: '',
+      ip1: '',
+      ip2: '',
+      ip3: '',
+      ip4: '',
+      rtu_work_model: '',
+      rtu_kind: '',
+      datagram_idx: '',
+      collect_time: ''
+    },
+    clockInfo: {
+      rtu_code: '',
+      datagram_idx: '',
+      collect_time: ''
+    },
+    runInfo: {
+      rtu_code: '',
+      datagram_idx: '',
+      collect_time: '',
+      collect_interval: '',
+      water_level_base_point: '',
+      water_level_correct_point: ''
+    },
+    datagramBuff: '',
+    datagramCache: [],
+    trySendCount: 0,
+    datagramIndex: 0,
+    rtu_kind_code: ['P', 'H', 'K', 'Z', 'D', 'T', 'M', 'G', 'Q', 'I', 'O'],
+    rtu_kind_name: ['P(降水)', 'H(河道)', 'K(水库/湖泊)', 'Z(闸坝)', 'D(泵站)', 'T(潮汐)', 'M(墒情)', 'G(地下水)', 'Q(水质)', 'I(取水口)', 'O(排水口)']
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    console.log('bluebooth main page load ', '**********************************************')
+    var that = this;
+    var deviceId = options.deviceId;
+    var serviceId = options.serviceId;
+    var characteristicId = options.characteristicId;
+    var connectedBluetoothName = options.connectedBluetoothName;
+
+    var devices = {}
+    devices['deviceId'] = deviceId;
+    devices['serviceId'] = serviceId;
+    devices['characteristicId'] = characteristicId;
+    devices['connectedBluetoothName'] = connectedBluetoothName;
+    this.setData({
+      devices: devices
+    })
+
+    wx.setNavigationBarTitle({
+      title: this.data.devices.name,
+    })
+    // if (null != deviceId && deviceId.length > 0 && null != serviceId && serviceId.length > 0 && null != characteristicId && characteristicId.length > //0) {
+    //   var devices = {}
+    //   devices['deviceId'] = deviceId;
+    //   devices['serviceId'] = serviceId;
+    //   devices['characteristicId'] = characteristicId;
+    //   devices['connectedBluetoothName'] = connectedBluetoothName;
+    //   this.setData({
+    //     devices: devices
+    //   })
+
+    // wx.setNavigationBarTitle({
+    //   title: this.data.devices.connectedBluetoothName,
+    // })
+
+    task_timer = undefined;
+    this.setData({
+      trySendCount: 0,
+      datagramIndex: 0
+    })
+    this.getRtuVersion();
+    this.getRtuBaseSetting();
+    this.getRtuRunSetting();
+
+    if (this.data.datagramCache.length > 0) {
+      let datagram = this.data.datagramCache[this.data.datagramIndex];
+      this.sendDatagramToRtu(datagram);
+      let index = this.data.datagramIndex + 1;
+      if (this.data.datagramCache.length == index) {
+        index = 0;
+      }
+      let count = this.data.trySendCount + 1;
+      this.setData({
+        datagramIndex: index,
+        trySendCount: count
+      })
+    }
+
+    // wx.onBLEConnectionStateChange(function (res) {
+    //   // 该方法回调中可以用于处理连接意外断开等异常情况
+    //   console.log(`device ${res.deviceId} state has changed, connected: ${res.connected}`)
+    //   if (res.deviceId == that.data.devices.deviceId) {
+    //     if (!res.connected) {
+    //       that.setData({
+    //         deviceConnected: false
+    //       })
+    //       wx.showToast({
+    //         title: '蓝牙连接断开',
+    //         icon: 'none',
+    //         duration: 2000
+    //       })
+    //     }
+    //   }
+    // })
+  },
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+    console.log('bluebooth main page onHide ', '**********************************************')
+    this.cancelTime();
+  },
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+    console.log('bluebooth main page  onUnload ', '**********************************************')
+    this.cancelTime();
+    this.closeBLEConnection();
+  },
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    console.log('bluebooth main page onShow ', '**********************************************')
+    this.timeCallback();
+  },
+  closeBLEConnection() {
+    if (this.data.devices.deviceId.length > 0) {
+      var id = this.data.devices.deviceId;
+      wx.closeBLEConnection({
+        deviceId: id,
+        success(res) {
+          console.log(res)
+        }
+      })
+    }
+  },
+  toRtuStatus: function () {
+    this.cancelTime();
+    wx.navigateTo({
+      url: '/pages/bluetooth/info/bluetoothInfo?connectedBluetoothName=' + this.data.devices.connectedBluetoothName + '&deviceId=' + this.data.devices.deviceId + '&serviceId=' + this.data.devices.serviceId + '&characteristicId=' + this.data.devices.characteristicId,
+    })
+  },
+  toRunSetting: function () {
+    this.cancelTime();
+    wx.navigateTo({
+      url: '/pages/bluetooth/runSetting/bluetoothRunSetting?connectedBluetoothName=' + this.data.devices.connectedBluetoothName + '&deviceId=' + this.data.devices.deviceId + '&serviceId=' + this.data.devices.serviceId + '&characteristicId=' + this.data.devices.characteristicId,
+    })
+  },
+  toBaseSetting: function () {
+    this.cancelTime();
+    wx.navigateTo({
+      url: '/pages/bluetooth/baseSetting/bluetoothBaseSetting?connectedBluetoothName=' + this.data.devices.connectedBluetoothName + '&deviceId=' + this.data.devices.deviceId + '&serviceId=' + this.data.devices.serviceId + '&characteristicId=' + this.data.devices.characteristicId,
+    })
+  },
+  toClockSetting: function () {
+    this.cancelTime();
+    wx.navigateTo({
+      url: '/pages/bluetooth/clock/bluetoothClock?connectedBluetoothName=' + this.data.devices.connectedBluetoothName + '&deviceId=' + this.data.devices.deviceId + '&serviceId=' + this.data.devices.serviceId + '&characteristicId=' + this.data.devices.characteristicId,
+    })
+  },
+  getRtuVersion() {
+    let datagram = datagramHelp.datagram_45();
+    let cache = this.data.datagramCache;
+    cache.push(datagram);
+  },
+  getRtuStatus() {
+    var datagram = datagramHelp.datagram_f7();
+    let cache = this.data.datagramCache;
+    cache.push(datagram);
+  },
+  getRtuClock() {
+    let datagram = datagramHelp.datagram_51();
+    let cache = this.data.datagramCache;
+    cache.push(datagram);
+  },
+  getRtuBaseSetting() {
+    let datagram = datagramHelp.datagram_41();
+    let cache = this.data.datagramCache;
+    cache.push(datagram);
+  },
+  getRtuRunSetting() {
+    let datagram = datagramHelp.datagram_43();
+    let cache = this.data.datagramCache;
+    cache.push(datagram);
+  },
+  pushDatagramBuff(datagram) {
+    let tmpdatagramBuff = this.data.datagramBuff;
+    if (tmpdatagramBuff.length > 0) {
+      tmpdatagramBuff = tmpdatagramBuff + datagram;
+    } else {
+      tmpdatagramBuff = datagram;
+    }
+    this.setData({
+      datagramBuff: tmpdatagramBuff
+    })
+    this.processDatagram();
+
+    this.setData({
+      trySendCount: 0
+    })
+  },
+  processDatagram() {
+    let datagram = this.data.datagramBuff;
+    if (datagram.length > 0) {
+      for (let i = 0; i < datagram.length; i++) {
+        if (datagram.indexOf("7e7e") == 0) {
+          break;
+        } else {
+          datagram = datagram.substring(i, datagram.length);
+        }
+      }
+      if (null != datagram && datagram.length > 0 && datagram.indexOf("7e7e") >= 0) {
+        if (datagram.length >= 26) {
+          var lenBuff = util.HexStr2Bytes(datagram.substring(22, 22 + 4));
+          var len = util.byteToUint16(lenBuff); // 报文长度(int)
+          var datagramlength = 11 + len + 6;
+          if (datagram.length >= datagramlength * 2) {
+            var onedatagram = datagram.substring(0, datagramlength * 2);
+            if (!datagramHelp.crcCheck(onedatagram)) {
+              wx.showToast({
+                title: '数据CRC校验错误,请重试!',
+                icon: 'none',
+                duration: 2000
+              })
+              this.setData({
+                datagramBuff: ''
+              })
+              return;
+            }
+            var count = 20;
+            var funcode = datagram.substring(count, count + 2);
+            count += 2;
+            if (funcode == "f6") {
+              let info = datagramHelp.datagram_f6_analyse(onedatagram)
+              console.log(info)
+            } else if (funcode == "f7") {
+              let info = datagramHelp.datagram_f7_analyse(onedatagram)
+              console.log(info)
+            } else if (funcode == '45') {
+              let info = datagramHelp.datagram_45_analyse(onedatagram)
+              console.log(info)
+              let ver = info['rtu_ver'];
+              if (ver != undefined && ver.length > 0) {
+                let statusInfo = this.data.statusInfo;
+                statusInfo['rtu_ver'] = ver;
+                this.setData({
+                  statusInfo: statusInfo
+                });
+              }
+              let ct = info['collect_time'];
+              if (ct != undefined && ct.length > 0) {
+                let clockInfo = this.data.clockInfo;
+                clockInfo['collect_time'] = ct;
+                this.setData({
+                  clockInfo: clockInfo
+                });
+              }
+            } else if (funcode == '47') {
+              var info = datagramHelp.datagram_47_analyse(onedatagram)
+              console.log(info)
+            } else if (funcode == '48') {
+              var info = datagramHelp.datagram_48_analyse(onedatagram)
+              console.log(info)
+            } else if (funcode == '41') {
+              var info = datagramHelp.datagram_41_analyse(onedatagram)
+              console.log(info)
+              var baseInfo = this.data.baseInfo;
+              let rtuCode = info['rtu_code'];
+              baseInfo['rtu_code'] = rtuCode;
+              let ip1 = info['ip1'];
+              if (ip1 != undefined && ip1.length > 0) {
+                // ip1 = ip1 + ":" + info['ip1_port'];
+              } else {
+                ip1 = "";
+              }
+              let ip2 = info['ip2'];
+              if (ip2 != undefined && ip2.length > 0) {
+                // ip2 = ip2 + ":" + info['ip2_port'];
+              } else {
+                ip2 = "";
+              }
+              let ip3 = info['ip3'];
+              if (ip3 != undefined && ip3.length > 0) {
+                // ip3 = ip3 + ":" + info['ip3_port'];
+              } else {
+                ip3 = "";
+              }
+              let ip4 = info['ip4'];
+              if (ip4 != undefined && ip4.length > 0) {
+                // ip4 = ip4 + ":" + info['ip4_port'];
+              } else {
+                ip4 = "";
+              }
+              baseInfo['ip1'] = ip1;
+              baseInfo['ip2'] = ip2;
+              baseInfo['ip3'] = ip3;
+              baseInfo['ip4'] = ip4;
+              let workModel = info['rtu_work_model'];
+              if (workModel == "0") {
+                baseInfo['rtu_work_model'] = "低功耗";
+              } else {
+                baseInfo['rtu_work_model'] = "永在线";
+              }
+              let rtuKind = info['rtu_kind'];
+              for (let i = 0; i < this.data.rtu_kind_code.length; i++) {
+                let code = this.data.rtu_kind_code[i];
+                if (code == rtuKind) {
+                  baseInfo['rtu_kind'] = this.data.rtu_kind_name[i];
+                  break;
+                }
+              }
+              this.setData({
+                baseInfo: baseInfo
+              });
+            } else if (funcode == '40') {
+              var info = datagramHelp.datagram_40_analyse(onedatagram)
+              console.log(info)
+            } else if (funcode == '43') {
+              var info = datagramHelp.datagram_43_analyse(onedatagram)
+              console.log(info)
+              let intervalTime = info['intervalTime'];
+              let intervalTimeText = "";
+              if (intervalTime == "5") {
+                intervalTimeText = "5分钟";
+              } else if (intervalTime == "60") {
+                intervalTimeText = "1小时";
+              } else if (intervalTime == "120") {
+                intervalTimeText = "2小时";
+              } else if (intervalTime == "180") {
+                intervalTimeText = "3小时";
+              } else if (intervalTime == "240") {
+                intervalTimeText = "4小时";
+              } else if (intervalTime == "360") {
+                intervalTimeText = "6小时";
+              } else if (intervalTime == "480") {
+                intervalTimeText = "8小时";
+              } else if (intervalTime == "720") {
+                intervalTimeText = "12小时";
+              } else if (intervalTime == "1440") {
+                intervalTimeText = "24小时";
+              }
+              let runInfo = this.data.runInfo;
+              runInfo['collect_interval'] = intervalTimeText;
+              runInfo['water_level_base_point'] = info['water_level_base_point'];
+              runInfo['water_level_correct_point'] = info['water_level_correct_point'];
+              this.setData({
+                runInfo: runInfo
+              });
+            } else if (funcode == '42') {
+              var info = datagramHelp.datagram_42_analyse(onedatagram)
+              console.log(info)
+            } else if (funcode == '4A') {
+              var info = datagramHelp.datagram_4A_analyse(onedatagram)
+              console.log(info)
+            } else if (funcode == '51') {
+              var info = datagramHelp.datagram_51_analyse(onedatagram)
+              console.log(info)
+              let ct = info['collect_time'];
+              if (ct != undefined && ct.length > 0) {
+                let clockInfo = this.data.clockInfo;
+                clockInfo['collect_time'] = ct;
+                this.setData({
+                  clockInfo: clockInfo
+                });
+              }
+            } else if (funcode == 'f3') {
+              var info = datagramHelp.datagram_f3_analyse(onedatagram)
+              console.log(info)
+            }
+            if (datagram.length - datagramlength * 2 > 0) {
+              let tmp = datagram.substring(datagramlength * 2, datagram.length);
+              this.setData({
+                datagramBuff: tmp
+              })
+            } else {
+              this.setData({
+                datagramBuff: ""
+              })
+            }
+          } else {
+            this.setData({
+              datagramBuff: datagram
+            })
+          }
+        } else {
+          this.setData({
+            datagramBuff: datagram
+          })
+        }
+      } else {
+        if (null != datagram && datagram.length > 0) {
+          this.setData({
+            datagramBuff: datagram
+          })
+        } else {
+          this.setData({
+            datagramBuff: ''
+          })
+        }
+      }
+    }
+  },
+  sendDatagramToRtu(datagram) {
+    console.log("will send datagram " + datagram);
+    let buffer = util.HexStr2Bytes(datagram);
+    var that = this;
+    let count = 0;
+    let inView = new DataView(buffer);
+    while (true) {
+      if (buffer.byteLength - count > 20) {
+        let tmpBuff = new ArrayBuffer(20);
+        let outView = new DataView(tmpBuff);
+        for (let i = 0; i < 20; i++) {
+          outView.setUint8(i, inView.getUint8(count + i))
+        }
+        wx.writeBLECharacteristicValue({
+          deviceId: that.data.devices['deviceId'],
+          serviceId: that.data.devices['serviceId'],
+          characteristicId: that.data.devices['characteristicId'],
+          value: tmpBuff,
+          success(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+            wx.onBLECharacteristicValueChange((characteristic) => {
+              console.log("read datagram==============", util.ab2hex(characteristic.value))
+              var datagram = util.ab2hex(characteristic.value);
+              that.pushDatagramBuff(datagram);
+            })
+            wx.readBLECharacteristicValue({
+              deviceId: that.data.devices['deviceId'],
+              serviceId: that.data.devices['serviceId'],
+              characteristicId: that.data.devices['characteristicId'],
+              success: function (res) {
+                console.log('readBLECharacteristicValue')
+              }
+            })
+          },
+          fail(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+          }
+        })
+        count += 20;
+      } else {
+        let len = buffer.byteLength - count;
+        let tmpBuff = new ArrayBuffer(len);
+        let outView = new DataView(tmpBuff);
+        for (let i = 0; i < len; i++) {
+          outView.setUint8(i, inView.getUint8(count + i))
+        }
+        wx.writeBLECharacteristicValue({
+          deviceId: that.data.devices['deviceId'],
+          serviceId: that.data.devices['serviceId'],
+          characteristicId: that.data.devices['characteristicId'],
+          value: tmpBuff,
+          success(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+            wx.onBLECharacteristicValueChange((characteristic) => {
+              console.log("read datagram==============", util.ab2hex(characteristic.value))
+              var datagram = util.ab2hex(characteristic.value);
+              that.pushDatagramBuff(datagram);
+            })
+            wx.readBLECharacteristicValue({
+              deviceId: that.data.devices['deviceId'],
+              serviceId: that.data.devices['serviceId'],
+              characteristicId: that.data.devices['characteristicId'],
+              success: function (res) {
+                console.log('readBLECharacteristicValue')
+              }
+            })
+          },
+          fail(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+          }
+        })
+        count += len;
+      }
+      if (count >= buffer.byteLength) {
+        wx.readBLECharacteristicValue({
+          deviceId: that.data.devices['deviceId'],
+          serviceId: that.data.devices['serviceId'],
+          characteristicId: that.data.devices['characteristicId'],
+          success: function (res) {
+            console.log('readBLECharacteristicValue')
+          }
+        })
+        break;
+      }
+    }
+  },
+  timeCallback() {
+    let that = this;
+    task_timer = setTimeout(function () {
+      console.log("------------------------------------Time CallBack----------------------------");
+      if (that.data.trySendCount == 0) {
+        console.log("index " + that.data.datagramIndex);
+        let datagram = that.data.datagramCache[that.data.datagramIndex];
+        that.sendDatagramToRtu(datagram);
+        if (that.data.datagramCache.length == that.data.datagramIndex + 1) {
+          that.setData({
+            datagramIndex: 0,
+            trySendCount: 1
+          })
+        } else {
+          that.setData({
+            datagramIndex: that.data.datagramIndex + 1,
+            trySendCount: 1
+          })
+        }
+      } else {
+        let count = that.data.trySendCount + 1;
+        if (count >= 4) {
+          count = 0;
+        }
+        that.setData({
+          trySendCount: count
+        })
+      }
+      that.timeCallback();
+    }, 3000);
+  },
+  cancelTime() {
+    if (task_timer != undefined) {
+      clearTimeout(task_timer);
+      task_timer = undefined;
+    }
+    this.setData({
+      datagramIndex: 0,
+      trySendCount: 0
+    })
+  }
+})

+ 6 - 0
pages/bluetooth/home/bluetoothHome.json

@@ -0,0 +1,6 @@
+{
+  "navigationBarTitleText": "",
+  "usingComponents": {
+    "mp-dialog": "weui-miniprogram/dialog/dialog"
+  }
+}

+ 222 - 0
pages/bluetooth/home/bluetoothHome.wxml

@@ -0,0 +1,222 @@
+<page>
+	<view class="page-body">
+		<view class="body-toolBar">
+			<view class="connected_devices_info">
+				<view class="connected-devices-info-image">
+					<text style="font-size:26rpx; color:#7b7b7b">已连接设备:</text>
+					<text style="font-size:34rpx; color: #426666; font-weight: bold;">{{devices.connectedBluetoothName}}</text>
+				</view>
+			</view>
+		</view>
+		<view class="body-content">
+			<view class="info_list_box">
+				<scroll-view class="scroll_info_list" scroll-y scroll-with-animation>
+					<view class="weui-panel weui-panel_access">
+						<view class="weui-panel__hd">RTU实时状态</view>
+						<view class="weui-panel__bd">
+							<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+								<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+									<view class="weui-media-box__desc rtu_baseinfo_text_line">
+										<view class="rtu_baseinfo_text_line_title">
+											版本号:
+										</view>
+										<view class="rtu_baseinfo_text_line_content">
+											{{statusInfo.rtu_ver}}
+										</view>
+									</view>
+								</view>
+							</navigator>
+						</view>
+						<view class="weui-panel__ft">
+							<view class="weui-cell weui-cell_access weui-cell_link" bindtap="toRtuStatus">
+								<view class="weui-cell__bd text_right_point">更多</view>
+								<view class="weui-cell__ft weui-cell__ft_in-access"></view>
+							</view>
+						</view>
+					</view>
+					<view class="weui-panel weui-panel_access">
+						<view class="weui-panel__hd">RTU时钟</view>
+						<view class="weui-panel__bd">
+							<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+								<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+									<view class="weui-media-box__desc rtu_baseinfo_text_line">
+										<view class="rtu_baseinfo_text_line_title">
+											当前时钟:
+										</view>
+										<view class="rtu_baseinfo_text_line_content">
+											{{clockInfo.collect_time}}
+										</view>
+									</view>
+								</view>
+							</navigator>
+						</view>
+						<view class="weui-panel__ft">
+							<view class="weui-cell weui-cell_access weui-cell_link" bindtap="toClockSetting">
+								<view class="weui-cell__bd text_right_point">设置</view>
+								<view class="weui-cell__ft weui-cell__ft_in-access"></view>
+							</view>
+						</view>
+					</view>
+					<view class="weui-panel weui-panel_access">
+						<view class="weui-panel__hd">基本参数</view>
+						<view class="weui-panel__bd">
+							<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+								<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+									<view class="weui-media-box__desc rtu_baseinfo_text_line">
+										<view class="rtu_baseinfo_text_line_title">
+											测站编码:
+										</view>
+										<view class="rtu_baseinfo_text_line_content">
+											{{baseInfo.rtu_code}}
+										</view>
+									</view>
+								</view>
+							</navigator>
+							<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+								<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+									<view class="weui-media-box__desc rtu_baseinfo_text_line">
+										<view class="ip_line_title">
+											IP1:
+										</view>
+										<view class="ip_line_content">
+											{{baseInfo.ip1}}
+										</view>
+									</view>
+								</view>
+							</navigator>
+							<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+								<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+									<view class="weui-media-box__desc rtu_baseinfo_text_line">
+										<view class="ip_line_title">
+											IP2:
+										</view>
+										<view class="ip_line_content">
+											{{baseInfo.ip2}}
+										</view>
+									</view>
+								</view>
+							</navigator>
+							<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+								<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+									<view class="weui-media-box__desc rtu_baseinfo_text_line">
+										<view class="ip_line_title">
+											IP3:
+										</view>
+										<view class="ip_line_content">
+											{{baseInfo.ip3}}
+										</view>
+									</view>
+								</view>
+							</navigator>
+							<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+								<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+									<view class="weui-media-box__desc rtu_baseinfo_text_line">
+										<view class="ip_line_title">
+											IP4:
+										</view>
+										<view class="ip_line_content">
+											{{baseInfo.ip4}}
+										</view>
+									</view>
+								</view>
+							</navigator>
+							<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+								<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+									<view class="weui-media-box__desc rtu_baseinfo_text_line">
+										<view class="rtu_baseinfo_text_line_title">
+											工作模式:
+										</view>
+										<view class="rtu_baseinfo_text_line_content">
+											{{baseInfo.rtu_work_model}}
+										</view>
+									</view>
+								</view>
+							</navigator>
+							<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+								<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+									<view class="weui-media-box__desc rtu_kind_text_line">
+										<view class="rtu_kind_text_line_title">
+											遥测站分类码:
+										</view>
+										<view class="rtu_kind_text_line_content">
+											{{baseInfo.rtu_kind}}
+										</view>
+										<!-- <view class="rtu_kind_text_line_desc">
+											?
+										</view> -->
+									</view>
+								</view>
+							</navigator>
+						</view>
+						<view class="weui-panel__ft">
+							<view class="weui-cell weui-cell_access weui-cell_link" bindtap="toBaseSetting"> 
+								<view class="weui-cell__bd text_right_point">设置</view>
+								<view class="weui-cell__ft weui-cell__ft_in-access"></view>
+							</view>
+						</view>
+					</view>
+					<view class="weui-panel weui-panel_access">
+						<view class="weui-panel__hd">运行参数</view>
+						<view class="weui-panel__bd">
+							<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+								<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+									<view class="weui-media-box__desc rtu_baseinfo_text_line">
+										<view class="rtu_baseinfo_text_line_title">
+											定时报时间间隔:
+										</view>
+										<view class="rtu_baseinfo_text_line_content">
+											{{runInfo.collect_interval}}
+										</view>
+									</view>
+								</view>
+							</navigator>
+							<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+								<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+									<view class="weui-media-box__desc rtu_baseinfo_text_line">
+										<view class="rtu_baseinfo_text_line_title">
+											水位基值:
+										</view>
+										<view class="rtu_baseinfo_text_line_content">
+											{{runInfo.water_level_base_point}}
+										</view>
+									</view>
+								</view>
+							</navigator>
+							<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+								<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+									<view class="weui-media-box__desc rtu_baseinfo_text_line">
+										<view class="rtu_baseinfo_text_line_title">
+											水位修正值:
+										</view>
+										<view class="rtu_baseinfo_text_line_content">
+											{{runInfo.water_level_correct_point}}
+										</view>
+									</view>
+								</view>
+							</navigator>
+						</view>
+						<view class="weui-panel__ft">
+							<view class="weui-cell weui-cell_access weui-cell_link" bindtap="toRunSetting">
+								<view class="weui-cell__bd text_right_point">设置</view>
+								<view class="weui-cell__ft weui-cell__ft_in-access"></view>
+							</view>
+						</view>
+					</view>
+				</scroll-view>
+			</view>
+		</view>
+	</view>
+	<!-- <view class="rtuMsgBox">
+		<view class="rtuMsg-container">
+			<view class="rtuMsg">
+				<view class="info_list_box">
+					<scroll-view class="info_list" scroll-y scroll-with-animation>
+						<text>RTU信息</text>
+					</scroll-view>
+				</view>
+			</view>
+		</view>
+		<view class="settingBox"></view>
+	</view> -->
+
+</page>

+ 406 - 0
pages/bluetooth/home/bluetoothHome.wxss

@@ -0,0 +1,406 @@
+/* page {
+  height: 97%;
+} */
+
+/* .page-bluebooth-list{
+  width: 100%;
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+} */
+
+.page-body{
+  width: 100%;
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+}
+
+ .body-toolBar{
+  width:100%;
+  height: 10%;
+  /* background-color: #426666; */
+  /* background-color: purple; */
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+} 
+
+.body-content{
+  width: 100%;
+  height: 90%;
+  /* background-color: green; */
+  /* display: flex; */
+  /* justify-content: center; */
+  /* flex-direction: column;
+  align-items: center; */
+}
+
+.info_list_box{
+  width: 100%;
+  height: 100%;
+  /* background-color: red; */
+  /* border-radius: 5px; */
+  position: relative;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  /* top: -22rpx; */
+  
+}
+
+.scroll_info_list {
+  /* margin: 50px 5px;
+  
+  border: 1px solid #EEE;
+  border-radius: 5px;
+  width: auto;  */
+  width: 98%;
+  height: 99%;
+  margin-top: 8px;
+  /* background-color: blueviolet; */
+  /* height: 90%;
+  background-color: #fff;
+  border-radius: 5px;
+  position: relative;
+  display: flex;
+  flex-direction: column;
+  align-items: center;  */
+}
+
+/* button{
+  margin-top: 30rpx;
+  margin-bottom: 10rpx;
+  margin-left: 20rpx;
+  margin-right: 20rpx;
+} */
+
+
+.button-sp-area{
+  margin: 0 auto;
+  width: 60%;
+}
+
+.mini-btn{
+  margin-right: 10rpx;
+}
+
+.devices_summary {
+  margin-top: 8px;
+  padding-left: 20rpx;
+  /* background-color: #EEEEEE; */
+  width: 100%;
+  height:60rpx;
+  align-items: center;
+}
+
+.devices_summary text{
+  font-size: 30rpx;
+  color:  #7b7b7b;
+  margin-left: 5px;
+}
+
+.connected_devices_info{
+  /* margin-top: 0px;
+  padding-left: 20rpx; */
+  background-color: #ffffff;
+  width: 100%;
+  height:100%;
+  display: flex;
+  flex-direction: column;
+  /* border-radius: 5px; */
+  position: relative;
+  /* top: -30px; */
+  border-bottom: 1px #dddddd solid;
+
+}
+
+/* .connected_devices_info text{
+  font-size: 26rpx;
+  color:  #444444;
+} */
+
+.device_list {
+  
+  
+  width: 90%;
+  height: auto;
+  /* border: 1px solid #EEE; */
+  /* border-radius: 5px; */
+  
+}
+
+
+
+.device_item {
+  /* border-bottom: 1px gray solid; */
+  margin-left: 10rpx;
+  margin-right: 10rpx;
+  margin-top:10rpx;
+  margin-bottom:10rpx;
+  /* color: #666; */
+}
+.device_item_hover {
+  background-color: rgba(0, 0, 0, .1);
+}
+
+.bluebooth-status-line{
+  height:50rpx;
+  width: 100%;
+  display: flex;
+  flex-direction: row;
+}
+
+.connected-devices-info-name{
+  height:100%;
+  /* padding-left: 10rpx; */
+  width: 90%;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  margin-left: 8px;
+  margin-bottom: 5px;
+  
+}
+
+.connected-devices-info-name text{
+  color: #181818;
+  font-size: 32rpx;
+}
+
+.bluebooth-status-name-view{
+  height:100%;
+  padding-left: 10rpx;
+  width: 90%;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+}
+
+.bluebooth-status-name-view text{
+  color: #181818;
+  font-size: 30rpx;
+}
+
+
+.connected-devices-info-image{
+  height:100%;
+  align-items: center;
+  margin-left: 8px;
+  margin-top: 8px;
+  /* width: 10%; */
+}
+
+/* .connected-devices-info-image image{
+  width: 40rpx;
+  height: 40rpx;
+  margin-left: 10rpx;
+  margin-top:5rpx;
+} */
+
+.bluebooth-status-image-view{
+  height:100%;
+  align-items: center;
+  width: 10%;
+}
+
+.bluebooth-status-image-view image{
+  width: 40rpx;
+  height: 40rpx;
+  margin-left: 10rpx;
+  margin-top:5rpx;
+  /* margin-right: 10rpx;
+  margin-left: 10rpx;
+  margin-top:5rpx; */
+}
+
+.bluebooth-status-info-sub{
+  height:40rpx;
+  align-items: center;
+  padding-left: 10rpx;
+  width: 100%;
+}
+
+.bluebooth-status-info-sub text{
+  font-size: 24rpx;
+  color: #acacac;
+}
+
+.bluebooth-process-btn{
+  display: flex;
+  flex-direction: row;
+  justify-content: flex-end;
+}
+
+.connected_info {
+  position: fixed;
+  bottom: 0;
+  width: 100%;
+  background-color: #F0F0F0;
+  padding: 10px;
+  padding-bottom: 20px;
+  margin-bottom: env(safe-area-inset-bottom);
+  font-size: 14px;
+  min-height: 100px;
+  box-shadow: 0px 0px 3px 0px;
+}
+.connected_info .operation {
+  position: absolute;
+  display: inline-block;
+  right: 30px;
+}
+
+.rtu_status_line_white{
+  /* background-color: whitesmoke; */
+  height: 60rpx;
+  display: flex;
+  flex-direction: row;
+}
+
+.rtu_status_line_grey{
+  /* background-color: #EEEEEE; */
+  height: 60rpx;
+  display: flex;
+  flex-direction: row;
+}
+
+.rtu_status_info_view_name{
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  height: 100%;
+  width: 40%;
+}
+
+.rtu_status_info_view_value{
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  height: 100%;
+  width: 60%;
+}
+
+.rtu_status_info_view_name text{
+   font-size: 26rpx;
+   color: #333333;
+   margin-left: 10rpx;
+}
+
+.rtu_status_info_view_value text{
+  font-size: 26rpx;
+  color: #FF9933;
+  width: 60%;
+}
+
+.shanshuo{
+  animation: twinkling 1s infinite ease-in-out;
+}
+
+@keyframes twinkling{
+  0% {opacity: 0; }
+  100% {opacity: 1; }
+}
+
+.blue-icon-button-hover {
+  opacity: 0.8;
+  background: #f7f7f7;
+}
+
+.bltImg{
+  width: 260rpx;
+  height: 260rpx;
+  margin-bottom: 20px;
+}
+
+.device-list-box{
+  width: 100%;
+  height: 100%;
+  background-color: white;
+  /* border-radius: 5px; */
+  position: relative;
+  /* top: -45px; */
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+
+}
+
+.scanBtn{
+  background-color: #669999;
+  border-radius: 50px;
+  width: 300rpx;
+  margin-bottom: 8px;
+  
+}
+
+.scanBtn-l{
+  background-color: #FD7400;
+  border-radius: 50px;
+  width: 300rpx;
+}
+
+.bluetooth-status-box{
+  margin-bottom: 10rpx;
+}
+
+.text_right_point{
+  text-align: right;
+}
+
+
+
+.rtu_baseinfo_text_line{
+  width: 100%;
+  display: flex;
+  flex-direction: row;
+  align-items: flex-start;
+  color: black;
+}
+
+.ip_line_title{
+  width: 10%;  
+}
+
+.ip_line_content{
+  width: 89%;
+  text-align: left;
+  color:#669999;
+  font-size: small;
+}
+
+.rtu_baseinfo_text_line_title{
+  width: 50%;
+}
+
+.rtu_baseinfo_text_line_content{
+  width: 50%;
+  text-align: left;
+  color:#669999;
+  font-size: small;
+}
+
+.rtu_kind_text_line{
+ width: 100%;
+ display: flex;
+ flex-direction: row;
+ align-items: flex-start;
+ color: black;
+}
+
+.rtu_kind_text_line_title{
+  width: 50%;
+}
+
+.rtu_kind_text_line_content{
+  width: 40%;
+  text-align: left;
+  color:#669999;
+  font-size: small;
+}
+
+.rtu_kind_text_line_desc{
+  width: 10%;
+  text-align: center;
+  color:#669999;
+  font-size: small;
+}

+ 417 - 0
pages/bluetooth/info/bluetoothInfo.js

@@ -0,0 +1,417 @@
+const util = require("../../../utils/util");
+const datagramHelp = require("../../../utils/datagramHelp")
+var app = getApp();
+var task_timer;
+Page({
+  data: {
+    devices: {
+      deviceId: '',
+      serviceId: '',
+      characteristicId: '',
+      connectedBluetoothName: ''
+    },
+    rtuInfo: {
+      rtu_code: '',
+      ip1: '',
+      ip2: '',
+      ip3: '',
+      ip4: '',
+      rtu_work_model: '',
+      rtu_kind: '',
+      collect_interval: '',
+      water_level_base_point: '',
+      water_level_correct_point: '',
+      datagram_idx: '',
+      collect_time: '',
+      acc_rain: '',
+      fiveMinute_rain: '',
+      hour_rain: '',
+      weater_level: '',
+      power_v: '',
+      rtu_ver: '',
+      rtu_uuid: '',
+      bt_v: '',
+      rtu_rssi: '',
+      rtu_temperature: '',
+      lua_ver: ''
+    },
+    datagramBuff: '',
+    datagramCache: [],
+    trySendCount: 0,
+    datagramIndex: 0,
+    showSettingResult: false,
+    settingResultText: '操作已完成!'
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    console.log('bluebooth info page load ', '**********************************************')
+    let deviceId = options.deviceId;
+    let serviceId = options.serviceId;
+    let characteristicId = options.characteristicId;
+    let connectedBluetoothName = options.connectedBluetoothName;
+    console.log('name' + connectedBluetoothName)
+    let devices = {}
+    devices['deviceId'] = deviceId;
+    devices['serviceId'] = serviceId;
+    devices['characteristicId'] = characteristicId;
+    devices['connectedBluetoothName'] = connectedBluetoothName;
+    this.setData({
+      devices: devices,
+      trySendCount: 0,
+      datagramIndex: 0
+    })
+    task_timer = undefined;
+    this.getRtuStatus();
+
+    if (this.data.datagramCache.length > 0) {
+      let datagram = this.data.datagramCache[this.data.datagramIndex];
+      this.sendDatagramToRtu(datagram);
+      let index = this.data.datagramIndex + 1;
+      if (this.data.datagramCache.length == index) {
+        index = 0;
+      }
+      let count = this.data.trySendCount + 1;
+      this.setData({
+        datagramIndex: index,
+        trySendCount: count
+      })
+    }
+  },
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+    console.log('bluebooth info page onHide ', '**********************************************');
+    this.cancelTime();
+  },
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+    console.log('bluebooth info page onUnload ', '**********************************************');
+    this.cancelTime();
+  },
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    console.log('bluebooth info page onShow ', '**********************************************');
+    this.timeCallback();
+  },
+  settingCompletTabEvent(e) {
+    this.setData({
+      showSettingResult: false
+    })
+    const btn = e.detail.index;
+    if (btn == 0) {
+      wx.navigateBack();
+    }
+  },
+  resetMemryBtnTap: function () {
+    this.cancelTime();
+    this.formatRtuMemory();
+  },
+  resetRtuBtnTap: function () {
+    this.cancelTime();
+    this.resetRtu();
+  },
+  rebootBtnTap: function () {
+    this.cancelTime();
+    this.rebootRtu();
+  },
+  /**
+   * 发送查询RTU状态信息的指令
+   */
+  getRtuStatus() {
+    var datagram = datagramHelp.datagram_f7();
+    let cache = this.data.datagramCache;
+    cache.push(datagram);
+  },
+  rebootRtu() {
+    let datagram = datagramHelp.datagram_f3();
+    this.sendDatagramToRtu(datagram);
+  },
+  /**
+   * 恢复RTU出厂设置
+   */
+  resetRtu() {
+    let datagram = datagramHelp.datagram_48();
+    this.sendDatagramToRtu(datagram);
+  },
+  /**
+   * 格式化RTU存储器
+   */
+  formatRtuMemory() {
+    let datagram = datagramHelp.datagram_47();
+    this.sendDatagramToRtu(datagram);
+  },
+  pushDatagramBuff(datagram) {
+    let tmpdatagramBuff = this.data.datagramBuff;
+    if (tmpdatagramBuff.length > 0) {
+      tmpdatagramBuff = tmpdatagramBuff + datagram;
+    } else {
+      tmpdatagramBuff = datagram;
+    }
+    console.log(" datagram buff ==========", tmpdatagramBuff)
+    this.setData({
+      datagramBuff: tmpdatagramBuff
+    })
+    this.processDatagram();
+  },
+  processDatagram() {
+    let datagram = this.data.datagramBuff;
+    if (datagram.length > 0) {
+      for (let i = 0; i < datagram.length; i++) {
+        if (datagram.indexOf("7e7e") == 0) {
+          break;
+        } else {
+          datagram = datagram.substring(i, datagram.length);
+        }
+      }
+      if (null != datagram && datagram.length > 0 && datagram.indexOf("7e7e") >= 0) {
+        if (datagram.length >= 26) {
+          var lenBuff = util.HexStr2Bytes(datagram.substring(22, 22 + 4));
+          var len = util.byteToUint16(lenBuff); // 报文长度(int)
+          var datagramlength = 11 + len + 6;
+          if (datagram.length >= datagramlength * 2) {
+            var onedatagram = datagram.substring(0, datagramlength * 2);
+            if (!datagramHelp.crcCheck(onedatagram)) {
+              wx.showToast({
+                title: '数据CRC校验错误,请重试!',
+                icon: 'none',
+                duration: 2000
+              })
+              this.setData({
+                datagramBuff: ''
+              })
+              return;
+            }
+            var count = 20;
+            var funcode = datagram.substring(count, count + 2);
+            count += 2;
+            if (funcode == "f6") {
+
+            } else if (funcode == "f7") {
+              let info = datagramHelp.datagram_f7_analyse(onedatagram)
+              console.log(info)
+              let rtuInfo = this.data.rtuInfo;
+              rtuInfo['collect_time'] = info['collect_time'];
+              rtuInfo['acc_rain'] = info['acc_rain'];
+              rtuInfo['fiveMinute_rain'] = info['fiveMinute_rain'];
+              rtuInfo['hour_rain'] = info['hour_rain'];
+              rtuInfo['fiveMinute_rain'] = info['fiveMinute_rain'];
+              rtuInfo['hour_rain'] = info['hour_rain'];
+              rtuInfo['weater_level'] = info['weater_level'];
+              rtuInfo['power_v'] = info['power_v'];
+              rtuInfo['rtu_uuid'] = info['rtu_uuid'];
+              rtuInfo['rtu_ver'] = info['rtu_ver'];
+              rtuInfo['bt_v'] = info['bt_v'];
+              rtuInfo['rtu_rssi'] = info['rtu_rssi'];
+              rtuInfo['rtu_temperature'] = info['rtu_temperature'];
+              rtuInfo['lua_ver'] = info['lua_ver'];
+              this.setData({
+                rtuInfo: rtuInfo
+              });
+              let index = this.data.datagramIndex + 1;
+              if (this.data.datagramCache.length == index) {
+                index = 0;
+              }
+              this.setData({
+                datagramIndex: index,
+                trySendCount: 0
+              })
+              this.cancelTime();
+            } else if (funcode == '45') {
+
+            } else if (funcode == '47') {
+              this.setData({
+                showSettingResult: true,
+                settingResultText: "设备存储重置操作已完成!"
+              })
+              // wx.showToast({
+              //   title: '操作已完成!',
+              //   icon: 'ok',
+              //   duration: 2000 //持续的时间
+              // })
+            } else if (funcode == '48') {
+              this.setData({
+                showSettingResult: true,
+                settingResultText: "恢复出厂设置操作已完成!"
+              })
+              // wx.showToast({
+              //   title: '操作已完成!',
+              //   icon: 'ok',
+              //   duration: 2000 //持续的时间
+              // })
+            } else if (funcode == '41') {
+
+            } else if (funcode == '40') {
+
+            } else if (funcode == '43') {
+
+            } else if (funcode == '42') {
+
+            } else if (funcode == '4a') {
+
+            } else if (funcode == '51') {
+
+            } else if (funcode == 'f3') {
+              this.setData({
+                showSettingResult: true,
+                settingResultText: "已重启RTU,请重新连接蓝牙!"
+              })
+
+              // wx.showToast({
+              //   title: '操作已完成!',
+              //   icon: 'ok',
+              //   duration: 2000 //持续的时间
+              // })
+            }
+            if (datagram.length - datagramlength * 2 > 0) {
+              let tmp = datagram.substring(datagramlength * 2, datagram.length);
+              this.setData({
+                datagramBuff: tmp
+              })
+            }
+          } else {
+            this.setData({
+              datagramBuff: datagram
+            })
+          }
+        } else {
+          this.setData({
+            datagramBuff: datagram
+          })
+        }
+      } else {
+        if (null != datagram && datagram.length > 0) {
+          this.setData({
+            datagramBuff: datagram
+          })
+        } else {
+          this.setData({
+            datagramBuff: ''
+          })
+        }
+      }
+    }
+  },
+  sendDatagramToRtu(datagram) {
+    console.log("will send datagram " + datagram);
+    let buffer = util.HexStr2Bytes(datagram);
+    var that = this;
+    let count = 0;
+    let inView = new DataView(buffer);
+    while (true) {
+      if (buffer.byteLength - count > 20) {
+        let tmpBuff = new ArrayBuffer(20);
+        let outView = new DataView(tmpBuff);
+        for (let i = 0; i < 20; i++) {
+          outView.setUint8(i, inView.getUint8(count + i))
+        }
+        wx.writeBLECharacteristicValue({
+          deviceId: that.data.devices['deviceId'],
+          serviceId: that.data.devices['serviceId'],
+          characteristicId: that.data.devices['characteristicId'],
+          value: tmpBuff,
+          success(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+            wx.onBLECharacteristicValueChange((characteristic) => {
+              console.log("read datagram==============", util.ab2hex(characteristic.value))
+              var datagram = util.ab2hex(characteristic.value);
+              that.pushDatagramBuff(datagram);
+            })
+            wx.readBLECharacteristicValue({
+              deviceId: that.data.devices['deviceId'],
+              serviceId: that.data.devices['serviceId'],
+              characteristicId: that.data.devices['characteristicId'],
+              success: function (res) {
+                console.log('readBLECharacteristicValue')
+              }
+            })
+          },
+          fail(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+          }
+        })
+        count += 20;
+      } else {
+        let len = buffer.byteLength - count;
+        let tmpBuff = new ArrayBuffer(len);
+        let outView = new DataView(tmpBuff);
+        for (let i = 0; i < len; i++) {
+          outView.setUint8(i, inView.getUint8(count + i))
+        }
+        wx.writeBLECharacteristicValue({
+          deviceId: that.data.devices['deviceId'],
+          serviceId: that.data.devices['serviceId'],
+          characteristicId: that.data.devices['characteristicId'],
+          value: tmpBuff,
+          success(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+            wx.onBLECharacteristicValueChange((characteristic) => {
+              console.log("read datagram==============", util.ab2hex(characteristic.value))
+              var datagram = util.ab2hex(characteristic.value);
+              that.pushDatagramBuff(datagram);
+            })
+            wx.readBLECharacteristicValue({
+              deviceId: that.data.devices['deviceId'],
+              serviceId: that.data.devices['serviceId'],
+              characteristicId: that.data.devices['characteristicId'],
+              success: function (res) {
+                console.log('readBLECharacteristicValue')
+              }
+            })
+          },
+          fail(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+          }
+        })
+        count += len;
+      }
+      if (count >= buffer.byteLength) {
+        break;
+      }
+    }
+  },
+  timeCallback() {
+    var that = this;
+    task_timer = setTimeout(function () {
+      console.log("------------------------------------Time CallBack----------------------------");
+      if (that.data.trySendCount == 0) {
+        let datagram = that.data.datagramCache[that.data.datagramIndex];
+        that.sendDatagramToRtu(datagram);
+        let index = that.data.datagramIndex + 1;
+        if (that.data.datagramCache.length == index) {
+          index = 0;
+        }
+        let count = that.data.trySendCount + 1;
+        that.setData({
+          datagramIndex: index,
+          trySendCount: count
+        })
+      } else {
+        let count = that.data.trySendCount + 1;
+        if (count >= 10) {
+          count = 0;
+        }
+        that.setData({
+          trySendCount: count
+        })
+      }
+      that.timeCallback();
+    }, 3000);
+  },
+  cancelTime() {
+    if (task_timer != undefined) {
+      clearTimeout(task_timer);
+      task_timer = undefined;
+    }
+    this.setData({
+      datagramIndex: 0,
+      trySendCount: 0
+    })
+  }
+})

+ 6 - 0
pages/bluetooth/info/bluetoothInfo.json

@@ -0,0 +1,6 @@
+{
+  "navigationBarTitleText": "",
+  "usingComponents": {
+    "mp-dialog": "weui-miniprogram/dialog/dialog"
+  }
+}

+ 186 - 0
pages/bluetooth/info/bluetoothInfo.wxml

@@ -0,0 +1,186 @@
+<page>
+	<view class="body-content">
+		<view class="info_list_box">
+			<scroll-view class="info_list" scroll-y scroll-with-animation>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">RTU实时状态</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										报文采集时间:
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.collect_time}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										电源电压(伏):
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.power_v}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										电池电压(伏):
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.bt_v}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										RTU信号强度:
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.rtu_rssi}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										设备温度(摄氏度):
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.rtu_temperature}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										RTU版本:
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.rtu_ver}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										LUA版本:
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.lua_ver}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										UUID:
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.rtu_uuid}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">采集数据</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										累计雨量(毫米):
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.acc_rain}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										5分钟雨量(毫米):
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.fiveMinute_rain}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										1小时雨量(毫米):
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.hour_rain}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-media-box__desc info_text_line_inline">
+									<view class="info_text_line_inline_title">
+										瞬时水位(米):
+									</view>
+									<view class="info_text_line_inline_content">
+										{{rtuInfo.weater_level}}
+									</view>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">RTU重置(慎重操作)</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<button type="warn" bindtap="resetMemryBtnTap">初始化存储</button>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<button type="warn" bindtap="resetRtuBtnTap">恢复出厂设置</button>
+							</view>
+						</navigator>
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<button type="warn" bindtap="rebootBtnTap">重启RTU</button>
+							</view>
+						</navigator>
+					</view>
+				</view>
+			</scroll-view>
+		</view>
+	</view>
+	<mp-dialog title="操作提示" show="{{showSettingResult}}" bindbuttontap="settingCompletTabEvent"
+		buttons="{{[ {text: '确定'}]}}">
+		<view>{{settingResultText}}</view>
+	</mp-dialog>
+</page>

+ 45 - 0
pages/bluetooth/info/bluetoothInfo.wxss

@@ -0,0 +1,45 @@
+/* page {
+  height: 97%;
+} */
+
+.body-content{
+  width: 100%;
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+}
+
+.info_list_box{
+  width: 100%;
+  height: 100%;
+  position: relative;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+
+.info_list {
+  width: 98%;
+  height: 98%;
+  margin-top: 8px;
+  margin-bottom: 8px;
+}
+
+.info_text_line_inline{
+  width: 100%;
+  display: flex;
+  flex-direction: row;
+  align-items: flex-start;
+  color: black;
+}
+
+.info_text_line_inline_title{
+  width: 50%;
+}
+
+.info_text_line_inline_content{
+  width: 50%;
+  text-align: left;
+  color:#669999;
+  font-size: small;
+}

+ 893 - 0
pages/bluetooth/runSetting/bluetoothRunSetting.js

@@ -0,0 +1,893 @@
+const util = require("../../../utils/util");
+const datagramHelp = require("../../../utils/datagramHelp")
+var app = getApp();
+var task_timer;
+Page({
+  data: {
+    devices: {
+      deviceId: '',
+      serviceId: '',
+      characteristicId: '',
+      connectedBluetoothName: ''
+    },
+    rtuInfo: {
+      rtu_code: '',
+      ip1: '',
+      ip2: '',
+      ip3: '',
+      ip4: '',
+      rtu_work_model: '',
+      rtu_kind: '',
+      collect_interval: '',
+      water_level_base_point: '',
+      water_level_correct_point: '',
+      rain_precision: '',
+      rain_extra_datagram_threshold: '',
+      water_se_agreement: '',
+      water_se_id: '',
+      water_se_address: '',
+      water_se_format: '',
+      water_se_adjust: '',
+      water_se_symbol: '',
+      addIntervalTime: '',
+      intervalTime: '',
+      datagram_idx: '',
+      collect_time: '',
+      acc_rain: '',
+      fiveMinute_rain: '',
+      hour_rain: '',
+      weater_level: '',
+      power_v: '',
+      riverDeep: '',
+      riverWide: '',
+      riverAngle: '',
+      radarHigh: '',
+      faceCoe: '',
+      speedCoe: '',
+      flowModelCoe: '',
+      rtu_ver: '',
+      rtu_uuid: '',
+      bt_v: '',
+      rtu_rssi: '',
+      rtu_temperature: '',
+      lua_ver: '',
+      agreement: 'sw2014',
+      datagramTimes: [{
+          value: '5',
+          name: '5分钟',
+        },
+        {
+          value: '60',
+          name: '1小时',
+          checked: true
+        },
+        {
+          value: '120',
+          name: '2小时'
+        },
+        {
+          value: '180',
+          name: '3小时'
+        },
+        {
+          value: '240',
+          name: '4小时'
+        },
+        {
+          value: '360',
+          name: '6小时'
+        },
+        {
+          value: '480',
+          name: '8小时'
+        },
+        {
+          value: '720',
+          name: '12小时'
+        },
+        {
+          value: '1440',
+          name: '24小时'
+        }
+      ],
+      waterLevelSensorKind: [{
+          value: '0',
+          name: '未连接',
+          checked: true
+        },
+        {
+          value: '1',
+          name: '数字量'
+        },
+        {
+          value: '2',
+          name: '模似量'
+        }
+      ],
+      flowRateSensorKind: [{
+          value: '0',
+          name: '未连接',
+          checked: true
+        },
+        {
+          value: '1',
+          name: '数字量'
+        },
+        {
+          value: '2',
+          name: '模似量'
+        }
+      ],
+      flowRateSensorProtocolType: [{
+          value: '0',
+          name: 'modbus',
+          checked: true
+        },
+        {
+          value: '1',
+          name: '老百特流量计'
+        },
+        {
+          value: '2',
+          name: '插入式超声波流量计'
+        },
+        {
+          value: '3',
+          name: 'LMAG流量计'
+        },
+        {
+          value: '4',
+          name: '京仪流速计'
+        },
+        {
+          value: '5',
+          name: '91雷达流量计'
+        },
+        {
+          value: '6',
+          name: '华聚流速计'
+        },
+        {
+          value: '7',
+          name: '模拟流量计'
+        },
+        {
+          value: '8',
+          name: '华儒流速计'
+        },
+        {
+          value: '9',
+          name: '鹰格流速计'
+        },
+        {
+          value: '10',
+          name: '协议10'
+        },
+        {
+          value: '11',
+          name: '协议11'
+        },
+        {
+          value: '12',
+          name: '协议12'
+        },
+        {
+          value: '13',
+          name: '协议13'
+        },
+        {
+          value: '14',
+          name: '协议14'
+        }
+      ],
+      flowRateSensorId:'',
+    },
+    datagramBuff: '',
+    datagramCache: [],
+    trySendCount: 0,
+    datagramIndex: 0,
+    showSettingResult: false,
+    settingResultText: '操作已完成!'
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    console.log('bluebooth info page load ', '**********************************************')
+    let deviceId = options.deviceId;
+    let serviceId = options.serviceId;
+    let characteristicId = options.characteristicId;
+    let connectedBluetoothName = options.connectedBluetoothName;
+    console.log('name' + connectedBluetoothName)
+    let devices = {}
+    devices['deviceId'] = deviceId;
+    devices['serviceId'] = serviceId;
+    devices['characteristicId'] = characteristicId;
+    devices['connectedBluetoothName'] = connectedBluetoothName;
+    this.setData({
+      devices: devices,
+      trySendCount: 0,
+      datagramIndex: 0
+    })
+    task_timer = undefined;
+    this.getRtuRunSetting();
+
+    if (this.data.datagramCache.length > 0) {
+      let datagram = this.data.datagramCache[this.data.datagramIndex];
+      this.sendDatagramToRtu(datagram);
+      let index = this.data.datagramIndex + 1;
+      if (this.data.datagramCache.length == index) {
+        index = 0;
+      }
+      let count = this.data.trySendCount + 1;
+      this.setData({
+        datagramIndex: index,
+        trySendCount: count
+      })
+    }
+  },
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+    console.log('bluebooth runSetting page onHide ', '**********************************************')
+    this.cancelTime();
+  },
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+    console.log('bluebooth runSetting page onUnload ', '**********************************************')
+    this.cancelTime();
+  },
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    console.log('bluebooth runSetting page onShow ', '**********************************************')
+    this.timeCallback();
+  },
+  settingCompletTabEvent(e) {
+    this.setData({
+      showSettingResult: false
+    })
+    const btn = e.detail.index;
+    if (btn == 0) {
+      wx.navigateBack();
+    }
+  },
+  radioChange: function (e) {
+    let intervalTime = e.detail.value;
+    let radioItems = this.data.rtuInfo.datagramTimes;
+    for (let i = 0, len = radioItems.length; i < len; ++i) {
+      radioItems[i].checked = radioItems[i].value == intervalTime;
+    }
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.datagramTimes = radioItems;
+    rtuInfo.intervalTime = intervalTime;
+    this.setData({
+      rtuInfo: rtuInfo
+    });
+  },
+  waterLevelSensorKindRadioChange: function (e) {
+    var rtuInfo = this.data.rtuInfo;
+    var radioItems = this.data.rtuInfo.waterLevelSensorKind;
+    for (var i = 0, len = radioItems.length; i < len; ++i) {
+      radioItems[i].checked = radioItems[i].value == e.detail.value;
+    }
+    rtuInfo.waterLevelSensorKind = radioItems;
+    this.setData({
+      rtuInfo: rtuInfo
+    });
+  },
+  flowRateSensorKindRadioChange: function (e) {
+    var rtuInfo = this.data.rtuInfo;
+    var radioItems = this.data.rtuInfo.flowRateSensorKind;
+    for (var i = 0, len = radioItems.length; i < len; ++i) {
+      radioItems[i].checked = radioItems[i].value == e.detail.value;
+    }
+    rtuInfo.flowRateSensorKind = radioItems;
+    this.setData({
+      rtuInfo: rtuInfo
+    });
+  },
+  flowRateProtocolRadioChange: function (e) {
+    var rtuInfo = this.data.rtuInfo;
+    var radioItems = this.data.rtuInfo.flowRateSensorProtocolType;
+    for (var i = 0, len = radioItems.length; i < len; ++i) {
+      radioItems[i].checked = radioItems[i].value == e.detail.value;
+    }
+    rtuInfo.flowRateSensorProtocolType = radioItems;
+    this.setData({
+      rtuInfo: rtuInfo
+    });
+  },
+  addDatagramInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.addIntervalTime = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  waterBaseValueInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.water_level_base_point = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  waterCorrectValueInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.water_level_correct_point = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  rainPrecisionInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.rain_precision = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  rainExtraDatagramThresholdInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.rain_extra_datagram_threshold = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  waterSeAgreementInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.water_se_agreement = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  waterSeIdInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.water_se_id = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  waterSeAddressInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.water_se_address = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  waterSeFormatInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.water_se_format = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  waterSeAdjustInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.water_se_adjust = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  waterSeSymbolInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.water_se_symbol = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  riverDeepInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.riverDeep = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  riverWideInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.riverWide = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  riverAngleInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.riverAngle = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  radarHighInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.radarHigh = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  faceCoeInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.faceCoe = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  speedCoeInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.speedCoe = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  flowModelCoeInputHandle: function (e) {
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.flowModelCoe = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  flowRateSensorIdInputHandle: function(e){
+    let rtuInfo = this.data.rtuInfo;
+    rtuInfo.flowRateSensorId = e.detail.value;
+    this.setData({
+      rtuInfo: rtuInfo
+    })
+  },
+  submitRunsetting: function () {
+    this.cancelTime();
+    let datagram = datagramHelp.datagram_42(this.data.rtuInfo);
+    this.sendDatagramToRtu(datagram);
+  },
+  getRtuRunSetting() {
+    let datagram = datagramHelp.datagram_43();
+    let cache = this.data.datagramCache;
+    cache.push(datagram);
+  },
+  pushDatagramBuff(datagram) {
+    let tmpdatagramBuff = this.data.datagramBuff;
+    if (tmpdatagramBuff.length > 0) {
+      tmpdatagramBuff = tmpdatagramBuff + datagram;
+    } else {
+      tmpdatagramBuff = datagram;
+    }
+    console.log(" datagram buff ==========", tmpdatagramBuff)
+    this.setData({
+      datagramBuff: tmpdatagramBuff
+    })
+    this.processDatagram();
+  },
+  processDatagram() {
+    let datagram = this.data.datagramBuff;
+    if (datagram.length > 0) {
+      for (let i = 0; i < datagram.length; i++) {
+        if (datagram.indexOf("7e7e") == 0) {
+          break;
+        } else {
+          datagram = datagram.substring(i, datagram.length);
+        }
+      }
+      if (null != datagram && datagram.length > 0 && datagram.indexOf("7e7e") >= 0) {
+        if (datagram.length >= 26) {
+          var lenBuff = util.HexStr2Bytes(datagram.substring(22, 22 + 4));
+          var len = util.byteToUint16(lenBuff); // 报文长度(int)
+          var datagramlength = 11 + len + 6;
+          if (datagram.length >= datagramlength * 2) {
+            var onedatagram = datagram.substring(0, datagramlength * 2);
+            if (!datagramHelp.crcCheck(onedatagram)) {
+              wx.showToast({
+                title: '数据CRC校验错误,请重试!',
+                icon: 'none',
+                duration: 2000
+              })
+              this.setData({
+                datagramBuff: ''
+              })
+              return;
+            }
+            var count = 20;
+            var funcode = datagram.substring(count, count + 2);
+            count += 2;
+            if (funcode == "f6") {
+
+            } else if (funcode == "f7") {
+
+            } else if (funcode == '45') {
+
+            } else if (funcode == '47') {
+
+            } else if (funcode == '48') {
+
+            } else if (funcode == '41') {
+
+            } else if (funcode == '40') {
+
+            } else if (funcode == '43') {
+              var info = datagramHelp.datagram_43_analyse(onedatagram)
+              console.log(info)
+              let rtuInfo = this.data.rtuInfo;
+              let intervalTime = info['intervalTime'];
+              let datagramTimes = rtuInfo.datagramTimes;
+              //  let it = {};
+              //it['name'] = "5分钟";
+              // it['value'] = "5";
+              if (intervalTime == "5") {
+                datagramTimes[0]['checked'] = true;
+              } else {
+                datagramTimes[0]['checked'] = false;
+              }
+              // datagramTimes.push(it);
+              //  it = {};
+              //  it['name'] = "1小时";
+              // it['value'] = "60";
+              if (intervalTime == "60") {
+                datagramTimes[1]['checked'] = true;
+              } else {
+                datagramTimes[1]['checked'] = false;
+              }
+              //datagramTimes.push(it);
+              //it = {};
+              //it['name'] = "2小时";
+              //it['value'] = "120";
+              if (intervalTime == "120") {
+                datagramTimes[2]['checked'] = true;
+              } else {
+                datagramTimes[2]['checked'] = false;
+              }
+              //datagramTimes.push(it);
+              //it = {};
+              //it['name'] = "3小时";
+              //it['value'] = "180";
+              if (intervalTime == "180") {
+                datagramTimes[3]['checked'] = true;
+              } else {
+                datagramTimes[3]['checked'] = false;
+              }
+              //datagramTimes.push(it);
+              //it = {};
+              //it['name'] = "4小时";
+              //it['value'] = "240";
+              if (intervalTime == "240") {
+                datagramTimes[4]['checked'] = true;
+              } else {
+                datagramTimes[4]['checked'] = false;
+              }
+              //datagramTimes.push(it);
+              //it = {};
+              //it['name'] = "6小时";
+              //it['value'] = "360";
+              if (intervalTime == "360") {
+                datagramTimes[5]['checked'] = true;
+              } else {
+                datagramTimes[5]['checked'] = false;
+              }
+              //datagramTimes.push(it);
+              //it = {};
+              //it['name'] = "8小时";
+              //it['value'] = "480";
+              if (intervalTime == "480") {
+                datagramTimes[6]['checked'] = true;
+              } else {
+                datagramTimes[6]['checked'] = false;
+              }
+              //datagramTimes.push(it);
+              //it = {};
+              //it['name'] = "12小时";
+              //it['value'] = "720";
+              if (intervalTime == "720") {
+                datagramTimes[7]['checked'] = true;
+              } else {
+                datagramTimes[7]['checked'] = false;
+              }
+              //datagramTimes.push(it);
+              //it = {};
+              //it['name'] = "24小时";
+              //it['value'] = "1440";
+              if (intervalTime == "1440") {
+                datagramTimes[8]['checked'] = true;
+              } else {
+                datagramTimes[8]['checked'] = false;
+              }
+              //datagramTimes.push(it);
+
+
+              rtuInfo['intervalTime'] = intervalTime;
+              rtuInfo['datagramTimes'] = datagramTimes;
+
+              var v = info['addIntervalTime'];
+              if (null != v && v.length > 0) {
+                rtuInfo['addIntervalTime'] = info['addIntervalTime'];
+              }
+
+              v = info['water_level_base_point'];
+              if (null != v && v.length > 0) {
+                rtuInfo['water_level_base_point'] = info['water_level_base_point'];
+              }
+
+              v = info['water_level_correct_point'];
+              if (null != v && v.length > 0) {
+                rtuInfo['water_level_correct_point'] = info['water_level_correct_point'];
+              }
+
+              v = info['rain_precision'];
+              if (null != v && v.length > 0) {
+                rtuInfo['rain_precision'] = info['rain_precision'];
+              }
+
+              v = info['rain_extra_datagram_threshold'];
+              if (null != v && v.length > 0) {
+                rtuInfo['rain_extra_datagram_threshold'] = info['rain_extra_datagram_threshold'];
+              }
+
+              v = info['water_se_agreement'];
+              if (null != v && v.length > 0) {
+                rtuInfo['water_se_agreement'] = info['water_se_agreement'];
+              }
+
+              v = info['water_se_id'];
+              if (null != v && v.length > 0) {
+                rtuInfo['water_se_id'] = info['water_se_id'];
+              }
+
+              v = info['water_se_address'];
+              if (null != v && v.length > 0) {
+                rtuInfo['water_se_address'] = info['water_se_address'];
+              }
+
+              v = info['water_se_format'];
+              if (null != v && v.length > 0) {
+                rtuInfo['water_se_format'] = info['water_se_format'];
+              }
+
+              v = info['water_se_adjust'];
+              if (null != v && v.length > 0) {
+                rtuInfo['water_se_adjust'] = info['water_se_adjust'];
+              }
+
+              v = info['water_se_symbol'];
+              if (null != v && v.length > 0) {
+                rtuInfo['water_se_symbol'] = info['water_se_symbol'];
+              }
+
+              v = info['riverDeep'];
+              if (null != v && v.length > 0) {
+                rtuInfo['riverDeep'] = info['riverDeep'];
+              }
+
+              v = info['riverWide'];
+              if (null != v && v.length > 0) {
+                rtuInfo['riverWide'] = info['riverWide'];
+              }
+
+              v = info['riverAngle'];
+              if (null != v && v.length > 0) {
+                rtuInfo['riverAngle'] = info['riverAngle'];
+              }
+
+              v = info['radarHigh'];
+              if (null != v && v.length > 0) {
+                rtuInfo['radarHigh'] = info['radarHigh'];
+              }
+
+              v = info['faceCoe'];
+              if (null != v && v.length > 0) {
+                rtuInfo['faceCoe'] = info['faceCoe'];
+              }
+
+              v = info['speedCoe'];
+              if (null != v && v.length > 0) {
+                rtuInfo['speedCoe'] = info['speedCoe'];
+              }
+
+              v = info['flowModelCoe'];
+              if (null != v && v.length > 0) {
+                rtuInfo['flowModelCoe'] = info['flowModelCoe'];
+              }
+
+              let waterLevelSensorKind = rtuInfo.waterLevelSensorKind;
+              let waterLevelSensorKindValue = info['waterLevelSensorKind'];
+              for(let i=0;i<3;i++){
+                if (waterLevelSensorKindValue == i) {
+                  waterLevelSensorKind[i]['checked'] = true;
+                } else {
+                  waterLevelSensorKind[i]['checked'] = false;
+                }
+              }
+
+
+              let flowRateSensorKind = rtuInfo.flowRateSensorKind;
+              let flowRateSensorKindValue = info['flowRateSensorKind'];
+              for(let i=0;i<3;i++){
+                if (flowRateSensorKindValue == i) {
+                  flowRateSensorKind[i]['checked'] = true;
+                } else {
+                  flowRateSensorKind[i]['checked'] = false;
+                }
+              }
+
+
+              let flowRateSensorProtocolType = rtuInfo.flowRateSensorProtocolType;
+              let flowRateSensorProtocolTypeValue = info['flowRateSensorProtocolType'];
+              for(let i=0;i<15;i++){
+                if (flowRateSensorProtocolTypeValue == i) {
+                  flowRateSensorProtocolType[i]['checked'] = true;
+                } else {
+                  flowRateSensorProtocolType[i]['checked'] = false;
+                }
+              }
+
+
+             let flowRateSensorId =  info['flowRateSensorId'];
+             if (null != flowRateSensorId && flowRateSensorId.length > 0) {
+              rtuInfo['flowRateSensorId'] = flowRateSensorId;
+            }
+
+
+              this.setData({
+                rtuInfo: rtuInfo
+              });
+              this.cancelTime();
+            } else if (funcode == '42') {
+              this.setData({
+                showSettingResult: true,
+                settingResultText: "运行参数配置已完成!"
+              })
+              // wx.showToast({
+              //   title: 'RTU运行参数设置已完成!',
+              //   icon: 'ok',
+              //   duration: 2000 //持续的时间
+              // })
+            } else if (funcode == '4A') {
+
+            } else if (funcode == '51') {
+
+            } else if (funcode == 'f3') {
+
+            }
+            if (datagram.length - datagramlength * 2 > 0) {
+              let tmp = datagram.substring(datagramlength * 2, datagram.length);
+              this.setData({
+                datagramBuff: tmp
+              })
+            }
+          } else {
+            this.setData({
+              datagramBuff: datagram
+            })
+          }
+        } else {
+          this.setData({
+            datagramBuff: datagram
+          })
+        }
+      } else {
+        if (null != datagram && datagram.length > 0) {
+          this.setData({
+            datagramBuff: datagram
+          })
+        } else {
+          this.setData({
+            datagramBuff: ''
+          })
+        }
+      }
+    }
+  },
+  sendDatagramToRtu(datagram) {
+    console.log("will send datagram " + datagram);
+    let buffer = util.HexStr2Bytes(datagram);
+    var that = this;
+    let count = 0;
+    let inView = new DataView(buffer);
+    while (true) {
+      if (buffer.byteLength - count > 20) {
+        let tmpBuff = new ArrayBuffer(20);
+        let outView = new DataView(tmpBuff);
+        for (let i = 0; i < 20; i++) {
+          outView.setUint8(i, inView.getUint8(count + i))
+        }
+        wx.writeBLECharacteristicValue({
+          deviceId: that.data.devices['deviceId'],
+          serviceId: that.data.devices['serviceId'],
+          characteristicId: that.data.devices['characteristicId'],
+          value: tmpBuff,
+          success(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+            wx.onBLECharacteristicValueChange((characteristic) => {
+              console.log("read datagram==============", util.ab2hex(characteristic.value))
+              var datagram = util.ab2hex(characteristic.value);
+              that.pushDatagramBuff(datagram);
+            })
+            wx.readBLECharacteristicValue({
+              deviceId: that.data.devices['deviceId'],
+              serviceId: that.data.devices['serviceId'],
+              characteristicId: that.data.devices['characteristicId'],
+              success: function (res) {
+                console.log('readBLECharacteristicValue')
+              }
+            })
+          },
+          fail(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+          }
+        })
+        count += 20;
+      } else {
+        let len = buffer.byteLength - count;
+        let tmpBuff = new ArrayBuffer(len);
+        let outView = new DataView(tmpBuff);
+        for (let i = 0; i < len; i++) {
+          outView.setUint8(i, inView.getUint8(count + i))
+        }
+        wx.writeBLECharacteristicValue({
+          deviceId: that.data.devices['deviceId'],
+          serviceId: that.data.devices['serviceId'],
+          characteristicId: that.data.devices['characteristicId'],
+          value: tmpBuff,
+          success(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+            wx.onBLECharacteristicValueChange((characteristic) => {
+              console.log("read datagram==============", util.ab2hex(characteristic.value))
+              var datagram = util.ab2hex(characteristic.value);
+              that.pushDatagramBuff(datagram);
+            })
+            wx.readBLECharacteristicValue({
+              deviceId: that.data.devices['deviceId'],
+              serviceId: that.data.devices['serviceId'],
+              characteristicId: that.data.devices['characteristicId'],
+              success: function (res) {
+                console.log('readBLECharacteristicValue')
+              }
+            })
+          },
+          fail(res) {
+            console.log('writeBLECharacteristicValue success', res.errMsg)
+          }
+        })
+        count += len;
+      }
+      if (count >= buffer.byteLength) {
+        break;
+      }
+    }
+  },
+  timeCallback() {
+    var that = this;
+    task_timer = setTimeout(function () {
+      console.log("------------------------------------Time CallBack----------------------------");
+      if (that.data.trySendCount == 0) {
+        let datagram = that.data.datagramCache[that.data.datagramIndex];
+        that.sendDatagramToRtu(datagram);
+        let index = that.data.datagramIndex + 1;
+        if (that.data.datagramCache.length == index) {
+          index = 0;
+        }
+        let count = that.data.trySendCount + 1;
+        that.setData({
+          datagramIndex: index,
+          trySendCount: count
+        })
+      } else {
+        let count = that.data.trySendCount + 1;
+        if (count >= 10) {
+          count = 0;
+        }
+        that.setData({
+          trySendCount: count
+        })
+      }
+      that.timeCallback();
+    }, 3000);
+  },
+  cancelTime() {
+    if (task_timer != undefined) {
+      clearTimeout(task_timer);
+      task_timer = undefined;
+    }
+    this.setData({
+      datagramIndex: 0,
+      trySendCount: 0
+    })
+  }
+})

+ 6 - 0
pages/bluetooth/runSetting/bluetoothRunSetting.json

@@ -0,0 +1,6 @@
+{
+  "navigationBarTitleText": "",
+  "usingComponents": {
+    "mp-dialog": "weui-miniprogram/dialog/dialog"
+  }
+}

+ 368 - 0
pages/bluetooth/runSetting/bluetoothRunSetting.wxml

@@ -0,0 +1,368 @@
+<page>
+	<view class="body-content">
+		<view class="info_list_box">
+			<scroll-view class="info_list" scroll-y scroll-with-animation>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">上报间隔</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-cells weui-cells_after-title">
+									<radio-group bindchange="radioChange">
+										<label class="time-select" wx:for="{{rtuInfo.datagramTimes}}" wx:key="value">
+											<view style="margin:5rpx;">
+												<block wx:if="{{item.checked}}">
+													<radio value="{{item.value}}" checked="true" />
+												</block>
+												<block wx:else>
+													<radio value="{{item.value}}" />
+												</block>
+											</view>
+											<view style="margin:5rpx;color:darkgray;">{{item.name}}</view>
+										</label>
+									</radio-group>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">加报时间间隔(分钟)</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='addDatagramInputHandle' value='{{rtuInfo.addIntervalTime}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">水位基值(米):</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='waterBaseValueInputHandle'
+										value='{{rtuInfo.water_level_base_point}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">水位修正值(米):</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='waterCorrectValueInputHandle'
+										value='{{rtuInfo.water_level_correct_point}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">雨量计分辨率:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='rainPrecisionInputHandle'
+										value='{{rtuInfo.rain_precision}}'></input>
+								</view>
+							</view>
+						</navigator>
+            <view style="padding-left: 10px;"><span style="color: red;font-size:0.8rem;">提示:</span><span style="color: gray;font-size:0.8rem;">0:不连接,1:0.1毫米,2:0.2毫米,3:0.5毫米,4:1毫米</span></view>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">雨量计加报阈值:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='rainExtraDatagramThresholdInputHandle'
+										value='{{rtuInfo.rain_extra_datagram_threshold}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">水位计协议:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='waterSeAgreementInputHandle'
+										value='{{rtuInfo.water_se_agreement}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">水位计id:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='waterSeIdInputHandle'
+										value='{{rtuInfo.water_se_id}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">水位计地址:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='waterSeAddressInputHandle'
+										value='{{rtuInfo.water_se_address}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">水位计格式:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='waterSeFormatInputHandle'
+										value='{{rtuInfo.water_se_format}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">水位计调整:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='waterSeAdjustInputHandle'
+										value='{{rtuInfo.water_se_adjust}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">水位计符号:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='waterSeSymbolInputHandle'
+										value='{{rtuInfo.water_se_symbol}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<!-- 流量参数 -->
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">河道深:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='riverDeepInputHandle'
+										value='{{rtuInfo.riverDeep}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">河道宽:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='riverWideInputHandle'
+										value='{{rtuInfo.riverWide}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">河道坡度:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='riverAngleInputHandle'
+										value='{{rtuInfo.riverAngle}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">探头高:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='radarHighInputHandle'
+										value='{{rtuInfo.radarHigh}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">断面系数:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='faceCoeInputHandle'
+										value='{{rtuInfo.faceCoe}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">流速系数:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='speedCoeInputHandle'
+										value='{{rtuInfo.speedCoe}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">流量模型系数:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='flowModelCoeInputHandle'
+										value='{{rtuInfo.flowModelCoe}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+        <view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">水位计类型</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-cells weui-cells_after-title">
+									<radio-group bindchange="waterLevelSensorKindRadioChange">
+										<label class="time-select" wx:for="{{rtuInfo.waterLevelSensorKind}}" wx:key="value">
+											<view style="margin:5rpx;">
+												<block wx:if="{{item.checked}}">
+													<radio value="{{item.value}}" checked="true" />
+												</block>
+												<block wx:else>
+													<radio value="{{item.value}}" />
+												</block>
+											</view>
+											<view style="margin:5rpx;color:darkgray;">{{item.name}}</view>
+										</label>
+									</radio-group>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+        <view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">流量计类型</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-cells weui-cells_after-title">
+									<radio-group bindchange="flowRateSensorKindRadioChange">
+										<label class="time-select" wx:for="{{rtuInfo.flowRateSensorKind}}" wx:key="value">
+											<view style="margin:5rpx;">
+												<block wx:if="{{item.checked}}">
+													<radio value="{{item.value}}" checked="true" />
+												</block>
+												<block wx:else>
+													<radio value="{{item.value}}" />
+												</block>
+											</view>
+											<view style="margin:5rpx;color:darkgray;">{{item.name}}</view>
+										</label>
+									</radio-group>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+        <view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">流量计协议</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="weui-cells weui-cells_after-title">
+									<radio-group bindchange="flowRateProtocolRadioChange">
+										<label class="time-select" wx:for="{{rtuInfo.flowRateSensorProtocolType}}" wx:key="value">
+											<view style="margin:5rpx;">
+												<block wx:if="{{item.checked}}">
+													<radio value="{{item.value}}" checked="true" />
+												</block>
+												<block wx:else>
+													<radio value="{{item.value}}" />
+												</block>
+											</view>
+											<view style="margin:5rpx;color:darkgray;">{{item.name}}</view>
+										</label>
+									</radio-group>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+        <view class="weui-panel weui-panel_access">
+					<view class="weui-panel__hd">流量计ID:</view>
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="myinput">
+									<input type='text' bindinput='flowRateSensorIdInputHandle'
+										value='{{rtuInfo.flowRateSensorId}}'></input>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+	      <!-- 提交 -->
+				<view class="weui-panel weui-panel_access">
+					<view class="weui-panel__bd">
+						<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
+							<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
+								<view class="submit-btn">
+									<button type="warn" bindtap="submitRunsetting">提交</button>
+								</view>
+							</view>
+						</navigator>
+					</view>
+				</view>
+			</scroll-view>
+		</view>
+	</view>
+	<mp-dialog title="操作提示" show="{{showSettingResult}}" bindbuttontap="settingCompletTabEvent"
+		buttons="{{[ {text: '确定'}]}}">
+		<view>{{settingResultText}}</view>
+	</mp-dialog>
+</page>

+ 83 - 0
pages/bluetooth/runSetting/bluetoothRunSetting.wxss

@@ -0,0 +1,83 @@
+/* page {
+  height: 97%;
+} */
+
+.body-content {
+  width: 100%;
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+}
+
+.info_list_box {
+  width: 100%;
+  height: 100%;
+  position: relative;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+
+.info_list {
+  width: 98%;
+  height: 98%;
+  margin-top: 8px;
+  margin-bottom: 8px;
+}
+
+.info_text_line_inline {
+  width: 100%;
+  display: flex;
+  flex-direction: row;
+  align-items: flex-start;
+  color: black;
+}
+
+.info_text_line_inline_title {
+  width: 50%;
+}
+
+.info_text_line_inline_content {
+  width: 50%;
+  text-align: left;
+  color: #669999;
+  font-size: small;
+}
+
+.info_text_line_center {
+  text-align: center;
+}
+
+.datetime_font {
+  color:#669999;
+}
+
+.myinput {
+  margin-top: 20rpx;
+}
+
+.radio_name{
+  margin:5rpx;
+  color:#669999;
+}
+
+.myinput input {
+  border-style: solid;
+  border-width: thin;
+  border-color: lightgray;
+  padding-top: 10rpx;
+  padding-left: 10rpx;
+  padding-bottom: 10rpx;
+  color:#669999;
+}
+
+.time-select {
+  margin-top: 10rpx;
+  display: flex;
+  flex-direction: row;
+  justify-content: start;
+}
+
+.submit-btn {
+  height: 15%;
+}

+ 108 - 0
pages/deviceCheck/deviceCheckList.js

@@ -0,0 +1,108 @@
+// pages/deviceCheck.js
+var app = getApp();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    checkList:[],
+    openid: '',
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    this.data.openid = wx.getStorageSync('openid');
+    if(this.data.openid){
+      this.getCheckList(this.data.openid);
+    }
+  },
+  checkProcessHandle: function (e) {
+    var checkid = e.currentTarget.dataset.checkid;
+    wx.navigateTo({
+      url: '/pages/deviceCheck/report/deviceCheckReport?checkId='+checkid
+    });
+  },
+  locationToHandle: function (e) {
+    var rtuCode = e.currentTarget.dataset.rtucode;
+    if(null != rtuCode){
+      wx.navigateTo({
+        url: '/pages/rtu/rtuNavigate/detail/rtuNavigateInfoView?rtuCode=' + rtuCode
+      });
+    }
+  },
+  getCheckList: function (opneId) {
+    wx.showNavigationBarLoading()
+    var that = this;
+    var url = app.globalData.cloudBase + "/Dev/Wx/check/list/" + opneId;
+    wx.request({
+      url: url,
+      method: 'GET',
+      header: {
+        "Content-Type": "json"
+      },
+      success: function (res) {
+        wx.hideNavigationBarLoading();
+        if (res.data.code === "0") {
+          that.setData({
+            checkList: res.data.data
+          });
+        }
+      },
+      fail: function (error) {
+        console.log(error)
+        wx.hideNavigationBarLoading();
+      }
+    })
+  },
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  },
+})

+ 4 - 0
pages/deviceCheck/deviceCheckList.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "巡检上报",
+  "usingComponents": {}
+}

+ 36 - 0
pages/deviceCheck/deviceCheckList.wxml

@@ -0,0 +1,36 @@
+<!--pages/deviceCheck/deviceCheck.wxml-->
+<view class="viewBox">
+  <view class="list-box">
+    <scroll-view scroll-y="true" class="sv">
+      <block wx:for="{{checkList}}" wx:key="value">
+        <view class="weui-cells">
+          <view class="time-select" style="padding-top: 10px;">
+            <view>
+              <text style="color:#426666;font-size:1.0rem;" >{{item.checkTitle}}</text>
+            </view>
+            <view>
+                <text style="color:gray"> {{item.warningDesc}}</text>
+            </view>
+             <view>
+              <text class="{{item.closeStatus=='0' ? 'processStatusNameNormal':'processStatusNameComplete'}}" >{{item.processStatusName}}</text>
+              <text style="margin-left: 10px;color:gray;font-size:0.7rem;">{{item.updateUser}}</text>
+              <text style="margin-left: 10px;color:gray;font-size:0.7rem;">{{item.updateTimeText}}</text>
+             </view>
+          </view>
+          <view class="button">
+            <view class="button-check">
+              <button class="check-btn" data-checkid="{{item.id}}" bindtap="checkProcessHandle">
+                <text class="text" style="font-size:0.6rem;display:flex;justify-content:center;align-items:center;height:22px;color:white">处理</text>
+              </button>
+            </view>
+            <view class="button-check">
+              <button class="check-btn" data-checkid="{{item.id}}" data-rtucode="{{item.rtuCode}}" bindtap="locationToHandle">
+                <text class="text" style="font-size:0.6rem;display:flex;justify-content:center;align-items:center;height:22px;color:white">导航</text>
+              </button>
+            </view>
+          </view>
+        </view>
+      </block>
+    </scroll-view>
+  </view>
+</view>

+ 74 - 0
pages/deviceCheck/deviceCheckList.wxss

@@ -0,0 +1,74 @@
+/* pages/deviceCheck/deviceCheck.wxss */
+
+.viewBox {
+  position: fixed;
+  width: 100%;
+  height: 100%;
+  overflow: hidden;
+}
+
+.list-box{
+  height: 100%;
+  width: 100%;
+}
+
+.sv{
+  width: 100%;
+  height: 100%;
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+}
+
+.weui-cells{
+  width: 95%;
+  height: 180rpx;
+  position: relative;
+  background: white;
+  border-radius: 4px;
+  margin-bottom: 5px;
+  left: 8px;
+  display: flex;
+  align-items: center;
+  margin-top: 8px;
+}
+
+.time-select{
+  margin-left:10rpx;
+  display: flex;
+  flex-direction: column;
+  justify-content: start;
+  align-items: left;
+}
+
+.button-check{
+  display: flex;
+  align-items: center;
+  margin-left: 5px;
+  margin-right: 5px;
+}
+
+.button{
+  display: flex;
+  flex-direction: row;
+  padding-left: 15px;
+  position: absolute;
+  right: 0;
+  margin-right: 10px;
+}
+
+.check-btn{
+  height: 22px;
+  width: 60px;
+  background-color: #669999;
+}
+
+.processStatusNameNormal{
+   color:#FD7400;
+   font-size:0.7rem;
+}
+
+.processStatusNameComplete{
+  color:rgb(47, 113, 255);
+  font-size:0.7rem;
+}

+ 126 - 0
pages/deviceCheck/process/checkProcessInfo.js

@@ -0,0 +1,126 @@
+// pages/deviceCheck/process/checkProcessList.js
+var app = getApp();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    processInfo: {},
+    photos: [],
+    processId: '',
+    imageUrl:'',
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    var processId = options.processId;
+    this.setData({
+      processId: processId,
+      imageUrl: app.globalData.cloudBase+"/"
+    })
+     this.getProcessInfo(processId);
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  },
+  getProcessInfo(processId) {
+    wx.showNavigationBarLoading()
+    var that = this;
+    var url = app.globalData.cloudBase + "/Dev/Wx/check/process/" + processId;
+    wx.request({
+      url: url,
+      method: 'GET',
+      header: {
+        "Content-Type": "json"
+      },
+      success: function (res) {
+        wx.hideNavigationBarLoading();
+        if (res.data.code === "0") {
+          let processInfo =res.data.data;
+          // processInfo['id'] = res.data.data.id;
+          // processInfo['createUser'] = res.data.data.createUser;
+          // processInfo['createTimeText'] = res.data.data.createTimeText;
+          // processInfo['processSuggest'] = res.data.data.processSuggest;
+          let photos=[];
+          // for(var i=0;i<10;i++){
+          //   photos.push(res.data.data.photos[0])
+          // }
+          photos= res.data.data.photos;
+
+          that.setData({
+            processInfo: processInfo,
+            photos:photos,
+          })
+        }
+      },
+      fail: function (error) {
+        console.log(error)
+        wx.hideNavigationBarLoading();
+      }
+    })
+  },
+  photoView: function (event) {
+    var path = event.currentTarget.dataset.path;
+    console.debug("path "+path);
+    var pictures=[];
+    for(let i=0;i<this.data.photos.length;i++){
+        pictures.push(this.data.imageUrl+this.data.photos[i]);
+    }
+    let current=this.data.imageUrl+path;
+    wx.previewImage({
+      //当前显示下表
+       current: current,
+       //数据源
+       urls: pictures
+      })
+  },
+})

+ 4 - 0
pages/deviceCheck/process/checkProcessInfo.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "巡检上报信息",
+  "usingComponents": {}
+}

+ 46 - 0
pages/deviceCheck/process/checkProcessInfo.wxml

@@ -0,0 +1,46 @@
+<!--pages/deviceCheck/process/checkProcessList.wxml-->
+<page>
+  <view class="viewBody">
+    <view class="lineTitle">
+      <view class="title">
+        <text>处理状态:</text>
+      </view>
+      <view class="content">
+        <text>{{processInfo.processStatusName}}</text>
+      </view>
+    </view>
+    <view class="lineTitle">
+      <view class="title">
+        <text>处理人:</text>
+      </view>
+      <view class="content">
+        <text>{{processInfo.createUser}}</text>
+      </view>
+    </view>
+    <view class="lineTitle">
+      <view class="title">
+        <text>处理时间:</text>
+      </view>
+      <view class="content">
+        <text>{{processInfo.createTimeText}}</text>
+      </view>
+    </view>
+    <view class="lineTitle">
+      <view class="title">
+        <text>处理意见:</text>
+      </view>
+
+    </view>
+
+    <view class="processSuggest">
+      <text>{{processInfo.processSuggest}}</text>
+    </view>
+    <view >
+      <view class='photoBox'>
+          <block wx:for="{{photos}}" wx:for-item="photo" wx:key="key">
+            <image class='item-img' data-path="{{photo}}" src='{{imageUrl}}{{photo}}' bindtap="photoView" mode='aspectFill'></image>
+          </block>
+      </view>
+    </view>
+  </view>
+</page>

+ 69 - 0
pages/deviceCheck/process/checkProcessInfo.wxss

@@ -0,0 +1,69 @@
+/* pages/deviceCheck/process/checkProcessList.wxss */
+page {
+  position: fixed;
+  width: 100%;
+  height: 100%;
+  overflow: hidden;
+}
+
+.viewBody {
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+  padding-left: 10rpx;
+  padding-right: 10rpx;
+}
+
+.lineTitle{
+  margin-top: 20rpx;
+  display: flex;
+  flex-direction: row;
+}
+
+.lineTitle .title{
+width: 30%;
+}
+
+.lineTitle .title text{
+  font-size: 1rem;
+  color: black;
+}
+
+.lineTitle .content{
+  width: 60%;
+}
+
+.lineTitle .content text{
+  font-size: 0.8rem;
+  color: gray;
+}
+
+.processSuggest {
+  width: 100%;
+  height: 200rpx;
+  border-style: solid;
+  border-width: 1px;
+  border-color: gray;
+}
+
+.processSuggest text {
+  font-size: 0.9rem;
+  color: black;
+  padding-left: 10rpx;
+}
+
+.photoBox {
+  width: 100%;
+  display: flex;
+  flex-direction: row;
+  justify-content: flex-start;
+  margin-top: 40rpx;
+ flex-flow: wrap;
+}
+
+.item-img {
+  width: 150rpx;
+  height: 150rpx;
+  margin: 5rpx 5rpx 5rpx 5rpx;
+  border-radius: 5rpx;
+}

+ 199 - 0
pages/deviceCheck/report/deviceCheckReport.js

@@ -0,0 +1,199 @@
+// pages/deviceCheck/report/deviceCheckReport.js
+var app = getApp();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    checkInfo: {},
+    checkProcessList: [],
+    scrollViewH: 1,
+    show: false,
+    closeStatus: false,
+    checkStatusText: false,
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    var checkId = options.checkId;
+    var checkInfo = {};
+    checkInfo['id'] = checkId;
+    checkInfo['createUser'] = "";
+    checkInfo['createTime'] = "";
+    checkInfo['warningDesc'] = "";
+    checkInfo['processSuggest'] = "";
+    var list = [];
+    this.setData({
+      checkInfo: checkInfo,
+      checkProcessList: list
+    })
+
+    var that = this;
+    let q = wx.createSelectorQuery().in(this)
+    q.select('.baseInfoView').boundingClientRect(function (res) {
+      let windowHeight = wx.getSystemInfoSync().windowHeight
+      let titleHeight = res.height
+      let h = windowHeight - titleHeight
+      that.setData({
+        scrollViewH: h,
+      })
+    }).exec()
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+    console.log("onReady")
+    //取巡检信息
+    this.getCheckInfo(this.data.checkInfo.id);
+    //取处理意见列表
+    this.getProcessList(this.data.checkInfo.id);
+    this.setData({
+      show: true,
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+    console.log("onShow")
+    if (this.data.show) {
+      //取处理意见列表
+      this.getProcessList(this.data.checkInfo.id);
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  },
+  /**
+   * 巡检信息
+   * @param {*} checkId 
+   */
+  getCheckInfo(checkId) {
+    wx.showNavigationBarLoading()
+    var that = this;
+    var url = app.globalData.cloudBase + "/Dev/Wx/check/" + checkId;
+    wx.request({
+      url: url,
+      method: 'GET',
+      header: {
+        "Content-Type": "json"
+      },
+      success: function (res) {
+        wx.hideNavigationBarLoading();
+        if (res.data.code === "0") {
+          let checkInfo = {};
+          checkInfo['id'] = res.data.data.id;
+          checkInfo['createUser'] = res.data.data.createUser;
+          checkInfo['createTimeText'] = res.data.data.createTimeText;
+          checkInfo['warningDesc'] = res.data.data.warningDesc;
+          checkInfo['processSuggest'] = res.data.data.processSuggest;
+          let closeStatus=true;
+          let checkStatusText=false;
+          if(res.data.data.closeStatus=='1'){
+            closeStatus=false;
+            checkStatusText=true;
+          }
+          that.setData({
+            checkInfo: checkInfo,
+            closeStatus: closeStatus,
+            checkStatusText: checkStatusText,
+          })
+        }
+      },
+      fail: function (error) {
+        console.log(error)
+        wx.hideNavigationBarLoading();
+      }
+    })
+  },
+  /**
+   * 处理信息列表
+   * @param {*} checkId 
+   */
+  getProcessList(checkId) {
+    wx.showNavigationBarLoading()
+    var that = this;
+    var url = app.globalData.cloudBase + "/Dev/Wx/check/process/list/" + checkId;
+    wx.request({
+      url: url,
+      method: 'GET',
+      header: {
+        "Content-Type": "json"
+      },
+      success: function (res) {
+        wx.hideNavigationBarLoading();
+        if (res.data.code === "0") {
+          let datas = res.data.data;
+          if (null != datas) {
+            var list = [];
+            for (var i = 0; i < datas.length; i++) {
+              let d = datas[i];
+              var p = {};
+              p['id'] = d.id;
+              p['createUser'] = d.createUser;
+              p['createTimeText'] = d.createTimeText;
+              p['processSuggest'] = d.processSuggest;
+              list.push(p);
+            }
+            that.setData({
+              checkProcessList: list
+            });
+          }
+        }
+      },
+      fail: function (error) {
+        console.log(error)
+        wx.hideNavigationBarLoading();
+      }
+    })
+  },
+  toReportHandle: function (e) {
+    wx.navigateTo({
+      url: "/pages/deviceCheck/report/edit/checkProcessReportEdit?checkId=" + this.data.checkInfo.id
+    })
+  },
+  toCheckProcessInfoHandle: function (e) {
+    var processid = e.currentTarget.dataset.processid;
+    wx.navigateTo({
+      url: "/pages/deviceCheck/process/checkProcessInfo?processId=" + processid
+    });
+  },
+})

+ 4 - 0
pages/deviceCheck/report/deviceCheckReport.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "巡检处理"
+}

+ 62 - 0
pages/deviceCheck/report/deviceCheckReport.wxml

@@ -0,0 +1,62 @@
+<!--pages/deviceCheck/report/deviceCheckReport.wxml-->
+<page>
+  <view class="viewBody">
+    <view class='baseInfoView'>
+      <!-- 创建时间,创建人 -->
+      <view style="padding-left: 10rpx;padding-right: 10rpx;">
+        <text style="margin:0rpx;color:#426666;font-size:0.9rem;">工单创建人:</text>
+        <text style="margin:0rpx;color:gray;font-size:0.8rem;">{{checkInfo.createUser}}</text>
+      </view>
+      <view style="padding-left: 10rpx;padding-right: 10rpx;">
+        <text style="margin:0rpx;color:#426666;font-size:0.9rem;">工单创建时间:</text>
+        <text style="margin:0rpx;color:gray;font-size:0.8rem;">{{checkInfo.createTimeText}}</text>
+      </view>
+      <!-- 预警说明 -->
+      <view style="padding-left: 10rpx;padding-right: 10rpx;">
+        <text style="margin:0rpx;color:#426666;font-size:0.9rem;">预警说明:</text>
+        <text style="margin:0rpx;color:gray;font-size:0.8rem;">{{checkInfo.warningDesc}}</text>
+      </view>
+      <block wx:if="{{closeStatus}}">
+        <view class="report-btn" bindtap='toReportHandle'>
+          <text class="new-report-btn-text">新建上报</text>
+        </view>
+      </block>
+
+      <block wx:if="{{checkStatusText}}">
+       <view style="margin-top: 20rpx; display: flex;flex-direction: row;justify-content: center;">
+         <text style="color:#FD7400;font-size:1rem;">工单已经完结</text>
+       </view>
+      </block>
+    </view>
+    <view class="listContainer" enable-flex="true">
+      <scroll-view scroll-y="true" class='scroll-box' style="height: {{scrollViewH}}px;" enable-flex="true">
+        <view class='scroll-body'>
+          <block wx:for="{{checkProcessList}}" wx:for-item="process" wx:key="id">
+            <view class="index-list-item-container">
+              <view class='index-list-item-box'>
+                <view class='index-list-item-info-box'>
+                  <view class="suggest-text">
+                    <text>{{process.processSuggest}}</text>
+                  </view>
+                  <view class="createInfo">
+                    <view class="createUser">
+                      <text>{{process.createUser}}</text>
+                    </view>
+                    <view class="createTime">
+                      <text>{{process.createTimeText}}</text>
+                    </view>
+                  </view>
+                </view>
+                <view class="index-list-item-box-right" data-processid='{{process.id}}' bindtap='toCheckProcessInfoHandle'>
+                  <view class="imageBox">
+                    <image src='/images/click.png'></image>
+                  </view>
+                </view>
+              </view>
+            </view>
+          </block>
+        </view>
+      </scroll-view>
+    </view>
+  </view>
+</page>

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно