You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import {
  2. EtcSdkBaseClass
  3. } from "./etc-sdk-base-class";
  4. import {
  5. connectDevice,
  6. disconnectDevice,
  7. transCmd,
  8. } from "../etc-sdk/JLAPI/JLObuSDK"
  9. const sdkName = '聚力SDK'
  10. export class JlSdkTool extends EtcSdkBaseClass {
  11. connectDevice(device, disConnectCallback) {
  12. return new Promise((resolve) => {
  13. console.log(`${sdkName}连接设备`)
  14. connectDevice(device, function (res) {
  15. resolve(res)
  16. }, (res) => {
  17. if (res.code != 0) {
  18. res.code = 10006
  19. res.mes = '连接已断开'
  20. if (disConnectCallback) disConnectCallback(res)
  21. }
  22. })
  23. })
  24. }
  25. disconnectDevice() {
  26. console.log(`${sdkName}断开设备连接`)
  27. return new Promise((resolve) => {
  28. disconnectDevice(function (res) {
  29. resolve(res)
  30. })
  31. })
  32. }
  33. async transCmd(
  34. cmd,
  35. cmdType = '20',
  36. ) {
  37. const that = this
  38. return new Promise((resolve) => {
  39. transCmd(cmd, cmdType, (res) => {
  40. return resolve(that.configBleDataSerialize(res))
  41. })
  42. })
  43. }
  44. // configICC15(cmd,
  45. // cmdType, ) {
  46. // return new Promise((resolve) => {
  47. // JLSDK.ICCReset((res) => {
  48. // if (res.code != 0) {
  49. // return resolve(that.configBleDataSerialize(res))
  50. // } else {
  51. // return this.configChannel(cmdType, cmd)
  52. // }
  53. // })
  54. // })
  55. // }
  56. // configObuInfo(cmd, cmdType, ) {
  57. // return new Promise((resolve) => {
  58. // JLSDK.ESAMRset((res) => {
  59. // if (res.code == 0) {
  60. // /// 读系统信息
  61. // return resolve(that.configBleDataSerialize(res))
  62. // } else {
  63. // return this.configChannel(cmdType, cmd)
  64. // }
  65. // })
  66. // })
  67. // }
  68. // configChannel(cmdType, cmd) {
  69. // return new Promise((resolve) => {
  70. // if (cmdType === "OBU") {
  71. // console.log('ESAM 写入数据')
  72. // JLSDK.ESAMChannel(cmd, function (res) {
  73. // resolve(that.configBleDataSerialize(res))
  74. // })
  75. // } else {
  76. // console.log('ICC 写入数据')
  77. // JLSDK.ICCChannel(cmd, function (res) {
  78. // resolve(that.configBleDataSerialize(res))
  79. // })
  80. // }
  81. // })
  82. // }
  83. // _readCmd(cmdArr, cmdType) {
  84. // return new Promise((resolve) => {
  85. // const that = this
  86. // if (cmdType === 20) {
  87. // console.log('ESAM 读取数据')
  88. // this._configReadObu(cmdArr, function (res) {
  89. // resolve(that.configBleDataSerialize(res))
  90. // })
  91. // } else {
  92. // console.log('ICC 读取数据')
  93. // this._configReadIcc(cmdArr, function (res) {
  94. // resolve(that.configBleDataSerialize(res))
  95. // })
  96. // }
  97. // })
  98. // }
  99. // _wirteCmd(
  100. // cmdArr,
  101. // cmdType
  102. // ) {
  103. // let cmd = cmdArr[cmdArr.length - 1]
  104. // console.log(`${sdkName}写入数据`, cmd)
  105. // return new Promise((resolve) => {
  106. // if (cmdType === 20) {
  107. // console.log('ESAM 写入数据')
  108. // JLSDK.ESAMChannel(cmd, function (res) {
  109. // resolve(res)
  110. // })
  111. // } else {
  112. // console.log('ICC 写入数据')
  113. // JLSDK.ICCChannel(cmd, function (res) {
  114. // resolve(res)
  115. // })
  116. // }
  117. // })
  118. // }
  119. // _configReadObu(cmdArr, callBack) {
  120. // if (arrayIsEqual(cmdArr, getObuSystemInfoCmd())) {
  121. // /// ESAM 复位后读系统信息
  122. // console.log('ESAM 复位后读系统信息')
  123. // JLSDK.ESAMRset((res) => {
  124. // if (res.code == 0) {
  125. // /// 读系统信息
  126. // JLSDK.getSystemInfo(callBack)
  127. // } else {
  128. // callBack(res)
  129. // }
  130. // })
  131. // } else if (arrayIsEqual(cmdArr, get3F00RandomCmd('04'))) {
  132. // /// 获取系统信息随机数
  133. // JLSDK.getObuRadom(0, callBack)
  134. // } else if (arrayIsEqual(cmdArr, getDF01RandomCmd('04'))) {
  135. // /// 获取车辆信息随机数
  136. // JLSDK.getObuRadom(1, callBack)
  137. // }
  138. // }
  139. // _configReadIcc(cmdArr, callBack) {
  140. // if (arrayIsEqual(cmdArr, getCardFile15Cmd())) {
  141. // console.log('ICC 复位后读 0015 文件')
  142. // JLSDK.ICCReset((res) => {
  143. // if (res.code != 0) {
  144. // callBack(res)
  145. // return
  146. // }
  147. // /// ICC 复位后读 0015 文件
  148. // JLSDK.getCardInfo(callBack)
  149. // })
  150. // } else if (arrayIsEqual(cmdArr, get1001RandomCmd('04'))) {
  151. // /// 0015随机数
  152. // JLSDK.getCardRandNum(0, callBack)
  153. // } else if (arrayIsEqual(cmdArr, get3F00RandomCmd('04'))) {
  154. // /// 0016随机数
  155. // JLSDK.getCardRandNum(1, callBack)
  156. // }
  157. // }
  158. }