Qt C++读写NFC标签NDEF网址URI

本示例使用的发卡器:https://item.taobao.com/item.htm?spm=a21dvs.23580594.0.0.1d292c1biFgjSs&ft=t&id=615391857885 

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include "QLibrary"
#include "QMessageBox"
#include <exception>

unsigned char mypicoldkey[6]={0x19,0x74,0x02,0x02,0x01,0x11};   //旧密钥
unsigned char mypicnewkey[6]={0x19,0x74,0x02,0x02,0x01,0x11};   //新密钥,可自行设置

//本示例可在windows、linux系统内编译、运行,自动判断windows系统加载DLL库、linux系统加载SO库----------------------------------------------------------------------------------------------------------------------------------------------
//让读写器发出声音
typedef  unsigned char (*pcdbeep)(unsigned long xms);
#ifdef Q_OS_WIN
    pcdbeep mypcdbeep = (pcdbeep)QLibrary("OUR_MIFARE.dll").resolve("pcdbeep");
#else
    pcdbeep mypcdbeep = (pcdbeep)QLibrary("./libOURMIFARE.so").resolve("pcdbeep");
#endif

//返回本读写器独一无二的设备编号
typedef  unsigned char (*pcdgetdevicenumber)(unsigned char *devicenumber);
#ifdef Q_OS_WIN
    pcdgetdevicenumber mypcdgetdevicenumber = (pcdgetdevicenumber)QLibrary("OUR_MIFARE.dll").resolve("pcdgetdevicenumber");
#else
    pcdgetdevicenumber mypcdgetdevicenumber = (pcdgetdevicenumber)QLibrary("./libOURMIFARE.so").resolve("pcdgetdevicenumber");
#endif

//清空MifareClass卡类标签NDEF数据缓冲
    typedef  unsigned char (*tagbuf_clear)();
#ifdef Q_OS_WIN
    tagbuf_clear mytagbuf_clear = (tagbuf_clear)QLibrary("OUR_MIFARE.dll").resolve("tagbuf_clear");
#else
    tagbuf_clear mytagbuf_clear = (tagbuf_clear)QLibrary("./libOURMIFARE.so").resolve("tagbuf_clear");
#endif

//清空ForumType4类标签NDEF数据缓冲
    typedef  unsigned char (*tagbuf_forumtype4_clear)();
#ifdef Q_OS_WIN
    tagbuf_forumtype4_clear mytagbuf_forumtype4_clear = (tagbuf_forumtype4_clear)QLibrary("OUR_MIFARE.dll").resolve("tagbuf_forumtype4_clear");
#else
    tagbuf_forumtype4_clear mytagbuf_forumtype4_clear = (tagbuf_forumtype4_clear)QLibrary("./libOURMIFARE.so").resolve("tagbuf_forumtype4_clear");
#endif

//轻松读Ntag卡
typedef  unsigned char (*piccreadex_ntag)(unsigned char ctrlword,unsigned char *serial,unsigned char *pickey,unsigned char blockadd,unsigned char blocksize,unsigned char *picdata);
#ifdef Q_OS_WIN
    piccreadex_ntag mypiccreadex_ntag = (piccreadex_ntag)QLibrary("OUR_MIFARE.dll").resolve("piccreadex_ntag");
#else
    piccreadex_ntag mypiccreadex_ntag = (piccreadex_ntag)QLibrary("./libOURMIFARE.so").resolve("piccreadex_ntag");
#endif

//轻松读15693卡
typedef unsigned char (*iso15693readex)(unsigned char ctrlword,unsigned char afi,unsigned char startblock,unsigned char blocknum,unsigned char *uid,unsigned char *piccdatabuf);
#ifdef Q_OS_WIN
    iso15693readex myiso15693readex = (iso15693readex)QLibrary("OUR_MIFARE.dll").resolve("iso15693readex");
#else
    iso15693readex myiso15693readex = (iso15693readex)QLibrary("./libOURMIFARE.so").resolve("iso15693readex");
#endif

//轻松读M1卡
typedef unsigned char (*piccreadex)(unsigned char ctrlword,unsigned char *serial,unsigned char area,unsigned char keyA1B0,unsigned char *picckey,unsigned char *piccdata0_2);
#ifdef Q_OS_WIN
    piccreadex mypiccreadex = (piccreadex)QLibrary("OUR_MIFARE.dll").resolve("piccreadex");
#else
    piccreadex mypiccreadex = (piccreadex)QLibrary("./libOURMIFARE.so").resolve("piccreadex");
#endif

//寻forumtype4
typedef unsigned char (*forumtype4request)(unsigned char ctrlword,unsigned char *serial,unsigned char *seriallen);
#ifdef Q_OS_WIN
    forumtype4request myforumtype4request = (forumtype4request)QLibrary("OUR_MIFARE.dll").resolve("forumtype4request");
#else
    forumtype4request myforumtype4request = (forumtype4request)QLibrary("./libOURMIFARE.so").resolve("forumtype4request");
#endif

//将ndef记录缓冲数据写入forumtype2标签
typedef unsigned char (*forumtype2_write_ndeftag)(unsigned char ctrlword,unsigned char *serial,unsigned char *oldkey);
#ifdef Q_OS_WIN
    forumtype2_write_ndeftag myforumtype2_write_ndeftag = (forumtype2_write_ndeftag)QLibrary("OUR_MIFARE.dll").resolve("forumtype2_write_ndeftag");
#else
    forumtype2_write_ndeftag myforumtype2_write_ndeftag = (forumtype2_write_ndeftag)QLibrary("./libOURMIFARE.so").resolve("forumtype2_write_ndeftag");
#endif

//读取forumtype2标签信息
typedef unsigned char (*forumtype2_read_ndeftag)(unsigned char ctrlword,unsigned char *serial,unsigned char *oldkey);
#ifdef Q_OS_WIN
    forumtype2_read_ndeftag myforumtype2_read_ndeftag = (forumtype2_read_ndeftag)QLibrary("OUR_MIFARE.dll").resolve("forumtype2_read_ndeftag");
