Compression method of HCI bit mask and operation code mapping table, storage medium and equipment
By introducing branch control masks into the HCI support command bitmask and opcode mapping table, the storage space of the opcode is compressed, the problem of excessive resource occupation is solved, and the resource consumption and cost reduction is achieved, and the The requirement for upgrading Bluetooth specifications.
Patent Information
- Application Number
- CN202411078536.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-07
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-08-07
AI Technical Summary
The existing technology cannot effectively compress the command bitmask and opcode mapping table in the Bluetooth protocol stack, resulting in too large resource usage and cannot adapt to the needs of Bluetooth 5.4 specifications and subsequent specification upgrades.
By introducing a 2-bit branch control mask of the first byte in the mapping table, four combinations representing a continuous number of different opcodes, reducing storage space, for example, using the first branch control mask to represent multiple 2-byte opcodes, The second branch control mask represents the 0-byte operation code of the RFU, the third branch control mask represents the 1-byte operation code of the previous operation code multiplexed, and the fourth branch control mask represents a word with a continuous number of 1 words. Section opcode.
Without significantly increasing CPU overhead, the resource usage of HCI support command bitmask and opcode mapping tables is reduced, resource consumption and cost are reduced, and the requirements of Bluetooth specification upgrades are adapted to the needs of map tables. size.
Smart Images

