1/*
2 * Copyright 2012-2019, Adrien Destugues, pulkomandy@pulkomandy.tk
3 * Distributed under the terms of the MIT licence.
4 */
5
6
7#ifndef _SERIALAPP_H_
8#define _SERIALAPP_H_
9
10
11#include <Application.h>
12#include <PropertyInfo.h>
13#include <SerialPort.h>
14#include <String.h>
15
16#include "FileSender.h"
17#include "XModem.h"
18
19
20class BFile;
21class SerialWindow;
22
23
24class SerialApp: public BApplication
25{
26	public:
27							SerialApp();
28							~SerialApp();
29				void		ReadyToRun();
30				void		MessageReceived(BMessage* message);
31				bool		QuitRequested();
32
33				status_t	GetSupportedSuites(BMessage* message);
34				BHandler*	ResolveSpecifier(BMessage*, int32, BMessage*, int32,
35								const char*);
36
37		const	BString&	GetPort();
38
39	private:
40				void		LoadSettings();
41				void		SaveSettings();
42
43	private:
44						BSerialPort		fSerialPort;
45						sem_id			fSerialLock;
46						SerialWindow*	fWindow;
47						BFile*			fLogFile;
48						BString			fPortPath;
49
50						FileSender*		fFileSender;
51
52		static			status_t		PollSerial(void*);
53
54		static const	BPropertyInfo	kScriptingProperties;
55		static const	char*			kApplicationSignature;
56};
57
58
59enum messageConstants {
60	kMsgCustomBaudrate  = 'cust',
61	kMsgDataRead        = 'dard',
62	kMsgDataWrite       = 'dawr',
63	kMsgLogfile         = 'logf',
64	kMsgOpenPort        = 'open',
65	kMsgProgress        = 'prog',
66	kMsgSettings        = 'stty',
67	kMsgSendFile        = 'sndf',
68	kMsgClear           = 'cler',
69};
70
71#endif
72