This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2540: Disabling connectable advertising

Hi

I'm hoping to try the multirole Peripheral/Broadcaster role. Specifically, turn off connectable advertising for a peripheral. Could I simply add the line

      uint8 connEnabled = FALSE;
      GAPRole_SetParameter( GAPROLE_ADV_NONCONN_ENABLED, sizeof( uint8 ), &connEnabled );

in SimpleBLEPeripheral's SimpleBLEPeripheral_Init() function to disable connectability? But this won't change the PDU Type - right? Does anyone know how to change the PDU Type to one of NONCONN?

Thanks

Steve

  • Do you want to just use it as a broadcaster or you want to have it as connected to a Master also broadcasting in the same time?

    Also

    GAPRole_SetParameter( GAPROLE_ADV_NONCONN_ENABLED, sizeof( uint8 ), &connEnabled );

    is for non-connectable event.

    This one is for connectable advertising

      GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );

  • Hi

    I'm hoping to basically allow run-time switching between peripheral and broadcaster roles. If my understanding is correct, SimpleBLEPeripheral implements the Peripheral/Broadcaster multirole profile.

    Doesn't setting GAPROLE_ADVERT_ENABLED to FALSE disable advertising completely (rather than changing the PDU Type)? According to the doc

    GAPROLE_ADVERT_ENABLED Enable and disable advertising. Default is TRUE = enabled.

    For a Peripheral to be a Broadcaster, I'd like it to continue advertising but with PDU set to a NONCONN type.

    Thanks
  • Then all you need to do is adding the pre-define symbol "PLUS_BROADCASTER" to the project, then you will be able to run it as connectable advertising and non-connectable advertising during run time.
  • Setting PLUS_BROADCASTER will need SBP_ADV_IN_CONNECTION_EV set too. It's not clear what it is and I can't seem to find it used much elsewhere. The only place I've found it used (MiniBeacon.h) has it set to 0x04. What is this symbol supposed to represent and how come 0x04 is an appropriate value?

    If my reading is correct, running it as PLUS_BROADCASTER will only turn on advertising whilst in a connection. Enabling/disabling connectability will still need to be managed separately. So, back to my original question: what's the right way to disabling connectability?


    Thanks

  • can you re-word what you want? I am not really sure if I follow.

    operating as a connectable device first and switch to non connectable after a while?

    For enable/disable for connectable

    uint8_t advState;

    advState = TRUE; // enable

    advState= FALSE; // disable

    GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),  &advState);

    This line can be set at any point of your program.

    Same goes for enable/disable for non-connectable

    GAPRole_SetParameter(GAPROLE_ADV_NONCONN_ENABLED, sizeof(uint8_t),  &advState);

  • Hi Christin

    Sure. Basically I'm hoping to dynamically switch between connectable (peripheral) and non-connectable (broadcaster) modes. Indeed there's the multirole peripheral/broadcaster multirole profile, but it seems that SimpleBLEPeripheral only switches on advertising whilst in a connection if the PLUS_BROADCASTER flag is set. It doesn't perform switching between connectable and non-connectable modes, i.e. between peripheral and broadcaster equivalent profiles.

    From an old version of the SWRU271, it states:

    The peripheral / broadcaster multi-role profile operates almost identically to the peripheral role profile; however it provides additional functionality allowing the device to operate in both the peripheral and broadcaster GAP roles simultaneously

    [snip]

    This allows the developer to take a single-role application and add multi-role support with minimal changes to the existing source code.

    It's not quite clear how the multi-role functionality could be utilised. I'm guessing P/B multirole should be designed to address scenarios like mine (switching between P and B), but how should connectability be disabled/re-enabled at run-time?

    Thanks
  • Sorry, I'm confused. Doesn't setting GAPROLE_ADVERT_ENABLED to FALSE completely disable advertising rather than disabling for connectable? The doc says "Enable and disable advertising." and indeed I don't get any advertising packets when it is set to FALSE.

    I'm hoping to continue advertising (broadcasting) but not let the device be connectable. That is, to switch from peripheral to broadcaster (and back).

    Thanks
    Steve

  • Sorry, I'm confused. Doesn't setting GAPROLE_ADVERT_ENABLED to FALSE completely disable advertising rather than disabling for connectable? 

    as a BLE device, you have 5 states, in order to make a connection, peripheral device needs to advertising as a connectable device then the Master(your phone) will scan and initialize connect request. So once you turn off advertising, or advertising as non-connectable device, then there is no way to connect.

    if you set it to false, then it's turned off. When you set it to true, then it will be on and advertising.

    GAPROLE_ADVERT_ENABLED--> means it's a connectable

    GAPROLE_ADV_NONCONN_ENABLED--> device will be not connectable.

    if you want to switch it back and forth based on some condition, then just add a if in the program to make it what you want.

    I would recommend you to go thru our software developer's guide and try out.

  • Hi Christin

    Yes, I understand all that. OK, let me try to break out from this circle. My understanding is that setting GAPROLE_ADVERT_ENABLED to FALSE completely disables advertising. Setting it to TRUE *does not* mean it's a connectable as you suggested - it only means that advertising is enabled (as the param name hints). Even SimpleBLEBroadcaster has it set to TRUE and it is *not* a connectable.

    That is in fact also stated in your software developer's guide B.2.

    AFAIK, PDU type in a packet announces connectability. So, back to my original issue, adding the following to the init function of SImpleBLEPeripheral does not change the PDU type from a connectable one to a non-connectable one:

    uint8 connEnable = TRUE;
    GAPRole_SetParameter(GAPROLE_ADV_NONCONN_ENABLED, sizeof( connEnable ), &connEnable);

    I was expecting the PDU type to be changed to ADV_NON_CONN_IND (0x02), but it remains to be ADV_IND. Does GAPROLE_ADV_EVENT_TYPE or some other params need to be updated as well?

    Thanks

    EDIT: I think I've figured out the solution: GAPROLE_ADV_EVENT_TYPE is needed to be of a non-conn type.

  • yes, by changing this parameter gapRole_AdvEventType, you can toggle between non-connectable and connectable.