From afc85e3daa16d2f2301ff13750a038eef06e61fc Mon Sep 17 00:00:00 2001
From: Alexandre Abadie <alexandre.abadie@inria.fr>
Date: Wed, 30 Jan 2019 10:04:39 +0100
Subject: [PATCH] pkg/semtech-loramac: improve send and recv functions doc

---
 pkg/semtech-loramac/contrib/semtech_loramac.c |  3 +++
 pkg/semtech-loramac/include/semtech_loramac.h | 14 +++++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/pkg/semtech-loramac/contrib/semtech_loramac.c b/pkg/semtech-loramac/contrib/semtech_loramac.c
index 452686f97a..7e14f35242 100644
--- a/pkg/semtech-loramac/contrib/semtech_loramac.c
+++ b/pkg/semtech-loramac/contrib/semtech_loramac.c
@@ -828,6 +828,9 @@ uint8_t semtech_loramac_send(semtech_loramac_t *mac, uint8_t *data, uint8_t len)
         return SEMTECH_LORAMAC_NOT_JOINED;
     }
 
+    /* Correctly set the caller pid */
+    mac->caller_pid = thread_getpid();
+
     loramac_send_params_t params;
     params.payload = data;
     params.len = len;
diff --git a/pkg/semtech-loramac/include/semtech_loramac.h b/pkg/semtech-loramac/include/semtech_loramac.h
index 2e58021d1b..69c7ad398d 100644
--- a/pkg/semtech-loramac/include/semtech_loramac.h
+++ b/pkg/semtech-loramac/include/semtech_loramac.h
@@ -149,17 +149,22 @@ uint8_t semtech_loramac_join(semtech_loramac_t *mac, uint8_t type);
 /**
  * @brief   Sends data to the LoRaWAN network
  *
- * This function returns immediately and leave the mac in busy state until a
- * message is received from the network (with RX1 and RX2 receive windows).
+ * This function returns after TX status is replied from the MAC. To receive
+ * potential messages sent from the network an explicit call to
+ * @ref semtech_loramac_recv must be done after this function if it returned
+ * @ref SEMTECH_LORAMAC_TX_OK and within the RX windows delays.
+ *
  * @see semtech_loramac_recv
  *
  * @param[in] mac          Pointer to the mac
  * @param[in] data         The TX data
  * @param[in] len          The length of the TX data
  *
+ * @return SEMTECH_LORAMAC_TX_OK when the message can be transmitted
  * @return SEMTECH_LORAMAC_NOT_JOINED when the network is not joined
  * @return SEMTECH_LORAMAC_BUSY when the mac is already active (join or tx in progress)
- * @return SEMTECH_LORAMAC_TX_SCHEDULED when the TX is scheduled in the mac
+ * @return SEMTECH_LORAMAC_DUTYCYCLE_RESTRICTED when the send is rejected because of dutycycle restriction
+ * @return SEMTECH_LORAMAC_TX_ERROR when an invalid parameter is given
  */
 uint8_t semtech_loramac_send(semtech_loramac_t *mac, uint8_t *data, uint8_t len);
 
@@ -172,6 +177,9 @@ uint8_t semtech_loramac_send(semtech_loramac_t *mac, uint8_t *data, uint8_t len)
  * class C device, a message can be received at any time. In this case, this
  * function can be used in a dedicated listener thread.
  *
+ * Be sure to call this function before the end of the RX windows otherwise it
+ * may block the calling thread.
+ *
  * @see semtech_loramac_send
  *
  * @param[in] mac          Pointer to the mac
-- 
GitLab