@@ -46,12 +46,12 @@ | |||
const datas = require("../../static/etcUtil/datas.js"); | |||
const bluetoothUtil = require("../../static/etcUtil/index.js"); | |||
const jlApi = require("../../static/etc/JLAPI/JLObuSDK.js"); //聚力SDK | |||
let jlApi = require("../../static/etc/JLAPI/JLObuSDK.js"); //聚力SDK | |||
const wjApi = require("../../static/etc/WJAPI/wjBleAPI"); | |||
let tdApi = require("../../static/etc/TDAPI/TDRObuSDK.js"); | |||
// #ifdef MP-ALIPAY | |||
// 这部分代码将仅在支付宝小程序平台下执行 | |||
// jlApi = require("../../static/etc/JLObuSDK/JLObuSDK.js"); | |||
jlApi = require("../../static/etc/JLObuSDK/JLObuSDK.js"); | |||
// wjApi = require("../../static/etc/WJBLE/WJBleAPI"); | |||
tdApi = require("../../static/etc/TDRAPI/TDRObuSDK.js"); | |||
// 执行支付宝小程序的特定功能 |
@@ -44,12 +44,12 @@ | |||
const tools = require("../../static/etcUtil/tools.js"); | |||
const datas = require("../../static/etcUtil/datas.js"); | |||
const bluetoothUtil = require("../../static/etcUtil/index.js"); | |||
const jlApi = require("../../static/etc/JLAPI/JLObuSDK.js"); //聚力SDK | |||
let jlApi = require("../../static/etc/JLAPI/JLObuSDK.js"); //聚力SDK | |||
const wjApi = require("../../static/etc/WJAPI/wjBleAPI"); | |||
let tdApi = require("../../static/etc/TDAPI/TDRObuSDK.js"); | |||
// #ifdef MP-ALIPAY | |||
// 这部分代码将仅在支付宝小程序平台下执行 | |||
// jlApi = require("../../static/etc/JLObuSDK/JLObuSDK.js"); | |||
jlApi = require("../../static/etc/JLObuSDK/JLObuSDK.js"); | |||
// wjApi = require("../../static/etc/WJBLE/WJBleAPI"); | |||
tdApi = require("../../static/etc/TDRAPI/TDRObuSDK.js"); | |||
// 执行支付宝小程序的特定功能 |
@@ -0,0 +1 @@ | |||
var appVersion="1.0.3";export var area_config={protocol_version:1330,};export function ICCResetCmd(){switch(area_config.protocol_version){case 1310:return'A2';break;case 1320:return'A2';break;case 1312:return'A2';break;case 1330:return"A801";break}}export function ICCChannelCmd(){switch(area_config.protocol_version){case 1310:return'A3';break;case 1320:return'A3';break;case 1312:return'A3';break;case 1330:return"A3";break}}export function ESAMResetCmd(){switch(area_config.protocol_version){case 1310:return'AA';break;case 1320:return'A8';break;case 1312:return'A2';break;case 1330:return"A803";break}}export function ESAMChannelCmd(){switch(area_config.protocol_version){case 1310:return'AC';break;case 1320:return'A4';break;case 1312:return'A8';break;case 1330:return"A7";break}}export function ObuAuthCmd(){switch(area_config.protocol_version){case 1310:return'FF';break;case 1320:return'A9';break;case 1312:return'FF';break}}export function deviceInfo(){switch(area_config.protocol_version){case 1310:return'FF';break;case 1320:return'AA';break;case 1312:return'FF';break}}export function NewPipe(){switch(area_config.protocol_version){case 1310:return'FF';break;case 1320:return'AD';break;case 1312:return'FF';break}}export function ActState(){switch(area_config.protocol_version){case 1310:return'FF';break;case 1320:return'AC';break;case 1312:return'FF';break}}export function checkPower(){switch(area_config.protocol_version){case 1330:return'A5';break}}export function ResetFlag(){return'JLReset'}export function ChannelFlag(){return'JLChannel'}export function Auth(){return'JLAuth'}export function ActStateFlag(){return'JLActState'}export function NewPipFlag(){return'JLNewPip'}export function DeviceInfo(){return'JLDeviceInfo'}export function successCode(){return 0}export function errorCode(){return 10020}export function timeOutCode(){return 10102}export function cardNoExists(){return 10103}export function bleSuccessCode(){return 0}export function bleErrorCode(){return 10101}export function bleAvailableCode(){return 10104}export function cosErrorCode(){return 100100}export var message={api:'',status:'',sendCmd:[],reciveCmd:[]};export function DevResult(type,objc){var code='';var err_msg='';var res=null;var msg='';if(objc.code==successCode()){err_msg='执行成功';message.reciveCmd.push(objc.data);switch(type){case 0:{var data=objc.data;var sw=data.substr(data.length-4,4);if(sw=='9000'){message.status='00';code=successCode();data=objc.data.substr(0,data.length);err_msg='操作成功';msg=''}else{message.status='01';code=cosErrorCode();data=null;err_msg='COS指令错误';msg=sw}}break;case 1:{message.status='00';code=objc.code;err_msg=objc.msg;data=objc.data.substr(4,objc.data.length-4);msg=crsateMessage()}break;case 2:{message.status='00';console.log('判断obuInfo:'+objc.data);code=objc.code;err_msg=objc.msg;data=objc.data.substr(6,objc.data.length-6);msg=crsateMessage()}break;case 3:{message.status='00';console.log('认证数据:'+objc.data);code=objc.code;err_msg=objc.msg;data=objc.data.substr(8,2);msg=crsateMessage()}break;default:break}return{code:code,err_msg:err_msg,data:data,msg:crsateMessage()}}else{message.status='01';return{code:objc.code,err_msg:objc.msg,data:null,msg:crsateMessage()}}}function crsateMessage(){var messageInfo=message.api+"|"+message.sendCmd+"|"+message.status+"|"+message.reciveCmd;return messageInfo} |
@@ -0,0 +1,133 @@ | |||
var JLSDK = require('./JLDeviceWechat+33Protocol.js'); | |||
var Analysis = require('./JLObuWecha33UnPackt.js'); | |||
var config = require('./JLConfig.js'); | |||
var TAG = " JLObuSdk "; | |||
/** | |||
* 扫描设备 | |||
* @param {需要查询的设备名称或部分名称} nameFlag | |||
* @param {*} callBack | |||
*/ | |||
export function ScanDevice(nameFlag, timeOut, callBack) { | |||
JLSDK.scanDevice(nameFlag, timeOut, | |||
(res) => { | |||
callBack.call(this, res); | |||
} | |||
) | |||
} | |||
/** | |||
* 停止扫描 | |||
* @param {回调} callBack | |||
*/ | |||
export function StopScanDevice(callBack) { | |||
JLSDK.stopScanDevice( | |||
(res) => { | |||
callBack.call(this, res); | |||
} | |||
); | |||
} | |||
/** | |||
* 连接设备 | |||
* @param {设备对象} device | |||
* @param {回调} callBack | |||
*/ | |||
export function connectDevice(device, callBack,listenStatus) { | |||
JLSDK.connectDevice(device, | |||
(res) => { | |||
callBack.call(this, res); | |||
}) | |||
JLSDK.onConnectState((res) =>{ | |||
listenStatus.call(this,res); | |||
}) | |||
} | |||
/** | |||
* 断开连接 | |||
* @param {回调} callBack | |||
*/ | |||
export function disconnectDevice(callBack) { | |||
JLSDK.disConnectDevice((res) => { | |||
callBack.call(this, res); | |||
}) | |||
} | |||
/** | |||
* ESAM复位 | |||
* @param {回调方法} callBack | |||
*/ | |||
// function ESAMReset(callBack) { | |||
// JLSDK.ESAMRset((res) => { | |||
// callBack.call(this, res); | |||
// }) | |||
// } | |||
/** | |||
* ESAM通道透传 | |||
* @param {透传数据} data | |||
* @param {回调方法} callBack | |||
*/ | |||
// function ESAMChannel(data, callBack) { | |||
// JLSDK.ESAMChannel(data, (res) => { | |||
// callBack.call(this, res); | |||
// }) | |||
// } | |||
/** | |||
* ESAM通道透传(数组) | |||
* @param {cos指令数组} cmdArray | |||
* @param {结果回掉} callBack | |||
*/ | |||
// function ESAMChannelArray(dataArray, callBack) { | |||
// JLSDK.ESAMChannel_CmdArray(dataArray, callBack); | |||
// } | |||
/** | |||
* ICC复位 | |||
* @param {回调方法} callBack | |||
*/ | |||
// function ICCReset(callBack) { | |||
// JLSDK.ICCReset((res) => { | |||
// callBack.call(this, res); | |||
// }) | |||
// } | |||
/** | |||
* ICC通道透传 | |||
* @param {透传数据} data | |||
* @param {回调方法} callBack | |||
*/ | |||
// function ICCChannel(data, callBack) { | |||
// JLSDK.ICCChannel(data, (res) => { | |||
// callBack.call(this, res); | |||
// }) | |||
// } | |||
// function ICCChannelArray(dataArray, callBack) { | |||
// JLSDK.ICCChannel_CmdArray(dataArray, callBack); | |||
// } | |||
export function transCmd(cmdArray, cmdtype, callback) { | |||
if (cmdtype == '10') { | |||
JLSDK.ICCChannel_CmdArray(cmdArray, callback); | |||
} //写卡 | |||
if (cmdtype == '20') { | |||
JLSDK.ESAMChannel_CmdArray(cmdArray, callback); | |||
} | |||
} //写设备 |
@@ -0,0 +1 @@ | |||
function strToHexCharCode(str){if(str==="")return"";var hexCharCode=[];for(var i=0;i<str.length;i++){hexCharCode.push((str.charCodeAt(i)).toString(16))}return hexCharCode.join("").toUpperCase()}function bccCheck(data){var bcc='';for(var a=0;a<data.length/2;a++){bcc^=parseInt(data.substring(2*a,2*a+2),16)}if(bcc.length==1){bcc='0'+bcc}return tenToHex(bcc,2).toUpperCase()}function tenToHex(num,len,boo){var hex=num.toString(16);var zero='';for(var a=0;a<len-hex.length;a++){zero+='0'}var ret='';if(boo){if(hex.length%2==0){}else{hex='0'+hex;zero=zero.substring(1)}ret=hex+zero}else if(!boo){ret=zero+hex}return ret.toUpperCase()}function hexToString(str){var trimedStr=str.trim();var rawStr=trimedStr.substr(0,2).toLowerCase()==="0x"?trimedStr.substr(2):trimedStr;var len=rawStr.length;if(len%2!==0){alert("Illegal Format ASCII Code!");return""}var curCharCode;var resultStr=[];for(var i=0;i<len;i=i+2){curCharCode=parseInt(rawStr.substr(i,2),16);resultStr.push(String.fromCharCode(curCharCode))}return resultStr.join("").toUpperCase()}function encodeUtf8(text){const code=encodeURIComponent(text);const bytes=[];for(var i=0;i<code.length;i++){const c=code.charAt(i);if(c==='%'){const hex=code.charAt(i+1)+code.charAt(i+2);const hexVal=parseInt(hex,16);bytes.push(hexVal);i+=2}else bytes.push(c.charCodeAt(0))}return bytes}function hexToTen(sixteen){var ten=parseInt(sixteen,16);return ten}function str2utf8(str){var code;var utf="";for(var i=0;i<str.length;i++){code=str.charCodeAt(i);if(code<0x0080){utf+=str.charAt(i)}else if(code<0x0800){utf+=String.fromCharCode(0xC0|((code>>6)&0x1F));utf+=String.fromCharCode(0x80|((code>>0)&0x3F))}else if(code<0x10000){utf+=String.fromCharCode(0xE0|((code>>12)&0x0F));utf+=String.fromCharCode(0x80|((code>>6)&0x3F));utf+=String.fromCharCode(0x80|((code>>0)&0x3F))}else{throw"不是UCS-2字符集";}}return utf}function hexTobin(str){str=str.toUpperCase();let hex_array=[{key:0,val:"0000"},{key:1,val:"0001"},{key:2,val:"0010"},{key:3,val:"0011"},{key:4,val:"0100"},{key:5,val:"0101"},{key:6,val:"0110"},{key:7,val:"0111"},{key:8,val:"1000"},{key:9,val:"1001"},{key:'A',val:"1010"},{key:'B',val:"1011"},{key:'C',val:"1100"},{key:'D',val:"1101"},{key:'E',val:"1110"},{key:'F',val:"1111"}];let value="";for(let i=0;i<str.length;i++){for(let j=0;j<hex_array.length;j++){if(str.charAt(i)==hex_array[j].key){value=value.concat(hex_array[j].val);break}}}return value}function binTohex(str){let hex_array=[{key:0,val:"0000"},{key:1,val:"0001"},{key:2,val:"0010"},{key:3,val:"0011"},{key:4,val:"0100"},{key:5,val:"0101"},{key:6,val:"0110"},{key:7,val:"0111"},{key:8,val:"1000"},{key:9,val:"1001"},{key:'a',val:"1010"},{key:'b',val:"1011"},{key:'c',val:"1100"},{key:'d',val:"1101"},{key:'e',val:"1110"},{key:'f',val:"1111"}];let value='';let list=[];if(str.length%4!==0){let a="0000";let b=a.substring(0,4-str.length%4);str=b.concat(str)}while(str.length>4){list.push(str.substring(0,4));str=str.substring(4)}list.push(str);for(let i=0;i<list.length;i++){for(let j=0;j<hex_array.length;j++){if(list[i]==hex_array[j].val){value=value.concat(hex_array[j].key);break}}}return value}function strToBuffer(cmd){let buffer=new ArrayBuffer(cmd.length/2);let dataView=new Uint8Array(buffer);for(var a=0;a<cmd.length/2;a++){dataView[a]='0x'+cmd.substring(2*a,2*a+2)}return buffer}function bufferTohex(buffer){var hexArr=Array.prototype.map.call(new Uint8Array(buffer),function(bit){return('00'+bit.toString(16)).slice(-2)});return hexArr.join('')}function isEmpty(data){if(data.length==0||data==null||data=='undefined'){return true}return false}module.exports={encodeUtf8:encodeUtf8,tenToHex:tenToHex,hexToTen:hexToTen,bccCheck:bccCheck,hexToString:hexToString,strToHexCharCode:strToHexCharCode,str2utf8:str2utf8,hexTobin:hexTobin,binTohex:binTohex,isEmpty:isEmpty,strToBuffer:strToBuffer,bufferTohex:bufferTohex} |
@@ -0,0 +1,100 @@ | |||
!function (root, factory) { | |||
if (typeof module === 'object' && module.exports) | |||
module.exports = factory(); | |||
else | |||
root.onfire = factory(); | |||
}(typeof window !== 'undefined' ? window : this, function () { | |||
var __onfireEvents = {}, | |||
__cnt = 0, // evnet counter | |||
string_str = 'string', | |||
function_str = 'function', | |||
hasOwnKey = Function.call.bind(Object.hasOwnProperty), | |||
slice = Function.call.bind(Array.prototype.slice); | |||
function _bind(eventName, callback, is_one, context) { | |||
if (typeof eventName !== string_str || typeof callback !== function_str) { | |||
throw new Error('args: '+string_str+', '+function_str+''); | |||
} | |||
if (! hasOwnKey(__onfireEvents, eventName)) { | |||
__onfireEvents[eventName] = {}; | |||
} | |||
__onfireEvents[eventName][++__cnt] = [callback, is_one, context]; | |||
return [eventName, __cnt]; | |||
} | |||
function _each(obj, callback) { | |||
for (var key in obj) { | |||
if (hasOwnKey(obj, key)) callback(key, obj[key]); | |||
} | |||
} | |||
function on(eventName, callback, context) { | |||
return _bind(eventName, callback, 0, context); | |||
} | |||
function one(eventName, callback, context) { | |||
return _bind(eventName, callback, 1, context); | |||
} | |||
function _fire_func(eventName, args) { | |||
if (hasOwnKey(__onfireEvents, eventName)) { | |||
_each(__onfireEvents[eventName], function(key, item) { | |||
item[0].apply(item[2], args); | |||
if (item[1]) delete __onfireEvents[eventName][key]; | |||
}); | |||
} | |||
} | |||
function fire(eventName) { | |||
var args = slice(arguments, 1); | |||
setTimeout(function () { | |||
_fire_func(eventName, args); | |||
}); | |||
} | |||
function fireSync(eventName) { | |||
_fire_func(eventName, slice(arguments, 1)); | |||
} | |||
function un(event) { | |||
var eventName, key, r = false, type = typeof event; | |||
if (type === string_str) { | |||
if (hasOwnKey(__onfireEvents, event)) { | |||
delete __onfireEvents[event]; | |||
return true; | |||
} | |||
return false; | |||
} | |||
else if (type === 'object') { | |||
eventName = event[0]; | |||
key = event[1]; | |||
if (hasOwnKey(__onfireEvents, eventName) && hasOwnKey(__onfireEvents[eventName], key)) { | |||
delete __onfireEvents[eventName][key]; | |||
return true; | |||
} | |||
return false; | |||
} | |||
else if (type === function_str) { | |||
_each(__onfireEvents, function(key_1, item_1) { | |||
_each(item_1, function(key_2, item_2) { | |||
if (item_2[0] === event) { | |||
delete __onfireEvents[key_1][key_2]; | |||
r = true; | |||
} | |||
}); | |||
}); | |||
return r; | |||
} | |||
return true; | |||
} | |||
function clear() { | |||
__onfireEvents = {}; | |||
} | |||
return { | |||
on: on, | |||
one: one, | |||
un: un, | |||
fire: fire, | |||
fireSync: fireSync, | |||
clear: clear | |||
}; | |||
}); |
@@ -4,8 +4,6 @@ | |||
// const jlApi = require("../etc/JLAPI/JLObuSDK.js"); | |||
// import * as jlApi from '../../lib/etc/JLAPI/JLObuSDK.js' | |||
const jyApi = require("../etc/JYAPI/GenvictBleUtil.js"); | |||
// import * as jyApi from '../../lib/etc/JYAPI/GenvictBleUtil.js' | |||
const jlQZApi = require("../etc/JLQZAPI/JLObuSDK.js"); | |||
// import * as jlQZApi from '../../lib/etc/JLQZAPI/JLObuSDK.js' | |||
const atApi = require("../etc/ATAPI/ArtcBleUtil.js"); | |||
// import * as atApi from '../../lib/etc/ATAPI/ArtcBleUtil.js' | |||
@@ -23,9 +21,10 @@ const zzApi = require("../etc/WJAPI/wjBleAPI.js"); | |||
const datas = require("./datas.js"); | |||
// import * as datas from '../../../utils/common/datas.js'; | |||
const tools = require('./tools.js'); | |||
const jlApi = require("../../static/etc/JLAPI/JLObuSDK.js"); //聚力SDK | |||
let jlApi = require("../../static/etc/JLAPI/JLObuSDK.js"); //聚力SDK | |||
const wjApi = require("../etc/WJAPI/wjBleAPI"); | |||
let tdApi = require("../etc/TDAPI/TDRObuSDK.js"); | |||
const jlQZApi = require("../etc/JLQZAPI/JLObuSDK.js"); | |||
import { | |||
getItem | |||
} from "../../utils/storage"; | |||
@@ -33,6 +32,7 @@ import { | |||
if (getItem('environment') == 'ZFB') { | |||
tdApi = require("../etc/TDRAPI/TDRObuSDK.js"); | |||
jlApi = require("../etc/JLObuSDK/JLObuSDK.js"); | |||
} | |||
/** |