lora

Revision:
26:f07f5febf97f
Parent:
18:1720bc3831ea
Child:
46:a124538e2891
--- a/main.cpp	Tue Jun 19 14:15:24 2018 +0100
+++ b/main.cpp	Thu Jun 28 12:45:20 2018 +0100
@@ -145,7 +145,6 @@
     return 0;
 }
 
-
 /**
  * Sends a message to the Network Server
  */
@@ -174,6 +173,13 @@
     if (retcode < 0) {
         retcode == LORAWAN_STATUS_WOULD_BLOCK ? printf("send - WOULD BLOCK\r\n")
                 : printf("\r\n send() - Error code %d \r\n", retcode);
+
+        if (retcode == LORAWAN_STATUS_WOULD_BLOCK) {
+            //retry in 3 seconds
+            if (MBED_CONF_LORA_DUTY_CYCLE_ON) {
+                ev_queue.call_in(3000, send_message);
+            }
+        }
         return;
     }
 
@@ -253,6 +259,12 @@
         case JOIN_FAILURE:
             printf("\r\n OTAA Failed - Check Keys \r\n");
             break;
+        case UPLINK_REQUIRED:
+            printf("\r\n Uplink required by NS \r\n");
+            if (MBED_CONF_LORA_DUTY_CYCLE_ON) {
+                send_message();
+            }
+            break;
         default:
             MBED_ASSERT("Unknown Event");
     }