1 | #include<config.h>
|
---|
2 |
|
---|
3 | #ifdef HAVE_LIBBLUETOOTH
|
---|
4 |
|
---|
5 | #ifndef RFCOMM_HPP_
|
---|
6 | #define RFCOMM_HPP_
|
---|
7 |
|
---|
8 | #include "ariba/utility/transport/transport.hpp"
|
---|
9 | #include "ariba/utility/transport/asio/asio_io_service.h"
|
---|
10 | #include "ariba/utility/transport/asio/bluetooth_endpoint.hpp"
|
---|
11 | #include "ariba/utility/transport/asio/rfcomm.hpp"
|
---|
12 |
|
---|
13 | #include <boost/thread.hpp>
|
---|
14 | #include <boost/system/system_error.hpp>
|
---|
15 | #include <boost/asio/io_service.hpp>
|
---|
16 |
|
---|
17 | #include "ariba/utility/logging/Logging.h"
|
---|
18 |
|
---|
19 | namespace ariba {
|
---|
20 | namespace transport {
|
---|
21 |
|
---|
22 | using boost::system::error_code;
|
---|
23 | using namespace boost::asio;
|
---|
24 |
|
---|
25 | class link_info;
|
---|
26 | class link_data;
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * TODO: Doc
|
---|
30 | *
|
---|
31 | * @author Sebastian Mies <mies@tm.uka.de>
|
---|
32 | */
|
---|
33 | class rfcomm : public transport_protocol {
|
---|
34 | use_logging_h(rfcomm)
|
---|
35 | public:
|
---|
36 | rfcomm( uint16_t channel );
|
---|
37 | virtual ~rfcomm();
|
---|
38 | virtual void start();
|
---|
39 | virtual void stop();
|
---|
40 | virtual void send( const address_v* remote, const uint8_t* data, size_t size );
|
---|
41 | virtual void send( const endpoint_set& endpoints, const uint8_t* data, size_t size );
|
---|
42 | virtual void terminate( const address_v* remote );
|
---|
43 | virtual void register_listener( transport_listener* listener );
|
---|
44 |
|
---|
45 | private:
|
---|
46 | uint16_t channel;
|
---|
47 | boost::mutex links_mutex;
|
---|
48 | vector<link_info*> links;
|
---|
49 | io_service& io;
|
---|
50 | transport_listener* listener;
|
---|
51 | bluetooth::rfcomm::acceptor* acceptor;
|
---|
52 | int accept_retries;
|
---|
53 | link_data* send_data;
|
---|
54 |
|
---|
55 | void start_accept();
|
---|
56 |
|
---|
57 | void handle_accept( const error_code& error, link_info* info );
|
---|
58 |
|
---|
59 | void start_read( link_info* info );
|
---|
60 |
|
---|
61 | void handle_read_header( const error_code& error, size_t bytes, link_info* info );
|
---|
62 |
|
---|
63 | void handle_read_data( const error_code& error, size_t bytes, link_info* info );
|
---|
64 |
|
---|
65 | void handle_connect( const error_code& error, link_info* info );
|
---|
66 |
|
---|
67 | void start_write( link_info* info );
|
---|
68 |
|
---|
69 | void handle_write_data(const error_code& error, size_t bytes,
|
---|
70 | link_info* info, size_t size, uint8_t* buffer );
|
---|
71 |
|
---|
72 | void shutdown(link_info* info);
|
---|
73 | };
|
---|
74 |
|
---|
75 | }} // namespace ariba::transport
|
---|
76 |
|
---|
77 | #endif /* RFCOMM_HPP_ */
|
---|
78 | #endif
|
---|