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 Reply Children
No Data
Related