You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Or is this call meant to start advertising while being already connected?

    Yes, I think it should do that...

    If the latter then why such flag is needed?

    Well what if you want it to not advertise when connected?

    I think not everyone will want setAdvertising to always enable advertising. I can imagine it getting very confusing if they see the device but then can't connect to it because it's already got something connected to it.

    ... also, if the default behaviour changes it may well mess with existing code :)

    it would permit only non connectable mode.

    Yes, that makes sense. It's another reason to have the flag, because without it, calls to setAdvertising that used to work would then throw an exception ('can't advertise as connectable when already connected')

  • Oh, got it. There is no startAdvertising/stopAdvertising and currently NRF.setAdvertising is not a substitute for that. It only sets the data but currently does not affect whether it is on or off. So calling it after being connected may modify the data but does not turn it back on now. That's why the flag is needed. So if it is already off because it is connected the whileConnected:tr­ue would turn it on (and false would turn it off if it was on). That looks sensible.

About

Avatar for Gordon @Gordon started