State switching method and device, equipment and storage medium
By maintaining the first state and waiting for retransmission when the sensing device cannot parse the command, the problem of low interaction efficiency caused by erroneous commands in the prior art is solved, and efficient communication is achieved in the environment of radio frequency interference.
Patent Information
- Application Number
- CN202510844084.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2025-06-20
- Filing Date
- 2025-06-23
- Publication Date
- 2025-10-21
AI Technical Summary
In existing contactless smart card communication standards, sensing devices immediately switch to an idle state when they encounter unparseable commands, resulting in low interaction efficiency. In particular, retry opportunities cannot be effectively utilized when there is radio frequency interference or unstable communication distance.
After switching to the first state, the sensing device sends a response identifier and maintains this state until the correct instruction is received if the reader instruction cannot be parsed, thus avoiding an immediate switch to the idle state. The reader resends the instruction if no response is received to ensure the accuracy of the state switching.
While ensuring fault tolerance, it improves the interaction efficiency between the card reader and the sensing device, reduces the restart process caused by external interference, and enhances the stability and efficiency of the system.
Smart Images

Figure CN120822534A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of wireless communication technology, and specifically to a state switching method, apparatus, device, and storage medium. Background Art
[0002] The existing contactless smart card communication standard specifies the physical layer, link layer, and transport layer specifications for short-range (generally less than 10 cm) wireless communication between a PCD (Proximity Coupling Device) and a PICC (Proximity Card or Object, collectively referred to as a proximity device) at a 13.56 MHz radio frequency.
[0003] The existing protocol defines a state migration mechanism between the reader / writer (PCD) and the receiving card (PICC), from initial identification, antenna coupling, anti-collision selection to formal data exchange. In other words, the PICC goes through a multi-state process from "idle state" to "protocol state" capable of processing application instructions, and then to "sleep state". It also stipulates a mechanism for the PICC to switch to the idle state after detecting any error. Summary of the Invention
[0004] In view of this, the present application provides a state switching method, apparatus, device and storage medium, which improve interaction efficiency while ensuring fault tolerance. The technical solution is as follows.
[0005] In a first aspect, a state switching method is provided, which is applied to a sensing device; the method comprises:
[0006] During the interaction between the sensing device and the card reader, when the sensing device switches to a first state, the sensing device sends a first response identifier to the card reader;
[0007] receiving a first instruction for switching a state of the sensing device;
[0008] If the first instruction cannot be parsed, the first state is maintained.
[0009] In an optional embodiment, the method further includes:
[0010] receiving a second instruction; wherein the second instruction is used to switch the state of the sensing device;
[0011] If the second instruction cannot be parsed, the first state is maintained.
[0012] In an optional implementation, the first instruction is the same as the second instruction.
[0013] In an optional embodiment, the first instruction and the second instruction are both used to switch the sensing device from the first state to the second state;
[0014] The first instruction and the second instruction have different frame formats; or the first instruction and the second instruction have different baud rates.
[0015] In an optional implementation, during the interaction between the sensing device and the card reader, the second state is the next state of the first state.
[0016] In an optional implementation, before receiving the second instruction, the method further includes:
[0017] Generate a corresponding parsing failure flag according to the parsing failure reason corresponding to the first instruction;
[0018] Send the parsing failure indicator to the card reader.
[0019] In an optional embodiment, the method further includes:
[0020] When the second instruction is successfully parsed, the sensing device is switched from the first state to the second state according to the second instruction, and a second response identifier is sent to the sensing device.
[0021] In an optional implementation, when the first state is the ready state, switching the sensing device from the first state to the second state according to the second instruction includes:
[0022] If the second instruction obtained by parsing is a notification instruction, switching the sensing device from a ready state to a recognition state;
[0023] Alternatively, if the second instruction obtained through analysis is an anti-collision instruction, the sensing device is switched from the ready state to the anti-collision state.
[0024] In an optional implementation manner, the second instruction is sent by the card reader according to the first response identifier when the card reader does not receive the second response identifier within the first time period;
[0025] The method further comprises:
[0026] receiving a target instruction; the target instruction is sent by the card reader when the card reader does not receive a second response identifier within a second time period; the second time period is greater than the first time period;
[0027] According to the target instruction, the sensing device is switched from the first state to the target state.
[0028] In an optional implementation, the target state is an idle state.
[0029] In an optional implementation manner, the target state is a state previous to the first state, or the target state is a state between the first state and the idle state.
[0030] In an optional embodiment, the method further includes:
[0031] If the first instruction is successfully parsed, the sensing device is switched from a first state to a next state according to the first instruction.
[0032] In an optional embodiment, the method further includes:
[0033] receiving a third instruction; wherein the third instruction is used to switch the state of the sensing device;
[0034] If the third instruction is not an instruction to switch the sensing device from the first state to the second state, the sensing device is switched to an idle state.
[0035] In a second aspect, a state switching method is provided, which is applied to a card reader; the method comprises:
[0036] During the interaction between the sensing device and the card reader, a first response identifier is received; the first response identifier is used to indicate that the sensing device is switched to the first state;
[0037] sending a first instruction to the sensing device according to the first response identifier;
[0038] If no second response identifier is received within the first time period, a second instruction is sent to the sensing device; the first instruction and the second instruction are used to switch the state of the sensing device.
[0039] In an optional implementation, the first instruction is the same as the second instruction.
[0040] In an optional implementation manner, the first instruction and the second instruction have different frame formats; or the first instruction and the second instruction have different baud rates.
[0041] In an optional implementation, the sending a second instruction to the sensing device includes:
[0042] sending a second instruction to the sensing device according to a target period until an end condition is reached;
[0043] The termination condition is that the second response identifier is received or the second response identifier is not received within the second time period.
[0044] In an optional embodiment, the sensing device includes a format set; the format set includes various instruction formats; and the method further includes:
[0045] sending a second instruction in a different instruction format to the sensing device according to a target cycle until an end condition is reached;
[0046] The end condition is receiving the second response identifier or traversing each instruction format in the format set.
[0047] In an optional implementation, the sending a second instruction to the sensing device includes:
[0048] Receive a parsing failure flag, wherein the parsing failure flag is used to indicate a parsing failure reason corresponding to the first instruction;
[0049] According to the reason for the parsing failure, a second instruction in a target format is sent to the sensing device.
[0050] In an optional embodiment, the method further includes:
[0051] When no second response identifier is received within the second time period, a target instruction is sent to the sensing device; the target instruction is used to instruct the sensing device to switch from the first state to the target state.
[0052] In an optional implementation, the target state is an idle state.
[0053] In an optional implementation manner, the target state is a state previous to the first state, or the target state is a state between the first state and the idle state.
[0054] In a third aspect, a state switching device is provided, the device being disposed in a sensing device; the device comprising:
[0055] an identification sending module, configured to send a first response identification to the card reader when the sensing device switches to a first state during the interaction between the sensing device and the card reader;
[0056] An instruction receiving module, configured to receive a first instruction for switching the state of the sensing device;
[0057] A state maintaining module is configured to maintain the first state if the first instruction cannot be parsed.
[0058] In a fourth aspect, a state switching device is provided, wherein the device is provided in a card reader; the device comprises:
[0059] An identification receiving module, configured to receive a first response identification during the interaction between the sensing device and the card reader; the first response identification is used to indicate that the sensing device has switched to the first state;
[0060] an instruction sending module, configured to send a first instruction to the sensing device according to the first response identifier;
[0061] The instruction sending module is further configured to send a second instruction to the sensing device if no second response identifier is received within the first time period; the first instruction and the second instruction are used to switch the state of the sensing device.
[0062] In a fifth aspect, an electronic device is provided, wherein the computer device includes a processor and a memory, wherein the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the above-mentioned state switching method.
[0063] In a sixth aspect, a computer-readable storage medium is provided, wherein the storage medium stores at least one instruction, and the at least one instruction is loaded and executed by a processor to implement the above-mentioned state switching method.
[0064] The technical solution provided by this application may have the following beneficial effects:
[0065] During the interaction between the card reader and the sensing device, when the sensing device switches to the first state, it will send a first response identifier to the card reader. At this time, after the card reader receives the first response identifier, it knows that the sensing device has switched to the first state and can send the first instruction corresponding to the first state to it, allowing it to enter the next state. After receiving the first instruction, the sensing device needs to parse it to determine whether it is the instruction corresponding to the first state. However, if it cannot be parsed temporarily, the sensing device can temporarily remain in the first state to wait for subsequent instructions from the card reader. In the above scheme, if the sensing device recognizes an error, and the error is that it cannot parse the received instruction, it means that this may be caused by external interference or the signal transmission environment. At this time, it can remain in the first state and wait for the card reader to resend the instruction. There is no need to return to the idle state to restart the interaction process, which improves the interaction efficiency while ensuring fault tolerance. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the specific implementation methods or the description of the prior art. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0067] Figure 1A state switching diagram of NFC technology is shown.
[0068] Figure 2 The figure is a flow chart of a state switching method according to an exemplary embodiment.
[0069] Figure 3 The figure is a flow chart of a state switching method according to an exemplary embodiment.
[0070] Figure 4 The figure is a flow logic diagram of a state switching method according to an exemplary embodiment.
[0071] Figure 5 An interactive flow chart corresponding to the state switching method shown in an embodiment of the present application is shown.
[0072] Figure 6 It is a structural diagram of a state switching device provided in an embodiment of the present application.
[0073] Figure 7 It is a structural diagram of a state switching device provided in an embodiment of the present application.
[0074] Figure 8 This is a structural diagram of an electronic device provided in an optional embodiment of the present application. DETAILED DESCRIPTION
[0075] To make the purpose, technical solutions, and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of this application.
[0076] In the description of the embodiments of the present application, the term "corresponding" may indicate a direct or indirect correspondence between the two, or an association relationship between the two, or a relationship between indication and being indicated, configuration and being configured, etc.
[0077] In the NFC system, the PICC goes through a series of state transitions from when it approaches the PCD to start command interaction to when it leaves the PCD. The NFC protocol usually defines the state transition mechanism, including how to switch states when encountering errors or exceptions. The state transition mechanism when encountering errors or exceptions may affect the compatibility and fault tolerance of the protocol. Please refer to Figure 1 , which shows a state switching diagram of NFC technology. Figure 1As shown, when the PCD transmits a 13.56MHz carrier, the PICC enters the Idle state from the Away state and begins listening for card-search commands from the PCD. For example, if the PICC is an NFC card, it is powered up by passive power, thus entering the Idle state. The PCD then sends a card-search command, and upon receiving it, the PICC enters the Ready state, awaiting further commands. While in the Ready state, if the PICC receives an anti-collision command from the PCD, it enters the Anti-Collision state, at which point the PICC sends a response and participates in unique identification. While in the Ready state, if the PICC receives a Notify command from the PCD, it determines it has been selected and enters the Active state, awaiting parameter negotiation. While in the Active state, the PICC receives a Negotiation command and negotiates parameters with the PCD. After completing the parameter negotiation process, the PICC enters the Protocol state, ready for full communication with the PCD. Once in the Protocol state, the PCD receives an Application Selection command from the PCD, at which point the PICC enters Working mode and begins processing specific application commands (such as reading or writing data).
[0078] In the above process, whenever the PICC is ready to enter the next state, it will return the corresponding flag to the PCD to inform the PCD that it has switched states, so that the PCD can send subsequent commands. If an illegal or unparseable command is received in any state, the PICC will return to the idle state and wait for communication initialization again.
[0079] The above process stipulates that if the PICC detects any error, it will switch to the idle state. This mechanism suffers from poor fault tolerance. It's normal for the PICC to return to the idle state when receiving a command that doesn't match its current state. However, if it also returns to the idle state when receiving an uninterpretable command, the PCD will not have a chance to retry. Because NFC communication relies on the radio frequency field, which can be susceptible to interference, long communication distances, and unstable power supply, the PICC can easily fail to interpret commands sent by the PCD. Therefore, if it encounters an uninterpretable command, it will return to the idle state, forcing the PCD to restart execution from the initial idle state, resulting in relatively low interaction efficiency.
[0080] In other words, if the PICC switches to the idle state upon recognizing any error, the process between the PCD and the PICC will need to be restarted, which results in low interaction efficiency while ensuring fault tolerance.
[0081] In order to solve the above problems, this application provides a state switching method, please refer to Figure 2 , Figure 2 This is a flow chart of a state switching method according to an exemplary embodiment. The method is applied to a sensing device; the method includes:
[0082] Step 201: During the interaction between the sensing device and the card reader, when the sensing device switches to a first state, the sensing device sends a first response identifier to the card reader.
[0083] In this application, the first state may correspond to any protocol stage (such as ready, identification, activation, or any level in the protocol state). The first response identifier is used to clearly inform the PCD that the PICC has completed the preamble negotiation and entered the stage of receiving the "first command".
[0084] Step 202: Receive a first instruction; the first instruction is used to switch the state of the sensing device.
[0085] The first instruction is a next-level state switching or application startup instruction sent by the PCD, such as an anti-collision instruction, a negotiation instruction, etc.
[0086] Step 203: If the first instruction cannot be parsed, maintain the first state.
[0087] In the embodiment of the present application, the inability to parse the first instruction may refer to a CRC / format check failure (bit error, frame loss, etc.) or a lack of a necessary link layer sequence number. In this case, if the PICC cannot parse the first instruction, it remains silent or responds to the PCD with a hold flag to inform the PCD that it remains in the first state.
[0088] If the PCD does not receive the identifier returned by the PICC after entering the next state within a certain period of time, or the PCD receives the hold identifier returned by the PICC, the PCD can know that the PICC is still in the first state at this time, so the PCD can resend the instruction to switch the state of the sensing device.
[0089] If the PICC successfully parses the first instruction, there are two possibilities. The first possibility is that the first instruction is an instruction to switch the first state to the next state, that is, the instruction sent by the PCD is correct. At this time, the PICC can directly switch the state according to the first instruction; the second possibility is that the first instruction is not an instruction to switch the first state to the next state, that is, the instruction sent by the PCD at this time is wrong. At this time, the PICC can fall back to the idle state and restart the interaction process.
[0090] It should be noted that in the embodiment of the present application, in the interaction process between the PICC and the PCD, if the PICC is in the ready state and successfully parses the first instruction, even if the first instruction is an instruction to switch the first state to the next state, there are still two possibilities for the first instruction. The first is that the first instruction is an anti-collision instruction. At this time, when the PICC receives the anti-collision instruction, it will switch from the ready state to the anti-collision state; and the second is that the first instruction is a notification instruction. At this time, when the PICC receives the notification instruction, it will switch from the ready state to the identification state.
[0091] In summary, during the interaction between the card reader and the sensing device, when the sensing device switches to the first state, it will send a first response identifier to the card reader; at this time, after the card reader receives the first response identifier, it knows that the sensing device has switched to the first state and can send the first instruction corresponding to the first state to it, allowing it to enter the next state; after receiving the first instruction, the sensing device needs to parse it to determine whether it is the instruction corresponding to the first state, but if it cannot be parsed temporarily, the sensing device can temporarily remain in the first state to wait for subsequent instructions from the card reader. In the above scheme, if the sensing device recognizes an error, and the error is that it cannot parse the received instruction, it means that this may be caused by external interference or the signal transmission environment. At this time, it can remain in the first state and wait for the card reader to resend the instruction. There is no need to return to the idle state to restart the interaction process, which improves the interaction efficiency while ensuring fault tolerance.
[0092] Please refer to Figure 3 , Figure 3 This is a flow chart of a method for state switching according to an exemplary embodiment. The method is executed by a card reader; the method includes:
[0093] Step 301: During the interaction between the sensing device and the card reader, a first response identifier is received; the first response identifier is used to indicate that the sensing device is switched to a first state.
[0094] Step 302: Send a first instruction to the sensing device according to the first response identifier.
[0095] Step 303: If the second response identifier is not received within the first time period, a second instruction is sent to the sensing device. The first instruction and the second instruction are used to switch the state of the sensing device.
[0096] In an embodiment of the present application, for the PCD, when the PCD receives the first response identifier, it can be determined that the PICC is already in the first state, so the PCD can send a first instruction to the PICC based on the first response identifier (generally the first instruction is a correct instruction, and it may also be an erroneous instruction sent due to an error inside the card reader).
[0097] If the PICC successfully parses the first instruction, if the first instruction is a correct instruction, the PICC will switch to the next state according to the first instruction and return the second response identifier corresponding to the next state; if the first instruction is an incorrect instruction, the PICC will fall back to the idle state and inform the PCD, thereby restarting the interaction process.
[0098] Therefore, if in the interaction process, the PCD does not receive the second response identifier within the first time period, it means that the PICC has not successfully parsed the first instruction. At this time, there may be an error in the message, or the message transmitted to the PICC is missing due to wireless transmission interference. Therefore, the PCD can resend the second instruction to the PICC, thereby trying again to make the PICC continue to switch states.
[0099] In summary, during the interaction between the card reader and the sensing device, when the sensing device switches to the first state, it will send a first response identifier to the card reader; at this time, after the card reader receives the first response identifier, it knows that the sensing device has switched to the first state and can send the first instruction corresponding to the first state to it, allowing it to enter the next state; after receiving the first instruction, the sensing device needs to parse it to determine whether it is the instruction corresponding to the first state, but if it cannot be parsed temporarily, the sensing device can temporarily remain in the first state to wait for subsequent instructions from the card reader. In the above scheme, if the sensing device recognizes an error, and the error is that it cannot parse the received instruction, it means that this may be caused by external interference or the signal transmission environment. At this time, it can remain in the first state and wait for the card reader to resend the instruction. There is no need to return to the idle state to restart the interaction process, which improves the interaction efficiency while ensuring fault tolerance.
[0100] Figure 4 FIG. 1 is a flow chart of a state switching method according to an exemplary embodiment. The method is performed by the sensing device and the card reader. Figure 4 As shown, the state switching method may include the following steps:
[0101] S401, during the interaction between the sensing device and the card reader, when the sensing device switches to the first state, the sensing device sends a first response identifier to the card reader; correspondingly, the card reader receives the first response identifier; the first response identifier is used to indicate that the sensing device switches to the first state.
[0102] After the PICC switches to the first state, it proactively sends a "first response identification" frame within the specified time window, notifying the PCD that it is ready to receive the next level of instructions. In response, after monitoring this frame, the PCD updates its internal state machine to confirm that the sensing device has entered the first state.
[0103] Optionally, in an embodiment of the present application, the first state may be any one of a ready state, an anti-collision state, an identification state, and an activation state.
[0104] S402: The card reader sends a first instruction to the sensing device according to the first response identifier; correspondingly, the sensing device receives the first instruction; the first instruction is used to switch the state of the sensing device.
[0105] Since the PCD knows that the PICC is in the first state, the PCD can send a first instruction to it to instruct it to switch states; after receiving the first instruction, the PICC performs format and CRC checks on it and determines whether the first instruction is one of the acceptable instruction sets corresponding to the first state.
[0106] In this process, when the PICC receives the first command, it is possible that an error occurs during the format and CRC verification process. In this case, the PICC cannot correctly recognize the first command and cannot parse the first command. Alternatively, after receiving the first command, the PICC may pass the format and CRC verification, but the recognition result indicates that the first command is not one of the acceptable commands corresponding to the first state. In other words, the first command is an erroneous command.
[0107] In the embodiment of the present application, instructions that cannot be parsed and erroneous instructions need to be processed differently.
[0108] S403: If the first instruction cannot be parsed, maintain the first state.
[0109] For the first command that cannot be parsed, such as CRC / format check failure, the PICC may remain silent and not return to the idle state, but continue to listen in the first state.
[0110] In another possible implementation of the embodiment of the present application, if the first instruction is parsed successfully, but it is found that the first instruction is an erroneous instruction, for example, when the first state is the identification state, but an anti-collision instruction is received, it means that the interaction process between the PCD and the PICC may have been disordered. The PICC directly returns to the idle state and sends a corresponding identifier to the PCD to inform the PCD that the interaction process needs to be restarted.
[0111] Optionally, in an embodiment of the present application, if the PICC successfully parses the first instruction, the sensing device may be switched from the first state to the next state according to the first instruction.
[0112] Among them, it should be noted that in the embodiment of the present application, in the interaction process between the PICC and the PCD, if the PICC is in the ready state and successfully parses the first instruction, even if the first instruction is an instruction to switch the first state to the next state, there are still two possibilities for the first instruction. The first is that the first instruction is an anti-collision instruction. At this time, when the PICC receives the anti-collision instruction, it will switch from the ready state to the anti-collision state; and the second is that the first instruction is a notification instruction. At this time, when the PICC receives the notification instruction, it will switch from the ready state to the identification state.
[0113] S404: If no second response identifier is received within the first time period, a second instruction is sent to the sensing device. Correspondingly, the sensing device receives the second instruction; the second instruction is used to switch the state of the sensing device.
[0114] For the card reader, if the PICC switches to the next state according to the first instruction, it should also return the corresponding second response identifier to the PCD within the specified time window. If the PCD does not receive the second response identifier, and the PCD and PICC do not start the interaction process at this time (that is, the PICC has not returned to the idle state), it can be considered that the PICC has not successfully received the first instruction or has received the instruction but failed to parse it, and the PICC is still in the first state.
[0115] Therefore, the PCD may send a second instruction to the PICC to try to instruct the sensing device to switch states again.
[0116] Furthermore, the first instruction and the second instruction are both used to switch the sensing device from the first state to the second state. The second state is the next state of the first state. When the second instruction is successfully parsed, the sensing device is switched from the first state to the second state according to the second instruction, and a second response identifier is sent to the sensing device.
[0117] It is also important to note that in the embodiment of the present application, in the interaction process between the PICC and the PCD, if the PICC is in the ready state and successfully parses the second instruction, since the second instruction has the same function as the first instruction, both are instructions for switching the first state to the next state, there are still two possibilities for the second instruction. The first is that the second instruction is an anti-collision instruction. In this case, the second instruction obtained by parsing is an anti-collision instruction, and the sensing device is switched from the ready state to the anti-collision state; and the second is that the second instruction is a notification instruction. In this case, the second instruction obtained by parsing the PICC is a notification instruction, and the sensing device is switched from the ready state to the identification state.
[0118] Optionally, in the embodiment of the present application, the first instruction is the same as the second instruction. That is, the PCD can directly resend the sent instruction as the second instruction, thereby giving the PICC more opportunities to receive correct data under strong interference.
[0119] Optionally, in an embodiment of the present application, the first instruction and the second instruction have different frame formats; or the first instruction and the second instruction have different baud rates.
[0120] Considering that the PICC may have problems recognizing commands of a certain frame format or baud rate, if the PICC fails to parse the first command after sending it, the PCD may consider switching to a different frame format or baud rate and regenerating a second command to send to the PICC.
[0121] Furthermore, the sensing device generates a corresponding parsing failure identifier based on the parsing failure reason corresponding to the first instruction; the sensing device sends the parsing failure identifier to the card reader; correspondingly, the card reader receives the parsing failure identifier; the parsing failure identifier is used to represent the parsing failure reason corresponding to the first instruction; the card reader sends a second instruction in the target format to the sensing device based on the parsing failure reason.
[0122] In an embodiment of the present application, when the PICC fails to parse the first instruction, a parsing failure reason corresponding to the first instruction can be generated, thereby generating a corresponding parsing failure identifier and sending it to the PCD. When the PCD receives the parsing failure identifier, it can know the reason for the PICC parsing failure, and thus switch the format of the sent instruction to the target format according to the reason for the parsing failure, thereby sending a second instruction in the target format to the sensing device.
[0123] S405: If the second instruction cannot be parsed, maintain the first state.
[0124] In an embodiment of the present application, if the PICC still cannot parse the second instruction, it is possible that external environmental interference still exists. At this time, the card reader can send the second instruction to the sensing device according to the target cycle until the end condition is reached, thereby maximizing the possibility of the sensing device receiving the correct switching instruction under interference.
[0125] In the embodiment of the present application, the end condition is receiving the second response identifier or not receiving the second response identifier within the second time period. When the PCD receives the second response identifier, it means that the PICC has been successfully switched, and there is no need to send the second instruction.
[0126] Optionally, in the interaction process between the PICC and the PCD in the embodiment of the present application, the PICC may receive a third instruction sent by the PCD, which is also used to switch the state of the sensing device; at this time, the PICC will parse the third instruction. If the parsing is successful and the third instruction is not an instruction to switch the sensing device from the first state to the second state, the sensing device can be switched to the idle state.
[0127] For example, if the first state of the PICC at this time is the ready state, the PICC receives the third instruction sent by the PCD, successfully parses the third instruction, and finds that the third instruction is a negotiation instruction. Obviously, the interaction process between the PICC and the PCD is wrong at this time, so the PICC can directly switch to the idle state and restart the interaction process with the PCD.
[0128] S406: When no second response identifier is received within the second time period, a target instruction is sent to the sensing device. Correspondingly, the sensing device receives the target instruction.
[0129] If the second response identifier is not received within the second time period, it means that the number of times the PCD has sent the second command to the PICC in a periodic manner has reached the limit. At this time, continuing to resend the second command will reduce the interaction efficiency between the PCD and the PICC. Therefore, the PCD can send a target command to the PICC, and the target command is used to switch the PICC to the target state.
[0130] Optionally, the target state is an idle state, which means that if the PICC fails to switch successfully within the second time period, the system directly returns to the idle state and restarts the interaction process between the PCD and the PICC.
[0131] Optionally, the target state is the previous state of the first state. This means that if the PICC fails to switch successfully within the second time period, the system returns to the previous state and goes through the interaction process again from the previous state to switch to the first state. This significantly improves the interaction efficiency compared to switching to the idle state while refreshing the first state.
[0132] Optionally, the target state may be a state between the first state and the idle state. This means that if the PICC fails to switch successfully within the second time period, the state returns to a state between the current first state and the idle state, and then the interaction process is repeated from this state, thereby refreshing one or more states and improving interaction efficiency to a certain extent compared to switching to the idle state.
[0133] In another possible implementation of the embodiment of the present application, the card reader can also send a second instruction in a different instruction format to the sensing device according to the target cycle until the end condition is reached; the end condition is receiving the second response identifier or traversing each instruction format in the format set.
[0134] If the second response identifier is received at this time, it means that the PICC successfully parses the second instruction, and the parsed second instruction is correct, so the PICC can directly jump to the next state, and the PCD can also send the next state instruction to the PICC normally.
[0135] If the PICC still fails to successfully identify the second instruction sent by the PCD after traversing each instruction format in the format set, it directly returns to the idle state to re-perform the interaction process or returns to the previous state to perform the interaction process.
[0136] S407: Switch the sensing device from the first state to the target state according to the target instruction.
[0137] In an embodiment of the present application, after receiving the target instruction, the PICC may still be unable to recognize the target instruction (due to environmental interference). At this time, the PICC may need to wait for the PCD to resend the target instruction. When the target instruction is successfully parsed, the state is switched directly according to the target instruction.
[0138] Figure 5 The interactive flow chart corresponding to the state switching method shown in the embodiment of the present application is shown. Figure 5 As shown, relative to Figure 1 The interaction process shown, Figure 5 In the state of ready, identification, activation or anti-collision, when the received frame cannot be parsed, it will remain in the current state for a period of time, waiting for the retransmission of PCD, so that some interaction problems can be solved directly by retransmission. When retransmission cannot solve the problem, it will return to the idle state, which improves the interaction efficiency.
[0139] In summary, during the interaction between the card reader and the sensing device, when the sensing device switches to the first state, it will send a first response identifier to the card reader; at this time, after the card reader receives the first response identifier, it knows that the sensing device has switched to the first state and can send the first instruction corresponding to the first state to it, allowing it to enter the next state; after receiving the first instruction, the sensing device needs to parse it to determine whether it is the instruction corresponding to the first state, but if it cannot be parsed temporarily, the sensing device can temporarily remain in the first state to wait for subsequent instructions from the card reader. In the above scheme, if the sensing device recognizes an error, and the error is that it cannot parse the received instruction, it means that this may be caused by external interference or the signal transmission environment. At this time, it can remain in the first state and wait for the card reader to resend the instruction. There is no need to return to the idle state to restart the interaction process, which improves the interaction efficiency while ensuring fault tolerance.
[0140] In the embodiments of the present application, a state switching device is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments. The details that have been described will not be repeated here. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
[0141] The embodiment of the present application provides a state switching device. Figure 6 : This is a schematic diagram of a state switching device provided in an embodiment of the present application. The device includes:
[0142] The identification sending module 601 is configured to send a first response identification to the card reader when the sensing device switches to a first state during the interaction between the sensing device and the card reader;
[0143] The instruction receiving module 602 is configured to receive a first instruction for switching the state of the sensing device;
[0144] The state maintaining module 603 is configured to maintain the first state if the first instruction cannot be parsed.
[0145] The embodiment of the present application also provides another state switching device, Figure 7 : is a structural diagram of a state switching device provided in an embodiment of the present application, the device comprising:
[0146] The identification receiving module 701 is used to receive a first response identification during the interaction between the sensing device and the card reader; the first response identification is used to indicate that the sensing device has switched to the first state;
[0147] An instruction sending module 702 is configured to send a first instruction to the sensing device according to the first response identifier;
[0148] The instruction sending module 702 is further configured to send a second instruction to the sensing device if no second response identifier is received within the first time period; the first instruction and the second instruction are used to switch the state of the sensing device.
[0149] In summary, during the interaction between the card reader and the sensing device, when the sensing device switches to the first state, it will send a first response identifier to the card reader; at this time, after the card reader receives the first response identifier, it knows that the sensing device has switched to the first state and can send the first instruction corresponding to the first state to it, allowing it to enter the next state; after receiving the first instruction, the sensing device needs to parse it to determine whether it is the instruction corresponding to the first state, but if it cannot be parsed temporarily, the sensing device can temporarily remain in the first state to wait for subsequent instructions from the card reader. In the above scheme, if the sensing device recognizes an error, and the error is that it cannot parse the received instruction, it means that this may be caused by external interference or the signal transmission environment. At this time, it can remain in the first state and wait for the card reader to resend the instruction. There is no need to return to the idle state to restart the interaction process, which improves the interaction efficiency while ensuring fault tolerance.
[0150] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0151] The device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0152] See also Figure 8 , Figure 8 This is a schematic diagram of the structure of an electronic device provided by an optional embodiment of the present application. The electronic device can be implemented as a card reader or sensing device in the above-mentioned device, such as Figure 8 As shown, the electronic device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses and can be installed on a common motherboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface).
[0153] The processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic, or any combination thereof.
[0154] The memory 20 stores instructions that can be executed by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0155] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store data created based on the use of an electronic device for displaying a mini-program landing page, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk, or a solid-state drive; the memory 20 may also include a combination of the above-mentioned types of memory.
[0156] The electronic device further includes a communication interface 30 for the electronic device to communicate with other devices or a communication network.
[0157] The embodiments of the present application also provide a computer-readable storage medium. The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as a computer code that can be recorded in a storage medium, or implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the method shown in the above embodiment is implemented.
[0158] Although the embodiments of the present application have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present application, and such modifications and variations shall fall within the scope defined by the appended claims.
Claims
1. A state switching method, characterized in that: The method is applied to a sensing device; the method comprises: During the interaction between the sensing device and the card reader, when the sensing device switches to the first state, the sensing device returns a first response identifier to the card reader; receiving a first instruction for switching a state of the sensing device; If the first instruction cannot be parsed, the first state is maintained.
2. The method according to claim 1, characterized in that The method further comprises: receiving a second instruction; wherein the second instruction is used to switch the state of the sensing device; If the second instruction cannot be parsed, the first state is maintained.
3. The method according to claim 2, characterized in that The first instruction is the same as the second instruction.
4. The method according to claim 2, characterized in that The first instruction and the second instruction are both used to switch the sensing device from a first state to a second state; The first instruction and the second instruction have different frame formats; or the first instruction and the second instruction have different baud rates.
5. The method according to claim 4, characterized in that During the interaction between the sensing device and the card reader, the second state is the next state of the first state.
6. The method according to claim 5, characterized in that Before receiving the second instruction, the method further includes: Generate a corresponding parsing failure flag according to the parsing failure reason corresponding to the first instruction; Send the parsing failure indicator to the card reader.
7. The method according to claim 2, characterized in that The method further comprises: When the second instruction is successfully parsed, the sensing device is switched from the first state to the second state according to the second instruction, and a second response identifier is sent to the sensing device.
8. The method according to claim 7, characterized in that When the first state is a ready state, switching the sensing device from the first state to the second state according to the second instruction includes: If the second instruction obtained by parsing is a notification instruction, switching the sensing device from a ready state to a recognition state; Alternatively, if the second instruction obtained through analysis is an anti-collision instruction, the sensing device is switched from the ready state to the anti-collision state.
9. The method according to any one of claims 2 to 8, characterized in that: The second instruction is sent by the card reader according to the first response identifier when the card reader does not receive the second response identifier within the first time period; The method further comprises: receiving a target instruction; the target instruction is sent by the card reader when the card reader does not receive a second response identifier within a second time period; the second time period is greater than the first time period; According to the target instruction, the sensing device is switched from the first state to the target state.
10. The method according to claim 9, characterized in that The target state is an idle state.
11. The method according to claim 9, characterized in that The target state is a state previous to the first state, or the target state is a state between the first state and the idle state.
12. The method according to any one of claims 2 to 8, characterized in that: The method further comprises: If the first instruction is successfully parsed, the sensing device is switched from a first state to a next state according to the first instruction.
13. The method according to any one of claims 2 to 8, characterized in that: The method further comprises: receiving a third instruction; wherein the third instruction is used to switch the state of the sensing device; If the third instruction is successfully parsed and the third instruction is not an instruction for switching the sensing device from the first state to the second state, the sensing device is switched to an idle state.
14. A state switching method, characterized in that: The method is applied to a card reader; the method comprises: During the interaction between the sensing device and the card reader, a first response identifier is received; the first response identifier is used to indicate that the sensing device is switched to the first state; sending a first instruction to the sensing device according to the first response identifier; If no second response identifier is received within the first time period, a second instruction is sent to the sensing device; the first instruction and the second instruction are used to switch the state of the sensing device.
15. The method according to claim 14, characterized in that The first instruction is the same as the second instruction.
16. The method according to claim 14, characterized in that The first instruction and the second instruction have different frame formats; or the first instruction and the second instruction have different baud rates.
17. The method according to any one of claims 14 to 16, characterized in that: The sending a second instruction to the sensing device includes: sending a second instruction to the sensing device according to a target period until an end condition is reached; The termination condition is that the second response identifier is received or the second response identifier is not received within the second time period.
18. The method according to claim 16, characterized in that The sensing device includes a format set; the format set includes various instruction formats; and the method further includes: sending a second instruction in a different instruction format to the sensing device according to a target cycle until an end condition is reached; The end condition is receiving the second response identifier or traversing each instruction format in the format set.
19. The method according to claim 16, wherein The sending a second instruction to the sensing device includes: Receive a parsing failure flag, wherein the parsing failure flag is used to indicate a parsing failure reason corresponding to the first instruction; According to the reason for the parsing failure, a second instruction in a target format is sent to the sensing device.
20. The method according to any one of claims 14 to 16, characterized in that The method further comprises: When no second response identifier is received within the second time period, a target instruction is sent to the sensing device; the target instruction is used to instruct the sensing device to switch from the first state to the target state.
21. The method according to claim 20, characterized in that The target state is an idle state.
22. The method according to claim 20, characterized in that The target state is a state previous to the first state, or the target state is a state between the first state and the idle state.
23. A state switching device, characterized in that: The device is provided on the sensing device; the device comprises: an identification sending module, configured to send a first response identification to the card reader when the sensing device switches to a first state during the interaction between the sensing device and the card reader; An instruction receiving module, configured to receive a first instruction for switching the state of the sensing device; A state maintaining module is configured to maintain the first state if the first instruction cannot be parsed.
24. A state switching device, characterized in that: The device is arranged on a card reader; the device comprises: An identification receiving module, configured to receive a first response identification during the interaction between the sensing device and the card reader; the first response identification is used to indicate that the sensing device has switched to the first state; an instruction sending module, configured to send a first instruction to the sensing device according to the first response identifier; The instruction sending module is further configured to send a second instruction to the sensing device if no second response identifier is received within the first time period; the first instruction and the second instruction are used to switch the state of the sensing device.
25. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the state switching method according to any one of claims 1 to 22 by executing the computer instructions.
26. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the state switching method according to any one of claims 1 to 22.
Citation Information
Patent Citations
RFID anti-collision read-write device and control method thereof
CN103489016A
Communication method and device, electronic equipment and storage medium
CN118972829A
NFC chip anti-collision processing method and device, NFC reading equipment and medium
CN119676683A
