最近更新换代的项目终端设备都要求国产系统,大家都知道现在所谓的国产系统,桌面式一般就是麒麟和统信两家,如果是嵌入式开发板之类的,则有鸿蒙可选,后面还有个星光麒麟(兼容安卓)可以不考虑先。
索性公司所有的身份证阅读器、社保卡读卡器、IC卡读写器、二维码扫码等产品都花时间弄了一套鸿蒙系统的SDK。
适配机型:EST-100、EST-100G、EST-J13X、EST-100GS等,支持USB免驱和串口两种方式。
鸿蒙测试版本:OpenHarmony 3.2 、4.0
demo开发语言:ArkTS,支持定制提供C语言调用的so库开发使用。
下面是鸿蒙的demo测试界面截图:
ArkTS代码如下:
import CommonContants from '../common/CommonContants';
import DonseeDevice from '@ohos/DonseeDevice/src/main/ets/model/DonseeDevice';
import { IDCardInfor } from '@ohos/DonseeDevice/src/main/ets/model/IDCardInfor';
import { SSCardInfor } from '@ohos/DonseeDevice/src/main/ets/model/SSCardInfor';
import util from '@ohos.util';
/**
* Card content contains the information list.
* 广东东信智能科技有限公司www.eastcoms.com
* EST-100身份证阅读器、社保卡读卡器鸿蒙系统SDK开发包
*/
@Component
export struct SSCardComponent {
@State tvResult: string = '';
@State pKkey: string = '01020304050607080102030405060708||';
@State slot : number = 1;//卡座 ,默认选中sam1
private textInputController: TextInputController = new TextInputController();
build() {
Column() {
Row() {
Column() {
Row() {
Text("pkey:")
.fontSize(18)
TextInput({ controller: this.textInputController,text:'01020304050607080102030405060708||' })
.type(InputType.Normal)
.height(32)
.margin({ left: $r('app.float.text_input_margin_left') })
.layoutWeight(CommonContants.TEXTINPUT_LAYOUT_WEIGHT)
.onChange(value => {
this.pKkey = value
})
}
Text(this.tvResult)
.fontSize(18)
Text("").layoutWeight(1)
}
.layoutWeight(1)
.margin({left:10})
.alignItems(HorizontalAlign.Start)
Column() {
Column() {
Row() {
Text('SAM卡座选择:')
}.margin({ left: 10 })
Row() {
Radio({ value: "SCard", group: "3" })
.checked(this.slot === 1 ? true : false)
.height(20)
.width(20)
.onClick(() => {
this.slot = 1;
console.info("Radio onClick")
})
Text('SAM1')
Radio({ value: "SCard", group: "3" })
.checked(this.slot === 2 ? true : false)
.height(20)
.width(20)
.onClick(() => {
this.slot = 2;
console.info("Radio onClick")
}).margin({ left: 10 })
Text('SAM2')
}.margin({ left: 10 })
Row() {
Radio({ value: "SCard", group: "3" })
.checked(this.slot === 3 ? true : false)
.height(20)
.width(20)
.onClick(() => {
this.slot = 3;
console.info("Radio onClick")
})
Text('SAM3')
Radio({ value: "SCard", group: "3" })
.checked(this.slot === 4 ? true : false)
.height(20)
.width(20)
.onClick(() => {
this.slot = 4;
console.info("Radio onClick")
}).margin({ left: 10 })
Text('SAM4')
}.margin({ left: 10 })
Row() {
Radio({ value: "SCard", group: "3" })
.checked(this.slot === 0 ? true : false)
.height(20)
.width(20)
.onClick(() => {
this.slot = 0;
console.info("Radio onClick")
}).margin({ left: 15 })
Text('无').margin({ left: 10 })
}
}.justifyContent(FlexAlign.Start)
.alignItems(HorizontalAlign.Start)
Row() {
Button("读取社保卡")
.fontSize($r('app.float.submit_button_font_size'))
.fontWeight(CommonContants.FONT_WEIGHT)
.height(20)
.width(95)
.onClick(() => {
//nType 1, 有SAM卡返回全部信息 2, 无SAM卡返回卡号
var nType = 1
if (this.slot == 0) {
nType = 2
}
console.info("nType = " + nType)
console.info("this.slot = " + this.slot)
let ssCardInfor: SSCardInfor = DonseeDevice.Donsee_ReadSSCardPre(this.slot, nType)
console.info("ssCardInfor.result = " + ssCardInfor.result)
if (ssCardInfor.result == 0) {
DonseeDevice.Donsee_Beep(50)
// const str = new util.TextDecoder('gbk').decode(ssCardInfor.name)
// let gbkDecoder = new util.TextDecoder("gbk",{ignoreBOM: true});
console.info("ssCardInfor.name = " + ssCardInfor.nation)
console.info("ssCardInfor.name = " + ssCardInfor.name)
// this.tvResult = "姓 名:"+ ssCardInfor.name
this.tvResult = "姓 名:" + ssCardInfor.name + "\n"
+ "性 别:" + ssCardInfor.sex + "\n"
+ "民 族:" + ssCardInfor.nation + "\n"
+ "出身日期:" + ssCardInfor.birthday + "\n"
+ "城市代码:" + ssCardInfor.city + "\n"
+ "身份证号:" + ssCardInfor.idnumber + "\n"
+ "社保卡号:" + ssCardInfor.cardnumber + "\n"
+ "开始有效期限:" + ssCardInfor.signdate + "\n"
+ "结束有效期限:" + ssCardInfor.validterm + "\n"
+ "社保版本:" + ssCardInfor.cardveVrsion + "\n"
} else {
this.tvResult = "读卡失败:" + ssCardInfor.result+"\n errMsg = "+ssCardInfor.errMsg.trim()
}
})
Button("读基本信息")
.fontSize($r('app.float.submit_button_font_size'))
.fontWeight(CommonContants.FONT_WEIGHT)
.height(20)
.width(95)
.onClick(() => {
let [result, data] = DonseeDevice.Donsee_iReadCardBas(3)
if (result == 0) {
DonseeDevice.Donsee_Beep(50)
this.tvResult = "读基本信息成功:" + data
} else {
this.tvResult = "读基本信息失败:" + result
}
})
}.margin({ top: 10 })
Row() {
Button("加密步骤1")
.fontSize($r('app.float.submit_button_font_size'))
.fontWeight(CommonContants.FONT_WEIGHT)
.height(20)
.width(95)
.onClick(() => {
let [result, data] = DonseeDevice.Donsee_iReadCardBas_HSM_Step1(3)
if (result == 0) {
DonseeDevice.Donsee_Beep(50)
this.tvResult = "读卡成功:" + data
} else {
this.tvResult = "读卡失败:" + result
}
})
Button("加密步骤2")
.fontSize($r('app.float.submit_button_font_size'))
.fontWeight(CommonContants.FONT_WEIGHT)
.height(20)
.width(95)
.onClick(() => {
let [result, data] = DonseeDevice.Donsee_iReadCardBas_HSM_Step2(this.pKkey)
if (result == 0) {
DonseeDevice.Donsee_Beep(50)
this.tvResult = "读卡成功:" + data
} else {
this.tvResult = "读卡失败:" + result
}
})
} .margin({ top: 10 })
}.justifyContent(FlexAlign.End)
.margin({right:10})
}.justifyContent(FlexAlign.Start)
.width(CommonContants.FULL_PARENT)
}.justifyContent(FlexAlign.Start)
.backgroundColor($r('app.color.card_background'))
.width(CommonContants.FULL_PARENT)
.height(CommonContants.FULL_PARENT)
}
}