Card library middleware of smart card terminal equipment and smart card terminal equipment construction method
By introducing card library middleware into smart card terminal devices, the business logic and underlying card reading modules are designed layeredly, and the problems of low development efficiency and poor compatibility in the existing technology are solved, and the effects of rapid development and debugging and multi-scenario application are achieved.
Patent Information
- Application Number
- CN202411689879.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-02-07
AI Technical Summary
Under the existing smart card terminal device development mode, the terminal card library layer developers cannot directly debug and run card business, which affects the development speed, and the file structure of different cards is different, resulting in increased difficulty in terminal devices being compatible with different cards, and the business logic is complex and cumbersome.
Provide a card library middleware for smart card terminal equipment, including product factory module, business logic module, simulation test module and card reading operation interface packaging module. Through layered design, the business logic is separated from the underlying card reading module to realize the business logic in Running in different card reading modes, and simplifying interface calls at the terminal APP application layer through general interface functions.
It realizes the development and debugging and self-test of business logic on the PC side, shortens the development and debugging time of terminal equipment, improves development efficiency, and is suitable for different application scenarios such as campus, enterprise and urban buses.
Smart Images

Figure CN119398090A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of smart card terminal equipment development, and in particular to a card library middleware of a smart card terminal equipment and a smart card terminal equipment construction method. Background Art
[0002] In the field of one-card pass, with the rapid development of smart card terminal equipment and the cross-integration of different manufacturers, different industries and different cards, there are more and more application scenarios and demands for smart card terminals. However, under the current smart card terminal equipment development model, terminal card library layer developers usually encapsulate smart card reading and writing into SO libraries, which are then called by terminal APP application layer developers. Direct debugging and operation of card services cannot be performed, affecting the development speed.
[0003] In addition, the file structure planning for different cards, different manufacturers, different industries, and different cards is different, which makes it increasingly difficult for the same terminal device to be compatible with different cards, and also makes the business logic of smart card terminal devices complex and cumbersome, with poor readability.
[0004] In order to solve the above problems, people have been seeking an ideal technical solution. Summary of the invention
[0005] The object of the present invention is to address the deficiencies of the prior art and thereby provide a card library middleware for a smart card terminal device and a method for constructing the smart card terminal device.
[0006] In order to achieve the above object, the technical solution adopted by the present invention is: A first aspect provides a card library middleware for a smart card terminal device, comprising: The product factory module is used to build different smart terminal products according to different device types and different system versions, and encapsulate common interface functions for different smart terminal products to implement interface calls at the terminal APP application layer; The business logic module has built-in business logic codes for operating smart cards for different terminal products under different business systems. The business logic codes include a business function layer and a business API interface. The business API interface is used to receive API interface instructions. The business function layer is used to implement business logic according to business parameters and business API instructions. The simulation test module includes a terminal APP simulation unit, wherein the terminal APP simulation unit is provided with business logic test cases of different businesses of different terminal products under different business systems, wherein the business logic test cases include the order of calling business API interfaces, and when executing the business logic test cases, business API instructions are generated in sequence, and corresponding business API interfaces are called to execute corresponding business logic, so as to perform code tracking and debugging of business logic of the target smart terminal product; The card reading operation interface encapsulation module is used to encapsulate a unified card reading operation interface to drive the card reader of the smart terminal product.
[0007] Furthermore, the general interface function includes opening a device interface function, closing a device interface function, setting a log level interface function, and sending an interface command function; the sending interface command function is used to provide business API instructions to the business API interface; the smart terminal product is opened or closed by opening the device interface function and closing the device interface function; the log level of the smart terminal product is set by setting the log level interface function.
[0008] A second aspect provides a development system for a smart card terminal device, including a terminal device layer, a terminal card library layer, and a terminal driver layer; The terminal device layer is used to determine the underlying card reader device according to the device type parameter, and use golang to encapsulate the underlying card reader device; The terminal card library layer is the terminal card library middleware described in the first aspect; The terminal APP application layer has built-in application programs to be executed by the smart card terminal device, and implements corresponding business logic calls through the universal interface functions of the terminal card library middleware.
[0009] A third aspect provides a method for constructing a smart card terminal device, comprising the following steps: At the terminal application layer, set the application to be executed by the target smart card terminal device, and distribute different business API instructions and related parameters through SendCommand; At the terminal device layer, use golang to encapsulate a unified card reading operation interface for the target smart card terminal device to drive the card reader; In the terminal card library layer, a product factory is used to build a target intelligent terminal product according to the target device type and the target system version, and a general interface function is encapsulated for the target intelligent terminal product; Use golang to encapsulate the business module required for the target smart terminal product to operate the card, design the code structure of the business module in layers according to the APDU layer, application layer, and interface layer, and provide a business API interface to the outside. When the business API interface receives the business API instruction and business parameters, it parses the business API instruction and implements the business logic according to the business API instruction and business parameters; Construct a simulation test module, and set corresponding business logic test cases of the target smart terminal product under the target business system according to the application to be executed by the target smart card terminal device, wherein the business logic test cases include the order of calling the business API interface; Execute business logic test cases, generate business API instructions in sequence, and call the corresponding business API interface to execute the corresponding business logic, so as to track and debug the code of business logic of the target smart terminal product; after the code tracking and debugging is completed, release the terminal card library.
[0010] Compared with the prior art, the present invention has outstanding substantial features and significant progress. Specifically, the present invention abstracts smart card terminal products into product factories according to different system platforms and terminal devices, and can quickly build different smart card terminal products; the business module is designed in a layered manner, and the implementation of the terminal card library business logic is separated from the terminal underlying card reading module, so that the business logic can run in different card reading modes, so that the business logic can be developed and debugged on the PC side first, and then packaged into an SO library to run in the terminal device after the self-test passes, which greatly shortens the development and debugging time of the terminal device; the method can be applied to different application scenarios of card swiping terminal devices such as campuses, enterprises and urban buses. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 It is a structural schematic diagram of the terminal card library layer of the present invention.
[0012] Figure 2 It is a structural schematic diagram of the smart card terminal equipment development system of the present invention. DETAILED DESCRIPTION
[0013] The development model of smart card terminal equipment includes terminal APP application layer, terminal card library layer and terminal driver layer. The core of the terminal APP application layer is responsible for the implementation of terminal business logic; the terminal card library layer, that is, the middleware, is responsible for smart card-related operations, and performs different read and write operations according to the cards of different systems; the core of the terminal driver layer is responsible for the encapsulation and integration of terminal device drivers, and is compatible with different card reader chips and drivers.
[0014] Under the current smart card terminal device development model, terminal card library layer developers usually encapsulate smart card reading and writing into an SO library, which is then called by terminal APP application layer developers. Direct debugging and operation of card services cannot be performed, affecting the development speed.
[0015] To this end, this application adopts a layered design for the business module, separating the implementation of the terminal card library business logic from the terminal's underlying card reading module, so that the business logic can run in different card reading modes. This allows the business logic to be developed and debugged on the PC first, and then packaged into an SO library and run in the terminal device after passing the self-test, greatly shortening the development and debugging time of the terminal device.
[0016] The technical solution of the present invention is further described in detail below through specific implementation methods.
[0017] Example 1 This embodiment provides a card library middleware for a smart card terminal device, such as Figure 1 As shown, including: The product factory module is used to build different smart terminal products according to different device types and different system versions, and encapsulate common interface functions for different smart terminal products to implement interface calls at the terminal APP application layer.
[0018] The product factory pattern encapsulates a series of creation logic for applications with different business versions of different business systems and different device types. Specifically, it defines an abstract factory class that declares a series of creation methods for smart terminal products, but does not provide specific code implementations of the methods. The code calls specific factory objects in a specific context to create a series of smart terminal products. When the client needs a smart terminal product, it sends a request to the abstract factory. The abstract factory selects a suitable specific factory based on current requirements, namely device type, business system type, and system version, and the factory returns the required smart terminal product instance.
[0019] Specifically, the general interface function includes opening a device interface function, closing a device interface function, setting a log level interface function, and sending an interface command function; the sending interface command function is used to provide business API instructions to the business API interface; the smart terminal product is opened or closed by opening the device interface function and closing the device interface function; the log level of the smart terminal product is set by setting the log level interface function.
[0020] Log level is a way to categorize log information. By assigning different levels to log information, developers can more finely control the generation and output of logs, thereby obtaining the most valuable information in different situations. Common log levels include: 1.DEBUG: Debug level, used to output detailed debugging information, usually used in the development and testing stages.
[0021] 2.INFO: Information level, used to output general information, indicating that the system is running normally.
[0022] 3.WARNING: Warning level, used to output possible problems or abnormal situations, but will not affect the normal operation of the system.
[0023] 4.ERROR: Error level, used to output serious error information that may affect the normal operation of the system.
[0024] 5.CRITICAL: Severe error level, used to output very serious error information, which usually causes the system to crash or be unable to continue running.
[0025] The business logic module has built-in business logic codes for operating smart cards for different terminal products under different business systems. The business logic code includes a business function layer and a business API interface. The business API interface is used to receive API interface instructions; the business function layer is used to implement business logic according to business parameters and business API instructions.
[0026] The business logic module includes a business API interface, specifically, Figure 1 As shown, it includes the business system 1 terminal 1 interface set, the business system 1 terminal 2 interface set...the business system n terminal 1 interface set, and the business system n terminal 2 interface set.
[0027] An API interface is a set of predefined functions, data structures, and classes that are defined in a software library or operating system for application programs to call. The main purpose of an API is to provide an interface that allows developers to use certain functions without having to know the internal implementation details of these functions.
[0028] It can be understood that the business logic module also includes a business application layer, in which the function programs shared by different terminal products under different business systems when operating smart cards are stored. Each function program provides a business API interface to the outside, so that the function program in the business application layer can be called by multiple applications through the business API interface.
[0029] It should be noted that the business systems here include but are not limited to campus card, enterprise card, and city bus card. The terminal product does not refer to a single product. Taking the campus card system as an example, the terminal equipment can include access control terminal products, consumer terminal products, water and electricity terminal products, etc. Supported cards include not only company card cards, but also third-party cards, UnionPay cards, social security cards, etc. Business types include not only standard card consumption services, cross-system card transfer services, and self-service card issuance services, but also third-party card reading and writing services, and reserve APDU instruction sending channels.
[0030] In particular, the Proto file is used to define the business API interface. Proto is a free, open source, cross-platform data format for serializing structured data. It is independent of language and platform and is highly scalable.
[0031] Of course, in actual development, other methods can also be used to define business API interfaces.
[0032] The simulation test module includes a terminal APP simulation unit, which is provided with business logic test cases for different businesses of different terminal products under different business systems. The business logic test cases include the order of calling business API interfaces. When executing the business logic test cases, business API instructions are generated in sequence, and the corresponding business API interfaces are called to execute the corresponding business logic, so as to track and debug the business logic code of the target smart terminal product.
[0033] The card reading operation interface encapsulation module is used to encapsulate a unified card reading operation interface to drive the card reader of the smart terminal product.
[0034] Among them, it should be noted that the unified card reading operation interface is internally compatible with PC card readers, smart terminals, handheld devices, self-service devices and read-write chips with different Android settings, and externally outputs interfaces that can operate CPU cards, PSAM cards and M1 cards, so that the smart card terminal card library can meet the use of different terminals in enterprises, schools or bus companies in the next few years, and can be used not only in A711 terminals, but also in third-party handheld devices, PCs, self-service machines and other devices; supported cards include not only company one-card cards, but also third-party cards and UnionPay cards, social security cards, etc. The supported business types include not only the company's standard card swiping consumption business, cross-system card transfer business, self-service card issuance business, but also third-party card reading and writing business, and an APDU instruction sending channel is reserved.
[0035] Furthermore, the card library middleware is also provided with a card reader simulation unit for simulating a PC-side card reader; according to the business logic test cases in the terminal APP simulation test program, the card reader simulation unit and the corresponding business API interface in the business logic module are called to perform code tracking and debugging of the business logic.
[0036] Example 2 This embodiment provides a development system for a smart card terminal device, which is characterized by: Figure 2 As shown, it includes a terminal device layer, a terminal card library layer and a terminal driver layer; The terminal device layer is used to determine the underlying card reader device according to the device type parameter, and use golang to encapsulate the underlying card reader device; The terminal card library layer is the terminal card library middleware described in Example 1; The terminal APP application layer has built-in application programs to be executed by the smart card terminal device, and implements corresponding business logic calls through the universal interface functions of the terminal card library middleware.
[0037] Specifically, the terminal APP application layer is provided with application programs of different terminal products of different business systems, such as business system 1 terminal 1, business system 1 terminal 2... business system n terminal 1, business system n terminal 2. When in use, the corresponding application program is selected according to the required smart terminal type and business system and version and sent to the target smart terminal.
[0038] Furthermore, the terminal card library layer designs a product factory model, abstracts the product factory at the program entry, and uses the product factory to obtain corresponding application programs from the terminal APP application layer according to different device types and different system versions, build different smart terminal products, and encapsulate common interface functions for different smart terminal products.
[0039] Example 3 This embodiment provides a method for constructing a smart card terminal device, including the following steps: At the terminal application layer, set the application to be executed by the target smart card terminal device, and distribute different business API instructions and related parameters through SendCommand; specifically, implement business logic calls through JAVA; At the terminal device layer, use golang to encapsulate a unified card reading operation interface for the target smart card terminal device to drive the card reader, achieve internal compatibility with PC-side card readers and read-write chips with different Android settings, and output interfaces that can operate CPU cards, PSAM cards, and M1 cards. In the terminal card library layer, the target intelligent terminal product is constructed according to the target device type and the target system version by using the product factory, and the universal interface function is encapsulated for the target intelligent terminal product; the universal interface function includes an opening device interface function, a closing device interface function, a setting log level interface function and a sending interface command function; Use golang to encapsulate the business module required for the target smart terminal product to operate the card, design the code structure of the business module in layers according to the APDU layer, application layer, and interface layer, and provide a business API interface to the outside. When the business API interface receives the business API instruction and business parameters, it parses the business API instruction and calls the corresponding business application layer to implement the business logic according to the business API instruction and business parameters; Construct a simulation test module, and set corresponding business logic test cases of the target smart terminal product under the target business system according to the application to be executed by the target smart card terminal device, wherein the business logic test cases include the order of calling the business API interface; Execute business logic test cases, generate business API instructions in sequence, and call the corresponding business API interface to execute the corresponding business logic to track and debug the business logic code of the target smart terminal product.
[0040] Further, the service API interface forwards the instruction through the sending interface command function encapsulated by the product factory to send the instruction to the smart card. It should be noted that the definition of the service API interface in this embodiment is defined by the Proto file, and of course it can also be defined in other ways.
[0041] Furthermore, a card reader simulation unit is provided at the terminal card library layer. According to the business logic test cases in the terminal APP simulation test program, the card reader simulation unit and the corresponding business API interface in the business logic module are called to track and debug the business logic code, thereby realizing development and debugging of the business logic on the PC side first, and then packaging it into an SO library and running it in the terminal device after the self-test passes, which greatly shortens the development and debugging time of the terminal device.
[0042] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or some technical features can be replaced by equivalents without departing from the spirit of the technical solution of the present invention, which should be included in the scope of the technical solution for protection of the present invention.
Claims
1. A card library middleware for a smart card terminal device, characterized in that: include: The product factory module is used to build different smart terminal products according to different device types and different system versions, and encapsulate common interface functions for different smart terminal products to implement interface calls at the terminal APP application layer; The business logic module has built-in business logic codes for operating smart cards for different terminal products under different business systems. The business logic codes include a business function layer and a business API interface. The business API interface is used to receive API interface instructions. The business function layer is used to implement business logic according to business parameters and business API instructions. The simulation test module includes a terminal APP simulation unit, wherein the terminal APP simulation unit is provided with business logic test cases of different businesses of different terminal products under different business systems, wherein the business logic test cases include the order of calling business API interfaces, and when executing the business logic test cases, business API instructions are generated in sequence, and corresponding business API interfaces are called to execute corresponding business logic, so as to perform code tracking and debugging of business logic of the target smart terminal product; The card reading operation interface encapsulation module is used to encapsulate a unified card reading operation interface to drive the card reader of the smart terminal product.
2. The card library middleware of a smart card terminal device according to claim 1, characterized in that: The general interface function includes an open device interface function, a close device interface function, a set log level interface function and a send interface command function; the send interface command function is used to provide business API instructions to the business API interface; the smart terminal product is opened or closed by opening the device interface function and closing the device interface function; the log level of the smart terminal product is set by setting the log level interface function.
3. The card library middleware of a smart card terminal device according to claim 1, characterized in that: The card library middleware is also provided with a card reader simulation unit for simulating a PC-side card reader; according to the business logic test cases in the terminal APP simulation test program, the card reader simulation unit and the corresponding business API interface in the business logic module are called to perform code tracking and debugging of the business logic.
4. A development system for a smart card terminal device, characterized in that: Includes terminal device layer, terminal card library layer and terminal driver layer; The terminal device layer is used to determine the underlying card reader device according to the device type parameter, and use golang to encapsulate the underlying card reader device; The terminal card library layer is the terminal card library middleware according to any one of claims 1 to 3; The terminal APP application layer has built-in application programs to be executed by the smart card terminal device, and implements corresponding business logic calls through the universal interface functions of the terminal card library middleware.
5. The development system of a smart card terminal device according to claim 4, characterized in that: The terminal card library layer designs a product factory mode, abstracts the product factory at the program entry, and uses the product factory to build different smart terminal products according to different device types and different system versions, and encapsulates common interface functions for different smart terminal products.
6. A method for constructing a smart card terminal device, characterized in that: The following steps are involved: At the terminal application layer, set the application to be executed by the target smart card terminal device, and distribute different business API instructions and related parameters through SendCommand; At the terminal device layer, use golang to encapsulate a unified card reading operation interface for the target smart card terminal device to drive the card reader; In the terminal card library layer, a product factory is used to build a target intelligent terminal product according to the target device type and the target system version, and a general interface function is encapsulated for the target intelligent terminal product; Use golang to encapsulate the business module required for the target smart terminal product to operate the card, design the code structure of the business module in layers according to the APDU layer, application layer, and interface layer, and provide a business API interface to the outside. When the business API interface receives the business API instruction and business parameters, it parses the business API instruction and implements the business logic according to the business API instruction and business parameters; Construct a simulation test module, and set corresponding business logic test cases of the target smart terminal product under the target business system according to the application to be executed by the target smart card terminal device, wherein the business logic test cases include the order of calling the business API interface; Execute business logic test cases, generate business API instructions in sequence, and call the corresponding business API interface to execute the corresponding business logic to track and debug the business logic code of the target smart terminal product.
7. The method for constructing a smart card terminal device according to claim 6, characterized in that: The following steps are involved: The business API interface forwards data through the sending interface command function encapsulated by the product factory.
8. The method for constructing a smart card terminal device according to claim 6, characterized in that: The following steps are involved: Use Proto files to define business API interfaces.
9. The card library construction method of a smart card terminal device according to any one of claims 6 to 8, characterized in that: The following steps are involved: At the terminal card library layer, a card reader simulation unit is also provided. According to the business logic test cases in the terminal APP simulation test program, the card reader simulation unit and the corresponding business API interface in the business logic module are called to perform code tracking and debugging of the business logic.