+char *_bt_otp_uuid_convert_hex_to_string(char *value, uint32_t length)
+{
+ char *uuid = NULL;
+ unsigned int data0;
+ unsigned short data1;
+ unsigned short data2;
+ unsigned short data3;
+ unsigned int data4;
+ unsigned short data5;
+ size_t n;
+
+ uuid = (char *) g_malloc0(2 * length * sizeof(char));
+ n = 2 * length + 1;
+
+ switch (length) {
+ case 2:
+ memcpy(&data1, &value[0], 2);
+ snprintf(uuid, n, "%.4x", ntohs(data1));
+ break;
+ case 4:
+ memcpy(&data0, &value[0], 4);
+ snprintf(uuid, n, "%.8x", ntohl(data0));
+ break;
+ case 16:
+ memcpy(&data0, &value[0], 4);
+ memcpy(&data1, &value[4], 2);
+ memcpy(&data2, &value[6], 2);
+ memcpy(&data3, &value[8], 2);
+ memcpy(&data4, &value[10], 4);
+ memcpy(&data5, &value[14], 2);
+
+ snprintf(uuid, n + 4, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x",
+ ntohl(data0), ntohs(data1),
+ ntohs(data2), ntohs(data3),
+ ntohl(data4), ntohs(data5));
+ break;
+ default:
+ g_free(uuid);
+ return NULL;
+ }
+
+ return uuid;
+}
+
+void _bt_otp_create_new_object(uint32_t size, char *uuid)
+{
+ struct object_metadata *object = NULL;
+
+ /* Store current object id.
+ * Incase of OACP Create fail, need to restore
+ * it back.
+ */
+ prev_obj_id = selected_object->id;
+
+ object = g_new0(struct object_metadata, 1);
+
+ object->name = NULL;
+ object->type = g_strdup(uuid);
+ object->first_created = 0;
+ object->last_modified = 0;
+ object->curr_size = 0;
+ object->alloc_size = size;
+ object->id = object_id;
+ object->props = OBJECT_READ | OBJECT_WRITE |
+ OBJECT_EXECUTE | OBJECT_DELETE;
+
+ otp_object_list = g_slist_append(otp_object_list,
+ object);
+
+ update_obj_metadata_charc_value(object);
+ selected_object = object;
+ curr_obj_index = g_slist_length(otp_object_list) - 1;
+ curr_obj_id = selected_object->id;
+ object_id++;
+
+ free(uuid);
+}
+
+void _bt_otp_restore_old_object()
+{
+ struct object_metadata *object = NULL;
+ guint index = 0;
+
+ object = _bt_otp_client_find_object(otp_object_list, curr_obj_id, &index);
+ if (!object)
+ return;
+
+ otp_object_list = g_slist_remove(otp_object_list, object);
+
+ index = 0;
+ object = _bt_otp_client_find_object(otp_object_list, prev_obj_id, &index);
+ if (!object) {
+ BT_ERR("Object is NULL");
+ return;
+ }
+ oacp_create = FALSE;
+ update_obj_metadata_charc_value(object);
+ selected_object = object;
+ curr_obj_index = index;
+ object_id--;
+}
+