From 59233d7de089f2d884acacdc3c05397b3a35e9d8 Mon Sep 17 00:00:00 2001
From: null pointer <eol@invalidfile.name>
Date: Wed, 3 Jan 2018 19:50:23 +0800
Subject: [PATCH] * add KC-specific notes * implement fix for slow joins  
 https://www.thethingsnetwork.org/forum/t/how-long-is-an-otaa-activation-join-supposed-to-take/5299/7
 * code cleanup (minor)

---
 ttb-otaa.ino.sample | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/ttb-otaa.ino.sample b/ttb-otaa.ino.sample
index 1f28c32..94986ca 100644
--- a/ttb-otaa.ino.sample
+++ b/ttb-otaa.ino.sample
@@ -1,14 +1,15 @@
 /*******************************************************************************
  * Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman
- *
+ * (+KC) Changes 2017 Null Pointer / Kinabalu Coders
+ * 
  * Permission is hereby granted, free of charge, to anyone
  * obtaining a copy of this document and accompanying files,
  * to do whatever they want with them without any restriction,
  * including, but not limited to, copying, modification and redistribution.
  * NO WARRANTY OF ANY KIND IS PROVIDED.
  *
- * This example sends a valid LoRaWAN packet with payload "Hello,
- * world!", using frequency and encryption settings matching those of
+ * (+KC) This example sends a valid LoRaWAN packet with a abitrary string 
+ * payload using frequency and encryption settings matching those of
  * the The Things Network.
  *
  * This uses OTAA (Over-the-air activation), where where a DevEUI and
@@ -25,7 +26,10 @@
  * Multiple devices can use the same AppEUI, but each device has its own
  * DevEUI and AppKey.
  *
- * Do not forget to define the radio type correctly in config.h.
+ * (+KC) Use the forked copy of the LMIC arduino library from 
+ *   https://github.com/CytronTechnologies/RFM-LoRa-Shield-Examples/
+ * arduino-lmic.zip contains the working src/lmic/config.h 
+ * configured for: us915, sx1276_radio
  *
  *******************************************************************************/
 
@@ -149,11 +153,12 @@ void do_send(osjob_t* j){
 }
 
 void setup() {
-    Serial.begin(9600);
+    Serial.begin(115200);
     Serial.println(F("Starting"));
 
     // LMIC init
     os_init();
+
     // Reset the MAC state. Session and pending data transfers will be discarded.
     LMIC_reset();
 
@@ -163,6 +168,9 @@ void setup() {
     // Disable link check validation
     LMIC_setLinkCheckMode(0);
 
+    // This tells LMIC to make the receive windows bigger, in case your clock is 1% faster or slower.
+    LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100);
+
     // TTN uses SF9 for its RX2 window.
     LMIC.dn2Dr = DR_SF9;
 
@@ -176,5 +184,3 @@ void setup() {
 void loop() {
     os_runloop_once();
 }
-
-
-- 
GitLab