Method for realizing UWB communication to support socket interface
By creating a new UWB protocol family and socket interface in the Linux system kernel, the problem of the lack of standard interfaces in the existing UWB communication in the Linux system is solved, and the effect of simplifying the development of upper-level applications and reducing the difficulty of development is achieved.
Patent Information
- Application Number
- CN202411941360.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-02-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing UWB communication lacks a standard upper-level application interface in Linux systems, which leads to upper-level application developers being familiar with complex protocol families, increasing development difficulty and cycle.
By creating a new protocol family in the Linux system kernel, defining and registering the protocol family, a socket interface that supports UWB communication is provided. This method includes creating a new protocol family, defining a protocol family structure, registering a protocol family, initializing a socket interface, binding a socket descriptor, listening to client connections, establishing communication, sending and receiving data, etc.
It realizes the provision of standard UWB communication socket interface in Linux system, reduces the difficulty and cycle of upper-level application developers to design and develop UWB communication, and simplifies the development and porting of UWB functions.
Smart Images

Figure CN119544810A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of short-distance communication, and specifically relates to a method for realizing a UWB communication supporting a socket interface. Background Art
[0002] UWB: Ultra Wide Band (UWB) technology is a wireless carrier communication technology that uses long-distance communication between two UWB-equipped devices to measure distance and confirm direction angles for positioning. At the same time, UWB characteristics also support high-speed data transmission. Compared with other existing communication technologies, it has the advantages of accurate positioning, high transmission rate, strong anti-interference ability, and low power consumption.
[0003] Socket communication: Socket communication originated from Unix, and one of the basic design logics of Unix / Linux is "everything is a file", which can be operated in the mode of "open -> read / write -> close". Socket is an implementation of this mode. Socket is a special file, and some socket functions are operations on it (read / write IO, open, close). Socket is an intermediate software abstraction layer for communication between the application layer and the Unix / Linux protocol family. It is a set of interfaces, which hides the complex Unix / Linux protocol family behind the Socket interface. For users, a set of simple Socket interfaces is all, allowing Socket to organize data to comply with the specified protocol.
[0004] At present, UWB related technologies have been successfully commercialized in many scenarios in the industry, but there is no standard upper-level application interface. Compared with similar short-distance communication methods such as WIFI, Bluetooth, and NFC, the socket interface is implemented in the Linux system. As long as the upper-level application developers understand socket communication programming, they can develop communications involving network, NFC, Bluetooth and other functions based on the standard socket interface socket, bind, connect, send, recv, close. However, when communicating with UWB, they need to be familiar with complex protocol families. It is difficult for upper-level application developers to design and develop communications involving UWB, and the development cycle is long. It is not convenient for upper-level applications to develop and transplant UWB functions. Therefore, it is necessary to develop a new method to implement UWB communication support socket interface to solve the existing problems. Summary of the invention
[0005] The purpose of the present invention is to provide a method for realizing UWB communication supporting a socket interface, so as to solve the problems of high difficulty and long development cycle of UWB communication.
[0006] To achieve the above object, the present invention provides the following technical solution: a method for implementing UWB communication supporting a socket interface, comprising: Create new protocol families; Define the protocol family to be created; Define the implemented protocol and register it; Register and initialize the socket interface and get the allocated socket descriptor; Bind the socket descriptor to the local interface address; The UWB server monitors whether there is a client connection.
[0007] Preferably, after the UWB server monitors whether there is a client connection, if the client sends an agreed identifier through the address, the UWB server establishes communication with the client; The UWB server and the client send data by calling the UWB fixed component to send data API; The UWB server and the client receive data by calling the UWB data receiving API.
[0008] Preferably, if the client sends the agreed identifier via the address, the server and the client establish communication including: When the client sends the agreed identifier through uwbdata_sock_connect and the server receives the agreed identifier through uwbdata_sock_accept, the server and the client establish communication to send and receive data.
[0009] Preferably, the creating a new protocol family includes: adding the newly created protocol family to the Linux system kernel protocol family, and the newly created protocol family ID value is different from the protocol ID value already registered in the Linux system kernel protocol family.
[0010] Preferably, the protocol family created by the definition includes: a protocol family created based on a Linux system kernel structure definition, the Linux system kernel structure includes a create function, and the create function is filled with a socket structure filled with a proto_ops structure. The create function is a socket creation method pointer of the protocol family, and the create method pointer points to the socket structure filled with the proto_ops structure.
[0011] Preferably, the protocol family created based on the Linux system kernel structure definition includes: a new protocol family through net_proto_family.
[0012] Preferably, the initialization socket interface is performed by initializing the socket interface based on a variable of proto_ops type.
[0013] Preferably, the defining and registering of the implemented protocol includes: registering the protocol family into the Linux system kernel using sock_register.
[0014] Preferably, binding the socket descriptor to the local interface address comprises: binding the descriptor to the local interface address via uwbdata_sock_bind.
[0015] Preferably, the method for the UWB server to monitor whether there is a client connection includes: monitoring whether there is a client connection through a uwbdata_sock_listen function.
[0016] The technical effects and advantages of the present invention are as follows: the method for implementing a socket interface supporting UWB communication adds a socket supporting UWB communication in the Linux system kernel by adding a new protocol family, provides a set of standard socket interfaces supporting UWB communication for upper-layer application development, provides support for upper-layer application design and development involving UWB, thereby reducing the difficulty of upper-layer application developers in designing and developing UWB communication and shortening the development cycle; by supporting the implementation of sockets for UWB communication in the Linux kernel framework, the development and transplantation of upper-layer applications involving UWB functions are facilitated. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a schematic diagram of the framework of the present invention; Figure 2 The present invention discloses a method for using a UWB socket in a user APP process. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0019] The present invention provides Figure 1 , Figure 2 A method for implementing a UWB communication support socket interface as shown in , comprising: 1. Create a new Socket protocol family PF_UWB, that is, add the protocol family PF_UWB to the Linux system kernel protocol family. Note that the ID value of the established protocol family PF_UWB should not conflict with the registered protocol; 2.net_proto_family is a structure of the Linux kernel. The open source C language code is as follows. It defines a new protocol family based on the Linux system kernel structure net_proto_family. This structure includes the create function, which implements the socket structure filled by the proto_ops structure in create; struct net_proto_family { int family; int (*create)(struct net *net, struct socket *sock, int protocol, int kern); / / Protocol family socket creation method pointer, each protocol family implementation is different.
[0020] struct module *owner; }; 3. Use sock_register to register the protocol family PF_UWB to the Linux kernel, and add a socket interface for the protocol family PF_UWB during the system initialization phase.
[0021] 4. Implement the uwb_sock_create C language method and call the corresponding method of establishing UWB according to the protocol implemented by the UWB protocol family.
[0022] 5.proto_ops is a set of function pointers corresponding to socket structure calls, which is a mapping of socket structure calls to functions. Some operation functions will continue to jump through the proto structure jump table and enter the specific communication protocol processing; The socket interface implementation requires entering the UWB communication protocol, defining variables based on the proto_ops structure type, and initializing them.
[0023] 6. Based on a set of socket structures and variables provided by the Linux kernel network framework and the Linux socket interface layer, as well as the UWB communication protocol, implement the socket interface and initialization steps based on the initialization of proto_ops type variables; The specific implementation steps are as follows: Step 1: Define a new protocol family and register it; the code is as follows: #definle PF_UWB 41 / *UWB sockets* / static struct net_proto_family uwb_sock_family_ops={ .owner = THIS_MODULE, .family = PF_UWB, .create = uwb_sock_create }; Sock_register(&uwb_sock_family_ops); Step 2: Define the implemented protocol and register it; the code is as follows: static sturct proto uwbdata_proto = { .name = "UWBDATA", .owner = THIS_MODULE, .obj_size = sizeof(struct uwbdata_proto) }; Proto_register(&uwbdat_proto,0); Step 3: Register the socket interface; the code is as follows: static const struct proto_ops uwbdata_sock_ops = { .family = PF_UWB, .owner = THIS_MODULE, .release = uwbdata_sock_release, .bind = uwbdata_sock_bind, .connect = uwbdata_sock_connect, .listen = uwbdata_sock_listen, .accept = uwbdata_sock_accept, .getname = uwbdata_sock_getname, .sendmsg = uwbdata_sock_sendmsg, .recvmsg = uwbdata_sock_recvmsg, .shutdown = uwbdata_sock_shutdown, .setsockopt = uwbdata_sock_setsockopt, .getsockopt = uwbdata_sock_getsockopt, .ioctl = uwbdata_sock_ioctl, .poll = uwb_sock_poll, .socketpair = sock_no_socketpair, .mmap = sock_no_mmap }; Step 4: Based on a set of socket system calls provided by the Linux kernel network framework and the Linux socket interface layer, based on the UWB communication protocol, implement the socket interface initialized based on the proto_ops type variable. The key necessary interfaces are described below; 4.1 After completing the first step of creating a socket and allocating a socket descriptor, the ultra-wideband communication device binds the descriptor to the local interface address through uwbdata_sock_bind when acting as a UWB server communication role; the socket descriptor is allocated through the Linux socket interface API at the beginning, (1) The operating system kernel maintains a file descriptor table for each process, which records all files, sockets and other resources opened by the process.
[0024] (2) A descriptor is an index into the file descriptor table, which can be used to access the corresponding resource. It is a reference or handle to the resource.
[0025] (3) The socket descriptor is the index of the socket in the file descriptor table of the process, through which operations such as reading and writing and setting options can be performed on the socket.
[0026] The code is as follows: static int uwbdata_sock_bind(struct socket *sock, structsockaddr *addr, int addr_len); 4.2: After binding the descriptor to the local interface address, the UWB server listens for client connections through the uwbdata_sock_listen function; the code is as follows: static int uwbdata_sock_listen(struct socket *sock, int backlog); 4.3: The UWB server is ready to accept the connection. The current UWB server calls the firmware API function interface provided by the UWB IC manufacturer to initiate the corresponding callback; static int uwbdata_sock_accept(struct socket *sock, struct socket *newsock, int flags); 4.4: The client sends the agreed identifier through the address to establish communication with the UWB server; static int uwbdata_sock_connect(struct socket *sock, struct sockaddr*addr, int alen, int flags); When the client sends the agreed identifier through uwbdata_sock_connect, the UWB server receives the connection request initiated by the client through uwbdata_sock_accept. It means that the server UWB device and the client UWB device can establish normal communication, and the client and the UWB server can send and receive data; 4.5: uwbdata_sock_sendmsg sends data by calling the send data API interface of the firmware provided by the UWB IC factory; static int uwbdata_sock_sendmsg(struct socket *sock, struct msghdr *msg,size_t len); 4.6: uwbdata_sock_recvmsg receives data by calling the data receiving API interface of the firmware provided by the UWB IC factory; static int uwbdata_sock_recvmsg(struct socket *sock, struct msghdr *msg,size_t size, int flags); 4.7: Close the communication and end this communication.
[0027] static int uwbdata_sock_shutdown(struct socket *sock, int how); The method for implementing a socket interface supporting UWB communication adds a socket supporting UWB communication in a manner of adding a new protocol family on the Linux system kernel, provides a set of standard socket interfaces supporting UWB communication for upper-layer application development, provides support for upper-layer application design and development involving UWB, thereby reducing the difficulty of upper-layer application developers in designing and developing UWB communication and shortening the development cycle; by supporting the implementation of the socket for UWB communication in the Linux kernel framework, the development and transplantation of upper-layer applications involving UWB functions are facilitated.
[0028] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for implementing UWB communication supporting a socket interface, characterized in that: include: Create new protocol families; Define the protocol family to be created; Define the implemented protocol and register it; Register and initialize the socket interface and get the allocated socket descriptor; Bind the socket descriptor to the local interface address; The UWB server monitors whether there is a client connection.
2. A method for implementing UWB communication supporting socket interface according to claim 1, characterized in that: After the UWB server monitors whether there is a client connection, if the client sends the agreed identifier through the address, the UWB server establishes communication with the client; The UWB server and the client send data by calling the UWB fixed component to send data API; The UWB server and the client receive data by calling the UWB data receiving API.
3. A method for implementing UWB communication supporting socket interface according to claim 2, characterized in that: If the client sends the agreed identifier through the address, the server and the client establish communication including: When the client sends the agreed identifier through uwbdata_sock_connect and the server receives the agreed identifier through uwbdata_sock_accept, the server and the client establish communication to send and receive data.
4. A method for implementing UWB communication supporting socket interface according to claim 1, characterized in that: The creating of the new protocol family includes: adding the newly created protocol family to the Linux system kernel protocol family, wherein the ID value of the newly created protocol family is different from the protocol ID value already registered in the Linux system kernel protocol family.
5. The method for implementing UWB communication supporting socket interface according to claim 1, characterized in that: The protocol family defined and created includes: a protocol family defined and created based on a linux system kernel structure, wherein the linux system kernel structure includes a create function member variable, and a create method pointer points to a socket structure filled with a proto_ops structure.
6. A method for implementing UWB communication supporting socket interface according to claim 5, characterized in that: The protocol family created based on the Linux system kernel structure definition includes: a new protocol family through net_proto_family.
7. A method for implementing UWB communication supporting socket interface according to claim 1, characterized in that: The initialization socket interface initializes the socket interface by using a variable based on the proto_ops type.
8. The method for implementing UWB communication supporting socket interface according to claim 1, characterized in that: The defining and registering of the implemented protocol includes: using sock_register to register the protocol family into the Linux system kernel.
9. A method for implementing UWB communication supporting socket interface according to claim 1, characterized in that: Binding the socket descriptor to the local interface address includes: binding the descriptor to the local interface address through uwbdata_sock_bind.
10. A method for implementing UWB communication supporting socket interface according to claim 1, characterized in that: The method for the UWB server to monitor whether there is a client connection includes: monitoring whether there is a client connection through a uwbdata_sock_listen function.
Citation Information
Patent Citations
AFDX-based socket implementation method
CN111212061A
Method for socket interface using asynchronousconnection based to IEEE 1394
KR1020060072251A
Method and apparatus for a mobile station application to receive and transmit raw packetized data
US6862276B1
Ultrawideband asynchronous tracking system and method
US8116350B1