From 52450ed3034b0ba058ea2c9f9baa2d5f78df6a94 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 17 Nov 2018 22:38:32 +0100 Subject: 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. --- include/ble/att.h | 4 ---- include/ble/misc.h | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'include') 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 #include #include @@ -10,9 +9,6 @@ namespace trygvis { namespace bluetooth { -template -using o = std::experimental::optional; - /** * 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 + #include #include #include @@ -7,6 +9,9 @@ namespace trygvis { namespace bluetooth { +template +using o = std::experimental::optional; + 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 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(value >> 8); auto b3 = static_cast(value & 0xff); return Uuid::fromShort(b2, b3); } + std::string str() const noexcept; + uint16_t value; }; -- cgit v1.2.3