From a1347393d099989e3b5d9dc9db25007444d6fb86 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Thu, 10 Sep 2020 11:11:46 +0900 Subject: [PATCH] Fix le advertising service data parsing logic Change-Id: I02a964819ebf1e51a39f9f78cf55c30fda5bc700 Signed-off-by: Wootak Jung --- src/bluetooth-adapter.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bluetooth-adapter.c b/src/bluetooth-adapter.c index e445a89..d4c22e6 100644 --- a/src/bluetooth-adapter.c +++ b/src/bluetooth-adapter.c @@ -2256,7 +2256,6 @@ static int __bt_find_uuid_in_service_data(bt_advertiser_h advertiser, char *adv_data = NULL; int adv_len = 0; bt_advertiser_s *__adv = (bt_advertiser_s *)advertiser; - bt_adapter_le_advertising_data_type_e data_type = BT_ADAPTER_LE_ADVERTISING_DATA_SERVICE_DATA; if (pkt_type == BT_ADAPTER_LE_PACKET_ADVERTISING) { @@ -2265,8 +2264,10 @@ static int __bt_find_uuid_in_service_data(bt_advertiser_h advertiser, } else if (pkt_type == BT_ADAPTER_LE_PACKET_SCAN_RESPONSE) { adv_data = __adv->scan_rsp_data; adv_len = __adv->scan_rsp_data_len; - } else + } else { + BT_ERR("Invalid Pakcet Type"); return BT_ERROR_INVALID_PARAMETER; + } if (!adv_data) { BT_INFO("Currently there is no advertisement data"); @@ -2278,7 +2279,7 @@ static int __bt_find_uuid_in_service_data(bt_advertiser_h advertiser, len = adv_data[i]; type = adv_data[i + 1]; - if (type == data_type) { + if (type == BT_ADAPTER_LE_ADVERTISING_DATA_SERVICE_DATA) { if (!memcmp((adv_data + i + 2), uuid, 2)) { BT_INFO("uuid matched"); *exist = true; @@ -2286,7 +2287,7 @@ static int __bt_find_uuid_in_service_data(bt_advertiser_h advertiser, } } - i = len + 1; + i += (len + 1); } *exist = false; -- 2.34.1