#else
    forumtype2_read_ndeftag myforumtype2_read_ndeftag = (forumtype2_read_ndeftag)QLibrary("./libOURMIFARE.so").resolve("forumtype2_read_ndeftag");
#endif

//将ndef记录缓冲数据写入forumtype5 15693标签
typedef unsigned char (*forumtype5_write_ndeftag)(unsigned char ctrlword,unsigned char afi,unsigned char *serial);
#ifdef Q_OS_WIN
    forumtype5_write_ndeftag myforumtype5_write_ndeftag = (forumtype5_write_ndeftag)QLibrary("OUR_MIFARE.dll").resolve("forumtype5_write_ndeftag");
#else
    forumtype5_write_ndeftag myforumtype5_write_ndeftag = (forumtype5_write_ndeftag)QLibrary("./libOURMIFARE.so").resolve("forumtype5_write_ndeftag");
#endif

//读取forumtype5 15693标签信息
typedef unsigned char (*forumtype5_read_ndeftag)(unsigned char ctrlword,unsigned char afi,unsigned char *serial);
#ifdef Q_OS_WIN
    forumtype5_read_ndeftag myforumtype5_read_ndeftag = (forumtype5_read_ndeftag)QLibrary("OUR_MIFARE.dll").resolve("forumtype5_read_ndeftag");
#else
    forumtype5_read_ndeftag myforumtype5_read_ndeftag = (forumtype5_read_ndeftag)QLibrary("./libOURMIFARE.so").resolve("forumtype5_read_ndeftag");
#endif

//将ndef记录缓冲数据写入mifareclass标签
typedef unsigned char (*piccwrite_ndeftag)(unsigned char ctrlword,unsigned char *serial,unsigned char *oldkey,unsigned char *newkey);
#ifdef Q_OS_WIN
    piccwrite_ndeftag mypiccwrite_ndeftag = (piccwrite_ndeftag)QLibrary("OUR_MIFARE.dll").resolve("piccwrite_ndeftag");
#else
    piccwrite_ndeftag mypiccwrite_ndeftag = (piccwrite_ndeftag)QLibrary("./libOURMIFARE.so").resolve("piccwrite_ndeftag");
#endif

//读取mifareclass标签信息
typedef unsigned char (*piccread_ndeftag)(unsigned char ctrlword,unsigned char *serial,unsigned char *oldkey);
#ifdef Q_OS_WIN
    piccread_ndeftag mypiccread_ndeftag = (piccread_ndeftag)QLibrary("OUR_MIFARE.dll").resolve("piccread_ndeftag");
#else
    piccread_ndeftag mypiccread_ndeftag = (piccread_ndeftag)QLibrary("./libOURMIFARE.so").resolve("piccread_ndeftag");
#endif

//将ndef记录缓冲数据写入forumtype4标签
typedef unsigned char (*forumtype4_write_ndeftag)(unsigned char ctrlword,unsigned char *serial,unsigned char *seriallen,unsigned char *newkey);
#ifdef Q_OS_WIN
    forumtype4_write_ndeftag myforumtype4_write_ndeftag = (forumtype4_write_ndeftag)QLibrary("OUR_MIFARE.dll").resolve("forumtype4_write_ndeftag");
#else
    forumtype4_write_ndeftag myforumtype4_write_ndeftag = (forumtype4_write_ndeftag)QLibrary("./libOURMIFARE.so").resolve("forumtype4_write_ndeftag");
#endif

//读取forumtype4标签信息
typedef unsigned char (*forumtype4_read_ndeftag)(unsigned char ctrlword,unsigned char *serial,unsigned char *seriallen,unsigned char *oldkey);
#ifdef Q_OS_WIN
    forumtype4_read_ndeftag myforumtype4_read_ndeftag = (forumtype4_read_ndeftag)QLibrary("OUR_MIFARE.dll").resolve("forumtype4_read_ndeftag");
#else
    forumtype4_read_ndeftag myforumtype4_read_ndeftag = (forumtype4_read_ndeftag)QLibrary("./libOURMIFARE.so").resolve("forumtype4_read_ndeftag");
#endif

//解析缓冲区内NDEF记录tagbuf_read
typedef unsigned char (*tagbuf_read)(unsigned char *mypiccdata,unsigned char *revstrlen,unsigned char *recordnumber);
#ifdef Q_OS_WIN
    tagbuf_read mytagbuf_read = (tagbuf_read)QLibrary("OUR_MIFARE.dll").resolve("tagbuf_read");
#else
    tagbuf_read mytagbuf_read = (tagbuf_read)QLibrary("./libOURMIFARE.so").resolve("tagbuf_read");
#endif

//锁定Ntag标签页数据
typedef  unsigned char (*picclock_ntag)(unsigned char locktype,unsigned char *mypicclockdata);
#ifdef Q_OS_WIN
    picclock_ntag mypicclock_ntag = (picclock_ntag)QLibrary("OUR_MIFARE.dll").resolve("picclock_ntag");
#else
    picclock_ntag mypicclock_ntag = (picclock_ntag)QLibrary("./libOURMIFARE.so").resolve("picclock_ntag");
#endif

//初始化Ntag卡,开启读写卡密码保护功能
typedef  unsigned char (*piccinit_ntag)(unsigned char ctrlword,unsigned char *serial,unsigned char *pickey,unsigned char *configdata);
#ifdef Q_OS_WIN
    piccinit_ntag mypiccinit_ntag = (piccinit_ntag)QLibrary("OUR_MIFARE.dll").resolve("piccinit_ntag");
#else
    piccinit_ntag mypiccinit_ntag = (piccinit_ntag)QLibrary("./libOURMIFARE.so").resolve("piccinit_ntag");
#endif

//生成NDEF文本记录数据缓冲tagbuf_addtext
typedef unsigned char (*tagbuf_addtext)(unsigned char *languagecodestr,int languagecodestrlen,unsigned char *textstr,int textstrlen);
#ifdef Q_OS_WIN
    tagbuf_addtext mytagbuf_addtext = (tagbuf_addtext)QLibrary("OUR_MIFARE.dll").resolve("tagbuf_addtext");
