7 Replies Latest reply on Sep 22, 2015 6:27 PM by wewu_1392881

    ADV customer defined data issue

    wewu_1392881

      I have see the definition of BLE_ADV_FIELD in bleprofile.h as following:

      typedef PACKED struct

      {

          UINT8 len; //length of field

          UINT8 val; //value of field

          UINT8 data[ADV_LEN_MAX-2]; // This is the data and the biggest one is 31-2 = 29

      } BLE_ADV_FIELD;

      During we define customer information in advertisement packet, whatever how many BLE_ADV_FIELD we defined, the length of all fields should be less than 31 bytes? For example, if I define BLE_ADV_FIELD adv[2], so the data length sum of adv[0].data and adv[1].data should  be no more than 27 bytes exclude four bytes for len and val field, is that right??

        • 2. Re: ADV customer defined data issue
          userc_19497

          That's correct. The sum of the total bytes of the advertisement packets should be less than 31 bytes. However you can use Scan response if you want to advertise more data.

           

          Here's another blog for advertising:

          Advertiser and Scanner

          • 3. Re: ADV customer defined data issue
            wewu_1392881

            Can you explain more about using scan response as we want to advertise more data? Thanks a lot.

            • 4. Re: ADV customer defined data issue
              wewu_1392881

              Further more, as i see some description for the scan response as following:

              The scan response comes with a catch. If scan responses are enabled in a peripheral device, the device has to keep the radio in RX mode after it sent the advertisement to be able to receive the scan request packet. This has to be done even if there is no device out there that will actually send one (because the peripheral doesn’t know who is really out there). This means more energy consumed. For very low power applications, consider disabling the scan response if not absolutely needed.

              can we implement this scan response in WICED SDK for BCM20737S?is this possible for us to implement?

              • 5. Re: ADV customer defined data issue
                BoonT_56

                It is true that the receiver of the peripheral device has to remain "on" so as to get itself ready to receive a scan_req, regardless if there is any. The above is also known as active scanning because the scanner will have to probe actively (sending scan_req) instead of passive listening.

                 

                Refer to userc_19497's blog, under "Starting Advertisement", use blecm_StartAdv to implement this scheme.

                • 6. Re: ADV customer defined data issue
                  userc_19497

                  Yes, you can implement the scan response in WICED SDK.

                  We actually have functions that you can call to easily implement it.

                  The implementation is essentially the same as regular advertisements using the API.

                   

                  Here is an example of manipulating both regular advertisement and scan request.

                  void makeADVData()

                  {

                      // advertise first vendor specific service

                      if(sizeof(tag4_uuid_main_service) > 1)

                      {

                          // Advertisement

                          // total length should be less than 31 bytes

                          BLE_ADV_FIELD adv[2];

                         

                          // Scan Request

                          BLE_ADV_FIELD scr[1];

                   

                          // Advertisement

                          // Flags

                          adv[0].len     = 1 + 1;

                          adv[0].val     = ADV_FLAGS; 

                          adv[0].data[0] = LE_LIMITED_DISCOVERABLE | BR_EDR_NOT_SUPPORTED;

                   

                          // Manufacturer Data & Device Type

                          adv[1].len     = 2 + 1;

                          adv[1].val     = ADV_MANUFACTURER_DATA; // (AD_TYPE == 0xff)

                          adv[1].data[0] = 0x0f;  // Broadcom  (Company Identifier 2 bytes)

                          adv[1].data[1] = 0x00;

                   

                          // Scan request

                          // Name

                          scr[0].len      = strlen(bleprofile_p_cfg->local_name) + 1;

                          scr[0].val      = ADV_LOCAL_NAME_COMP;

                   

                          memcpy(scr[0].data, bleprofile_p_cfg->local_name, scr[0].len - 1);

                   

                          bleprofile_GenerateADVData(adv, 2);

                          bleprofile_GenerateScanRspData(scr, 1);

                      }

                   

                      blecm_setTxPowerInADV(0);

                  } //@end makeADVData

                   

                  Then you can call this function in create function before you start advertising.

                   

                  Let us know if this helped.

                  James

                  • 7. Re: ADV customer defined data issue
                    wewu_1392881

                    It works, thanks a lot.