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

Samsung Galaxy S8 cannot find nRF52 after Directed Advertisement

We have a discovery issue that seemingly only happens with the Samsung Galaxy S8.

We are using the nRF52832 with SoftDevice S132 v2.0.1, and do directed advertisements to the last connected peer when disconnecting. We do not use pairing or bonding. If we connect to a second device, such as an iPhone, and disconnect from the iPhone, the radio goes into fast directed advertising, and if it doesn't find the last connected peer, it goes to fast undirected advertising.

Our problem is that the Samsung Galaxy S8 does not discover the nRF52 after the fast directed advertising mode is over and undirected advertisements starts. We have tried having 4 different brand phones running in parallel with the nRF Go scanner app open, and only on the Galaxy S8 it cannot discover the nRF. If we restart the nRF and start immediately in fast undirected advertisement, the S8 finds the nRF instantly. Also disabling directed advertisements altogether seem to resolve the connectivity issues with the S8, but this seems like a non-solution to me as we are giving up the fast reconnect feature of having directed advertisements.

The problem appears not only with the scanner app, but also when using our own BLE Android application.

Below is the config we are currently passing to the advertising module (SDK 12.3)

#define APP_ADV_INTERVAL_FAST            20 // ms
#define APP_ADV_TIMEOUT_FAST_IN_SECONDS  30 // s

#define APP_ADV_INTERVAL_SLOW            1285 // ms
#define APP_ADV_TIMEOUT_SLOW_IN_SECONDS  BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED

static const ble_adv_modes_config_t options = {
    .ble_adv_whitelist_enabled = false,
    .ble_adv_directed_enabled  = true, // Disable this due to Samsung S8
    .ble_adv_directed_slow_enabled = false,
    .ble_adv_fast_enabled = true,
    .ble_adv_slow_enabled = true,
    .ble_adv_directed_slow_interval = 0,
    .ble_adv_directed_slow_timeout = 0,
    .ble_adv_fast_interval = (uint32_t) MSEC_TO_UNITS(APP_ADV_INTERVAL_FAST, UNIT_0_625_MS),
    .ble_adv_fast_timeout = APP_ADV_TIMEOUT_FAST_IN_SECONDS,
    .ble_adv_slow_interval = (uint32_t) MSEC_TO_UNITS(APP_ADV_INTERVAL_SLOW, UNIT_0_625_MS),
    .ble_adv_slow_timeout = APP_ADV_TIMEOUT_SLOW_IN_SECONDS
};

Are we doing anything wrong from our side, or is this most likely an issue with the BLE stack on the Samsung S8? Regardless, any ideas for fixes or workarounds would be appreciated