#else
    tagbuf_addtext mytagbuf_addtext = (tagbuf_addtext)QLibrary("./libOURMIFARE.so").resolve("tagbuf_addtext");
#endif

//生成NDEF唤醒android.com:pkg APP
typedef unsigned char (*tagbuf_addapp)(unsigned char *packagestr,int packagestrlen);
#ifdef Q_OS_WIN
    tagbuf_addapp mytagbuf_addapp = (tagbuf_addapp)QLibrary("OUR_MIFARE.dll").resolve("tagbuf_addapp");
#else
    tagbuf_addapp mytagbuf_addapp = (tagbuf_addapp)QLibrary("./libOURMIFARE.so").resolve("tagbuf_addapp");
#endif

//生成NDEF唤醒任意类型APP
typedef unsigned char (*tagbuf_addapp1)(unsigned char *packagestr,int packagestrlen,unsigned char *typestr,int typelen);
#ifdef Q_OS_WIN
    tagbuf_addapp1 mytagbuf_addapp1 = (tagbuf_addapp1)QLibrary("OUR_MIFARE.dll").resolve("tagbuf_addapp1");
#else
    tagbuf_addapp1 mytagbuf_addapp1 = (tagbuf_addapp1)QLibrary("./libOURMIFARE.so").resolve("tagbuf_addapp1");
#endif

//生成NDEF网址URI记录数据缓冲tagbuf_adduri
typedef unsigned char (*tagbuf_adduri)(unsigned char *languagecodestr,int languagecodestrlen,unsigned char *textstr,int textstrlen,int uriheaderindex,unsigned char *uristr,int uristrlen);
#ifdef Q_OS_WIN
    tagbuf_adduri mytagbuf_adduri = (tagbuf_adduri)QLibrary("OUR_MIFARE.dll").resolve("tagbuf_adduri");
#else
    tagbuf_adduri mytagbuf_adduri = (tagbuf_adduri)QLibrary("./libOURMIFARE.so").resolve("tagbuf_adduri");
#endif

//生成NDEF蓝牙连接数据缓冲
typedef unsigned char (*tagbuf_addbluetooth)(unsigned char *blenamestr,int blenamestrlen,unsigned char *blemac);
#ifdef Q_OS_WIN
    tagbuf_addbluetooth mytagbuf_addbluetooth = (tagbuf_addbluetooth)QLibrary("OUR_MIFARE.dll").resolve("tagbuf_addbluetooth");
#else
    tagbuf_addbluetooth mytagbuf_addbluetooth = (tagbuf_addbluetooth)QLibrary("./libOURMIFARE.so").resolve("tagbuf_addbluetooth");
#endif

//生成NDEF热点wifi连接数据缓冲
typedef unsigned char (*tagbuf_addwifi)(unsigned char *ssidstr,int ssidstrlen,int authtype,int crypttype,unsigned char *keystr,int keystrlen);
#ifdef Q_OS_WIN
    tagbuf_addwifi mytagbuf_addwifi = (tagbuf_addwifi)QLibrary("OUR_MIFARE.dll").resolve("tagbuf_addwifi");
#else
    tagbuf_addwifi mytagbuf_addwifi = (tagbuf_addwifi)QLibrary("./libOURMIFARE.so").resolve("tagbuf_addwifi");
#endif

//生成NDEF电子名片数据缓冲
typedef unsigned char (*tagbuf_addbusinesscard)(unsigned char *infostr,int infostrlen);
#ifdef Q_OS_WIN
    tagbuf_addbusinesscard mytagbuf_addbusinesscard = (tagbuf_addbusinesscard)QLibrary("OUR_MIFARE.dll").resolve("tagbuf_addbusinesscard");
#else
    tagbuf_addbusinesscard mytagbuf_addbusinesscard = (tagbuf_addbusinesscard)QLibrary("./libOURMIFARE.so").resolve("tagbuf_addbusinesscard");
#endif

//生成NDEF新数据类型
typedef unsigned char (*tagbuf_adddata)(unsigned char *typestr,int typestrlen,unsigned char *datastr,int datastrlen);
#ifdef Q_OS_WIN
    tagbuf_adddata mytagbuf_adddata = (tagbuf_adddata)QLibrary("OUR_MIFARE.dll").resolve("tagbuf_adddata");
#else
    tagbuf_adddata mytagbuf_adddata = (tagbuf_adddata)QLibrary("./libOURMIFARE.so").resolve("tagbuf_adddata");
#endif


//检测动态库文件是否在运行目录内----------------------------------------------------------------------------------------------------------------------------------------------------------
static bool checkdllos(){
    #ifdef Q_OS_WIN
        QLibrary mylib("OUR_MIFARE.dll");
        if (!mylib.load()){                //判断windows系统下,OUR_MIFARE.dll是否在运行目录内
            QMessageBox::information(NULL, "提示", "请将OUR_MIFARE.dll文件拷贝到生成exe文件相同目录下!");
            return false;
        }else{return true;}
    #else
        QLibrary mylib("./libOURMIFARE.so");
        if (!mylib.load()){                //判断linux系统下,libOURMIFARE.so是否正运行目录内
            QMessageBox::information(NULL, "提示", "请将libOURMIFARE.so文件拷贝到生成的运行文件相同目录下!");
            return false;
        }else{return true;}
    #endif
}

