Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: common.h
- Revision:
- 8:1861d0eef60a
- Parent:
- 7:e51d0fbb1a25
- Child:
- 10:869163c7929d
--- a/common.h Thu Jan 05 13:13:28 2017 +0000
+++ b/common.h Thu Jan 05 13:23:49 2017 +0100
@@ -24,6 +24,10 @@
SOUND = 4,
};
+constexpr bool is_sensor_float(SENSOR_TYPE t) {
+ return t == SENSOR_TYPE::SOUND;
+}
+
struct SensorDescription {
SensorDescription(int _sensor_id, unsigned long long _rx_address, unsigned long long _tx_address)
: sensor_id(_sensor_id), rx_address(_rx_address), tx_address(_tx_address) {}
@@ -33,20 +37,27 @@
};
struct Data {
- Data(uint8_t type_, uint8_t counter_)
- : type(type_), counter(counter_) {}
-
- // TODO correct?
- Data(std::string serialized)
- : type(serialized[0]), counter(serialized[1]) {}
+ Data(uint8_t type_, int32_t i_val)
+ : type(type_) {
+ value.i = i_val;
+ }
+
+ Data(uint8_t type_, float f_val)
+ : type(type_) {
+ value.f = f_val;
+ }
std::string serialize();
+ bool deserialize(std::string str);
uint8_t type;
- uint8_t counter;
+ union {
+ int32_t i;
+ float f;
+ } value;
};
void radio_init(nRF24L01P* radio, unsigned long long rx_address,
unsigned long long tx_address);
-#endif /* JNP3_COMMON */
\ No newline at end of file
+#endif /* JNP3_COMMON */