|
1 | 1 | #include "pgp_handshake_multi.h" |
2 | 2 |
|
| 3 | +#include "esp_bt_defs.h" |
| 4 | +#include "esp_gap_ble_api.h" |
3 | 5 | #include "esp_log.h" |
4 | 6 | #include "log_tags.h" |
5 | 7 |
|
@@ -79,6 +81,15 @@ int get_cert_state(uint16_t conn_id) { |
79 | 81 | return entry->cert_state; |
80 | 82 | } |
81 | 83 |
|
| 84 | +void set_remote_bda(uint16_t conn_id, esp_bd_addr_t remote_bda) { |
| 85 | + client_state_t* entry = get_or_create_client_state_entry(conn_id); |
| 86 | + if (!entry) { |
| 87 | + ESP_LOGE(HANDSHAKE_TAG, "set_remote_bda: conn_id %d unknown", conn_id); |
| 88 | + return; |
| 89 | + } |
| 90 | + memcpy(entry->remote_bda, remote_bda, sizeof(esp_bd_addr_t)); |
| 91 | +} |
| 92 | + |
82 | 93 | void connection_start(uint16_t conn_id) { |
83 | 94 | active_connections++; |
84 | 95 |
|
@@ -170,3 +181,16 @@ void dump_client_states() { |
170 | 181 | dump_client_state(i, &client_states[i]); |
171 | 182 | } |
172 | 183 | } |
| 184 | + |
| 185 | + |
| 186 | +void reset_client_states() { |
| 187 | + ESP_LOGI(HANDSHAKE_TAG, "active_connections: %d", active_connections); |
| 188 | + for (int i = 0; i < MAX_CONNECTIONS; i++) { |
| 189 | + // make sure it's not an empty slot |
| 190 | + if (conn_id_map[i] != 0xffff) { |
| 191 | + ESP_LOGI(HANDSHAKE_TAG, "disconnecting %d", i); |
| 192 | + esp_ble_gap_disconnect(client_states[i].remote_bda); |
| 193 | + connection_stop(client_states[i].conn_id); |
| 194 | + } |
| 195 | + } |
| 196 | +} |
0 commit comments