5 Replies Latest reply on Oct 31, 2017 7:45 AM by e.pratt_1639216

    Switch between FAST and SLOW adevrtising

    filippo.ambroglini_1700146

      Dear all,

       

      I'm developping a low power beacon based on solar harvesting. I would like to dynamically switch between the SLOW and the FAST advertising based on the energy available on the temporary storage.

       

      I have defined two different value for the following parameter at the configuration phase:

          cyBle_discoveryModeInfo.advParam->advIntvMin = REGVAL_Slow;

          cyBle_discoveryModeInfo.advParam->advIntvMax = REGVAL_Fast;

       

      and I start the advertising in SLOW mode

       

      CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_SLOW);

       

      During the runtime at the end of every becaon transmission using the ADC_Sar i estimate the volatge of the storage with these commands:

       

          int16 res_ADC = 0u;

          ADC_VddConv_Wakeup();

          ADC_VddConv_StartConvert();

          ADC_VddConv_IsEndConversion(ADC_VddConv_WAIT_FOR_RESULT);

          res_ADC = ADC_VddConv_GetResult16(0u);

       

      Then I have defined a cut value and based on this value I would like to swtich among SLOW and FAST with a simple solution like this:

      is_in_fast_advertisement is a global value initialized to false

       

          if(res_ADC>ADC_Cut){

              if(!is_in_fast_advertisement){

                     CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

                     is_in_fast_advertisement=true;

              }

          }else{

              if(is_in_fast_advertisement){

                     CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_SLOW);

                     is_in_fast_advertisement=false;

              }

          }

       

      Unortunately is not working.

       

      Anyone can hep me on find a solutions for this?

       

      Thanks in advances for the support.

       

      Best regards

       

      Filippo