License
Warranty and License
+-----------------------+
| act (USER APPs)... |
+-----------------------+
| MWX C++ LIB |
+---------------+ |
| TWENET C LIB | |
+------------+----------+
| MAC LAYER | AHI APIs |
+-----------------------+
| TWELITE HARDWARE |
+-----------------------+
The name of the MWX library is Mono Wireless C++ Library for TWELITE. “MW” comes from MonoWireless, and “C++” → “CXX” → double X → “WX”. By overlapping this MW and WX, it became MWX. Code written using this library is called “act”.
This section describes the notations used in this explanation.
Called a universal reference, it is often used in the standard library. In this library as well, auto&&
is used in most cases.
auto
in C language is a keyword used to declare local variables (automatic variables), but here it means declaration by type inference. In C++ template syntax, type names often become very complicated, and it is convenient when you can implement without explicitly specifying the type name.
The example below uses the standard library algorithm std::minmax_element
to find the minimum and maximum values of the type of v
, and the return value is declared with auto
. In this case, the type inferred by auto
is std::pair<int, int>
.
#include <algorithm>
int v[] = { 1, 3, -1, 5, 10 };
auto&& result = std::minmax_element(std::begin(v), std::end(v));
Serial << "min=" << int(result.first)
<< ",max=" << int(result.second);
You need to refer to specialized books for the strict meaning of &&
in auto &&
, but here, think of it as “whether the return is a reference type (similar to pointer passing in C) or a value, you can declare it without worrying.”
namespace
, inline namespace
, and using
are used to redefine names. Some parts are omitted even in the explanation.
The MWX library is not developed with the purpose of supporting all the underlying libraries and functions (functions in the TWENET C library, microcontroller peripheral functions provided by semiconductor vendors, IEEE802.15.4 functions).
The MWX library is written in C++ and the act is also written in C++. However, not all features of C++ can be used. Please note the following points especially.
new
and new[]
operators is possible, but the allocated memory cannot be freed. Most dynamic memory allocations in C++ libraries are practically unusable.setup()
) like new ((void*)&obj_global) class_foo();
.exception
) cannot be used.virtual
) cannot be used.※ This is based on what we are aware of.
The source code can be referenced from the following.
{MWSDK installation folder}/TWENET/current/src/mwx