30 lines
506 B
C++
30 lines
506 B
C++
#include "Socket.h"
|
|
#include <unistd.h>
|
|
#include <bluetooth/bluetooth.h>
|
|
#include <bluetooth/hci.h>
|
|
#include <stdexcept>
|
|
|
|
|
|
namespace PresenceDetection {
|
|
namespace Bluetooth {
|
|
|
|
Socket::Socket()
|
|
{
|
|
m_descriptor = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_L2CAP);
|
|
if (m_descriptor < 0)
|
|
throw std::runtime_error("Can't create Bluetooth socket");
|
|
}
|
|
|
|
Socket::~Socket()
|
|
{
|
|
close(m_descriptor);
|
|
}
|
|
|
|
int Socket::Descriptor() const
|
|
{
|
|
return m_descriptor;
|
|
}
|
|
|
|
} // namespace Bluetooth
|
|
} // namespace PresenceDetection
|