//判断发卡器感应区内标签类型----------------------------------------------------------------------------------------------------------------------------------------------------------
static int checkcardtype(){
    unsigned char status;
    unsigned char myctrlword;
    unsigned char mypiccserial[8] ;
    unsigned char mypicdata[48] ;
    unsigned char mypickey[6]={0xff,0xff,0xff,0xff,0xff,0xff};
    unsigned char mypiccseriallen[1] ;

    myctrlword=0;
    status = mypiccreadex_ntag(myctrlword, mypiccserial, mypicoldkey, 4, 1, mypicdata);
    if(status==0){
        return 1;
    }else{
        status = myiso15693readex(myctrlword,0,0,1,mypiccserial,mypicdata);
        if(status==0){
            return 2;
        }else{
            myctrlword=23;
            status = mypiccreadex(myctrlword,mypiccserial,0,1,mypickey,mypicdata);
            if(status==0){
                return 3;
            }else{
                mypickey[0]=0xa0;mypickey[1]=0xa1;mypickey[2]=0xa2;mypickey[3]=0xa3;mypickey[4]=0xa4;mypickey[5]=0xa5;
                status = mypiccreadex(myctrlword,mypiccserial,0,1,mypickey,mypicdata);
                if(status==0){
                    return 3;
                }else{
                    myctrlword=0;
                    status=myforumtype4request(myctrlword,mypiccserial,mypiccseriallen);
                    if(status==0 || status==52){
                        return 4;
                    }else{
                        return 0;
                    }
                }
            }
        }
    }
}

//Ntag标签开启或关闭密钥保护功能,推荐用此方法保护写入标签内的数据------------------------------------------------------------------------------------------------------------------------------------------------------
static int NtagKeyEn(unsigned char *mypiccserial,bool havekey,bool addkey){
    unsigned char myctrlword;
    unsigned char mypiccdata[16];

    if(havekey){myctrlword=0x10;}else{myctrlword=0;}
    if(addkey){  //开启密钥保护功能
        mypiccdata[0]=0;mypiccdata[1]=0;mypiccdata[2]=0;mypiccdata[3]=4;    //有效数据是从第4块开始的
        myctrlword=myctrlword+1;
        mypiccdata[4]=0;   //允许密钥认证失败次数 ,0表示不限制次数
        mypiccdata[5]=0;mypiccdata[6]=0;mypiccdata[7]=0;   //启用计数器
        myctrlword=myctrlword+2;
        for(int i=0;i<4;i++){
            mypiccdata[8+i]=mypicnewkey[i];   //新认证密钥
        }
        mypiccdata[12]=0x16;mypiccdata[13]=0x16;mypiccdata[14]=0;mypiccdata[15]=4;
        myctrlword=myctrlword+4;
    }else{
        mypiccdata[0]=0;mypiccdata[1]=0;mypiccdata[2]=0;mypiccdata[3]=0xff;
        myctrlword=myctrlword+1;
        mypiccdata[4]=0;mypiccdata[5]=0;mypiccdata[6]=0;mypiccdata[7]=0;
        myctrlword=myctrlword+2;
    }
    unsigned char status=mypiccinit_ntag(myctrlword, mypiccserial, mypicoldkey, mypiccdata);
}

//锁定ntag2数据页,锁定后标签不可以再次修改,请谨慎使用锁定功能----------------------------------------------------------------------------------------------------------------------------------------------------------
static int NtagPageLock(){
    unsigned char status;
    unsigned char mypicclockdata[4] ;
    mypicclockdata[0]=0;mypicclockdata[1]=0;mypicclockdata[2]=0xff;mypicclockdata[3]=0xff;
    status=mypicclock_ntag(0,mypicclockdata);   //静态锁15块之前

    mypicclockdata[0]=0xff;mypicclockdata[1]=0xff;mypicclockdata[2]=0xff;mypicclockdata[3]=0;
    status=mypicclock_ntag(1,mypicclockdata);   //动态锁15块之后
}

//将ndef记录缓冲数据写入不同类型的NFC标签----------------------------------------------------------------------------------------------------------------------------------------------------------
void MainWindow::WriteDataBufToTag(){
    bool havelock;
    bool keyen;
    unsigned char status;
    unsigned char myctrlword;
    unsigned char mypiccserial[8] ;
    unsigned char mypiccseriallen[1] ;
    QString uidstr="" ;
    int i;

    if(ui->checkBox_before->isChecked()){havelock=true;}else{havelock=false;}
    if(ui->checkBox_later->isChecked()){keyen=true;}else{keyen=false;}

    int cardtype=checkcardtype();
    switch (cardtype){
    case 1:
        if(havelock){myctrlword=0x10;} else{myctrlword=0x00;}
        status=myforumtype2_write_ndeftag(myctrlword,mypiccserial,mypicoldkey);
        if(status==0){
            NtagKeyEn(mypiccserial,havelock,keyen);
            mypcdbeep(30);
            for (i = 0; i < 7; i++) {
                uidstr=uidstr+QString::asprintf("%02X",mypiccserial[i]);
            }
            ui->listWidget->addItem("ForumType2Tag:"+uidstr+",NDEF记录缓冲写入成功!");
        }else{
            disperrinf(status);
        }
        break;
    case 2:
        myctrlword=0;
        status=myforumtype5_write_ndeftag(myctrlword,0,mypiccserial);
        if(status==0){
            mypcdbeep(30);
            for (i = 0; i < 8; i++) {
                uidstr=uidstr+QString::asprintf("%02X",mypiccserial[i]);
            }
            ui->listWidget->addItem("ForumType5Tag:"+uidstr+",NDEF记录缓冲写入成功!");
        }else{
            disperrinf(status);
        }
        break;
    case 3:
        if(havelock){myctrlword=208;} else{myctrlword=144;}
        if(keyen){myctrlword=myctrlword+4;}
        status=mypiccwrite_ndeftag(myctrlword,mypiccserial,mypicoldkey,mypicnewkey);
        if(status==0){
            mypcdbeep(30);
            for (i = 0; i < 4; i++) {
                uidstr=uidstr+QString::asprintf("%02X",mypiccserial[i]);
            }
            ui->listWidget->addItem("MifareclassTag:"+uidstr+",NDEF记录缓冲写入成功!");
        }else{
            disperrinf(status);
        }
        break;
    case 4:
        myctrlword=0;
        status=myforumtype4_write_ndeftag(myctrlword,mypiccserial,mypiccseriallen,mypicnewkey);
        if(status==0){
            mypcdbeep(30);
            for (i = 0; i < mypiccseriallen[0]; i++) {
                uidstr=uidstr+QString::asprintf("%02X",mypiccserial[i]);
            }
            ui->listWidget->addItem("ForumType4Tag:"+uidstr+",NDEF记录缓冲写入成功!");
        }else{
            disperrinf(status);
        }
        break;
    default:
        QMessageBox::critical(NULL, "提示", "请刷有效的NFC标签");
        break;
    }
}


