Lines Matching refs:device

178     auto device = FindDeviceByAddress(address);  in AssignCsisGroup()  local
179 if (device == nullptr) { in AssignCsisGroup()
182 device = FindDeviceByAddress(address); in AssignCsisGroup()
185 if (!csis_group->IsDeviceInTheGroup(device)) csis_group->AddDevice(device); in AssignCsisGroup()
211 auto device = FindDeviceByAddress(address); in OnGroupMemberRemovedCb() local
212 if (device) RemoveCsisDevice(device, group_id); in OnGroupMemberRemovedCb()
217 auto device = FindDeviceByAddress(address); in OnGroupAddFromStorageCb() local
218 if (device == nullptr) return; in OnGroupAddFromStorageCb()
226 if (!csis_group->IsDeviceInTheGroup(device)) { in OnGroupAddFromStorageCb()
237 auto csis_instance = device->GetCsisInstanceByGroupId(group_id); in OnGroupAddFromStorageCb()
242 callbacks_->OnDeviceAvailable(device->addr, csis_group->GetGroupId(), in OnGroupAddFromStorageCb()
249 auto device = FindDeviceByAddress(address); in Connect() local
250 if (device == nullptr) { in Connect()
258 device->connecting_actively = true; in Connect()
267 auto device = FindDeviceByAddress(addr); in Disconnect() local
268 if (device == nullptr) { in Disconnect()
275 if (device->IsConnected()) { in Disconnect()
276 BTA_GATTC_Close(device->conn_id); in Disconnect()
279 DoDisconnectCleanUp(device); in Disconnect()
287 auto device = FindDeviceByAddress(addr); in RemoveDevice() local
288 if (device == nullptr) { in RemoveDevice()
295 if (device->GetNumberOfCsisInstances() == 0) { in RemoveDevice()
296 RemoveCsisDevice(device); in RemoveDevice()
302 auto device = FindDeviceByAddress(addr); in GetGroupId() local
303 if (device == nullptr) return bluetooth::groups::kGroupUnknown; in GetGroupId()
340 auto device = FindDeviceByConnId(conn_id); in OnGattCsisWriteLockRsp() local
341 if (device == nullptr) { in OnGattCsisWriteLockRsp()
355 log::debug("Device {}, target lock: {}, status: 0x{:02x}", device->addr, in OnGattCsisWriteLockRsp()
371 HandleCsisLockProcedureError(csis_group, device); in OnGattCsisWriteLockRsp()
374 log::info("Database out of sync for {}", device->addr); in OnGattCsisWriteLockRsp()
375 ClearDeviceInformationAndStartSearch(device); in OnGattCsisWriteLockRsp()
381 auto csis_instance = device->GetCsisInstanceByGroupId(group_id); in OnGattCsisWriteLockRsp()
403 next_dev = csis_group->GetNextDevice(device); in OnGattCsisWriteLockRsp()
426 void SetLock(std::shared_ptr<CsisDevice>& device, in SetLock() argument
433 device->addr, csis_instance->GetRank(), device->conn_id, in SetLock()
437 device->conn_id, csis_instance->svc_data.lock_handle.val_hdl, value, in SetLock()
572 auto device = FindDeviceByAddress(addr); in SerializeSets() local
573 if (device == nullptr) { in SerializeSets()
578 if (device->GetNumberOfCsisInstances() == 0) { in SerializeSets()
583 log::debug(": device= {}", device->addr); in SerializeSets()
585 auto num_sets = device->GetNumberOfCsisInstances(); in SerializeSets()
597 device->ForEachCsisInstance( in SerializeSets()
681 auto device = FindDeviceByAddress(addr); in AddFromStorage() local
682 if (device == nullptr) { in AddFromStorage()
683 device = std::make_shared<CsisDevice>(addr, false); in AddFromStorage()
684 devices_.push_back(device); in AddFromStorage()
688 if (!csis_group->IsDeviceInTheGroup(device)) continue; in AddFromStorage()
697 callbacks_->OnDeviceAvailable(device->addr, group_id, in AddFromStorage()
711 for (auto& device : devices_) { in CleanUp() local
712 if (device->IsConnected()) BTA_GATTC_Close(device->conn_id); in CleanUp()
713 DoDisconnectCleanUp(device); in CleanUp()
739 for (auto& device : devices_) { in Dump() local
740 if (!g->IsDeviceInTheGroup(device)) { in Dump()
741 if (device->GetExpectedGroupIdMember() == g->GetGroupId()) { in Dump()
743 << ADDRESS_TO_LOGGABLE_STR(device->addr) << "\n"; in Dump()
748 stream << " == addr: " << ADDRESS_TO_LOGGABLE_STR(device->addr) in Dump()
753 auto instance = device->GetCsisInstanceByGroupId(g->GetGroupId()); in Dump()
762 if (!device->IsConnected()) { in Dump()
766 << std::to_string(device->conn_id) << "\n"; in Dump()
783 void RemoveCsisDevice(std::shared_ptr<CsisDevice>& device) { in RemoveCsisDevice() argument
785 CsisDevice::MatchAddress(device->addr)); in RemoveCsisDevice()
789 void RemoveCsisDevice(std::shared_ptr<CsisDevice>& device, int group_id) { in RemoveCsisDevice() argument
792 CsisDevice::MatchAddress(device->addr)); in RemoveCsisDevice()
804 csis_group->RemoveDevice(device->addr); in RemoveCsisDevice()
824 device->RemoveCsisInstance(group_id); in RemoveCsisDevice()
827 if (device->GetNumberOfCsisInstances() == 0) { in RemoveCsisDevice()
860 void OnEncrypted(std::shared_ptr<CsisDevice>& device) { in OnEncrypted() argument
861 log::debug("{}", device->addr); in OnEncrypted()
863 if (device->is_gatt_service_valid) { in OnEncrypted()
864 NotifyCsisDeviceValidAndStoreIfNeeded(device); in OnEncrypted()
866 BTA_GATTC_ServiceSearchRequest(device->conn_id, kCsisServiceUuid); in OnEncrypted()
871 std::shared_ptr<CsisDevice>& device) { in NotifyCsisDeviceValidAndStoreIfNeeded() argument
879 if (!csis_group->IsDeviceInTheGroup(device)) continue; in NotifyCsisDeviceValidAndStoreIfNeeded()
882 auto csis_instance = device->GetCsisInstanceByGroupId(group_id); in NotifyCsisDeviceValidAndStoreIfNeeded()
897 device->addr, group_id, csis_group->GetDesiredSize(), in NotifyCsisDeviceValidAndStoreIfNeeded()
907 callbacks_->OnConnectionState(device->addr, ConnectionState::CONNECTED); in NotifyCsisDeviceValidAndStoreIfNeeded()
934 auto device = FindDeviceByConnId(conn_id); in OnGattWriteCcc() local
935 if (device == nullptr) { in OnGattWriteCcc()
942 log::info("Database out of sync for {}", device->addr); in OnGattWriteCcc()
943 ClearDeviceInformationAndStartSearch(device); in OnGattWriteCcc()
949 device->addr); in OnGattWriteCcc()
956 handle, device->addr, status); in OnGattWriteCcc()
958 auto val_handle = device->FindValueHandleByCccHandle(handle); in OnGattWriteCcc()
961 device->addr); in OnGattWriteCcc()
966 BTA_GATTC_DeregisterForNotifications(gatt_if_, device->addr, val_handle); in OnGattWriteCcc()
972 auto device = FindDeviceByConnId(conn_id); in OnCsisNotification() local
973 if (device == nullptr) { in OnCsisNotification()
978 auto csis_instance = device->GetCsisInstanceByOwningHandle(handle); in OnCsisNotification()
988 OnCsisLockNotifications(device, csis_instance, len, value); in OnCsisNotification()
1020 void OnCsisLockNotifications(std::shared_ptr<CsisDevice>& device, in OnCsisLockNotifications() argument
1077 auto device = FindDeviceByConnId(conn_id); in OnCsisSizeValueUpdate() local
1079 if (device == nullptr) { in OnCsisSizeValueUpdate()
1084 log::debug("{}, status: 0x{:02x}", device->addr, status); in OnCsisSizeValueUpdate()
1088 log::info("Database out of sync for {}", device->addr); in OnCsisSizeValueUpdate()
1089 ClearDeviceInformationAndStartSearch(device); in OnCsisSizeValueUpdate()
1092 BTA_GATTC_Close(device->conn_id); in OnCsisSizeValueUpdate()
1100 BTA_GATTC_Close(device->conn_id); in OnCsisSizeValueUpdate()
1104 auto csis_instance = device->GetCsisInstanceByOwningHandle(handle); in OnCsisSizeValueUpdate()
1107 BTA_GATTC_Close(device->conn_id); in OnCsisSizeValueUpdate()
1119 if (notify_valid_services) NotifyCsisDeviceValidAndStoreIfNeeded(device); in OnCsisSizeValueUpdate()
1125 auto device = FindDeviceByConnId(conn_id); in OnCsisLockReadRsp() local
1126 if (device == nullptr) { in OnCsisLockReadRsp()
1131 log::info("{}, status 0x{:02x}", device->addr, status); in OnCsisLockReadRsp()
1135 log::info("Database out of sync for {}", device->addr); in OnCsisLockReadRsp()
1136 ClearDeviceInformationAndStartSearch(device); in OnCsisLockReadRsp()
1139 BTA_GATTC_Close(device->conn_id); in OnCsisLockReadRsp()
1147 BTA_GATTC_Close(device->conn_id); in OnCsisLockReadRsp()
1151 auto csis_instance = device->GetCsisInstanceByOwningHandle(handle); in OnCsisLockReadRsp()
1154 BTA_GATTC_Close(device->conn_id); in OnCsisLockReadRsp()
1159 if (notify_valid_services) NotifyCsisDeviceValidAndStoreIfNeeded(device); in OnCsisLockReadRsp()
1165 auto device = FindDeviceByConnId(conn_id); in OnCsisRankReadRsp() local
1166 if (device == nullptr) { in OnCsisRankReadRsp()
1171 log::debug("{}, status: 0x{:02x}, rank: {}", device->addr, status, in OnCsisRankReadRsp()
1175 log::info("Database out of sync for {}", device->addr); in OnCsisRankReadRsp()
1176 ClearDeviceInformationAndStartSearch(device); in OnCsisRankReadRsp()
1179 BTA_GATTC_Close(device->conn_id); in OnCsisRankReadRsp()
1187 BTA_GATTC_Close(device->conn_id); in OnCsisRankReadRsp()
1191 auto csis_instance = device->GetCsisInstanceByOwningHandle(handle); in OnCsisRankReadRsp()
1194 BTA_GATTC_Close(device->conn_id); in OnCsisRankReadRsp()
1207 if (notify_valid_services) NotifyCsisDeviceValidAndStoreIfNeeded(device); in OnCsisRankReadRsp()
1320 devices_.begin(), devices_.end(), [group_id](const auto& device) { in GetNumOfKnownExpectedDevicesWaitingForBonding() argument
1321 return device->GetExpectedGroupIdMember() == group_id && in GetNumOfKnownExpectedDevicesWaitingForBonding()
1322 !device->GetCsisInstanceByGroupId(group_id); in GetNumOfKnownExpectedDevicesWaitingForBonding()
1328 auto device = FindDeviceByAddress(address); in CacheAndAdvertiseExpectedMember() local
1329 if (device == nullptr) { in CacheAndAdvertiseExpectedMember()
1330 device = std::make_shared<CsisDevice>(address, false); in CacheAndAdvertiseExpectedMember()
1331 devices_.push_back(device); in CacheAndAdvertiseExpectedMember()
1338 device.get()->SetExpectedGroupIdMember(group_id); in CacheAndAdvertiseExpectedMember()
1340 device.get()->GetExpectedGroupIdMember()); in CacheAndAdvertiseExpectedMember()
1458 auto device = FindDeviceByAddress(address); in CheckForGroupInInqDb() local
1459 if (device && csis_group->IsDeviceInTheGroup(device)) { in CheckForGroupInInqDb()
1566 auto device = FindDeviceByConnId(conn_id); in OnCsisSirkValueUpdate() local
1567 if (device == nullptr) { in OnCsisSirkValueUpdate()
1572 log::debug("{}, status: 0x{:02x}", device->addr, status); in OnCsisSirkValueUpdate()
1580 log::info("Database out of sync for {}", device->addr); in OnCsisSirkValueUpdate()
1581 ClearDeviceInformationAndStartSearch(device); in OnCsisSirkValueUpdate()
1584 BTA_GATTC_Close(device->conn_id); in OnCsisSirkValueUpdate()
1592 BTA_GATTC_Close(device->conn_id); in OnCsisSirkValueUpdate()
1596 auto csis_instance = device->GetCsisInstanceByOwningHandle(handle); in OnCsisSirkValueUpdate()
1599 BTA_GATTC_Close(device->conn_id); in OnCsisSirkValueUpdate()
1610 device->conn_id); in OnCsisSirkValueUpdate()
1611 BTA_GATTC_Close(device->conn_id); in OnCsisSirkValueUpdate()
1621 sdf(device->addr, received_sirk, sirk); in OnCsisSirkValueUpdate()
1648 dev_groups_->AddDevice(device->addr, csis_instance->GetUuid()); in OnCsisSirkValueUpdate()
1653 dev_groups_->AddDevice(device->addr, csis_instance->GetUuid(), in OnCsisSirkValueUpdate()
1658 csis_group->AddDevice(device); in OnCsisSirkValueUpdate()
1664 device->is_gatt_service_valid = true; in OnCsisSirkValueUpdate()
1665 btif_storage_update_csis_info(device->addr); in OnCsisSirkValueUpdate()
1667 if (notify_valid_services) NotifyCsisDeviceValidAndStoreIfNeeded(device); in OnCsisSirkValueUpdate()
1671 device->addr); in OnCsisSirkValueUpdate()
1697 void DeregisterNotifications(std::shared_ptr<CsisDevice> device) { in DeregisterNotifications() argument
1698 device->ForEachCsisInstance( in DeregisterNotifications()
1700 DisableGattNotification(device->conn_id, device->addr, in DeregisterNotifications()
1702 DisableGattNotification(device->conn_id, device->addr, in DeregisterNotifications()
1704 DisableGattNotification(device->conn_id, device->addr, in DeregisterNotifications()
1709 void DoDisconnectCleanUp(std::shared_ptr<CsisDevice> device) { in DoDisconnectCleanUp() argument
1710 log::info("{}", device->addr); in DoDisconnectCleanUp()
1712 DeregisterNotifications(device); in DoDisconnectCleanUp()
1714 if (device->IsConnected()) { in DoDisconnectCleanUp()
1715 BtaGattQueue::Clean(device->conn_id); in DoDisconnectCleanUp()
1716 device->conn_id = GATT_INVALID_CONN_ID; in DoDisconnectCleanUp()
1720 bool OnCsisServiceFound(std::shared_ptr<CsisDevice> device, in OnCsisServiceFound() argument
1731 int group_id = dev_groups_->GetGroupId(device->addr, context_uuid); in OnCsisServiceFound()
1735 device->SetCsisInstance(csis_inst->svc_data.start_handle, csis_inst); in OnCsisServiceFound()
1742 FindCccHandle(device->conn_id, charac.value_handle); in OnCsisServiceFound()
1745 device->RemoveCsisInstance(group_id); in OnCsisServiceFound()
1751 SubscribeForNotifications(device->conn_id, device->addr, in OnCsisServiceFound()
1758 csis_inst->svc_data.lock_handle.ccc_hdl, device->addr); in OnCsisServiceFound()
1763 csis_inst->svc_data.rank_handle, device->addr); in OnCsisServiceFound()
1767 FindCccHandle(device->conn_id, charac.value_handle); in OnCsisServiceFound()
1772 SubscribeForNotifications(device->conn_id, device->addr, in OnCsisServiceFound()
1779 csis_inst->svc_data.sirk_handle.ccc_hdl, device->addr); in OnCsisServiceFound()
1783 FindCccHandle(device->conn_id, charac.value_handle); in OnCsisServiceFound()
1788 SubscribeForNotifications(device->conn_id, device->addr, in OnCsisServiceFound()
1795 csis_inst->svc_data.size_handle.ccc_hdl, device->addr); in OnCsisServiceFound()
1805 device->RemoveCsisInstance(group_id); in OnCsisServiceFound()
1831 device->conn_id, csis_inst->svc_data.sirk_handle.val_hdl, in OnCsisServiceFound()
1843 device->conn_id, csis_inst->svc_data.lock_handle.val_hdl, in OnCsisServiceFound()
1856 device->conn_id, csis_inst->svc_data.size_handle.val_hdl, in OnCsisServiceFound()
1869 device->conn_id, csis_inst->svc_data.rank_handle, in OnCsisServiceFound()
1946 auto device = FindDeviceByAddress(evt.remote_bda); in OnGattConnected() local
1947 if (device == nullptr) { in OnGattConnected()
1955 if (device->connecting_actively) in OnGattConnected()
1958 DoDisconnectCleanUp(device); in OnGattConnected()
1962 device->connecting_actively = false; in OnGattConnected()
1963 device->conn_id = evt.conn_id; in OnGattConnected()
1966 if (BTM_SecIsSecurityPending(device->addr)) { in OnGattConnected()
1973 if (BTM_IsEncrypted(device->addr, BT_TRANSPORT_LE)) { in OnGattConnected()
1975 OnEncrypted(device); in OnGattConnected()
1979 int result = BTM_SetEncryption(device->addr, BT_TRANSPORT_LE, nullptr, in OnGattConnected()
1983 device->addr, result); in OnGattConnected()
1986 log::error("Link key unknown for {}, disconnect profile", device->addr); in OnGattConnected()
1987 BTA_GATTC_Close(device->conn_id); in OnGattConnected()
1992 auto device = FindDeviceByAddress(evt.remote_bda); in OnGattDisconnected() local
1993 if (device == nullptr) { in OnGattDisconnected()
1999 log::debug("device={}", device->addr); in OnGattDisconnected()
2008 device->ForEachCsisInstance( in OnGattDisconnected()
2015 csis_group, device, in OnGattDisconnected()
2021 DoDisconnectCleanUp(device); in OnGattDisconnected()
2025 auto device = FindDeviceByConnId(evt.conn_id); in OnGattServiceSearchComplete() local
2027 if (device == nullptr) { in OnGattServiceSearchComplete()
2033 if (!BTM_IsEncrypted(device->addr, BT_TRANSPORT_LE)) { in OnGattServiceSearchComplete()
2040 if (!device->is_gatt_service_valid) { in OnGattServiceSearchComplete()
2043 BTA_GATTC_Close(device->conn_id); in OnGattServiceSearchComplete()
2044 DoDisconnectCleanUp(device); in OnGattServiceSearchComplete()
2051 BTA_GATTC_GetServices(device->conn_id); in OnGattServiceSearchComplete()
2065 BTA_GATTC_Close(device->conn_id); in OnGattServiceSearchComplete()
2066 RemoveCsisDevice(device, bluetooth::groups::kGroupUnknown); in OnGattServiceSearchComplete()
2077 device->conn_id, included_srvc.start_handle); in OnGattServiceSearchComplete()
2083 instance->OnCsisServiceFound(device, csis_svrc, svrc.uuid, in OnGattServiceSearchComplete()
2097 auto csis_svrc = BTA_GATTC_GetOwningService(device->conn_id, in OnGattServiceSearchComplete()
2100 device, csis_svrc, bluetooth::groups::kGenericContextUuid, true); in OnGattServiceSearchComplete()
2108 NotifyCsisDeviceValidAndStoreIfNeeded(device); in OnGattServiceSearchComplete()
2125 auto device = FindDeviceByAddress(address); in OnLeEncryptionComplete() local
2126 if (device == nullptr) { in OnLeEncryptionComplete()
2134 BTA_GATTC_Close(device->conn_id); in OnLeEncryptionComplete()
2138 if (device->is_gatt_service_valid) { in OnLeEncryptionComplete()
2139 instance->OnEncrypted(device); in OnLeEncryptionComplete()
2141 BTA_GATTC_ServiceSearchRequest(device->conn_id, kCsisServiceUuid); in OnLeEncryptionComplete()
2146 std::shared_ptr<CsisDevice> device) { in ClearDeviceInformationAndStartSearch() argument
2147 log::info("{}", device->addr); in ClearDeviceInformationAndStartSearch()
2148 if (device->is_gatt_service_valid == false) { in ClearDeviceInformationAndStartSearch()
2154 BtaGattQueue::Clean(device->conn_id); in ClearDeviceInformationAndStartSearch()
2155 DeregisterNotifications(device); in ClearDeviceInformationAndStartSearch()
2156 device->ClearSvcData(); in ClearDeviceInformationAndStartSearch()
2157 BTA_GATTC_ServiceSearchRequest(device->conn_id, kCsisServiceUuid); in ClearDeviceInformationAndStartSearch()
2161 auto device = FindDeviceByAddress(address); in OnGattServiceChangeEvent() local
2162 if (!device) { in OnGattServiceChangeEvent()
2168 ClearDeviceInformationAndStartSearch(device); in OnGattServiceChangeEvent()
2172 auto device = FindDeviceByAddress(address); in OnGattServiceDiscoveryDoneEvent() local
2173 if (!device) { in OnGattServiceDiscoveryDoneEvent()
2180 if (!device->is_gatt_service_valid) in OnGattServiceDiscoveryDoneEvent()
2181 BTA_GATTC_ServiceSearchRequest(device->conn_id, kCsisServiceUuid); in OnGattServiceDiscoveryDoneEvent()
2245 auto device = FindDeviceByAddress(address); in SirkValueReadCompleteDuringPairing() local
2246 if (device == nullptr) { in SirkValueReadCompleteDuringPairing()
2252 auto group_id_to_join = device->GetExpectedGroupIdMember(); in SirkValueReadCompleteDuringPairing()
2253 device->SetPairingSirkReadFlag(false); in SirkValueReadCompleteDuringPairing()
2310 auto device = FindDeviceByAddress(address); in VerifySetMember() local
2315 if (!device) { in VerifySetMember()
2321 auto group_id_to_join = device->GetExpectedGroupIdMember(); in VerifySetMember()
2326 address, device->conn_id, device->GetNumberOfCsisInstances()); in VerifySetMember()
2339 device->SetPairingSirkReadFlag(true); in VerifySetMember()