Advertising 128 bit UUID for custom service

Hi,

What macro should be used in the bt_data ad struct in order to advertise a custom 128 bit UUID? I have tried the following: BT_UUID_128_ENCODE(BT_UUID_CUSTOM_SERVICE).

Thanks,

Adam

Parents
  • Probably some code snippets that you used might help us see the issue. What kind of errors are you getting?

    The eddystone sample uses below initialization to advertise all of 128 bit UUID, just an example to show you.

    static const struct bt_data ad[] = {
    	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
    	/* Eddystone Service UUID a3c87500-8ed3-4bdf-8a39-a01bebede295 */
    	BT_DATA_BYTES(BT_DATA_UUID128_ALL,
    		      0x95, 0xe2, 0xed, 0xeb, 0x1b, 0xa0, 0x39, 0x8a,
    		      0xdf, 0x4b, 0xd3, 0x8e, 0x00, 0x75, 0xc8, 0xa3),
    };
     

  • Hi Susheel,

    I have attached the relevant code below. I am now getting the following error: too big advertising data. It works perfectly when I leave out the other SIG defined UUIDs. The error probably occurs because I am already advertising three other SIG defined services.

    1. Is there anyway to encode this 128 bit data into a smaller number that can be advertised?

    2. Or would it be a better idea to just include the 128 but UUID in the scan response sd data? If so, I am using the Android nRF Connect app - how do I request scan response data so that I can see the 128 bit UUID.

    3. Any other suggestions?

    4. Also, what is the max size in bits for a legacy advertising packet?

    Thanks so much,

    Adam

    Here is my advertising struct:

    static struct bt_data ad[] = {
    	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
    	BT_DATA_BYTES(BT_DATA_UUID16_ALL,
    		      BT_UUID_16_ENCODE(BT_UUID_HTS_VAL),
    			  BT_UUID_16_ENCODE(BT_UUID_DIS_VAL),
    		      BT_UUID_16_ENCODE(BT_UUID_BAS_VAL)),
    	BT_DATA_BYTES(BT_DATA_UUID128_ALL, RSSI_SERVICE_UUID),
    };

    In my service.h file, I have the following: 

    #define RSSI_SERVICE_UUID 0xb4, 0xa0, 0x76, 0x45, 0xE9, 0x47, 0xC5, \
                                    0x93, 0x9D, 0x9D, 0x03, 0x45, 0x76, 0xA0, 0xB4, 0x49
    In my service.c file, I have the following: 
    #define BT_UUID_RSSI_SERVICE            BT_UUID_DECLARE_128(RSSI_SERVICE_UUID)
  • adam_atmo said:
    2. Or would it be a better idea to just include the 128 but UUID in the scan response sd data? If so, I am using the Android nRF Connect app - how do I request scan response data so that I can see the 128 bit UUID.

    I would suggest you to split this advertising data into advertising data and scan response data. 

    adam_atmo said:
    4. Also, what is the max size in bits for a legacy advertising packet?

    We have 31 bytes of payload data that we can put in advertising or scan response data. So together you can put 31 + 31 = 62 bytes.

  • Thanks.

    How do I request scan response data on Android nRF Connect?

    Adam

  • nRF Connect on mobile on Android by default does active scanning. So it sends the scan request to advertiser by default.

    If you go in the app->Settings->Scanner->you see all the settings for the mobile scanner there.

Reply Children
Related