Lines Matching refs:hearingDevice

351     HearingDevice* hearingDevice = hearingDevices.FindByAddress(address);  in OnGattConnected()  local
352 if (!hearingDevice) { in OnGattConnected()
362 if (!hearingDevice->connecting_actively) { in OnGattConnected()
373 hearingDevice->connecting_actively = false; in OnGattConnected()
374 hearingDevice->conn_id = conn_id; in OnGattConnected()
386 hearingDevice->connection_update_status = STARTED; in OnGattConnected()
387 hearingDevice->requested_connection_interval = in OnGattConnected()
390 hearingDevice->connection_update_status = AWAITING; in OnGattConnected()
437 HearingDevice* hearingDevice = hearingDevices.FindByConnId(conn_id); in OnConnectionUpdateComplete() local
438 if (!hearingDevice) { in OnConnectionUpdateComplete()
446 (hearingDevice->requested_connection_interval == in OnConnectionUpdateComplete()
449 switch (hearingDevice->connection_update_status) { in OnConnectionUpdateComplete()
455 << hearingDevice->requested_connection_interval in OnConnectionUpdateComplete()
458 << hearingDevice->connection_update_status; in OnConnectionUpdateComplete()
460 hearingDevice->connection_update_status = AWAITING; in OnConnectionUpdateComplete()
467 << ", device=" << hearingDevice->address; in OnConnectionUpdateComplete()
468 hearingDevice->connection_update_status = COMPLETED; in OnConnectionUpdateComplete()
473 << hearingDevice->requested_connection_interval in OnConnectionUpdateComplete()
476 << hearingDevice->connection_update_status; in OnConnectionUpdateComplete()
491 send_state_change_to_other_side(hearingDevice, conn_update); in OnConnectionUpdateComplete()
492 send_state_change(hearingDevice, conn_update); in OnConnectionUpdateComplete()
497 << ", device=" << hearingDevice->address in OnConnectionUpdateComplete()
499 << hearingDevice->connection_update_status; in OnConnectionUpdateComplete()
501 if (hearingDevice->connection_update_status == STARTED) { in OnConnectionUpdateComplete()
504 hearingDevice->connection_update_status = AWAITING; in OnConnectionUpdateComplete()
508 hearingDevice->connection_update_status = NONE; in OnConnectionUpdateComplete()
523 HearingDevice* hearingDevice = hearingDevices.FindByAddress(address); in OnReadRssiComplete() local
524 if (!hearingDevice) { in OnReadRssiComplete()
531 if (hearingDevice->read_rssi_count <= 0) { in OnReadRssiComplete()
533 << ", invalid read_rssi_count=" << hearingDevice->read_rssi_count; in OnReadRssiComplete()
537 rssi_log& last_log_set = hearingDevice->audio_stats.rssi_history.back(); in OnReadRssiComplete()
539 if (hearingDevice->read_rssi_count == READ_RSSI_NUM_TRIES) { in OnReadRssiComplete()
546 hearingDevice->read_rssi_count--; in OnReadRssiComplete()
550 HearingDevice* hearingDevice = hearingDevices.FindByAddress(address); in OnEncryptionComplete() local
551 if (!hearingDevice) { in OnEncryptionComplete()
558 BTA_GATTC_Close(hearingDevice->conn_id); in OnEncryptionComplete()
559 if (hearingDevice->first_connection) { in OnEncryptionComplete()
567 if (hearingDevice->audio_control_point_handle && in OnEncryptionComplete()
568 hearingDevice->audio_status_handle && in OnEncryptionComplete()
569 hearingDevice->audio_status_ccc_handle && in OnEncryptionComplete()
570 hearingDevice->volume_handle && hearingDevice->read_psm_handle) { in OnEncryptionComplete()
572 ReadPSM(hearingDevice); in OnEncryptionComplete()
574 hearingDevice->first_connection = true; in OnEncryptionComplete()
575 BTA_GATTC_ServiceSearchRequest(hearingDevice->conn_id, &HEARING_AID_UUID); in OnEncryptionComplete()
580 HearingDevice* hearingDevice = hearingDevices.FindByAddress(address); in OnServiceChangeEvent() local
581 if (!hearingDevice) { in OnServiceChangeEvent()
586 hearingDevice->first_connection = true; in OnServiceChangeEvent()
587 hearingDevice->service_changed_rcvd = true; in OnServiceChangeEvent()
588 BtaGattQueue::Clean(hearingDevice->conn_id); in OnServiceChangeEvent()
589 if (hearingDevice->gap_handle) { in OnServiceChangeEvent()
590 GAP_ConnClose(hearingDevice->gap_handle); in OnServiceChangeEvent()
591 hearingDevice->gap_handle = 0; in OnServiceChangeEvent()
596 HearingDevice* hearingDevice = hearingDevices.FindByAddress(address); in OnServiceDiscDoneEvent() local
597 if (!hearingDevice) { in OnServiceDiscDoneEvent()
601 if (hearingDevice->service_changed_rcvd) { in OnServiceDiscDoneEvent()
602 BTA_GATTC_ServiceSearchRequest(hearingDevice->conn_id, &HEARING_AID_UUID); in OnServiceDiscDoneEvent()
607 HearingDevice* hearingDevice = hearingDevices.FindByConnId(conn_id); in OnServiceSearchComplete() local
608 if (!hearingDevice) { in OnServiceSearchComplete()
614 if (!hearingDevice->first_connection) return; in OnServiceSearchComplete()
619 if (hearingDevice->first_connection) { in OnServiceSearchComplete()
621 hearingDevice->address); in OnServiceSearchComplete()
644 hearingDevice->address); in OnServiceSearchComplete()
651 hearingDevice->address, &hearingDevice->capabilities, in OnServiceSearchComplete()
652 &hearingDevice->hi_sync_id, &hearingDevice->render_delay, in OnServiceSearchComplete()
653 &hearingDevice->preparation_delay, &hearingDevice->codecs)) { in OnServiceSearchComplete()
661 hearingDevice->audio_control_point_handle = charac.value_handle; in OnServiceSearchComplete()
664 hearingDevice->audio_status_handle = charac.value_handle; in OnServiceSearchComplete()
666 hearingDevice->audio_status_ccc_handle = in OnServiceSearchComplete()
668 if (!hearingDevice->audio_status_ccc_handle) { in OnServiceSearchComplete()
675 << ", ccc=" << loghex(hearingDevice->audio_status_ccc_handle); in OnServiceSearchComplete()
677 hearingDevice->volume_handle = charac.value_handle; in OnServiceSearchComplete()
679 hearingDevice->read_psm_handle = charac.value_handle; in OnServiceSearchComplete()
685 if (hearingDevice->service_changed_rcvd) { in OnServiceSearchComplete()
686 hearingDevice->service_changed_rcvd = false; in OnServiceSearchComplete()
689 ReadPSM(hearingDevice); in OnServiceSearchComplete()
692 void ReadPSM(HearingDevice* hearingDevice) { in ReadPSM() argument
693 if (hearingDevice->read_psm_handle) { in ReadPSM()
694 LOG(INFO) << "Reading PSM " << loghex(hearingDevice->read_psm_handle) in ReadPSM()
695 << ", device=" << hearingDevice->address; in ReadPSM()
697 hearingDevice->conn_id, hearingDevice->read_psm_handle, in ReadPSM()
739 HearingDevice* hearingDevice = hearingDevices.FindByConnId(conn_id); in OnReadOnlyPropertiesRead() local
740 if (!hearingDevice) { in OnReadOnlyPropertiesRead()
764 hearingDevice->capabilities = capabilities; in OnReadOnlyPropertiesRead()
774 STREAM_TO_UINT64(hearingDevice->hi_sync_id, p); in OnReadOnlyPropertiesRead()
775 VLOG(2) << __func__ << " hiSyncId: " << loghex(hearingDevice->hi_sync_id); in OnReadOnlyPropertiesRead()
779 STREAM_TO_UINT16(hearingDevice->render_delay, p); in OnReadOnlyPropertiesRead()
781 << " render delay: " << loghex(hearingDevice->render_delay); in OnReadOnlyPropertiesRead()
783 STREAM_TO_UINT16(hearingDevice->preparation_delay, p); in OnReadOnlyPropertiesRead()
785 << loghex(hearingDevice->preparation_delay); in OnReadOnlyPropertiesRead()
789 hearingDevice->codecs = codecs; in OnReadOnlyPropertiesRead()
820 void ChooseCodec(const HearingDevice& hearingDevice) { in ChooseCodec() argument
824 uint16_t codecs = hearingDevice.codecs; in ChooseCodec()
825 if (hearingDevice.hi_sync_id != 0) { in ChooseCodec()
827 if (device.hi_sync_id != hearingDevice.hi_sync_id) continue; in ChooseCodec()
849 HearingDevice* hearingDevice = hearingDevices.FindByConnId(conn_id); in OnPsmRead() local
850 if (!hearingDevice) { in OnPsmRead()
856 LOG(ERROR) << "Error reading PSM for device" << hearingDevice->address; in OnPsmRead()
868 ConnectSocket(hearingDevice, psm); in OnPsmRead()
871 void ConnectSocket(HearingDevice* hearingDevice, uint16_t psm) { in ConnectSocket() argument
874 SendEnableServiceChangedInd(hearingDevice); in ConnectSocket()
876 uint8_t service_id = hearingDevice->isLeft() in ConnectSocket()
880 "", service_id, false, &hearingDevice->address, psm, 514 /* MPS */, in ConnectSocket()
889 hearingDevice->gap_handle = gap_handle; in ConnectSocket()
917 HearingDevice* hearingDevice = hearingDevices.FindByAddress(address); in OnGapConnection() local
918 if (!hearingDevice) { in OnGapConnection()
923 if (hearingDevice->first_connection) { in OnGapConnection()
924 btif_storage_add_hearing_aid(*hearingDevice); in OnGapConnection()
926 hearingDevice->first_connection = false; in OnGapConnection()
930 << loghex(hearingDevice->audio_status_handle) in OnGapConnection()
932 << loghex(hearingDevice->audio_status_ccc_handle); in OnGapConnection()
937 gatt_if, address, hearingDevice->audio_status_handle); in OnGapConnection()
948 hearingDevice->conn_id, hearingDevice->audio_status_ccc_handle, in OnGapConnection()
951 ChooseCodec(*hearingDevice); in OnGapConnection()
953 SendStart(hearingDevice); in OnGapConnection()
959 send_state_change_to_other_side(hearingDevice, inform_conn_state); in OnGapConnection()
962 hearingDevice->accepting_audio = true; in OnGapConnection()
964 << ", hi_sync_id=" << loghex(hearingDevice->hi_sync_id) in OnGapConnection()
968 StartSendingAudio(*hearingDevice); in OnGapConnection()
970 callbacks->OnDeviceAvailable(hearingDevice->capabilities, in OnGapConnection()
971 hearingDevice->hi_sync_id, address); in OnGapConnection()
975 void StartSendingAudio(const HearingDevice& hearingDevice) { in StartSendingAudio() argument
976 VLOG(0) << __func__ << ": device=" << hearingDevice.address; in StartSendingAudio()
983 uint16_t codecs = hearingDevice.codecs; in StartSendingAudio()
984 if (hearingDevice.hi_sync_id != 0) { in StartSendingAudio()
986 if (device.hi_sync_id != hearingDevice.hi_sync_id) continue; in StartSendingAudio()
1002 if (hearingDevice.render_delay != 0) { in StartSendingAudio()
1004 hearingDevice.render_delay + in StartSendingAudio()
1296 HearingDevice* hearingDevice = hearingDevices.FindByGapHandle(gap_handle); in GapCallback() local
1297 if (!hearingDevice) { in GapCallback()
1315 << ": GAP_EVT_CONN_CLOSED: " << hearingDevice->address in GapCallback()
1316 << ", playback_started=" << hearingDevice->playback_started; in GapCallback()
1317 hearingDevice->accepting_audio = false; in GapCallback()
1318 hearingDevice->gap_handle = 0; in GapCallback()
1319 hearingDevice->playback_started = false; in GapCallback()
1320 hearingDevice->command_acked = false; in GapCallback()
1373 << hearingDevice->address << " added" << tmp.credits_received in GapCallback()
1444 HearingDevice* hearingDevice = hearingDevices.FindByAddress(address); in Disconnect() local
1445 if (!hearingDevice) { in Disconnect()
1452 bool connected = hearingDevice->accepting_audio; in Disconnect()
1454 LOG(INFO) << "GAP_EVT_CONN_CLOSED: " << hearingDevice->address in Disconnect()
1455 << ", playback_started=" << hearingDevice->playback_started in Disconnect()
1456 << ", accepting_audio=" << hearingDevice->accepting_audio; in Disconnect()
1458 if (hearingDevice->connecting_actively) { in Disconnect()
1469 send_state_change_to_other_side(hearingDevice, inform_disconn_state); in Disconnect()
1471 DoDisconnectCleanUp(hearingDevice); in Disconnect()
1491 HearingDevice* hearingDevice = hearingDevices.FindByConnId(conn_id); in OnGattDisconnected() local
1492 if (!hearingDevice) { in OnGattDisconnected()
1503 send_state_change_to_other_side(hearingDevice, inform_disconn_state); in OnGattDisconnected()
1505 DoDisconnectCleanUp(hearingDevice); in OnGattDisconnected()
1509 BTA_GATTC_Open(gatt_if, hearingDevice->address, false, GATT_TRANSPORT_LE, in OnGattDisconnected()
1522 void DoDisconnectCleanUp(HearingDevice* hearingDevice) { in DoDisconnectCleanUp() argument
1523 if (hearingDevice->connection_update_status != COMPLETED) { in DoDisconnectCleanUp()
1525 << hearingDevice->connection_update_status in DoDisconnectCleanUp()
1526 << ", device=" << hearingDevice->address; in DoDisconnectCleanUp()
1528 if (hearingDevice->connection_update_status == STARTED) { in DoDisconnectCleanUp()
1529 OnConnectionUpdateComplete(hearingDevice->conn_id, NULL); in DoDisconnectCleanUp()
1532 hearingDevice->connection_update_status = NONE; in DoDisconnectCleanUp()
1534 if (hearingDevice->conn_id) { in DoDisconnectCleanUp()
1535 BtaGattQueue::Clean(hearingDevice->conn_id); in DoDisconnectCleanUp()
1536 BTA_GATTC_Close(hearingDevice->conn_id); in DoDisconnectCleanUp()
1537 hearingDevice->conn_id = 0; in DoDisconnectCleanUp()
1540 if (hearingDevice->gap_handle) { in DoDisconnectCleanUp()
1541 GAP_ConnClose(hearingDevice->gap_handle); in DoDisconnectCleanUp()
1542 hearingDevice->gap_handle = 0; in DoDisconnectCleanUp()
1545 hearingDevice->accepting_audio = false; in DoDisconnectCleanUp()
1546 LOG(INFO) << __func__ << ": device=" << hearingDevice->address in DoDisconnectCleanUp()
1547 << ", playback_started=" << hearingDevice->playback_started; in DoDisconnectCleanUp()
1548 hearingDevice->playback_started = false; in DoDisconnectCleanUp()
1549 hearingDevice->command_acked = false; in DoDisconnectCleanUp()
1599 HearingDevice* hearingDevice = hearingDevices.FindByConnId(conn_id); in find_server_changed_ccc_handle() local
1600 if (!hearingDevice) { in find_server_changed_ccc_handle()
1606 hearingDevice->service_changed_ccc_handle = in find_server_changed_ccc_handle()
1608 if (!hearingDevice->service_changed_ccc_handle) { in find_server_changed_ccc_handle()
1614 << loghex(hearingDevice->service_changed_ccc_handle); in find_server_changed_ccc_handle()