//显示返回的错误代码信息-----------------------------------------------------------------------------------------------------------------------------------------------------------------
void MainWindow:: disperrinf(unsigned char result){
    switch (result) {
    case 8:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",未寻到卡,请重新拿开卡后再放到感应区!");
        break;
    case 9:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",有多张卡在感应区,寻卡过程中防冲突失败,读序列吗错误!");
        break;
    case 10:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",该卡可能已被休眠,无法选中卡片!");
        break;
    case 11:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",密码装载失败!");
        break;
    case 12:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",卡片密码认证失败!");
        break;
    case 13:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",读页数据失败,可能需要验证密码!");
        break;
    case 14:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",写页数据失败,可能需要验证密码!");
        break;
    case 18:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",写UID失败,此卡可能不是UID卡!");
        break;
    case 22:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",动态库或驱动程序异常!");
        break;
    case 23:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",驱动程序错误或发卡器尚未安装!");
        break;
    case 24:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",操作超时,一般是动态库没有反应!");
        break;
    case 25:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",发送字数不够!");
        break;
    case 26:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",驱动程序错误或发卡器尚未安装!");
        break;
    case 27:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",操作超时,一般是动态库没有反应!");
        break;
    case 28:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",发送字数不够!");
        break;
    default:
        QMessageBox::critical(NULL, "提示", QString::asprintf("错误代码:%d", result)+",未知的错误信息!");
        break;
    }
}


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_beep_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在

    unsigned char status;
    status = mypcdbeep(30);
    if(status==0){
    }else{
        disperrinf(status);
    }
}


void MainWindow::on_pushButton_getdevnum_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在

    unsigned char devicenumber[4];    //设备编号缓冲
    unsigned char status;             //函数返回状态
    status = mypcdgetdevicenumber(devicenumber);
    if(status==0){
        mypcdbeep(30);
        QMessageBox::information(NULL, "提示", QString::asprintf("设备编号:%03d-%03d-%03d-%03d", devicenumber[0],devicenumber[1],devicenumber[2],devicenumber[3]));
    }else{
        disperrinf(status);
    }
}


void MainWindow::on_pushButton_clearbuff_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在
    mytagbuf_forumtype4_clear();
    mytagbuf_clear();
    QMessageBox::information(NULL, "提示", "NDEF数据缓冲已经清除!");
}


void MainWindow::on_pushButton_writetag_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在
    WriteDataBufToTag();
}

void MainWindow::on_pushButton_text_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在

    QString languagecodestr = "en";   //语言编码,英文为en,中文为zh
    QByteArray languagecodebuf=languagecodestr.toLocal8Bit();
    int languagecodestrlen=languagecodebuf.length();

    QString textstr=ui->lineEdit_text->text();    //文本
    QByteArray textbuf=textstr.toLocal8Bit();
    int textstrlen=textbuf.length();

    unsigned char status=mytagbuf_addtext((unsigned char *)languagecodebuf.data(),languagecodestrlen,(unsigned char *)textbuf.data(),textstrlen);
    if(status==0){
        QMessageBox::information(NULL, "提示","        生成NDEF纯文本标签数据缓冲成功,可以向缓冲区继续添加记录,也可以将缓冲区内数据写标签。");
    }else {
        disperrinf(status);
    }
}


void MainWindow::on_comboBox_seleapp_currentTextChanged(const QString &arg1)
{
    QString seleappstr=ui->comboBox_seleapp->currentText();
    QStringList list = seleappstr.split("|");
    ui->lineEdit_appname->setText(list.at(1));
}


void MainWindow::on_pushButton_App_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在

    QString packagestr=ui->lineEdit_appname->text().trimmed();   //app包名称
    QByteArray packagebuf=packagestr.toLocal8Bit();
    int packagestrlen=packagebuf.length();

    QString typestr=ui->comboBox_appstype->currentText();     //app类型
    QByteArray typebuf=typestr.toLocal8Bit();
    int typestrlen=typebuf.length();

    unsigned char status=mytagbuf_addapp1((unsigned char *)packagebuf.data(),packagestrlen,(unsigned char *)typebuf.data(),typestrlen);
    if(status==0){
        QMessageBox::information(NULL, "提示","        生成NDEF启动应用数据缓冲成功,可以向缓冲区继续添加记录,也可以将缓冲区内数据写标签。");
    }else {
        disperrinf(status);
    }
}


void MainWindow::on_pushButton_Url_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在

    QString languagecodestr = "en";   //语言编码,英文为en,中文为zh
    QByteArray languagecodebuf=languagecodestr.toLocal8Bit();
    int languagecodestrlen=languagecodebuf.length();

    QString textstr=ui->lineEdit_title->text();    //标题
    QByteArray textbuf=textstr.toLocal8Bit();
    int textstrlen=textbuf.length();

    int uriheaderindex = ui->comboBox_headindex->currentIndex();   //前缀

    QString uristr=ui->lineEdit_uri->text();        //uri
    QByteArray uribuf=uristr.toLocal8Bit();
    int uristrlen=uribuf.length();

    unsigned char status=mytagbuf_adduri((unsigned char *)languagecodebuf.data(),languagecodestrlen,(unsigned char *)textbuf.data(),textstrlen,uriheaderindex,(unsigned char *)uribuf.data(),uristrlen);
    if(status==0){
        QMessageBox::information(NULL, "提示","        生成NDEF网址URI记录数据缓冲成功,可以向缓冲区继续添加记录,也可以将缓冲区内数据写标签。");
    }else {
        disperrinf(status);
    }
}