Figure CN118972465A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a method, storage medium and device for compressing an HCI-supported command bit mask and an operation code mapping table. Background Art
[0002] The Bluetooth core specification specifies a command (Read Local Supported Commands command) for the host to obtain the status of the HCI (Host Controller Interface) commands supported by the controller, and then return it in the form of a bit mask Supported_Commands
[64] byte, where each bit represents a specific command, 1 for support and 0 for non-support. The host protocol stack software needs to control whether to send the corresponding command to the controller based on this information. Among them, the commands defined by HCI are identified by OGF (Opcode Group Field, upper 6 bits) + OCF (Opcode Command Field, lower 10 bits), that is, the operation code OPCODE[2] byte. Obviously, both the host and the controller have a requirement, that is, to know whether this command is supported by the operation code OPCODE[2] byte, and map it to the Supported_Commands
[64] byte mask; or its reverse search.
[0003] However, since the Bluetooth protocol stack, whether on the host side or the controller side, is applied on an embedded platform, it is required that the code size and the amount of resources occupied by const static, Flash or RAM are as small as possible. Therefore, it is imperative to compress the bit mask and opcode mapping table. The use of general lossless compression algorithms such as traditional Huffman encoding will result in a larger bit mask and opcode mapping table size, occupying more space resources, and cannot meet the needs of Bluetooth 5.4 specifications and subsequent specification upgrades. Summary of the invention
[0004] The present invention provides a compression method, storage medium and device for an HCI-supported command bit mask and an operation code mapping table, which further compresses the size of the HCI-supported command bit mask and the operation code mapping table without significantly increasing the CPU overhead during the search, thereby reducing resource consumption to better meet the needs of Bluetooth 5.4 specifications and subsequent specification upgrades.
[0005] In order to achieve the above-mentioned purpose, the first technical solution adopted by the present invention is: to provide a compression method for an HCI-supported command bit mask and an operation code mapping table, which includes: in sequence, according to the bit mask sequence number in the mapping table, the operation code is additionally set with a first byte, the first byte includes a 2-bit branch control mask, and there are four combinations according to the 2-bit branch control mask, and the four combinations are named as a first branch control mask, a second branch control mask, a third branch control mask and a fourth branch control mask; the first branch control mask is used to represent a plurality of consecutive 2-byte operation codes; the second branch control mask is used to represent a 0-byte operation code whose command is RFU, wherein RFU is Reserved for Future Use, i.e., reserved for future use; the third branch control mask is used to represent a 1-byte operation code that reuses the high-order byte of the previous operation code; and the fourth branch control mask is used to represent a consecutive 1-byte operation code.
[0006] The second technical solution adopted by the present invention is: providing a computer-readable storage medium storing computer instructions, which are operated to execute the compression method of the HCI support command bit mask and operation code mapping table in solution one.
[0007] The third technical solution adopted by the present invention is: to provide a computer device, which includes a processor and a memory, the memory stores computer instructions, and the processor operates the computer instructions to execute the compression method of the HCI support command bit mask and operation code mapping table in solution one.
[0008] The technical solution of the present invention can achieve the following beneficial effects: the compression method of the present invention reduces the size of const static resources, Flash or RAM occupied by the HCI support command bit mask and operation code mapping table without significantly increasing the CPU overhead during the search, thereby reducing resource consumption and cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 It is a schematic diagram of a specific example of the HCI support command bit mask and operation code mapping table before compression of the present invention;
[0010] Figure 2 It is a schematic diagram of a specific implementation method of the HCI support command bit mask and operation code mapping table compression method of the present invention. DETAILED DESCRIPTION
[0011] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making a clearer and more definite definition of the protection scope of the present invention.
[0012] The Bluetooth core specification specifies a command (Read Local Supported Commands command) for the host to obtain the status of the HCI (Host Controller Interface) commands supported by the controller, and then return it using the bit mask Supported_Commands
[64] byte. Each bit represents a specific command, 1 for support and 0 for non-support. The host protocol stack software needs to control whether to send the corresponding command to the controller based on this information. The commands defined by HCI are identified by OGF (Opcode Group Field, upper 6 bits) + OCF (Opcode Command Field, lower 10 bits), that is, the operation code OPCODE[2] byte. Among them, OGF is the grouping of the operation code. The current Bluetooth specification only uses about 6 values, that is, 3 bits; OCF is the command number under the OGF grouping, which is not distributed continuously but discretely.
[0013] Figure 1 It is a schematic diagram of a specific example of the HCI supporting command bit mask and operation code mapping table before compression of the present invention.
[0014] from Figure 1 As can be seen, the mapping table defined by the HCI specification mainly records the corresponding opcodes in the mapping table in the order of the bit mask serial number. However, due to historical and version upgrade reasons, the order of the Supported_Commands
[64] byte mask defined by the HCI specification does not completely match the numerical order of OPCODE, nor is it arranged in a fixed order.
[0015] Obviously, both the host and controller sides have a requirement, that is, to know whether this command is supported by the operation code OPCODE[2] byte and map it to the Supported_Commands
[64] byte mask; or its reverse search.
[0016] However, by far the simplest way to store a bitmask and opcode mapping table is as follows:
[0017]
[0018] The above method of storing the bit mask and opcode mapping table is to record all corresponding opcodes Opcode[2] in a table in the order of the low bit of the low byte, the high bit, and the high byte. In this way, the number of bytes to be stored is: number of commands * 2 bytes, which is about 332 * 2 = 664 bytes under Bluetooth core specification 5.4.
[0019] Since the Bluetooth protocol stack, whether it is the host side or the controller side, is applied in an embedded platform, the code size and the amount of resources occupied by const static, Flash or RAM are required to be as small as possible. Therefore, it is imperative to compress the mapping table of bit masks and operation codes. The present invention summarizes the law of operation codes, adds the first byte to the operation codes, and then reduces the space required for storing the operation codes by using the branch control mask in the first byte, thereby achieving the purpose of compressing the HCI support command bit mask and the operation code mapping table, thereby reducing the size and occupied resources of the HCI support command bit mask and the operation code mapping table.
[0020] Figure 2 It is a schematic diagram of a specific implementation method of the HCI support command bit mask and operation code mapping table compression method of the present invention.
[0021] In a specific embodiment of the present invention, the compression method of the HCI support command bit mask and operation code mapping table of the present invention includes process S201, and the first byte is additionally set to the operation code in sequence according to the bit mask sequence number order in the mapping table, and the first byte includes a 2-bit branch control mask. There are four combinations of the 2-bit branch control mask, and the four combinations are named the first branch control mask, the second branch control mask, the third branch control mask and the fourth branch control mask.
[0022] In this specific implementation, the 2-bit branch control mask can have four combinations, namely 0b00, 0b01, 0b10, and 0b11.
[0023] In a specific embodiment of the present invention, the mapping table is compressed in bytes.
[0024] In a specific embodiment of the present invention, the first byte also includes a 6-bit continuous number.
[0025] In this specific embodiment, the first byte includes not only the 2-bit branch control mask part but also the 6-bit operation code continuous number part, wherein the maximum operation code continuous number that can be described by the 6-bit operation code continuous number part is 2^6-1=63, which is represented by binary as: 0b111111.
[0026] In a specific embodiment of the present invention, each time the branch control mask is used, one or more consecutive operation codes are obtained, that is, an operation code range. Regardless of whether it is the first branch control mask, the second branch control mask, the third branch control mask, or the fourth branch control mask, each time it is used, one or more consecutive operation codes are obtained, that is, an operation code range.
[0027] In a specific embodiment of the present invention, the method for compressing the HCI support command bit mask and operation code mapping table of the present invention further includes a process S202 of using the first branch control mask to represent a plurality of consecutive 2-byte operation codes.
[0028] In this specific implementation, when the first branch control mask is used, a plurality of consecutive opcodes will be obtained, that is, an opcode range, and each opcode in the opcode range is 2 bytes.
[0029] Specifically, assuming that the number of consecutive opcodes is 15, the space required to store these opcodes is: number of consecutive opcodes * 2 bytes + first byte = 15 * 2 + 1 = 31 bytes, which corresponds to 15 bits of the bit mask.
[0030] In a specific embodiment of the present invention, the compression method of the HCI support command bit mask and operation code mapping table of the present invention also includes process S203, using the second branch control mask to indicate that the command is a 0-byte operation code of RFU, wherein RFU is Reserved for Future Use, i.e., reserved for future use.
[0031] In a specific embodiment of the present invention, the operation code of the RFU command is 0x0000, where 0x represents hexadecimal.
[0032] Since no specific commands have been defined for some bits of the bit mask, they are reserved for future use. All commands that have not been defined are RFU, and the opcode for the command RFU can be considered to be 0 bytes.
[0033] Specifically, assuming that the second branch control mask is used once, a continuous range of 7 opcodes is obtained, that is, 7 RFUs, then the space required to store these opcodes is: continuous number * 0 bytes + first byte = 7 * 0 + 1 = 1 byte. In other words, only 1 byte of space is actually required to store these 7 opcodes. Although the opcodes of the 7 RFUs are all 0 bytes, they correspond to 7 bits of the bit mask, that is, they occupy 7 bits of the bit mask.
[0034] In a specific embodiment of the present invention, the HCI support command bit mask and operation code mapping table compression method of the present invention also includes process S204, using the third branch control mask to represent a 1-byte operation code that reuses the high-order byte of the previous operation code.
[0035] In this specific implementation, a 1-byte opcode that reuses the high-order byte of the previous opcode is used as the low-order bit of the opcode, and the high-order bit can take the high-order byte of the previous opcode. Such an opcode only occupies 1 byte.
[0036] Specifically, assuming that the third branch control mask is used once to obtain a continuous range of 5 opcodes, the space required to store these opcodes is: continuous number * 1 byte + first byte = 5 * 1 + 1 = 6 bytes, that is, only 6 bytes of storage space are required to store these 5 opcodes, which corresponds to 5 bits of the bit mask.
[0037] In a specific embodiment of the present invention, the method for compressing the HCI support command bit mask and operation code mapping table of the present invention further includes a process S205 of using the fourth branch control mask to represent a continuous number of 1 byte operation codes.
[0038] In a specific embodiment of the present invention, the fourth branch control mask is used to represent a 1-byte operation code with a continuous quantity of 1, including: using the 6-bit continuous quantity part of the first byte to store the 6-bit high-order part of the operation code.
[0039] In this specific embodiment, when the fourth branch control mask is used, there is no 6-bit portion of the consecutive number of opcodes in the first byte, and the 6-bit portion is used to store the 6 high bits of the opcode, i.e., the OGF portion, and the number of such consecutive opcodes is fixed to only one, and such an opcode is a 1-byte opcode.
[0040] Specifically, assuming that the fourth branch control mask is used, the number of consecutive opcodes is fixed to 1, and the space required to store this opcode is: consecutive number * 1 byte + first byte = 1*1+1 = 2 bytes, which corresponds to occupying 1 bit of the bit mask.
[0041] In a specific embodiment of the present invention, different branch control masks correspond to different following bytes, that is, the following bytes depend on the branch control mask portion of the first byte.
[0042] In a specific embodiment of the present invention, different branch control masks correspond to different following bytes, including: when the branch control mask is the first branch control mask, the following byte is a 2-byte opcode; when the branch control mask is the second branch control mask, the following byte is a 0-byte opcode, fixed to RFU; when the branch control mask is the third branch control mask, the following byte is a 1-byte opcode low bit; when the branch control mask is the fourth branch control mask, the following byte is a 1-byte opcode.
[0043] The following is a detailed description of the compression method of the HCI support command bit mask and operation code mapping table of the present invention in conjunction with the specific implementation of the present invention:
[0044]
[0045] The detailed explanation of each line is as follows:
[0046] The first line (0x00|15), 0x04, 0x01, uses hexadecimal 0x00, the operation code OPCODE is 2 bytes, starting from OPCODE = 0x0401, and 15 consecutive OPCODEs (i.e. 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x040D, 0x040E, 0x040F) occupy the first 15 bits of the bit mask respectively;
[0047] The second line (0x80|1), 0x11, uses hexadecimal 0x80, the operation code OPCODE is 1 byte, and the high bit 0x04 of the OPCODE before multiplexing is reused, that is, starting from 0x0411, there is 1 consecutive OPCODE;
[0048] The third line (0x80|1), 0x13, uses hexadecimal 0x80, the operation code OPCODE is 1 byte, the high bit 0x04 of the OPCODE before multiplexing is reused, starting from 0x0413, there is 1 consecutive OPCODE;
[0049] The fourth line (0x80|1), 0x15, uses hexadecimal 0x80, the operation code OPCODE is 1 byte, and the high bit 0x04 of the previous OPCODE is reused. Starting from 0x0415, there is a continuous OPCODE;
[0050] The fifth line (0x80|1), 0x17, uses hexadecimal 0x80, the operation code OPCODE is 1 byte, and the high bit 0x04 of the previous OPCODE is reused. Starting from 0x0417, there is a continuous OPCODE;
[0051] The sixth line (0x80|5), 0x19, uses hexadecimal 0x80, the operation code OPCODE is 1 byte, and the high bit 0x04 of the OPCODE before multiplexing is reused. Starting from 0x0419, there are 5 consecutive OPCODEs (i.e. 0x0419, 0x041A, 0x041B, 0x041C, 0x041D);
[0052] The seventh line (0x80|2), 0x1f, uses hexadecimal 0x80, the operation code OPCODE is 1 byte, and the high bit 0x04 of the OPCODE before multiplexing is reused, starting from 0x041f, there are two consecutive OPCODEs (i.e. 0x041f, 0x0420);
[0053] The eighth line (0x40|7) uses hexadecimal 0x40, the operation code OPCODE is 0 bytes, which is RFU, that is, OPCODE is 0x0000, 7 consecutive RFUs;
[0054] The ninth line (0xC0|0x08), 0x01, uses hexadecimal 0xC0, OPCODE is 1 byte, the first byte does not contain the 6-bit part of the opcode, the 6-bit part is used for the high 6 bits of the opcode, i.e. the OGF part, starting from 0x0801, the continuous number is fixed at 1;
[0055] The tenth line (0x80|5), 0x03, uses hexadecimal 0x80, the operation code OPCODE is 1 byte, and the high bit 0x08 of OPCODE before multiplexing starts from 0x0803, and there are 5 consecutive ones (i.e. 0x0803, 0x0804, 0x0805, 0x0806, 0x0807).
[0056] By adopting the above compression method, under the Bluetooth core specification 5.4, the size of the HCI support command bit mask and operation code mapping table can be reduced from the original 664 bytes to 179 bytes. The size of the compressed mapping table is approximately 26.95% of the original size, which greatly reduces the resources occupied by the HCI support command bit mask and operation code mapping table. For embedded platforms, the smaller the resource consumption, the lower the cost. Moreover, as embedded products may be used in large quantities, the cost will be greatly reduced by multiples.
[0057] The following is a comparative analysis of the compression method of the present invention and the original flat OPCODE method from the perspective of search complexity:
[0058] The original mapping table in the flat OPCODE mode needs to traverse 332 commands and 664 bytes of the mapping table when searching for commands, so as to obtain the serial number of the bit mask. If it is found, the traversal process can be exited in advance.
[0059] The mapping table in the compression mode provided by the present invention still needs to traverse the entire mapping table when performing command search. By jumping a small number of branches, it is determined that after reading the subsequent 0, 1 or 2 bytes each time, the current hit operation code OPCODE range and the serial number of the bit mask that stays are determined. When the OPCODE range is hit, the traversal process can be stopped.
[0060] In summary, the HCI support command bit mask and opcode mapping table compression method of the present invention has a traversal size of about 27% of the original flat OPCODE method. Although a small number of branches are added, it is calculated that the search speed is increased by about 30%, and the search function is about 40 bytes larger, which is very effective.
[0061] Since the Bluetooth core specification is updated regularly, the number of commands will continue to increase with the upgrade of the Bluetooth core specification, and the compression effect will become more and more obvious.
[0062] In the compression method of the HCI support command bit mask and operation code mapping table of the present invention, the size of the HCI support command bit mask and operation code mapping table is further compressed without significantly increasing the CPU overhead during the search, thereby reducing resource consumption, better adapting to the needs of Bluetooth 5.4 specification and subsequent specification upgrades, and reducing costs.
[0063] In a specific embodiment of the present invention, a computer-readable storage medium stores computer instructions, and the computer instructions are operated to execute the compression method of the HCI support command bit mask and operation code mapping table described in any embodiment.
[0064] In a specific embodiment of the present application, a computer device includes a processor and a memory, the memory stores computer instructions, and the processor operates the computer instructions to execute the compression method of the HCI support command bit mask and operation code mapping table described in any embodiment.
[0065] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present application. Any equivalent structural transformations made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for compressing an HCI support command bit mask and an operation code mapping table, characterized in that: include: The operation code is additionally set with a first byte in sequence according to the bit mask sequence number in the mapping table, wherein the first byte includes a 2-bit branch control mask, and there are four combinations of the 2-bit branch control mask, and the four combinations are named as a first branch control mask, a second branch control mask, a third branch control mask, and a fourth branch control mask; Using the first branch control mask to represent a plurality of consecutive 2-byte operation codes; The second branch control mask is used to indicate that the command is a 0-byte opcode of RFU, wherein RFU stands for Reserved for Future Use, i.e., reserved for future use; The third branch control mask is used to represent a 1-byte operation code that reuses the high-order byte of the previous operation code; The fourth branch control mask is used to indicate a consecutive number of 1-byte operation codes.
2. The method for compressing the HCI support command bit mask and operation code mapping table as claimed in claim 1, characterized in that: The mapping table is compressed in bytes.
3. The method for compressing the HCI support command bit mask and operation code mapping table as claimed in claim 1, characterized in that: The first byte also contains a 6-bit continuation number.
4. The method for compressing the HCI support command bit mask and operation code mapping table as claimed in claim 1, characterized in that: Different branch control masks correspond to different following bytes.
5. The method for compressing the HCI support command bit mask and operation code mapping table as claimed in claim 4, characterized in that: The different branch control masks correspond to different follow-up bytes, including: When the branch control mask is the first branch control mask, the following byte is a 2-byte operation code; When the branch control mask is the second branch control mask, the following byte is a 0-byte operation code, which is fixed to RFU; When the branch control mask is the third branch control mask, the following byte is a 1-byte operation code low bit; When the branch control mask is the fourth branch control mask, the following byte is a 1-byte operation code.
6. The method for compressing the HCI support command bit mask and operation code mapping table as claimed in claim 5, characterized in that: The fourth branch control mask is used to represent a continuous number of 1 byte operation codes, including: The 6-bit continuous quantity portion of the first byte is used to store the 6-bit high-order portion of the operation code.
7. The method for compressing the HCI support command bit mask and operation code mapping table as claimed in claim 1, characterized in that: Each time the branch control mask is used, one or more consecutive operation codes are obtained, that is, an operation code range.
8. The method for compressing the HCI support command bit mask and operation code mapping table as claimed in claim 1, characterized in that: The operation code of the command RFU is 0x0000, where 0x represents hexadecimal.
9. A computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are operated to execute the HCI support command bit mask and operation code mapping table compression method described in any one of claims 1-8.
10. A computer device comprising a processor and a memory, wherein the memory stores computer instructions, characterized in that: The processor operates the computer instructions to execute the HCI support command bit mask and operation code mapping table compression method according to any one of claims 1-8.
Citation Information
Patent Citations
HCI code secondary generation method
CN110069258A
Host control interface command event encoding method
CN111464187A
Instruction stream compression and decompression method and device
CN111708574A
Bluetooth patch downloading method and device, electronic equipment and storage medium
CN117793697A
Method and system for transporting FM data over a Bluetooth HCI link
US20080051131A1
