An advertisement data that contains manufacturing data

Hi 

As shown in the title, I want to add manufacturing data(BT_DATA_MANUFACTURER_DATA) to the advertisement data.

The *.conf seems to only define the device name...

I want to be able to  modify manufacturing data dynamically. 

let me know if anything I need to change, thanks!

OS: windows 10
Hardware used: nrf5340 dk
example:C:\ncs\v2.5.1\nrf\samples\matter\lock

Parents
  • Hello,

    By dynamically, I assume you mean during runtime?

    If so, you can have a look at this little side project I did once.

    In main.c I only used the function simple_ad_start(), which is defined in the file remote.c.

    It is a bit messy, but I hope it may give an idea for you to start with.

    Best regards,

    Edvin

  • Hi Edvin

    The problem I am currently encountering is that the advertisement data of matter cannot be accompanied by manufacturing data.

    when I turn on the discoverable over Bluetooth LE(Matter), the manufacturing data were disappeared

    The dynamically changing advertisement data part should have been completed, but it seems that only work with "general" BLE broadcasts

    void Sunion::BleService::SetManufData(uint8_t *buff)
    {
    	int err = 0;
        bt_le_adv_param advParams;
        advParams.id           = BT_ID_DEFAULT;
        advParams.options      = BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME;
        advParams.interval_min = mAdvertisingRequest.minInterval;
        advParams.interval_max = mAdvertisingRequest.maxInterval;
    
    	const bt_data scanResponseData[]    = { BT_DATA(BT_DATA_UUID128_ALL, kBTUuid, sizeof(kBTUuid)) };
    	const bt_data * scanResponseDataPtr = sizeof(kBTUuid) > 0 ? scanResponseData : nullptr;
    	const size_t scanResponseDataLen    = sizeof(kBTUuid) > 0 ? sizeof(scanResponseData) / sizeof(scanResponseData[0]) : 0u;
    
    	const char *name = bt_get_name();
        const bt_data advertisingData[] = { BT_DATA(BT_DATA_FLAGS, &kAdvertisingFlags, sizeof(kAdvertisingFlags)),
                                            BT_DATA(BT_DATA_NAME_COMPLETE, name, strlen(CONFIG_BT_DEVICE_NAME)),
    										BT_DATA(BT_DATA_MANUFACTURER_DATA, buff, 12) };
    
    
        // Restart advertising
        err = bt_le_adv_stop();
        // VerifyOrReturnError(err == 0, MapErrorZephyr(err));
    
        err = bt_le_adv_start(&advParams, advertisingData, sizeof(advertisingData) / sizeof(advertisingData[0]), scanResponseDataPtr,
                              scanResponseDataLen);
    }

  • Hi Edvin

    I can understand your reply, but I'm not sure that PrepareAdvertisingRequest()  is allowed to be modified.

  • As I see it, you have two options.

    1: Advertise with your custom data only whenever you are not advertising your Matter services (so when your Matter service advertising data times out, or stops due to another reason, like a connection or something).

    2: Modify modules\lib\matter\src\platform\Zephyr\BLEmanagerImpl.cpp and add more data to the advertising data used during the Matter service advertising. 

    These are the two options that our Matter team provided. 

    If neither of these are suitable, you would need to implement something that alternates advertising with the Matter service and your custom advertisements. You can look at the ncs\nrf\samples\bluetooth\multiple_adv_sets for reference. However I am not sure exactly how to do that, since the advertising of the matter stack seems to be quite far down in the stack, so it will be difficult to do without changing anything in the Matter files.

    Best regards,
    Edvin

  • Hi Edvin

    thank you for your informationI used option 1 and sure it works.

    In addition, I expect that the BLE peripheral(nus) can connect to multiple devices at any point in time.

    But when I restarted the Advertising, it failed.

    example:C:\ncs\v2.5.1\nrf\samples\matter\lock

  • The problem has been solved. If there is any mistake in my method, please tell me.

    Just add CONFIG_BT_MAX_CONN in multiprotocol_rpmsg and set the value to 2.

    The device advertises after I connect to the device.

  • Hello,

    I am glad to hear that you figured it out. 

    I just want to mention that there are separate configs for peripheral and central connections. As long as you only support peripheral connections, then CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT will determine how many peripheral connections you can have. This will default to 1 if CONFIG_BT_CENTRAL is enabled.

    Best regards,

    Edvin

Reply
  • Hello,

    I am glad to hear that you figured it out. 

    I just want to mention that there are separate configs for peripheral and central connections. As long as you only support peripheral connections, then CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT will determine how many peripheral connections you can have. This will default to 1 if CONFIG_BT_CENTRAL is enabled.

    Best regards,

    Edvin

Children
Related