Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
mesh_system.c
00001 /* 00002 * Copyright (c) 2015-2019 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include <stdlib.h> 00018 #include "eventOS_scheduler.h" 00019 #include "eventOS_event.h" 00020 #include "net_interface.h" 00021 #include "nsdynmemLIB.h" 00022 #include "randLIB.h" 00023 #include "platform/arm_hal_timer.h" 00024 #include "ns_hal_init.h" 00025 #include "include/mesh_system.h" 00026 #include "mbed_assert.h" 00027 #include "mbed_error.h" 00028 #include "ns_file_system.h" 00029 // For tracing we need to define flag, have include and define group 00030 #define HAVE_DEBUG 1 00031 #include "ns_trace.h" 00032 #define TRACE_GROUP "m6-mesh-system" 00033 00034 /* Heap for NanoStack */ 00035 #if !MBED_CONF_MBED_MESH_API_USE_MALLOC_FOR_HEAP 00036 static uint8_t app_stack_heap[MBED_CONF_MBED_MESH_API_HEAP_SIZE + 1]; 00037 #else 00038 static uint8_t *app_stack_heap; 00039 #endif 00040 static bool mesh_initialized = false; 00041 #ifdef MBED_CONF_MBED_MESH_API_HEAP_STAT_INFO_DEFINITION 00042 MBED_CONF_MBED_MESH_API_HEAP_STAT_INFO_DEFINITION; 00043 #endif 00044 00045 /* 00046 * Heap error handler, called when heap problem is detected. 00047 * Function is for-ever loop. 00048 */ 00049 static void mesh_system_heap_error_handler(heap_fail_t event) 00050 { 00051 MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_NETWORK_STACK, MBED_ERROR_CODE_OUT_OF_MEMORY), "Heap error, mesh_system_heap_error_handler()", event); 00052 } 00053 00054 void mesh_system_init(void) 00055 { 00056 if (mesh_initialized == false) { 00057 #if MBED_CONF_MBED_MESH_API_USE_MALLOC_FOR_HEAP 00058 app_stack_heap = malloc(MBED_CONF_MBED_MESH_API_HEAP_SIZE + 1); 00059 MBED_ASSERT(app_stack_heap); 00060 #endif 00061 ns_hal_init(app_stack_heap, MBED_CONF_MBED_MESH_API_HEAP_SIZE, 00062 mesh_system_heap_error_handler, MBED_CONF_MBED_MESH_API_HEAP_STAT_INFO); 00063 eventOS_scheduler_mutex_wait(); 00064 net_init_core(); 00065 eventOS_scheduler_mutex_release(); 00066 mesh_initialized = true; 00067 } 00068 } 00069 00070 void mesh_system_send_connect_event(uint8_t receiver) 00071 { 00072 arm_event_s event = { 00073 .sender = receiver, 00074 .event_id = APPL_EVENT_CONNECT, 00075 .receiver = receiver, 00076 .event_type = APPLICATION_EVENT, 00077 .priority = ARM_LIB_LOW_PRIORITY_EVENT, 00078 }; 00079 eventOS_event_send(&event); 00080 } 00081 00082 int mesh_system_set_file_system_root_path(const char *root_path) 00083 { 00084 return ns_file_system_set_root_path(root_path); 00085 }
Generated on Tue Jul 12 2022 13:54:35 by
