Bluetooth identity creating in extended advertising

Dear all,

I wanted to modify BTHome template sample for Home Assistant software in order to run enable it to advertise on PHY Coded, there I guess I need to enable extended advertiising via:

err = bt_le_ext_adv_create(&param, NULL, &adv);

It seems I was able to enable extended advertising and Home Assistant sees the devices, but anytime I power up the dongle it pops up is Home Assistant as a device with unique MAC address, so everytime I have to add a new device which is not practical, I need the device to appear in Home assistant as a device which was already added, so I guess the MAC address is the key to et rid of this obstacle.

Following the skilled person, tried to base my solution on this, but it seems not to be based on extended advertising, therefore BT_LE_ADV_OPT_USE_IDENTITY, which is also used in BTHome templeate, works perfectly fine:

devzone.nordicsemi.com/.../427087

 

I was trying to my issue with this with  id = bt_id_create(&static_addr, NULL); before bt_enable(NULL), but whenever I try to set up id parameter to  struct bt_le_adv_param param, param.id = id, the application alwas fails here:  err = bt_le_ext_adv_create(&param, NULL, &adv); with error -22. When I use BT_LE_ADV_OPT_USE_IDENTITY in params this way: struct bt_le_adv_param param =
BT_LE_ADV_PARAM_INIT(BT_LE_ADV_OPT_EXT_ADV |
BT_LE_ADV_OPT_USE_IDENTITY |
BT_LE_ADV_OPT_CODED,
BT_GAP_ADV_SLOW_INT_MIN, \
BT_GAP_ADV_SLOW_INT_MAX, NULL); It is not detected in Home Assistant at all. So I got stuck, probably missing a piece of information. The BTHome template works perfectly fine, but I wanted to enhance with bluetooth 5 extended advertising capability.

My prj.conf:

CONFIG_BT=y
#CONFIG_LOG=y
#CONFIG_BT_SMP=y
#CONFIG_BT_PERIPHERAL=y
#CONFIG_BT_PERIPHERAL=n
#CONFIG_BT_DIS=y
#CONFIG_BT_DIS_PNP=n
#CONFIG_BT_BAS=y
CONFIG_BT_DEVICE_NAME="BTHome template"

#CONFIG_BT_DEVICE_APPEARANCE=768
CONFIG_BT_CTLR_PHY_CODED=y
CONFIG_BT_CTLR_ADV_EXT=y
CONFIG_BT_EXT_ADV=y
#CONFIG_CBPRINTF_FP_SUPPORT=y

#!!new
CONFIG_BT_BROADCASTER=y
CONFIG_BT_PRIVACY=n
#CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
CONFIG_BT_SETTINGS=y

  • Actually I can use BT_LE_ADV_OPT_ANONYMOUS, this works, but then I ran into issues whenever I want to add multiple sensors, they clash as they all are assigned 00:00:00:00:00:00. So I guess the MAC address must be unique as well as fixed, otherwise Home Assistant will not work properly, but I do not know how to achieve this

  • The reason why it doesn't work with extended advertising might also be that there is something missing somewhere. It works slightly differently with extended advertising after all. But then it doesn't immediately make sense to me how you got BT_LE_ADV_OPT_ANONYMOUS working.

    Ivo H said:
    I read that anytime I boot my bluetooth device I see a certain MAC address in usb printk info output at the initialization bt_enable()

    I am not sure if I understood this entire part, but the next part about randomization for privacy is correct. But if you do not need that, that is fine.

    You can have a look at the code I sent below, which seems to me atleast to use the same address each time. You can also change it when needed.

    Regards,

    Elfving

  • Thank you,if  you mean the code you sent in your first reply I guess that is just abbriviationfor this  BT_LE_ADV_PARAM_INIT(BT_LE_ADV_OPT_EXT_ADV |
    BT_LE_ADV_OPT_USE_IDENTITY |
    BT_LE_ADV_OPT_CODED,
    BT_GAP_ADV_SLOW_INT_MIN, \
    BT_GAP_ADV_SLOW_INT_MAX, NULL); 

    Right?

    This I used in my first post and it did not show up in Home Assistant with extended advertising,but anyway  will verify it once more with your NCONN_IDENTITY and double check.

    Anyway,this uses identity,isn't there a way how to omit IDENTITY and make the RPA address fixed?So instead of this:

    BT_LE_EXT_ADV_CODED_NCONN_IDENTITY

    ,we will use this 

    BT_LE_EXT_ADV_CODED_NCONN

    ?

  • Thank you very much for help, but unfortunately, your code with 

    BT_LE_EXT_ADV_CODED_NCONN_IDENTITY

    does not cause the device to be visible in Home Assistant, it is visible in bluetoothctl, but it does not pop up even once in Home Assistant.

    I read it is related to extended_advertising, in legacy, 

    IDENTITY 

    works fine, but in extended, it is different.

Related