Demo program for LoRaWan with data formated for cayenne interface on mydevices.com Check on https://goo.gl/fTUDNc

Dependencies:   Cayenne-LPP

Demonstration d'un node LoRaWan sur carte : Discovery IOT STmicro : B-L072Z-LRWAN1 https://www.st.com/en/evaluation-tools/b-l072z-lrwan1.html

L e code original MBED-ARM : https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-lorawan/ est une application de l'API LoRAWan https://os.mbed.com/docs/v5.9/reference/lorawan.html

Le code original a été adapté pour une carte B-L072Z-LRWAN1 équipée d'un capteur de température LM35 connecté en 3.3v sur le port PA_0 (port analogique AN0) Les données sont formatées "cayenne" et visualisables sur mydevices.com ( https://goo.gl/fTUDNc ) Documentation cayenne : https://mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload

Les essais ont été réalisés avec une passerelle TTN https://www.thethingsnetwork.org/ le "Payload Format" ayant été configuré pour "Cayenne LPP"

Des capteurs virtuels on été également ajoutés (humidité, température, lumière, etc...) pour les essais au format cayenne.

Données physiques transmises (downlink)

- Température sur capteur LM35 - Tension sur PA_1 (AN1) est transmise entre 0% et 100% - Etat du bouton bleu

Données physiques reçues (uplink) Un actionneur permet d'allumer/eteindre à distance la led verte de la carte B-L072Z-LRWAN1

L'interface mydevice.com proposé permet de visualiser :

- Les capteurs virtuels - La température réelle sur LM35 - L'état du bouton bleu

/media/uploads/cdupaty/cayenne_mydevice.jpg

/media/uploads/cdupaty/ex_terminal-lorawan.jpg

Committer:
mbed_official
Date:
Thu Mar 08 17:46:15 2018 +0000
Revision:
0:7037ed05f54f
Child:
8:7594ad70d2bf
Fix construction of LoRaWANInterface object

Since radio object is constructed by another source file, we have a
race condition. In order to prevent this race condition, LoRaWANInterface
object is now created in main().

.
Commit copied from https://github.com/ARMmbed/mbed-os-example-lorawan

Who changed what in which revision?

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