example using mbed loramac with GPS in application layer

Dependencies:   lib_gps

This repository can work on NAmote72.

This main.cpp generates Cayenne LPP GPS payload.

See mbed documentation for provisioning instructions.

Committer:
Wayne Roberts
Date:
Thu Jan 03 16:18:09 2019 -0800
Revision:
0:2e040cc7f7b8
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wayne Roberts 0:2e040cc7f7b8 1 /**
Wayne Roberts 0:2e040cc7f7b8 2 * Copyright (c) 2017, Arm Limited and affiliates.
Wayne Roberts 0:2e040cc7f7b8 3 * SPDX-License-Identifier: Apache-2.0
Wayne Roberts 0:2e040cc7f7b8 4 *
Wayne Roberts 0:2e040cc7f7b8 5 * Licensed under the Apache License, Version 2.0 (the "License");
Wayne Roberts 0:2e040cc7f7b8 6 * you may not use this file except in compliance with the License.
Wayne Roberts 0:2e040cc7f7b8 7 * You may obtain a copy of the License at
Wayne Roberts 0:2e040cc7f7b8 8 *
Wayne Roberts 0:2e040cc7f7b8 9 * http://www.apache.org/licenses/LICENSE-2.0
Wayne Roberts 0:2e040cc7f7b8 10 *
Wayne Roberts 0:2e040cc7f7b8 11 * Unless required by applicable law or agreed to in writing, software
Wayne Roberts 0:2e040cc7f7b8 12 * distributed under the License is distributed on an "AS IS" BASIS,
Wayne Roberts 0:2e040cc7f7b8 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Wayne Roberts 0:2e040cc7f7b8 14 * See the License for the specific language governing permissions and
Wayne Roberts 0:2e040cc7f7b8 15 * limitations under the License.
Wayne Roberts 0:2e040cc7f7b8 16 */
Wayne Roberts 0:2e040cc7f7b8 17
Wayne Roberts 0:2e040cc7f7b8 18 /**
Wayne Roberts 0:2e040cc7f7b8 19 * If we have tracing library available, we can see traces from within the
Wayne Roberts 0:2e040cc7f7b8 20 * stack. The library could be made unavailable by removing FEATURE_COMMON_PAL
Wayne Roberts 0:2e040cc7f7b8 21 * from the mbed_app.json to save RAM.
Wayne Roberts 0:2e040cc7f7b8 22 */
Wayne Roberts 0:2e040cc7f7b8 23
Wayne Roberts 0:2e040cc7f7b8 24 #include "mbed_trace.h"
Wayne Roberts 0:2e040cc7f7b8 25
Wayne Roberts 0:2e040cc7f7b8 26 #ifdef FEA_TRACE_SUPPORT
Wayne Roberts 0:2e040cc7f7b8 27 #include "platform/PlatformMutex.h"
Wayne Roberts 0:2e040cc7f7b8 28
Wayne Roberts 0:2e040cc7f7b8 29 /**
Wayne Roberts 0:2e040cc7f7b8 30 * Local mutex object for synchronization
Wayne Roberts 0:2e040cc7f7b8 31 */
Wayne Roberts 0:2e040cc7f7b8 32 static PlatformMutex mutex;
Wayne Roberts 0:2e040cc7f7b8 33
Wayne Roberts 0:2e040cc7f7b8 34 static void serial_lock();
Wayne Roberts 0:2e040cc7f7b8 35 static void serial_unlock();
Wayne Roberts 0:2e040cc7f7b8 36
Wayne Roberts 0:2e040cc7f7b8 37 /**
Wayne Roberts 0:2e040cc7f7b8 38 * Sets up trace for the application
Wayne Roberts 0:2e040cc7f7b8 39 * Wouldn't do anything if the FEATURE_COMMON_PAL is not added
Wayne Roberts 0:2e040cc7f7b8 40 * or if the trace is disabled using mbed_app.json
Wayne Roberts 0:2e040cc7f7b8 41 */
Wayne Roberts 0:2e040cc7f7b8 42 void setup_trace()
Wayne Roberts 0:2e040cc7f7b8 43 {
Wayne Roberts 0:2e040cc7f7b8 44 // setting up Mbed trace.
Wayne Roberts 0:2e040cc7f7b8 45 mbed_trace_mutex_wait_function_set(serial_lock);
Wayne Roberts 0:2e040cc7f7b8 46 mbed_trace_mutex_release_function_set(serial_unlock);
Wayne Roberts 0:2e040cc7f7b8 47 mbed_trace_init();
Wayne Roberts 0:2e040cc7f7b8 48 }
Wayne Roberts 0:2e040cc7f7b8 49
Wayne Roberts 0:2e040cc7f7b8 50 /**
Wayne Roberts 0:2e040cc7f7b8 51 * Lock provided for serial printing used by trace library
Wayne Roberts 0:2e040cc7f7b8 52 */
Wayne Roberts 0:2e040cc7f7b8 53 static void serial_lock()
Wayne Roberts 0:2e040cc7f7b8 54 {
Wayne Roberts 0:2e040cc7f7b8 55 mutex.lock();
Wayne Roberts 0:2e040cc7f7b8 56 }
Wayne Roberts 0:2e040cc7f7b8 57
Wayne Roberts 0:2e040cc7f7b8 58 /**
Wayne Roberts 0:2e040cc7f7b8 59 * Releasing lock provided for serial printing used by trace library
Wayne Roberts 0:2e040cc7f7b8 60 */
Wayne Roberts 0:2e040cc7f7b8 61 static void serial_unlock()
Wayne Roberts 0:2e040cc7f7b8 62 {
Wayne Roberts 0:2e040cc7f7b8 63 mutex.unlock();
Wayne Roberts 0:2e040cc7f7b8 64 }
Wayne Roberts 0:2e040cc7f7b8 65 #else
Wayne Roberts 0:2e040cc7f7b8 66 void setup_trace()
Wayne Roberts 0:2e040cc7f7b8 67 {
Wayne Roberts 0:2e040cc7f7b8 68
Wayne Roberts 0:2e040cc7f7b8 69 }
Wayne Roberts 0:2e040cc7f7b8 70 #endif
Wayne Roberts 0:2e040cc7f7b8 71
Wayne Roberts 0:2e040cc7f7b8 72