7 Replies Latest reply on Nov 4, 2014 5:08 PM by VictorZ_46

    How to change advertisement interval after init?

    jora_1327726

      I have an external source that needs to be able to modify the advertisement rate after the device is up and running.  What's the right way to do this?  All the examples are set-and-forget.

        • 1. Re: How to change advertisement interval after init?
          dmiya

          blecm_startAdv() has a parameter about adv. interval.

          Does it work for you?

          1 of 1 people found this helpful
          • 2. Re: How to change advertisement interval after init?
            jora_1327726

            Yes, and so does blecm_setAdvParam().  The problem is, neither is documented and neither is HOW to do it properly.  Do I stop advertisements first?  What's the difference between enabling advertisements (blecm_setAdvEnable()) and starting them?  I can make educated guesses all day long but in the end I need some input from Broadcom on how to do this correctly.

            • 3. Re: How to change advertisement interval after init?
              ArvindS_76

              > Do I stop advertisements first?

              Yes, you have to stop advertisements before changing parameters if you are already advertising.

               

              blecm_setAdvEnable() will start advertisements using parameters that were set before and maps to LE set advertise enable in section 7.8.9. If parameters were not set, then the default parameters will be used (see section 7.8.5 in Volume 2, part E in the BT spec).

               

              blecm_setAdvParam() will set the advertisement parameters and maps directly to LE Set advertising parameters command described in 7.8.5.

               

              The right sequence is:

               

              1. Stop advertisements in already advertising using blecm_setAdvEnable(0)

              2. Set advertisement parameters using blecm_setAdvParam()

              3. Start advertisements using blecm_setAdvEnable(1)

               

              Advertisement data can be set at any time.

              1 of 1 people found this helpful
              • 4. Re: How to change advertisement interval after init?
                jora_1327726

                Thanks for the spec pointer.  It helped fill in the missing pieces from mybeacon.c.  The needed defines aren't in the SDK and I wasn't sure how the translation from ble_discover_mode (default_adv in the profile config) to BT adv types was being handled.

                 

                Haven't tested yet but hopefully this will help the next person.  Is there any difference between calling setAdvEnable(0), setAdvParam, setAdvEnable(1) and setAdvEnable(0), startAdv()?

                 

                #define HCIULP_ADV_INDIRECT                       0x00
                #define    HCIULP_ADV_DIRECT                         0x01
                #define    HCIULP_ADV_SCANNABLE                      0x02
                #define
                HCIULP_ADV_NONCONNECTABLE0x03
                #define HCIULP_ADV_CHANNEL_37                     0x01
                #define HCIULP_ADV_CHANNEL_38                     0x02
                #define HCIULP_ADV_CHANNEL_39                     0x04
                #define HCIULP_ADV_CHANNEL_MAP_MASK               (HCIULP_ADV_CHANNEL_37 | HCIULP_ADV_CHANNEL_38 | HCIULP_ADV_CHANNEL_39)
                #define HCIULP_PUBLIC_ADDRESS                     0x00
                #define HCIULP_ADV_FILTER_POLICY_WHITE_LIST_NOT_USED 
                0x00

                 

                void update_adv_interval(UINT32 seconds)

                {

                   INT32 interval = (seconds* 1000 * 1000) / 625;

                    blecm_setAdvEnable(0);

                    blecm_setAdvParam(interval,

                                      HCIULP_ADV_INDIRECT,

                                      HCIULP_PUBLIC_ADDRESS,

                                      HCIULP_ADV_CHANNEL_MAP_MASK,

                                      HCIULP_ADV_FILTER_POLICY_WHITE_LIST_NOT_USED,

                                      HCIULP_PUBLIC_ADDRESS,

                                      NULL);

                    setAdvEnable(1);

                }

                • 5. Re: How to change advertisement interval after init?
                  mamec_1509466

                  It is still not clear to me exactly which advertising values in the init config

                  are being changed by function calls.

                   

                  a) blecm_setAdvParam has an interval argument, but is this for changing high, low or just the current setting?

                  b) there does not seem to be a function call for changing duration

                  c) is tx_power_level in config struct for advertising, connection or both?

                   

                   

                  StaticDynamic
                  BLE_PROFILE_CFGUnits
                  high_undirect_adv_interval slotsslotsblecm_setAdvParam(interval, ...?
                  low_undirect_adv_interval slotsslotsblecm_setAdvParam(interval, ...?
                  high_undirect_adv_durationseconds?
                  low_undirect_adv_durationseconds?
                  tx_power_leveldbmblecm_setTxPowerInConnection(power_level)
                  Or
                  blecm_setTxPowerInADV(power_level)?
                  • 6. Re: How to change advertisement interval after init?
                    MichaelF_56

                    I'll ask one of the developers to respond to your inquiry.

                    • 7. Re: How to change advertisement interval after init?
                      VictorZ_46

                      The variables in the BLE_PROFILE_CGS are used when application uses higher level API - bleprofile_Discoverable.  For example if application calls bleprofile_Discoverable(HIGH_UNDIRECTED_DISCOVERABLE, NULL) stack will start advertisements (actually using blecm_startAdv call) with high_undirecter_adv_interval interval.

                       

                      The stack will run a little advertisement state machine.  When you start high duty advertisements it will run for high_undirect_adv_duration seconds, after that stack will automatically switches to low duty advertisements and runs for low_undirect_adv_duration.  After that advertisements will be stopped.  There is a callback back to the application so you can restart advertisements if you need to stay connectable all the time.

                       

                      The tx_power_level in the configuration is used during connection.  You can use blecm_setTxPowerInADV to set tx power during advertisements.

                      1 of 1 people found this helpful