Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Revision:
67:9ac9d109b80a
Parent:
66:492b1d7ba370
Child:
68:d2778c6abf1a
--- a/src/d7a.cpp	Fri Oct 21 15:31:45 2016 +0000
+++ b/src/d7a.cpp	Wed Oct 26 10:01:26 2016 +0000
@@ -195,7 +195,7 @@
 }
 
 
-d7a_msg_t** d7a_read(const uint8_t file_id, const uint32_t offset, const uint32_t size, d7a_addressee_t* addressee, alp_rpol_t retry)
+d7a_msg_t** d7a_read(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* root_key, d7a_addressee_t* addressee, alp_rpol_t retry)
 {
     FPRINT("\r\n");
     
@@ -205,7 +205,7 @@
     
     if (g_started)
     {
-        ret = d7a_alp_read_file(file_id, offset, size, addressee, retry);
+        ret = d7a_alp_read_file(file_id, offset, size, root_key, addressee, retry);
     }
     
     DPRINT("Read %d Done.\r\n", file_id);
@@ -216,7 +216,7 @@
 }
 
 
-d7a_msg_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)
+d7a_msg_t** d7a_write(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* const buf, const uint8_t* root_key, d7a_addressee_t* addressee, alp_rpol_t retry, bool resp)
 {
     FPRINT("\r\n");
     
@@ -226,7 +226,7 @@
     
     if (g_started)
     {
-        ret = d7a_alp_write_file(file_id, offset, size, buf, addressee, retry, resp);
+        ret = d7a_alp_write_file(file_id, offset, size, buf, root_key, addressee, retry, resp);
     }
     
     DPRINT("Write %d Done.\r\n", file_id);
@@ -236,6 +236,25 @@
     return ret;
 }
 
+d7a_msg_t** d7a_flush(const uint8_t file_id, const uint8_t* root_key, d7a_addressee_t* addressee, alp_rpol_t retry, bool resp)
+{
+    FPRINT("\r\n");
+    
+    d7a_msg_t** ret = NULL;
+    
+    DPRINT("Flush %d.\r\n", file_id);
+    
+    if (g_started)
+    {
+        ret = d7a_alp_flush_file(file_id, root_key, addressee, retry, resp);
+    }
+    
+    DPRINT("Flush %d Done.\r\n", file_id);
+    
+    WARNING(ret[0]->err == D7A_ERR_NONE, "%s FID: %d err %d\r\n", __FUNCTION__, file_id, ret[0]->err);
+    
+    return ret;
+}
 
 d7a_errors_t d7a_notify(const uint8_t file_id, const uint32_t offset, const uint32_t size)
 {
@@ -321,7 +340,7 @@
     PRINT("| Manufacturer ID:  %08X            |\r\n", rev.manufacturer_id);
     PRINT("| Device ID:        %08X            |\r\n", rev.device_id);
     PRINT("| Hardware version: %08X            |\r\n", rev.hw_version);
-    PRINT("| Firmware version: %d-%d.%d.%d-%08x \t|\r\n", rev.fw_version.id, rev.fw_version.major, rev.fw_version.minor, rev.fw_version.patch, rev.fw_version.hash);
+    PRINT("| Firmware version: (%02X) v%d.%d.%d-%08x \t|\r\n", rev.fw_version.id, rev.fw_version.major, rev.fw_version.minor, rev.fw_version.patch, rev.fw_version.hash);
     PRINT("| File system CRC:  0x%08x          |\r\n", rev.fs_crc);
     PRINT("-----------------------------------------\r\n");