This is an example application based on Mbed-OS LoRaWAN protocol APIs. The Mbed-OS LoRaWAN stack implementation is compliant with LoRaWAN v1.0.2 specification.

Dependents:   Projet_de_bachelor_code Projet_de_bachelor_code

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers trace_helper.cpp Source File

trace_helper.cpp

00001 /**
00002  * Copyright (c) 2017, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /**
00019  * If we have tracing library available, we can see traces from within the
00020  * stack. The library could be made unavailable by removing FEATURE_COMMON_PAL
00021  * from the mbed_app.json to save RAM.
00022  */
00023 
00024 #include "mbed_trace.h"
00025 
00026 #ifdef FEA_TRACE_SUPPORT
00027 #include "platform/PlatformMutex.h"
00028 
00029 /**
00030  * Local mutex object for synchronization
00031  */
00032 static PlatformMutex mutex;
00033 
00034 static void serial_lock();
00035 static void serial_unlock();
00036 
00037 /**
00038  * Sets up trace for the application
00039  * Wouldn't do anything if the FEATURE_COMMON_PAL is not added
00040  * or if the trace is disabled using mbed_app.json
00041  */
00042 void setup_trace()
00043 {
00044     // setting up Mbed trace.
00045     mbed_trace_mutex_wait_function_set(serial_lock);
00046     mbed_trace_mutex_release_function_set(serial_unlock);
00047     mbed_trace_init();
00048 }
00049 
00050 /**
00051  * Lock provided for serial printing used by trace library
00052  */
00053 static void serial_lock()
00054 {
00055     mutex.lock();
00056 }
00057 
00058 /**
00059  * Releasing lock provided for serial printing used by trace library
00060  */
00061 static void serial_unlock()
00062 {
00063     mutex.unlock();
00064 }
00065 #else
00066 void setup_trace()
00067 {
00068 
00069 }
00070 #endif
00071 
00072