Parents
  • Hi,

    I have finally been able to reproduce the problem. For testing I used:

    1. Samsung Galaxy S8 running Android 7.0
    2. Nexus 7 Tablet running Android 6.0
    3. Nexus 5X running Android 8.1
    4. nRF Connect for Mobile
    5. The ble_app_hids_mouse example:
    6. nRF52, SDK 14.2, S132 v5.0.0
    7. nRF52, SDK 12.3, S132 v3.0.0
    8. User @Matej also sees the issue with nRF51, SDK 12.3, S130 v2.0.1

    The steps to reproduce it are:

    1. Start advertising with the ble_app_hids_mouse example.
    2. All Android devices are now able to scan for, and see the hids_mouse peripheral.
    3. Connect to the peripheral with the Nexus 7.
    4. Bond the peripheral and the Nexus 7
    5. Nexus 7 is added to the whitelist in the peripheral
    6. Disconnect Nexus 7 and peripheral
    7. Using the hids_mouse example, the peripheral will now start directed advertising
    8. Shortly after, the peripheral will start normal undirected advertising again
    9. Now the S8 is no longer able to see the peripheral, but the Nexus 7 and 5X still can.
    10. A simple reset of the peripheral is all it takes to fix it.

    Background

    The problem seems to be caused by an obscure corner case triggered by a combination of two things:

    1. A specification violation in the Softdevice
    2. A specification violation in the Samsung Galaxy S7/S8 software, the chipset they use, or a combination of both.

    The following arguments refer to the Bluetooth Core Specification Version 5.0, but also applies to Version 4.x (chapter numbers and phrasing might be different).

    The core of the matter is the RxAdd bit field in the Advertising Channel PDU, and how it is being used in directed and undirected advertising.

    Refer to Vol 6, Part B, Ch 2.3 ADVERTISING CHANNEL PDU:

    image

    The chapter states that:

    The ChSel, TxAdd and RxAdd fields of the advertising channel PDU that are contained in the header contain information specific to the PDU type defined for each advertising channel PDU separately. If the ChSel, TxAdd or RxAdd fields are not defined as used in a given PDU then they shall be considered Reserved for Future Use.

    Vol 6, Part B, Ch 2.3.1.1 ADV_IND (undirected advertising) writes nothing about the RxAdd field, implying that the bit is Reserved For Future Use (RFU).

    Jumping back to the "General Interpretation Rules" in the Bluetooth specification, the chapter Vol 1, Part E, Ch 2.4 RESERVED FOR FUTURE USE (RFU) states that:

    Where a field in a packet, PDU, or other data structure is described as "Reserved for future use" (irrespective of whether in upper or lower case), the device creating the structure shall set it to zero unless otherwise specified. Any device receiving or interpreting the structure shall ignore that field; in particular, it shall not reject the structure because of the value of the field

    Furthermore, Vol 6, Part B, Ch 2.3.1.2 ADV_DIRECT_IND (directed advertising) states that:

    […] The PDU shall be used in connectable directed advertising events. The TxAdd in the advertising channel PDU header indicates whether the advertiser’s address in the AdvA field is public (TxAdd = 0) or random (TxAdd = 1). The RxAdd in the advertising channel PDU header indicates whether the target’s address in the TargetA field is public (RxAdd = 0) or random (RxAdd = 1).

    The “target address” mentioned here is the address of the phone (peer device) that we successfully connected to our peripheral. In our case, the target address is of type ‘Random’ and hence, the RxAdd bit is set to 1.

    So to summarize this:

    • In directed advertising, the RxAdd bit field is used to indicate whether the address of the peer device, which the advertising packet is intended for, is random or public.
    • In undirected advertising, the bit field is not used. It is actually completely irrelevant since no peer address is included in the advertising packet and hence, it is considered “Reserved for Future Use".

    Cause

    Since our phones are able to see the device in one instance, but not the other, I figured that there had to be a difference between the advertising packets. I used a sniffer and found that indeed there is. Before the peripheral does directed advertising the RxAdd bit is 0 according to spec. After I connected, disconnected, did direct advertising, and finally started undirected advertising again, the bit was 1. So what happens is that:

    1. The Softdevice initializes with the RxAdd bit set to 0 according to spec.
    2. The Softdevice starts undirected advertising.
    3. After connecting and disconnecting again, the Softdevice starts directed advertising.
    4. Since the previously connected peer had a random address, the RxAdd bit is set to 1 during the directed advertising.
    5. When the Softdevice finally starts undirected advertising again, it forgets to revert the bit back to 0, violating the spec requirement in Vol 1, Part E, Ch 2.4 RESERVED FOR FUTURE USE (RFU).

    The bug in the Softdevice seems to be present in all three SoftDevices mentioned in this case, but it probably affects other SoftDevice versions too. It is a simple bug, but every change we make to the SoftDevice, however small or significant, has to go through vigorous testing and the stack might need to be requalified. Hence, this is not something we can fix and publish overnight and I cannot make any promises about how long it will take.

    But why does this seemingly only happen with Samsung Galaxy S7 and S8 Phones?

    It seems like these phones also violates the spec requirements in Vol 1, Part E, Ch 2.4 RESERVED FOR FUTURE USE (RFU), by not ignoring the RFU field in undirected advertising packets. The phones probably receive the packets, but chose to filter them out due to the unexpected value in the RxAdd field. Other phones, that correctly ignores the field, can discover and connect just fine, even though there is a spec violation in our Softdevice.

    The common denominator in the case seems to be Samsung Galaxy S7/S8 phones, and Android 7. However, there is no guarantee that the issue is not present in other phones, chipsets, and/or operating systems. It could be interesting to try other Galaxy models or Galaxy S7 and S8 with other Android versions. I do not know, and I am not in a position to find out, whether this is a Samsung Galaxy software issue, a chipset issue, or a combination of both.


    Workaround

    So far, we only see two workarounds:

    1. Easy, but unfortunate: Disable and re-enable the Softdevice after directed advertising.
    2. Complicated, and also unfortunate: If re-enabling the Softdevice is impossible, start directed advertising towards a public dummy address every time after doing directed advertising to a random address. This will set the bit back to 0.

    EDITS:

    Tested Samsung Galaxy S5 with Android 6.0.1 - Works fine.

