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

Connecting to nRF Connect app in iPad

Hello,

 

I am using nRF52840, SDK_16.0.0, SoftDevice S140 V7.0.1 and Segger for flashing the image. I am using ‘ble_app_blinky’.

 

Till now we were using nRF Connect app in Android and its working fine. Now we want to do the same with Apple iOS. But we are facing issues. We are refereeing to Apple document “Accessory Design Guidelines.pdf” from below link

https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf

 

1) Initially with below settings it did not work. After changing to the values mentioned in “Accessory Design Guidelines” I am able to connect and able to Read / Write Characteristics.

a) Connection settings.

 

#if APPLE_iOS_COMPATIBLE

  //#define APP_ADV_INTERVAL                64                                  /**< The advertising interval (in units of 0.625 ms; this value corresponds to 40 ms). */
  #define APP_ADV_INTERVAL                1636                                  // 1022.5ms (1639 * 0.625 micoSec)
  
  
  
  #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(990, UNIT_1_25_MS)      // 990ms  : (990 % 15 == 0)                         : "Interval Min modulo 15 ms == 0"
                                                                                // 990ms                                            : "Interval Min =15 ms"
  
  #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(1020, UNIT_1_25_MS)     // 1020ms : (990ms + 15ms <= 1020ms)                : "Interval Min + 15 ms = Interval Max"
                                                                                // 1020ms : (1020ms * (0 + 1)) = 1020ms = 2 seconds : "Interval Max * (Slave Latency + 1) = 2 seconds"
                                                                                // 1020ms : (1020ms * (0 + 1) * 3 = 3060ms < 5000ms : "Interval Max * (Slave Latency + 1) * 3 < connSupervisionTimeout"
  
  #define SLAVE_LATENCY                   0                                     // "Slave Latency =30"
  
  #define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(5000, UNIT_10_MS)       // 5 sec : "2 seconds = connSupervisionTimeout = 6 seconds"
    /* As per standards, “The connSupervisionTimeout shall be a multiple of 10 ms in the range of 100 ms to 32.0 s and it
       shall be larger than (1 + connSlaveLatency) * connInterval * 2.” */

#else

  #define APP_ADV_INTERVAL                1600                                    /**< The advertising interval (in units of 0.625 ms; this value corresponds to 1000 ms). */
  #define APP_ADV_DURATION                BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED   /**< The advertising time-out (in units of seconds). When set to 0, we will never time out. */

  //#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(500, UNIT_1_25_MS)      /**< Minimum acceptable connection interval (0.5 seconds). */
  #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(1000, UNIT_1_25_MS)       /**< Minimum acceptable connection interval (1 seconds). */
  #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(1000, UNIT_1_25_MS)       /**< Maximum acceptable connection interval (1 second). */
  #define SLAVE_LATENCY                   5                                       /**< Slave latency. */
    // As per standards, "connSlaveLatency shall be an integer in the range of 0 to ((connSupervisionTimeout / (connInterval*2)) - 1)" "( (13 / (1 * 2)) - 1)"

  #define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(13000, UNIT_10_MS)        /**< Connection supervisory time-out (13 seconds). */
  /* As per standards, “The connSupervisionTimeout shall be a multiple of 10 ms in the range of 100 ms to 32.0 s and it
     shall be larger than (1 + connSlaveLatency) * connInterval * 2.”  "(1 + 5) * 1 * 2 = 12" < 13 */

#endif

 

b) Security settings.

#if BLE_SECURITY_ENABLED
  #define SEC_PARAM_BOND                0                                       /**< Perform Pairing (non-bonding). */
  
  #define SEC_PARAM_LESC                0                                       /**< LE Secure Connections not enabled. */
  #define SEC_PARAM_KEYPRESS            0                                       /**< Keypress notifications not enabled. */
  
  
  #define SEC_PARAM_OOB                 0                                       /**< Out Of Band data not available. */
  #define SEC_PARAM_MIN_KEY_SIZE        7                                       /**< Minimum encryption key size. */
  #define SEC_PARAM_MAX_KEY_SIZE        16                                      /**< Maximum encryption key size. */
  
  // Static Passkey
  //#define SEC_PARAM_IO_CAPABILITIES     BLE_GAP_IO_CAPS_DISPLAY_ONLY            /**< Display Only. (Static Passkey) */
  //#define SEC_PARAM_MITM                1                                       /**< Man In The Middle protection required. */
  
  //#define STATIC_PASSKEY    "654321"                                          // 6 digit Passkey
  static ble_opt_t    m_static_pin_option;
  //uint8_t passkey[] = STATIC_PASSKEY;
