nfc读写m1卡的方法

sun0095 2016-02-19 10:57:58
求大牛指导,什么方法能读写m1卡制定的某个扇区?
...全文
1438 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_37169401 2018-06-14
  • 打赏
  • 举报
回复
//TODO 补充一个读取扇区的方法 public String readTag(Tag tag){ if (tag==null){ return ""; } MifareClassic mfc = MifareClassic.get(tag); boolean auth = false; try { mfc.connect(); String metaInfo = ""; int type = mfc.getType();//获取TAG的类型 获得MifareClassic标签的具体类型 int sectorCount = mfc.getSectorCount();//获取TAG中包含的扇区数 String types = ""; switch (type) { case MifareClassic.TYPE_CLASSIC: types = "TYPE_CLASSIC"; break; case MifareClassic.TYPE_PLUS: types = "TYPE_PLUS"; break; case MifareClassic.TYPE_PRO: types = "TYPE_PRO"; break; case MifareClassic.TYPE_UNKNOWN: types = "TYPE_UNKNOWN"; break; } //getBlockCount():获得标签总共有的的块数量; metaInfo +="卡片类型:" + types + "\n共" + sectorCount + "个扇区\n共" + mfc.getBlockCount() + "个块\n存储空间: " + mfc.getSize() + "B\n"; for (int i = 0; i < sectorCount; i++) { //验证当前扇区的KeyA密码,返回值为ture或false。 auth = mfc.authenticateSectorWithKeyA(i,MifareClassic.KEY_DEFAULT); int bCount; int bIndex; if (auth){ metaInfo +="Sector " + i + ":验证成功\n"; bCount = mfc.getBlockCountInSector(i);//获得当前扇区的所包含块的数量; bIndex = mfc.sectorToBlock(i);//当前扇区的第1块的块号; for (int j = 0; j < bCount; j++) { //读取当前块的数据。 byte[] bytes = mfc.readBlock(bIndex); metaInfo += "Block " + bIndex + " : " + printHexBinary(bytes) + "\n"; bIndex++; } } else { metaInfo += "Sector " + i + ":验证失败\n"; } } return metaInfo; } catch (IOException e) { Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); e.printStackTrace(); }finally { if (mfc!=null){ try { mfc.close(); } catch (IOException e) { Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG) .show(); } } } return null; }
City_Savage 2016-04-24
  • 打赏
  • 举报
回复
应该MCT算同类软件里比较好的了。 https://github.com/ikarus23/MifareClassicTool
doge0_0 2016-03-05
  • 打赏
  • 举报
回复
MCT工具 不用谢
敌花师 2016-02-26
  • 打赏
  • 举报
回复
没试过读M1芯片,读过rfid巡更点

80,471

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