| 123456789101112131415161718192021222324252627282930 |
- #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
|