Reply
  • Hi,

    I have finally been able to reproduce the problem. For testing I used:

    1. Samsung Galaxy S8 running Android 7.0
    2. Nexus 7 Tablet running Android 6.0
    3. Nexus 5X running Android 8.1
    4. nRF Connect for Mobile
    5. The ble_app_hids_mouse example:
    6. nRF52, SDK 14.2, S132 v5.0.0
    7. nRF52, SDK 12.3, S132 v3.0.0
    8. User @Matej also sees the issue with nRF51, SDK 12.3, S130 v2.0.1

    The steps to reproduce it are:

    1. Start advertising with the ble_app_hids_mouse example.
    2. All Android devices are now able to scan for, and see the hids_mouse peripheral.
    3. Connect to the peripheral with the Nexus 7.
    4. Bond the peripheral and the Nexus 7
    5. Nexus 7 is added to the whitelist in the peripheral
    6. Disconnect Nexus 7 and peripheral
    7. Using the hids_mouse example, the peripheral will now start directed advertising
    8. Shortly after, the peripheral will start normal undirected advertising again
    9. Now the S8 is no longer able to see the peripheral, but the Nexus 7 and 5X still can.
    10. A simple reset of the peripheral is all it takes to fix it.

    Background

    The problem seems to be caused by an obscure corner case triggered by a combination of two things:

    1. A specification violation in the Softdevice
    2. A specification violation in the Samsung Galaxy S7/S8 software, the chipset they use, or a combination of both.

    The following arguments refer to the Bluetooth Core Specification Version 5.0, but also applies to Version 4.x (chapter numbers and phrasing might be different).

    The core of the matter is the RxAdd bit field in the Advertising Channel PDU, and how it is being used in directed and undirected advertising.

    Refer to Vol 6, Part B, Ch 2.3 ADVERTISING CHANNEL PDU:

    image

    The chapter states that:

    The ChSel, TxAdd and RxAdd fields of the advertising channel PDU that are contained in the header contain information specific to the PDU type defined for each advertising channel PDU separately. If the ChSel, TxAdd or RxAdd fields are not defined as used in a given PDU then they shall be considered Reserved for Future Use.

    Vol 6, Part B, Ch 2.3.1.1 ADV_IND (undirected advertising) writes nothing about the RxAdd field, implying that the bit is Reserved For Future Use (RFU).

    Jumping back to the "General Interpretation Rules" in the Bluetooth specification, the chapter Vol 1, Part E, Ch 2.4 RESERVED FOR FUTURE USE (RFU) states that:

    Where a field in a packet, PDU, or other data structure is described as "Reserved for future use" (irrespective of whether in upper or lower case), the device creating the structure shall set it to zero unless otherwise specified. Any device receiving or interpreting the structure shall ignore that field; in particular, it shall not reject the structure because of the value of the field

    Furthermore, Vol 6, Part B, Ch 2.3.1.2 ADV_DIRECT_IND (directed advertising) states that:

    […] The PDU shall be used in connectable directed advertising events. The TxAdd in the advertising channel PDU header indicates whether the advertiser’s address in the AdvA field is public (TxAdd = 0) or random (TxAdd = 1). The RxAdd in the advertising channel PDU header indicates whether the target’s address in the TargetA field is public (RxAdd = 0) or random (RxAdd = 1).

    The “target address” mentioned here is the address of the phone (peer device) that we successfully connected to our peripheral. In our case, the target address is of type ‘Random’ and hence, the RxAdd bit is set to 1.

    So to summarize this:

    • In directed advertising, the RxAdd bit field is used to indicate whether the address of the peer device, which the advertising packet is intended for, is random or public.
    • In undirected advertising, the bit field is not used. It is actually completely irrelevant since no peer address is included in the advertising packet and hence, it is considered “Reserved for Future Use".

    Cause

    Since our phones are able to see the device in one instance, but not the other, I figured that there had to be a difference between the advertising packets. I used a sniffer and found that indeed there is. Before the peripheral does directed advertising the RxAdd bit is 0 according to spec. After I connected, disconnected, did direct advertising, and finally started undirected advertising again, the bit was 1. So what happens is that:

    1. The Softdevice initializes with the RxAdd bit set to 0 according to spec.
    2. The Softdevice starts undirected advertising.
    3. After connecting and disconnecting again, the Softdevice starts directed advertising.
    4. Since the previously connected peer had a random address, the RxAdd bit is set to 1 during the directed advertising.
    5. When the Softdevice finally starts undirected advertising again, it forgets to revert the bit back to 0, violating the spec requirement in Vol 1, Part E, Ch 2.4 RESERVED FOR FUTURE USE (RFU).

    The bug in the Softdevice seems to be present in all three SoftDevices mentioned in this case, but it probably affects other SoftDevice versions too. It is a simple bug, but every change we make to the SoftDevice, however small or significant, has to go through vigorous testing and the stack might need to be requalified. Hence, this is not something we can fix and publish overnight and I cannot make any promises about how long it will take.

    But why does this seemingly only happen with Samsung Galaxy S7 and S8 Phones?

    It seems like these phones also violates the spec requirements in Vol 1, Part E, Ch 2.4 RESERVED FOR FUTURE USE (RFU), by not ignoring the RFU field in undirected advertising packets. The phones probably receive the packets, but chose to filter them out due to the unexpected value in the RxAdd field. Other phones, that correctly ignores the field, can discover and connect just fine, even though there is a spec violation in our Softdevice.

    The common denominator in the case seems to be Samsung Galaxy S7/S8 phones, and Android 7. However, there is no guarantee that the issue is not present in other phones, chipsets, and/or operating systems. It could be interesting to try other Galaxy models or Galaxy S7 and S8 with other Android versions. I do not know, and I am not in a position to find out, whether this is a Samsung Galaxy software issue, a chipset issue, or a combination of both.


    Workaround

    So far, we only see two workarounds:

    1. Easy, but unfortunate: Disable and re-enable the Softdevice after directed advertising.
    2. Complicated, and also unfortunate: If re-enabling the Softdevice is impossible, start directed advertising towards a public dummy address every time after doing directed advertising to a random address. This will set the bit back to 0.

    EDITS:

    Tested Samsung Galaxy S5 with Android 6.0.1 - Works fine.