void MainWindow::on_pushButton_Map_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在

    QString languagecodestr = "en";   //语言编码,英文为en,中文为zh
    QByteArray languagecodebuf=languagecodestr.toLocal8Bit();
    int languagecodestrlen=languagecodebuf.length();

    QString textstr=ui->lineEdit_mapname->text();    //标题
    QByteArray textbuf=textstr.toLocal8Bit();
    int textstrlen=textbuf.length();

    int uriheaderindex = 0;   //地理位置没有链接前缀

    QString uristr="geo:" +ui->lineEdit_latitude->text().trimmed()+ ","+ui->lineEdit_longitude->text().trimmed() ;        //uri
    QByteArray uribuf=uristr.toLocal8Bit();
    int uristrlen=uribuf.length();

    unsigned char status=mytagbuf_adduri((unsigned char *)languagecodebuf.data(),languagecodestrlen,(unsigned char *)textbuf.data(),textstrlen,uriheaderindex,(unsigned char *)uribuf.data(),uristrlen);
    if(status==0){
        QMessageBox::information(NULL, "提示","        生成NDEF地图坐标数据缓冲成功,可以向缓冲区继续添加记录,也可以将缓冲区内数据写标签。");
    }else {
        disperrinf(status);
    }
}


void MainWindow::on_pushButton_Bluetooth_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在

    QString blenamestr=ui->lineEdit_Bluetoothname->text().trimmed();   //设备名称
    QByteArray blenamebuf=blenamestr.toLocal8Bit();
    int blenamestrlen=blenamebuf.length();

    QString macstr=ui->lineEdit_Bluetoothmac->text().trimmed();     //mac
    QStringList list = macstr.split(":");
    unsigned char macbuf[6];
    try{
        for(int i=0;i<6;i++){
            bool ok;
            macbuf[i]=QString(list.at(i)).toInt(&ok,16);
        }
    }catch(_exception){
        QMessageBox::critical(NULL, "提示", "MAC地址输入错误!");
        return;
    }

    unsigned char status=mytagbuf_addbluetooth((unsigned char *)blenamebuf.data(),blenamestrlen,macbuf);
    if(status==0){
        QMessageBox::information(NULL, "提示","        生成NDEF蓝牙连接数据缓冲成功,可以向缓冲区继续添加记录,也可以将缓冲区内数据写标签。");
    }else {
        disperrinf(status);
    }
}


void MainWindow::on_pushButton_Wifi_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在

    QString ssidstr = ui->lineEdit_hostname->text();   //热点名称
    QByteArray ssidbuf=ssidstr.toLocal8Bit();
    int ssidstrlen=ssidbuf.length();

    int authtype=ui->comboBox_auth->currentIndex();     //认证方式
    int crypttype=ui->comboBox_Calculation->currentIndex();     //加密算法

    QString keystr=ui->lineEdit_password->text();      //密钥
    QByteArray keybuf=keystr.toLocal8Bit();
    int keystrlen=keybuf.length();

    unsigned char status=mytagbuf_addwifi((unsigned char *)ssidbuf.data(),ssidstrlen,authtype,crypttype,(unsigned char *)keybuf.data(),keystrlen);
    if(status==0){
        QMessageBox::information(NULL, "提示","        生成WIFI无线连接数据缓冲成功,可以向缓冲区继续添加记录,也可以将缓冲区内数据写标签。");
    }else {
        disperrinf(status);
    }
}


void MainWindow::on_pushButton_Card_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在

    QString infostr = "BEGIN:VCARD\n" ;
    infostr=infostr+"VERSION:3.0" + "\n";
    infostr=infostr+"FN:" +ui->lineEdit_name->text()+ "\n";
    infostr=infostr+"TEL:"+ui->lineEdit_tel->text() + "\n";
    infostr=infostr+"ORG:"+ui->lineEdit_unilname->text() + "\n";
    infostr=infostr+"ADR:" +ui->lineEdit_address->text()+ "\n";
    infostr=infostr+"EMAIL:"+ui->lineEdit_email->text() + "\n";
    infostr=infostr+"URL:" +ui->lineEdit_net->text()+ "\n";
    infostr=infostr+"END:VCARD\n";
    QByteArray infobuf=infostr.toLocal8Bit();
    int infostrlen=infobuf.length();

    unsigned char status=mytagbuf_addbusinesscard((unsigned char *)infobuf.data(),infostrlen);
    if(status==0){
        QMessageBox::information(NULL, "提示","        生成NDEF电子名片数据缓冲成功,可以向缓冲区继续添加记录,也可以将缓冲区内数据写标签。");
    }else {
        disperrinf(status);
    }
}


void MainWindow::on_pushButton_Data_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在

    QString typestr=ui->lineEdit_datatype->text().trimmed();   //类型名称
    QByteArray typebuf=typestr.toLocal8Bit();
    int typestrlen=typebuf.length();

    QString datastr=ui->lineEdit_data->text();     //数据
    QByteArray databuf=datastr.toLocal8Bit();
    int datastrlen=databuf.length();

    unsigned char status=mytagbuf_adddata((unsigned char *)typebuf.data(),typestrlen,(unsigned char *)databuf.data(),datastrlen);
    if(status==0){
        QMessageBox::information(NULL, "提示","        生成NDEF数据标签缓冲成功,可以向缓冲区继续添加记录,也可以将缓冲区内数据写标签。");
    }else {
        disperrinf(status);
    }
}


