| 
 
注册时间2006-3-11最后登录1970-1-1 
 | 
 
| wqx和手机不能文件传输,这很令人不爽, 所以最近研究红外文件传输协议,好让我
 自己编一个通讯程序.
 红外文件传输协议有好几种,但我只找到
 OBEX协议,而且我在wqx中也搜索到OBEX
 这几个字母,所以深入了解了一下.我看了
 本OBEX 1.0的书,倒是有所收获
 在数据通讯中,每次传输我称之为一次会话
 并以数据包为单位,每个数据包结构如下:
 xx,yyyy,zzzz.....
 xx:一个字节(类推),为操作指码
 yyyy:数据包总长度
 zzzz....:数据区(也可以没有该部分)
 例如:如果没有数据区,那么yyyy为0x0003
 以下是操作码含义:
 Version 1.0
 请求中的操作码                         名称                           说明
 0x80 // high bit always set    Connect                      请求连接
 0x81 // high bit always set    Disconnect                   断开连接
 0x02 (0x82)                    Put                          发送对象
 0x03 (0x83)                    Get                          请求对象
 0x04 (0x84)                    Command                      send a responseless packet
 0x85 // high bit always set    SetPath                      设置路径
 0xFF // high bit always set    Abort                        abort the current operation.
 0x05 to 0x0F                   Reserved                     not to be used w/out extension to this specification
 0x10 to 0x1F                   User definable               use as you please with peer application
 0x00 to 0x0F              none              reserved
 回复中的操作码                                    说明
 0x10 (0x90)               100               继续
 0x11 (0x91)               101               Switching Protocols
 0x20 (0xA0)               200               成功
 0x21 (0xA1)               201               Created
 0x22 (0xA2)               202               Accepted
 0x23 (0xA3)               203               Non-Authoritative Information
 0x24 (0xA4)               204               No Content
 0x25 (0xA5)               205               Reset Content
 0x26 (0xA6)               206               Partial Content
 0x30 (0xB0)               300               Multiple Choices
 0x31 (0xB1)               301               Moved Permanently
 0x32 (0xB2)               302               Moved temporarily
 0x33 (0xB3)               303               See Other
 0x34 (0xB4)               304               Not modified
 0x35 (0xB5)               305               Use Proxy
 0x40 (0xC0)               400               Bad Request - server couldn’t understand request
 0x41 (0xC1)               401               Unauthorized
 0x42 (0xC2)               402               Payment required
 0x43 (0xC3)               403               Forbidden - operation is understood but refused
 0x44 (0xC4)               404               Not Found
 0x45 (0xC5)               405               Method not allowed
 0x46 (0xC6)               406               Not Acceptable
 0x47 (0xC7)               407               Proxy Authentication required
 0x48 (0xC8)               408               Request Time Out
 0x49 (0xC9)               409               Conflict
 0x4A (0xCA)               410               Gone
 0x4B (0xCB)               411               Length Required
 0x4C (0xCC)               412               Precondition failed
 0x4D (0xCD)               413               Requested entity too large
 0x4E (0xCE)               414               Request URL too large
 0x4F (0xCF)               415               Unsupported media type
 0x60 (0xE0)               500               Internal Server Error
 0x61 (0xE1)               501               Not Implemented
 0x62 (0xE2)               502               Bad Gateway
 0x63 (0xE3)               503               Service Unavailable
 0x64 (0xE4)               504               Gateway Timeout
 0x65 (0xE5)               505
 其实和Ftp-link的传输协议有点相似
 
 在数据区中又有一些格式
 数据区中可以只包含一条信息
 也可包含多条信息
 信息代码         名称      数据类型   描述
 0xC0          Count    long     传输对象的数据包数 (在请求连接时使用)
 0x01          Name     string   传输对象的名称 (通常是文件名)
 0x42          Type     char     传输对象的类型
 0xC3          Length   long     传输对象的长度
 0x44          Time      ?       时间 ISO8601
 0xC4          Time     long     date/time stamp - 4byte version (for compatibility only)
 0x05       Description string   传输对象的文本描述
 0x46         Target     ?       name of service that operation is targeted to
 0x47         HTTP       ?       an HTTP 1.x header
 0x48         Body       ?       传输对象的一个包
 0x49      End of Body   ?       传输对象的最后一个包
 0x4A         Who        ?       identifies the application using OBEX - used in Connect to tell if talking to a peer
 0x0B-0x2F  reserved     ?       this range includes all combinations of the upper 2 bits
 0x30-0x3  user defined  ?       this range includes all combinations of the upper 2 bits
 
 
 以下是接头方式
 请求端发送
 0x80    //请求连接
 0xhhhh  //数据包长度
 0xhh    //OBEX版本 0x10表示1.0
 0x00    //标志位 flags, all zero for this version of OBEX
 0xhhhh  //最大可发送数据包长度
 接收端回复
 0xA0    //成功
 0xhhhh  //数据包长度
 0xhh    //OBEX版本
 0x00    //标志位
 0xhhhh  //最大可接收数据包长度
 .......(开始传输)
 我表达能力有限,再加上我对这个协议的细节还没完全看明白,说了这么多,
 或许你的只是了解一点点,我拿出两个例子来让大家更明白
 请求端发送
 0x80
 0x0007
 0x10
 0x01  flags
 0x2000
 接收端回复
 0xA0
 0x07
 0x11
 0x00
 0x0400
 请求端发送
 0x02
 0x0422
 0x01        //HI for Name
 0x000D      //Length of Name header
 xx.txt/0    //name of object, null terminated
 0xC3        // HI for Length
 0x00006000  //Length of object is 0x6000 bytes
 0x48        //HI for Object Body chunk
 0x0403      //Length of body header (1K) plus HI and header length
 0x..........//1K bytes of body
 接收端回复:
 0x90
 0x0003
 请求端发送
 0x02        //Put, Final bit not set
 0x0406      //1030 bytes is length of packet
 0x48        //HI for Object Body chunk
 0x0403      //Length of body header (1K) plus HI and header length
 0x..........//next 1K bytes of body
 接收端回复
 0x90
 0x0003
 一直到最后一块
 请求端发送
 0x82        //Put, Final bit set
 0x0406      //1030 bytes is length of packet
 0x49        //HI for final Object Body chunk
 0x0403      //Length of body header (1K) plus HI and header length
 0x..........//next 1K bytes of body
 接收端回复
 0xA0
 0x0003
 这样就成功发送完毕
 
 好,现在我们知道了OBEX协议的部分内容
 但还有一个重要的问题没有解决
 那就是如何握手,我现在也一直搞不清
 我需要解决的问题
 1.如何握手
 2.NC3000的红外代码
 3.WQX的传输协议
 4.01页nor函数的意思
 
 不知有谁愿意帮我,我将不胜感激
 QQ:280071966
 MAIL:gt945@163.com
 | 
 |