1*ce058fa0SAdrien Destugues /* 2*ce058fa0SAdrien Destugues * Copyright 2017, Adrien Destugues, pulkomandy@pulkomandy.tk 3*ce058fa0SAdrien Destugues * Distributed under terms of the MIT license. 4*ce058fa0SAdrien Destugues */ 5*ce058fa0SAdrien Destugues 6*ce058fa0SAdrien Destugues 7*ce058fa0SAdrien Destugues #ifndef XMODEM_H 8*ce058fa0SAdrien Destugues #define XMODEM_H 9*ce058fa0SAdrien Destugues 10*ce058fa0SAdrien Destugues 11*ce058fa0SAdrien Destugues #include <Messenger.h> 12*ce058fa0SAdrien Destugues #include <String.h> 13*ce058fa0SAdrien Destugues 14*ce058fa0SAdrien Destugues 15*ce058fa0SAdrien Destugues class BDataIO; 16*ce058fa0SAdrien Destugues class BHandler; 17*ce058fa0SAdrien Destugues class BSerialPort; 18*ce058fa0SAdrien Destugues 19*ce058fa0SAdrien Destugues 20*ce058fa0SAdrien Destugues class XModemSender { 21*ce058fa0SAdrien Destugues public: 22*ce058fa0SAdrien Destugues XModemSender(BDataIO* source, BSerialPort* sink, 23*ce058fa0SAdrien Destugues BHandler* listener); 24*ce058fa0SAdrien Destugues ~XModemSender(); 25*ce058fa0SAdrien Destugues 26*ce058fa0SAdrien Destugues bool BytesReceived(const char* data, size_t length); 27*ce058fa0SAdrien Destugues private: 28*ce058fa0SAdrien Destugues 29*ce058fa0SAdrien Destugues void SendBlock(); 30*ce058fa0SAdrien Destugues status_t NextBlock(); 31*ce058fa0SAdrien Destugues 32*ce058fa0SAdrien Destugues private: 33*ce058fa0SAdrien Destugues BDataIO* fSource; 34*ce058fa0SAdrien Destugues BSerialPort* fSink; 35*ce058fa0SAdrien Destugues BMessenger fListener; 36*ce058fa0SAdrien Destugues off_t fBlockNumber; 37*ce058fa0SAdrien Destugues off_t fSourceSize; 38*ce058fa0SAdrien Destugues uint8_t fBuffer[128]; 39*ce058fa0SAdrien Destugues bool fEotSent; 40*ce058fa0SAdrien Destugues BString fStatus; 41*ce058fa0SAdrien Destugues }; 42*ce058fa0SAdrien Destugues 43*ce058fa0SAdrien Destugues 44*ce058fa0SAdrien Destugues #endif /* !XMODEM_H */ 45