void MainWindow::on_pushButton_Call_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在

    QString languagecodestr = "en";   //语言编码,英文为en,中文为zh
    QByteArray languagecodebuf=languagecodestr.toLocal8Bit();
    int languagecodestrlen=languagecodebuf.length();

    QString textstr="";    //标题
    QByteArray textbuf=textstr.toLocal8Bit();
    int textstrlen=textbuf.length();

    int uriheaderindex = 5;   //呼叫电话的链接前缀为5

    QString uristr=ui->lineEdit_callnum->text().trimmed() ;        //uri
    QByteArray uribuf=uristr.toLocal8Bit();
    int uristrlen=uribuf.length();

    unsigned char status=mytagbuf_adduri((unsigned char *)languagecodebuf.data(),languagecodestrlen,(unsigned char *)textbuf.data(),textstrlen,uriheaderindex,(unsigned char *)uribuf.data(),uristrlen);
    if(status==0){
        QMessageBox::information(NULL, "提示","        生成NDEF呼叫电话数据缓冲成功,可以向缓冲区继续添加记录,也可以将缓冲区内数据写标签。");
    }else {
        disperrinf(status);
    }
}


void MainWindow::on_pushButton_cleatag_clicked()
{
    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在
    mytagbuf_forumtype4_clear();
    mytagbuf_clear();
    WriteDataBufToTag();
}


void MainWindow::on_pushButton_clearinf_clicked()
{
    ui->listWidget->clear();
    ui->plainTextEdit_taginf->setPlainText("");
}


