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