Nordic BLE only works with NumbericComparison enabled, JustWorks seems broken

We want to turn NumericComparison off. We don’t need it, and JustWorks encryption would be just fine, so long as it bonded and paired with the phone all the same. Trying to turn it off. Can’t seem to get anything working except NumComp turned on.

/**
 * @brief Configuration to enable numeric comparison for authentication.
 *
 * If the configuration is set to 0 and #IOT_BLE_ENABLE_SECURE_CONNECTION is set to 1, then
 * device will use just works pairing.
 */
#ifndef IOT_BLE_ENABLE_NUMERIC_COMPARISON
    #define IOT_BLE_ENABLE_NUMERIC_COMPARISON    ( 0 )
#endif

Using the the latest 202012.00 release, but also at least 202011… Turning off NumericComparison for BLE connection and asking for “Just Works” encryption instead does not work.

The phone will show this with NumbericComparison turned off, it still looks like it’s trying to numerically compare to me:

The code that asserts is this, because the transferControl never sees a “1” published to open the channel.

    if( status != MQTTSuccess )
    {
        LogError( ( "There was a problem initializing the data channel" ) );
        configASSERT( false );

If this code wasn’t here, eventually this will be sent to the console from nordic/…/ports/ble/iot_ble_hal_common_gap.c

18 38687 [BLE] [ERROR][BLE_HAL][38687] Failed to secure connection. Disconnecting.

This is getting more into the Nordic side of things.

Likewise, as I understand it, JustWorks encryption for the Nordic requires in the same common_gap.c file, this is being called as I think it should when the phone is about to be asked to pair.

        case BLE_GAP_EVT_LESC_DHKEY_REQUEST:
            nrf_ble_lesc_request_handler();
            break;

So… SO FAR AS I CAN TELL… Most things seem to be on the right path. But something is wrong. Our device does not have output so NumComp is not for us, and even in development I’d rather turn it off.

We have tested this on a Galaxy S7 (didn’t still show pair, but same error eventually) and an iPhone 11, same issue.

Hi,
To enable just works pairing you need to turn off secure connection (which is on by default) and set I/O type to None (since the board does not support a display type) as below:

#define IOT_BLE_ENABLE_NUMERIC_COMPARISON        ( 0 )
#define IOT_BLE_ENABLE_SECURE_CONNECTION         ( 0 )
#define IOT_BLE_INPUT_OUTPUT                     ( eBTIONone )

Please take a look at this doc on how to enable different types of pairing modes.

Ravi,

Yes, this works perfectly of course! I had a little trouble defining those things in iot_config.h, not wanting to write anything in the “amazon code” at iot_config_defaults.h I was getting redefined errors. Fixed this by bringing iot_config.h into main(), apparently I must have some code somewhere else that breaks the rules and doesn’t bring iot_config in first, somehow getting to iot_config_defaults first.

“Just Works” encryption will be fine for this project. Thanks for your help! Really appreciate it.