From c1847bdd4facbd48359690d584accc65fbc13ab8 Mon Sep 17 00:00:00 2001
From: Sophia Papagiannaki <papagiannaki@stettbacher.ch>
Date: Tue, 12 May 2020 11:09:42 +0200
Subject: added firmware upgrade function

---
 o3000.c | 27 +++++++++++++++++++++++++++
 o3000.h |  1 +
 2 files changed, 28 insertions(+)

diff --git a/o3000.c b/o3000.c
index dd99f97..c68baf7 100644
--- a/o3000.c
+++ b/o3000.c
@@ -868,6 +868,33 @@ int __stdcall o3000_send_xml(int id, const char *msg, int msg_len) {
 }
 
 
+/**
+ * Do firmware update of the device
+ * 
+ * @param data pointer to firmware update data
+ * @param data_len update package lenght in bytes
+ * @return 0 on success, -1 on failure
+ */
+int __stdcall o3000_firmware_update(unsigned char *data, int data_len) {
+	
+	int ret;
+	
+	// paranoia checks
+	if(data == NULL) {
+		return -1;
+	}
+
+
+	if(data_len <= 0) {
+		return -1;
+	}
+
+	// checking whether all connection are closed
+	ret = firmware_update(data, data_len);
+	return ret;
+}
+
+
 /**
  * Disconnect a currently claimed USB connection.
  * Use this function if the driver is connected to an USB device. The o3000_connect() function-call is blocking now.
diff --git a/o3000.h b/o3000.h
index 51c8c3b..2ec4d07 100644
--- a/o3000.h
+++ b/o3000.h
@@ -88,6 +88,7 @@ int __stdcall o3000_disconnect(int id);
 
 int __stdcall o3000_send_xml(int id, const char *msg, int msg_len);
 
+int __stdcall o3000_firmware_update(unsigned char *data, int data_len);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 } // extern "C"
-- 
cgit v1.2.1