[ summary of the invention ]
In view of this, embodiments of the present invention provide a near field communication method, an apparatus, and a computer-readable storage medium, which can manage data communication connection with a connected NFC card, improve stability of data communication connection, and improve efficiency of data transmission.
In one aspect, an embodiment of the present invention provides a near field communication method, applied to an NFC (near field communication) reader, including:
acquiring basic information of a first NFC card, wherein the first NFC card is an NFC card which is far away from the NFC reader and is within a specified range;
judging whether the first NFC card is an NFC card for the NFC reader to execute operation or not according to the basic information of the first NFC card;
if the first NFC card is judged to be the NFC card executed by the NFC reader-writer to operate, acquiring data of the first NFC card;
and executing a data reading operation or a data writing operation on the first NFC card according to the basic information and the data.
As to the above-mentioned aspect and any possible implementation manner, there is further provided an implementation manner, where the determining whether the first NFC card is an NFC card that the NFC reader performs an operation includes: comparing whether the basic information of the first NFC card is the same as the basic information of the NFC card operated by the NFC reader-writer to obtain a comparison result;
and if the comparison result is the same, determining that the first NFC card is the NFC card operated by the NFC reader-writer, and if the comparison result is different, determining that the first NFC card is not the NFC card operated by the NFC reader-writer.
In the aspect and any possible implementation manner described above, there is further provided an implementation manner, before the determining whether the first NFC card is an NFC card on which the NFC reader/writer performs an operation, the method includes:
and acquiring basic information of the NFC card operated by the NFC reader-writer from a first position.
As to the above-mentioned aspect and any possible implementation manner, there is further provided an implementation manner, where if the basic information of the first NFC card is compared with the basic information of the NFC card executed by the NFC reader/writer to be different, the method further includes:
judging whether the basic information of the NFC card executing the operation stored by the NFC reader-writer is empty;
and if the basic information of the NFC card for executing the operation stored by the NFC reader-writer is judged to be null, determining that the first NFC card is the NFC card for executing the operation by the NFC card reader-writer, and taking the basic information of the first NFC card as the basic information of the NFC card for executing the operation by the NFC reader-writer.
The above-described aspects and any possible implementations further provide an implementation, and the method further includes:
judging whether the data reading operation or the data writing operation performed on the first NFC card is finished or not;
and if the data reading operation or the data writing operation of the first NFC card is judged to be finished, deleting the basic information of the NFC card operated by the NFC reader-writer in the first position, and generating a specified identifier, wherein the specified identifier is used for representing that the basic information of the NFC card operated by the NFC reader-writer is empty.
The aspect and any possible implementation manner described above further provide an implementation manner, where performing a read data operation or a write data operation on the first NFC card includes:
displaying the progress of the data reading operation or the data writing operation and data corresponding to the data reading operation or the data writing operation;
the judging whether the data reading operation or the data writing operation performed on the first NFC card is finished comprises: and judging whether the progress of the display data reading operation or the data writing operation reaches a preset threshold, if so, determining that the first NFC card executes the data reading operation or the data writing operation is finished, and if not, determining that the first NFC card executes the data reading operation or the data writing operation is not finished.
The above-described aspects and any possible implementations further provide an implementation, the method including:
establishing a card object and a data object corresponding to the first NFC card according to the basic information and data of the first NFC card;
and executing a read data operation or a write data operation based on the card object and the data object.
The above-described aspects and any possible implementation further provide an implementation in which the card object includes at least one or more of data description information, data length information, available memory pages, and data available memory space.
As with the above-described aspect and any possible implementation, there is further provided an implementation in which the performing a read data operation based on the card object and the data object includes:
acquiring the storage address of the data object according to the data description information,
and reading the data corresponding to the data object based on the storage address.
The above-described aspect and any possible implementation further provide an implementation in which performing a write operation based on the card object and the data object includes:
configuring a storage address for the data object according to the data length and the available storage page;
and writing the data corresponding to the data object based on the storage address.
The above aspects and any possible implementations further provide an implementation, the method including;
judging whether the data corresponding to the data object exceeds the available storage space of the data;
if the judgment result is that the alarm signal exceeds the preset threshold, sending a prompt message;
and if the data object is judged not to be exceeded, the step of writing the data corresponding to the data object based on the storage address is executed.
In yet another aspect, an embodiment of the present invention provides a near field communication device, which includes
The first acquisition unit is used for acquiring basic information of a first NFC card, and the first NFC card is an NFC card which is far away from the NFC reader and is within a specified range;
the judgment unit is used for judging whether the first NFC card is an NFC card for the NFC reader-writer to execute operation or not according to the basic information of the first NFC card;
a second obtaining unit, configured to obtain data of the first NFC card if it is determined that the first NFC card is an NFC card on which the NFC reader executes an operation;
and the processing unit executes data reading operation or data writing operation on the first NFC card according to the basic information and the data.
In yet another aspect, the present invention provides a computer-readable storage medium, which includes a computer program, and when the computer program is executed by a processor, the computer program implements the near field communication method of any one of the foregoing.
According to the technical scheme provided by the embodiment of the invention, when the first NFC card and the NFC reader-writer can realize near field communication, the basic information of the first NFC card is acquired, and the data of the first NFC card is triggered to be acquired only when the first NFC card is judged to be the NFC card locked by the NFC reader-writer (namely the NFC card for executing operation by the NFC reader-writer) through judging whether the first NFC card is the NFC card locked by the NFC reader-writer, so that the first NFC card is executed with reading operation or writing operation. The invention utilizes the basic information of the NFC card to identify whether the NFC card which is close to the NFC reader-writer at present is the NFC card for carrying out data reading and writing operation or not, and carries out data communication only when the NFC card which is close to the NFC reader-writer at present is the NFC card for carrying out data reading and writing operation, thereby realizing the management of data communication connection with the connected NFC card, improving the stability of data communication connection and improving the efficiency of data transmission.
[ detailed description ] embodiments
For better understanding of the technical solutions of the present invention, the following detailed descriptions of the embodiments of the present invention are provided with reference to the accompanying drawings.
It should be understood that the described embodiments are only some embodiments of the invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the present invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be understood that the term "and/or" as used herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
It should be understood that although the terms first, second, etc. may be used herein to describe locations in embodiments of the invention, these locations should not be limited by these terms. These terms are only used to distinguish one location from another. For example, a first location may also be referred to as a second location, and similarly, a second location may also be referred to as a first location, without departing from the scope of embodiments of the present invention.
The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrases "if determined" or "if detected (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
An embodiment of the present invention provides a near field communication method, which is applied to an NFC (near field communication) reader, please refer to fig. 1, which is a schematic flow diagram of the method provided in the embodiment of the present invention, and as shown in the drawing, the method includes the following steps:
102. and acquiring basic information of a first NFC card, wherein the first NFC card is an NFC card which is far away from the NFC reader within a specified range.
The basic information includes information such as capacity, type, creation time, card identification, data abstract, check code of data, data name and the like of the NFC card.
The designated range is a range in which the NFC card and the NFC card reader can implement near field communication, and the designated range is a range specified by the near field communication technology, for example, NFC operates at 13.56MHZ, and requires a communication distance within a range of 20 cm.
The storage space of the NFC card is divided into a boot area, a data storage page area, a data description area and a data area.
The boot area is used for storing basic information of the NFC card, and the basic information comprises information such as capacity, type, creation time, card identification, data abstract, check code of data, data name and the like of the NFC card.
The data storage page area indicates the use condition of the storage page of the NFC card, represents a linked list structure of the page stored by file data, the address sequence stored by each item in the storage page area is consistent with an item number (0 item is at 0 offset, 1 item is at 2 offset, and 2 items are at 4 offset), each item is in one-to-one correspondence with the corresponding storage page, so that the storage page volume only needs to store the page number of the next page through the mapping relation of the offset, the item number and the page number, and the allocation use condition of the page can be indicated;
and the data description area is used for describing information of the stored files, each item of the data description area corresponds to the file description of one file stored in the card, and the content of the data description area is the file information and the initial page number of the file.
And the data area is used for storing written data contents and occupies most of the pages of the FLASH storage area.
104. And judging whether the first NFC card is an NFC card for the NFC reader-writer to execute operation or not according to the basic information of the first NFC card.
In a possible embodiment, whether the first NFC card is an NFC card executed by the NFC reader-writer is determined, first, whether the first NFC card is the NFC card executed by the NFC reader-writer is determined by comparing whether basic information of the first NFC card is the same as basic information of the NFC card executed by the NFC reader-writer, and if the comparison result is the same, it is determined that the first NFC card is the NFC card executed by the NFC reader-writer, and if the comparison result is different, it is determined that the first NFC card is not the NFC card executed by the NFC reader-writer.
It should be noted here that before the first NFC card is attached to the NFC reader and establishes the near field communication with the NFC reader, the NFC reader does not perform a data reading (writing) operation on any NFC card, or has completed the data reading (writing) operation, that is, the NFC reader is in an idle state, and the basic information of the NFC card performing the operation stored by the NFC reader is empty, and in this case, the execution main body may use the first NFC card as the NFC card performing the operation to perform a reading operation or a writing operation on the first NFC card, based on which, when the basic information of the first NFC card is compared with the basic information of the NFC card performing the operation by the NFC reader, it is further determined whether the basic information of the NFC card performing the operation stored by the NFC reader is empty, and if so (i.e., it is determined that the basic information of the NFC card performing the operation stored by the NFC reader is empty), it is determined that the first NFC card is the NFC reader performing the operation, the basic information of the first NFC card is used as the basic information of the NFC card operated by the NFC reader; if not, determining that the first NFC card is not the NFC card operated by the NFC reader-writer.
Since the basic information of the NFC card includes a large amount of content, in order to improve the efficiency of near field communication and increase the processing speed, when comparing whether the basic information of the first NFC card is the same as the basic information of the NFC card operated by the NFC reader, the basic information of the first NFC card and the basic information of the NFC card operated by the NFC reader may be compared by comparing whether the basic information of the first NFC card is the same as the specific sub-information in the basic information of the NFC card operated by the NFC reader. For example, each NFC card has a unique identifier (e.g., an ID number of the NFC card), and a corresponding comparison result is obtained by comparing whether the ID number of the first NFC card is the same as the ID number of the NFC card operated by the NFC reader, and if the comparison result is that the ID number of the first NFC card is the same as the ID number of the NFC card operated by the NFC reader, it is determined that the first NFC card is the NFC card operated by the NFC reader; if not, further judging whether the ID number of the NFC card which is stored by the NFC reader and executes the operation is empty, if so, determining that the first NFC card is the NFC card which is executed by the NFC reader and storing the ID number of the first NFC card as the ID number of the NFC card which is executed by the NFC reader and executes the operation; if not, determining that the first NFC card is not the NFC card operated by the NFC reader-writer, and displaying the result that the first NFC card is not the NFC card operated by the NFC reader-writer.
106. And if the first NFC card is judged to be the NFC card operated by the NFC reader-writer, acquiring the data of the first NFC card.
It should be noted that the obtaining of the data of the first NFC card may be performed at any time before performing the data reading operation or the data writing operation, but in order to further improve the efficiency of the near field communication, in the embodiment of the present invention, when it is determined that the first NFC card is an NFC card in which the NFC reader performs an operation, the execution main body is triggered to obtain the data of the first NFC card; if the first NFC card is determined not to be the NFC card executed by the NFC reader, the execution main body does not need to execute the operation on the first NFC card, that is, the execution main body does not process the data of the first NFC card. Therefore, compared with the mode of directly triggering to acquire the first NCF card, the situation that the acquired first NFC card is not processed when the first NFC card is determined not to be the NFC card operated by the NFC reader-writer can be avoided, so that the time required for the execution main to execute the near field communication method is shortened, and the efficiency is improved.
108. And performing a data reading operation or a data writing operation on the first NFC card according to the basic information and the data.
According to the technical scheme provided by the embodiment of the invention, when the first NFC card and the NFC reader-writer can realize near field communication, the basic information of the first NFC card is acquired, and the data of the first NFC card is triggered and acquired only when the first NFC card is judged to be the NFC card locked by the NFC reader-writer (namely the NFC card executed by the NFC reader-writer) through judging whether the first NFC card is the NFC card locked by the NFC reader-writer, so that the first NFC card is executed with reading operation or writing operation. The invention utilizes the basic information of the NFC card to identify whether the NFC card which is close to the NFC reader-writer at present is the NFC card for carrying out data reading and writing operation or not, and carries out data communication only when the NFC card which is close to the NFC reader-writer at present is the NFC card for carrying out data reading and writing operation, thereby realizing the management of data communication connection with the connected NFC card, improving the stability of data communication connection and improving the efficiency of data transmission.
In an implementation manner of the present invention, before the first NFC card is close to the NFC reader-writer and establishes near field communication with the NFC reader-writer, the NFC reader-writer performs a data reading (writing) operation on another NFC card, but for some reasons, when the data reading (writing) operation is not performed on the another NFC card, communication between the NFC reader-writer and the another NFC card is interrupted, and in order to continue the data reading (writing) operation on the another NFC card, the execution main body may store the basic information of the another NFC card in the first location, so that the execution main body may obtain the basic information of the NFC card on which the NFC reader-writer performs the operation, and then the step 104 is implemented by comparing the basic information of the first NFC card with the basic information of the NFC card on which the NFC reader-writer performs the operation. That is, the basic information of the NFC card operated by the NFC reader/writer needs to be acquired from the first location before step 104 is implemented by using the basic information of the NFC card.
Further, in order to enable the executing entity to perform operations on other NFC cards in addition to the NFC card that is currently locked (i.e., the NFC reader is currently executing an operating NFC card) to perform read data operations or write data operations on the NFC card, therefore, to achieve this purpose, an embodiment of the present invention provides another implementation manner, and as shown in fig. 2, the method includes:
110. and judging whether the data reading operation or the data writing operation performed on the first NFC card is finished or not. If the data reading operation or the data writing operation on the first NFC card is determined to be finished, step 112 is executed, otherwise step 108 is executed.
112. And deleting the basic information of the NFC card operated by the NFC reader-writer in the first position, and generating a specified identifier.
And the designated identification is used for representing the basic information of the NFC card which is stored in the NFC reader and executes the operation.
In order to facilitate a user to understand a situation that the execution main body performs a data reading operation or a data writing operation, and improve user experience, the present invention provides a feasible embodiment in which, when the data reading operation or the data writing operation is performed on the first NFC card, the execution main body displays a process of the data reading operation or the data writing operation and data corresponding to the data reading operation or the data writing operation.
In addition, in this feasible embodiment, for the implementation of determining whether the data reading operation or the data writing operation performed on the first NFC card is finished, the following may be implemented: and judging whether the progress of displaying the data reading operation or the data writing operation reaches a preset threshold, wherein the preset threshold is mainly used for representing the relation between the quantity of the read (written) data and the quantity of the unread (written) data of the execution main body, if so, determining that the data reading operation or the data writing operation of the first NFC card is finished, and if not, determining that the data reading operation or the data writing operation of the first NFC card is not finished.
Specifically, the form of the preset threshold may include, but is not limited to: is the percentage of the amount of data that has been read (written) to the total amount of data that needs to be read (written) by the executing agent; alternatively, the percentage of the amount of unread (write) data to the total amount of data that needs to be read (written) by the executing agent; alternatively, it can also be characterized by the amount of unread (written) data.
If the preset threshold is in the form of the percentage of the number of the read (written) data to the total number of the data needing to be read (written) by the executing main body, the preset threshold for the executing main body to execute the data reading operation or the data writing operation to be finished is judged to be 100%, if the progress of the data reading (writing) operation is displayed to be 100%, the data reading (writing) operation is represented to be finished, the data reading (writing) operation executed by the first NFC card is determined to be finished, and if the progress of the data reading (writing) operation is displayed to be smaller than 100%, the data reading (writing) operation is represented to be not finished, and the data reading operation or the data writing operation executed by the first NFC card is determined to be not finished.
If the preset threshold is in the form of the percentage of the quantity of unread (written) data to the total quantity of data to be read (written) by the execution main body, the preset threshold for the execution main body to execute the data reading operation or the data writing operation is judged to be 0%, if the progress for displaying the data reading (writing) operation is 0%, the data reading (writing) operation is represented to be completed, the data reading (writing) operation executed by the first NFC card is determined to be completed, if the progress for displaying the data reading (writing) operation is greater than 0%, the data reading (writing) operation is represented to be not completed, and the data reading operation or the data writing operation executed by the first NFC card is determined to be not completed.
If the form of the preset threshold is the quantity of unread (write) data, the preset threshold for executing the data reading operation or the data writing operation of the main body to be finished is judged to be 0, if the progress for displaying the data reading (writing) operation is 0, the data reading (writing) operation is represented to be finished, the data reading (writing) operation of the first NFC card is determined to be finished, if the progress for displaying the data reading (writing) operation is larger than 0, the data reading (writing) operation is represented to be not finished, and the data reading operation or the data writing operation of the first NFC card is determined to be not finished.
In another implementation manner of the present invention, as shown in fig. 3, the execution body may further perform the following steps to implement a data reading (writing) operation on the first NFC card:
202. and establishing a card object and a data object corresponding to the first NFC card according to the basic information and data of the first NFC card.
The card object is established according to basic information of the first NFC card, and at least one or more of data description information, data length information, available memory pages and available memory space of data are packaged in the card object.
It should be noted that the communication protocol specifies the format of the storage space of the storage device, where the commonly used specified formats include FAT32 and FAT16, the NFC card adopts a FAT16 format, and in order to avoid an abnormality in data reading (writing) operation due to the storage space format not conforming to the specification of the communication protocol, in an embodiment of the present invention, before establishing a card object and a data object corresponding to the first NFC card, it is determined whether the storage space of the first NFC card is the specified format, if so, a step of establishing the card object and the data object corresponding to the first NFC card is triggered, and if not, the storage space of the first NFC card is formatted. The storage space comprises a guide area, a data storage page area, a data description area and a data area.
204. Based on the card object and the data object, a read data operation or a write data operation is performed.
It should be added that, in order to improve the efficiency of the read (write) data operation and reduce the error rate of the read (write) data operation, before the read data operation or the write data operation is performed, the execution main body may first determine whether to perform the read data operation or the write data operation, and then perform the corresponding read or write operation on the data. Based on the idea, the executing the data reading operation or the data writing operation based on the card object and the data object comprises the following steps: and generating a data monitoring instruction and a data read-write list based on the established card object and the data object, so as to respond to the data monitoring instruction and execute data reading operation or data writing operation on the data in the data read-write list according to the data read-write list.
Based on the card object and the data object, executing a process of reading data operation: the execution main body firstly obtains data description information corresponding to the card object according to the established card object, and obtains the number of data storage pages occupied by data read by the execution main body and a data starting storage page based on the data description information, wherein the data storage pages comprise data storage page items, the data storage page items comprise partial addresses for storing the data and next data storage pages corresponding to the data object, so that the execution main body obtains storage addresses corresponding to the data object based on the data storage starting pages and the data storage page items, and further the execution main body can read the data corresponding to the data object based on the obtained storage addresses. In order to know whether data is read completely, after the data storage page item is obtained, whether the content in the data storage page item is valid may be determined first, for example, whether the data storage page in the data storage page item is less than or equal to the maximum data storage page corresponding to the card object may be determined, if so, the content in the data storage page item is determined to be valid, the execution main body may execute the data corresponding to the data object based on the acquired storage address, and otherwise, the execution main body obtains an indication indicating end, and stops reading the data.
Wherein, based on the card object and the data object, the process of writing data operation is executed: the execution main body firstly obtains the data length and the available storage page of the card object according to the established card object, generates a data storage page configuration scheme based on the data length and the available storage page, configures a storage address for the data object, obtains a data start storage page corresponding to the data storage page configuration scheme, writes data corresponding to the data object based on the storage address, and in addition, after completing the data writing operation, the execution main body generates corresponding data storage page information and data description page information according to the data storage configuration scheme and writes the two information into a data storage page area and a data description area respectively in order to facilitate reading the written data. In order to improve the data writing efficiency, before acquiring a data start storage page corresponding to the data storage page configuration scheme, whether data corresponding to the data object exceeds a data available storage space or not may be judged; if the judgment result is that the data is over, sending prompt information to inform a user that the storage space is insufficient and the data cannot be stored; and if the data object does not exceed the preset data storage page configuration scheme, executing a step of obtaining a data initial storage page corresponding to the data storage page configuration scheme, and writing data corresponding to the data object based on the storage address.
The near field communication method provided by the embodiment of the present invention is further described in detail by two specific application examples in conjunction with a specific execution device.
Example 1
Fig. 4 is a flowchart of a near field communication method according to an embodiment of the present invention. Referring to fig. 4, the near field communication method in this example includes:
step 10: and the NFC card reader polls the NFC card ID attached to the bottom layer, judges whether the attached NFC card ID exists or not, and stores the current attached NFC card ID when the NFC card is attached to the NFC card reader.
Step 20: judging whether the ID number of the current approaching card is the same as the ID number of the current transaction operation card (namely the NFC card currently operated by the NFC reader), and if so, executing the step 30; if not, executing step 40;
step 30: polling a small data block of the file in the read-write file queue, judging whether the read-write file NFC card is interrupted, and if the read-write file NFC card is interrupted, executing the step 10 again; if not, go to step 50;
step 40: judging whether the ID number of the current transaction operation card is empty, if not, prompting that the current close card is inconsistent with the card in operation; if the ID number of the operation card is null, executing step 60;
step 50: storing the progress of reading and writing data, displaying the progress on an upper layer, displaying contents when a file is read and written, simultaneously judging whether all read-write operations are finished, and if so, clearing the ID number of the current transaction operation card to be null; otherwise, re-executing step 30;
step 60: acquiring the NFC card object and the read-write object, requesting to monitor the read-write file, saving the current NFC card ID number as the current transaction operation card ID number, and executing the step 30.
Example two:
fig. 5 is a diagram illustrating another flow chart of a near field communication method according to an embodiment of the present invention. Referring to fig. 5, the near field communication method in this example includes:
step 1: acquiring basic information of the card and inputting and outputting streams. Judging whether the storage space is in a standardized format, if not, formatting the storage space of the NFC card, wherein the storage space comprises a guide area, a storage page area, a file description area and a file data area; if yes, executing step 2;
step 2: establishing a card object and a read-write object, requesting to monitor a read-write file by an upper layer, setting an upper layer buffer read-write file list, judging whether to execute read operation or write operation, and executing a step 3 if the read operation is executed; if the write operation is executed, executing step 7;
and step 3: obtaining a file initial storage page according to the file description;
and 4, step 4: reading the file data of the offset position corresponding to the storage page, judging whether the content of the storage page item is normal, and if so, executing the step 5; otherwise, executing step 6;
and 5: acquiring the content of the storage page item, namely the next storage page number, and returning to the step 4;
step 6: stopping reading the file when the file is finished or other identifiers exist;
and 7: according to the file length and the available storage pages, a file storage page scheme is arranged, whether the available storage data space is exceeded or not is judged, and if the available storage data space is exceeded, the upper layer prompts the file to exceed the capacity of the card; otherwise, executing step 8;
and 8: obtaining a file initial storage page according to a storage page distribution scheme;
and step 9: writing file data of the offset position corresponding to the file storage page, judging whether the file is written completely, and executing the step 10 if the file is written completely; otherwise, executing step 11;
step 10: writing the file storage page area according to the file storage page allocation scheme, and writing the file description area according to the file storage page allocation scheme;
step 11: and obtaining the next storage page according to the storage page allocation scheme, and returning to execute the step 9.
Note that, the NFC reader according to the embodiment of the present invention may include, but is not limited to, a Personal Computer (PC), a Personal Digital Assistant (PDA), a wireless handheld device, a Tablet Computer (Tablet Computer), a mobile phone, an MP3 player, an MP4 player, and the like, which can implement near field communication.
The embodiment of the invention further provides an embodiment of a device for realizing the steps and the method in the embodiment of the method.
Please refer to fig. 6, which is a block diagram illustrating an apparatus according to an embodiment of the present invention. As shown, the apparatus comprises:
the card management module 610 is configured to acquire basic information of a first NFC card, where the first NFC card is an NFC card within a specified range from an NFC reader, determine whether the first NFC card is an NFC card for the NFC reader to perform operations according to the basic information of the first NFC card, and acquire data of the first NFC card if it is determined that the first NFC card is an NFC card for the NFC reader to perform operations.
Specifically, the card management module 610 may include a card information reading unit, a card object management unit, and a card status monitoring unit. The card information reading unit is used for reading basic information of the card, and the card object management unit is used for managing objects, such as card approaching to the NFC card reader, card leaving from the NFC card reader, card changing and the like, executing management of connection stability and card identification and locking management. The card state monitoring unit is used for monitoring the read-write operation of the file.
And the read-write module 620 is configured to perform a read data operation or a write data operation on the first NFC card according to the basic information and the data.
Specifically, the read/write module 620 may include a read/write management unit, a physical addressing IO management unit, a read queue, and a write queue. The read-write management unit is used for managing the read-write operation of the data. And the physical addressing IO management unit is used for converting a physical addressing mode into a file storage management mode. The read queue and the write queue are respectively used for reading and writing data. And the read-write management unit, the physical addressing IO management unit, the read queue and the write queue in the read-write module are matched with each other, so that the data reading operation or the data writing operation is executed on the first NFC card according to the basic information and the data.
Since each unit in the present embodiment is capable of the above-mentioned near field communication method, reference may be made to the above-mentioned related description of the near field communication method in the present embodiment, which is not described in detail.
Embodiments of the present invention further provide a computer-readable storage medium having stored thereon a computer program, which when executed by a processor, performs any of the near field communication methods described above.
According to the technical scheme provided by the embodiment of the invention, when the first NFC card and the NFC reader-writer can realize near field communication, the basic information of the first NFC card is acquired, and the data of the first NFC card is triggered to be acquired only when the first NFC card is judged to be the NFC card locked by the NFC reader-writer (namely the NFC card for executing operation by the NFC reader-writer) through judging whether the first NFC card is the NFC card locked by the NFC reader-writer, so that the first NFC card is executed with reading operation or writing operation. The invention utilizes the basic information of the NFC card to identify whether the NFC card which is close to the NFC reader-writer at present is the NFC card for carrying out data reading and writing operation or not, and carries out data communication only when the NFC card which is close to the NFC reader-writer at present is the NFC card for carrying out data reading and writing operation, thereby realizing the management of data communication connection with the connected NFC card, improving the stability of data communication connection and improving the efficiency of data transmission.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions in actual implementation, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) or a Processor (Processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.