Files
2018-12-18 12:07:12 +01:00

31 lines
507 B
C++

#include <stdexcept>
#include <unistd.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include "Socket.h"
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