home *** CD-ROM | disk | FTP | other *** search
- //
- // $Id: IrOutputStream.cc,v 1.4 2000/06/07 06:53:11 sergey Exp $
- //
-
- #include <Pilot.h>
- #include "IrOutputStream.h"
-
-
- namespace IrDA
- {
- // operations
-
- bool IrOutputStream::open()
- {
- // without callback in this version
- if (_port.open(0))
- return _port.connect();
-
- return false;
- }
-
- bool IrOutputStream::open(Callback& callback)
- {
- if (_port.open(&callback))
- return _port.connect();
-
- return false;
- }
-
- void IrOutputStream::close()
- {
- _port.close();
- }
-
- // OutputStream interface
-
- void IrOutputStream::writeData(const void* data, int size)
- {
- if (_port.isConnected())
- {
- int off = 0;
- do
- {
- int txSize = size-off;
- if (txSize > _port.getMaxTxSize())
- txSize = _port.getMaxTxSize(); // couldn't send more then a MaxSize bytes
-
- _port.blockingSendData((const Byte*)data+off, txSize);
- off += txSize;
- }
- while(off < size);
- }
- }
- }
- // namespace IrDA
-