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

NRF_ERROR_INVALID_PARAM error code

Hello,

I try to add pairing functionality to my app. Error code NRF_ERROR_INVALID_PARAM occur from the sd_ble_gap_sec_params_reply when i want to read my characteritic.

Characteristic properties: Read & Write : BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM No authentication required for read authentication required for write

on_ble_evt function (main.c)

 case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
    
       
            err_code = sd_ble_gap_sec_params_reply(m_conn_handle,BLE_GAP_SEC_STATUS_SUCCESS,&m_sec_params);
            APP_ERROR_CHECK(err_code);
						
            break;
case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
				{
					
					ble_gatts_rw_authorize_reply_params_t reply;
					memset(&reply, 0, sizeof(ble_gatts_rw_authorize_reply_params_t));
					reply.type = p_ble_evt->evt.gatts_evt.params.authorize_request.type;
					
					//==== Write case ====
					if ( p_ble_evt->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_READ  )
					{
							uint8_t test_buffer[20];							
							
							for(uint8_t i = 0 ; i evt.gatts_evt.params.authorize_request.request.write.len; i++)
									test_buffer[i] = p_ble_evt->evt.gatts_evt.params.authorize_request.request.write.data[i];                                   
							
							// This is a test function. Master will get this error when first byte is not 0x12. 
							if (test_buffer[0] != 0x12)
									reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED;
							
							err_code = sd_ble_gatts_rw_authorize_reply(p_ble_evt->evt.gap_evt.conn_handle, &reply);       
						 APP_ERROR_CHECK(err_code);
					}
					
					//====Read case====
					else if( p_ble_evt->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE  )
					{	
						
							err_code = sd_ble_gatts_rw_authorize_reply(p_ble_evt->evt.gap_evt.conn_handle, &reply);       
							APP_ERROR_CHECK(err_code);
						
					}
				
				}
Parents
  • You don't need to have authorized read and/or write to start pairing. As you can see if you test nrf51-ble-app-lbs with LightBlue, just trying to read one of the characteristics with BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM() is sufficient for iOS to trigger bonding. However, I don't really think this is related to the problem here.

    You don't include the actual parameters you pass here, but are you absolutely certain that you haven't changed any of them?

    There are several checks being done:

    • IO caps has a legal value
    • Minimum key size less than max key size
    • Minimum key size >= 7 and max key size <= 16
    • Timeout == 30 s

    Can you please verify that these are all ok for your case? If you still have problems, can you please supply your complete project, so that I can test it here?

Reply Children
No Data
Related