左晓为主开发手持机充值管理机
zuoxiao
2024-03-15 96232cdfabd4488b8e1d4d37fa36293adcbe2879
app/src/main/java/com/dayu/recharge/tools/NFCWriteHelper.java
@@ -66,7 +66,7 @@
    public boolean writeData(byte[] str, int a, int b) {
        Log.i("NFCWreatActivity", "writeData: a=" + a + " b=" + b);
        //写卡时修改所有密码
//        changePasword(a);
        changePasword(a);
        if (str.length <= 16) {
            try {
                MifareClassic mfc = MifareClassic.get(tag);
@@ -142,7 +142,7 @@
                        data[i] = dataA[i];
                    }
                    //输入控制位
                    data[6] = (byte) 0xff;
                    data[6] = (byte) 0xFF;
                    data[7] = (byte) 0x07;
                    data[8] = (byte) 0x80;
                    data[9] = (byte) 0x69;
@@ -155,6 +155,11 @@
                    int bCount = mfc.getBlockCountInSector(a);
                    //写到扇区的最后一个块
                    mfc.writeBlock(bIndex + bCount - 1, data);
//                    byte[] dataa = mfc.readBlock(bIndex + bCount - 1);
//                    // 修改密码 A
//                    mfc.writeBlock(mfc.sectorToBlock(a) + 3, dataA);
//                    // 修改密码 B
//                    mfc.writeBlock(mfc.sectorToBlock(a) + 7, dataB);
                }
                return true;
            } catch (Exception e) {