Children
  • @Martin Thank you for detailed explanation! Please let me know when there will be update availabe on that...

    Thank you!

    BR, Matej

  • @Martin, thanks indeed for spending the time to get to get to the bottom of this. Your explanation was very interesting to read as well, thanks for sharing the details with us. Looking forward to an update in future SoftDevices

  • I have the same issue re refusal of the Android phone to connect to the directed advertisement (though it does work when the directed advertisement times out and switches to fast advertising). Wireshark shows that the central's public MAC is correct in the packet (matches that reported by phone), but central just wont connect via the directed advertising packet. Thankfully, after directed advertising times out (1 minute in my case), fast advertising starts and the central then immediately reconnects to the peripheral. I am using SDKV6.0 soft device 132. 

    I had hoped to use directed advertising as a kind of single MAC whitelist, only allowing the previous central the chance to reconnect per power-cycle of my peripheral. Turns out that directed advertising simply is not reliable/predictable enough across a range of devices and thus should not be used. My test device's: Galaxy S7 (android 7.1), Google Nexus 5 (Android 6.0.1) and Samsung Note 8 (Android 8.0)  -->None of these can reconnect to the peripheral using the directed advertising packets. Tested using nRFConnect and also my own App, my App makes a connection direct to the peripheral MAC - no filter is used (I am aware that directed advertising includes only the peripheral and central MAC's and no name, UUID etc).

    Link to my original thread: https://devzone.nordicsemi.com/f/nordic-q-a/39950/directed-advertising---how-to-make-it-work

    'Kenneth' on thread above responded re how to detect from the peripheral whether the central supports directed advertising, which could then be used to choose what to do - but this does not work in my case (single MAC whitelist).

    Basically, don't waste your time (I have spent 2 days on this) - directed advertising does not work correctly across all devices. Use fast advertising and the whitelist module instead. <Sigh>.

    Nigel

Related