* Optimise clearing by adding `nullptr` overload. This overload means
`Callback(NULL)` or `Callback(0)` will no longer work; users must
use `Callback(nullptr)` or `Callback()`.
* Optimise clearing by not clearing storage - increases code size of
comparison, but that is extremely rare.
* Reduce ROM used by trivial functors - share copy/destroy code.
* Config option to force trivial functors - major ROM saving by
eliminating the "operations" table.
* Config option to eliminate comparison altogether - minor ROM saving by
eliminating zero padding.
* Conform more to `std::function` API.
Use tag dispatch to better handle both NetworkInterface and NetworkStack
pointers.
The previous design was intended to avoid ambiguities when presented
with a scenario like
class MyDevice : public NetworkInterface, public NetworkStack {
};
TCPSocket(&MyDevice);
// Need NetworkStack *: use NetworkInterface::get_stack or
// cast to NetworkStack?
But the previous solution didn't actually work as intended. The overload
pair
nsapi_create_stack(NetworkStack *);
// versus
template <class IF>
nsapi_create_stack(IF *);
would only select the first form if passed an exact match -
`NetworkStack *`. If passed a derived class pointer, like `MyDevice *`,
it would select the template.
This meant that an ambiguity for MyDevice was at least avoided, but
in the wrong direction, potentially increasing code size.
But in other cases, the system just didn't work at all - you couldn't
pass a `MyStack *` pointer, unless you cast it to `NetworkStack *`.
Quite a few bits of test code do this.
Add a small bit of tag dispatch to prioritise the cast whenever the
supplied pointer is convertible to `NetworkStack *`.
Moved the existing BufferedBlockDevice to features/storage unittests and switched it to gmock.
Added gmock-based unit tests to all other BlockDevice classes.
SlicingBlockDevice test left as a module test.
Major changes:
- Dependency to FileHandle removed from base classes
- AT_CellularDevice owns the default FileHandle and shares it with AT -classes
- Hang-up -detection moved as CellularContext::configure_hup(). Cannot be configured via CellularDevice any more.
Result on NRF52840_DK + BG96:
GCC:
Total Static RAM memory (data + bss): 29360(+296) bytes
Total Flash memory (text + data): 130660(-832) bytes
ARM:
Total Static RAM memory (data + bss): 261554(+8) bytes
Total Flash memory (text + data): 127573(-1193) bytes
IAR:
Total Static RAM memory (data + bss): 25479(+296) bytes
Total Flash memory (text + data): 102418(-527) bytes
RAM increase is because now ATHandler is no longer created with new -operator but is now member of AT_CellularDevice,
so image tool is able to count it. Actually total RAM consumption has decreased due to removed variables.
string_to_pdp_type is only used in CellularContext classes and by having
the conversion method in CellularContext it can be used to check also
the non-standard Non-IP PDP type string.
ATHandler is part of our API so header file was moved under API folder and .cpp file was moved under device/ folder
ATHandler is used in both AT and PPP mode so it has been in slightly wrong place at the beginning.
Add a missing license header.
Remove semaphores and add +CRTDCP to support async operation.
Fix delete context and disconnect to execute just once.
Add support for NONIP PPD type.
Change CellularNetwork::clear() to virtual so it can be overridden.
Earlier CellularDevice has owned event queue used by cellular (state machine and ATHandler for example),
but the thread used to dispatch the queue has been owned by state machine.
This commit moves the event queue thread to CellularDevice so now the ownership of cellular event queue
is in one place.
New members are added to the network interface
-getaddrinfo
-getaddrinfo_async
gethostbyname is unchanged but gethostbyname_async result param now contains results od DNS records found.
Test cases for sync/async added added to DNS test folder.