Smart card reading method, system and device and terminal equipment
By detecting SIM card insertion, Bluetooth communication, and LED display feedback, the portability and intelligent diagnostic issues of traditional SIM card debugging equipment have been solved. This enables intelligent real-time data feedback and fault diagnosis, improving operational efficiency and equipment portability.
Patent Information
- Application Number
- CN202510767897.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-10-21
AI Technical Summary
Traditional SIM card debugging equipment relies on wired interfaces, which limits portability and lacks real-time data display and intelligent diagnostic capabilities. It cannot meet the wireless, intelligent, and efficient needs of the Internet of Things era.
By detecting the SIM card insertion action, abnormal states can be identified in real time. The system connects to an external terminal via Bluetooth communication, and the display module synchronously displays APDU commands and response data. Fault information is also fed back through LED indicators, realizing embedded monitoring and automatic diagnosis.
It improves the portability and operational efficiency of debugging equipment, realizes intelligent real-time data feedback and fault diagnosis, shortens the debugging cycle, and reduces the risk of manual intervention and misoperation.
Smart Images

Figure CN120822529A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communications, and in particular to a smart card reading method, system, device and terminal equipment. Background Art
[0002] Traditional SIM card debugging equipment suffers from numerous technical drawbacks: Relying on traditional wired interfaces, such as USB, for connection, it limits portability and fails to meet remote debugging requirements. The lack of an interactive interface also results in limited operational flexibility. Regarding data interaction and display, an external computer is required to view communication data during debugging, complicating the operational process and resulting in poor real-time performance, making it difficult to quickly respond to debugging data feedback. In terms of fault diagnosis, the equipment lacks embedded algorithms and hardware-level automatic monitoring capabilities, making it unable to identify abnormalities such as SIM card insertion and removal status, poor contact, or missing files in real time. Manual troubleshooting is required, resulting in inefficient and error-prone troubleshooting. Furthermore, most existing technologies are single-function designs. For example, some devices only support Bluetooth communication but lack local real-time display capabilities, or only have a display but cannot implement APDU (Application Protocol Data Unit) command interaction. Furthermore, there is a lack of innovative solutions that integrate multiple modules, such as Bluetooth communication, real-time data display, intelligent diagnosis, and dual power supply modes. This makes it difficult to adapt to the comprehensive requirements of the Internet of Things era for wireless, intelligent, portable, and efficient debugging equipment.
[0003] Furthermore, current technology lacks intelligent diagnostics and embedded algorithms for real-time monitoring of SIM card status, forcing manual troubleshooting. Early designs were not adapted to the wireless and intelligent needs of the Internet of Things and mobile scenarios.
[0004] In view of the above problems, the existing technology is in urgent need of improvement. Summary of the Invention
[0005] In view of the above-mentioned defects in the prior art, a first aspect of the present invention provides a smart card reading method, which includes the following steps:
[0006] Step S1: Detect the insertion of the SIM card and read the SIM card information to identify abnormal conditions;
[0007] Step S2: establishing a communication connection with an external user terminal, forwarding the abnormal status to the user terminal, obtaining the APDU command sent by the user terminal to perform SIM card operations, and then transmitting the response data of the SIM card back to the user terminal and / or card reader for display;
[0008] Step S3: diagnose the abnormality type after the SIM card operation according to the response data of the SIM card, and control the LED indicator and display module of the card reader to output corresponding fault feedback information.
[0009] In the smart card reading method as described above, optionally, step S1 further includes the following steps:
[0010] Step S1.1: When the detection pin level changes from high to low, it is determined that the SIM card has been inserted; conversely, when the detection pin remains at a low level, first check the cumulative number of abnormalities in the current smart card module slot: if the cumulative number of abnormalities is less than 3, activate the SIM card through a cold reset operation;
[0011] If the SIM card is activated successfully, the ATR (Answer To Reset) response data will be returned; otherwise, the retry process will be started, and the maximum number of retries will not exceed three times; if the cumulative number of abnormalities is greater than or equal to three, it will be determined as a permanent fault and the card abnormality handling process will be started;
[0012] Step S1.2: If no ATR response data is received after the cold reset operation, it is determined that no SIM card is inserted or the SIM card physical layer is abnormal;
[0013] Step S1.3: If the key file is missing or the contact is poor, the APDU returns an error status code, and it is determined that the file layer or communication is abnormal.
[0014] In the smart card reading method as described above, optionally, in step S1.1, the ATR data returned by the SIM card is parsed and checked to see whether it complies with the protocol specification; if not, a retry process is entered.
[0015] In the smart card reading method as described above, optionally, in step S1.3, the file information of the SIM card is read one by one and checked to see if any file is missing; if any file is missing, a retry process is entered; otherwise, the accumulated number of abnormalities of the SIM card is cleared, and the SIM card is then deemed to be a normal card;
[0016] If the retry fails three times, the corresponding error message will be displayed on the display module and the LED indicator will show the corresponding status;
[0017] If an external user terminal device is connected via Bluetooth, the error information is synchronously sent to the external terminal device; at the same time, the accumulated abnormal number of the SIM card is cleared.
[0018] In the smart card reading method as described above, optionally, in step S2, the display module adopts a dual-line real-time refresh mode: the first line displays the original APDU instruction sent to the SIM card, and the second line displays the response data returned by the SIM card; when there is no card or the card is abnormal, the specific error message is displayed; if the length of the response data exceeds the display limit, the key fields are scrolled and displayed.
[0019] In the smart card reading method as described above, optionally, in step S3, the abnormality type of the SIM card includes at least one of: no SIM card inserted, abnormal SIM card, and normal SIM card;
[0020] When no SIM card is inserted or the SIM card physical layer is abnormal, the LED indicator remains on;
[0021] When a SIM card abnormality is detected, the LED indicator flashes;
[0022] When the SIM card status is normal, the LED indicator is off.
[0023] In order to achieve the above-mentioned purpose, the second aspect of the present invention provides a smart card reading system, which uses the smart card reading method described in any one of the first aspects above, including a smart card reader and a user terminal device; the card reader detects the insertion action of the SIM card and reads the SIM card information, and identifies the abnormal state; the card reader establishes a communication connection with the user terminal, forwards the abnormal state to the user terminal, obtains the APDU instruction sent by the user terminal to perform the SIM card operation, and then transmits the response data of the SIM card back to the user terminal and / or the display module of the card reader for display; the card reader diagnoses the type of abnormality after the SIM card operation based on the response data of the SIM card, and controls the LED indicator light and display module of the card reader to output corresponding fault feedback information.
[0024] In order to achieve the above-mentioned purpose, the third aspect of the present invention provides a smart card reading device, which implements the smart card reading method as described in any one of the first aspects above, including a main control module, a smart card module, an LED module, a Bluetooth module, a display module and a power module; wherein the main control module is communicatively connected with the smart card module, the Bluetooth module and the display module respectively, and the LED module is physically connected with the main control module; the power module is physically connected with the main control module, the smart card module, the LED module, the Bluetooth module and the display module.
[0025] In order to achieve the above-mentioned purpose, the fourth aspect of the present invention provides a terminal device, including a memory, a processor and a computer program stored in the memory and runnable on the processor, characterized in that when the processor runs the program, it implements the smart card reading method as described in any one of the first aspects above.
[0026] In order to achieve the above-mentioned purpose, the fifth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions or a computer program, and when the computer-executable instructions or the computer program are processed and executed, the smart card reading method as described in any one of the above-mentioned first aspects is implemented.
[0027] In summary, the smart card reading method, system, device, and terminal device provided by the present invention solve the problems of traditional devices relying on wired connections and lacking real-time display and intelligent diagnosis by detecting the SIM card status, transmitting data to the user terminal in real time, diagnosing the type of abnormality, and feeding back fault information. It has the advantages of improving the portability of debugging equipment, realizing real-time data feedback, enhancing the intelligent level of fault diagnosis, and optimizing operational efficiency.
[0028] Specifically, the present invention achieves significant beneficial effects through multi-module collaborative innovation: the dual-line display screen directly and synchronously displays APDU instructions and response data, and cooperates with Bluetooth remote backhaul to realize "local + remote" dual real-time monitoring, shortening the debugging cycle; through embedded monitoring combined with LED and screen feedback, it automatically identifies the abnormal status of the SIM card and quickly locates the fault type, reducing manual intervention and improving the efficiency of troubleshooting; the risk of misoperation is reduced through the linkage between LED and screen; and it provides integrated tools for multiple types of users to promote the transformation of debugging to wireless intelligence.
[0029] The concept, specific structure and technical effects of the present invention will be further described below in conjunction with the accompanying drawings to fully understand the purpose, characteristics and effects of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is a flow chart of an embodiment of a smart card reading method provided by the present invention;
[0031] Figure 2 yes Figure 1 Schematic diagram of the startup process of the smart card reading method;
[0032] Figure 3 yes Figure 1 Detailed flowchart of exception handling in the smart card reading method;
[0033] Figure 4 This is a schematic diagram of the module structure of a smart card reader provided by the present invention;
[0034] Figure 5 yes Figure 4 MCU oscillation circuit diagram of the main control module of the smart card reader;
[0035] Figure 6 yes Figure 4 The lithium battery charging circuit diagram of the power module of the smart card reader;
[0036] Figure 7 yes Figure 4 A power conversion circuit diagram of a power module of a smart card reader;
[0037] Figure 8 yes Figure 4 The step-down circuit diagram of the power module of the smart card reader;
[0038] Figure 9 yes Figure 4 OLED circuit diagram of the display module of the smart card reader;
[0039] Figure 10 yes Figure 4 The overall circuit diagram of the main control module of the smart card reader device;
[0040] Figure 11 yes Figure 4 Circuit diagram of the Bluetooth module in the smart card reader device. DETAILED DESCRIPTION
[0041] In order to make the technical means, creative features, objectives and effects of the invention easier to understand, the invention is further described below with reference to specific diagrams. However, the invention is not limited to the following implementation cases.
[0042] It should be noted that the structures, proportions, sizes, etc. illustrated in the drawings in this specification are only used to match the contents disclosed in the specification so that people familiar with this technology can understand and read them. They are not used to limit the conditions under which the present invention can be implemented. Therefore, they have no substantive technical significance. Any modification of the structure, change in the proportion relationship or adjustment of the size should still fall within the scope of the technical content disclosed in the present invention without affecting the efficacy and purpose that can be achieved by the present invention.
[0043] Terms such as “comprise” and “include” indicate that in addition to the components directly and explicitly stated in the description and claims, the technical solution of the present invention does not exclude the situation where it has other components that are not directly or explicitly stated.
[0044] It should also be noted that the terms "upper", "inner", "outer", etc. indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present disclosure and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present disclosure.
[0045] In addition, the term "and / or" in this document simply describes an association between related objects, indicating that three possible relationships exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. Furthermore, the character " / " in this document generally indicates that the related objects are in an "or" relationship.
[0046] Traditional SIM card debugging equipment uses a wired interface connection, which limits device mobility and makes it impossible to support remote debugging scenarios. The lack of an operating interface leads to redundant command interaction paths. Data visualization relies on an external computer terminal, resulting in response delays. The lack of physical layer status monitoring functions leads to delayed anomaly identification. Due to the lack of an embedded anomaly diagnosis algorithm, it is impossible to analyze the changes in the electrical characteristics of the SIM card insertion action in real time, making it difficult to distinguish between transient poor contact and permanent hardware failures, resulting in insufficient fault classification accuracy. The communication protocol stack does not implement the APDU instruction transparent transmission mechanism, resulting in frequent switching between the hardware interface and the host computer software during the debugging process, significantly reducing operational continuity.
[0047] For example, in the on-site debugging scenario of IoT devices, technicians need to carry a traditional card reader device equipped with a USB interface to perform SIM card testing. When the device is deployed in a small space or high altitude, the physical cable connection limits the device placement angle, resulting in an obstructed view of the SIM card insertion and removal operation. During the debugging process, the laptop needs to be continuously connected to capture the ATR response data, which creates the risk of device dragging during mobile inspection operations. When the SIM card contacts are oxidized, resulting in intermittent communication interruptions, the device can only return a hexadecimal error code through the serial port and cannot automatically trigger the reset and retry process, forcing technicians to repeatedly perform the insertion and removal operations and manually parse the log files. When the EF_ICCID file fails to be read, due to the lack of a file system integrity check mechanism, it is difficult to distinguish between poor contact and file corruption, resulting in frequent incorrect replacement of normal SIM cards.
[0048] If these issues are not addressed, wired connections will restrict the ability to deploy devices in mobile scenarios, increasing the time and safety risks of field operations. Data visualization delays will increase the time gap between exception responses and operational instructions, reducing the efficiency of problem location during debugging. The lack of physical layer status monitoring will extend fault classification time, and misdiagnosis may lead to unnecessary hardware replacement. The lack of automated exception handling mechanisms will continue to rely on manual judgment, significantly reducing overall operational efficiency in batch device debugging scenarios and making it difficult to meet the real-time requirements of IoT device operation and maintenance.
[0049] In this regard, Figure 1 In the embodiment shown, a smart card reading method of the present invention may specifically include the following steps:
[0050] Step S1: Detect the insertion action of the SIM card and read the SIM card information to identify abnormal status.
[0051] In this embodiment, the SIM card information includes but is not limited to key files such as IMSI (International Mobile Subscriber Identity), ICCID (Integrated Circuit Card Identity), and KI (Authentication Key Identifier). Abnormal conditions in this step include file missing.
[0052] Before step S1, Figure 2 As shown, the following steps are also included: the smart card reader is powered on; wherein, it is determined whether an external power source is connected. If so, the external power source is used as the power source, while simultaneously charging the lithium battery; otherwise, the internal power source is used as the power source. Specifically, when the smart card reader detects that the power button has been pressed, it immediately checks whether an external power source is connected via USB. If an external power source is available, it is used first, while simultaneously charging the device's internal lithium battery. If no external USB power source is connected, the device relies on the lithium battery for power. Once the device power supply is stable, the main control module begins to boot. Once booting is complete, the main control module establishes communication connections with the Bluetooth module, display module, and smart card module in sequence.
[0053] Furthermore, if Figure 3 As shown, in an optional embodiment, step S1 may further include the following steps:
[0054] Step S1.1: When the detection pin level changes from high to low, it is determined that the SIM card has been inserted; conversely, when the detection pin remains at a low level, first check the cumulative number of abnormalities in the current smart card module slot: if the cumulative number of abnormalities is less than 3, activate the SIM card through a cold reset operation.
[0055] If the SIM card is activated successfully, the ATR response data will be returned; otherwise, the retry process will be entered, and the maximum number of retries will not exceed three times; if the cumulative number of exceptions is greater than or equal to three times, it will be determined as a permanent fault and the card exception handling process will be entered.
[0056] In this embodiment, the ATR data returned by the SIM card is parsed and checked to see if it complies with the protocol specification; if not, a retry process is entered.
[0057] It's important to note that when a SIM card is inserted into a device, the card reader sends a reset command to the card to obtain a response. The SIM card's Automatic Transmitter Record (ATR) contains information about the card itself, such as card type, speed, and voltage. The ATR consists of a series of bytes, each containing different information about the card. This information is used for initialization and communication with SIM-enabled devices.
[0058] In this embodiment, the protocol specification check of the ATR data includes at least one of protocol version matching verification, data field length compliance verification, and check code correctness verification. In the protocol version matching verification, the byte indicating the protocol type in the ATR data is compared with the preset standard protocol list. If the match is not successful, the protocol is determined to be incompatible. In the data field length compliance check, the total length of the ATR data and the segment length of each information field are checked according to the protocol specification, and an exception is triggered when a field is too long or missing. The check code correctness verification is performed by calculating the checksum or XOR value of the received data and comparing it with the check code carried at the end of the ATR data. If they are inconsistent, the data integrity is determined to be damaged.
[0059] Specifically, after the SIM card is activated, the ATR data is first received and the data content is parsed layer by layer. During the protocol version matching verification stage, the protocol identification byte of the ATR data is extracted and compared with the stored standard protocol parameter table. If it is found that the protocol identifier does not exist in the standard parameter table, a protocol mismatch flag is immediately generated. Subsequently, a data field length compliance check is performed, and the ATR data is split according to the field structure defined by the protocol specification. The historical byte length, the number of interface bytes, and the subsequent extension fields are checked one by one to see if there are any excesses. Finally, the checksum verification module calculates the checksum value of the received data and verifies its consistency with the checksum at the end of the ATR data.
[0060] Step S1.2: If no ATR response data is received after the cold reset operation, it is determined that no SIM card is inserted or the physical layer of the SIM card is abnormal.
[0061] Optionally, if any of the above checks detect an anomaly, the system marks the anomaly as a protocol layer error rather than a physical layer fault and triggers a retry. During the retry, the voltage parameters for the cold reset operation are adjusted to 3.3V ± 0.2V, and the clock frequency is set to an adjustable mode between 1MHz and 5MHz. If compliant ATR data cannot be obtained after three retries, the system resets the accumulated anomaly count to zero to avoid falsely triggering a permanent fault.
[0062] Step S1.3: If the key file is missing or the connection is poor, the APDU returns an error status code, and the file layer or communication is abnormal. APDU is the "language" of smart card communication, and it achieves efficient and reliable data exchange through standardized instructions (command APDU) and responses (response APDU).
[0063] In this step, the SIM card's file information is read one by one and checked for missing files. If any files are missing, the retry process begins. Otherwise, the accumulated exception count for the SIM card is reset to zero, and the SIM card is deemed normal. The file information can be read one by one using a sequential traversal or by prioritizing key files. For example, the file directory hierarchy can be checked layer by layer, or the existence of key files such as EF_ICCID and EF_IMSI can be prioritized. The retry process can be executed three times, or the threshold range can be adjusted based on the actual scenario, for example, between two and five times. Error information can be displayed in various ways, including but not limited to scrolling text, fixed error codes, or icon symbols. The LED status can distinguish error types by different colors or flashing frequencies. The Bluetooth transmission protocol can use the standard HID specification or a custom data frame format to ensure compatibility with external terminal devices. The accumulated exception count reset operation can be automatically triggered after each successful retry or executed when the external terminal sends a reset command.
[0064] Specifically, during the file information reading phase, the system checks file integrity item by item to accurately identify specific file missing issues, avoiding missing details due to global detection. When a file is detected as missing, a pre-set retry process is initiated. For example, after the first failure, the system waits 200 milliseconds before attempting to read again. If three attempts fail, the system considers the failure to be persistent.
[0065] If the retry fails three times, the corresponding error message will be displayed on the display module and the LED indicator will show the corresponding status;
[0066] If an external user terminal device is connected via Bluetooth, the error message will be sent to the external terminal device synchronously; at the same time, the accumulated abnormal number of the SIM card will be cleared.
[0067] As a preferred embodiment, the solution of this application is specifically implemented as follows:
[0068] During the SIM card initialization phase, the card reader receives the ATR data from the SIM card and first parses it. This process involves extracting key information from the ATR data, such as the protocol version, parameters, and operating mode. The card reader then compares this parsed information with pre-set protocol specifications. These pre-set specifications include the length range of the ATR data, the presence of required fields, and the validity of each field value.
[0069] For example, the card reader checks whether the ATR data contains valid historical bytes, verifies whether the T=0 and T=1 protocol support flags are correctly set, and checks whether the interface characters comply with ISO / IEC 7816. If any item in the ATR data is found to be inconsistent with the protocol specifications, the card reader immediately triggers a retry process.
[0070] Step S2: Establish a communication connection with an external user terminal, forward the abnormal status to the user terminal, obtain the APDU command sent by the user terminal to perform SIM card operations, and then return the response data of the SIM card to the user terminal and / or card reader for display.
[0071] Optionally, in step S2, the display module adopts a dual-line real-time refresh mode: the first line displays the original APDU instruction sent to the SIM card, and the second line displays the response data returned by the SIM card; when there is no card or the card is abnormal, the specific error message is displayed; if the length of the response data exceeds the display limit, the key fields are scrolled and displayed.
[0072] Among them, the dual-line real-time refresh mode can be configured to refresh the upper and lower lines independently. The first line fixedly displays the original text of the APDU instruction currently being sent, and the second line dynamically updates the response data. Under abnormal conditions, the error information is converted into readable text through a pre-defined character encoding format, such as converting the error code SW1SW2 to "ERR:0x6A82". When the length of the response data exceeds the single-line display capacity, the scrolling display mechanism intercepts the fields containing the status code and check value at fixed time intervals, such as preferentially extracting the first 4 bytes and the last 2 bytes of data. The display of the original text of the APDU instruction is output as is in hexadecimal. The response data needs to be parsed before display to separate the status code and the data body, for example, "9000" is displayed independently at the end of the line as a success mark.
[0073] Specifically, during the APDU instruction transmission phase, the first line refreshes and locks the content of the currently executed instruction in real time, retaining a complete record of operations. The second line dynamically switches the display mode according to the response status of the SIM card: if the response data is normal, the complete data body and status code are parsed and displayed in byte segments; if no card or card abnormality is detected, the second line immediately overwrites the original content and outputs the error type code and description text. When the response data exceeds the display line width, the key field scrolling display loops through the intercepted data segments at a preset scrolling rate, for example, switching the display window every 500 milliseconds. The display module's exception handling priority is higher than regular data display. When an exception is triggered, the original data stream is interrupted and an error message is forced to be output until the normal refresh mode is restored after the abnormal state is resolved. This solution achieves visual separation of data flow and rapid feedback of abnormal states through the hierarchical division of the physical display area and dynamic refresh logic, solving the problem of key information loss caused by long data truncation.
[0074] Step S3: diagnose the abnormality type after the SIM card operation according to the response data of the SIM card, and control the LED indicator light and display module of the card reader to output corresponding fault feedback information.
[0075] Optionally, in step S3, the abnormality type of the SIM card includes at least one of: no SIM card inserted, abnormal SIM card, and normal SIM card;
[0076] When no SIM card is inserted or the SIM card physical layer is abnormal, the LED indicator remains on;
[0077] When a SIM card abnormality is detected, the LED indicator flashes;
[0078] When the SIM card status is normal, the LED indicator is off.
[0079] In this step, the abnormality type is refined into three categories: no card inserted, physical layer abnormality and logical layer abnormality. Each type of abnormality corresponds to a unique visual signal. When no card is inserted or a physical layer abnormality is detected, the LED is always on to prompt the user to check the card slot contact or the integrity of the card body. For example, when the detection pin is continuously low and the cold reset operation fails three times, the LED enters the always on state. When it is detected that the APDU returns an error status code or the file is missing, the LED switches to a flashing state to distinguish non-physical faults. The flashing frequency can be twice per second. The LED off state is only triggered when the cumulative number of abnormalities of the SIM card is cleared and the response data is normal. The mapping relationship between the abnormality type and the LED state is realized through the pin output level of the main control module. For example, the LED is always on when pin 2 outputs a high level, and the LED flashes when pin 2 periodically outputs high and low levels. Through the cumulative number of abnormalities judgment mechanism in step S1.1 in the pre-information, the LED state can be associated with a permanent fault. For example, when the number of abnormalities exceeds three times, the always on state is triggered, thereby avoiding confusion with a temporary fault.
[0080] Specifically, after a SIM card is inserted, if the detection pin level remains unchanged or a cold reset fails, it is determined that a card is not inserted or a physical layer error has occurred. The main control module controls the LED to remain permanently lit. If a missing file is detected or an APDU returns an error status code, the main control module controls the LED to flash at a preset frequency. For example, in step S1.3, the flashing mode is activated after three failed attempts to read the file. When the SIM card response data is normal and the cumulative number of exceptions is reset to zero, the LED turns off to eliminate false positives. The main control module's firmware algorithm links the abnormality type to the LED state. For example, a permanent light control function is invoked when a physical layer abnormality is detected, and a flashing control function is invoked when a logical layer abnormality is detected. This three-state differentiation mechanism allows users to quickly determine the fault level. For example, in the permanent light state, card slot contact is prioritized, while in the flashing state, APDU instruction or file integrity is checked, without relying on detailed error information from the display module. This solution deeply integrates hardware indicators with software diagnostic results. For example, the abnormality count in step S1.1 is linked to the LED status in step S3, making fault feedback information direct and actionable.
[0081] To achieve the above-mentioned objectives, the present invention further provides a smart card reading system, which may specifically include a smart card reader and a user terminal device; the card reader detects the insertion of a SIM card and reads the SIM card information to identify an abnormal state; the card reader establishes a communication connection with the user terminal, forwards the abnormal state to the user terminal, obtains the APDU instruction sent by the user terminal to perform SIM card operations, and then transmits the SIM card response data back to the user terminal and / or the display module of the card reader for display; the card reader diagnoses the type of abnormality after the SIM card operation based on the SIM card response data, and controls the LED indicator and display module of the card reader to output corresponding fault feedback information. This system uses the smart card reading method of any of the aforementioned embodiments, which will not be described in detail here.
[0082] In order to achieve the above object, the present invention also provides a smart card reader device, such as Figure 4 As shown, the device may include a main control module, a smart card module, an LED module, a Bluetooth module, a display module, and a power module. The main control module is communicatively connected to the smart card module, the Bluetooth module, and the display module, respectively; the LED module is physically connected to the main control module; and the power module is physically connected to the main control module, the smart card module, the LED module, the Bluetooth module, and the display module. This device can implement the smart card reading method described in any of the aforementioned embodiments.
[0083] like Figures 4 to 11 As shown:
[0084] The main control module may include an MCU oscillator circuit and a main control module circuit, wherein the MCU oscillator circuit is used to provide a main control clock signal and the main control module circuit is used for communication control. Optionally, the main control module is connected to the display module via I2C and is connected to the smart card module and the Bluetooth module via UART.
[0085] The MCU oscillation circuit may include a clock circuit, which may include:
[0086] The low-speed external clock LSE unit is connected to the PC14 and PC15 pins of the main control chip to provide a clock source for the real-time clock RTC;
[0087] High-speed external clock HSE unit, connected to an external crystal oscillator through the OSCIN and OSCOUT pins to generate a high-frequency system clock signal;
[0088] The oscillation stabilization circuit is composed of capacitors connected in parallel on both sides of the crystal oscillator, which is used to assist the crystal oscillator in starting up and maintain the oscillation frequency stability.
[0089] like Figure 5 and Figure 10As shown, the main control module uses crystal oscillators and capacitors to build HSE and LSE clock circuits, where PC14 and PC15 of the main control chip serve as the pins of the LSE oscillator to provide a clock source for the RTC, OSCIN and OSCOUT are configured as pins for connecting the HSE crystal oscillator, and the HSE provides a high-frequency clock signal. Capacitors C10, C11, C12, and C13 are used to assist the crystal oscillator in starting and stabilizing the oscillation frequency. In this embodiment, the main control module circuit uses the STM32F103C8T6 chip as the main control chip. In the main control chip: Pin 1 is the power pin, which is connected to the power converted by the power module; Pin 2 is connected to an external LED light, which is controlled by outputting high and low levels; Pins 3, 4, 5, and 6 are used as crystal oscillator pins, which are externally connected to the corresponding crystal oscillator; Pin 7 is the reset pin, which triggers the chip system reset operation when a low level is detected; Pins 12 and 13 are respectively connected to the Bluetooth module, where Pin 12 is used to send data and Pin 13 is used to receive data; Pins 21 and 22 are respectively connected to the display module, Among them, pin 22 is the data line, and pin 21 is the clock line; pin 47 and pin 44 are both grounded, used to configure the chip startup mode to boot from the user flash memory; pin 38 is used to control the power switch of the smart card module. When the output is high, the MOS tube Q1 is turned on to power the smart card module; pin 30 is connected to the IO of the smart card module as a data exchange pin; pin 29 is connected to the CLK of the smart card module to provide it with a clock signal; pin 28 is connected to the RST of the smart card module to provide it with a reset signal; pin 27 is connected to the DET of the smart card module to detect whether the smart card module is inserted with a SIM card.
[0090] The smart card module may include a card slot circuit for physically contacting and connecting with the SIM card and providing IO, CLK, and RST signals. Optionally, the smart card module is connected to the main control module via UART communication.
[0091] The LED module may include an indication circuit, which may indicate a state of being constantly on, flashing, or off through three-state indication according to high and low level signals to feedback the current state of the SIM card.
[0092] Optionally, the LED module is physically connected to the main control module via GPIO, and the indicator circuit of the LED module uses three-state indication to indicate a state of constant light, flashing, or off according to the high and low level signals output by the GPIO to feedback the status of the SIM card.
[0093] The Bluetooth module may include a Bluetooth module circuit for wireless communication between the main control module and an external terminal device. Optionally, the Bluetooth module is connected to the main control module via a UART communication.
[0094] like Figure 11As shown, the Bluetooth module is HC-05. In the Bluetooth module: pin 1 and pin 2 are connected to pin 13 and pin 12 of the main control module respectively, pin 12 of the Bluetooth module is connected to the power supply, and pin 31 is connected to an LED. The state of the LED is controlled to indicate whether a Bluetooth connection is established.
[0095] The display module may include an OLED display module circuit for displaying SIM card commands and response data. Optionally, the display module is connected to the main control module via I2C communication.
[0096] like Figure 9 As shown, the OLED display module circuit of the display module uses SSD1306 as the display module chip. In the display module chip: Pin 19 and Pin 18 are the data pin and clock pin, respectively, which are connected to Pin 21 and Pin 22 of the main control chip through the I2C interface. During configuration, Pin 11 is connected to a high level and Pin 10 is connected to a low level. In the display module chip: Pin 26 is the IREF pin, which is the segment output current reference pin. The current reference value of the segment drive circuit is set through an external resistor, thereby controlling the output current of each segment of the OLED screen. The external resistor R3 keeps the IREF current at a preset level. Pin 15 is used to distinguish whether the transmission is display data or command. Pin 13 is the chip select pin, which is used to select whether the display module chip responds to the operation of the external main control device. Pin 14 is the reset pin RES#. Connecting RES# to a high level, that is, to VCC, keeps the reset pin of the chip always high and in an unreset state. Pin 20 is the data pin, which can be used for data transmission in I2C mode and is externally connected to Pin 21 of the main control module.
[0097] The power module can include a lithium battery charging circuit, a power conversion circuit, and a step-down circuit. The lithium battery charging circuit charges and protects the lithium battery, the power conversion circuit automatically switches between USB power supply and lithium battery power supply, and the step-down circuit provides a stable voltage source for the entire system. Optionally, the step-down circuit reduces the 5V or lithium battery voltage to 3.3V for powering the system.
[0098] like Figure 6As shown in the figure, the lithium battery charging circuit of the power module adopts the TP4056 charging management chip. In the charging management chip, pin 4 is connected to the USB 5V voltage, pin 4 serves as the power pin, and pin 8 serves as the enable pin; pins 6 and 7 are used to control the on and off of the indicator light. If it is detected that the battery is fully charged during charging, the green light will be on, otherwise the red light will be on; pin 2 controls the charging current, and pin 1 is used to detect the temperature of the thermistor R15; the positive and negative poles of Bal are connected to the positive and negative poles of the lithium battery respectively, pin 5 is responsible for charging the lithium battery, and resistors R11 and R12 are used to protect the circuit; resistor R16 is used to set the charging current, and its resistance value determines the size of the charging current; resistors R13, R14 and thermistor R15 work together to prevent the temperature from being too high; capacitors C14 and C15 are used for filtering.
[0099] like Figure 7 As shown in the figure, the power conversion circuit of the power module is connected to the 5V power supply through the USB interface, the positive and negative poles of Bal are connected to the positive and negative poles of the lithium battery, and the two diodes IN5819 and the MOS tube CJ2301 work together for switch control: when USB power input is detected, the card reader automatically switches to the USB power supply mode; if no USB power is detected, the lithium battery is enabled as the power supply, and the Vout of the power conversion circuit is connected to the step-down circuit.
[0100] like Figure 8 As shown in the figure, the power module uses XC6206P332MR as a step-down chip. The Vout of the step-down circuit of the power module is connected to the Vout of the power conversion circuit. SW2 is used as a power switch to control whether the power module supplies power to other modules. In the step-down chip: Pin 3 is the input end of the step-down power supply, Pin 2 is the output end VCC of the power supply after step-down, which is used to supply power to other functional modules. Capacitors C17 and C18 are used for filtering.
[0101] In order to achieve the above objectives, the present invention also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the smart card reading method as described in any of the foregoing embodiments can be implemented.
[0102] The processor and memory may be provided separately or integrated together, for example, integrated into a system on chip (SOC) of a terminal device.
[0103] In order to achieve the above objectives, the present invention also provides a computer-readable storage medium, which stores computer-executable instructions or computer programs. When the computer-executable instructions or computer programs are processed and executed, the smart card reading method as described above is implemented.
[0104] The computer-readable storage medium is, for example, a memory. The memory may be a volatile memory or a non-volatile memory, or the memory may include both volatile memory and non-volatile memory. The non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).
[0105] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes a number of instructions for causing one or more computer devices (such as personal computers, servers, or network devices) to execute all or part of the steps of the methods described in various embodiments of the present invention.
[0106] The preferred embodiments of the present invention have been described in detail above. It should be understood that numerous modifications and variations based on the concepts of the present invention are possible without inventive effort by those skilled in the art. Therefore, any technical solution that can be derived by one skilled in the art through logical analysis, reasoning, or limited experimentation based on the concepts of the present invention and the prior art should be within the scope of protection defined by the claims.
Claims
1. A smart card reading method, characterized in that: The steps include: Step S1: Detect the insertion of the SIM card and read the SIM card information to identify abnormal conditions; Step S2: establishing a communication connection with an external user terminal, forwarding the abnormal status to the user terminal, obtaining the APDU command sent by the user terminal to perform SIM card operations, and then transmitting the response data of the SIM card back to the user terminal and / or card reader for display; Step S3: diagnose the abnormality type after the SIM card operation according to the response data of the SIM card, and control the LED indicator and display module of the card reader to output corresponding fault feedback information.
2. The smart card reading method according to claim 1, wherein: The step S1 further comprises the following steps: Step S1.1: When the detection pin level changes from high to low, it is determined that the SIM card has been inserted; conversely, when the detection pin remains at a low level, first check the cumulative number of abnormalities in the current smart card module slot: if the cumulative number of abnormalities is less than 3, activate the SIM card through a cold reset operation; If the SIM card is activated successfully, the ATR response data will be returned; Otherwise, it will enter the retry process, and the maximum number of retries will not exceed three times; If the cumulative number of abnormalities is greater than or equal to three times, it is considered a permanent fault and the card abnormality processing process is entered; Step S1.2: If no ATR response data is received after the cold reset operation, it is determined that no SIM card is inserted or the SIM card physical layer is abnormal; Step S1.3: If the key file is missing or the contact is poor, the APDU returns an error status code, and it is determined that the file layer or communication is abnormal.
3. The smart card reading method according to claim 1, wherein: In step S1.1, the ATR data returned by the SIM card is parsed and checked to see if it complies with the protocol specification; if not, a retry process is entered.
4. The smart card reading method according to claim 1, wherein: In step S1.3, the file information of the SIM card is read one by one and checked to see if any file is missing; if any file is missing, the retry process is started; otherwise, the accumulated abnormal number of the SIM card is cleared, and the SIM card is considered to be a normal card; If the retry fails three times, the corresponding error message will be displayed on the display module and the LED indicator will show the corresponding status; If an external user terminal device is connected via Bluetooth, the error information is synchronously sent to the external terminal device; at the same time, the accumulated abnormal number of the SIM card is cleared.
5. The smart card reading method according to claim 1, wherein: In step S2, the display module adopts a two-line real-time refresh mode: the first line displays the original APDU instruction sent to the SIM card, and the second line displays the response data returned by the SIM card; when there is no card or the card is abnormal, the specific error message is displayed; if the length of the response data exceeds the display limit, the key fields are scrolled and displayed.
6. The smart card reading method according to claim 1, wherein: In step S3, the abnormality type of the SIM card includes at least one of: no SIM card inserted, SIM card abnormality, and SIM card normal; When no SIM card is inserted or the SIM card physical layer is abnormal, the LED indicator remains on; When a SIM card abnormality is detected, the LED indicator flashes; When the SIM card status is normal, the LED indicator is off.
7. A smart card reading system, characterized in that: A smart card reading method according to any one of claims 1 to 6 includes a smart card reader and a user terminal device; the card reader detects the insertion action of a SIM card and reads SIM card information to identify an abnormal state; the card reader establishes a communication connection with the user terminal, forwards the abnormal state to the user terminal, obtains an APDU instruction sent by the user terminal to perform a SIM card operation, and then transmits response data of the SIM card back to the user terminal and / or a display module of the card reader for display; the card reader diagnoses the type of abnormality after the SIM card operation based on the response data of the SIM card, and controls the LED indicator light and display module of the card reader to output corresponding fault feedback information.
8. A smart card reader, characterized in that: Implementing the smart card reading method according to any one of claims 1 to 6, comprising a main control module, a smart card module, an LED module, a Bluetooth module, a display module and a power module; wherein the main control module is communicatively connected to the smart card module, the Bluetooth module and the display module respectively, and the LED module is physically connected to the main control module; the power module is physically connected to the main control module, the smart card module, the LED module, the Bluetooth module and the display module.
9. A terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor runs the program, the smart card reading method according to any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions or a computer program, and when the computer-executable instructions or the computer program are processed and executed, the smart card reading method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method and system for detecting smart card by using handheld device and handheld device
CN104850878A
Method and mobile terminal for automatic trigger recognition and detection of SIM (subscriber identification module) card
CN106792863A
Embedded subscriber identity module card configuration method and device, communication equipment and storage medium
CN111586671A
Fault positioning method of embedded subscriber identity module card and related device
CN117119504A
Virtual card reader debugging method, system, device and equipment and storage medium
CN118916273A
