diff options
-rw-r--r-- | apps/ble-inspect-device.cpp | 2 | ||||
-rw-r--r-- | include/ble/misc.h | 4 | ||||
-rw-r--r-- | test/ByteBufferTest.cpp | 20 |
3 files changed, 15 insertions, 11 deletions
diff --git a/apps/ble-inspect-device.cpp b/apps/ble-inspect-device.cpp index c07879b..a6665b3 100644 --- a/apps/ble-inspect-device.cpp +++ b/apps/ble-inspect-device.cpp @@ -44,7 +44,7 @@ public: << endl; for (auto &c : characteristics) { - cout << "Characteristic: UUID: " << c->getUuid() << ", properties: " << (int) c->getProperties() + cout << "Characteristic: UUID: " << c->getUuid() << ", properties: " << (uint16_t) c->getProperties() << endl; } } diff --git a/include/ble/misc.h b/include/ble/misc.h index 70a19f5..563d039 100644 --- a/include/ble/misc.h +++ b/include/ble/misc.h @@ -133,6 +133,10 @@ public: bool extendedProperties() { return static_cast<bool>(value & 0x80); } + + explicit operator uint16_t() { + return value; + } }; } // namespace bluetooth diff --git a/test/ByteBufferTest.cpp b/test/ByteBufferTest.cpp index f8190c5..9f26971 100644 --- a/test/ByteBufferTest.cpp +++ b/test/ByteBufferTest.cpp @@ -8,12 +8,12 @@ using namespace std; -static void checkBuffer(const ByteBuffer& buffer, size_t size, size_t cursor) { +static void checkBuffer(const ByteBuffer& buffer, size_t size, size_t position) { if (false) { - cout << "size=" << buffer.getSize() << ", cursor=" << buffer.getCursor(); + cout << "size=" << buffer.getSize() << ", position=" << buffer.getPosition(); } BOOST_CHECK_EQUAL(buffer.getSize(), size); - BOOST_CHECK_EQUAL(buffer.getCursor(), cursor); + BOOST_CHECK_EQUAL(buffer.getPosition(), position); } class Bytes { @@ -70,13 +70,13 @@ BOOST_AUTO_TEST_CASE(setCursor) { BOOST_CHECK_EQUAL(buffer.read8(), 0); checkBuffer(buffer, 1000, 1); - buffer.setCursor(0); + buffer.setPosition(0); checkBuffer(buffer, 1000, 0); BOOST_CHECK_EQUAL(buffer.read8(), 0); checkBuffer(buffer, 1000, 1); - buffer.setCursor(9); + buffer.setPosition(9); checkBuffer(buffer, 1000, 9); } @@ -85,13 +85,13 @@ BOOST_AUTO_TEST_CASE(view) { ByteBuffer buffer(b.bytes, b.capacity); BOOST_CHECK_EQUAL(buffer.read8(), 0); - ByteBuffer view1 = buffer.viewRest(); + ByteBuffer view1 = buffer.viewCursorToEnd(); checkBuffer(view1, 999, 0); BOOST_CHECK_EQUAL(view1.read8(), 1); BOOST_CHECK_EQUAL(view1.read8(), 2); - ByteBuffer view2 = view1.viewRest(); + ByteBuffer view2 = view1.viewCursorToEnd(); checkBuffer(view2, 997, 0); BOOST_CHECK_EQUAL(view1.read8(), 3); @@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(ieee_11073_20601_float_1_0d) { ByteBuffer buffer(b.bytes, b.capacity); buffer.writeFLOAT(1.0); - buffer.setCursor(0); + buffer.setPosition(0); BOOST_CHECK_EQUAL(buffer.readFLOAT(), 1.0); } @@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(ieee_11073_20601_float_nan) { BOOST_CHECK_EQUAL(std::isnan(stof("NaN")), true); buffer.writeFLOAT(stof("NaN")); - buffer.setCursor(0); + buffer.setPosition(0); BOOST_CHECK_EQUAL(std::isnan(buffer.readFLOAT()), true); } @@ -120,7 +120,7 @@ void c(double input, uint32_t hx, double sigma = 0.00001) { Bytes b(1000); ByteBuffer buffer(b.bytes, b.capacity); buffer.writeFLOAT(input); - buffer.setCursor(0); + buffer.setPosition(0); double output = buffer.readFLOAT(); stringstream str; |