Control Surface stm32
MIDI Control Surface library for Arduino
midi-connection.c
Go to the documentation of this file.
1#ifdef ESP32
2
9#include "logging.h"
10#include "midi-private.h"
11#include "advertising.h"
12
13#include <string.h> // memcpy
14
15#include <esp_gap_ble_api.h>
16
17void midi_handle_connect_event(esp_gatt_if_t gatts_if,
18 esp_ble_gatts_cb_param_t *param) {
19 ESP_LOGI("MIDIBLE",
20 "Connection ID: %d, remote: "
21 "%02x:%02x:%02x:%02x:%02x:%02x:",
22 param->connect.conn_id, param->connect.remote_bda[0],
23 param->connect.remote_bda[1], param->connect.remote_bda[2],
24 param->connect.remote_bda[3], param->connect.remote_bda[4],
25 param->connect.remote_bda[5]);
26
27 midi_set_connection_id(param->connect.conn_id);
28
29 // <?> Why do we need to update the connection parameters?
30 // How are these parameters different from the advertising
31 // parameters?
32
33 // For the IOS system, please reference the apple official documents about
34 // the ble connection parameters restrictions:
35 // https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf
36 // https://developer.apple.com/library/archive/qa/qa1931/_index.html
37
38 esp_ble_conn_update_params_t conn_params;
39 memcpy(conn_params.bda, param->connect.remote_bda, sizeof(esp_bd_addr_t));
40 conn_params.max_int = 0x000C;
41 conn_params.min_int = 0x000C;
42 conn_params.latency = 0;
43 conn_params.timeout = 400; // timeout = 400*10ms = 4s
44 esp_ble_gap_update_conn_params(&conn_params);
45}
46
47void midi_handle_disconnect_event(esp_gatt_if_t gatts_if,
48 esp_ble_gatts_cb_param_t *param) {
49 ESP_LOGI("MIDIBLE", "Disconnect reason: %d", param->disconnect.reason);
50
52
54}
55
56#endif
Advertising the MIDI service for Bluetooth Low Energy.
bool advertising_config(void)
Configure the advertising data, register with the Bluetooth driver.
Declarations of internal functions for the MIDI over BLE system, used in the midi-*....
void midi_handle_disconnect_event(esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
void midi_set_connection_id(uint16_t conn_id)
void midi_handle_connect_event(esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)