Initial Commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user