#endif // BLE_SECURITY_ENABLED

 0> 
 0> printf_Blinky
 0> <info> app_timer: RTC: initialized.
 0> <info> app: FDSInit
 0> <info> app: R1 found 10 0
 0> <info> app: R2 found 8
 0> <info> app: MAC UICR: 0xFFFFFF FFFFFF
 0> <info> app: No HON MAC addr
 0> <info> app: Serial UICR: 0xFFFF FFFFFF
 0> <info> app: No HON Serial Num
 0> <info> app: Model UICR: 
 0> <info> app: No HON Model Num
 0> <info> app: Blinky example started.
 0> 
 0> printf_Blinky
 0> <info> app_timer: RTC: initialized.
 0> <info> app: FDSInit
 0> <info> app: R1 found 10 0
 0> <info> app: R2 found 8
 0> <info> app: MAC UICR: 0xFFFFFF FFFFFF
 0> <info> app: No HON MAC addr
 0> <info> app: Serial UICR: 0xFFFF FFFFFF
 0> <info> app: No HON Serial Num
 0> <info> app: Model UICR: 
 0> <info> app: No HON Model Num
 0> <info> app: Blinky example started.
 0> <info> app: Default 16
 0> <info> app: Connected
 0> <debug> nrf_ble_gatt: Peer on connection 0x0 requested an ATT MTU of 185 bytes.
 0> <debug> nrf_ble_gatt: Updating ATT MTU to 23 bytes (desired: 23) on connection 0x0.
 0> <info> app: Default 85
 0> <info> app: 
 0> on_write
 0> <info> app: Beeper OFF!
 0> <info> app: Default 18
 0> <info> app: 
 0> on_write
 0> <info> app: Beeper OFF!		// Vishnu: Able to send commands over BLE
 0> <info> app: 
 0> on_write
 0> <info> app: Beeper ON!
 0> <info> app: Default 17
 0> <info> app: Disconnected	// Vishnu: Intentionally disconnected from nRF app in iPhone

2) But later I enabled security “Just Works”. Here also I am able to connect. But whenever I am trying to read/write secure Characteristic, connection getting lost. Attached sniffer log for reference.

a) I am able to connect with nRF Connect app in Android both with “Just Works” and “Static Passkey” with just pairing without Bonding. Also able to Read / Write Characteristics.

b) How to connect with nRF Connect app in iPhone even with "Just Works" and "Static Passkey".

 

 0> 
 0> printf_Blinky
 0> <info> app_timer: RTC: initialized.
 0> <info> app: FDSInit
 0> <info> app: R1 found 10 0
 0> <info> app: R2 found 8
 0> <info> app: MAC UICR: 0xFFFFFF FFFFFF
 0> <info> app: No HON MAC addr
 0> <info> app: Serial UICR: 0xFFFF FFFFFF
 0> <info> app: No HON Serial Num
 0> <info> app: Model UICR: 
 0> <info> app: No HON Model Num
 0> <info> app: FDSInit
 0> <info> app: Blinky example started.
 0> <info> app: Default 16
 0> <info> app: Connected
 0> <debug> nrf_ble_gatt: Peer on connection 0x0 requested an ATT MTU of 185 bytes.
 0> <debug> nrf_ble_gatt: Updating ATT MTU to 23 bytes (desired: 23) on connection 0x0.
 0> <info> app: Default 85
 0> <info> app: PM 1
 0> <info> app: PM 5
 0> <info> app: Default 19
 0> <info> app: Default 26
 0> <info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 0, procedure: Pairing
 0> <info> app: PM 2
 0> <info> app: Default 25
 0> <info> app: 
 0> on_write
 0> <info> app: Beeper ON!
 0> <info> app: Default 18
 0> <info> app: Default 17
 0> <info> app: Disconnected	// Vishnu: Connection automatically got disconnected.

Connect_with_iPhone_With Security.psd

3) nRF app iPhone version is 2.1.2. Build number 2.1.2. iOS version is 12.1.4.

Thanks & Regards

Vishnu Beema

Parents Reply Children
No Data
Related