This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why does this particular flag involve an "or" operation?

uint8_t flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED |
                BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

And then when I look up "BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;", I got this:

(BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED)   /**< LE General Discoverable Mode, BR/EDR not supported. */

I'm having a bit of brain stall right now and can't figure it out. I know it's a trick to make the whole thing a "switch" of some sort but really don't know how.

Parents
  • I don't really understand the question, and why you set your flags like this. If using the LE_ONLY flag you implicitly also set BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED.

    #define BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE (0x02) Note that this define does not say LE_ONLY.

    #define BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE (BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED)

    Hence, if you want to set your flag like this, either change it to

    uint8_t flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE

    or

    uint8_t flags = BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED)

  • I forgot to say that I was reading someone else's code. If it were me I wouldn't use the "|" operator like that. My question isn't with the protocol itself, but on the "|" operator, I've seen this use several times before but I didn't really care why or how until now.

Reply Children
No Data
Related