
This is a simple mbed client example demonstrating, registration of a device with mbed Device Connector and reading and writing values as well as deregistering on different Network Interfaces including Ethernet, WiFi, 6LoWPAN ND and Thread respectively.
Fork of mbed-os-example-client by
Revision 19:91eb6f58fd77, committed 2016-09-29
- Comitter:
- mbed_official
- Date:
- Thu Sep 29 16:15:08 2016 +0100
- Parent:
- 18:628e22df9c41
- Child:
- 20:5542a1afdc32
- Commit message:
- Merge pull request #88 from mikaleppanen/entropy
Added support for entropy poll to randomize source ports.
Commit copied from https://github.com/ARMmbed/mbed-os-example-client
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
simpleclient.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Sep 21 07:30:08 2016 +0100 +++ b/main.cpp Thu Sep 29 16:15:08 2016 +0100 @@ -18,6 +18,7 @@ #include <sstream> #include <vector> #include "mbed-trace/mbed_trace.h" +#include "mbedtls/entropy_poll.h" #include "security.h" @@ -256,19 +257,29 @@ // Entry point to the program int main() { -#ifndef MBEDTLS_ENTROPY_HARDWARE_ALT + unsigned int seed; + size_t len; -#ifdef MBEDTLS_TEST_NULL_ENTROPY +#ifdef MBEDTLS_ENTROPY_HARDWARE_ALT + // Used to randomize source port + mbedtls_hardware_poll(NULL, (unsigned char *) &seed, sizeof seed, &len); + +#elif defined MBEDTLS_TEST_NULL_ENTROPY + #warning "mbedTLS security feature is disabled. Connection will not be secure !! Implement proper hardware entropy for your selected hardware." + // Used to randomize source port + mbedtls_null_entropy_poll( NULL,(unsigned char *) &seed, sizeof seed, &len); #else #error "This hardware does not have entropy, endpoint will not register to Connector.\ You need to enable NULL ENTROPY for your application, but if this configuration change is made then no security is offered by mbed TLS.\ Add MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES and MBEDTLS_TEST_NULL_ENTROPY in mbed_app.json macros to register your endpoint." + #endif -#endif + srand(seed); + status_ticker.attach_us(blinky, 250000); // Keep track of the main thread
--- a/simpleclient.h Wed Sep 21 07:30:08 2016 +0100 +++ b/simpleclient.h Thu Sep 29 16:15:08 2016 +0100 @@ -91,7 +91,6 @@ void *handler=NULL) { // Randomizing listening port for Certificate mode connectivity _server_address = server_address; - srand(time(NULL)); uint16_t port = rand() % 65535 + 12345; // create mDS interface object, this is the base object everything else attaches to