faecher:nwt:lorawan:uebersicht:lorashield:start

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
faecher:nwt:lorawan:uebersicht:lorashield:start [17.02.2020 19:41] sbelfaecher:nwt:lorawan:uebersicht:lorashield:start [17.02.2020 20:19] (aktuell) sbel
Zeile 4: Zeile 4:
 ===== LoraShield aufstecken ===== ===== LoraShield aufstecken =====
  
 +{{ :faecher:nwt:lorawan:uebersicht:lorashield:img_20200217_191115.jpg?300 |}}
 ===== Bibliothek installieren ===== ===== Bibliothek installieren =====
  
-Um das Shield ansprechen zu können, muss die LMIC Bibliothek installiert werden+Um das Shield ansprechen zu können, muss die LMIC Bibliothek installiert werden. 
- +
-{{ :faecher:nwt:lorawan:uebersicht:lorashield:lmic.png |}}+
  
 +  * [[https://github.com/matthijskooijman/arduino-lmic/archive/master.zip|Zip Datei herunterladen]] (Source: https://github.com/matthijskooijman/arduino-lmic)
 +  * Installieren mit ''Sketch''-> ''Bibliothek einbinden'' -> ''ZIP-Bibliothek hinzufügen'' 
 ===== Sketch ===== ===== Sketch =====
  
 ++++ Klicken, um den Beispielsketch zu sehen | ++++ Klicken, um den Beispielsketch zu sehen |
-<code c hellolora.ino> +<code c hello_lora.ino>
 // MIT License // MIT License
 // https://github.com/gonzalocasas/arduino-uno-dragino-lorawan/blob/master/LICENSE // https://github.com/gonzalocasas/arduino-uno-dragino-lorawan/blob/master/LICENSE
Zeile 29: Zeile 28:
 static const u1_t APPSKEY[16] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; static const u1_t APPSKEY[16] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
 static const u4_t DEVADDR = 0x00000000; static const u4_t DEVADDR = 0x00000000;
 +
  
 // These callbacks are only used in over-the-air activation, so they are // These callbacks are only used in over-the-air activation, so they are
Zeile 96: Zeile 96:
  
     // Start job     // Start job
-    do_send(// MIT License +    do_send(&sendjob); 
-// https://github.com/gonzalocasas/arduino-uno-dragino-lorawan/blob/master/LICENSE +}
-// Based on examples from https://github.com/matthijskooijman/arduino-lmic +
-// Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman+
  
-// Adaptions: Andreas Spiess +void loop() { 
- +    os_runloop_once();
-#include <lmic.h> +
-#include <hal/hal.h> +
-//#include <credentials.h> +
- +
-#ifdef CREDENTIALS +
-static const u1_t NWKSKEY[16] = NWKSKEY1; +
-static const u1_t APPSKEY[16] = APPSKEY1; +
-static const u4_t DEVADDR = DEVADDR1; +
-#else +
-static const u1_t NWKSKEY[16] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +
-static const u1_t APPSKEY[16] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +
-static const u4_t DEVADDR = 0x00000000; +
-#endif +
- +
-// These callbacks are only used in over-the-air activation, so they are +
-// left empty here (we cannot leave them out completely unless +
-// DISABLE_JOIN is set in config.h, otherwise the linker will complain). +
-void os_getArtEui (u1_t* buf{ } +
-void os_getDevEui (u1_t* buf) { } +
-void os_getDevKey (u1_t* buf) { } +
- +
-static osjob_t sendjob; +
- +
-// Schedule TX every this many seconds (might become longer due to duty +
-// cycle limitations). +
-const unsigned TX_INTERVAL = 20; +
- +
-// Pin mapping Dragino Shield +
-const lmic_pinmap lmic_pins = +
-    .nss = 10, +
-    .rxtx = LMIC_UNUSED_PIN, +
-    .rst = 9, +
-    .dio = {2, 6, 7}, +
-}; +
-void onEvent (ev_t ev) { +
-    if (ev == EV_TXCOMPLETE) { +
-        Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)")); +
-        // Schedule next transmission +
-        os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send); +
-    }+
 } }
 +</code>
 +++++
  
