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: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
mesh_system.c
00001 /* 00002 * Copyright (c) 2015 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 "eventOS_scheduler.h" 00018 #include "eventOS_event.h" 00019 #include "net_interface.h" 00020 #include "nsdynmemLIB.h" 00021 #include "randLIB.h" 00022 #include "platform/arm_hal_timer.h" 00023 #include "ns_hal_init.h" 00024 #include "include/static_config.h" 00025 #include "include/mesh_system.h" 00026 // For tracing we need to define flag, have include and define group 00027 #define HAVE_DEBUG 1 00028 #include "ns_trace.h" 00029 #define TRACE_GROUP "m6-mesh-system" 00030 00031 /* Heap for NanoStack */ 00032 static uint8_t app_stack_heap[MBED_MESH_API_HEAP_SIZE + 1]; 00033 static bool mesh_initialized = false; 00034 00035 /* 00036 * Heap error handler, called when heap problem is detected. 00037 * Function is for-ever loop. 00038 */ 00039 static void mesh_system_heap_error_handler(heap_fail_t event) 00040 { 00041 tr_error("Heap error, mesh_system_heap_error_handler() %d", event); 00042 switch (event) { 00043 case NS_DYN_MEM_NULL_FREE: 00044 case NS_DYN_MEM_DOUBLE_FREE: 00045 case NS_DYN_MEM_ALLOCATE_SIZE_NOT_VALID: 00046 case NS_DYN_MEM_POINTER_NOT_VALID: 00047 case NS_DYN_MEM_HEAP_SECTOR_CORRUPTED: 00048 case NS_DYN_MEM_HEAP_SECTOR_UNITIALIZED: 00049 break; 00050 default: 00051 break; 00052 } 00053 while (1); 00054 } 00055 00056 void mesh_system_init(void) 00057 { 00058 if (mesh_initialized == false) { 00059 ns_hal_init(app_stack_heap, MBED_MESH_API_HEAP_SIZE, 00060 mesh_system_heap_error_handler, NULL); 00061 eventOS_scheduler_mutex_wait(); 00062 net_init_core(); 00063 eventOS_scheduler_mutex_release(); 00064 mesh_initialized = true; 00065 } 00066 } 00067 00068 void mesh_system_send_connect_event(uint8_t receiver) 00069 { 00070 arm_event_s event = { 00071 .sender = receiver, 00072 .event_id = APPL_EVENT_CONNECT, 00073 .receiver = receiver, 00074 .event_type = APPLICATION_EVENT, 00075 .priority = ARM_LIB_LOW_PRIORITY_EVENT, 00076 }; 00077 eventOS_event_send(&event); 00078 }
Generated on Tue Jul 12 2022 11:02:47 by
