Skip to content

Commit

Permalink
gatt_wait_count experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
shermp committed Oct 1, 2024
1 parent 4472f7c commit 9a9cf24
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/asha_bt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ static void handle_bt_audio_pending_worker([[maybe_unused]] async_context_t *con
AudioBuffer::Volume vol = audio_buff.get_volume();
bool pcm_is_streaming = audio_buff.pcm_streaming.Load();
for (auto& ha : ha_mgr.hearing_aids) {
if (ha.gatt_wait_count > 0) {
ha.gatt_wait_count--;
continue;
}
switch(ha.state) {
case ServicesDiscovered:
ha.state = DiscoverASHAChars;
Expand Down
2 changes: 2 additions & 0 deletions src/hearing_aid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ void HA::on_l2cap_channel_created(uint8_t status)
if (status != ERROR_CODE_SUCCESS) {
LOG_ERROR("%s: L2CAP CoC failed with status code: 0x%02x", side_str, status);
state = State::ASPNotificationSubscribed;
gatt_wait_count = 1000;
return;
}
LOG_INFO("%s: L2CAP CoC channel created", side_str);
Expand Down Expand Up @@ -390,6 +391,7 @@ void HA::on_gatt_event_query_complete(uint8_t* query_complete_packet)
break;
case SubscribeASPNotification:
set_state(ASPNotificationSubscribed);
gatt_wait_count = 1000;
break;
// If this case is hit, it means the connection attempt probably timed out
case L2Connecting:
Expand Down
2 changes: 2 additions & 0 deletions src/hearing_aid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ class HA
void print_values();
} rop = {};

int gatt_wait_count = 0;

// Pointer to current audio packet
uint8_t* audio_packet = nullptr;

Expand Down

0 comments on commit 9a9cf24

Please sign in to comment.