-void do_send(osjob_t* j){ +===== Neues Device bei TTN erstellen =====
-    // Payload to send (uplink) +
-    static uint8_t message[] "hi";+
  
-    // Check if there is not a current TX/RX job running 
-    if (LMIC.opmode & OP_TXRXPEND) { 
-        Serial.println(F("OP_TXRXPEND, not sending")); 
-    } else { 
-        // Prepare upstream data transmission at the next possible time. 
-        LMIC_setTxData2(1, message, sizeof(message)-1, 0); 
-        Serial.println(F("Sending uplink packet...")); 
-    } 
-    // Next TX is scheduled after TX_COMPLETE event. 
-} 
  
-void setup() { +Nun benötigt man in der TTN Console eine Application und muss dort ein neues Device anlegenMan vergibt einen Namen und lässt die übrigen Werte berechnenDas Ergebnis sieht so aus, wie im Screenshot zu sehen
-    Serial.begin(115200); +
-    Serial.println(F("Starting..."));+
  
-    // LMIC init +**Wichtig**: 
-    os_init();+
  
-    // Reset the MAC stateSession and pending data transfers will be discarded. +  * Das Device muss als Activation Method ''ABP'' haben 
-    LMIC_reset();+  * Um die passenden IDs im Sketch einzutragen, müssen diese das passende Format haben - die Darstellung kann man durch anklicken von ''<>'' umschalten.
  
-    // Set static session parameters. +{{ :faecher:nwt:lorawan:uebersicht:lorashield:device_ttn.png |}}
-    LMIC_setSession (0x1, DEVADDR, NWKSKEY, APPSKEY);+
  
-    // Disable link check validation +===== IDs in den Sketch eintragen =====
-    LMIC_setLinkCheckMode(0);+
  
-    // TTN uses SF9 for its RX2 window. +  * NWKSKEY: Network Session Key 
-    LMIC.dn2Dr = DR_SF9;+  * APPSKEY: Application Session Key 
 +  * DEVADDR: Device Address
  
-    // Set data rate and transmit power for uplink (note: txpow seems to be ignored by the library) 
-    LMIC_setDrTxpow(DR_SF12,14); 
  
-    // Start job +{{ :faecher:nwt:lorawan:uebersicht:lorashield:keys.png |}}
-    do_send(&sendjob); +
-}+
  
-void loop() { +===== Kompilieren und Testen =====
-    os_runloop_once(); +
-+
-&sendjob); +
-}+
  
-void loop() { +Beim Kompilieren erscheinen Warnungen, die kann man ignorieren.
-    os_runloop_once(); +
-}+
  
-</code> +{{ :faecher:nwt:lorawan:uebersicht:lorashield:warnings.png |}} 
-+++++
  
-===== Neues Device bei TTN erstellen ===== 
  
  
-Nun benötigt man in der TTN Console eine Application und muss dort ein neues Device anlegen. Man vergibt einen Namen und lässt die übrigen Werte berechnen. Das Ergebnis sieht so auswie im Screenshot zu sehen. **Wichtig**: Um die passenden IDs im Sketch einzutragenmüssn diese das passende Format haben - die Darstellung kann man durch anklicken von ''<>'' umschalten.+Wenn man den Sketch auf den Arduino lädtsollte man bei TTN sehen, dass das Device aktiv ist:
  
-{{ :faecher:nwt:lorawan:uebersicht:lorashield:device_ttn.png |}} +{{ :faecher:nwt:lorawan:uebersicht:lorashield:active.png?600 |}}
- +
-===== IDs in den Sketch eintragen =====+
  
 +Im Data-Tab kann man jetzt auch sehen, dass da Daten übermittelt werden:
  
- +{{ :faecher:nwt:lorawan:uebersicht:lorashield:data.png?600 |}}
  
  
  • faecher/nwt/lorawan/uebersicht/lorashield/start.1581964914.txt.gz
  • Zuletzt geändert: 17.02.2020 19:41
  • von sbel