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.cpp
- Revision:
- 8:1861d0eef60a
- Parent:
- 2:6541a391bdbd
- Child:
- 37:1251e35fe43e
- Child:
- 40:40d4161fe1ad
--- a/common.cpp Thu Jan 05 13:13:28 2017 +0000
+++ b/common.cpp Thu Jan 05 13:23:49 2017 +0100
@@ -1,11 +1,20 @@
#include "common.h"
+#include <cstring>
std::string Data::serialize() {
std::string serialized;
serialized.push_back(type);
- serialized.push_back(counter);
+ serialized.append((char*)&value, sizeof(value));
return serialized;
};
+bool Data::deserialize(std::string str) {
+ if(str.length() < 1 + sizeof(value)) {
+ return false;
+ }
+ type = str[0];
+ memcpy(&value, str.data() + 1, sizeof(value));
+ return true;
+}
void radio_init(nRF24L01P* radio, unsigned long long rx_address,
unsigned long long tx_address) {