summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/lib/device.h
blob: 3631c97fe49ac635eef079109868a21fe71b2e9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

#ifndef OpieToothDevice_H
#define OpieToothDevice_H

#include <qobject.h>
#include <qstring.h>
#include <qvaluelist.h>

#include <sys/types.h>

namespace Opie {namespace Core {class OProcess;}}
namespace OpieTooth {
    /**
     *  Device takes care of attaching serial
     *  devices to the blueZ stack.
     *  After attaching it hciconfig ups it
     */
    class Device : public QObject {

        Q_OBJECT

    public:

    /**
     * Brings up an device.
     * Usage example: new Device(/dev/ttySB0, csr)
     *
     * @param &device QString the device name
     * @param &mode QString the mode
     * @param &speed QString the speed of the device, can be left blank
     */
    Device(const QString &device, const QString& mode, const QString& speed);

        /**
         * unloads the device
         */
        ~Device();

        /**
         * attach the device
         */
        void attach();

        /**
         * detach the device
         */
        void detach();

        /**
         * Is the device loaded?
         * @return bool, if the device is loaded
	 */
        bool isLoaded()const;

        /**
         * Returns the device name
         * @return QString, the device name
         */
        QString devName()const ; // hci0

    signals:

        /**
         * Signals devicename and up status
         * @return &device QString, Devicename
         * @return up bool, if the device is up or not.
         */
        void device(const QString& device, bool up );
    private slots:
        virtual void slotExited( Opie::Core::OProcess* );
        virtual void slotStdOut(Opie::Core::OProcess*, char*, int );
	virtual void slotStdErr(Opie::Core::OProcess*, char*, int );
    private:
	class Private;
	Private *d;
	QString m_device;
	bool m_attached:1;
	Opie::Core::OProcess* m_hci;
	Opie::Core::OProcess* m_process;
	QString m_devId;
	QString m_mode;
        QString m_speed;
	pid_t pid;
	QCString m_output;
    };
};

#endif