external/bluetooth/bluez
修訂 | 3be654144dfb099c42eee3af53c9f0c42bd17c9c (tree) |
---|---|
時間 | 2015-12-10 16:42:42 |
作者 | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
android: fix building errors on Android 6.0
Change libhal to match the new HAL headers.
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
@@ -783,6 +783,18 @@ static void gattc_batchscan_threshold_cb(int client_if) | ||
783 | 783 | } |
784 | 784 | |
785 | 785 | /* Track ADV VSE callback invoked when tracked device is found or lost */ |
786 | +#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0) | |
787 | +static void gattc_track_adv_event_cb(btgatt_track_adv_info_t *p_track_adv_info) | |
788 | +{ | |
789 | + char buf[MAX_ADDR_STR_LEN]; | |
790 | + | |
791 | + haltest_info("%s, client_if=%d, filt_index=%d, addr_type=%d, bda=%s" | |
792 | + ", adv_state=%d", __func__, p_track_adv_info->client_if, | |
793 | + p_track_adv_info->filt_index, p_track_adv_info->addr_type, | |
794 | + bt_bdaddr_t2str(&p_track_adv_info->bd_addr, buf), | |
795 | + p_track_adv_info->advertiser_state); | |
796 | +} | |
797 | +#else | |
786 | 798 | static void gattc_track_adv_event_cb(int client_if, int filt_index, |
787 | 799 | int addr_type, bt_bdaddr_t* bda, |
788 | 800 | int adv_state) |
@@ -794,6 +806,7 @@ static void gattc_track_adv_event_cb(int client_if, int filt_index, | ||
794 | 806 | addr_type, bt_bdaddr_t2str(bda, buf), adv_state); |
795 | 807 | } |
796 | 808 | #endif |
809 | +#endif | |
797 | 810 | |
798 | 811 | static const btgatt_client_callbacks_t btgatt_client_callbacks = { |
799 | 812 | .register_client_cb = gattc_register_client_cb, |
@@ -1677,6 +1690,25 @@ static void scan_filter_param_setup_c(int argc, const char **argv, | ||
1677 | 1690 | |
1678 | 1691 | static void scan_filter_param_setup_p(int argc, const char **argv) |
1679 | 1692 | { |
1693 | +#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0) | |
1694 | + btgatt_filt_param_setup_t filt_param; | |
1695 | + | |
1696 | + RETURN_IF_NULL(if_gatt); | |
1697 | + VERIFY_CLIENT_IF(2, filt_param.client_if); | |
1698 | + VERIFY_ACTION(3, filt_param.action); | |
1699 | + VERIFY_FILT_INDEX(4, filt_param.filt_index); | |
1700 | + VERIFY_FEAT_SELN(5, filt_param.feat_seln); | |
1701 | + VERIFY_LIST_LOGIC_TYPE(6, filt_param.list_logic_type); | |
1702 | + VERIFY_FILT_LOGIC_TYPE(7, filt_param.filt_logic_type); | |
1703 | + VERIFY_RSSI_HI_THR(8, filt_param.rssi_high_thres); | |
1704 | + VERIFY_RSSI_LOW_THR(9, filt_param.rssi_low_thres); | |
1705 | + VERIFY_DELY_MODE(10, filt_param.dely_mode); | |
1706 | + VERIFY_FND_TIME(11, filt_param.found_timeout); | |
1707 | + VERIFY_LOST_TIME(12, filt_param.lost_timeout); | |
1708 | + VERIFY_FND_TIME_CNT(13, filt_param.found_timeout_cnt); | |
1709 | + | |
1710 | + EXEC(if_gatt->client->scan_filter_param_setup, filt_param); | |
1711 | +#else | |
1680 | 1712 | int client_if; |
1681 | 1713 | int action; |
1682 | 1714 | int filt_index; |
@@ -1704,6 +1736,7 @@ static void scan_filter_param_setup_p(int argc, const char **argv) | ||
1704 | 1736 | filt_index, feat_seln, list_logic_type, filt_logic_type, |
1705 | 1737 | rssi_high_thres, rssi_low_thres, dely_mode, found_timeout, |
1706 | 1738 | lost_timeout, found_timeout_cnt); |
1739 | +#endif | |
1707 | 1740 | } |
1708 | 1741 | |
1709 | 1742 | /* scan filter add remove */ |
@@ -1916,6 +1949,18 @@ static void conn_parameter_update_p(int argc, const char **argv) | ||
1916 | 1949 | /* set scan parameters */ |
1917 | 1950 | static void set_scan_parameters_p(int argc, const char **argv) |
1918 | 1951 | { |
1952 | +#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0) | |
1953 | + int client_if; | |
1954 | + int scan_interval; | |
1955 | + int scan_window; | |
1956 | + | |
1957 | + RETURN_IF_NULL(if_gatt); | |
1958 | + VERIFY_CLIENT_IF(2, client_if); | |
1959 | + VERIFY_SCAN_INTERVAL(3, scan_interval); | |
1960 | + VERIFY_SCAN_WINDOW(4, scan_window); | |
1961 | + | |
1962 | + EXEC(if_gatt->client->set_scan_parameters, client_if, scan_interval, scan_window); | |
1963 | +#else | |
1919 | 1964 | int scan_interval; |
1920 | 1965 | int scan_window; |
1921 | 1966 |
@@ -1924,6 +1969,7 @@ static void set_scan_parameters_p(int argc, const char **argv) | ||
1924 | 1969 | VERIFY_SCAN_WINDOW(3, scan_window); |
1925 | 1970 | |
1926 | 1971 | EXEC(if_gatt->client->set_scan_parameters, scan_interval, scan_window); |
1972 | +#endif | |
1927 | 1973 | } |
1928 | 1974 | |
1929 | 1975 | /* enable multi advertising */ |
@@ -249,7 +249,11 @@ static void handle_pin_request(void *buf, uint16_t len, int fd) | ||
249 | 249 | DBG(""); |
250 | 250 | |
251 | 251 | if (bt_hal_cbacks->pin_request_cb) |
252 | +#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0) | |
253 | + bt_hal_cbacks->pin_request_cb(addr, name, ev->class_of_dev, false); | |
254 | +#else | |
252 | 255 | bt_hal_cbacks->pin_request_cb(addr, name, ev->class_of_dev); |
256 | +#endif | |
253 | 257 | } |
254 | 258 | |
255 | 259 | static void handle_ssp_request(void *buf, uint16_t len, int fd) |
@@ -610,9 +610,21 @@ static void handle_batchscan_threshold(void *buf, uint16_t len, int fd) | ||
610 | 610 | |
611 | 611 | static void handle_track_adv(void *buf, uint16_t len, int fd) |
612 | 612 | { |
613 | -#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0) | |
614 | 613 | struct hal_ev_gatt_client_track_adv *ev = buf; |
615 | 614 | |
615 | +#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0) | |
616 | + if (cbs->client->track_adv_event_cb) { | |
617 | + btgatt_track_adv_info_t info_t = { | |
618 | + .client_if = ev->client_if, | |
619 | + .filt_index = ev->filetr_index, | |
620 | + .advertiser_state = ev->state, | |
621 | + .addr_type = ev->address_type, | |
622 | + .bd_addr = *(bt_bdaddr_t *) ev->address, | |
623 | + }; | |
624 | + | |
625 | + cbs->client->track_adv_event_cb(&info_t); | |
626 | + } | |
627 | +#elif ANDROID_VERSION >= PLATFORM_VER(5, 0, 0) | |
616 | 628 | if (cbs->client->track_adv_event_cb) |
617 | 629 | cbs->client->track_adv_event_cb(ev->client_if, ev->filetr_index, |
618 | 630 | ev->address_type, |
@@ -1341,6 +1353,20 @@ static bt_status_t test_command(int command, btgatt_test_params_t *params) | ||
1341 | 1353 | } |
1342 | 1354 | |
1343 | 1355 | #if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0) |
1356 | +#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0) | |
1357 | +static bt_status_t scan_filter_param_setup(btgatt_filt_param_setup_t filt_param) | |
1358 | +{ | |
1359 | + struct hal_cmd_gatt_client_scan_filter_setup *cmd; | |
1360 | + | |
1361 | + if (!interface_ready()) | |
1362 | + return BT_STATUS_NOT_READY; | |
1363 | + | |
1364 | + cmd = (struct hal_cmd_gatt_client_scan_filter_setup *)&filt_param; | |
1365 | + return hal_ipc_cmd(HAL_SERVICE_ID_GATT, | |
1366 | + HAL_OP_GATT_CLIENT_SCAN_FILTER_SETUP, | |
1367 | + sizeof(*cmd), cmd, NULL, NULL, NULL); | |
1368 | +} | |
1369 | +#else | |
1344 | 1370 | static bt_status_t scan_filter_param_setup(int client_if, int action, |
1345 | 1371 | int filt_index, int feat_seln, |
1346 | 1372 | int list_logic_type, |
@@ -1374,6 +1400,7 @@ static bt_status_t scan_filter_param_setup(int client_if, int action, | ||
1374 | 1400 | HAL_OP_GATT_CLIENT_SCAN_FILTER_SETUP, |
1375 | 1401 | sizeof(cmd), &cmd, NULL, NULL, NULL); |
1376 | 1402 | } |
1403 | +#endif | |
1377 | 1404 | |
1378 | 1405 | static bt_status_t scan_filter_add_remove(int client_if, int action, |
1379 | 1406 | int filt_type, int filt_index, |
@@ -1491,7 +1518,12 @@ static bt_status_t conn_parameter_update(const bt_bdaddr_t *bd_addr, | ||
1491 | 1518 | sizeof(cmd), &cmd, NULL, NULL, NULL); |
1492 | 1519 | } |
1493 | 1520 | |
1521 | +#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0) | |
1522 | +static bt_status_t set_scan_parameters(int client_if, int scan_interval, | |
1523 | + int scan_window) | |
1524 | +#else | |
1494 | 1525 | static bt_status_t set_scan_parameters(int scan_interval, int scan_window) |
1526 | +#endif | |
1495 | 1527 | { |
1496 | 1528 | struct hal_cmd_gatt_client_set_scan_param cmd; |
1497 | 1529 |
@@ -314,8 +314,12 @@ static void local_le_feat2string(char *str, const bt_local_le_features_t *f) | ||
314 | 314 | str += sprintf(str, "Num of offloaded scan filters: %u,\n", |
315 | 315 | f->max_adv_filter_supported); |
316 | 316 | |
317 | +#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0) | |
318 | + scan_num = f->scan_result_storage_size; | |
319 | +#else | |
317 | 320 | scan_num = (f->scan_result_storage_size_hibyte << 8) + |
318 | 321 | f->scan_result_storage_size_lobyte; |
322 | +#endif | |
319 | 323 | |
320 | 324 | str += sprintf(str, "Num of offloaded scan results: %u,\n", scan_num); |
321 | 325 |