1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import log from '../../dxmodules/dxLogger.js'
import dxMap from '../../dxmodules/dxMap.js'
import dxCommonUtils from '../../dxmodules/dxCommonUtils.js'
import bus from '../../dxmodules/dxEventBus.js'
import config from '../../dxmodules/dxConfig.js'
const uartCodeService = {}
 
uartCodeService.receiveMsg = function (data) {
  log.info('[uartBleService] cmdcode :' + JSON.stringify(data))
  if (data.cmd == "30") {
    if (data.length > 0) {
      let code = dxCommonUtils.codec.hexToStr(dxCommonUtils.codec.uint8ArrayToHex(data.data))
      let map = dxMap.get("SCAN")
      let time = map.get("time") || 0
      let interval = config.get("sys.scanInterval") * 1000 || 1000
      if (new Date().getTime() - time > interval) {
        bus.fire("code", code)
        map.put("time", new Date().getTime())
      }
    }
  }
}
 
export default uartCodeService