Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Revision:
46:665391110051
Parent:
45:b85384e7d825
Child:
49:81d5bddb02f0
diff -r b85384e7d825 -r 665391110051 src/d7a.cpp
--- a/src/d7a.cpp	Thu Sep 01 09:35:27 2016 +0000
+++ b/src/d7a.cpp	Thu Sep 01 18:13:46 2016 +0000
@@ -137,6 +137,8 @@
 {
     FPRINT("\r\n");
     
+    d7a_errors_t err;
+    
     DPRINT("Declare %d.\r\n", file_id);
     
     register_file_param_t file_infos = {
@@ -150,11 +152,11 @@
         .alloc = alloc,
     };
     
-    d7a_modem_register(&file_infos);
+    err = d7a_modem_register(&file_infos);
     
     DPRINT("Declare %d Done\r\n", file_id);
     
-    return D7A_ERR_NONE;
+    return err;
 }
 
 //======================================================================
@@ -165,16 +167,50 @@
 /// @param uint32_t             Offset from which to start reading
 /// @param uint32_t             Size of data to read
 /// @param uint8_t*             Buffer to retrieve data
-/// @param uint8_t              Retry policy
+/// @param d7a_addressee_t*     Addressee to an eventual distant device
+/// @param alp_rpol_t           Index to the retry policy to use
 /// @return d7a_errors_t        Error code
 //======================================================================
-d7a_errors_t d7a_read(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* buf, d7a_addressee_t* addressee, uint8_t retry)
+d7a_errors_t d7a_read(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* buf, d7a_addressee_t* addressee, alp_rpol_t retry)
 {
     FPRINT("\r\n");
     
-    d7a_alp_read_file(file_id, offset, size, buf, addressee, retry);
+    d7a_errors_t err;
+    
+    PRINT("Read %d.\r\n", file_id);
+    
+    err = d7a_alp_read_file(file_id, offset, size, buf, addressee, retry);
+    
+    PRINT("Read %d Done. err %d\r\n", file_id, err);
     
-    return D7A_ERR_NONE;
+    return err;
+}
+
+//======================================================================
+// d7a_write
+//----------------------------------------------------------------------
+/// @brief                      Write data to a file
+/// @param uint8_t              File ID of file to write
+/// @param uint32_t             Offset from which to start writing
+/// @param uint32_t             Size of data to write
+/// @param uint8_t*             Buffer of the data to write
+/// @param d7a_addressee_t*     Addressee to an eventual distant device
+/// @param alp_rpol_t           Index to the retry policy to use
+/// @return d7a_errors_t        Error code
+//======================================================================
+d7a_errors_t d7a_write(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* const buf, d7a_addressee_t* addressee, alp_rpol_t retry, bool resp)
+{
+    FPRINT("\r\n");
+    
+    d7a_errors_t err;
+    
+    DPRINT("Write %d.\r\n", file_id);
+    
+    err = d7a_alp_write_file(file_id, offset, size, buf, addressee, retry, resp);
+    
+    DPRINT("Write %d Done. err %d\r\n", file_id, err);
+    
+    return err;
 }
 
 //======================================================================
@@ -187,11 +223,23 @@
 /// @param uint8_t*             Buffer of the data to write
 /// @return d7a_errors_t        Error code
 //======================================================================
-d7a_errors_t d7a_write(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* const buf, d7a_addressee_t* addressee, uint8_t retry, bool resp)
+d7a_errors_t d7a_notify(const uint8_t file_id, const uint32_t offset, const uint32_t size)
 {
     FPRINT("\r\n");
     
-    d7a_alp_write_file(file_id, offset, size, buf, addressee, retry, resp);
+    d7a_errors_t err;
+    
+    DPRINT("Notify %d.\r\n", file_id);
     
-    return D7A_ERR_NONE;
+    notify_file_param_t notif = {
+        .bf.fid = file_id,
+        .bf.offset = offset,
+        .bf.size = size
+    };
+    
+    err = d7a_modem_notify(&notif);
+    
+    DPRINT("Notify %d Done. err %d\r\n", file_id, err);
+    
+    return err;
 }
\ No newline at end of file