aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ble/att.h4
-rw-r--r--include/ble/misc.h15
2 files changed, 12 insertions, 7 deletions
diff --git a/include/ble/att.h b/include/ble/att.h
index 3c7914f..1db560e 100644
--- a/include/ble/att.h
+++ b/include/ble/att.h
@@ -1,6 +1,5 @@
#pragma once
-#include <experimental/optional>
#include <variant>
#include <vector>
@@ -10,9 +9,6 @@
namespace trygvis {
namespace bluetooth {
-template<typename T>
-using o = std::experimental::optional<T>;
-
/**
* BLUETOOTH SPECIFICATION Version 4.0 [Vol 3] - Attribute Protocol (ATT) - 3.4.8 Attribute Opcode Summary
* Table 3.37
diff --git a/include/ble/misc.h b/include/ble/misc.h
index 089c3a1..4ba3309 100644
--- a/include/ble/misc.h
+++ b/include/ble/misc.h
@@ -1,5 +1,7 @@
#pragma once
+#include <experimental/optional>
+
#include <cstring>
#include <cctype>
#include <stdexcept>
@@ -7,6 +9,9 @@
namespace trygvis {
namespace bluetooth {
+template<typename T>
+using o = std::experimental::optional<T>;
+
class BluetoothAdapter;
class BluetoothDevice;
@@ -31,7 +36,7 @@ struct Uuid {
Uuid(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4, uint8_t b5, uint8_t b6, uint8_t b7,
uint8_t b8, uint8_t b9, uint8_t b10, uint8_t b11, uint8_t b12, uint8_t b13, uint8_t b14, uint8_t b15) noexcept : value{
- b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15} {}
+ b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15} {}
bool operator==(const Uuid &other) {
return std::memcmp(value, other.value, 16) == 0;
@@ -48,20 +53,24 @@ struct Uuid {
static Uuid fromShort(uint8_t b2, uint8_t b3) {
return {0x00, 0x00, b2, b3, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb};
}
+
+ static o<Uuid> fromString(const std::string &str);
};
struct ShortUuid {
private:
public:
- explicit ShortUuid(uint16_t value) : value(value) {}
+ explicit ShortUuid(uint16_t value) noexcept : value(value) {}
- Uuid toLong()
+ Uuid toLong() const noexcept
{
auto b2 = static_cast<uint8_t>(value >> 8);
auto b3 = static_cast<uint8_t>(value & 0xff);
return Uuid::fromShort(b2, b3);
}
+ std::string str() const noexcept;
+
uint16_t value;
};