Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Revision:
58:38a366236bda
Parent:
57:fd9c8b67ffdc
Child:
59:b42eae56b51b
diff -r fd9c8b67ffdc -r 38a366236bda include/d7a.h
--- a/include/d7a.h	Thu Sep 08 10:44:05 2016 +0000
+++ b/include/d7a.h	Mon Sep 12 16:36:09 2016 +0000
@@ -13,6 +13,14 @@
 #define D7A_XCL_ENDPOINT    (0x01)
 #define D7A_XCL_GATEWAY     (0x21)
 
+#define D7A_CTF_VAL(mant,exp)   ((uint8_t)(mant|(exp<<5)))
+#define D7A_CTF_TO_VAL(ctf)     ((uint32_t)()
+
+
+
+
+#define D7A_NBID(nbid)          (nbid >= 32)? D7A_CTF_VAL(8,1) : D7A_CTF_VAL(nbid,0)
+
 
 //======================================================================
 // Enums
@@ -186,6 +194,26 @@
     D7A_NOTIFICATION_PART
 } d7a_action_t;
 
+
+// =======================================================================
+// d7a_id_t
+// -----------------------------------------------------------------------
+// Identifier types enumerator
+// =======================================================================
+typedef enum
+{
+    // Void identifier (broadcast) 
+    // with indication of number of reached devices
+    D7A_ID_NBID = 0,
+    // Void identifier (broadcast)
+    D7A_ID_NOID = 1,
+    // Unique Identifier
+    D7A_ID_UID  = 2,
+    // Virtual identifier
+    D7A_ID_VID  = 3,
+
+} d7a_id_t;
+
 //======================================================================
 // Structures
 //======================================================================
@@ -347,6 +375,25 @@
 } d7a_addressee_t;
 
 
+// =======================================================================
+// d7a_resp_t
+// -----------------------------------------------------------------------
+/// Response data and meta-data from a device
+// =======================================================================
+typedef struct
+{
+    /// Error code
+    int8_t err;
+    /// Responder's UID
+    uint8_t id[D7A_UID_LEN];
+    /// Transmission Link Budget
+    int8_t lb;
+    /// Potential data
+    uint32_t data_len;
+    uint8_t* data;
+} d7a_msg_t;
+
+
 //======================================================================
 // Prototypes
 //======================================================================
@@ -442,10 +489,9 @@
 /// @param retry                Index to the retry policy to use
 /// @return d7a_errors_t        Error code
 //======================================================================
-d7a_errors_t d7a_read(const uint8_t file_id, 
+d7a_msg_t** d7a_read(const uint8_t file_id, 
                       const uint32_t offset, 
                       const uint32_t size, 
-                      const uint8_t* buf, 
                       d7a_addressee_t* addressee = NULL, 
                       alp_rpol_t retry = ALP_RPOL_ONESHOT);
 
@@ -462,7 +508,7 @@
 /// @param resp                 Wait to see if write is OK
 /// @return d7a_errors_t        Error code
 //======================================================================
-d7a_errors_t d7a_write(const uint8_t file_id, 
+d7a_msg_t** d7a_write(const uint8_t file_id, 
                        const uint32_t offset, 
                        const uint32_t size, 
                        const uint8_t* const buf, 
@@ -484,6 +530,8 @@
                         const uint32_t size = 0);
 
 
+void d7a_free_msg(d7a_msg_t** msg);
+
 //======================================================================
 // d7a_modem_print_infos
 //----------------------------------------------------------------------