资源预览内容
第1页 / 共6页
第2页 / 共6页
第3页 / 共6页
第4页 / 共6页
第5页 / 共6页
第6页 / 共6页
亲,该文档总共6页全部预览完了,如果喜欢就下载吧!
资源描述
Linux下基于bluez与obex的服务Linux is based on the service of bluez and obexClassification: bluez/obex 2009-08-1017:1260 reading review (0) collects reportsA service side need to give each other the OBEX Object Push service charinel, so before I open the server needs to determine the service registry to SDP server, use sdptool registered under Linux commands to the service: sdptool add opush;OBEX Init () is used to initialize an obex instance handle;Argl: OBEX TRANS BLUETOOTH is used to declare the transport protocol as bluetooth;Arg2: the callback function.Arg3: flag = OBEX FL KEEPSERVER, and after receiving the request, the server can continue to receive requests from other die nts;OBEX SetUserData () sets the users own variable, which is entirely dependent on the user himself;3. BtOBEX ServerRegister () ; A server-side function dedicated to the bluetooth protocol that listens for requests sent by the client;The internal function creates a socket (call socket(AF BLUETOOTH SOCK STREAM, BTPROTO RFCOMM), bind the socket to the local bluetooth address, convert the socket to listen sockt, after the socket to listen on port from the client on the connection request;The 0BEX_Hand1eInput () function is used to read and process the received data, which will block if no data arrives.This function is called the selet () function, parameters to the system registration handle client sockt with server-side sockt, let the system to monitor the events on the socket, if is the data to the server socket, is called the accept () function for the client to create a new sockt,If the flag of 0BEX_Init () is not set to OBEX_FL_KEEPSERVER, then the service terminal socket is turned off and other client connections are forbidden;(? : the accept () for the client to create a new socket, and returns its descriptor, then the newly created socket port is to redistribute or the original channel from the server, if the redistribution, only register the service on the server channel, if there is no redistribution, so is more than one client to use the same channel? 0 (studying studying) o.5. The callback: OBEX_EV_ACCEPTHINT;OBEX_ServerAccept () returns the socket for the above clientFunction to create a internal obex instance handle, and copies the server handle parameters to the handle, obtain the server handle fd (accept the client to create a socket), after removing the server itself of fd;This function also sets the callback function and Userdata for the newly created obex instance handleSo far, have the server for the client to create a completely independent obex instance handle, then the server operations are made by the handle logo, the server socket continued to monitor other client connection request;Callback: OBEX EV REQDONE: OBEX CMD CONNECT:10. callback: OBEX_EV_REQHINT a request is coming;Invoke OBEX_ObjectSetRsp (object, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS) to set the response operation code11. callback: OBEX_EV_REQCHECK: the first received request package has been parsed;1. callback: OBEX_EV_PROGRESS (the receipt of n events indicates that the customer is correct in transmitting the contents of the file);13. Callback: OBEX EV REQ: OBEX CMD PUT;OBEX_ObjectSetRsp (object, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS) sets the response operation code;At this point,Client files are transferred and processed:OBEX ObjectGetNextHeader () takes the n ame and con tent of the file separately;Callback: OBEX_EV_REQDONE: OBEX_CMD_PUTCallback: OBEX_EV_REQHINT a request is coming 16. Callback: OBEX_EV_REQ: : OBEX_CMD_DISCONNECTOBEX_ObjectSetRsp (object, OBEX_RSP_SUCCESS, OBEX_RSP_SUCCESS) sets the response operation code;Callback: OBEX_EV_REQDONE: OBEX_CMD_DISCONNECT;OBEX_TransportDisconnect (handle) disconnects;Note: this function simply closes the socket and does not release the resources that the handle occupies, so you need to release the resources that the handle consumes when applied.OBEX_Cleanup () turns off obex handle and frees the resources that the handie consumes(the function also closes the client and the server-side socket);At this point, the server receives one instance from the clientOBEX is short for Object Exchang, which is IrDA? The protocol for infrared transmission, but it is not limited to specific underlying transports, can be run on blueteeth, usb, and TCP/IP. OBEX is primarily a session layer protocol, but also includes the application layer It can transmit any object, which is usually used to transfer files, images, business CARDS (Vcard) and calendar (Veal), etc OpenOBEX is an open source OBEX protocol implementation that provides both client and server functionality This article briefly introduces OBEX and OpenOBEXOBEX protocol stack on top of irDA (infrared protocol):IrLAP is the data link layer protoco1.IrLMP is a multiplexing protoco1.Tiny TP provides f1ow contro1.IAS is Information Access ServiceInfrared proto
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号