void MainWindow::on_pushButton_readtag_clicked()
{
    bool havelock;
    unsigned char status=8;
    unsigned char myctrlword;
    unsigned char mypiccserial[8] ;
    unsigned char mypiccseriallen[1] ;
    QString uidstr="" ;
    int i;

    if(!checkdllos()){return;}        //判断运行目录内动态库文件是否存在

    ui->plainTextEdit_taginf->setPlainText("");

    if(ui->checkBox_before->isChecked()){havelock=true;}else{havelock=false;}   //标签是否已加密钥

    int cardtype=checkcardtype();
    switch (cardtype){
    case 1:
        if(havelock){myctrlword=0x10;} else{myctrlword=0x00;}
        status=myforumtype2_read_ndeftag(myctrlword,mypiccserial,mypicoldkey);
        uidstr="ForumType2Tag:";
        for (i = 0; i < 7; i++) {
            uidstr=uidstr+QString::asprintf("%02X",mypiccserial[i]);
        }
        break;
    case 2:
        myctrlword=0;
        status=myforumtype5_read_ndeftag(myctrlword,0,mypiccserial);
        uidstr="ForumType5Tag:";
        for (i = 0; i < 8; i++) {
            uidstr=uidstr+QString::asprintf("%02X",mypiccserial[i]);
        }
        break;
    case 3:
        myctrlword=144;
        status=mypiccread_ndeftag(myctrlword,mypiccserial,mypicoldkey);
        uidstr="MifareclassTag:";
        for (i = 0; i < 4; i++) {
            uidstr=uidstr+QString::asprintf("%02X",mypiccserial[i]);
        }
        break;
    case 4:
        myctrlword=0;
        status=myforumtype4_read_ndeftag(myctrlword,mypiccserial,mypiccseriallen,mypicoldkey);
        uidstr="ForumType4Tag:";
        for (i = 0; i < mypiccseriallen[0]; i++) {
            uidstr=uidstr+QString::asprintf("%02X",mypiccserial[i]);
        }
        break;
    default:
        QMessageBox::critical(NULL, "提示", "请刷有效的NFC标签");
        break;
    }

    if(status==0){
        ui->listWidget->addItem(uidstr+",读取标签内信息成功!");
        mypcdbeep(30);
        unsigned char mypiccdata[1024];
        unsigned char revstrlen[2];
        unsigned char recordnumber[2];
        mytagbuf_read(mypiccdata,revstrlen,recordnumber);
        QString str =   QString::fromLocal8Bit(reinterpret_cast<const char *>(mypiccdata));
        ui->plainTextEdit_taginf->setPlainText(str);
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/952990.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

NVIDIA Clara平台助力医学影像处理:编程案例与实践探索(上)

一、引言 1.1 研究背景与意义 在现代医学领域,医学影像技术已然成为疾病诊断、治疗方案制定以及疗效评估的关键支柱。从早期的 X 射线成像,到如今的计算机断层扫描(CT)、磁共振成像(MRI)、正电子发射断层扫描(PET)等先进技术,医学影像为医生提供了直观、精准的人体内…

【硬件介绍】Type-C接口详解

一、Type-C接口概述 Type-C接口特点&#xff1a;以其独特的扁头设计和无需区分正反两面的便捷性而广受欢迎。这种设计大大提高了用户的使用体验&#xff0c;避免了传统USB接口需要多次尝试才能正确插入的问题。Type-C接口内部结构&#xff1a;内部上下两排引脚的设计虽然可能不…

【数据结构】第1天之Java中的数据结构

前言 众所周知&#xff0c;程序数据结构算法&#xff0c;可见数据结构的重要性。 在Java中&#xff0c;数据结构通常指的是Java集合框架中的类和接口。 Java集合框架提供了一套标准的数据结构&#xff0c;例如列表、集合、映射表等&#xff0c;以及相应的实现类。 今天要分享的…

Open FPV VTX开源之默认MAVLink设置

Open FPV VTX开源之默认MAVLink设置 1. 源由2. 准备3. 连接4. 安装5. 配置6. 测试6.1 启动wfb-ng服务6.2 启动wfb-ng监测6.3 启动QGroundControl6.4 观察测试结果 7. 总结8. 参考资料9. 补充9.1 telemetry_tx异常9.2 DEBUG串口部分乱码9.3 PixelPilot软件问题9.4 偶尔启动卡住 …

Spring Boot 和微服务:快速入门指南

&#x1f496; 欢迎来到我的博客&#xff01; 非常高兴能在这里与您相遇。在这里&#xff0c;您不仅能获得有趣的技术分享&#xff0c;还能感受到轻松愉快的氛围。无论您是编程新手&#xff0c;还是资深开发者&#xff0c;都能在这里找到属于您的知识宝藏&#xff0c;学习和成长…

Redis 为什么要引入 Pipeline机制?

在 Redis 中有一种 Pipeline&#xff08;管道&#xff09;机制&#xff0c;其目的是提高数据传输效率和吞吐量。那么&#xff0c;Pipeline是如何工作的&#xff1f;它又是如何提高性能的&#xff1f;Pipeline有什么优缺点&#xff1f;我们该如何使用 Pipeline&#xff1f; 1、…

Cesium小知识:粒子系统的参数详解

Cesium 的粒子系统通过 ParticleSystem 类提供了一套丰富的参数来控制粒子的生成、行为和外观。以下是这些参数的详细说明,帮助你更好地理解和使用 Cesium 的粒子系统。 基本参数 image (String) - 粒子图像的URL路径。这个图像是每个粒子在渲染时使用的纹理。 startColor (Co…

【数据结构-堆】力扣1834. 单线程 CPU

给你一个二维数组 tasks &#xff0c;用于表示 n​​​​​​ 项从 0 到 n - 1 编号的任务。其中 tasks[i] [enqueueTimei, processingTimei] 意味着第 i​​​​​​​​​​ 项任务将会于 enqueueTimei 时进入任务队列&#xff0c;需要 processingTimei 的时长完成执行。 现…

OSPF - 2、3类LSA(Network-LSA、NetWork-Sunmmary-LSA)

前篇博客有对常用LSA的总结 2类LSA&#xff08;Network-LSA&#xff09; DR产生泛洪范围为本区域 作用:  描述MA网络拓扑信息和网络信息&#xff0c;拓扑信息主要描述当前MA网络中伪节点连接着哪几台路由。网络信息描述当前网络的 掩码和DR接口IP地址。 影响邻居建立中说到…

【强化学习】演员评论家Actor-Critic算法(万字长文、附代码)

&#x1f4e2;本篇文章是博主强化学习&#xff08;RL&#xff09;领域学习时&#xff0c;用于个人学习、研究或者欣赏使用&#xff0c;并基于博主对相关等领域的一些理解而记录的学习摘录和笔记&#xff0c;若有不当和侵权之处&#xff0c;指出后将会立即改正&#xff0c;还望谅…

【2024年华为OD机试】 (C卷,100分)- 密钥格式化(Java JS PythonC/C++)

一、问题描述 题目描述 给定一个非空字符串 S&#xff0c;其被 N 个‘-’分隔成 N1 的子串&#xff0c;给定正整数 K&#xff0c;要求除第一个子串外&#xff0c;其余的串每 K 个用‘-’分隔&#xff0c;并将小写字母转换为大写。 输入描述 正整数 K 和‘-’分割的字符串&a…

基于单片机的指纹密码锁

【摘要】 本设计是一款基于单片机的指纹识别电子密码锁系统。该系统以STC89C52单片机作为模块核心同时结合ZFM-60指纹模块实现录取指纹并存储指纹数据的功能&#xff0c;并且通过HS12864-15C液晶显示比对流程及比对结果&#xff0c;该指纹电子密码锁通过直流继电器与发光二极管…

企业总部和分支通过GRE VPN互通

PC1可以ping通PC2 1、首先按照地址表配置ip地址 2、分别在AR1和AR3上配置nat 3、配置GRE a 创建tunnel接口&#xff0c;并选择tunnel协议为GRE&#xff0c;为隧道创建一个地址&#xff0c;用作互联 b 为隧道配置源地址或者源接口&#xff0c;这里选择源接口&#xff1b;再为…

回归预测 | MATLAB实MLR多元线性回归多输入单输出回归预测

回归预测 | MATLAB实MLR多元线性回归多输入单输出回归预测 目录 回归预测 | MATLAB实MLR多元线性回归多输入单输出回归预测预测效果基本介绍程序设计参考资料 预测效果 基本介绍 回归预测 | MATLAB实MLR多元线性回归多输入单输出回归预测。 程序设计 完整代码&#xff1a;回…

计算机网络(五)运输层

5.1、运输层概述 概念 进程之间的通信 从通信和信息处理的角度看&#xff0c;运输层向它上面的应用层提供通信服务&#xff0c;它属于面向通信部分的最高层&#xff0c;同时也是用户功能中的最低层。 当网络的边缘部分中的两个主机使用网络的核心部分的功能进行端到端的通信时…

【PPTist】插入形状、插入图片、插入图表

一、插入形状 插入形状有两种情况&#xff0c;一种是插入固定的形状&#xff0c; 一种是插入自定义的形状。 插入固定的形状时&#xff0c;跟上一篇文章 绘制文本框 是一样一样的&#xff0c;都是调用的 mainStore.setCreatingElement() 方法&#xff0c;只不多传的类型不一…

Elasticsearch—索引库操作(增删查改)

Elasticsearch中Index就相当于MySQL中的数据库表 Mapping映射就类似表的结构。 因此我们想要向Elasticsearch中存储数据,必须先创建Index和Mapping 1. Mapping映射属性 Mapping是对索引库中文档的约束&#xff0c;常见的Mapping属性包括&#xff1a; type&#xff1a;字段数据类…

ROS Action接口

实现自主导航是使用Action接口的主要目的 在实际使用navigation导航系统的时候&#xff0c;机器人需要自主进行导航。不能每次都手动设置导航的目标点。所以需要编写程序代码来实现导航控制。这就需要使用到navigation的导航接口。Navigation的这个导航接口有好几个。Rose官方…

macOS 安装tomcat9

macOS 安装tomcat9 URL&#xff1a;https://tomcat.apache.org/download-90.cgi 解压之后放到指定目录 /Users/lanren/install/tomcat-9 自己取个名字就行 给权限&#xff1a; ① 先进行权限修改&#xff1a;终端输入sudo chmod 755 /Users/lanren/install/tomcat-9/bin/…

PatchTST:通道独立的、切片的 时序 Transformer

出处&#xff1a;ICLR 2023 代码链接&#xff1a;yuqinie98/PatchTST: An offical implementation of PatchTST: "A Time Series is Worth 64 Words: Long-term Forecasting with Transformers." (ICLR 2023) https://arxiv.org/abs/2211.14730 一 模型主要思想及…