BLUETOOTH_ERROR_NONE, otp_client_s->remote_address, obj_list, otp_client_s->user_data);
}
+static void __bt_otp_client_feature_response(bt_otp_client_s *otp_client_s, char *value, int len)
+{
+ int error_code = BLUETOOTH_ERROR_NONE;
+
+ uint64_t feature = (uint64_t)(value[0] & 0xFF) << 56 |
+ (uint64_t)(value[1] & 0xFF) << 48 |
+ (uint64_t)(value[2] & 0xFF) << 40 |
+ (uint64_t)(value[3] & 0xFF) << 32 |
+ (uint64_t)(value[4] & 0xFF) << 24 |
+ (uint64_t)(value[5] & 0xFF) << 16 |
+ (uint64_t)(value[6] & 0xFF) << 8 |
+ (uint64_t)(value[7] & 0xFF);
+ otp_client_s->otp_feature = feature;
+ BT_INFO("OTP Feature [%llu]", feature);
+
+ if (BT_OTP_IS_OACP_SUPPORTED(otp_client_s->otp_feature)
+ && !otp_client_s->oacp_cccd_enabled
+ && otp_client_s->otp_oacp_control_point) {
+
+ error_code = bluetooth_otp_enable_notification(otp_client_s->otp_oacp_control_point);
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("OACP Notification enable failed %s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ }
+
+ if (BT_OTP_IS_OLCP_SUPPORTED(otp_client_s->otp_feature)
+ && !otp_client_s->olcp_cccd_enabled
+ && otp_client_s->otp_olcp_control_point) {
+ error_code = bluetooth_otp_enable_notification(otp_client_s->otp_olcp_control_point);
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("OLCP Notification enable failed %s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ }
+
+ if (!otp_client_s->obj_changed_cccd_enabed
+ && otp_client_s->otp_obj_changed_obj_path) {
+ error_code = bluetooth_otp_enable_notification(otp_client_s->otp_obj_changed_obj_path);
+ if (error_code != BT_ERROR_NONE)
+ BT_ERR("Object Changed Notification enable failed %s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ }
+}
+
+static void __bt_otp_client_name_response(bt_otp_client_s *otp_client_s, char *value, int len)
+{
+ int error_code = BLUETOOTH_ERROR_NONE;
+ int result = BLUETOOTH_ERROR_NONE;
+ char *name = NULL;
+ name = g_strndup(value, len);
+ BT_INFO("Object Name [%s]", name);
+
+ if (otp_client_s->curr_op == BT_OTP_OBJECT_DISCOVERY) {
+ metadata->name = g_strdup(name);
+ error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_type_obj_path);
+ if (error_code != BLUETOOTH_ERROR_NONE) {
+ BT_INFO("Read Charc Value Failed %s(0x%08x)",
+ _bt_convert_error_to_string(error_code), error_code);
+ result = error_code;
+ _bt_otp_send_callback(result, NULL, otp_client_s->object_id, 0, otp_client_s);
+ g_free(name);
+ return;
+ }
+ }
+ g_free(name);
+}
+
+static void __bt_otp_client_type_response(bt_otp_client_s *otp_client_s, char *value, int len)
+{
+ int error_code = BLUETOOTH_ERROR_NONE;
+ int result = BLUETOOTH_ERROR_NONE;
+ char *type = NULL;
+ type = g_strndup(value, len);
+ BT_INFO("Object Type [%s]", type);
+
+ if (otp_client_s->curr_op == BT_OTP_OBJECT_DISCOVERY) {
+ metadata->type = g_strdup(type);
+ error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_size_obj_path);
+ if (error_code != BLUETOOTH_ERROR_NONE) {
+ BT_INFO("Read Charc Value Failed %s(0x%08x)",
+ _bt_convert_error_to_string(error_code), error_code);
+ result = error_code;
+ _bt_otp_send_callback(result, NULL, otp_client_s->object_id, 0, otp_client_s);
+ g_free(type);
+ return;
+ }
+ }
+ g_free(type);
+}
+
+static void __bt_otp_client_size_response(bt_otp_client_s *otp_client_s, char *value, int len)
+{
+ int error_code = BLUETOOTH_ERROR_NONE;
+ int result = BLUETOOTH_ERROR_NONE;
+ uint32_t csize, asize;
+ csize = (uint32_t)(value[3] & 0xFF) << 24 |
+ (uint32_t)(value[2] & 0xFF) << 16 |
+ (uint32_t)(value[1] & 0xFF) << 8 |
+ (uint32_t)(value[0] & 0xFF);
+
+ asize = (uint32_t)(value[7] & 0xFF) << 24 |
+ (uint32_t)(value[6] & 0xFF) << 16 |
+ (uint32_t)(value[5] & 0xFF) << 8 |
+ (uint32_t)(value[4] & 0xFF);
+
+ BT_INFO("Object Size curr[%u] alloc[%u]", csize, asize);
+
+ if (otp_client_s->curr_op == BT_OTP_OBJECT_DISCOVERY) {
+ metadata->curr_size = csize;
+ metadata->alloc_size = asize;
+ error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_props_obj_path);
+ if (error_code != BLUETOOTH_ERROR_NONE) {
+ BT_INFO("Read Charc Value Failed %s(0x%08x)",
+ _bt_convert_error_to_string(error_code), error_code);
+ result = error_code;
+ _bt_otp_send_callback(result, NULL, otp_client_s->object_id, 0, otp_client_s);
+ }
+ }
+}
+
+static void __bt_otp_client_props_response(bt_otp_client_s *otp_client_s, char *value, int len)
+{
+ int error_code = BLUETOOTH_ERROR_NONE;
+ int result = BLUETOOTH_ERROR_NONE;
+ uint32_t props;
+ props = (uint32_t)(value[3] & 0xFF) << 24 |
+ (uint32_t)(value[2] & 0xFF) << 16 |
+ (uint32_t)(value[1] & 0xFF) << 8 |
+ (uint32_t)(value[0] & 0xFF);
+ BT_INFO("Object Properties [%u]", props);
+
+ /* First-created & Last-modified are optional charcacteristics */
+ if (otp_client_s->curr_op != BT_OTP_OBJECT_DISCOVERY)
+ return;
+
+ metadata->props = props;
+ if (otp_client_s->otp_first_created_obj_path) {
+ error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_first_created_obj_path);
+ if (error_code != BLUETOOTH_ERROR_NONE) {
+ BT_INFO("Read Charc Value Failed %s(0x%08x)",
+ _bt_convert_error_to_string(error_code), error_code);
+ result = error_code;
+ goto done;
+ }
+ return;
+ }
+
+ if (otp_client_s->otp_last_modified_obj_path) {
+ error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_last_modified_obj_path);
+ if (error_code != BLUETOOTH_ERROR_NONE) {
+ BT_INFO("Read Charc Value Failed %s(0x%08x)",
+ _bt_convert_error_to_string(error_code), error_code);
+ result = error_code;
+ goto done;
+ }
+ return;
+ }
+
+ /* Reading Object ID characteristics makes sense if server
+ * supports multiple objects.
+ */
+ if (otp_client_s->multiple_obj_supp) {
+ metadata->id = 0x256;
+ otp_client_s->object_id = metadata->id;
+ otp_client_s->object_list = g_slist_append(otp_client_s->object_list, metadata);
+ goto done;
+ }
+
+ if (otp_client_s->otp_id_obj_path) {
+ error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_id_obj_path);
+ if (error_code != BLUETOOTH_ERROR_NONE) {
+ BT_INFO("Read Charc Value Failed %s(0x%08x)",
+ _bt_convert_error_to_string(error_code), error_code);
+ result = error_code;
+ goto done;
+ }
+ }
+ return;
+done:
+ _bt_otp_send_callback(result, NULL, otp_client_s->object_id, 0, otp_client_s);
+}
+
+static void __bt_otp_client_first_created_response(bt_otp_client_s *otp_client_s, char *value, int len)
+{
+ int error_code = BLUETOOTH_ERROR_NONE;
+ int result = BLUETOOTH_ERROR_NONE;
+ struct tm tm = {0};
+ uint16_t year = (uint16_t)(value[1] & 0xFF) << 8 |
+ (uint16_t)(value[0] & 0xFF);
+ tm.tm_year = year-1900;
+ tm.tm_mon = value[2] & 0xFF;
+ tm.tm_mon = tm.tm_mon-1;
+ tm.tm_mday = value[3] & 0xFF;
+ tm.tm_hour = value[4] & 0xFF;
+ tm.tm_min = value[5] & 0xFF;
+ tm.tm_sec = value[6] & 0xFF;
+ BT_INFO("Object First Created [%d]-[%d]-[%d]\t[%d][%d][%d]", tm.tm_mday,
+ tm.tm_mon, tm.tm_year, tm.tm_hour, tm.tm_min, tm.tm_sec);
+
+ if (otp_client_s->curr_op != BT_OTP_OBJECT_DISCOVERY)
+ return;
+
+ metadata->first_created = mktime(&tm);
+ if (otp_client_s->otp_last_modified_obj_path) {
+ error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_last_modified_obj_path);
+ if (error_code != BLUETOOTH_ERROR_NONE) {
+ BT_INFO("Read Charc Value Failed %s(0x%08x)",
+ _bt_convert_error_to_string(error_code), error_code);
+ result = error_code;
+ goto done;
+ }
+ return;
+ }
+
+ if (otp_client_s->multiple_obj_supp) {
+ metadata->id = 0x256;
+ otp_client_s->object_id = metadata->id;
+ otp_client_s->object_list = g_slist_append(otp_client_s->object_list, metadata);
+ goto done;
+ }
+
+ if (otp_client_s->otp_id_obj_path) {
+ error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_id_obj_path);
+ if (error_code != BLUETOOTH_ERROR_NONE) {
+ BT_INFO("Read Charc Value Failed %s(0x%08x)",
+ _bt_convert_error_to_string(error_code), error_code);
+ result = error_code;
+ goto done;
+ }
+ }
+ return;
+done:
+ _bt_otp_send_callback(result, NULL, otp_client_s->object_id, 0, otp_client_s);
+}
+
+static void __bt_otp_client_last_modified_response(bt_otp_client_s *otp_client_s, char *value, int len)
+{
+ int error_code = BLUETOOTH_ERROR_NONE;
+ int result = BLUETOOTH_ERROR_NONE;
+ struct tm tm = {0};
+ uint16_t year = (uint16_t)(value[1] & 0xFF) << 8 |
+ (uint16_t)(value[0] & 0xFF);
+ tm.tm_year = year-1900;
+ tm.tm_mon = value[2] & 0xFF;
+ tm.tm_mon = tm.tm_mon-1;
+ tm.tm_mday = value[3] & 0xFF;
+ tm.tm_hour = value[4] & 0xFF;
+ tm.tm_min = value[5] & 0xFF;
+ tm.tm_sec = value[6] & 0xFF;
+ BT_INFO("Object Last Modified [%d]-[%d]-[%d]\t[%d][%d][%d]", tm.tm_mday,
+ tm.tm_mon, tm.tm_year, tm.tm_hour, tm.tm_min, tm.tm_sec);
+
+ if (otp_client_s->curr_op != BT_OTP_OBJECT_DISCOVERY)
+ return;
+
+ metadata->last_modified = mktime(&tm);
+ if (otp_client_s->multiple_obj_supp) {
+ /* None of the optional characteristics supported, so finish object discovery */
+ metadata->id = 0x256;
+ otp_client_s->object_id = metadata->id;
+ otp_client_s->object_list = g_slist_append(otp_client_s->object_list, metadata);
+ _bt_otp_send_callback(result, NULL, otp_client_s->object_id, 0, otp_client_s);
+ return;
+ }
+
+ if (otp_client_s->otp_id_obj_path) {
+ error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_id_obj_path);
+ if (error_code != BLUETOOTH_ERROR_NONE) {
+ BT_INFO("Read Charc Value Failed %s(0x%08x)",
+ _bt_convert_error_to_string(error_code), error_code);
+ result = error_code;
+ _bt_otp_send_callback(result, NULL, otp_client_s->object_id, 0, otp_client_s);
+ }
+ }
+}
+
+static void __bt_otp_client_id_response(bt_otp_client_s *otp_client_s, char *value, int len)
+{
+ int error_code = BLUETOOTH_ERROR_NONE;
+ int result = BLUETOOTH_ERROR_NONE;
+ uint64_t id;
+ id = (uint64_t)(value[5] & 0xFF) << 48 |
+ (uint64_t)(value[4] & 0xFF) << 32 |
+ (uint64_t)(value[3] & 0xFF) << 24 |
+ (uint64_t)(value[2] & 0xFF) << 16 |
+ (uint64_t)(value[1] & 0xFF) << 8 |
+ (uint64_t)(value[0] & 0xFF);
+ BT_INFO("Object ID [%llu]", id);
+
+ /* TODO: Remove the previous stored object list */
+ if (otp_client_s->curr_op == BT_OTP_OBJECT_DISCOVERY) {
+ uint8_t write_value[7] = {0x00};
+
+ metadata->id = id;
+
+ otp_client_s->object_id = metadata->id;
+ otp_client_s->object_list = g_slist_append(otp_client_s->object_list, metadata);
+ write_value[0] = OLCP_NEXT;
+
+ error_code = bluetooth_otp_write_characteristics_value(otp_client_s->otp_olcp_control_point, write_value, 1);
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("Failed to write control point : %s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ result = error_code;
+ _bt_otp_send_callback(result, NULL, otp_client_s->object_id, 0, otp_client_s);
+ }
+ return;
+ }
+
+ if (otp_client_s->curr_op == BT_OTP_OBJECT_CREATE) {
+ metadata = g_malloc0(sizeof(object_metadata));
+ metadata->name = g_strdup(oacp_create_op->filename);
+ metadata->type = g_strdup(oacp_create_op->type_uuid);
+ metadata->curr_size = oacp_create_op->size;
+ metadata->alloc_size = oacp_create_op->size;
+ /* Dont hard code */
+ metadata->props = OBJECT_READ | OBJECT_WRITE;
+ metadata->first_created = oacp_create_op->first_created;
+ metadata->last_modified = oacp_create_op->first_created;
+ metadata->id = id;
+ otp_client_s->object_id = metadata->id;
+ otp_client_s->object_list = g_slist_append(otp_client_s->object_list, metadata);
+ _bt_otp_send_callback(result, NULL, otp_client_s->object_id, 0, otp_client_s);
+ }
+}
+
void _bt_otp_client_read_value_response(int result, char *char_path,
char *value, int len)
{
bt_otp_client_s *otp_client_s = NULL;
char remote_address[BT_ADDR_LENGTH];
- int error_code = BLUETOOTH_ERROR_NONE;
_bt_otp_get_remote_address(char_path, remote_address);
if (result != BLUETOOTH_ERROR_NONE) {
BT_INFO("Read failed for [%s]", char_path);
- goto done;
+ if (otp_client_s->curr_op == BT_OTP_OBJECT_DISCOVERY ||
+ otp_client_s->curr_op == BT_OTP_OBJECT_CREATE)
+ _bt_otp_send_callback(result, NULL, otp_client_s->object_id, 0, otp_client_s);
+ return;
}
if (!g_strcmp0(otp_client_s->otp_feature_obj_path, char_path)) {
- uint64_t feature = (uint64_t)(value[0] & 0xFF) << 56 |
- (uint64_t)(value[1] & 0xFF) << 48 |
- (uint64_t)(value[2] & 0xFF) << 40 |
- (uint64_t)(value[3] & 0xFF) << 32 |
- (uint64_t)(value[4] & 0xFF) << 24 |
- (uint64_t)(value[5] & 0xFF) << 16 |
- (uint64_t)(value[6] & 0xFF) << 8 |
- (uint64_t)(value[7] & 0xFF);
- otp_client_s->otp_feature = feature;
- BT_INFO("OTP Feature [%llu]", feature);
-
- if (BT_OTP_IS_OACP_SUPPORTED(otp_client_s->otp_feature)
- && !otp_client_s->oacp_cccd_enabled
- && otp_client_s->otp_oacp_control_point) {
-
- error_code = bluetooth_otp_enable_notification(otp_client_s->otp_oacp_control_point);
- if (error_code != BT_ERROR_NONE)
- BT_ERR("OACP Notification enable failed %s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
- }
+ __bt_otp_client_feature_response(otp_client_s, value, len);
+ return;
+ }
- if (BT_OTP_IS_OLCP_SUPPORTED(otp_client_s->otp_feature)
- && !otp_client_s->olcp_cccd_enabled
- && otp_client_s->otp_olcp_control_point) {
- error_code = bluetooth_otp_enable_notification(otp_client_s->otp_olcp_control_point);
- if (error_code != BT_ERROR_NONE)
- BT_ERR("OLCP Notification enable failed %s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
- }
+ if (!g_strcmp0(otp_client_s->otp_name_obj_path, char_path)) {
+ __bt_otp_client_name_response(otp_client_s, value, len);
+ return;
+ }
- if (!otp_client_s->obj_changed_cccd_enabed
- && otp_client_s->otp_obj_changed_obj_path) {
- error_code = bluetooth_otp_enable_notification(otp_client_s->otp_obj_changed_obj_path);
- if (error_code != BT_ERROR_NONE)
- BT_ERR("Object Changed Notification enable failed %s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
- }
- } else {
- if (!g_strcmp0(otp_client_s->otp_name_obj_path, char_path)) {
- char *name = NULL;
- name = g_strndup(value, len);
- BT_INFO("Object Name [%s]", name);
-
- if (otp_client_s->curr_op == BT_OTP_OBJECT_DISCOVERY) {
- metadata->name = g_strdup(name);
- error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_type_obj_path);
- if (error_code != BLUETOOTH_ERROR_NONE) {
- BT_INFO("Read Charc Value Failed %s(0x%08x)",
- _bt_convert_error_to_string(error_code), error_code);
- result = error_code;
- g_free(name);
- goto done;
- }
- }
- g_free(name);
- } else if (!g_strcmp0(otp_client_s->otp_type_obj_path, char_path)) {
- char *type = NULL;
- type = g_strndup(value, len);
- BT_INFO("Object Type [%s]", type);
-
- if (otp_client_s->curr_op == BT_OTP_OBJECT_DISCOVERY) {
- metadata->type = g_strdup(type);
- error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_size_obj_path);
- if (error_code != BLUETOOTH_ERROR_NONE) {
- BT_INFO("Read Charc Value Failed %s(0x%08x)",
- _bt_convert_error_to_string(error_code), error_code);
- result = error_code;
- g_free(type);
- goto done;
- }
- }
- g_free(type);
- } else if (!g_strcmp0(otp_client_s->otp_size_obj_path, char_path)) {
- uint32_t csize, asize;
- csize = (uint32_t)(value[3] & 0xFF) << 24 |
- (uint32_t)(value[2] & 0xFF) << 16 |
- (uint32_t)(value[1] & 0xFF) << 8 |
- (uint32_t)(value[0] & 0xFF);
-
- asize = (uint32_t)(value[7] & 0xFF) << 24 |
- (uint32_t)(value[6] & 0xFF) << 16 |
- (uint32_t)(value[5] & 0xFF) << 8 |
- (uint32_t)(value[4] & 0xFF);
-
- BT_INFO("Object Size curr[%u] alloc[%u]", csize, asize);
-
- if (otp_client_s->curr_op == BT_OTP_OBJECT_DISCOVERY) {
- metadata->curr_size = csize;
- metadata->alloc_size = asize;
- error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_props_obj_path);
- if (error_code != BLUETOOTH_ERROR_NONE) {
- BT_INFO("Read Charc Value Failed %s(0x%08x)",
- _bt_convert_error_to_string(error_code), error_code);
- result = error_code;
- goto done;
- }
- }
- } else if (!g_strcmp0(otp_client_s->otp_props_obj_path, char_path)) {
- uint32_t props;
- props = (uint32_t)(value[3] & 0xFF) << 24 |
- (uint32_t)(value[2] & 0xFF) << 16 |
- (uint32_t)(value[1] & 0xFF) << 8 |
- (uint32_t)(value[0] & 0xFF);
- BT_INFO("Object Properties [%u]", props);
-
- /* First-created & Last-modified are optional charcacteristics */
- if (otp_client_s->curr_op == BT_OTP_OBJECT_DISCOVERY) {
- metadata->props = props;
- if (otp_client_s->otp_first_created_obj_path) {
- error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_first_created_obj_path);
- if (error_code != BLUETOOTH_ERROR_NONE) {
- BT_INFO("Read Charc Value Failed %s(0x%08x)",
- _bt_convert_error_to_string(error_code), error_code);
- result = error_code;
- goto done;
- }
- } else if (otp_client_s->otp_last_modified_obj_path) {
- error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_last_modified_obj_path);
- if (error_code != BLUETOOTH_ERROR_NONE) {
- BT_INFO("Read Charc Value Failed %s(0x%08x)",
- _bt_convert_error_to_string(error_code), error_code);
- result = error_code;
- goto done;
- }
- } else {
- /* Reading Object ID characteristics makes sense if server
- * supports multiple objects.
- */
- if (otp_client_s->multiple_obj_supp) {
- metadata->id = 0x256;
- otp_client_s->object_id = metadata->id;
- otp_client_s->object_list = g_slist_append(otp_client_s->object_list, metadata);
- goto done;
- } else {
- if (otp_client_s->otp_id_obj_path) {
- error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_id_obj_path);
- if (error_code != BLUETOOTH_ERROR_NONE) {
- BT_INFO("Read Charc Value Failed %s(0x%08x)",
- _bt_convert_error_to_string(error_code), error_code);
- result = error_code;
- goto done;
- }
- }
- }
- }
- }
- } else if (!g_strcmp0(otp_client_s->otp_first_created_obj_path, char_path)) {
- struct tm tm = {0};
- uint16_t year = (uint16_t)(value[1] & 0xFF) << 8 |
- (uint16_t)(value[0] & 0xFF);
- tm.tm_year = year-1900;
- tm.tm_mon = value[2] & 0xFF;
- tm.tm_mon = tm.tm_mon-1;
- tm.tm_mday = value[3] & 0xFF;
- tm.tm_hour = value[4] & 0xFF;
- tm.tm_min = value[5] & 0xFF;
- tm.tm_sec = value[6] & 0xFF;
- BT_INFO("Object First Created [%d]-[%d]-[%d]\t[%d][%d][%d]", tm.tm_mday,
- tm.tm_mon, tm.tm_year, tm.tm_hour, tm.tm_min, tm.tm_sec);
-
- if (otp_client_s->curr_op == BT_OTP_OBJECT_DISCOVERY) {
- metadata->first_created = mktime(&tm);
- if (otp_client_s->otp_last_modified_obj_path) {
- error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_last_modified_obj_path);
- if (error_code != BLUETOOTH_ERROR_NONE) {
- BT_INFO("Read Charc Value Failed %s(0x%08x)",
- _bt_convert_error_to_string(error_code), error_code);
- result = error_code;
- goto done;
- }
- } else {
- if (otp_client_s->multiple_obj_supp) {
- metadata->id = 0x256;
- otp_client_s->object_id = metadata->id;
- otp_client_s->object_list = g_slist_append(otp_client_s->object_list, metadata);
- goto done;
- } else {
- if (otp_client_s->otp_id_obj_path) {
- error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_id_obj_path);
- if (error_code != BLUETOOTH_ERROR_NONE) {
- BT_INFO("Read Charc Value Failed %s(0x%08x)",
- _bt_convert_error_to_string(error_code), error_code);
- result = error_code;
- goto done;
- }
- }
- }
- }
- }
- } else if (!g_strcmp0(otp_client_s->otp_last_modified_obj_path, char_path)) {
- struct tm tm = {0};
- uint16_t year = (uint16_t)(value[1] & 0xFF) << 8 |
- (uint16_t)(value[0] & 0xFF);
- tm.tm_year = year-1900;
- tm.tm_mon = value[2] & 0xFF;
- tm.tm_mon = tm.tm_mon-1;
- tm.tm_mday = value[3] & 0xFF;
- tm.tm_hour = value[4] & 0xFF;
- tm.tm_min = value[5] & 0xFF;
- tm.tm_sec = value[6] & 0xFF;
- BT_INFO("Object Last Modified [%d]-[%d]-[%d]\t[%d][%d][%d]", tm.tm_mday,
- tm.tm_mon, tm.tm_year, tm.tm_hour, tm.tm_min, tm.tm_sec);
-
- if (otp_client_s->curr_op == BT_OTP_OBJECT_DISCOVERY) {
- metadata->last_modified = mktime(&tm);
- if (otp_client_s->multiple_obj_supp) {
- /* None of the optional characteristics supported, so finish object discovery */
- metadata->id = 0x256;
- otp_client_s->object_id = metadata->id;
- otp_client_s->object_list = g_slist_append(otp_client_s->object_list, metadata);
- goto done;
- } else {
- if (otp_client_s->otp_id_obj_path) {
- error_code = bluetooth_otp_read_characteristic_value(otp_client_s->otp_id_obj_path);
- if (error_code != BLUETOOTH_ERROR_NONE) {
- BT_INFO("Read Charc Value Failed %s(0x%08x)",
- _bt_convert_error_to_string(error_code), error_code);
- result = error_code;
- goto done;
- }
- }
- }
- }
- } else if (!g_strcmp0(otp_client_s->otp_id_obj_path, char_path)) {
- uint64_t id;
- id = (uint64_t)(value[5] & 0xFF) << 48 |
- (uint64_t)(value[4] & 0xFF) << 32 |
- (uint64_t)(value[3] & 0xFF) << 24 |
- (uint64_t)(value[2] & 0xFF) << 16 |
- (uint64_t)(value[1] & 0xFF) << 8 |
- (uint64_t)(value[0] & 0xFF);
- BT_INFO("Object ID [%llu]", id);
- /* TODO: Remove the previous stored object list */
- if (otp_client_s->curr_op == BT_OTP_OBJECT_DISCOVERY) {
- uint8_t write_value[7] = {0x00};
-
- metadata->id = id;
-
- otp_client_s->object_id = metadata->id;
- otp_client_s->object_list = g_slist_append(otp_client_s->object_list, metadata);
- write_value[0] = OLCP_NEXT;
-
- error_code = bluetooth_otp_write_characteristics_value(otp_client_s->otp_olcp_control_point, write_value, 1);
- if (error_code != BT_ERROR_NONE) {
- BT_ERR("Failed to write control point : %s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
- result = error_code;
- goto done;
- }
- } else if (otp_client_s->curr_op == BT_OTP_OBJECT_CREATE) {
- metadata = g_malloc0(sizeof(object_metadata));
- metadata->name = g_strdup(oacp_create_op->filename);
- metadata->type = g_strdup(oacp_create_op->type_uuid);
- metadata->curr_size = oacp_create_op->size;
- metadata->alloc_size = oacp_create_op->size;
- /* Dont hard code */
- metadata->props = OBJECT_READ | OBJECT_WRITE;
- metadata->first_created = oacp_create_op->first_created;
- metadata->last_modified = oacp_create_op->first_created;
- metadata->id = id;
- otp_client_s->object_id = metadata->id;
- otp_client_s->object_list = g_slist_append(otp_client_s->object_list, metadata);
- goto done;
- }
- }
+ if (!g_strcmp0(otp_client_s->otp_type_obj_path, char_path)) {
+ __bt_otp_client_type_response(otp_client_s, value, len);
+ return;
+ }
+
+ if (!g_strcmp0(otp_client_s->otp_size_obj_path, char_path)) {
+ __bt_otp_client_size_response(otp_client_s, value, len);
+ return;
+ }
+
+ if (!g_strcmp0(otp_client_s->otp_props_obj_path, char_path)) {
+ __bt_otp_client_props_response(otp_client_s, value, len);
+ return;
+ }
+
+ if (!g_strcmp0(otp_client_s->otp_first_created_obj_path, char_path)) {
+ __bt_otp_client_first_created_response(otp_client_s, value, len);
+ return;
+ }
+
+ if (!g_strcmp0(otp_client_s->otp_last_modified_obj_path, char_path)) {
+ __bt_otp_client_last_modified_response(otp_client_s, value, len);
+ return;
+ }
+
+ if (!g_strcmp0(otp_client_s->otp_id_obj_path, char_path)) {
+ __bt_otp_client_id_response(otp_client_s, value, len);
return;
-done:
- switch (otp_client_s->curr_op) {
- case BT_OTP_OBJECT_DISCOVERY:
- case BT_OTP_OBJECT_CREATE:
- _bt_otp_send_callback(result, NULL, otp_client_s->object_id, 0, otp_client_s);
- break;
- default:
- break;
- }
}
}