NuMaker connection with AWS IoT thru MQTT/HTTPS

Dependencies:   MQTT

Committer:
ccli8
Date:
Tue Oct 29 10:59:34 2019 +0800
Revision:
29:e890b0fdce53
Update to mbed-os 5.14.2 and related modifications

1. Provide custom entropy source on targets without real TRNG
The targets below don't have real TRNG and cannot annouce TRNG support. A custom entropy source with EADC seeded PRNG is given to remedy it:
- NUMAKER_PFM_NUC47
- NUMAKER_PFM_M487
- NUMAKER_IOT_M487
2. Override mbed_main() for:
(1) Simulating provision process
(2) Handling host command via event queue
3. Remove memory statistics printing at end of main(). Printed via host command instead.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ccli8 29:e890b0fdce53 1 /*
ccli8 29:e890b0fdce53 2 * Copyright (c) 2019 Nuvoton Technology Corporation
ccli8 29:e890b0fdce53 3 *
ccli8 29:e890b0fdce53 4 * SPDX-License-Identifier: Apache-2.0
ccli8 29:e890b0fdce53 5 *
ccli8 29:e890b0fdce53 6 * Licensed under the Apache License, Version 2.0 (the "License");
ccli8 29:e890b0fdce53 7 * you may not use this file except in compliance with the License.
ccli8 29:e890b0fdce53 8 * You may obtain a copy of the License at
ccli8 29:e890b0fdce53 9 *
ccli8 29:e890b0fdce53 10 * http://www.apache.org/licenses/LICENSE-2.0
ccli8 29:e890b0fdce53 11 *
ccli8 29:e890b0fdce53 12 * Unless required by applicable law or agreed to in writing, software
ccli8 29:e890b0fdce53 13 * distributed under the License is distributed on an "AS IS" BASIS,
ccli8 29:e890b0fdce53 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ccli8 29:e890b0fdce53 15 * See the License for the specific language governing permissions and
ccli8 29:e890b0fdce53 16 * limitations under the License.
ccli8 29:e890b0fdce53 17 */
ccli8 29:e890b0fdce53 18
ccli8 29:e890b0fdce53 19 #include "mbed.h"
ccli8 29:e890b0fdce53 20
ccli8 29:e890b0fdce53 21 #if (MBED_HEAP_STATS_ENABLED) || (MBED_STACK_STATS_ENABLED)
ccli8 29:e890b0fdce53 22 /* Measure memory footprint */
ccli8 29:e890b0fdce53 23 #include "mbed_stats.h"
ccli8 29:e890b0fdce53 24 /* Fix up the compilation on AMRCC for PRIu32 */
ccli8 29:e890b0fdce53 25 #define __STDC_FORMAT_MACROS
ccli8 29:e890b0fdce53 26 #include <inttypes.h>
ccli8 29:e890b0fdce53 27 #endif
ccli8 29:e890b0fdce53 28
ccli8 29:e890b0fdce53 29 /* Support memory footprint */
ccli8 29:e890b0fdce53 30
ccli8 29:e890b0fdce53 31 /* Check weak reference/definition at the link:
ccli8 29:e890b0fdce53 32 * http://www.keil.com/support/man/docs/ARMLINK/armlink_pge1362065917715.htm */
ccli8 29:e890b0fdce53 33
ccli8 29:e890b0fdce53 34 extern "C" {
ccli8 29:e890b0fdce53 35 #if (MBED_HEAP_STATS_ENABLED)
ccli8 29:e890b0fdce53 36 MBED_USED void print_heap_stats(void);
ccli8 29:e890b0fdce53 37 #endif
ccli8 29:e890b0fdce53 38 #if (MBED_STACK_STATS_ENABLED)
ccli8 29:e890b0fdce53 39 MBED_USED void print_stack_statistics();
ccli8 29:e890b0fdce53 40 #endif
ccli8 29:e890b0fdce53 41 }
ccli8 29:e890b0fdce53 42
ccli8 29:e890b0fdce53 43 #if (MBED_HEAP_STATS_ENABLED)
ccli8 29:e890b0fdce53 44 void print_heap_stats(void)
ccli8 29:e890b0fdce53 45 {
ccli8 29:e890b0fdce53 46 mbed_stats_heap_t stats;
ccli8 29:e890b0fdce53 47 mbed_stats_heap_get(&stats);
ccli8 29:e890b0fdce53 48 printf("** MBED HEAP STATS **\n");
ccli8 29:e890b0fdce53 49 printf("**** current_size: %" PRIu32 "\n", stats.current_size);
ccli8 29:e890b0fdce53 50 printf("**** max_size : %" PRIu32 "\n", stats.max_size);
ccli8 29:e890b0fdce53 51 printf("*****************************\n\n");
ccli8 29:e890b0fdce53 52 }
ccli8 29:e890b0fdce53 53 #endif // MBED_HEAP_STATS_ENABLED
ccli8 29:e890b0fdce53 54
ccli8 29:e890b0fdce53 55 #if (MBED_STACK_STATS_ENABLED)
ccli8 29:e890b0fdce53 56 void print_stack_statistics()
ccli8 29:e890b0fdce53 57 {
ccli8 29:e890b0fdce53 58 printf("** MBED THREAD STACK STATS **\n");
ccli8 29:e890b0fdce53 59 int cnt = osThreadGetCount();
ccli8 29:e890b0fdce53 60 mbed_stats_stack_t *stats = (mbed_stats_stack_t*) malloc(cnt * sizeof(mbed_stats_stack_t));
ccli8 29:e890b0fdce53 61
ccli8 29:e890b0fdce53 62 if (stats) {
ccli8 29:e890b0fdce53 63 cnt = mbed_stats_stack_get_each(stats, cnt);
ccli8 29:e890b0fdce53 64 for (int i = 0; i < cnt; i++) {
ccli8 29:e890b0fdce53 65 printf("Thread: 0x%" PRIx32 ", Stack size: %" PRIu32 ", Max stack: %" PRIu32 "\r\n", stats[i].thread_id, stats[i].reserved_size, stats[i].max_size);
ccli8 29:e890b0fdce53 66 }
ccli8 29:e890b0fdce53 67
ccli8 29:e890b0fdce53 68 free(stats);
ccli8 29:e890b0fdce53 69 }
ccli8 29:e890b0fdce53 70 printf("*****************************\n\n");
ccli8 29:e890b0fdce53 71 }
ccli8 29:e890b0fdce53 72 #endif // MBED_STACK_STATS_ENABLED