1/*
2    File:       IrComm.h
3
4    Contains:   IrCOMM protocol layer
5
6*/
7
8#ifndef __IrComm_h__
9#define __IrComm_h__
10
11#include "ttp.h"            // subclassing off tinytp
12#include "IrDscInfo.h"      // for hints
13
14class TIrGlue;
15class IrDAComm;
16
17enum {
18    kTinyTPCredit   = 2             // USB queue is 4k bytes.  2k max per irda window, so 2 packets
19};
20
21class IrComm  : public TTinyTP      // hook up to TTinyTP/CIrLSAP/TIrStream/etal
22{
23    OSDeclareDefaultStructors(IrComm);
24
25public:
26    static  IrComm *irComm(TIrGlue *irda, IrDAComm *irdacomm);
27    Boolean Init(TIrGlue *irda, IrDAComm *irdacomm);
28
29    void        free();
30    UInt32      TxBufferAvailable(void);            // max number of bytes in next write
31    UInt32      Write(UInt8 *buf, UInt32 length);   // send to peer
32    void        ReturnCredit(UInt32 bytecount);     // our consumer has released this many bytes
33    void        TryConnect(int slots);              // try to connect
34    void        Listen();                           // listen for peer connect attempt
35    void        Disconnect(void);                   // disconnect existing, abort pending
36
37
38private:                            // we implement these for tinytp
39
40    virtual void TTPDiscoverComplete (      // Discover has completed
41	int     numFound,                   // number of peers discovered
42	IrDAErr result);                    // result of discovery
43
44    virtual void TTPLookupComplete (        // Lookup completed
45	IrDAErr result,
46	UInt32  peerLSAPId);
47
48    virtual void TTPConnectIndication (     // Listen complete
49	IrDAErr result,
50	TTPSAP  SAP,                        // calling TTP SAP
51	TIrQOS *ourQOS,                     // our QoS (post negotiation)
52	TIrQOS *peerQOS,                    // peer QoS (post negotiation)
53	int     MaxSduSize,                 // calling MaxSduSize
54	TTPBuf  *UserData);                 // calling UserData
55
56    virtual void TTPConnectConfirm (        // Connect complete
57	TTPSAP  SAP,                        // called TTP SAP
58	TIrQOS *ourQOS,                     // our QoS (post negotiation)
59	TIrQOS *peerQOS,                    // peer QoS (post negotiation)
60	int     MaxSduSize,                 // called MaxSduSize
61	TTPBuf  *UserData);                 // called UserData
62
63    virtual void TTPDisconnectIndication (  // Disconnect complete
64	int     reason,                     // passed up from IrLMP (not)
65	TTPBuf  *UserData);
66
67    virtual void TTPDataIndication (        // Read complete
68	TTPBuf  *UserData,                  // data read
69	TTP_Read_Status status);            // Ok or Truncated
70
71    virtual void TTPUDataIndication (       // UData Read complete (unimpld)
72	TTPBuf  *UserData);                 // data read
73
74    virtual void TTPAcceptDoneIndication(   // accept done (we're really open now)
75	IrDAErr result);                    // just result code, buffer copied during accept call
76
77    virtual void TTPBackEnable(void);       // Called when more TTP buffers available
78
79    // fields ...
80
81    IrDAComm        *fIrDAComm;             // back to my manager
82    UInt32          fPeerAddress;           // address of our ircomm peer
83    UInt16          fMaxPacketSize;         // max size to transmit to peer in one packet
84    Boolean         fConnected;             // all the state we need
85
86
87};  // class IrComm
88
89
90#endif  // __IrComm_h__
91
92
93
94
95