1#if defined(ARDUINO_RASPBERRY_PI_PICO_W) && ENABLE_BLE
15 0x02, BLUETOOTH_DATA_TYPE_FLAGS, 0x06,
17 0x05, BLUETOOTH_DATA_TYPE_SLAVE_CONNECTION_INTERVAL_RANGE, 0x0c, 0x00, 0x0c,
20 0x11, BLUETOOTH_DATA_TYPE_COMPLETE_LIST_OF_128_BIT_SERVICE_CLASS_UUIDS,
21 0x00, 0xc7, 0xc4, 0x4e, 0xe3, 0x6c, 0x51, 0xa7, 0x33, 0x4b, 0xe8, 0xed,
22 0x5a, 0x0e, 0xb8, 0x03};
23static_assert(
sizeof(adv_data) <= LE_ADVERTISING_DATA_SIZE);
24uint8_t adv_rsp_data[LE_ADVERTISING_DATA_SIZE] {
26 0x15, BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME,
28 'C',
'o',
'n',
't',
'r',
'o',
'l',
' ',
'S',
'u',
'r',
'f',
'a',
'c',
'e',
29 ' ',
'M',
'I',
'D',
'I'};
30uint8_t adv_rsp_data_len() {
return adv_rsp_data[0] + 1; }
32void set_adv_connection_interval(uint16_t min_itvl, uint16_t max_itvl) {
33 uint8_t *slave_itvl_range = adv_data + 5;
34 slave_itvl_range[0] = (min_itvl >> 0) & 0xFF;
35 slave_itvl_range[1] = (min_itvl >> 8) & 0xFF;
36 slave_itvl_range[2] = (max_itvl >> 0) & 0xFF;
37 slave_itvl_range[3] = (max_itvl >> 8) & 0xFF;
40void set_adv_name(
const char *name) {
41 auto len = std::min(std::strlen(name),
sizeof(adv_rsp_data) - 2);
42 uint8_t *adv_name_len = adv_rsp_data;
43 uint8_t *adv_name = adv_rsp_data + 2;
44 std::memcpy(adv_name, name, len);
45 *adv_name_len =
static_cast<uint8_t
>(len + 1);
54 uint16_t adv_int_min = 0x0020;
55 uint16_t adv_int_max = 0x0040;
57 bd_addr_t null_addr {};
58 uint8_t channel_map = 0x07;
59 uint8_t filter_policy = 0x00;
60 gap_advertisements_set_params(adv_int_min, adv_int_max, adv_type, 0,
61 null_addr, channel_map, filter_policy);
62 gap_advertisements_set_data(
sizeof(adv_data), adv_data);
63 gap_scan_response_set_data(adv_rsp_data_len(), adv_rsp_data);
64 gap_advertisements_enable(1);
void le_midi_setup_adv(const BLESettings &ble_settings)
Configuration options for the low-level BLE code.
struct BLESettings::@4 connection_interval
Connection intervals as multiples of 1.25 milliseconds (e.g.0x000C = 15 ms).
const char * device_name
Device name (used for advertising)