5 years, 4 months ago.

How to fix MAC Address when Advertising?(NUCLEO- WB55)

Dear.

I use some examples like privacy and SM etc.

but, MAC Address is changed when reseted.

so I found API's for showing PUBLIC MAC Address.

but it is not working.

help me.

CODE:

if (!set_advertising_parameters()) { return; }

if (!set_advertising_data()) { return; } Gap::PeripheralPrivacyConfiguration_t privacy_configuration = { false, Gap::PeripheralPrivacyConfiguration_t::PERFORM_PAIRING_PROCEDURE };

_ble_interface.gap().setPeripheralPrivacyConfiguration(&privacy_configuration);

if (!start_advertising()) { return; }

bool start_advertising(void) { Gap &gap = _ble_interface.gap();

/* Start advertising the set */ print_local_mac_address(); ble_error_t error = gap.startAdvertising(ble::LEGACY_ADVERTISING_HANDLE); 500ms Advertising Duration

if (error) { printf("Error %u during gap.startAdvertising.\r\n", error); return false; } else { printf("Advertising started.\r\n"); return true; } }

bool set_advertising_parameters() { Gap &gap = _ble_interface.gap(); ble::AdvertisingParameters adv_parameters( ble::advertising_type_t::CONNECTABLE_UNDIRECTED );

ble_error_t error = gap.setAdvertisingParameters( ble::LEGACY_ADVERTISING_HANDLE, adv_parameters );

if (error) { printf("Gap::setAdvertisingParameters() failed with error %d", error); return false; }

return true; }

bool set_advertising_data() { Gap &gap = _ble_interface.gap();

/* Use the simple builder to construct the payload; it fails at runtime

  • if there is not enough space left in the buffer */ ble_error_t error = gap.setAdvertisingPayload( ble::LEGACY_ADVERTISING_HANDLE, ble::AdvertisingDataSimpleBuilder<ble::LEGACY_ADVERTISING_MAX_SIZE>() .setFlags() .setName("EthanTEST") .getAdvertisingData() );

if (error) { printf("Gap::setAdvertisingPayload() failed with error %d", error); return false; }

return true; }

Be the first to answer this question.