diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2018-11-17 22:38:32 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2018-11-17 22:38:32 +0100 |
commit | 52450ed3034b0ba058ea2c9f9baa2d5f78df6a94 (patch) | |
tree | 97fe35d5d7fe6fe354b2effe8c0ef4836787eb83 /include | |
parent | a167d6e68e634a70af442cd86e43fd9223b1431c (diff) | |
download | ble-toys-52450ed3034b0ba058ea2c9f9baa2d5f78df6a94.tar.gz ble-toys-52450ed3034b0ba058ea2c9f9baa2d5f78df6a94.tar.bz2 ble-toys-52450ed3034b0ba058ea2c9f9baa2d5f78df6a94.tar.xz ble-toys-52450ed3034b0ba058ea2c9f9baa2d5f78df6a94.zip |
apps/ble-bts:
o Adding start of health termometer service tool.
apps/ble-read-characteristic:
o Sart of new tool.
apps/ble-inspect-device
o Make adapter configurable.
other:
o UUID fixes and tests.
Diffstat (limited to 'include')
-rw-r--r-- | include/ble/att.h | 4 | ||||
-rw-r--r-- | include/ble/misc.h | 15 |
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; }; |