aboutsummaryrefslogtreecommitdiff
path: root/include/ble/ByteBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/ble/ByteBuffer.h')
-rw-r--r--include/ble/ByteBuffer.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/ble/ByteBuffer.h b/include/ble/ByteBuffer.h
index d977c67..1032187 100644
--- a/include/ble/ByteBuffer.h
+++ b/include/ble/ByteBuffer.h
@@ -7,6 +7,29 @@
#include <iosfwd>
#include <memory>
#include <stdexcept>
+#include <math.h>
+
+namespace FLOAT {
+static const uint32_t positive_infinity = 0x007FFFFE;
+static const uint32_t negative_infinity = 0x00800002;
+static const uint32_t NaN = 0x007FFFFF;
+static const uint32_t NRes = 0x00800000;
+static const uint32_t FLAOT_reserved_value = 0x00800001;
+
+// (2^23 - 3) * 10^127
+static const double max = 8.388604999999999e+133;
+static const double min = -max;
+
+static const double mantissa_max = 0x007FFFFD;
+static const double exponent_max = 127;
+static const double exponent_min = -128;
+
+// 10^-128
+static const double epsilon = 1e-128;
+
+// 10^upper(23 * log(2) / log(10))
+static const double precision = 10000000;
+}
class ByteBufferException : public std::runtime_error {
public:
@@ -53,6 +76,8 @@ public:
ByteBuffer &write16le(uint16_t value);
+ ByteBuffer &write32le(uint32_t value);
+
/**
* Appends the entire buffer. Make a view if you want to write a part of it.
*/
@@ -60,12 +85,21 @@ public:
ByteBuffer &write(const uint8_t *bytes, size_t len);
+ ByteBuffer &writeFLOAT(double d);
+
uint8_t get8(size_t index) const;
uint8_t read8();
uint16_t read16le();
+ uint32_t read32le();
+
+ /**
+ * IEEE-11073 32-bit FLOAT
+ */
+ double readFLOAT();
+
void copy(uint8_t *bytes, size_t length) const;
/**