Go to the documentation of this file.
11 #ifndef INC_MESHHELPER_H_
12 #define INC_MESHHELPER_H_
57 #define HAS_MEM_FUNC(func, name) \
58 template<typename T, typename Sign> \
60 typedef char yes[1]; \
61 typedef char no [2]; \
62 template <typename U, U> struct type_check; \
63 template <typename _1> static yes &chk(type_check<Sign, &_1::func> *); \
64 template <typename > static no &chk(...); \
65 static bool const value = sizeof(chk<T>(0)) == sizeof(yes); \
90 std::string descriptor;
92 uint32_t millis()
const;
93 uint32_t micros()
const;
94 void delay(uint32_t time)
const;
95 void delayMicroseconds(uint32_t time)
const;
96 std::stringstream& NotifyTableChangeBegin(TableChangeType changeType);
97 void NotifyTableChangeEnd();
100 std::stringstream tableChangeStream;
101 TableChangeType lastChangeType = MST_CLEAR;
108 char*
_itoa_s( int32_t value,
char * buffer,
size_t size,
int radix);
169 return sizeof(*this);
178 virtual size_t printRaw(
OSTREAM* stream,
void(* CRC_calculation)(uint8_t*,
size_t))
const {
266 return *(
reinterpret_cast<const uint32_t*
>(
this));
288 size_t printTo(Print& p)
const;
296 static char digitToHex(uint8_t digit,
bool low =
true);
302 operator uint32_t()
const {
return getRaw(); }
342 MeshVersion(uint8_t major, uint8_t minor, uint8_t patch);
360 return *(
reinterpret_cast<const uint16_t*
>(
this));
367 inline void setRaw(
const uint16_t version) {
380 size_t printTo(Print& p)
const;
387 operator uint16_t()
const {
return getRaw(); }
void setRaw(const uint32_t mac)
Sets Mesh MAC address from raw form.
Definition: meshHelper.h:274
void operator=(const uint32_t &val)
Definition: meshHelper.h:298
bool operator>(const uint16_t &val)
Definition: meshHelper.h:403
@ T_RIGHT
Definition: meshHelper.h:118
uint16_t Major
Major part of version. It's value can be between 0-63.
Definition: meshHelper.h:325
MeshPacketStatus
Definition: meshHelper.h:195
Interface for printing derived class collection as table with header and rows.
Definition: meshHelper.h:134
void setRaw(const uint16_t version)
Sets MeshVersion from raw form.
Definition: meshHelper.h:367
This class implements MeshNet protocol for microcontrollers.
Definition: mesh.h:104
bool operator<(const uint16_t &val)
Definition: meshHelper.h:406
bool operator>(const MeshVersion &val)
Definition: meshHelper.h:404
size_t printTo(Print &p) const
Pretty prints MeshVersion.
Definition: meshHelper.cpp:158
virtual size_t sizeOf() const
Gets size of whole current instance uncompressed (including dynamically allocated memory) in bytes.
Definition: meshHelper.h:168
uint8_t octet3
Third octet of MeshMAC address.
Definition: meshHelper.h:216
size_t printTo(Print &p) const
Pretty prints MeshMAC.
Definition: meshHelper.cpp:132
This file contains macros, which can MeshNet behavior can be configured.
uint8_t octet1
First octet of MeshMAC address.
Definition: meshHelper.h:226
void alignText(char *text, int size, char fill, TextAlignment alignment)
Aligns text in char array.
Definition: meshHelper.cpp:97
bool operator>=(const MeshVersion &val)
Definition: meshHelper.h:398
bool operator!=(const uint16_t &val)
Definition: meshHelper.h:394
virtual size_t printRaw(OSTREAM *stream, void(*CRC_calculation)(uint8_t *, size_t)) const
Prints current instance into stream in raw bytes.
Definition: meshHelper.h:178
bool operator<(const MeshVersion &val)
Definition: meshHelper.h:407
@ T_LEFT
Definition: meshHelper.h:116
uint16_t getRaw() const
Gets raw form of MeshVersion.
Definition: meshHelper.h:359
bool operator!=(const MeshVersion &val)
Definition: meshHelper.h:395
@ MPS_Sent
Definition: meshHelper.h:197
MeshVersion()
Constructor.
Definition: meshHelper.h:330
bool isValid() const
Checks if Mesh MAC address is valid.
Definition: meshHelper.h:257
@ T_CENTER
Definition: meshHelper.h:117
Interface for converting class or structure instance to raw bytes, which can be sent.
Definition: meshHelper.h:161
@ MPS_Unknown
Definition: meshHelper.h:196
bool operator==(const uint16_t &val)
Definition: meshHelper.h:391
#define OSTREAM
Definition: meshConfig.h:41
bool operator==(const MeshVersion &val)
Definition: meshHelper.h:392
virtual size_t getRawSize() const
Gets size of data, that will be printed to stream using printRaw() in bytes.
Definition: meshHelper.h:186
@ MPS_WaitingForPath
Definition: meshHelper.h:199
virtual size_t printHeader(OSTREAM *stream) const
Prints header of table.
Definition: meshHelper.h:142
Structure that represents physical MAC address used in MeshNEt protocol. MeshMAC address unlike MAC a...
Definition: meshHelper.h:207
uint32_t getRaw() const
Gets raw form of Mesh MAC address.
Definition: meshHelper.h:265
uint16_t Patch
Patch part of version. It's value can be between 0-31.
Definition: meshHelper.h:315
bool operator<=(const MeshVersion &val)
Definition: meshHelper.h:401
uint16_t Minor
Minor part of version. It's value can be between 0-31.
Definition: meshHelper.h:320
@ MPS_Waiting
Definition: meshHelper.h:198
void operator=(const uint16_t &val)
Definition: meshHelper.h:383
TextAlignment
Enumeration for text alignment in alignText() function.
Definition: meshHelper.h:115
bool operator<=(const uint16_t &val)
Definition: meshHelper.h:400
bool operator>=(const uint16_t &val)
Definition: meshHelper.h:397
uint8_t octet2
Second octet of MeshMAC address.
Definition: meshHelper.h:221
char * _itoa_s(int32_t value, char *buffer, size_t size, int radix)
MeshMAC()=default
Default constructor.
static char digitToHex(uint8_t digit, bool low=true)
Converts one HEX digit (0-15) to HEX character (0-F).
Definition: meshHelper.cpp:140
Structure that represents MeshNet version. Real size of this class is always 2 bytes.
Definition: meshHelper.h:310
uint8_t octet4
Fourth octet of MeshMAC address.
Definition: meshHelper.h:211
virtual size_t printLine(OSTREAM *stream) const
Prints this data as row to table.
Definition: meshHelper.h:152