Demo program for LoRaWan with data formated for cayenne interface on mydevices.com Check on https://goo.gl/fTUDNc
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
trace_helper.cpp@43:74226f6ca42c, 2018-11-29 (annotated)
- Committer:
- cdupaty
- Date:
- Thu Nov 29 07:48:18 2018 +0000
- Revision:
- 43:74226f6ca42c
- Parent:
- 26:f07f5febf97f
Demo with LM52 captor on analog A0.; Data formated for cayenne (mydevices.com); Led green (LED1) on B-L072Z-LRWAN1 flash when data reception
Who changed what in which revision?
User | Revision | Line number | New 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 | /** |
mbed_official | 0:7037ed05f54f | 19 | * If we have tracing library available, we can see traces from within the |
mbed_official | 0:7037ed05f54f | 20 | * stack. The library could be made unavailable by removing FEATURE_COMMON_PAL |
mbed_official | 0:7037ed05f54f | 21 | * from the mbed_app.json to save RAM. |
mbed_official | 0:7037ed05f54f | 22 | */ |
mbed_official | 26:f07f5febf97f | 23 | |
mbed_official | 26:f07f5febf97f | 24 | #include "mbed_trace.h" |
mbed_official | 0:7037ed05f54f | 25 | |
mbed_official | 26:f07f5febf97f | 26 | #ifdef FEA_TRACE_SUPPORT |
mbed_official | 26:f07f5febf97f | 27 | #include "platform/PlatformMutex.h" |
mbed_official | 0:7037ed05f54f | 28 | |
mbed_official | 26:f07f5febf97f | 29 | /** |
mbed_official | 26:f07f5febf97f | 30 | * Local mutex object for synchronization |
mbed_official | 26:f07f5febf97f | 31 | */ |
mbed_official | 26:f07f5febf97f | 32 | static PlatformMutex mutex; |
mbed_official | 0:7037ed05f54f | 33 | |
mbed_official | 26:f07f5febf97f | 34 | static void serial_lock(); |
mbed_official | 26:f07f5febf97f | 35 | static void serial_unlock(); |
mbed_official | 0:7037ed05f54f | 36 | |
mbed_official | 26:f07f5febf97f | 37 | /** |
mbed_official | 26:f07f5febf97f | 38 | * Sets up trace for the application |
mbed_official | 26:f07f5febf97f | 39 | * Wouldn't do anything if the FEATURE_COMMON_PAL is not added |
mbed_official | 26:f07f5febf97f | 40 | * or if the trace is disabled using mbed_app.json |
mbed_official | 26:f07f5febf97f | 41 | */ |
mbed_official | 26:f07f5febf97f | 42 | void setup_trace() |
mbed_official | 26:f07f5febf97f | 43 | { |
mbed_official | 26:f07f5febf97f | 44 | // setting up Mbed trace. |
mbed_official | 26:f07f5febf97f | 45 | mbed_trace_mutex_wait_function_set(serial_lock); |
mbed_official | 26:f07f5febf97f | 46 | mbed_trace_mutex_release_function_set(serial_unlock); |
mbed_official | 26:f07f5febf97f | 47 | mbed_trace_init(); |
mbed_official | 26:f07f5febf97f | 48 | } |
mbed_official | 0:7037ed05f54f | 49 | |
mbed_official | 26:f07f5febf97f | 50 | /** |
mbed_official | 26:f07f5febf97f | 51 | * Lock provided for serial printing used by trace library |
mbed_official | 26:f07f5febf97f | 52 | */ |
mbed_official | 26:f07f5febf97f | 53 | static void serial_lock() |
mbed_official | 26:f07f5febf97f | 54 | { |
mbed_official | 26:f07f5febf97f | 55 | mutex.lock(); |
mbed_official | 26:f07f5febf97f | 56 | } |
mbed_official | 0:7037ed05f54f | 57 | |
mbed_official | 26:f07f5febf97f | 58 | /** |
mbed_official | 26:f07f5febf97f | 59 | * Releasing lock provided for serial printing used by trace library |
mbed_official | 26:f07f5febf97f | 60 | */ |
mbed_official | 26:f07f5febf97f | 61 | static void serial_unlock() |
mbed_official | 26:f07f5febf97f | 62 | { |
mbed_official | 26:f07f5febf97f | 63 | mutex.unlock(); |
mbed_official | 26:f07f5febf97f | 64 | } |
mbed_official | 26:f07f5febf97f | 65 | #else |
mbed_official | 26:f07f5febf97f | 66 | void setup_trace() |
mbed_official | 26:f07f5febf97f | 67 | { |
mbed_official | 0:7037ed05f54f | 68 | |
mbed_official | 26:f07f5febf97f | 69 | } |
mbed_official | 0:7037ed05f54f | 70 | #endif |
mbed_official | 0:7037ed05f54f | 71 | |
mbed_official | 26:f07f5febf97f | 72 |